Public/Set-GCUserRoles.ps1

<#
.SYNOPSIS
    Sets the roles for a subject in Genesys Cloud.

.DESCRIPTION
    Replaces the authorization roles assigned to a specific subject (user or group) using
    a PUT request. The body should contain the complete set of role assignments.
    API Endpoint: PUT /api/v2/authorization/subjects/{subjectId}/roles

.PARAMETER SubjectId
    The unique identifier of the subject (user or group) whose roles to set.

.PARAMETER Body
    The request body containing the role assignments. Accepts a hashtable or JSON string.
    Should include an array of role objects with division assignments.

.EXAMPLE
    Set-GCUserRoles -SubjectId '12345678-1234-1234-1234-123456789012' -Body @(@{ roleId = 'role-id'; divisionId = 'div-id' })
    Sets the roles for the specified subject.

.NOTES
    Genesys Cloud API: PUT /api/v2/authorization/subjects/{subjectId}/roles
#>

function Set-GCUserRoles {
    [CmdletBinding()]
    param(
        [Parameter(Mandatory = $true)]
        [string]$SubjectId,

        [Parameter(Mandatory = $true)]
        [object]$Body
    )

    $endpoint = "authorization/subjects/$SubjectId/roles"
    return Invoke-GCApiRequest -Endpoint $endpoint -Method PUT -Body $Body
}