Model/POSTNodesQemuCloneRB.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 Newid
No description available.
.PARAMETER Format
No description available.
.PARAMETER Name
No description available.
.PARAMETER Vmid
No description available.
.PARAMETER Bwlimit
No description available.
.PARAMETER Snapname
No description available.
.PARAMETER Full
No description available.
.PARAMETER Description
No description available.
.PARAMETER Storage
No description available.
.PARAMETER Target
No description available.
.PARAMETER Pool
No description available.
.PARAMETER Node
No description available.
.OUTPUTS

POSTNodesQemuCloneRB<PSCustomObject>
#>


function Initialize-PVEPOSTNodesQemuCloneRB {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${Newid},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("raw", "qcow2", "vmdk")]
        [String]
        ${Format},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Name},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${Vmid},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${Bwlimit},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Snapname},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${Full},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Description},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Storage},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Target},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Pool},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Node}
    )

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

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

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

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

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

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

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

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


         $DisplayNameMapping =@{
            "Newid"="newid"; "Format"="format"; "Name"="name"; "Vmid"="vmid"; "Bwlimit"="bwlimit"; "Snapname"="snapname"; "Full"="full"; "Description"="description"; "Storage"="storage"; "Target"="target"; "Pool"="pool"; "Node"="node"
        }
        
         $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 POSTNodesQemuCloneRB<PSCustomObject>

.DESCRIPTION

Convert from JSON to POSTNodesQemuCloneRB<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

POSTNodesQemuCloneRB<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in PVEPOSTNodesQemuCloneRB
        $AllProperties = ("newid", "format", "name", "vmid", "bwlimit", "snapname", "full", "description", "storage", "target", "pool", "node")
        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 "newid"))) { #optional property not found
            $Newid = $null
        } else {
            $Newid = $JsonParameters.PSobject.Properties["newid"].value
        }

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

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

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

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

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

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

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

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

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

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

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

        $PSO = [PSCustomObject]@{
            "newid" = ${Newid}
            "format" = ${Format}
            "name" = ${Name}
            "vmid" = ${Vmid}
            "bwlimit" = ${Bwlimit}
            "snapname" = ${Snapname}
            "full" = ${Full}
            "description" = ${Description}
            "storage" = ${Storage}
            "target" = ${Target}
            "pool" = ${Pool}
            "node" = ${Node}
        }

        return $PSO
    }

}