Public/Access/Deny-SIAAccessRequest.ps1

function Deny-SIAAccessRequest {
    <#
    .SYNOPSIS
        Rejects an open SIA access request.
    .DESCRIPTION
        Calls the access request finalize operation to reject a pending
        request. Only a user who is an assigned approver for the request can
        call this successfully.
    .PARAMETER Id
        The access request's ID, as returned by Get-SIAAccessRequest.
    .PARAMETER Reason
        The reason for rejecting the request.
    .EXAMPLE
        Deny-SIAAccessRequest -Id 'req-01' -Reason 'Insufficient justification'

        Rejects the specified access request.
    .INPUTS
        psSIA.AccessRequest
    .OUTPUTS
        psSIA.AccessRequest
    .LINK
        https://api-docs.cyberark.com/access-request-api/docs/access-request-api
    #>

    [CmdletBinding(SupportsShouldProcess)]
    [OutputType('psSIA.AccessRequest')]
    param(
        [Parameter(Mandatory, ValueFromPipelineByPropertyName)]
        [Alias('requestId')]
        [string]$Id,

        [Parameter(Mandatory)]
        [string]$Reason
    )

    process {
        if ($PSCmdlet.ShouldProcess($Id, 'Reject access request')) {
            $body = @{
                result             = 'REJECTED'
                finalizationReason = $Reason
            }
            Invoke-SIARequest -Method POST -Path "/workflows/requests/$Id/finalize" -Body $body -Service Uar |
                ConvertFrom-SIAResponse -TypeName 'psSIA.AccessRequest'
        }
    }
}