Model/ClusterHaStatusCurrentInner.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 CrmState
No description available.
.PARAMETER MaxRestart
No description available.
.PARAMETER Type
No description available.
.PARAMETER Node
No description available.
.PARAMETER Sid
No description available.
.PARAMETER RequestState
No description available.
.PARAMETER Timestamp
No description available.
.PARAMETER Status
No description available.
.PARAMETER Id
No description available.
.PARAMETER MaxRelocate
No description available.
.PARAMETER Quorate
No description available.
.OUTPUTS

ClusterHaStatusCurrentInner<PSCustomObject>
#>


function Initialize-PVEClusterHaStatusCurrentInner {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${State},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${CrmState},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${MaxRestart},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("quorum", "master", "lrm", "service")]
        [String]
        ${Type},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Node},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Sid},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${RequestState},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${Timestamp},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Status},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Id},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${MaxRelocate},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${Quorate}
    )

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

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

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


         $DisplayNameMapping =@{
            "State"="state"; "CrmState"="crm_state"; "MaxRestart"="max_restart"; "Type"="type"; "Node"="node"; "Sid"="sid"; "RequestState"="request_state"; "Timestamp"="timestamp"; "Status"="status"; "Id"="id"; "MaxRelocate"="max_relocate"; "Quorate"="quorate"
        }
        
         $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 ClusterHaStatusCurrentInner<PSCustomObject>

.DESCRIPTION

Convert from JSON to ClusterHaStatusCurrentInner<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

ClusterHaStatusCurrentInner<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in PVEClusterHaStatusCurrentInner
        $AllProperties = ("state", "crm_state", "max_restart", "type", "node", "sid", "request_state", "timestamp", "status", "id", "max_relocate", "quorate")
        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 "crm_state"))) { #optional property not found
            $CrmState = $null
        } else {
            $CrmState = $JsonParameters.PSobject.Properties["crm_state"].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 "node"))) { #optional property not found
            $Node = $null
        } else {
            $Node = $JsonParameters.PSobject.Properties["node"].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 "request_state"))) { #optional property not found
            $RequestState = $null
        } else {
            $RequestState = $JsonParameters.PSobject.Properties["request_state"].value
        }

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

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

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

        $PSO = [PSCustomObject]@{
            "state" = ${State}
            "crm_state" = ${CrmState}
            "max_restart" = ${MaxRestart}
            "type" = ${Type}
            "node" = ${Node}
            "sid" = ${Sid}
            "request_state" = ${RequestState}
            "timestamp" = ${Timestamp}
            "status" = ${Status}
            "id" = ${Id}
            "max_relocate" = ${MaxRelocate}
            "quorate" = ${Quorate}
        }

        return $PSO
    }

}