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