Skip to content

Commit

Permalink
Fixed Groups loading + added Domains + Groups caller
Browse files Browse the repository at this point in the history
  • Loading branch information
tirnovar committed Aug 29, 2024
1 parent 33d293b commit 8c5d402
Show file tree
Hide file tree
Showing 2 changed files with 213 additions and 34 deletions.
Binary file modified .DS_Store
Binary file not shown.
247 changes: 213 additions & 34 deletions 03 - Development/pbiAdminAPI/pbiAdminAPI.pq
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ fabric_api_uri = "https://api.fabric.microsoft.com/v1";

// Connector Window
windowWidth = 1024;

windowHeight = 1024;

// Source
Expand Down Expand Up @@ -314,6 +313,14 @@ MetricsNavigation = () as table =>
"Function",
"GoalValuesAndNotes",
true
},
{
Extension.LoadString("GroupsCaller"),
"GroupsCaller",
pbiAdminAPI.GroupsCaller,
"Function",
"GroupsCaller",
true
}
}
),
Expand Down Expand Up @@ -377,7 +384,12 @@ AboutTenantNavigation = () as table =>
{"Name", "Key", "Data", "ItemKind", "ItemName", "IsLeaf"},
{
{
Extension.LoadString("TenantSettings"), "TenantSettings", pbiAdminAPI.TenantSettings(), "Table", "Table", true
Extension.LoadString("TenantSettings"),
"TenantSettings",
pbiAdminAPI.TenantSettings(),
"Table",
"Table",
true
},
{Extension.LoadString("TenantKeys"), "TenantKeys", pbiAdminAPI.TenantKeys(), "Table", "Table", true},
{Extension.LoadString("Imports"), "Imports", pbiAdminAPI.Imports(), "Table", "Table", true},
Expand Down Expand Up @@ -405,6 +417,14 @@ AboutTenantNavigation = () as table =>
"Table",
"Table",
true
},
{
Extension.LoadString("Domains"),
"Domains",
pbiAdminAPI.Domains(),
"Table",
"Table",
true
}
}
),
Expand Down Expand Up @@ -562,7 +582,7 @@ ActivityNavigation = () as table =>
"Table",
"Table",
true
}
}
}
),
Navigation = Table.ForceToNavigationTable(objects, {"Key"}, "Name", "Data", "ItemKind", "ItemName", "IsLeaf")
Expand All @@ -585,39 +605,46 @@ pbiAdminAPI = [
// ** Groups
[
DataSource.Kind = "pbiAdminAPI"
] pbiAdminAPI.Groups = (optional expandParameters) =>
] pbiAdminAPI.Groups = () =>
let
expandParameters = if expandParameters = null then "users,reports,dashboards,datasets,dataflows,workbooks" else expandParameters,
expandParameters = "users,reports,dashboards,datasets,dataflows,workbooks",
queryRecord = [#"$top" = "5000", #"$expand" = expandParameters],
apiCall =
List.Generate(
()=>[values = Json.Document(
Web.Contents(
api_uri,
[
RelativePath = "admin/groups",
Headers = [
#"Content-Type" = "application/json"
],
Query = queryRecord
]
)
)[value]?, index = 5000],
each [values] <> null or List.IsEmpty([values]),
each [values = Json.Document(
Web.Contents(
api_uri,
[
RelativePath = "admin/groups",
Headers = [
#"Content-Type" = "application/json"
],
Query = Record.AddField(queryRecord,"$skip",Text.From(index))
]
)
)[value]?, index = [index] + 5000],
apiCall = List.Combine(List.Generate(
() =>
[
values = Json.Document(
Web.Contents(
api_uri,
[
RelativePath = "admin/groups",
Headers = [
#"Content-Type" = "application/json"
],
Query = queryRecord
]
)
)[value]?,
index = 5000
],
each not List.IsEmpty([values]),
each
[
values = Json.Document(
Web.Contents(
api_uri,
[
RelativePath = "admin/groups",
Headers = [
#"Content-Type" = "application/json"
],
Query = Record.AddField(queryRecord, "$skip", Text.From(index))
]
)
)[value]?,
index = [index] + 5000
],
each [values]
),
)),
output = #table(
type table [
id = text,
Expand All @@ -641,7 +668,7 @@ pbiAdminAPI = [
{
_[id]?,
Logical.From(_[isReadOnly]?),
_[isOnDedicatedCapacity]?,
Logical.From(_[isOnDedicatedCapacity]?),
_[capacityId]?,
_[capacityMigrationStatus]?,
_[#"type"]?,
Expand Down Expand Up @@ -1926,6 +1953,44 @@ DatasourcesOfDataset = (optional datasetId as text) =>
)
in
output;
//**** Domains
[
DataSource.Kind = "pbiAdminAPI"
] pbiAdminAPI.Domains = () =>
let
apiCall = Json.Document(
Web.Contents(
fabric_api_uri,
[
RelativePath = "admin/domains",
Headers = [
#"Content-Type" = "application/json"
]
]
)
),
output = #table(
type table [
id = text,
displayName = text,
description = text,
parentDomainId = text,
contributionsScope = text
],
List.Transform(
apiCall[domains],
each
{
_[id]?,
_[displayName]?,
_[description]?,
_[parentDomainId]?,
_[contributionsScope]?
}
)
)
in
output;
//**** Encryption Keys
[
DataSource.Kind = "pbiAdminAPI"
Expand Down Expand Up @@ -3252,6 +3317,120 @@ ScannerAPIStatusAndResult = (optional scanId as text) =>
in
functionVarTester;

shared pbiAdminAPI.GroupsCaller = Value.ReplaceType(GroupsCaller, GroupsCallerType);

GroupsCallerType = type function (
optional workspaceId as (
type text meta [
Documentation.FieldCaption = "expandParameter",
Documentation.FieldDescription = "expandParameter represents what you want to expand. If you want to expand all, just leave it empty.",
Documentation.SampleValues = {"users,reports,dashboards,..."}
]
)
) as table meta [
Documentation.Name = "pbiAdminAPI.GroupsCaller",
Documentation.LongDescription = "This call can be used to easier extracting of workspaces and their content.",
Documentation.Examples = {
[
Code = "=pbiAdminAPI.GroupsCaller(null)",
Result = "With all expanding parameters"
],
[
Code = "=pbiAdminAPI.GroupsCaller(""users,reports,dashboards,datasets"")",
Result = "With all selected expanding parameters"
],
[
Code = "=pbiAdminAPI.GroupsCaller("""")",
Result = "Without any expanding parameters"
]
}
];

GroupsCaller = (optional expandParameter as text) =>
let
expandParameters =
if expandParameter = null then
"users,reports,dashboards,datasets,dataflows,workbooks"
else
expandParameter,
queryRecord = [#"$top" = "5000", #"$expand" = expandParameters],
apiCall = List.Combine(List.Generate(
() =>
[
values = Json.Document(
Web.Contents(
api_uri,
[
RelativePath = "admin/groups",
Headers = [
#"Content-Type" = "application/json"
],
Query = queryRecord
]
)
)[value]?,
index = 5000
],
each not List.IsEmpty([values]),
each
[
values = Json.Document(
Web.Contents(
api_uri,
[
RelativePath = "admin/groups",
Headers = [
#"Content-Type" = "application/json"
],
Query = Record.AddField(queryRecord, "$skip", Text.From(index))
]
)
)[value]?,
index = [index] + 5000
],
each [values]
)),
output = #table(
type table [
id = text,
isReadOnly = logical,
isOnDedicatedCapacity = logical,
capacityId = text,
capacityMigrationStatus = text,
#"type" = text,
state = text,
name = text,
users = list,
reports = list,
dashboards = list,
datasets = list,
dataflows = list,
workbooks = list
],
List.Transform(
apiCall,
each
{
_[id]?,
Logical.From(_[isReadOnly]?),
Logical.From(_[isOnDedicatedCapacity]?),
_[capacityId]?,
_[capacityMigrationStatus]?,
_[#"type"]?,
_[state]?,
_[name]?,
_[users]?,
_[reports]?,
_[dashboards]?,
_[datasets]?,
_[dataflows]?,
_[workbooks]?
}
)
)
in
output;

//**** Table of Datasets
[
DataSource.Kind = "pbiAdminAPI"
Expand Down

0 comments on commit 8c5d402

Please sign in to comment.