-
Notifications
You must be signed in to change notification settings - Fork 13
/
get-UserSubscriptionsAsAdmin.pq
93 lines (93 loc) · 3.82 KB
/
get-UserSubscriptionsAsAdmin.pq
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
let
output =
(generatedToken as text, identifier as text) =>
let
callingPath =
"https://api.powerbi.com/v1.0/myorg/admin/users/"
& identifier
& "/subscriptions",
callInitStructure = [
Headers = [
#"Content-Type" = "application/json",
Authorization = generatedToken
]
],
apiCalling = (uri as text, structure as record) => Json.Document(Web.Contents(uri, structure)),
generator =
List.Buffer(
List.Generate(
() =>
[
result =
apiCalling(
callingPath,
callInitStructure
),
uri = result[continuationUri]?
],
each [uri] <> null,
each
[
result = apiCalling(uri, callInitStructure),
uri = _[result][continuationUri]?
],
each [result][SubscriptionEntities]?
)
),
combined = List.Buffer(List.Union(generator)),
resultTable =
#table(
type table [
id = text,
title = text,
artifactId = text,
artifactDislayName = text,
subArtifactDisplayName = text,
artifactType = text,
isEnabled = logical,
frequency = text,
startDate = datetime,
endDate = datetime,
linkToContent = logical,
previewImage = logical,
attachmentFormat = text,
users = list
],
List.Transform(
List.RemoveNulls(combined),
each
{
_[id]?,
_[tite]?,
_[artifactId]?,
_[artifactDislayName]?,
_[subArtifactDisplayName]?,
_[artifactType]?,
_[isEnabled]?,
_[frequency]?,
_[startDate]?,
_[endDate]?,
_[linkToContent]?,
_[previewImage]?,
_[attachmentFormat]?,
_[users]?
}
)
)
in
resultTable,
documentation = [
Documentation.Name = " get-UserSubscriptionsAsAdmin.pq ",
Documentation.Description = " Get user subscriptions as an Admin ",
Documentation.Source = "https://www.jaknapowerbi.cz",
Documentation.Version = " 1.0 ",
Documentation.Author = " Štěpán Rešl "
]
in
Value.ReplaceType(
output,
Value.ReplaceMetadata(
Value.Type(output),
documentation
)
)