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