-
Notifications
You must be signed in to change notification settings - Fork 13
/
get-LinksSharedToWholeOrganization.pq
80 lines (80 loc) · 3.25 KB
/
get-LinksSharedToWholeOrganization.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
let
output =
(generatedToken as text) =>
let
callingPath = "https://api.powerbi.com/v1.0/myorg/admin/widelySharedArtifacts/linksSharedToWholeOrganization",
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[ArtifactAccessEntities]?
],
each [uri] <> null,
each
[
result = apiCalling(uri, callInitStructure),
uri = _[result][continuationUri]?
],
each [result][ArtifactAccessEntities]?
)
),
union = List.Union(generator)
in
#table(
type table [
artifactId = text,
displayName = text,
artifactType = text,
accessRight = text,
shareType = text,
sharer.emailAddress = text,
sharer.displayName = text,
sharer.identifier = text,
sharer.graphId = text,
sharer.principalType = text
],
List.Transform(
List.RemoveNulls(union),
each
{
_[artifactId]?,
_[displayName]?,
_[artifactType]?,
_[accessRight]?,
_[shareType]?,
_[sharer]?[emailAddress]?,
_[sharer]?[displayName]?,
_[sharer]?[identifier]?,
_[sharer]?[graphId]?,
_[sharer]?[principalType]?
}
)
),
documentation = [
Documentation.Name = " get-LinksSharedToWholeOrganization.pq ",
Documentation.Description = " Get the links shared to the whole organization ",
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
)
)