From 8c5d402e27bb6d81fed0bd75b354f06d08b7ed30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0t=C4=9Bp=C3=A1n=20Re=C5=A1l?= Date: Thu, 29 Aug 2024 17:05:13 +0200 Subject: [PATCH] Fixed Groups loading + added Domains + Groups caller --- .DS_Store | Bin 6148 -> 6148 bytes 03 - Development/pbiAdminAPI/pbiAdminAPI.pq | 247 +++++++++++++++++--- 2 files changed, 213 insertions(+), 34 deletions(-) diff --git a/.DS_Store b/.DS_Store index c55f1203beb79bf9ba5810d399dcc8b5c0c4e704..415ea6a14fded03ba1fc241bc49786f07d0a2643 100644 GIT binary patch delta 545 zcmZoMXfc=|#>B!ku~2NHo+2aD#DLw4n3yLUh_FoNXM6(0vh|tCWd%t&`AG~6jE9m6 zax#lc3=HlI2rx1+v#_$Ub8vET^YHTV3kV7c3yKJeii(Pfi%LjJNXH8ZCnY9lrx)dy z=A}62=j0bT<&>sIWG3h51!q>JMwFyhlzKlB5JL4Kl?6aWA_x(%VeUn# zsd>@qMVTr7X=%l&B@yug{Kd&d`8hcO`Nf$fnfZBB`mu~2NHo+2aT#DLw5jFUgGC`{I2IlfthLzrb_10&OBb`E|HpsLM+ b9N(EI^NUytFaQA~0|OJ3X4xDevW6J|0Ot^V diff --git a/03 - Development/pbiAdminAPI/pbiAdminAPI.pq b/03 - Development/pbiAdminAPI/pbiAdminAPI.pq index 3b28266..adc0c69 100644 --- a/03 - Development/pbiAdminAPI/pbiAdminAPI.pq +++ b/03 - Development/pbiAdminAPI/pbiAdminAPI.pq @@ -23,7 +23,6 @@ fabric_api_uri = "https://api.fabric.microsoft.com/v1"; // Connector Window windowWidth = 1024; - windowHeight = 1024; // Source @@ -314,6 +313,14 @@ MetricsNavigation = () as table => "Function", "GoalValuesAndNotes", true + }, + { + Extension.LoadString("GroupsCaller"), + "GroupsCaller", + pbiAdminAPI.GroupsCaller, + "Function", + "GroupsCaller", + true } } ), @@ -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}, @@ -405,6 +417,14 @@ AboutTenantNavigation = () as table => "Table", "Table", true + }, + { + Extension.LoadString("Domains"), + "Domains", + pbiAdminAPI.Domains(), + "Table", + "Table", + true } } ), @@ -562,7 +582,7 @@ ActivityNavigation = () as table => "Table", "Table", true - } + } } ), Navigation = Table.ForceToNavigationTable(objects, {"Key"}, "Name", "Data", "ItemKind", "ItemName", "IsLeaf") @@ -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, @@ -641,7 +668,7 @@ pbiAdminAPI = [ { _[id]?, Logical.From(_[isReadOnly]?), - _[isOnDedicatedCapacity]?, + Logical.From(_[isOnDedicatedCapacity]?), _[capacityId]?, _[capacityMigrationStatus]?, _[#"type"]?, @@ -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" @@ -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"