Model/PUTClusterSdnVnetsSubnetsRB.ps1

#
# Proxmox VE
# Generated module to access all Proxmox VE Api Endpoints
# Version: 0.3
# Contact: amna.wolf@gmail.com
# Generated by OpenAPI Generator: https://openapi-generator.tech
#

<#
.SYNOPSIS

No summary available.

.DESCRIPTION

No description available.

.PARAMETER DhcpDnsServer
No description available.
.PARAMETER Gateway
No description available.
.PARAMETER Dnszoneprefix
No description available.
.PARAMETER DhcpRange
No description available.
.PARAMETER Snat
No description available.
.PARAMETER Vnet
No description available.
.PARAMETER Digest
No description available.
.PARAMETER Subnet
No description available.
.PARAMETER Delete
No description available.
.OUTPUTS

PUTClusterSdnVnetsSubnetsRB<PSCustomObject>
#>


function Initialize-PVEPUTClusterSdnVnetsSubnetsRB {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${DhcpDnsServer},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Gateway},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Dnszoneprefix},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String[]]
        ${DhcpRange},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${Snat},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Vnet},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Digest},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Subnet},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Delete}
    )

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

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

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

        if (!$Digest -and $Digest.length -gt 64) {
            throw "invalid value for 'Digest', the character length must be smaller than or equal to 64."
        }

        if (!$Delete -and $Delete.length -gt 4096) {
            throw "invalid value for 'Delete', the character length must be smaller than or equal to 4096."
        }


         $DisplayNameMapping =@{
            "DhcpDnsServer"="dhcp-dns-server"; "Gateway"="gateway"; "Dnszoneprefix"="dnszoneprefix"; "DhcpRange"="dhcp-range"; "Snat"="snat"; "Vnet"="vnet"; "Digest"="digest"; "Subnet"="subnet"; "Delete"="delete"
        }
        
         $OBJ = @{}
        foreach($parameter in   $PSBoundParameters.Keys){
            #If Specifield map the Display name back
            $OBJ.($DisplayNameMapping.($parameter)) = "$PSBoundParameters.$parameter"
        }

        $PSO = [PSCustomObject]$OBJ


        return $PSO
    }
}

<#
.SYNOPSIS

Convert from JSON to PUTClusterSdnVnetsSubnetsRB<PSCustomObject>

.DESCRIPTION

Convert from JSON to PUTClusterSdnVnetsSubnetsRB<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

PUTClusterSdnVnetsSubnetsRB<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in PVEPUTClusterSdnVnetsSubnetsRB
        $AllProperties = ("dhcp-dns-server", "gateway", "dnszoneprefix", "dhcp-range", "snat", "vnet", "digest", "subnet", "delete")
        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 "dhcp-dns-server"))) { #optional property not found
            $DhcpDnsServer = $null
        } else {
            $DhcpDnsServer = $JsonParameters.PSobject.Properties["dhcp-dns-server"].value
        }

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

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

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

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

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

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

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

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

        $PSO = [PSCustomObject]@{
            "dhcp-dns-server" = ${DhcpDnsServer}
            "gateway" = ${Gateway}
            "dnszoneprefix" = ${Dnszoneprefix}
            "dhcp-range" = ${DhcpRange}
            "snat" = ${Snat}
            "vnet" = ${Vnet}
            "digest" = ${Digest}
            "subnet" = ${Subnet}
            "delete" = ${Delete}
        }

        return $PSO
    }

}