Api/GenericRequestApprovalConfigApi.ps1

#
# Identity Security Cloud API - Generic Request Approval Config
# 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

Get generic request approval config

.DESCRIPTION

This API returns the approval configuration for one scope. The scope is identified by `targetType` and, depending on the target type, `targetId` and `sourceId`. The response holds one entry per action that the target type supports. An action with no stored setting is returned as `{}`, which means it inherits the organization-level approval configuration. A scope that has never been configured returns `200` with every action set to `{}`, and the response always carries the `id` to use with the update API. Actions by target type: **RESOURCE**: *ACTIVATE, DEACTIVATE* **SUBTYPE**: *CREATE, DELETE* **SOURCE**: *DELETE* **GLOBAL**: *ACTIVATE, DEACTIVATE* Only resources of the AI agent type support resource-level approval settings; any other resource returns `400`. An unknown source, resource, or subtype returns `400`. When agentic identity provisioning is not enabled for the tenant, this API returns `404`. When this API is not enabled for the tenant, it returns `403`.

.PARAMETER TargetType
The kind of scope to read.

.PARAMETER XSailPointExperimental
Use this header to enable this experimental API.

.PARAMETER TargetId
The scope target. Required for **RESOURCE** (the source resource ID) and **SUBTYPE** (the subtype ID). For **SOURCE** the target is the `sourceId`, and for **GLOBAL** it is the tenant; when you supply it for those target types, it must match that value or the request returns `400`.

.PARAMETER SourceId
The source that owns the scope. Required for **RESOURCE**, **SUBTYPE**, and **SOURCE**. Must be omitted for **GLOBAL**.

.PARAMETER WithHttpInfo

A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response

.OUTPUTS

GenericRequestApprovalConfig
#>

