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