Model/BlockListItem.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
Leave empty for auto-generation
.PARAMETER IpOrNetwork
ip address or cidr network. Both IPv4 and IPv6 are supported
.PARAMETER Persistence
No description available.
.PARAMETER ExpirationUTC
it make senses if persistence is 'Temporary'
.PARAMETER Hits
This field will be auto-populated, omit it when adding a new item
.PARAMETER AddReason
No description available.
.PARAMETER Notes
No description available.
.OUTPUTS

BlockListItem<PSCustomObject>
#>


function Initialize-SS6BlockListItem {
    [CmdletBinding()]
    Param (
        [Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Id},
        [Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)]
        [String]
        ${IpOrNetwork},
        [Parameter(Position = 2, ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${Persistence},
        [Parameter(Position = 3, ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[System.DateTime]]
        ${ExpirationUTC},
        [Parameter(Position = 4, ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int64]]
        ${Hits},
        [Parameter(Position = 5, ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${AddReason},
        [Parameter(Position = 6, ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Notes}
    )

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

        if ($IpOrNetwork -eq $null) {
            throw "invalid value for 'IpOrNetwork', 'IpOrNetwork' cannot be null."
        }


        $PSO = [PSCustomObject]@{
            "id" = ${Id}
            "ipOrNetwork" = ${IpOrNetwork}
            "persistence" = ${Persistence}
            "expirationUTC" = ${ExpirationUTC}
            "hits" = ${Hits}
            "addReason" = ${AddReason}
            "notes" = ${Notes}
        }


        return $PSO
    }
}

<#
.SYNOPSIS

Convert from JSON to BlockListItem<PSCustomObject>

.DESCRIPTION

Convert from JSON to BlockListItem<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

BlockListItem<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in SS6BlockListItem
        $AllProperties = ("id", "ipOrNetwork", "persistence", "expirationUTC", "hits", "addReason", "notes")
        foreach ($name in $JsonParameters.PsObject.Properties.Name) {
            if (!($AllProperties.Contains($name))) {
                throw "Error! JSON key '$name' not found in the properties: $($AllProperties)"
            }
        }

        If ([string]::IsNullOrEmpty($Json) -or $Json -eq "{}") { # empty json
            throw "Error! Empty JSON cannot be serialized due to the required property 'ipOrNetwork' missing."
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "ipOrNetwork"))) {
            throw "Error! JSON cannot be serialized due to the required property 'ipOrNetwork' missing."
        } else {
            $IpOrNetwork = $JsonParameters.PSobject.Properties["ipOrNetwork"].value
        }

        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 "persistence"))) { #optional property not found
            $Persistence = $null
        } else {
            $Persistence = $JsonParameters.PSobject.Properties["persistence"].value
        }

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

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

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

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

        $PSO = [PSCustomObject]@{
            "id" = ${Id}
            "ipOrNetwork" = ${IpOrNetwork}
            "persistence" = ${Persistence}
            "expirationUTC" = ${ExpirationUTC}
            "hits" = ${Hits}
            "addReason" = ${AddReason}
            "notes" = ${Notes}
        }

        return $PSO
    }

}