function Get-GenericRequestApprovalConfigV1 {
    [CmdletBinding()]
    Param (
        [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
        [ValidateSet("RESOURCE", "SUBTYPE", "SOURCE", "GLOBAL")]
        [String]
        ${TargetType},
        [Parameter(Position = 1, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
        [String]
        $XSailPointExperimental = "true",
        [Parameter(Position = 2, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
        [String]
        ${TargetId},
        [Parameter(Position = 3, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
        [String]
        ${SourceId},
        [Switch]
        $WithHttpInfo
    )

    Process {
        'Calling method: Get-GenericRequestApprovalConfigV1' | Write-Debug
        $PSBoundParameters | Out-DebugParameter | Write-Debug

        $LocalVarAccepts = @()
        $LocalVarContentTypes = @()
        $LocalVarQueryParameters = @{}
        $LocalVarHeaderParameters = @{}
        $LocalVarFormParameters = @{}
        $LocalVarPathParameters = @{}
        $LocalVarCookieParameters = @{}
        $LocalVarBodyParameter = $null

        # HTTP header 'Accept' (if needed)
        $LocalVarAccepts = @('application/json')

        $LocalVarUri = '/generic-request-approval-config/v1'

        if (!$XSailPointExperimental) {
            throw "Error! The required parameter `XSailPointExperimental` missing when calling getGenericRequestApprovalConfigV1."
        }
        $LocalVarHeaderParameters['X-SailPoint-Experimental'] = $XSailPointExperimental

        if (!$TargetType) {
            throw "Error! The required parameter `TargetType` missing when calling getGenericRequestApprovalConfigV1."
        }
        $LocalVarQueryParameters['targetType'] = $TargetType

        if ($TargetId) {
            $LocalVarQueryParameters['targetId'] = $TargetId
        }

        if ($SourceId) {
            $LocalVarQueryParameters['sourceId'] = $SourceId
        }

        $LocalVarResult = Invoke-ApiClient -Method 'GET' `
                                -Uri $LocalVarUri `
                                -Accepts $LocalVarAccepts `
                                -ContentTypes $LocalVarContentTypes `
                                -Body $LocalVarBodyParameter `
                                -HeaderParameters $LocalVarHeaderParameters `
                                -QueryParameters $LocalVarQueryParameters `
                                -FormParameters $LocalVarFormParameters `
                                -CookieParameters $LocalVarCookieParameters `
                                -ReturnType "GenericRequestApprovalConfig" `
                                -IsBodyNullable $false

        if ($WithHttpInfo.IsPresent) {
            return $LocalVarResult
        } else {
            return $LocalVarResult["Response"]
        }
    }
}

<#
.SYNOPSIS

Patch generic request approval config

.DESCRIPTION

Use this API to update the approval configuration of one scope using a JSON Patch payload. Use the `id` returned by the get API. Patchable paths are `/approvalConfig`, which replaces every action at once, and `/approvalConfig/{ACTION}` for each action the scope's target type supports. One request can update several actions. `id`, `targetType`, and `targetId` identify the scope and can't be patched; a patch that targets any other path returns `400`. To return an action to the organization-level approval configuration, `remove` it or `replace` it with `{}`. Each configured action uses one scheme: **APPROVAL**: requires `approvers` and `comments`. `approvers` is a comma-separated list of approver tokens: `sourceOwner`, `manager`, `machineIdentityPrimaryOwner`, `machineIdentitySecondaryOwners`, `machineIdentityAllOwners`, `workgroup:{governanceGroupId}`, and `identity:{identityId}`. For the **SUBTYPE** **DELETE** action, `accountOwner` is also allowed. Tokens without an ID can appear at most once, and IDs must be unique and must exist. `comments` is one of `ALL`, `APPROVAL`, `REJECTION`, or `OFF`. **WORKFLOW**: requires `workflowId`, the UUID of a workflow. The same workflow can't be used for more than one action. When workflow approvals are enabled for the tenant, the workflow must exist, be enabled, and use the trigger for its action (`idn:machine-identity-activate` for ACTIVATE, `idn:machine-identity-deactivate` for DEACTIVATE). The **GLOBAL** scope only accepts the **WORKFLOW** scheme. The ID must be a UUID; any other value returns `400`. When no approval configuration exists for the ID, this API returns `404`. When agentic identity provisioning is not enabled for the tenant, this API returns `404`. When this API is not enabled for the tenant, it returns `403`.

.PARAMETER Id
Approval configuration ID.

.PARAMETER XSailPointExperimental
Use this header to enable this experimental API.

.PARAMETER JsonPatchOperation
A JSON of updated values [JSON Patch](https://tools.ietf.org/html/rfc6902) standard.

.PARAMETER WithHttpInfo

A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response

.OUTPUTS

GenericRequestApprovalConfig
#>

function Update-GenericRequestApprovalConfigV1 {
    [CmdletBinding()]
    Param (
        [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
        [String]
        ${Id},
        [Parameter(Position = 1, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
        [String]
        $XSailPointExperimental = "true",
        [Parameter(Position = 2, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
        [PSCustomObject[]]
        ${JsonPatchOperation},
        [Switch]
        $WithHttpInfo
    )

    Process {
        'Calling method: Update-GenericRequestApprovalConfigV1' | Write-Debug
        $PSBoundParameters | Out-DebugParameter | Write-Debug

        $LocalVarAccepts = @()
        $LocalVarContentTypes = @()
        $LocalVarQueryParameters = @{}
        $LocalVarHeaderParameters = @{}
        $LocalVarFormParameters = @{}
        $LocalVarPathParameters = @{}
        $LocalVarCookieParameters = @{}
        $LocalVarBodyParameter = $null

        # HTTP header 'Accept' (if needed)
        $LocalVarAccepts = @('application/json')

        # HTTP header 'Content-Type'
        $LocalVarContentTypes = @('application/json-patch+json')

        $LocalVarUri = '/generic-request-approval-config/v1/{id}'
        if (!$Id) {
            throw "Error! The required parameter `Id` missing when calling updateGenericRequestApprovalConfigV1."
        }
        $LocalVarUri = $LocalVarUri.replace('{id}', [System.Web.HTTPUtility]::UrlEncode($Id))

        if (!$XSailPointExperimental) {
            throw "Error! The required parameter `XSailPointExperimental` missing when calling updateGenericRequestApprovalConfigV1."
        }
        $LocalVarHeaderParameters['X-SailPoint-Experimental'] = $XSailPointExperimental

        if (!$JsonPatchOperation) {
            throw "Error! The required parameter `JsonPatchOperation` missing when calling updateGenericRequestApprovalConfigV1."
        }

        if ($LocalVarContentTypes.Contains('application/json-patch+json') -or ($JsonPatchOperation -is [array])) {
            $LocalVarBodyParameter = $JsonPatchOperation | ConvertTo-Json -AsArray -Depth 100
        } else {
            $LocalVarBodyParameter = $JsonPatchOperation | ForEach-Object {
            # Get array of names of object properties that can be cast to boolean TRUE
            # PSObject.Properties - https://msdn.microsoft.com/en-us/library/system.management.automation.psobject.properties.aspx
            $NonEmptyProperties = $_.psobject.Properties | Where-Object {$null -ne $_.Value} | Select-Object -ExpandProperty Name
        
            # Convert object to JSON with only non-empty properties
            $_ | Select-Object -Property $NonEmptyProperties | ConvertTo-Json -Depth 100
            }
        }

        $LocalVarResult = Invoke-ApiClient -Method 'PATCH' `
                                -Uri $LocalVarUri `
                                -Accepts $LocalVarAccepts `
                                -ContentTypes $LocalVarContentTypes `
                                -Body $LocalVarBodyParameter `
                                -HeaderParameters $LocalVarHeaderParameters `
                                -QueryParameters $LocalVarQueryParameters `
                                -FormParameters $LocalVarFormParameters `
                                -CookieParameters $LocalVarCookieParameters `
                                -ReturnType "GenericRequestApprovalConfig" `
                                -IsBodyNullable $false

        if ($WithHttpInfo.IsPresent) {
            return $LocalVarResult
        } else {
            return $LocalVarResult["Response"]
        }
    }
}