power-bi 2.5.0 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 98d26348ce002789d1f065e91735ae2d441a64bb32c8c935993961036f2d2379
4
- data.tar.gz: e3527606c13a8f62a4918b98e0dfc5ed441f691b836b4f670251e80442fcf104
3
+ metadata.gz: a22ca0a37fc03e4fd19214f0ecb71c8fedf820fabbbc9e7a7e5add198e0ab25a
4
+ data.tar.gz: 61fc121ec95aa7cc815b7ee4e84a9fe28facbb2c5177dbe91e519e17ebcfae19
5
5
  SHA512:
6
- metadata.gz: 5e1674d67c5cf55473e0325601b65b532dc374cd9e5a08a2345a282c4b5dd0a984392d1c0196857a649a00ceaf45362d21980e85c9050868b5538b4377f20dd6
7
- data.tar.gz: 1c7517a30c1d32ddcc7e6d6883ef6a5b91fcac12500c76b89bdbebb473c405dde6b58f45a2b60dc3c60b7dfac440973ea81daa6a49f308c9d22b23670484293a
6
+ metadata.gz: 1c69b92f3b68c19b67a417ba7deb402b4bcc8130ebf074260e97b36c62f773ac27e3720d4fa3946060ad1d8d062bbcf95768c436f7be207e773f849a818a633f
7
+ data.tar.gz: 9454fcb89c9de930616e8ea944fb9aba73f5cfa558e2bef1e755c4f16ec66164dff386154532242ebd55242bc6ccd6ecbcc59fce3f64bf5e8fca554ed309ee59
data/README.md CHANGED
@@ -112,6 +112,10 @@ Note 2: to limit the number of API calls, it is best to directly use the _getter
112
112
  * Delete the dataset: `dataset.delete`
113
113
  * Bind dataset to a gateway datasource: `dataset.bind_to_gateway(gateway, gateway_datasource)`
114
114
 
115
+ ## Datasources
116
+
117
+ * Update credentials of a datasource: `datasource.update_credentials(username, password)`
118
+
115
119
  ## Gateways
116
120
 
117
121
  * List gateways: `pbi.gateways`
@@ -16,6 +16,24 @@ module PowerBI
16
16
  }
17
17
  end
18
18
 
19
+ # only MySQL type is currently supported
20
+ def update_credentials(username, password)
21
+ @tenant.patch("/gateways/#{gateway_id}/datasources/#{datasource_id}") do |req|
22
+ req.body = {
23
+ credentialDetails: {
24
+ credentialType: "Basic",
25
+ credentials: "{\"credentialData\":[{\"name\":\"username\", \"value\":\"#{username}\"},{\"name\":\"password\", \"value\":\"#{password}\"}]}",
26
+ encryptedConnection: "Encrypted",
27
+ encryptionAlgorithm: "None",
28
+ privacyLevel: "None",
29
+ useCallerAADIdentity: false,
30
+ useEndUserOAuth2Credentials: false,
31
+ },
32
+ }.to_json
33
+ end
34
+ true
35
+ end
36
+
19
37
  end
20
38
 
21
39
  class DatasourceArray < Array
@@ -18,6 +18,14 @@ module PowerBI
18
18
  }
19
19
  end
20
20
 
21
+ # currently only implemented for users or service principals (not yet service principal profiles)
22
+ def delete
23
+ email_address_or_object_id = email_address || identifier
24
+ @tenant.delete("/gateways/#{@gateway_datasource.gateway.id}/datasources/#{@gateway_datasource.id}/users/#{email_address_or_object_id}", use_profile: false)
25
+ @gateway_datasource.gateway_datasource_users.reload
26
+ true
27
+ end
28
+
21
29
  end
22
30
 
23
31
  class GatewayDatasourceUserArray < Array
@@ -74,7 +74,7 @@ module PowerBI
74
74
  unless [200, 202].include? response.status
75
75
  raise APIError.new("Error calling Power BI API (status #{response.status}): #{response.body}")
76
76
  end
