Model/TeamsMappingCreationModel.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 EnableChannelMapping
A boolean value indicates whether enable channel mapping
.PARAMETER ChannelMapping
A list of channel mappings
.PARAMETER IncludeOtherChannels
A boolean value indicates whether migrate channels not listed
.PARAMETER SourceType
The data type of source identity, no need to specify.
.PARAMETER DestinationType
The data type of destination identity, no need to specify.
.PARAMETER ProjectId
Specify the GUID of project which the project mapping belongs
.PARAMETER SourceName
The display name of source identity
.PARAMETER SourceIdentity
The source identity of migration
.PARAMETER DestinationName
The display name of destination identity
.PARAMETER DestinationIdentity
The destination identity of migration
.OUTPUTS
 
TeamsMappingCreationModel<PSCustomObject>
#>


function Initialize-FlyTeamsMappingCreationModel {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Boolean]]
        ${EnableChannelMapping},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject[]]
        ${ChannelMapping},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Boolean]]
        ${IncludeOtherChannels},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${SourceType},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${DestinationType},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${ProjectId},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${SourceName},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${SourceIdentity},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${DestinationName},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${DestinationIdentity}
    )

    Process {
        'Creating PSCustomObject: Fly.Client => FlyTeamsMappingCreationModel' | 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 (!$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."
        }


        $PSO = [PSCustomObject]@{
            "enableChannelMapping" = ${EnableChannelMapping}
            "channelMapping" = ${ChannelMapping}
            "includeOtherChannels" = ${IncludeOtherChannels}
            "sourceType" = ${SourceType}
            "destinationType" = ${DestinationType}
            "projectId" = ${ProjectId}
            "sourceName" = ${SourceName}
            "sourceIdentity" = ${SourceIdentity}
            "destinationName" = ${DestinationName}
            "destinationIdentity" = ${DestinationIdentity}
        }

        return $PSO
    }
}

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

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in FlyTeamsMappingCreationModel
        $AllProperties = ("enableChannelMapping", "channelMapping", "includeOtherChannels", "sourceType", "destinationType", "projectId", "sourceName", "sourceIdentity", "destinationName", "destinationIdentity")
        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 "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 "enableChannelMapping"))) { #optional property not found
            $EnableChannelMapping = $null
        } else {
            $EnableChannelMapping = $JsonParameters.PSobject.Properties["enableChannelMapping"].value
        }

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

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

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

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

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "projectId"))) { #optional property not found
            $ProjectId = $null
        } else {
            $ProjectId = $JsonParameters.PSobject.Properties["projectId"].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]@{
            "enableChannelMapping" = ${EnableChannelMapping}
            "channelMapping" = ${ChannelMapping}
            "includeOtherChannels" = ${IncludeOtherChannels}
            "sourceType" = ${SourceType}
            "destinationType" = ${DestinationType}
            "projectId" = ${ProjectId}
            "sourceName" = ${SourceName}
            "sourceIdentity" = ${SourceIdentity}
            "destinationName" = ${DestinationName}
            "destinationIdentity" = ${DestinationIdentity}
        }

        return $PSO
    }

}