Model/SrvConfig.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
virtual site short-name, ex default. This field cannot be changed
.PARAMETER MaxConn
maximum number of concurrent client connections (hard limit, regardless of anything else). 0 means no limit. Cannot be < 0
.PARAMETER MaxConnPerClient
maximum number of connections each client can perform simultaneously. 0 means no limit. Cannot be < 0
.PARAMETER MaxConnPerUser
maximum number of connections each user profile can perform simultaneously (can be overridden at user level). 0 means no limit. Cannot be < 0
.PARAMETER ConnDelaySecs
Anti-hammering delay enforced upon accepting any new incoming client connection. Cannot be < 0
.PARAMETER IdleTimeoutMinutes
Number of minutes after which an idle client session will be forcefully terminated. 0 means no timeout. Cannot be < 0
.PARAMETER ProtectorTimeWindowMin
Time window (in minutes) that Protector will count client errors for potential kicking/blocking. Must be > 0
.PARAMETER ProtectorErrThreshold
Number of errors that will get a client kicked/blocked if detected within the above TimeWindow. Must be > 0
.PARAMETER ProtectorBanForMin
Once Protector determines a client needs to be blocked, it will block it (prevent from connecting) for these many minutes. Must be > 0
.PARAMETER ProtectorBehavior
No description available.
.PARAMETER ProtectorCompoundIncr
0-100, how much Protector should increment the ban time if an already-bannec client tries to connect again
.PARAMETER PassComplexity
No description available.
.PARAMETER SafeList
A list of IPv4/6 and networks that Protector will never kick/block, regardless of what they do
.PARAMETER AllowList
If empty, any client can connect; if populated, only clients from these IPs and networks can connect
.PARAMETER FtpConf
No description available.
.PARAMETER SshConf
No description available.
.PARAMETER HttpConf
No description available.
.PARAMETER SpeedLimits
List of various speed limits to be appied to dofferent client IPs and networks
.PARAMETER EventHandlers
List of global (server-wide) event handlers
.PARAMETER SmtpConf
No description available.
.PARAMETER LogConf
No description available.
.PARAMETER QuotaTtl
Refresh VFS quotas every not-less-than this number of seconds
.OUTPUTS

SrvConfig<PSCustomObject>
#>


function Initialize-SS6SrvConfig {
    [CmdletBinding()]
    Param (
        [Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Id},
        [Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${MaxConn},
        [Parameter(Position = 2, ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${MaxConnPerClient},
        [Parameter(Position = 3, ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${MaxConnPerUser},
        [Parameter(Position = 4, ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Double]]
        ${ConnDelaySecs},
        [Parameter(Position = 5, ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${IdleTimeoutMinutes},
        [Parameter(Position = 6, ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${ProtectorTimeWindowMin},
        [Parameter(Position = 7, ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${ProtectorErrThreshold},
        [Parameter(Position = 8, ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${ProtectorBanForMin},
        [Parameter(Position = 9, ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${ProtectorBehavior},
        [Parameter(Position = 10, ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${ProtectorCompoundIncr},
        [Parameter(Position = 11, ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${PassComplexity},
        [Parameter(Position = 12, ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject[]]
        ${SafeList},
        [Parameter(Position = 13, ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject[]]
        ${AllowList},
        [Parameter(Position = 14, ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${FtpConf},
        [Parameter(Position = 15, ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${SshConf},
        [Parameter(Position = 16, ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${HttpConf},
        [Parameter(Position = 17, ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject[]]
        ${SpeedLimits},
        [Parameter(Position = 18, ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject[]]
        ${EventHandlers},
        [Parameter(Position = 19, ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${SmtpConf},
        [Parameter(Position = 20, ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${LogConf},
        [Parameter(Position = 21, ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${QuotaTtl}
    )

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

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

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

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


        $PSO = [PSCustomObject]@{
            "id" = ${Id}
            "maxConn" = ${MaxConn}
            "maxConnPerClient" = ${MaxConnPerClient}
            "maxConnPerUser" = ${MaxConnPerUser}
            "connDelaySecs" = ${ConnDelaySecs}
            "idleTimeoutMinutes" = ${IdleTimeoutMinutes}
            "protectorTimeWindowMin" = ${ProtectorTimeWindowMin}
            "protectorErrThreshold" = ${ProtectorErrThreshold}
            "protectorBanForMin" = ${ProtectorBanForMin}
            "ProtectorBehavior" = ${ProtectorBehavior}
            "protectorCompoundIncr" = ${ProtectorCompoundIncr}
            "passComplexity" = ${PassComplexity}
            "safeList" = ${SafeList}
            "allowList" = ${AllowList}
            "ftpConf" = ${FtpConf}
            "sshConf" = ${SshConf}
            "httpConf" = ${HttpConf}
            "speedLimits" = ${SpeedLimits}
            "eventHandlers" = ${EventHandlers}
            "smtpConf" = ${SmtpConf}
            "logConf" = ${LogConf}
            "quotaTtl" = ${QuotaTtl}
        }


        return $PSO
    }
}

<#
.SYNOPSIS

Convert from JSON to SrvConfig<PSCustomObject>

.DESCRIPTION

Convert from JSON to SrvConfig<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

SrvConfig<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in SS6SrvConfig
        $AllProperties = ("id", "maxConn", "maxConnPerClient", "maxConnPerUser", "connDelaySecs", "idleTimeoutMinutes", "protectorTimeWindowMin", "protectorErrThreshold", "protectorBanForMin", "ProtectorBehavior", "protectorCompoundIncr", "passComplexity", "safeList", "allowList", "ftpConf", "sshConf", "httpConf", "speedLimits", "eventHandlers", "smtpConf", "logConf", "quotaTtl")
        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 "maxConn"))) { #optional property not found
            $MaxConn = $null
        } else {
            $MaxConn = $JsonParameters.PSobject.Properties["maxConn"].value
        }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "eventHandlers"))) { #optional property not found
            $EventHandlers = $null
        } else {
            $EventHandlers = $JsonParameters.PSobject.Properties["eventHandlers"].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 "quotaTtl"))) { #optional property not found
            $QuotaTtl = $null
        } else {
            $QuotaTtl = $JsonParameters.PSobject.Properties["quotaTtl"].value
        }

        $PSO = [PSCustomObject]@{
            "id" = ${Id}
            "maxConn" = ${MaxConn}
            "maxConnPerClient" = ${MaxConnPerClient}
            "maxConnPerUser" = ${MaxConnPerUser}
            "connDelaySecs" = ${ConnDelaySecs}
            "idleTimeoutMinutes" = ${IdleTimeoutMinutes}
            "protectorTimeWindowMin" = ${ProtectorTimeWindowMin}
            "protectorErrThreshold" = ${ProtectorErrThreshold}
            "protectorBanForMin" = ${ProtectorBanForMin}
            "ProtectorBehavior" = ${ProtectorBehavior}
            "protectorCompoundIncr" = ${ProtectorCompoundIncr}
            "passComplexity" = ${PassComplexity}
            "safeList" = ${SafeList}
            "allowList" = ${AllowList}
            "ftpConf" = ${FtpConf}
            "sshConf" = ${SshConf}
            "httpConf" = ${HttpConf}
            "speedLimits" = ${SpeedLimits}
            "eventHandlers" = ${EventHandlers}
            "smtpConf" = ${SmtpConf}
            "logConf" = ${LogConf}
            "quotaTtl" = ${QuotaTtl}
        }

        return $PSO
    }

}