power-bi 1.1.0 → 1.2.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 +4 -4
- data/lib/power-bi/tenant.rb +35 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38722ac553ebd26a3d354aae65d622752817faa16c9a30af60a01bf719bcbba0
|
4
|
+
data.tar.gz: 2cffe049c3488a0e2f642293d48a9a0a25e81a39b619da32a0609ec1dc9ad029
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2e719c386fcc7b6e97878a5d01ace8795ae67f16b1e1c8f9848c012d3493c9c02ba7293e7f6b4d70b48d06ce75204c0455bc2a3c1f9610c05dbfc91bd17b48d
|
7
|
+
data.tar.gz: 4a27316227878ce178bb30d3d79f81863b0cb60a0923ee1c5bf24278691ccb6dff36efc19c06067090b23f203ff058c674e7aaceaa1acd2da00a607333932914
|
data/lib/power-bi/tenant.rb
CHANGED
@@ -2,14 +2,30 @@ module PowerBI
|
|
2
2
|
class Tenant
|
3
3
|
attr_reader :workspaces, :gateways
|
4
4
|
|
5
|
-
def initialize(token_generator)
|
5
|
+
def initialize(token_generator, retries: 5)
|
6
6
|
@token_generator = token_generator
|
7
7
|
@workspaces = WorkspaceArray.new(self)
|
8
8
|
@gateways = GatewayArray.new(self)
|
9
|
+
|
10
|
+
## WHY RETRIES? ##
|
11
|
+
# 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 :-)
|
12
|
+
##################
|
13
|
+
@retry_options = {
|
14
|
+
max: retries,
|
15
|
+
exceptions: [Errno::ETIMEDOUT, Timeout::Error, Faraday::TimeoutError, Faraday::RetriableResponse],
|
16
|
+
retry_statuses: [500], # internal server error
|
17
|
+
interval: 0.2,
|
18
|
+
interval_randomness: 0,
|
19
|
+
backoff_factor: 4,
|
20
|
+
retry_block: -> (env, options, retries, exc) { puts "retrying...!!" },
|
21
|
+
}
|
9
22
|
end
|
10
23
|
|
11
24
|
def get(url, params = {})
|
12
|
-
|
25
|
+
conn = Faraday.new do |f|
|
26
|
+
f.request :retry, @retry_options
|
27
|
+
end
|
28
|
+
response = conn.get(PowerBI::BASE_URL + url) do |req|
|
13
29
|
req.params = params
|
14
30
|
req.headers['Accept'] = 'application/json'
|
15
31
|
req.headers['authorization'] = "Bearer #{token}"
|
@@ -24,7 +40,10 @@ module PowerBI
|
|
24
40
|
end
|
25
41
|
|
26
42
|
def get_raw(url, params = {})
|
27
|
-
|
43
|
+
conn = Faraday.new do |f|
|
44
|
+
f.request :retry, @retry_options
|
45
|
+
end
|
46
|
+
response = conn.get(PowerBI::BASE_URL + url) do |req|
|
28
47
|
req.params = params
|
29
48
|
req.headers['authorization'] = "Bearer #{token}"
|
30
49
|
yield req if block_given?
|
@@ -36,7 +55,10 @@ module PowerBI
|
|
36
55
|
end
|
37
56
|
|
38
57
|
def post(url, params = {})
|
39
|
-
|
58
|
+
conn = Faraday.new do |f|
|
59
|
+
f.request :retry, @retry_options
|
60
|
+
end
|
61
|
+
response = conn.post(PowerBI::BASE_URL + url) do |req|
|
40
62
|
req.params = params
|
41
63
|
req.headers['Accept'] = 'application/json'
|
42
64
|
req.headers['Content-Type'] = 'application/json'
|
@@ -52,7 +74,10 @@ module PowerBI
|
|
52
74
|
end
|
53
75
|
|
54
76
|
def patch(url, params = {})
|
55
|
-
|
77
|
+
conn = Faraday.new do |f|
|
78
|
+
f.request :retry, @retry_options
|
79
|
+
end
|
80
|
+
response = conn.patch(PowerBI::BASE_URL + url) do |req|
|
56
81
|
req.params = params
|
57
82
|
req.headers['Accept'] = 'application/json'
|
58
83
|
req.headers['Content-Type'] = 'application/json'
|
@@ -68,7 +93,10 @@ module PowerBI
|
|
68
93
|
end
|
69
94
|
|
70
95
|
def delete(url, params = {})
|
71
|
-
|
96
|
+
conn = Faraday.new do |f|
|
97
|
+
f.request :retry, @retry_options
|
98
|
+
end
|
99
|
+
response = conn.delete(PowerBI::BASE_URL + url) do |req|
|
72
100
|
req.params = params
|
73
101
|
req.headers['Accept'] = 'application/json'
|
74
102
|
req.headers['authorization'] = "Bearer #{token}"
|
@@ -85,6 +113,7 @@ module PowerBI
|
|
85
113
|
def post_file(url, file, params = {})
|
86
114
|
conn = Faraday.new do |f|
|
87
115
|
f.request :multipart
|
116
|
+
f.request :retry, @retry_options
|
88
117
|
end
|
89
118
|
response = conn.post(PowerBI::BASE_URL + url) do |req|
|
90
119
|
req.params = params
|