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