Model/CertificateBaseFields.ps1

#
# SMServer V6
# Syncplify Server! REST API
# Version: 1.0.0
# Generated by OpenAPI Generator: https://openapi-generator.tech
#

<#
.SYNOPSIS

No summary available.

.DESCRIPTION

No description available.

.PARAMETER CommonName
No description available.
.PARAMETER Country
No description available.
.PARAMETER Organization
No description available.
.PARAMETER OrganizationalUnit
No description available.
.PARAMETER Locality
No description available.
.PARAMETER Province
No description available.
.PARAMETER Bits
No description available.
.PARAMETER Algo
No description available.
.PARAMETER Hosts
No description available.
.OUTPUTS

CertificateBaseFields<PSCustomObject>
#>


function Initialize-SS6CertificateBaseFields {
    [CmdletBinding()]
    Param (
        [Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
        [String]
        ${CommonName},
        [Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Country},
        [Parameter(Position = 2, ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Organization},
        [Parameter(Position = 3, ValueFromPipelineByPropertyName = $true)]
        [String]
        ${OrganizationalUnit},
        [Parameter(Position = 4, ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Locality},
        [Parameter(Position = 5, ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Province},
        [Parameter(Position = 6, ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("2048", "3072", "4096")]
        [System.Nullable[Int32]]
        ${Bits},
        [Parameter(Position = 7, ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("RSA", "P256", "P384", "P521", "ED25519")]
        [String]
        ${Algo},
        [Parameter(Position = 8, ValueFromPipelineByPropertyName = $true)]
        [String[]]
        ${Hosts}
    )

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


        $PSO = [PSCustomObject]@{
            "commonName" = ${CommonName}
            "country" = ${Country}
            "organization" = ${Organization}
            "organizationalUnit" = ${OrganizationalUnit}
            "locality" = ${Locality}
            "province" = ${Province}
            "bits" = ${Bits}
            "algo" = ${Algo}
            "hosts" = ${Hosts}
        }


        return $PSO
    }
}

<#
.SYNOPSIS

Convert from JSON to CertificateBaseFields<PSCustomObject>

.DESCRIPTION

Convert from JSON to CertificateBaseFields<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

CertificateBaseFields<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in SS6CertificateBaseFields
        $AllProperties = ("commonName", "country", "organization", "organizationalUnit", "locality", "province", "bits", "algo", "hosts")
        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 "commonName"))) { #optional property not found
            $CommonName = $null
        } else {
            $CommonName = $JsonParameters.PSobject.Properties["commonName"].value
        }

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

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

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

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

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

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

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

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

        $PSO = [PSCustomObject]@{
            "commonName" = ${CommonName}
            "country" = ${Country}
            "organization" = ${Organization}
            "organizationalUnit" = ${OrganizationalUnit}
            "locality" = ${Locality}
            "province" = ${Province}
            "bits" = ${Bits}
            "algo" = ${Algo}
            "hosts" = ${Hosts}
        }

        return $PSO
    }

}