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