Model/ImportEnvironmentModel.ps1

#
# Cloud Governance Api
# Contact: support@avepoint.com
#

<#
ImportEnvironmentModel<PSCustomObject>
#>


function New-ImportEnvironmentModel {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${ObjectType} = "None",
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Id},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Url},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Name},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${TenantId},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${ContactElectionProfile},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${RenewalProfile},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${PrimaryContact},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${SecondaryContact},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject[]]
        ${Metadatas}
    )

    Process {
        'Creating PSCustomObject: Cloud.Governance.Client => ImportEnvironmentModel' | Write-Debug
        $PSBoundParameters | Out-DebugParameter | Write-Debug

        
        $PSO = [PSCustomObject]@{
            "ObjectType" = ${ObjectType}
            "Id" = ${Id}
            "Url" = ${Url}
            "Name" = ${Name}
            "TenantId" = ${TenantId}
            "ContactElectionProfile" = ${ContactElectionProfile}
            "RenewalProfile" = ${RenewalProfile}
            "PrimaryContact" = ${PrimaryContact}
            "SecondaryContact" = ${SecondaryContact}
            "Metadatas" = ${Metadatas}
        }

        return $PSO
    }
}

<#
ImportEnvironmentModel<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in ImportEnvironmentModel
        $AllProperties = $("ObjectType", "Id", "Url", "Name", "TenantId", "ContactElectionProfile", "RenewalProfile", "PrimaryContact", "SecondaryContact", "Metadatas")
        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 "ObjectType"))) { #optional property not found
            $ObjectType = $null
        } else {
            $ObjectType = $JsonParameters.PSobject.Properties["ObjectType"].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 "Url"))) { #optional property not found
            $Url = $null
        } else {
            $Url = $JsonParameters.PSobject.Properties["Url"].value
        }

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

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

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

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

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

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

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

        $PSO = [PSCustomObject]@{
            "ObjectType" = ${ObjectType}
            "Id" = ${Id}
            "Url" = ${Url}
            "Name" = ${Name}
            "TenantId" = ${TenantId}
            "ContactElectionProfile" = ${ContactElectionProfile}
            "RenewalProfile" = ${RenewalProfile}
            "PrimaryContact" = ${PrimaryContact}
            "SecondaryContact" = ${SecondaryContact}
            "Metadatas" = ${Metadatas}
        }

        return $PSO
    }

}