Model/PUTClusterFirewallOptionsRB.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 Ebtables
No description available.
.PARAMETER PolicyIn
No description available.
.PARAMETER PolicyOut
No description available.
.PARAMETER Delete
No description available.
.PARAMETER PolicyForward
No description available.
.PARAMETER LogRatelimit
No description available.
.PARAMETER Digest
No description available.
.PARAMETER Enable
No description available.
.OUTPUTS

PUTClusterFirewallOptionsRB<PSCustomObject>
#>


function Initialize-PVEPUTClusterFirewallOptionsRB {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${Ebtables},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("ACCEPT", "REJECT", "DROP")]
        [String]
        ${PolicyIn},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("ACCEPT", "REJECT", "DROP")]
        [String]
        ${PolicyOut},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Delete},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("ACCEPT", "DROP")]
        [String]
        ${PolicyForward},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${LogRatelimit},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Digest},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${Enable}
    )

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

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

        if ($Ebtables -and $Ebtables -lt 0) {
          throw "invalid value for 'Ebtables', 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."
        }


         $DisplayNameMapping =@{
            "Ebtables"="ebtables"; "PolicyIn"="policy_in"; "PolicyOut"="policy_out"; "Delete"="delete"; "PolicyForward"="policy_forward"; "LogRatelimit"="log_ratelimit"; "Digest"="digest"; "Enable"="enable"
        }
        
         $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 PUTClusterFirewallOptionsRB<PSCustomObject>

.DESCRIPTION

Convert from JSON to PUTClusterFirewallOptionsRB<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

PUTClusterFirewallOptionsRB<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in PVEPUTClusterFirewallOptionsRB
        $AllProperties = ("ebtables", "policy_in", "policy_out", "delete", "policy_forward", "log_ratelimit", "digest", "enable")
        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 "ebtables"))) { #optional property not found
            $Ebtables = $null
        } else {
            $Ebtables = $JsonParameters.PSobject.Properties["ebtables"].value
        }

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

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

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

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

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

        $PSO = [PSCustomObject]@{
            "ebtables" = ${Ebtables}
            "policy_in" = ${PolicyIn}
            "policy_out" = ${PolicyOut}
            "delete" = ${Delete}
            "policy_forward" = ${PolicyForward}
            "log_ratelimit" = ${LogRatelimit}
            "digest" = ${Digest}
            "enable" = ${Enable}
        }

        return $PSO
    }

}