Model/ChangedLicense.ps1

#
# Cloud Governance Api
# Contact: support@avepoint.com
#

<#
ChangedLicense<PSCustomObject>
#>


function New-ChangedLicense {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${LicenseId},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${LicenseName},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Boolean]]
        ${SelectedAllForShow} = $false,
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject[]]
        ${SelectedApps}
    )

    Process {
        'Creating PSCustomObject: Cloud.Governance.Client => ChangedLicense' | Write-Debug
        $PSBoundParameters | Out-DebugParameter | Write-Debug

        
        $PSO = [PSCustomObject]@{
            "LicenseId" = ${LicenseId}
            "LicenseName" = ${LicenseName}
            "SelectedAllForShow" = ${SelectedAllForShow}
            "SelectedApps" = ${SelectedApps}
        }

        return $PSO
    }
}

<#
ChangedLicense<PSCustomObject>
#>

function ConvertFrom-JsonToChangedLicense {
    Param(
        [AllowEmptyString()]
        [string]$Json
    )

    Process {
        'Converting JSON to PSCustomObject: Cloud.Governance.Client => ChangedLicense' | Write-Debug
        $PSBoundParameters | Out-DebugParameter | Write-Debug

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in ChangedLicense
        $AllProperties = $("LicenseId", "LicenseName", "SelectedAllForShow", "SelectedApps")
        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
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "SelectedAllForShow"))) { #optional property not found
            $SelectedAllForShow = $null
        } else {
            $SelectedAllForShow = $JsonParameters.PSobject.Properties["SelectedAllForShow"].value
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "SelectedApps"))) { #optional property not found
            $SelectedApps = $null
        } else {
            $SelectedApps = $JsonParameters.PSobject.Properties["SelectedApps"].value
        }

        $PSO = [PSCustomObject]@{
            "LicenseId" = ${LicenseId}
            "LicenseName" = ${LicenseName}
            "SelectedAllForShow" = ${SelectedAllForShow}
            "SelectedApps" = ${SelectedApps}
        }

        return $PSO
    }

}