resources/license.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
function Get-QlikAccessTypeInfo {
  PROCESS {
    return Invoke-QlikGet "/qrs/license/accesstypeinfo"
  }
}

function Get-QlikLicense {
  PROCESS {
    return Invoke-QlikGet "/qrs/license"
  }
}

function Get-QlikLicenseAudit {
  [CmdletBinding()]
  param (
    [string]$resourceType,
    [string]$resourceFilter,
    [string]$userFilter,
    [string]$environmentAttributes,
    [int]$userSkip,
    [int]$userTake,
    [int]$resourceSkip,
    [int]$resourceTake,
    [switch]$includeNonGrantingRules,
    [parameter(ValueFromPipelinebyPropertyName=$true)]
    [alias("id")]
    [string]$resourceId,
    [switch]$raw
  )
  PROCESS {
    $params = @{
      resourceType = $resourceType;
      resourceFilter = $resourceFilter;
      userFilter = $userFilter;
      environmentAttributes = $environmentAttributes;
      userSkip = $userSkip;
      userTake = $userTake;
      resourceSkip = $resourceSkip;
      resourceTake = $resourceTake;
    }
    If( $includeNonGrantingRules ) { $params.includeNonGrantingRules = $true }
    If( $resourceId ) { $params.resourceFilter = "id eq $resourceId" }
    $json = $params | ConvertTo-Json -Compress -Depth 10
    If( $raw ) { $rawOutput = $true }
    return Invoke-QlikPost "/qrs/systemrule/license/audit" $json
  }
}

function Get-QlikLoginAccess {
  [CmdletBinding()]
  param (
    [parameter(Position=0)]
    [string]$id,
    [string]$filter,
    [switch]$full,
    [switch]$raw
  )

  PROCESS {
    $path = "/qrs/license/loginAccessType"
    If( $id ) { $path += "/$id" }
    If( $full ) { $path += "/full" }
    If( $raw ) { $rawOutput = $true }
    return Invoke-QlikGet $path $filter
  }
}

function Get-QlikUserAccessType {
  [CmdletBinding()]
  param (
    [parameter(Position=0)]
    [string]$id,
    [string]$filter,
    [switch]$full,
    [switch]$raw
  )

  PROCESS {
    $path = "/qrs/license/useraccesstype"
    If( $id ) { $path += "/$id" }
    If( $full ) { $path += "/full" }
    If( $raw ) { $rawOutput = $true }
    return Invoke-QlikGet $path $filter
  }
}

function New-QlikUserAccessGroup {
  [CmdletBinding()]
  param (
    [string]$name
  )

  PROCESS {
    $json = (@{
      name=$name
    } | ConvertTo-Json -Compress -Depth 10)

    return Invoke-QlikPost "/qrs/License/UserAccessGroup" $json
  }
}

function Remove-QlikUserAccessType {
  [CmdletBinding()]
  param (
    [parameter(Position=0,ValueFromPipelinebyPropertyName=$true)]
    [string]$id
  )
  PROCESS {
    return Invoke-QlikDelete -path "/qrs/license/useraccesstype/$id"
  }
}

function Set-QlikLicense {
  [CmdletBinding()]
  param (
    [parameter(Mandatory=$true,Position=0)]
    [string]$serial,

    [parameter(Mandatory=$true,Position=1)]
    [string]$control,

    [parameter(Mandatory=$true,Position=2)]
    [string]$name,

    [parameter(Mandatory=$true,Position=3)]
    [alias("org")]
    [string]$organization,

    [parameter(Mandatory=$false,Position=4)]
    [string]$lef
  )

  PROCESS {
    $resource = "/qrs/license?control=$control"
    $json = @{
      serial = $serial;
      name = $name;
      organization = $organization;
      lef = $lef;
    } | ConvertTo-Json
    Invoke-QlikPost $resource $json

    return $result
  }
}