Model/ExchangeMappingCreationModel.ps1

#
# Fly SDK API
# No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
# Version: 1.0
# Contact: support@avepoint.com
# Generated by OpenAPI Generator: https://openapi-generator.tech
#

<#
.SYNOPSIS
 
No summary available.
 
.DESCRIPTION
 
No description available.
 
.PARAMETER SourceName
The display name of source identity
.PARAMETER SourceIdentity
The source identity of migration
.PARAMETER SourceType
The data type of source identity, refer to [**PlatformDataTypes**](PlatformDataTypes.md) for more details
.PARAMETER DestinationName
The display name of destination identity
.PARAMETER DestinationIdentity
The destination identity of migration
.PARAMETER DestinationType
The data type of destination identity, refer to [**PlatformDataTypes**](PlatformDataTypes.md) for more details
.OUTPUTS
 
ExchangeMappingCreationModel<PSCustomObject>
#>


function Initialize-FlyExchangeMappingCreationModel {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${SourceName},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${SourceIdentity},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [Int32]
        ${SourceType},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${DestinationName},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${DestinationIdentity},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [Int32]
        ${DestinationType}
    )

    Process {
        'Creating PSCustomObject: Fly.Client => FlyExchangeMappingCreationModel' | Write-Debug
        $PSBoundParameters | Out-DebugParameter | Write-Debug

        if (!$SourceIdentity) {
            throw "invalid value for 'SourceIdentity', 'SourceIdentity' cannot be null."
        }

        if ($SourceIdentity.length -lt 1) {
            throw "invalid value for 'SourceIdentity', the character length must be great than or equal to 1."
        }

        if (!$SourceType) {
            throw "invalid value for 'SourceType', 'SourceType' cannot be null."
        }

        if (!$DestinationIdentity) {
            throw "invalid value for 'DestinationIdentity', 'DestinationIdentity' cannot be null."
        }

        if ($DestinationIdentity.length -lt 1) {
            throw "invalid value for 'DestinationIdentity', the character length must be great than or equal to 1."
        }

        if (!$DestinationType) {
            throw "invalid value for 'DestinationType', 'DestinationType' cannot be null."
        }


        $PSO = [PSCustomObject]@{
            "sourceName" = ${SourceName}
            "sourceIdentity" = ${SourceIdentity}
            "sourceType" = ${SourceType}
            "destinationName" = ${DestinationName}
            "destinationIdentity" = ${DestinationIdentity}
            "destinationType" = ${DestinationType}
        }

        return $PSO
    }
}

<#
.SYNOPSIS
 
Convert from JSON to ExchangeMappingCreationModel<PSCustomObject>
 
.DESCRIPTION
 
Convert from JSON to ExchangeMappingCreationModel<PSCustomObject>
 
.PARAMETER Json
 
Json object
 
.OUTPUTS
 
ExchangeMappingCreationModel<PSCustomObject>
#>

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

    Process {
        'Converting JSON to PSCustomObject: Fly.Client => FlyExchangeMappingCreationModel' | Write-Debug
        $PSBoundParameters | Out-DebugParameter | Write-Debug

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in FlyExchangeMappingCreationModel
        $AllProperties = ("sourceName", "sourceIdentity", "sourceType", "destinationName", "destinationIdentity", "destinationType")
        foreach ($name in $JsonParameters.PsObject.Properties.Name) {
            if (!($AllProperties.Contains($name))) {
                throw "Error! JSON key '$name' not found in the properties: $($AllProperties)"
            }
        }

        If ([string]::IsNullOrEmpty($Json) -or $Json -eq "{}") { # empty json
            throw "Error! Empty JSON cannot be serialized due to the required property 'sourceIdentity' missing."
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "sourceIdentity"))) {
            throw "Error! JSON cannot be serialized due to the required property 'sourceIdentity' missing."
        } else {
            $SourceIdentity = $JsonParameters.PSobject.Properties["sourceIdentity"].value
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "sourceType"))) {
            throw "Error! JSON cannot be serialized due to the required property 'sourceType' missing."
        } else {
            $SourceType = $JsonParameters.PSobject.Properties["sourceType"].value
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "destinationIdentity"))) {
            throw "Error! JSON cannot be serialized due to the required property 'destinationIdentity' missing."
        } else {
            $DestinationIdentity = $JsonParameters.PSobject.Properties["destinationIdentity"].value
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "destinationType"))) {
            throw "Error! JSON cannot be serialized due to the required property 'destinationType' missing."
        } else {
            $DestinationType = $JsonParameters.PSobject.Properties["destinationType"].value
        }

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

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

        $PSO = [PSCustomObject]@{
            "sourceName" = ${SourceName}
            "sourceIdentity" = ${SourceIdentity}
            "sourceType" = ${SourceType}
            "destinationName" = ${DestinationName}
            "destinationIdentity" = ${DestinationIdentity}
            "destinationType" = ${DestinationType}
        }

        return $PSO
    }

}