power-bi 1.4.0 → 1.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: 7d2c83c53427a7a2604d4c9f012c307e6b6b2cc083b84e809a7e0a407aa1b31b
4
- data.tar.gz: 4b32aeb05f4b0f2c871b01f6551b355a206c5efcbc424aa97c8b5c8468ab3b5a
3
+ metadata.gz: '053216118d9fed6cb0cb3dff7a8bbe03c64be8a80f2cf26205a1c1b2ee48699c'
4
+ data.tar.gz: 29908d4c0d9c2c988073f42c7b1180e21863a755ee14c68858016a0d74f437b3
5
5
  SHA512:
6
- metadata.gz: 39a25dbff366b7ee4bf71a6b3ebe7d4674295c0d9787926d3afa157819ba0f2b2af929c5fda042e2b8dab31368a16881bbbf5fc3a9d455b939057d0f01a4a72d
7
- data.tar.gz: 4c2b804f4e83641f54a7738e80421c50b15194ace184d3c2ff80be53a2da02889bdb13fb628f46d5b362bde4da9a4b7c8c4a6f06806372668a86ae18243b956a
6
+ metadata.gz: b466f3f6b3d67701d40635ac0035b4a94d5aa9a1908152e2f32e244cbfe9f27f8c35f7978ec47bb2a3bccc7e681f14247d76128074c6a93006c2fc2b0c7f8438
7
+ data.tar.gz: b43176b8de6c021e9c2529aafa9f137fab06877d320b26acc9ea0d7e7edfaee5d37a03d81dbf9f2672beae4399e25a24958aad94f39cecbaaf4d4ecf29edeb4f
data/README.md CHANGED
@@ -31,6 +31,12 @@ pbi = PowerBI::Tenant.new(->{token = get_token(client, token) ; token.token})
31
31
 
32
32
  * List pages in a report: `report.pages`
33
33
 
34
+ ## Users
35
+
36
+ * List users in a workspace: `workspace.pages`
37
+ * Delete a user from a workspace: `user.delete`
38
+ * Add a user to a workspace: `workspace.create(email_address, access_right: "Viewer")`
39
+
34
40
  ## Datasets
35
41
 
36
42
  * List datasets in a workspace: `workspace.datasets`
data/lib/power-bi.rb CHANGED
@@ -21,3 +21,4 @@ require_relative "power-bi/refresh"
21
21
  require_relative "power-bi/gateway"
22
22
  require_relative "power-bi/gateway_datasource"
23
23
  require_relative "power-bi/page"
24
+ require_relative "power-bi/user"
@@ -0,0 +1,48 @@
1
+ module PowerBI
2
+ class User
3
+ attr_reader :email_address, :group_user_access_right, :display_name, :identifier, :principal_type
4
+
5
+ def initialize(tenant, data)
6
+ @email_address = data[:emailAddress]
7
+ @group_user_access_right = data[:groupUserAccessRight]
8
+ @display_name = data[:displayName]
9
+ @identifier = data[:identifier]
10
+ @principal_type = data[:principalType]
11
+ @workspace = data[:workspace]
12
+ @tenant = tenant
13
+ end
14
+
15
+ def delete
16
+ @tenant.delete("/groups/#{@workspace.id}/users/#{@email_address}")
17
+ @workspace.users.reload
18
+ end
19
+
20
+ end
21
+
22
+ class UserArray < Array
23
+
24
+ def initialize(tenant, workspace)
25
+ super(tenant)
26
+ @workspace = workspace
27
+ end
28
+
29
+ def self.get_class
30
+ User
31
+ end
32
+
33
+ def create(email_address, access_right: "Viewer")
34
+ @tenant.post("/groups/#{@workspace.id}/users") do |req|
35
+ req.body = {
36
+ emailAddress: email_address,
37
+ groupUserAccessRight: access_right
38
+ }.to_json
39
+ end
40
+ self.reload
41
+ end
42
+
43
+ def get_data
44
+ data = @tenant.get("/groups/#{@workspace.id}/users")[:value]
45
+ data.each { |d| d[:workspace] = @workspace }
46
+ end
47
+ end
48
+ end
@@ -1,6 +1,6 @@
1
1
  module PowerBI
2
2
  class Workspace
3
- attr_reader :name, :is_read_only, :is_on_dedicated_capacity, :id, :reports, :datasets
3
+ attr_reader :name, :is_read_only, :is_on_dedicated_capacity, :id, :reports, :datasets, :users
4
4
 
5
5
  class UploadError < PowerBI::Error ; end
6
6
 
@@ -12,6 +12,7 @@ module PowerBI
12
12
  @tenant = tenant
13
13
  @reports = ReportArray.new(@tenant, self)
14
14
  @datasets = DatasetArray.new(@tenant, self)
15
+ @users = UserArray.new(@tenant, self)
15
16
  end
16
17
 
17
18
  def upload_pbix(file, dataset_name, timeout: 30)
@@ -43,17 +44,6 @@ module PowerBI
43
44
  true
44
45
  end
45
46
 
46
- # TODO LATER: the 'Viewer' acces right is currently not settable throught the API. Fix that later
47
- def add_user(email_address, access_right = 'Member')
48
- @tenant.post("/groups/#{id}/users") do |req|
49
- req.body = {
50
- emailAddress: email_address,
51
- groupUserAccessRight: access_right
52
- }.to_json
53
- end
54
- true
55
- end
56
-
57
47
  end
58
48
 
59
49
  class WorkspaceArray < Array
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: 1.4.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lode Cools
@@ -57,6 +57,7 @@ files:
57
57
  - lib/power-bi/refresh.rb
58
58
  - lib/power-bi/report.rb
59
59
  - lib/power-bi/tenant.rb
60
+ - lib/power-bi/user.rb
60
61
  - lib/power-bi/workspace.rb
61
62
  homepage: https://github.com/piloos/power-bi
62
63
  licenses: