Model/POSTNodesCephInitRB.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 Network
No description available.
.PARAMETER DisableCephx
No description available.
.PARAMETER ClusterNetwork
No description available.
.PARAMETER Size
No description available.
.PARAMETER Node
No description available.
.PARAMETER MinSize
No description available.
.PARAMETER PgBits
No description available.
.OUTPUTS

POSTNodesCephInitRB<PSCustomObject>
#>


function Initialize-PVEPOSTNodesCephInitRB {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Network},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${DisableCephx},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${ClusterNetwork},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${Size},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Node},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${MinSize},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${PgBits}
    )

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

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

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

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

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

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

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

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

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

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

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


         $DisplayNameMapping =@{
            "Network"="network"; "DisableCephx"="disable_cephx"; "ClusterNetwork"="cluster-network"; "Size"="size"; "Node"="node"; "MinSize"="min_size"; "PgBits"="pg_bits"
        }
        
         $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 POSTNodesCephInitRB<PSCustomObject>

.DESCRIPTION

Convert from JSON to POSTNodesCephInitRB<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

POSTNodesCephInitRB<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in PVEPOSTNodesCephInitRB
        $AllProperties = ("network", "disable_cephx", "cluster-network", "size", "node", "min_size", "pg_bits")
        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 "network"))) { #optional property not found
            $Network = $null
        } else {
            $Network = $JsonParameters.PSobject.Properties["network"].value
        }

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

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

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

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

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

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

        $PSO = [PSCustomObject]@{
            "network" = ${Network}
            "disable_cephx" = ${DisableCephx}
            "cluster-network" = ${ClusterNetwork}
            "size" = ${Size}
            "node" = ${Node}
            "min_size" = ${MinSize}
            "pg_bits" = ${PgBits}
        }

        return $PSO
    }

}