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