Model/ApplyProfilesModel.ps1

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

<#
ApplyProfilesModel<PSCustomObject>
#>


function New-ApplyProfilesModel {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${VarFilter},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Search},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Boolean]]
        ${EnableModernRenewalProfile} = $false,
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${ModernRenewalProfile},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Boolean]]
        ${EnableElectionProfile} = $false,
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${ElectionProfile},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Boolean]]
        ${EnableQuotaProfile} = $false,
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${QuotaProfile},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Boolean]]
        ${EnableExternalSharingProfile} = $false,
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${ExternalSharingProfile},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${ProfileObjectType} = "Site",
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String[]]
        ${SelectedObjects},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${HandleOngoingType} = "None",
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${HandleTaskType} = "None",
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Boolean]]
        ${IsSendCancelEmail} = $false,
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${CancelEmailTemplateId}
    )

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

        
        $PSO = [PSCustomObject]@{
            "VarFilter" = ${VarFilter}
            "Search" = ${Search}
            "EnableModernRenewalProfile" = ${EnableModernRenewalProfile}
            "ModernRenewalProfile" = ${ModernRenewalProfile}
            "EnableElectionProfile" = ${EnableElectionProfile}
            "ElectionProfile" = ${ElectionProfile}
            "EnableQuotaProfile" = ${EnableQuotaProfile}
            "QuotaProfile" = ${QuotaProfile}
            "EnableExternalSharingProfile" = ${EnableExternalSharingProfile}
            "ExternalSharingProfile" = ${ExternalSharingProfile}
            "ProfileObjectType" = ${ProfileObjectType}
            "SelectedObjects" = ${SelectedObjects}
            "HandleOngoingType" = ${HandleOngoingType}
            "HandleTaskType" = ${HandleTaskType}
            "IsSendCancelEmail" = ${IsSendCancelEmail}
            "CancelEmailTemplateId" = ${CancelEmailTemplateId}
        }

        return $PSO
    }
}

<#
ApplyProfilesModel<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in ApplyProfilesModel
        $AllProperties = $("VarFilter", "Search", "EnableModernRenewalProfile", "ModernRenewalProfile", "EnableElectionProfile", "ElectionProfile", "EnableQuotaProfile", "QuotaProfile", "EnableExternalSharingProfile", "ExternalSharingProfile", "ProfileObjectType", "SelectedObjects", "HandleOngoingType", "HandleTaskType", "IsSendCancelEmail", "CancelEmailTemplateId")
        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 "VarFilter"))) { #optional property not found
            $VarFilter = $null
        } else {
            $VarFilter = $JsonParameters.PSobject.Properties["VarFilter"].value
        }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        $PSO = [PSCustomObject]@{
            "VarFilter" = ${VarFilter}
            "Search" = ${Search}
            "EnableModernRenewalProfile" = ${EnableModernRenewalProfile}
            "ModernRenewalProfile" = ${ModernRenewalProfile}
            "EnableElectionProfile" = ${EnableElectionProfile}
            "ElectionProfile" = ${ElectionProfile}
            "EnableQuotaProfile" = ${EnableQuotaProfile}
            "QuotaProfile" = ${QuotaProfile}
            "EnableExternalSharingProfile" = ${EnableExternalSharingProfile}
            "ExternalSharingProfile" = ${ExternalSharingProfile}
            "ProfileObjectType" = ${ProfileObjectType}
            "SelectedObjects" = ${SelectedObjects}
            "HandleOngoingType" = ${HandleOngoingType}
            "HandleTaskType" = ${HandleTaskType}
            "IsSendCancelEmail" = ${IsSendCancelEmail}
            "CancelEmailTemplateId" = ${CancelEmailTemplateId}
        }

        return $PSO
    }

}