Model/TLSCertificate.ps1

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

<#
.SYNOPSIS

No summary available.

.DESCRIPTION

The fields 'cert' and 'key' are required when adding a new certificate

.PARAMETER Id
Unique ID, it will be auto-generated
.PARAMETER Cert
X.509 certificate
.PARAMETER Key
X.509 certificate's private key
.PARAMETER CaBundle
optional CA bundle
.PARAMETER KeyPass
No description available.
.PARAMETER Hash
auto generated
.PARAMETER CommonName
automatically extracted from the certificate
.PARAMETER ValidFrom
automatically extracted from the certificate
.PARAMETER ValidUntil
automatically extracted from the certificate
.OUTPUTS

TLSCertificate<PSCustomObject>
#>


function Initialize-SS6TLSCertificate {
    [CmdletBinding()]
    Param (
        [Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Id},
        [Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Cert},
        [Parameter(Position = 2, ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Key},
        [Parameter(Position = 3, ValueFromPipelineByPropertyName = $true)]
        [String]
        ${CaBundle},
        [Parameter(Position = 4, ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${KeyPass},
        [Parameter(Position = 5, ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Hash},
        [Parameter(Position = 6, ValueFromPipelineByPropertyName = $true)]
        [String]
        ${CommonName},
        [Parameter(Position = 7, ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[System.DateTime]]
        ${ValidFrom},
        [Parameter(Position = 8, ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[System.DateTime]]
        ${ValidUntil}
    )

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


        $PSO = [PSCustomObject]@{
            "id" = ${Id}
            "cert" = ${Cert}
            "key" = ${Key}
            "caBundle" = ${CaBundle}
            "keyPass" = ${KeyPass}
            "hash" = ${Hash}
            "commonName" = ${CommonName}
            "validFrom" = ${ValidFrom}
            "validUntil" = ${ValidUntil}
        }


        return $PSO
    }
}

<#
.SYNOPSIS

Convert from JSON to TLSCertificate<PSCustomObject>

.DESCRIPTION

Convert from JSON to TLSCertificate<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

TLSCertificate<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in SS6TLSCertificate
        $AllProperties = ("id", "cert", "key", "caBundle", "keyPass", "hash", "commonName", "validFrom", "validUntil")
        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 "id"))) { #optional property not found
            $Id = $null
        } else {
            $Id = $JsonParameters.PSobject.Properties["id"].value
        }

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

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

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

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

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

        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 "validFrom"))) { #optional property not found
            $ValidFrom = $null
        } else {
            $ValidFrom = $JsonParameters.PSobject.Properties["validFrom"].value
        }

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

        $PSO = [PSCustomObject]@{
            "id" = ${Id}
            "cert" = ${Cert}
            "key" = ${Key}
            "caBundle" = ${CaBundle}
            "keyPass" = ${KeyPass}
            "hash" = ${Hash}
            "commonName" = ${CommonName}
            "validFrom" = ${ValidFrom}
            "validUntil" = ${ValidUntil}
        }

        return $PSO
    }

}