Model/ClusterHaResources.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 State
No description available.
.PARAMETER Comment
No description available.
.PARAMETER MaxRestart
No description available.
.PARAMETER Type
No description available.
.PARAMETER MaxRelocate
No description available.
.PARAMETER Group
No description available.
.PARAMETER Sid
No description available.
.PARAMETER Digest
No description available.
.OUTPUTS

ClusterHaResources<PSCustomObject>
#>


function Initialize-PVEClusterHaResources {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("started", "stopped", "enabled", "disabled", "ignored")]
        [String]
        ${State},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Comment},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${MaxRestart},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Type},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${MaxRelocate},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Group},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Sid},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Digest}
    )

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


         $DisplayNameMapping =@{
            "State"="state"; "Comment"="comment"; "MaxRestart"="max_restart"; "Type"="type"; "MaxRelocate"="max_relocate"; "Group"="group"; "Sid"="sid"; "Digest"="digest"
        }
        
         $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 ClusterHaResources<PSCustomObject>

.DESCRIPTION

Convert from JSON to ClusterHaResources<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

ClusterHaResources<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in PVEClusterHaResources
        $AllProperties = ("state", "comment", "max_restart", "type", "max_relocate", "group", "sid", "digest")
        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 "state"))) { #optional property not found
            $State = $null
        } else {
            $State = $JsonParameters.PSobject.Properties["state"].value
        }

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

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

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

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

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

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

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

        $PSO = [PSCustomObject]@{
            "state" = ${State}
            "comment" = ${Comment}
            "max_restart" = ${MaxRestart}
            "type" = ${Type}
            "max_relocate" = ${MaxRelocate}
            "group" = ${Group}
            "sid" = ${Sid}
            "digest" = ${Digest}
        }

        return $PSO
    }

}