resources/privileges.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
function Assert-QlikPrivilege { [CmdletBinding()] param ( [parameter(Mandatory = $true, Position = 1, ValueFromPipeline = $true)] [object]$InputObject, [parameter(Position = 0)] [string[]]$privileges ) PROCESS { $access = @(Get-QlikPrivileges -InputObject $InputObject) $privileges.ForEach{ if ($access -notcontains $_) { throw ("Expected '{0}' to be found in collection @('{1}'), but it was not found. {2} - {{{3}}}" -f $_, ($access -join "', '"), $InputObject.schemaPath, $InputObject.id) } } } } function Get-QlikPrivilege { [CmdletBinding()] param ( [parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)] [object]$InputObject, [int]$privilegesFilter ) PROCESS { $resourceType = $InputObject.schemaPath $path = "/qrs/$resourceType/previewprivileges" If ( $privilegesFilter ) { $path += "?privilegesFilter=$privilegesFilter" } return Invoke-QlikPost $path ($InputObject | ConvertTo-Json -Depth 10 -Compress) } } |