access-requests/src/PSSailpoint.AccessRequests/Model/AccessRequest.ps1

#
# Identity Security Cloud API - Access Requests
# Use these APIs to interact with the Identity Security Cloud platform to achieve repeatable, automated processes with greater scalability. We encourage you to join the SailPoint Developer Community forum at https://developer.sailpoint.com/discuss to connect with other developers using our APIs.
# Version: v1
# Generated by OpenAPI Generator: https://openapi-generator.tech
#

<#
.SYNOPSIS

No summary available.

.DESCRIPTION

No description available.

.PARAMETER RequestedFor
A list of Identity IDs for whom the Access is requested. If it's a Revoke request, there can only be one Identity ID. * Used for human identity requests with the 'requestedItems' field. * Must be omitted (do not send an empty array) when using `requestedForWithRequestedItems` (including all machine identity requests).
.PARAMETER RequestType
No description available.
.PARAMETER RequestedItems
* Used for human identity requests with the 'requestedFor' field. * Must be omitted (do not send an empty array) when using `requestedForWithRequestedItems`.
.PARAMETER ClientMetadata
Arbitrary key-value pairs. They will never be processed by the IdentityNow system but will be returned on associated APIs such as /account-activities.
.PARAMETER RequestedForWithRequestedItems
Additional submit data structure with requestedFor containing requestedItems allowing distinction for each request item and Identity. * Can only be used when 'requestedFor' and 'requestedItems' are not separately provided * Adds ability to specify which account the user wants the access on, in case they have multiple accounts on a source. * Allows the ability to request items with different start dates and remove dates. * Also allows different combinations of request items and identities in the same request. * For human identities, primarily used with GRANT_ACCESS (and related multi-account flows). Human REVOKE_ACCESS continues to use the flat `requestedFor` / `requestedItems` shape. * Required for machine identity access requests. Set `identityType: MACHINE` on each entry. Machine requests support GRANT_ACCESS, MODIFY_ACCESS, and REVOKE_ACCESS with the constraints documented on the create endpoint and item schemas (entitlement-only; grant/modify account selection; revoke nativeIdentity).
.OUTPUTS

AccessRequest<PSCustomObject>
#>


function Initialize-AccessRequest {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String[]]
        ${RequestedFor},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("GRANT_ACCESS", "REVOKE_ACCESS", "MODIFY_ACCESS", "")]
        [PSCustomObject]
        ${RequestType},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject[]]
        ${RequestedItems},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Collections.Hashtable]
        ${ClientMetadata},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject[]]
        ${RequestedForWithRequestedItems}
    )

    Process {
        'Creating PSCustomObject: PSSailpoint.AccessRequests => AccessRequest' | Write-Debug
        $PSBoundParameters | Out-DebugParameter | Write-Debug

        if (!$RequestedItems -and $RequestedItems.length -lt 1) {
            throw "invalid value for 'RequestedItems', number of items must be greater than or equal to 1."
        }


        $PSO = [PSCustomObject]@{
            "requestedFor" = ${RequestedFor}
            "requestType" = ${RequestType}
            "requestedItems" = ${RequestedItems}
            "clientMetadata" = ${ClientMetadata}
            "requestedForWithRequestedItems" = ${RequestedForWithRequestedItems}
        }

        return $PSO
    }
}

<#
.SYNOPSIS

Convert from JSON to AccessRequest<PSCustomObject>

.DESCRIPTION

Convert from JSON to AccessRequest<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

AccessRequest<PSCustomObject>
#>

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

    Process {
        'Converting JSON to PSCustomObject: PSSailpoint.AccessRequests => AccessRequest' | Write-Debug
        $PSBoundParameters | Out-DebugParameter | Write-Debug

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in AccessRequest
        $AllProperties = ("requestedFor", "requestType", "requestedItems", "clientMetadata", "requestedForWithRequestedItems")
        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 "requestedFor"))) { #optional property not found
            $RequestedFor = $null
        } else {
            $RequestedFor = $JsonParameters.PSobject.Properties["requestedFor"].value
        }

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

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

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

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

        $PSO = [PSCustomObject]@{
            "requestedFor" = ${RequestedFor}
            "requestType" = ${RequestType}
            "requestedItems" = ${RequestedItems}
            "clientMetadata" = ${ClientMetadata}
            "requestedForWithRequestedItems" = ${RequestedForWithRequestedItems}
        }

        return $PSO
    }

}