Model/Binding.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 Service
No description available.
.PARAMETER IpVersion
No description available.
.PARAMETER Ip
This is the IP v4/v6 the service will try bind to. Empty means all the available IP addresses
.PARAMETER Port
The port this service will bind to. This field is required
.PARAMETER HostName
Optional host name related to this binding (useful for web-based sharing functionality)
.PARAMETER BehindHaProxy
This particular binding must expect the HAProxy header in the first packet
.PARAMETER DataPort
The data port this service will bindto. Only valid for FTP protocol
.PARAMETER PortRangeMin
The lower limit of the port range for passive FTP dynamic ports
.PARAMETER PortRangeMax
The upper limit of the port range for passive FTP dynamic ports
.OUTPUTS

Binding<PSCustomObject>
#>


function Initialize-SS6Binding {
    [CmdletBinding()]
    Param (
        [Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${Service},
        [Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${IpVersion},
        [Parameter(Position = 2, ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Ip},
        [Parameter(Position = 3, ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${Port},
        [Parameter(Position = 4, ValueFromPipelineByPropertyName = $true)]
        [String]
        ${HostName},
        [Parameter(Position = 5, ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Boolean]]
        ${BehindHaProxy},
        [Parameter(Position = 6, ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${DataPort},
        [Parameter(Position = 7, ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${PortRangeMin},
        [Parameter(Position = 8, ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${PortRangeMax}
    )

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

        if ($Port -and $Port -gt 65535) {
          throw "invalid value for 'Port', must be smaller than or equal to 65535."
        }

        if ($Port -and $Port -lt 1) {
          throw "invalid value for 'Port', must be greater than or equal to 1."
        }

        if ($DataPort -and $DataPort -gt 65535) {
          throw "invalid value for 'DataPort', must be smaller than or equal to 65535."
        }

        if ($DataPort -and $DataPort -lt 1) {
          throw "invalid value for 'DataPort', must be greater than or equal to 1."
        }

        if ($PortRangeMin -and $PortRangeMin -gt 65535) {
          throw "invalid value for 'PortRangeMin', must be smaller than or equal to 65535."
        }

        if ($PortRangeMin -and $PortRangeMin -lt 1) {
          throw "invalid value for 'PortRangeMin', must be greater than or equal to 1."
        }

        if ($PortRangeMax -and $PortRangeMax -gt 65535) {
          throw "invalid value for 'PortRangeMax', must be smaller than or equal to 65535."
        }

        if ($PortRangeMax -and $PortRangeMax -lt 1) {
          throw "invalid value for 'PortRangeMax', must be greater than or equal to 1."
        }


        $PSO = [PSCustomObject]@{
            "service" = ${Service}
            "ipVersion" = ${IpVersion}
            "ip" = ${Ip}
            "port" = ${Port}
            "hostName" = ${HostName}
            "behindHaProxy" = ${BehindHaProxy}
            "dataPort" = ${DataPort}
            "portRangeMin" = ${PortRangeMin}
            "portRangeMax" = ${PortRangeMax}
        }


        return $PSO
    }
}

<#
.SYNOPSIS

Convert from JSON to Binding<PSCustomObject>

.DESCRIPTION

Convert from JSON to Binding<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

Binding<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in SS6Binding
        $AllProperties = ("service", "ipVersion", "ip", "port", "hostName", "behindHaProxy", "dataPort", "portRangeMin", "portRangeMax")
        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 "service"))) { #optional property not found
            $Service = $null
        } else {
            $Service = $JsonParameters.PSobject.Properties["service"].value
        }

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

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

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

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

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

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

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

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

        $PSO = [PSCustomObject]@{
            "service" = ${Service}
            "ipVersion" = ${IpVersion}
            "ip" = ${Ip}
            "port" = ${Port}
            "hostName" = ${HostName}
            "behindHaProxy" = ${BehindHaProxy}
            "dataPort" = ${DataPort}
            "portRangeMin" = ${PortRangeMin}
            "portRangeMax" = ${PortRangeMax}
        }

        return $PSO
    }

}