Model/SiteDesignModel.ps1

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

<#
SiteDesignModel<PSCustomObject>
#>


function New-SiteDesignModel {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Description},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Boolean]]
        ${IsDefault} = $false,
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Boolean]]
        ${IsOutOfBoxTemplate} = $false,
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${PreviewImageAltText},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${PreviewImageUrl},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String[]]
        ${SiteScriptIds},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Title},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [Int32[]]
        ${SupportedWebTemplates},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Id},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${Version} = 0
    )

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

        
        $PSO = [PSCustomObject]@{
            "Description" = ${Description}
            "IsDefault" = ${IsDefault}
            "IsOutOfBoxTemplate" = ${IsOutOfBoxTemplate}
            "PreviewImageAltText" = ${PreviewImageAltText}
            "PreviewImageUrl" = ${PreviewImageUrl}
            "SiteScriptIds" = ${SiteScriptIds}
            "Title" = ${Title}
            "SupportedWebTemplates" = ${SupportedWebTemplates}
            "Id" = ${Id}
            "Version" = ${Version}
        }

        return $PSO
    }
}

<#
SiteDesignModel<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in SiteDesignModel
        $AllProperties = $("Description", "IsDefault", "IsOutOfBoxTemplate", "PreviewImageAltText", "PreviewImageUrl", "SiteScriptIds", "Title", "SupportedWebTemplates", "Id", "Version")
        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 "Description"))) { #optional property not found
            $Description = $null
        } else {
            $Description = $JsonParameters.PSobject.Properties["Description"].value
        }

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

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

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

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

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

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

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "SupportedWebTemplates"))) { #optional property not found
            $SupportedWebTemplates = $null
        } else {
            $SupportedWebTemplates = $JsonParameters.PSobject.Properties["SupportedWebTemplates"].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 "Version"))) { #optional property not found
            $Version = $null
        } else {
            $Version = $JsonParameters.PSobject.Properties["Version"].value
        }

        $PSO = [PSCustomObject]@{
            "Description" = ${Description}
            "IsDefault" = ${IsDefault}
            "IsOutOfBoxTemplate" = ${IsOutOfBoxTemplate}
            "PreviewImageAltText" = ${PreviewImageAltText}
            "PreviewImageUrl" = ${PreviewImageUrl}
            "SiteScriptIds" = ${SiteScriptIds}
            "Title" = ${Title}
            "SupportedWebTemplates" = ${SupportedWebTemplates}
            "Id" = ${Id}
            "Version" = ${Version}
        }

        return $PSO
    }

}