power-bi 2.4.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 90d415a89ed5860c82824f7e152e4c58d42054bc293f5534f6669774682a1ffe
4
- data.tar.gz: 536d4c7cea48c859c7b780db751da15375b060a45c59946a2335887d8e948494
3
+ metadata.gz: 98d26348ce002789d1f065e91735ae2d441a64bb32c8c935993961036f2d2379
4
+ data.tar.gz: e3527606c13a8f62a4918b98e0dfc5ed441f691b836b4f670251e80442fcf104
5
5
  SHA512:
6
- metadata.gz: d31db71feb4b03d7810d5805b3d48016e89ead1782bfae66269aa2a0c55340e6cf21031525ffa6d5b917cdc36041670ef52c1ccff499ebdfc7d0051d8005b6a8
7
- data.tar.gz: 1ea49ae1a15e45b16c21b9da86c8ac20abb9e96a6eb63e6a0ed9a7dfcbca25dfff8431896703f2d55736a148668cf4b85ac591eb20c68bf1b2d9f6baee455e3a
6
+ metadata.gz: 5e1674d67c5cf55473e0325601b65b532dc374cd9e5a08a2345a282c4b5dd0a984392d1c0196857a649a00ceaf45362d21980e85c9050868b5538b4377f20dd6
7
+ data.tar.gz: 1c7517a30c1d32ddcc7e6d6883ef6a5b91fcac12500c76b89bdbebb473c405dde6b58f45a2b60dc3c60b7dfac440973ea81daa6a49f308c9d22b23670484293a
@@ -0,0 +1,80 @@
1
+ module PowerBI
2
+ class Admin
3
+
4
+ def initialize(tenant)
5
+ @tenant = tenant
6
+ end
7
+
8
+ def get_user_artifact_access(user_id, artifact_types: nil)
9
+ if artifact_types
10
+ params = {artifactTypes: artifact_types.join(',')}
11
+ else
12
+ params = {}
13
+ end
14
+
15
+ url = "/admin/users/#{user_id}/artifactAccess"
16
+
17
+ resp = @tenant.get(url, params)
18
+ data = resp[:ArtifactAccessEntities]
19
+
20
+ continuation_token = resp[:continuationToken]
21
+
22
+ while continuation_token
23
+ params = {continuationToken: "'#{continuation_token}'"}
24
+ resp = @tenant.get(url, params)
25
+ data += resp[:ArtifactAccessEntities]
26
+ continuation_token = resp[:continuationToken] ? URI::decode_uri_component(resp[:continuationToken]) : nil
27
+ end
28
+
29
+ data
30
+ end
31
+
32
+ def get_workspaces(filter: nil, expand: nil)
33
+ params = {}
34
+ params[:$filter] = filter if filter
35
+ params[:$expand] = expand if expand
36
+
37
+ url = '/admin/groups'
38
+
39
+ nr_records = 5000
40
+ count = 0
41
+
42
+ data = []
43
+
44
+ loop do
45
+ params[:$top] = nr_records
46
+ params[:$skip] = count
47
+ resp = @tenant.get(url, params)
48
+ data += resp[:value]
49
+ batch_count = resp[:value].size
50
+ count += batch_count
51
+ break if batch_count < nr_records
52
+ end
53
+
54
+ data
55
+ end
56
+
57
+ def force_delete_workspace_by_workspace_name(user_email, workspace_name)
58
+ workspace = get_workspaces(filter: "name eq '#{workspace_name}' and state eq 'Active'").first
59
+ add_user(user_email, workspace[:id], access_right: "Admin")
60
+ @tenant.workspace(workspace[:id]).delete
61
+ end
62
+
63
+ def force_delete_workspace_by_workspace_id(user_email, workspace_id)
64
+ add_user(user_email, workspace_id, access_right: "Admin")
65
+ @tenant.workspace(workspace_id).delete
66
+ end
67
+
68
+ private
69
+
70
+ def add_user(user_email, workspace_id, access_right: "Admin")
71
+ @tenant.post("/admin/groups/#{workspace_id}/users") do |req|
72
+ req.body = {
73
+ emailAddress: user_email,
74
+ groupUserAccessRight: access_right,
75
+ }.to_json
76
+ end
77
+ end
78
+
79
+ end
80
+ end
@@ -1,6 +1,6 @@
1
1
  module PowerBI
2
2
  class Dataset < Object
3
- attr_reader :workspace, :datasources, :parameters, :refresh_history
3
+ attr_reader :workspace, :datasources, :parameters
4
4
 
5
5
  def initialize(tenant, parent, id = nil)
6
6
  super(tenant, id)
@@ -38,6 +38,11 @@ module PowerBI
38
38
  true
39
39
  end
40
40
 
41
+ def refresh_history(entries_to_load = 1)
42
+ @refresh_history.entries_to_load = entries_to_load
43
+ @refresh_history
44
+ end
45
+
41
46
  def last_refresh
42
47
  @refresh_history.first
43
48
  end
@@ -22,18 +22,27 @@ module PowerBI
22
22
  end
23
23
 
24
24
  class RefreshArray < Array
25
+ attr_reader :entries_to_load
25
26
 
26
27
  def initialize(tenant, dataset)
27
28
  super(tenant, dataset)
28
29
  @dataset = dataset
30
+ @entries_to_load = 1
29
31
  end
30
32
 
31
33
  def self.get_class
32
34
  Refresh
33
35
  end
34
36
 
37
+ def entries_to_load=(entries_to_load)
38
+ if entries_to_load > @entries_to_load
39
+ @entries_to_load = entries_to_load
40
+ reload
41
+ end
42
+ end
43
+
35
44
  def get_data
36
- @tenant.get("/groups/#{@dataset.workspace.id}/datasets/#{@dataset.id}/refreshes", {'$top': '1'})[:value]
45
+ @tenant.get("/groups/#{@dataset.workspace.id}/datasets/#{@dataset.id}/refreshes", {'$top': @entries_to_load.to_s})[:value]
37
46
  end
38
47
  end
39
48
  end
@@ -1,6 +1,6 @@
1
1
  module PowerBI
2
2
  class Tenant
3
- attr_reader :workspaces, :gateways, :capacities, :profiles, :profile_id
3
+ attr_reader :workspaces, :gateways, :capacities, :profiles, :profile_id, :admin
4
4
 
5
5
  def initialize(token_generator, retries: 5, logger: nil)
6
6
  @token_generator = token_generator
@@ -10,6 +10,7 @@ module PowerBI
10
10
  @profiles = ProfileArray.new(self)
11
11
  @logger = logger
12
12
  @profile_id = nil
13
+ @admin = Admin.new(self)
13
14
 
14
15
  ## WHY RETRIES? ##
15
16
  # It is noticed that once in a while (~0.1% API calls), the Power BI server returns a 500 (internal server error) without apparent reason, just retrying works :-)
data/lib/power-bi.rb CHANGED
@@ -26,4 +26,5 @@ require_relative "power-bi/gateway_datasource_user"
26
26
  require_relative "power-bi/page"
27
27
  require_relative "power-bi/user"
28
28
  require_relative "power-bi/capacity"
29
- require_relative "power-bi/profile"
29
+ require_relative "power-bi/profile"
30
+ require_relative "power-bi/admin"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: power-bi
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lode Cools
@@ -89,6 +89,7 @@ files:
89
89
  - LICENSE
90
90
  - README.md
91
91
  - lib/power-bi.rb
92
+ - lib/power-bi/admin.rb
92
93
  - lib/power-bi/array.rb
93
94
  - lib/power-bi/capacity.rb
94
95
  - lib/power-bi/dataset.rb