power-bi 1.5.0 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/power-bi/page.rb +1 -1
- data/lib/power-bi/tenant.rb +21 -2
- data/lib/power-bi/workspace.rb +3 -3
- metadata +45 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2cdaf275d6377b0f772985c4e6b616030022652fd88201f7cc79b04cfe009d67
|
4
|
+
data.tar.gz: 654d2e658ffbc996beb652976094eceecf95256897ad70ff59b461e46810ff82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ccf88e40d284bc8e91e0bc683ed077a42a077a810e409346ac6dce508e8803b9313c7ccc1ec3ab0937c43d53169dfdbb04db64c3c73d55b52180a4f2d59a0dc0
|
7
|
+
data.tar.gz: 221a648dbbc8e35ab2ed75834dfbe756e57f5583282a5f1224194489378c6c17d3c10f5f2578c50f377e1536b14bd9398b7a586ba89ec751bfa89eb15c0ca79e
|
data/lib/power-bi/page.rb
CHANGED
data/lib/power-bi/tenant.rb
CHANGED
@@ -2,10 +2,11 @@ module PowerBI
|
|
2
2
|
class Tenant
|
3
3
|
attr_reader :workspaces, :gateways
|
4
4
|
|
5
|
-
def initialize(token_generator, retries: 5)
|
5
|
+
def initialize(token_generator, retries: 5, logger: nil)
|
6
6
|
@token_generator = token_generator
|
7
7
|
@workspaces = WorkspaceArray.new(self)
|
8
8
|
@gateways = GatewayArray.new(self)
|
9
|
+
@logger = logger
|
9
10
|
|
10
11
|
## WHY RETRIES? ##
|
11
12
|
# It is noticed that once in a while (~0.1% API calls), the Power BI server returns a 500 (internal server error) withou apparent reason, just retrying works :-)
|
@@ -18,11 +19,18 @@ module PowerBI
|
|
18
19
|
interval: 0.2,
|
19
20
|
interval_randomness: 0,
|
20
21
|
backoff_factor: 4,
|
21
|
-
retry_block: -> (env, options, retries, exc) {
|
22
|
+
retry_block: -> (env, options, retries, exc) { self.log "retrying...!! exception: #{exc.to_s} ---- #{exc.message}, request URL: #{env.url}" },
|
22
23
|
}
|
23
24
|
end
|
24
25
|
|
26
|
+
def log(message, level: :info)
|
27
|
+
if @logger
|
28
|
+
@logger.send(level, message) # hence, the logger needs to implement the 'level' methods
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
25
32
|
def get(url, params = {})
|
33
|
+
t0 = Time.now
|
26
34
|
conn = Faraday.new do |f|
|
27
35
|
f.request :retry, @retry_options
|
28
36
|
end
|
@@ -35,12 +43,14 @@ module PowerBI
|
|
35
43
|
unless [200, 202].include? response.status
|
36
44
|
raise APIError.new("Error calling Power BI API (status #{response.status}): #{response.body}")
|
37
45
|
end
|
46
|
+
log "Calling (GET) #{url} - took #{((Time.now - t0) * 1000).to_i} ms"
|
38
47
|
unless response.body.empty?
|
39
48
|
JSON.parse(response.body, symbolize_names: true)
|
40
49
|
end
|
41
50
|
end
|
42
51
|
|
43
52
|
def get_raw(url, params = {})
|
53
|
+
t0 = Time.now
|
44
54
|
conn = Faraday.new do |f|
|
45
55
|
f.request :retry, @retry_options
|
46
56
|
end
|
@@ -49,6 +59,7 @@ module PowerBI
|
|
49
59
|
req.headers['authorization'] = "Bearer #{token}"
|
50
60
|
yield req if block_given?
|
51
61
|
end
|
62
|
+
log "Calling (GET - raw) #{url} - took #{((Time.now - t0) * 1000).to_i} ms"
|
52
63
|
unless [200, 202].include? response.status
|
53
64
|
raise APIError.new("Error calling Power BI API (status #{response.status}): #{response.body}")
|
54
65
|
end
|
@@ -56,6 +67,7 @@ module PowerBI
|
|
56
67
|
end
|
57
68
|
|
58
69
|
def post(url, params = {})
|
70
|
+
t0 = Time.now
|
59
71
|
conn = Faraday.new do |f|
|
60
72
|
f.request :retry, @retry_options
|
61
73
|
end
|
@@ -66,6 +78,7 @@ module PowerBI
|
|
66
78
|
req.headers['authorization'] = "Bearer #{token}"
|
67
79
|
yield req if block_given?
|
68
80
|
end
|
81
|
+
log "Calling (POST) #{url} - took #{((Time.now - t0) * 1000).to_i} ms"
|
69
82
|
unless [200, 201, 202].include? response.status
|
70
83
|
raise APIError.new("Error calling Power BI API (status #{response.status}): #{response.body}")
|
71
84
|
end
|
@@ -75,6 +88,7 @@ module PowerBI
|
|
75
88
|
end
|
76
89
|
|
77
90
|
def patch(url, params = {})
|
91
|
+
t0 = Time.now
|
78
92
|
conn = Faraday.new do |f|
|
79
93
|
f.request :retry, @retry_options
|
80
94
|
end
|
@@ -85,6 +99,7 @@ module PowerBI
|
|
85
99
|
req.headers['authorization'] = "Bearer #{token}"
|
86
100
|
yield req if block_given?
|
87
101
|
end
|
102
|
+
log "Calling (PATCH) #{url} - took #{((Time.now - t0) * 1000).to_i} ms"
|
88
103
|
unless [200, 202].include? response.status
|
89
104
|
raise APIError.new("Error calling Power BI API (status #{response.status}): #{response.body}")
|
90
105
|
end
|
@@ -94,6 +109,7 @@ module PowerBI
|
|
94
109
|
end
|
95
110
|
|
96
111
|
def delete(url, params = {})
|
112
|
+
t0 = Time.now
|
97
113
|
conn = Faraday.new do |f|
|
98
114
|
f.request :retry, @retry_options
|
99
115
|
end
|
@@ -103,6 +119,7 @@ module PowerBI
|
|
103
119
|
req.headers['authorization'] = "Bearer #{token}"
|
104
120
|
yield req if block_given?
|
105
121
|
end
|
122
|
+
log "Calling (DELETE) #{url} - took #{((Time.now - t0) * 1000).to_i} ms"
|
106
123
|
unless [200, 202].include? response.status
|
107
124
|
raise APIError.new("Error calling Power BI API (status #{response.status}): #{response.body}")
|
108
125
|
end
|
@@ -112,6 +129,7 @@ module PowerBI
|
|
112
129
|
end
|
113
130
|
|
114
131
|
def post_file(url, file, params = {})
|
132
|
+
t0 = Time.now
|
115
133
|
conn = Faraday.new do |f|
|
116
134
|
f.request :multipart
|
117
135
|
f.request :retry, @retry_options
|
@@ -124,6 +142,7 @@ module PowerBI
|
|
124
142
|
req.body = {value: Faraday::UploadIO.new(file, 'application/octet-stream')}
|
125
143
|
req.options.timeout = 120 # default is 60 seconds Net::ReadTimeout
|
126
144
|
end
|
145
|
+
log "Calling (POST - file) #{url} - took #{((Time.now - t0) * 1000).to_i} ms"
|
127
146
|
if response.status != 202
|
128
147
|
raise APIError.new("Error calling Power BI API (status #{response.status}): #{response.body}")
|
129
148
|
end
|
data/lib/power-bi/workspace.rb
CHANGED
@@ -23,13 +23,13 @@ module PowerBI
|
|
23
23
|
status_history = ''
|
24
24
|
old_status = ''
|
25
25
|
while !success
|
26
|
-
sleep 0.
|
26
|
+
sleep 0.5
|
27
27
|
iterations += 1
|
28
|
-
raise UploadError.new("Upload did not succeed after #{timeout} seconds. Status history:#{status_history}") if iterations > (
|
28
|
+
raise UploadError.new("Upload did not succeed after #{timeout} seconds. Status history:#{status_history}") if iterations > (2 * timeout)
|
29
29
|
new_status = @tenant.get("/groups/#{@id}/imports/#{import_id}")[:importState].to_s
|
30
30
|
success = (new_status == "Succeeded")
|
31
31
|
if new_status != old_status
|
32
|
-
status_history += "\nStatus change after #{iterations/
|
32
|
+
status_history += "\nStatus change after #{iterations/2}s: '#{old_status}' --> '#{new_status}'"
|
33
33
|
old_status = new_status
|
34
34
|
end
|
35
35
|
end
|
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: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lode Cools
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -38,6 +38,48 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '3.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry-byebug
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: oauth2
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
41
83
|
description: Ruby wrapper for the Power BI API
|
42
84
|
email: lode.cools1@gmail.com
|
43
85
|
executables: []
|
@@ -78,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
78
120
|
- !ruby/object:Gem::Version
|
79
121
|
version: '0'
|
80
122
|
requirements: []
|
81
|
-
rubygems_version: 3.1.
|
123
|
+
rubygems_version: 3.1.6
|
82
124
|
signing_key:
|
83
125
|
specification_version: 4
|
84
126
|
summary: Ruby wrapper for the Power BI API
|