Public/Roles/Get-UKGRolePermission.ps1
|
function Get-UKGRoleCorePermission { <# .SYNOPSIS Gets core permissions for a role from the UKG HR Service Delivery API. .DESCRIPTION Retrieves the core permissions assigned to a specific role. .PARAMETER RoleId The unique identifier of the role. .EXAMPLE Get-UKGRoleCorePermission -RoleId "role123" .OUTPUTS UKG.RolePermission object containing core permissions. #> [CmdletBinding()] [OutputType([PSCustomObject])] param( [Parameter(Mandatory, ValueFromPipelineByPropertyName)] [ValidateNotNullOrEmpty()] [Alias('Id')] [string]$RoleId ) process { $response = Invoke-UKGRequest -Endpoint "/roles/$RoleId/permissions/core" -Method GET if ($response) { $response.PSObject.TypeNames.Insert(0, 'UKG.RolePermission') } return $response } } function Set-UKGRoleCorePermission { <# .SYNOPSIS Sets core permissions for a role in the UKG HR Service Delivery system. .DESCRIPTION Updates the core permissions assigned to a specific role. .PARAMETER RoleId The unique identifier of the role. .PARAMETER Permissions Hashtable or array of permission settings. .PARAMETER InputObject A PSCustomObject containing the permission settings. .EXAMPLE Set-UKGRoleCorePermission -RoleId "role123" -Permissions @{ employees = @{ read = $true; write = $true } documents = @{ read = $true; write = $false } } .OUTPUTS UKG.RolePermission object representing the updated permissions. #> [CmdletBinding(SupportsShouldProcess)] [OutputType([PSCustomObject])] param( [Parameter(Mandatory, ValueFromPipelineByPropertyName)] [ValidateNotNullOrEmpty()] [Alias('Id')] [string]$RoleId, [Parameter(Mandatory, ParameterSetName = 'Hashtable')] [hashtable]$Permissions, [Parameter(Mandatory, ParameterSetName = 'InputObject')] [object]$InputObject ) process { $body = @{} if ($InputObject) { if ($InputObject -is [hashtable]) { $body = $InputObject.Clone() } else { foreach ($prop in $InputObject.PSObject.Properties) { $body[$prop.Name] = $prop.Value } } } else { $body = $Permissions } if ($PSCmdlet.ShouldProcess($RoleId, 'Update Core Permissions')) { $response = Invoke-UKGRequest -Endpoint "/roles/$RoleId/permissions/core" -Method PUT -Body $body if ($response) { $response.PSObject.TypeNames.Insert(0, 'UKG.RolePermission') } return $response } } } function Get-UKGRoleEFMPermission { <# .SYNOPSIS Gets EFM (Electronic File Management) permissions for a role. .DESCRIPTION Retrieves the EFM permissions assigned to a specific role. .PARAMETER RoleId The unique identifier of the role. .EXAMPLE Get-UKGRoleEFMPermission -RoleId "role123" .OUTPUTS UKG.RolePermission object containing EFM permissions. #> [CmdletBinding()] [OutputType([PSCustomObject])] param( [Parameter(Mandatory, ValueFromPipelineByPropertyName)] [ValidateNotNullOrEmpty()] [Alias('Id')] [string]$RoleId ) process { $response = Invoke-UKGRequest -Endpoint "/roles/$RoleId/permissions/efm" -Method GET if ($response) { $response.PSObject.TypeNames.Insert(0, 'UKG.RolePermission') } return $response } } |