Model/CustomSiteTemplate.ps1
# # Cloud Governance Api # Contact: support@avepoint.com # <# CustomSiteTemplate<PSCustomObject> #> function New-CustomSiteTemplate { [CmdletBinding()] Param ( [Parameter(ValueFromPipelineByPropertyName = $true)] [String] ${TemplateStoreUrl}, [Parameter(ValueFromPipelineByPropertyName = $true)] [String] ${TemplateName} ) Process { 'Creating PSCustomObject: Cloud.Governance.Client => CustomSiteTemplate' | Write-Debug $PSBoundParameters | Out-DebugParameter | Write-Debug $PSO = [PSCustomObject]@{ "TemplateStoreUrl" = ${TemplateStoreUrl} "TemplateName" = ${TemplateName} } return $PSO } } <# CustomSiteTemplate<PSCustomObject> #> function ConvertFrom-JsonToCustomSiteTemplate { Param( [AllowEmptyString()] [string]$Json ) Process { 'Converting JSON to PSCustomObject: Cloud.Governance.Client => CustomSiteTemplate' | Write-Debug $PSBoundParameters | Out-DebugParameter | Write-Debug $JsonParameters = ConvertFrom-Json -InputObject $Json # check if Json contains properties not defined in CustomSiteTemplate $AllProperties = $("TemplateStoreUrl", "TemplateName") 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 "TemplateStoreUrl"))) { #optional property not found $TemplateStoreUrl = $null } else { $TemplateStoreUrl = $JsonParameters.PSobject.Properties["TemplateStoreUrl"].value } if (!([bool]($JsonParameters.PSobject.Properties.name -match "TemplateName"))) { #optional property not found $TemplateName = $null } else { $TemplateName = $JsonParameters.PSobject.Properties["TemplateName"].value } $PSO = [PSCustomObject]@{ "TemplateStoreUrl" = ${TemplateStoreUrl} "TemplateName" = ${TemplateName} } return $PSO } } |