Model/ImportSiteModel.ps1

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

<#
ImportSiteModel<PSCustomObject>
#>


function New-ImportSiteModel {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${ObjectType} = "None",
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${SiteTitle},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${SiteUrl},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Boolean]]
        ${IsKeepSiteQuota} = $false,
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${AppSetting} = "None",
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${ExternalSharingProfile},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${StorageManagementProfile},
        [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 => ImportSiteModel' | Write-Debug
        $PSBoundParameters | Out-DebugParameter | Write-Debug

        
        $PSO = [PSCustomObject]@{
            "ObjectType" = ${ObjectType}
            "SiteTitle" = ${SiteTitle}
            "SiteUrl" = ${SiteUrl}
            "IsKeepSiteQuota" = ${IsKeepSiteQuota}
            "AppSetting" = ${AppSetting}
            "ExternalSharingProfile" = ${ExternalSharingProfile}
            "StorageManagementProfile" = ${StorageManagementProfile}
            "ContactElectionProfile" = ${ContactElectionProfile}
            "RenewalProfile" = ${RenewalProfile}
            "PrimaryContact" = ${PrimaryContact}
            "SecondaryContact" = ${SecondaryContact}
            "Metadatas" = ${Metadatas}
        }

        return $PSO
    }
}

<#
ImportSiteModel<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in ImportSiteModel
        $AllProperties = $("ObjectType", "SiteTitle", "SiteUrl", "IsKeepSiteQuota", "AppSetting", "ExternalSharingProfile", "StorageManagementProfile", "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 "SiteTitle"))) { #optional property not found
            $SiteTitle = $null
        } else {
            $SiteTitle = $JsonParameters.PSobject.Properties["SiteTitle"].value
        }

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

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

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

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

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "StorageManagementProfile"))) { #optional property not found
            $StorageManagementProfile = $null
        } else {
            $StorageManagementProfile = $JsonParameters.PSobject.Properties["StorageManagementProfile"].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}
            "SiteTitle" = ${SiteTitle}
            "SiteUrl" = ${SiteUrl}
            "IsKeepSiteQuota" = ${IsKeepSiteQuota}
            "AppSetting" = ${AppSetting}
            "ExternalSharingProfile" = ${ExternalSharingProfile}
            "StorageManagementProfile" = ${StorageManagementProfile}
            "ContactElectionProfile" = ${ContactElectionProfile}
            "RenewalProfile" = ${RenewalProfile}
            "PrimaryContact" = ${PrimaryContact}
            "SecondaryContact" = ${SecondaryContact}
            "Metadatas" = ${Metadatas}
        }

        return $PSO
    }

}