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