77
- log "Calling (GET) #{response.env.url.to_s} - took #{((Time.now - t0) * 1000).to_i} ms"
77
+ log "Calling (GET) #{response.env.url.to_s} - took #{((Time.now - t0) * 1000).to_i} ms - status: #{response.status}"
78
78
  unless response.body.empty?
79
79
  JSON.parse(response.body, symbolize_names: true)
80
80
  end
@@ -93,7 +93,7 @@ module PowerBI
93
93
  end
94
94
  yield req if block_given?
95
95
  end
96
- log "Calling (GET - raw) #{response.env.url.to_s} - took #{((Time.now - t0) * 1000).to_i} ms"
96
+ log "Calling (GET - raw) #{response.env.url.to_s} - took #{((Time.now - t0) * 1000).to_i} ms - status: #{response.status}"
97
97
  unless [200, 202].include? response.status
98
98
  raise APIError.new("Error calling Power BI API (status #{response.status}): #{response.body}")
99
99
  end
@@ -115,7 +115,7 @@ module PowerBI
115
115
  end
116
116
  yield req if block_given?
117
117
  end
118
- log "Calling (POST) #{response.env.url.to_s} - took #{((Time.now - t0) * 1000).to_i} ms"
118
+ log "Calling (POST) #{response.env.url.to_s} - took #{((Time.now - t0) * 1000).to_i} ms - status: #{response.status}"
119
119
  unless [200, 201, 202].include? response.status
120
120
  raise APIError.new("Error calling Power BI API (status #{response.status}): #{response.body}")
121
121
  end
@@ -139,7 +139,7 @@ module PowerBI
139
139
  end
140
140
  yield req if block_given?
141
141
  end
142
- log "Calling (PATCH) #{response.env.url.to_s} - took #{((Time.now - t0) * 1000).to_i} ms"
142
+ log "Calling (PATCH) #{response.env.url.to_s} - took #{((Time.now - t0) * 1000).to_i} ms - status: #{response.status}"
143
143
  unless [200, 202].include? response.status
144
144
  raise APIError.new("Error calling Power BI API (status #{response.status}): #{response.body}")
145
145
  end
@@ -162,7 +162,7 @@ module PowerBI
162
162
  end
163
163
  yield req if block_given?
164
164
  end
165
- log "Calling (DELETE) #{response.env.url.to_s} - took #{((Time.now - t0) * 1000).to_i} ms"
165
+ log "Calling (DELETE) #{response.env.url.to_s} - took #{((Time.now - t0) * 1000).to_i} ms - status: #{response.status}"
166
166
  if [400, 401, 404].include? response.status
167
167
  raise NotFoundError
168
168
  end
@@ -191,7 +191,7 @@ module PowerBI
191
191
  req.body = {value: Faraday::UploadIO.new(file, 'application/octet-stream')}
192
192
  req.options.timeout = 120 # default is 60 seconds Net::ReadTimeout
193
193
  end
194
- log "Calling (POST - file) #{response.env.url.to_s} - took #{((Time.now - t0) * 1000).to_i} ms"
194
+ log "Calling (POST - file) #{response.env.url.to_s} - took #{((Time.now - t0) * 1000).to_i} ms - status: #{response.status}"
195
195
  if response.status != 202
196
196
  raise APIError.new("Error calling Power BI API (status #{response.status}): #{response.body}")
197
197
  end
data/lib/power-bi.rb CHANGED
@@ -1,4 +1,3 @@
1
- require 'pry' # TODO remove in final product
2
1
  require 'faraday'
3
2
  require 'json'
4
3
  require 'date'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: power-bi
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 2.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lode Cools
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-21 00:00:00.000000000 Z
11
+ date: 2025-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -110,7 +110,7 @@ homepage: https://github.com/piloos/power-bi
110
110
  licenses:
111
111
  - MIT
112
112
  metadata: {}
113
- post_install_message:
113
+ post_install_message:
114
114
  rdoc_options: []
115
115
  require_paths:
116
116
  - lib
@@ -126,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
126
  version: '0'
127
127
  requirements: []
128
128
  rubygems_version: 3.4.6
129
- signing_key:
129
+ signing_key:
130
130
  specification_version: 4
131
131
  summary: Ruby wrapper for the Power BI API
132
132
  test_files: []