Public/MIT/Set-MITFolderAcl.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
function Set-MITFolderAcl {
    [CmdletBinding()]
    param (
        [Parameter(Mandatory)]
        [string]$Id,
        [Parameter(Mandatory)]
        [ValidateSet('User','Group')]
        [string]$Type,
        [Parameter(Mandatory)]
        [string]$TypeId,
        [switch]$ReadFiles,
        [switch]$WriteFiles,
        [switch]$DeleteFiles,
        [switch]$ListFiles,
        [switch]$Notify,
        [switch]$AddDeleteSubfolders,
        [switch]$Share,
        [switch]$Admin,
        [switch]$ListUsers
    )

    # Need to build the body for this request. Doesn't currently include setting share permissions.
    $body = @{
        type = "$Type"
        id = "$TypeId"
        permissions = @{
            readFiles = "$ReadFiles"
            writeFiles = "$WriteFiles"
            deleteFiles = "$DeleteFiles"
            listFiles = "$ListFiles"
            notify = "$Notify"
            addDeleteSubfolders = "$AddDeleteSubfolders"
            share = "$Share"
            admin = "$Admin"
            listUsers = "$ListUsers"
        }
    }

    $response = Invoke-MITRequest -Method 'Put' -Resource "folders/$Id/acls" -Body $body
    Write-MITOutput -Response $response -Typename 'MIREST.MITFolderAcl'
# "type": "None",
# "id": "string",
# "permissions": {
# "readFiles": true,
# "writeFiles": true,
# "deleteFiles": true,
# "listFiles": true,
# "notify": true,
# "addDeleteSubfolders": true,
# "share": true,
# "sharePermissions": {
# "readFiles": true,
# "writeFiles": true,
# "deleteFiles": true,
# "listFiles": true,
# "notify": true,
# "listUsers": true
# },
# "admin": true,
# "listUsers": true
}