Model/GlobalConfig.ps1

#
# SMServer V6
# Syncplify Server! REST API
# Version: 1.0.0
# Generated by OpenAPI Generator: https://openapi-generator.tech
#

<#
.SYNOPSIS

No summary available.

.DESCRIPTION

No description available.

.PARAMETER Id
always ""global"" (forced by code)
.PARAMETER SmtpConf
No description available.
.PARAMETER LogConf
No description available.
.PARAMETER SecurityConf
No description available.
.PARAMETER CorsConf
No description available.
.PARAMETER JwtLifeSpan
JWT lifespan as minutes. This field is required when adding a new config and must be > 0
.PARAMETER JwtAutoRefresh
No description available.
.PARAMETER JwtAutoRefreshMaxTimes
No description available.
.OUTPUTS

GlobalConfig<PSCustomObject>
#>


function Initialize-SS6GlobalConfig {
    [CmdletBinding()]
    Param (
        [Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Id},
        [Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${SmtpConf},
        [Parameter(Position = 2, ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${LogConf},
        [Parameter(Position = 3, ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${SecurityConf},
        [Parameter(Position = 4, ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${CorsConf},
        [Parameter(Position = 5, ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${JwtLifeSpan},
        [Parameter(Position = 6, ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Boolean]]
        ${JwtAutoRefresh},
        [Parameter(Position = 7, ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${JwtAutoRefreshMaxTimes}
    )

    Process {
        'Creating PSCustomObject: SS6AdminModule => SS6GlobalConfig' | Write-Debug
        $PSBoundParameters | Out-DebugParameter | Write-Debug


        $PSO = [PSCustomObject]@{
            "id" = ${Id}
            "smtpConf" = ${SmtpConf}
            "logConf" = ${LogConf}
            "securityConf" = ${SecurityConf}
            "corsConf" = ${CorsConf}
            "jwtLifeSpan" = ${JwtLifeSpan}
            "jwtAutoRefresh" = ${JwtAutoRefresh}
            "jwtAutoRefreshMaxTimes" = ${JwtAutoRefreshMaxTimes}
        }


        return $PSO
    }
}

<#
.SYNOPSIS

Convert from JSON to GlobalConfig<PSCustomObject>

.DESCRIPTION

Convert from JSON to GlobalConfig<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

GlobalConfig<PSCustomObject>
#>

function ConvertFrom-SS6JsonToGlobalConfig {
    Param(
        [AllowEmptyString()]
        [string]$Json
    )

    Process {
        'Converting JSON to PSCustomObject: SS6AdminModule => SS6GlobalConfig' | Write-Debug
        $PSBoundParameters | Out-DebugParameter | Write-Debug

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in SS6GlobalConfig
        $AllProperties = ("id", "smtpConf", "logConf", "securityConf", "corsConf", "jwtLifeSpan", "jwtAutoRefresh", "jwtAutoRefreshMaxTimes")
        foreach ($name in $JsonParameters.PsObject.Properties.Name) {
            if (!($AllProperties.Contains($name))) {
                throw "Error! JSON key '$name' not found in the properties: $($AllProperties)"
            }
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "id"))) { #optional property not found
            $Id = $null
        } else {
            $Id = $JsonParameters.PSobject.Properties["id"].value
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "smtpConf"))) { #optional property not found
            $SmtpConf = $null
        } else {
            $SmtpConf = $JsonParameters.PSobject.Properties["smtpConf"].value
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "logConf"))) { #optional property not found
            $LogConf = $null
        } else {
            $LogConf = $JsonParameters.PSobject.Properties["logConf"].value
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "securityConf"))) { #optional property not found
            $SecurityConf = $null
        } else {
            $SecurityConf = $JsonParameters.PSobject.Properties["securityConf"].value
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "corsConf"))) { #optional property not found
            $CorsConf = $null
        } else {
            $CorsConf = $JsonParameters.PSobject.Properties["corsConf"].value
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "jwtLifeSpan"))) { #optional property not found
            $JwtLifeSpan = $null
        } else {
            $JwtLifeSpan = $JsonParameters.PSobject.Properties["jwtLifeSpan"].value
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "jwtAutoRefresh"))) { #optional property not found
            $JwtAutoRefresh = $null
        } else {
            $JwtAutoRefresh = $JsonParameters.PSobject.Properties["jwtAutoRefresh"].value
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "jwtAutoRefreshMaxTimes"))) { #optional property not found
            $JwtAutoRefreshMaxTimes = $null
        } else {
            $JwtAutoRefreshMaxTimes = $JsonParameters.PSobject.Properties["jwtAutoRefreshMaxTimes"].value
        }

        $PSO = [PSCustomObject]@{
            "id" = ${Id}
            "smtpConf" = ${SmtpConf}
            "logConf" = ${LogConf}
            "securityConf" = ${SecurityConf}
            "corsConf" = ${CorsConf}
            "jwtLifeSpan" = ${JwtLifeSpan}
            "jwtAutoRefresh" = ${JwtAutoRefresh}
            "jwtAutoRefreshMaxTimes" = ${JwtAutoRefreshMaxTimes}
        }

        return $PSO
    }

}