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