looker-sdk 0.1.7 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +22 -0
- data/lib/looker-sdk/client/dynamic.rb +5 -3
- data/lib/looker-sdk/client.rb +16 -7
- data/lib/looker-sdk/default.rb +1 -1
- data/lib/looker-sdk/error.rb +8 -2
- data/lib/looker-sdk/version.rb +1 -1
- data/lib/looker-sdk.rb +2 -1
- data/test/helper.rb +10 -4
- data/test/looker/swagger.json +42011 -1117
- data/test/looker/test_client.rb +19 -15
- data/test/looker/test_dynamic_client.rb +36 -34
- data/test/looker/test_dynamic_client_agent.rb +45 -12
- data/test/looker/test_inline_query.rb +97 -0
- metadata +14 -45
- data/.github/CODEOWNERS +0 -1
- data/.github/scripts/wait_for_looker.sh +0 -35
- data/.github/workflows/release-metrics.yml +0 -44
- data/.github/workflows/release.yml +0 -47
- data/.github/workflows/ruby-ci.yml +0 -140
- data/.gitignore +0 -60
- data/.ruby-gemset +0 -1
- data/Gemfile +0 -22
- data/Gemfile.lock +0 -73
- data/Makefile +0 -81
- data/Rakefile +0 -38
- data/examples/.netrc +0 -1
- data/examples/add_delete_users.rb +0 -118
- data/examples/change_credentials_email_address_for_users.rb +0 -47
- data/examples/convert_look_to_lookless_tile.rb +0 -71
- data/examples/create_credentials_email_for_users.rb +0 -43
- data/examples/delete_all_user_sessions.rb +0 -39
- data/examples/delete_credentials_google_for_users.rb +0 -43
- data/examples/errors.rb +0 -47
- data/examples/generate_password_reset_tokens_for_users.rb +0 -43
- data/examples/ldap_roles_test.rb +0 -74
- data/examples/me.rb +0 -27
- data/examples/refresh_user_notification_addresses.rb +0 -34
- data/examples/roles_and_users_with_permission.rb +0 -46
- data/examples/sdk_setup.rb +0 -45
- data/examples/streaming_downloads.rb +0 -44
- data/examples/users_with_credentials_email.rb +0 -30
- data/examples/users_with_credentials_embed.rb +0 -33
- data/examples/users_with_credentials_google.rb +0 -30
- data/examples/users_with_credentials_google_without_credentials_email.rb +0 -30
- data/looker-sdk.gemspec +0 -32
- data/shell/.gitignore +0 -41
- data/shell/.netrc +0 -3
- data/shell/Gemfile +0 -6
- data/shell/Gemfile.lock +0 -60
- data/shell/readme.md +0 -18
- data/shell/shell.rb +0 -62
- data/shell.nix +0 -38
- data/test/fixtures/.netrc.template +0 -1
data/test/looker/test_client.rb
CHANGED
@@ -287,24 +287,28 @@ describe LookerSDK::Client do
|
|
287
287
|
end
|
288
288
|
|
289
289
|
[
|
290
|
-
[:get, '/api/
|
291
|
-
[:get, '/api/
|
292
|
-
[:post, '/api/
|
293
|
-
[:post, '/api/
|
294
|
-
[:put, '/api/
|
295
|
-
[:put, '/api/
|
296
|
-
[:patch, '/api/
|
297
|
-
[:patch, '/api/
|
298
|
-
[:delete, '/api/
|
299
|
-
[:delete, '/api/
|
300
|
-
[:head, '/api/
|
301
|
-
[:head, '/api/
|
290
|
+
[:get, '/api/4.0/users/foo%2Fbar', false],
|
291
|
+
[:get, '/api/4.0/users/foo%252Fbar', true],
|
292
|
+
[:post, '/api/4.0/users/foo%2Fbar', false],
|
293
|
+
[:post, '/api/4.0/users/foo%252Fbar', true],
|
294
|
+
[:put, '/api/4.0/users/foo%2Fbar', false],
|
295
|
+
[:put, '/api/4.0/users/foo%252Fbar', true],
|
296
|
+
[:patch, '/api/4.0/users/foo%2Fbar', false],
|
297
|
+
[:patch, '/api/4.0/users/foo%252Fbar', true],
|
298
|
+
[:delete, '/api/4.0/users/foo%2Fbar', false],
|
299
|
+
[:delete, '/api/4.0/users/foo%252Fbar', true],
|
300
|
+
[:head, '/api/4.0/users/foo%2Fbar', false],
|
301
|
+
[:head, '/api/4.0/users/foo%252Fbar', true],
|
302
302
|
].each do |method, path, encoded|
|
303
303
|
it "handles request path encoding" do
|
304
|
-
expected_path = '/api/
|
304
|
+
expected_path = '/api/4.0/users/foo%252Fbar'
|
305
305
|
|
306
306
|
resp = OpenStruct.new(:data => "hi", :status => 204)
|
307
|
-
mock =
|
307
|
+
#mock = Minitest::Mock.new.expect(:call, resp, [method, expected_path, nil])
|
308
|
+
mock = Minitest::Mock.new.expect :call, resp do | verb, route, body, h=nil, **kw |
|
309
|
+
verb == method && route == expected_path
|
310
|
+
end
|
311
|
+
|
308
312
|
Sawyer::Agent.stubs(:new).returns(mock, mock)
|
309
313
|
|
310
314
|
sdk = LookerSDK::Client.new
|
@@ -314,7 +318,7 @@ describe LookerSDK::Client do
|
|
314
318
|
args = [method, path, nil, nil, encoded]
|
315
319
|
end
|
316
320
|
sdk.without_authentication do
|
317
|
-
value = sdk.public_send
|
321
|
+
value = sdk.public_send(*args)
|
318
322
|
assert_equal "hi", value
|
319
323
|
end
|
320
324
|
mock.verify
|
@@ -24,7 +24,7 @@
|
|
24
24
|
|
25
25
|
require_relative '../helper'
|
26
26
|
|
27
|
-
class
|
27
|
+
class LookerDynamicClienttest < Minitest::Spec
|
28
28
|
|
29
29
|
def access_token
|
30
30
|
'87614b09dd141c22800f96f11737ade5226d7ba8'
|
@@ -58,7 +58,7 @@ class LookerDynamicClientTest < MiniTest::Spec
|
|
58
58
|
|
59
59
|
def confirm_env(env, method, path, body, query, content_type)
|
60
60
|
req = Rack::Request.new(env)
|
61
|
-
req_body = req.body
|
61
|
+
req_body = req.body&.gets || ''
|
62
62
|
|
63
63
|
req.base_url.must_equal 'https://localhost:19999'
|
64
64
|
req.request_method.must_equal method.to_s.upcase
|
@@ -70,7 +70,7 @@ class LookerDynamicClientTest < MiniTest::Spec
|
|
70
70
|
|
71
71
|
begin
|
72
72
|
JSON.parse(req_body, :symbolize_names => true).must_equal body
|
73
|
-
rescue JSON::ParserError
|
73
|
+
rescue JSON::ParserError
|
74
74
|
req_body.must_equal body
|
75
75
|
end
|
76
76
|
|
@@ -86,7 +86,7 @@ class LookerDynamicClientTest < MiniTest::Spec
|
|
86
86
|
end
|
87
87
|
|
88
88
|
def verify(response, method, path, body='', query={}, content_type = nil)
|
89
|
-
mock =
|
89
|
+
mock = Minitest::Mock.new.expect(:call, response){|env| confirm_env(env, method, path, body, query, content_type)}
|
90
90
|
yield sdk_client(default_swagger, mock)
|
91
91
|
mock.verify
|
92
92
|
end
|
@@ -94,7 +94,7 @@ class LookerDynamicClientTest < MiniTest::Spec
|
|
94
94
|
describe "swagger" do
|
95
95
|
|
96
96
|
it "raises when swagger.json can't be loaded" do
|
97
|
-
mock =
|
97
|
+
mock = Minitest::Mock.new.expect(:call, nil) {raise "no swagger for you"}
|
98
98
|
mock.expect(:call, nil) {raise "still no swagger for you"}
|
99
99
|
err = assert_raises(RuntimeError) { sdk_client(nil, mock) }
|
100
100
|
assert_equal "still no swagger for you", err.message
|
@@ -102,14 +102,14 @@ class LookerDynamicClientTest < MiniTest::Spec
|
|
102
102
|
|
103
103
|
it "loads swagger without authentication" do
|
104
104
|
resp = [200, {'Content-Type' => 'application/json'}, [default_swagger.to_json]]
|
105
|
-
mock =
|
105
|
+
mock = Minitest::Mock.new.expect(:call, resp, [Hash])
|
106
106
|
sdk = sdk_client(nil, mock)
|
107
107
|
assert_equal default_swagger, sdk.swagger
|
108
108
|
end
|
109
109
|
|
110
110
|
it "loads swagger with authentication" do
|
111
111
|
resp = [200, {'Content-Type' => 'application/json'}, [default_swagger.to_json]]
|
112
|
-
mock =
|
112
|
+
mock = Minitest::Mock.new.expect(:call, nil) {raise "login first!"}
|
113
113
|
mock.expect(:call, resp, [Hash])
|
114
114
|
sdk = sdk_client(nil, mock)
|
115
115
|
assert_equal default_swagger, sdk.swagger
|
@@ -128,130 +128,132 @@ class LookerDynamicClientTest < MiniTest::Spec
|
|
128
128
|
|
129
129
|
describe "operation maps" do
|
130
130
|
it "invoke by string operationId" do
|
131
|
-
verify(response, :get, '/api/
|
131
|
+
verify(response, :get, '/api/4.0/user') do |sdk|
|
132
132
|
sdk.invoke('me')
|
133
133
|
end
|
134
134
|
end
|
135
135
|
|
136
136
|
it "invoke by symbol operationId" do
|
137
|
-
verify(response, :get, '/api/
|
137
|
+
verify(response, :get, '/api/4.0/user') do |sdk|
|
138
138
|
sdk.invoke(:me)
|
139
139
|
end
|
140
140
|
end
|
141
141
|
end
|
142
142
|
|
143
143
|
it "get no params" do
|
144
|
-
verify(response, :get, '/api/
|
144
|
+
verify(response, :get, '/api/4.0/user') do |sdk|
|
145
145
|
sdk.me
|
146
146
|
end
|
147
147
|
end
|
148
148
|
|
149
149
|
it "get with params" do
|
150
|
-
verify(response, :get, '/api/
|
150
|
+
verify(response, :get, '/api/4.0/users/25') do |sdk|
|
151
151
|
sdk.user(25)
|
152
152
|
end
|
153
153
|
end
|
154
154
|
|
155
155
|
it "get with params that need encoding" do
|
156
|
-
verify(response, :get, '/api/
|
156
|
+
verify(response, :get, '/api/4.0/users/foo%2Fbar') do |sdk|
|
157
157
|
sdk.user("foo/bar")
|
158
158
|
end
|
159
159
|
end
|
160
160
|
|
161
161
|
it "get with params already encoded" do
|
162
|
-
verify(response, :get, '/api/
|
162
|
+
verify(response, :get, '/api/4.0/users/foo%2Fbar') do |sdk|
|
163
163
|
sdk.user("foo%2Fbar")
|
164
164
|
end
|
165
165
|
end
|
166
166
|
|
167
167
|
it "get with query" do
|
168
|
-
verify(response, :get, '/api/
|
168
|
+
verify(response, :get, '/api/4.0/user', '', {bar:"foo"}) do |sdk|
|
169
169
|
sdk.me({bar:'foo'})
|
170
170
|
end
|
171
171
|
end
|
172
172
|
|
173
173
|
it "get with params and query" do
|
174
|
-
verify(response, :get, '/api/
|
174
|
+
verify(response, :get, '/api/4.0/users/25', '', {bar:"foo"}) do |sdk|
|
175
175
|
sdk.user(25, {bar:'foo'})
|
176
176
|
end
|
177
177
|
end
|
178
178
|
|
179
179
|
it "get with array query param - string input (csv)" do
|
180
|
-
verify(response, :get, '/api/
|
180
|
+
verify(response, :get, '/api/4.0/users/1/attribute_values','',{user_attribute_ids: '2,3,4'}) do |sdk|
|
181
181
|
sdk.user_attribute_user_values(1, {user_attribute_ids: '2,3,4'})
|
182
182
|
sdk.last_response.env.url.query.must_equal 'user_attribute_ids=2%2C3%2C4'
|
183
183
|
end
|
184
184
|
end
|
185
185
|
|
186
186
|
it "get with array query param - array input (multi[])" do
|
187
|
-
verify(response, :get, '/api/
|
187
|
+
verify(response, :get, '/api/4.0/users/1/attribute_values','',{user_attribute_ids: ['2','3','4']}) do |sdk|
|
188
188
|
sdk.user_attribute_user_values(1, {user_attribute_ids: [2,3,4]})
|
189
189
|
sdk.last_response.env.url.query.must_equal 'user_attribute_ids%5B%5D=2&user_attribute_ids%5B%5D=3&user_attribute_ids%5B%5D=4'
|
190
190
|
end
|
191
191
|
end
|
192
192
|
|
193
193
|
it "post" do
|
194
|
-
verify(response, :post, '/api/
|
194
|
+
verify(response, :post, '/api/4.0/users', {first_name:'Joe'}) do |sdk|
|
195
195
|
sdk.create_user({first_name:'Joe'})
|
196
196
|
end
|
197
197
|
end
|
198
198
|
|
199
199
|
it "post with default body" do
|
200
|
-
verify(response, :post, '/api/
|
200
|
+
verify(response, :post, '/api/4.0/users', {}) do |sdk|
|
201
201
|
sdk.create_user()
|
202
202
|
end
|
203
203
|
end
|
204
204
|
|
205
205
|
it "post with default body and default content_type" do
|
206
|
-
verify(response, :post, '/api/
|
206
|
+
verify(response, :post, '/api/4.0/users', {}, {}, "application/json") do |sdk|
|
207
207
|
sdk.create_user()
|
208
208
|
end
|
209
209
|
end
|
210
210
|
|
211
211
|
it "post with default body and specific content_type at option-level" do
|
212
|
-
verify(response, :post, '/api/
|
212
|
+
verify(response, :post, '/api/4.0/users', {}, {}, "application/vnd.BOGUS1+json") do |sdk|
|
213
213
|
sdk.create_user({}, {:content_type => "application/vnd.BOGUS1+json"})
|
214
214
|
end
|
215
215
|
end
|
216
216
|
|
217
217
|
it "post with default body and specific content_type in headers" do
|
218
|
-
verify(response, :post, '/api/
|
218
|
+
verify(response, :post, '/api/4.0/users', {}, {}, "application/vnd.BOGUS2+json") do |sdk|
|
219
219
|
sdk.create_user({}, {:headers => {:content_type => "application/vnd.BOGUS2+json"}})
|
220
220
|
end
|
221
221
|
end
|
222
222
|
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
223
|
+
if defined?(Faraday::FilePart) or Gem.loaded_specs['faraday'].version < Gem::Version.new('2.0')
|
224
|
+
it "post with file upload" do
|
225
|
+
#skip 'not required with this version'
|
226
|
+
verify(response, :post, '/api/4.0/users', {first_name:'Joe', last_name:'User'}, {}, "application/vnd.BOGUS3+json") do |sdk|
|
227
|
+
name = File.join(File.dirname(__FILE__), 'user.json')
|
228
|
+
if Gem.loaded_specs['faraday'].version < Gem::Version.new('2.0')
|
229
|
+
sdk.create_user(Faraday::UploadIO.new(name, "application/vnd.BOGUS3+json"))
|
230
|
+
else
|
231
|
+
sdk.create_user(Faraday::FilePart.new(name, "application/vnd.BOGUS3+json"))
|
232
|
+
end
|
231
233
|
end
|
232
234
|
end
|
233
235
|
end
|
234
236
|
|
235
237
|
it "patch" do
|
236
|
-
verify(response, :patch, '/api/
|
238
|
+
verify(response, :patch, '/api/4.0/users/25', {first_name:'Jim'}) do |sdk|
|
237
239
|
sdk.update_user(25, {first_name:'Jim'})
|
238
240
|
end
|
239
241
|
end
|
240
242
|
|
241
243
|
it "patch with query" do
|
242
|
-
verify(response, :post, '/api/
|
244
|
+
verify(response, :post, '/api/4.0/users', {first_name:'Jim'}, {foo:'bar', baz:'bla'}) do |sdk|
|
243
245
|
sdk.create_user({first_name:'Jim'}, {foo:'bar', baz:'bla'})
|
244
246
|
end
|
245
247
|
end
|
246
248
|
|
247
249
|
it "put" do
|
248
|
-
verify(response, :put, '/api/
|
250
|
+
verify(response, :put, '/api/4.0/users/25/roles', [10, 20]) do |sdk|
|
249
251
|
sdk.set_user_roles(25, [10,20])
|
250
252
|
end
|
251
253
|
end
|
252
254
|
|
253
255
|
it "delete" do
|
254
|
-
verify(delete_response, :delete, '/api/
|
256
|
+
verify(delete_response, :delete, '/api/4.0/users/25') do |sdk|
|
255
257
|
sdk.delete_user(25)
|
256
258
|
end
|
257
259
|
end
|
@@ -64,15 +64,21 @@ describe LookerSDK::Client::Dynamic do
|
|
64
64
|
|
65
65
|
describe "swagger" do
|
66
66
|
it "get" do
|
67
|
-
mock =
|
67
|
+
#mock = Minitest::Mock.new.expect(:call, response, [:get, '/api/4.0/user', nil])
|
68
|
+
mock = Minitest::Mock.new.expect :call, response do | verb, route, body, h=nil, **kw |
|
69
|
+
verb == :get && route == '/api/4.0/user' && body.nil?
|
70
|
+
end
|
68
71
|
with_stub(Sawyer::Agent, :new, mock) do
|
69
72
|
sdk.me
|
70
73
|
mock.verify
|
71
74
|
end
|
72
75
|
end
|
73
76
|
|
74
|
-
it "get with
|
75
|
-
mock =
|
77
|
+
it "get with params" do
|
78
|
+
#mock = Minitest::Mock.new.expect(:call, response, [:get, '/api/4.0/users/25', nil, {}])
|
79
|
+
mock = Minitest::Mock.new.expect :call, response do | verb, route, body |
|
80
|
+
verb == :get && route == '/api/4.0/users/25' && body.nil?
|
81
|
+
end
|
76
82
|
with_stub(Sawyer::Agent, :new, mock) do
|
77
83
|
sdk.user(25)
|
78
84
|
mock.verify
|
@@ -80,7 +86,10 @@ describe LookerSDK::Client::Dynamic do
|
|
80
86
|
end
|
81
87
|
|
82
88
|
it "get with query" do
|
83
|
-
mock =
|
89
|
+
#mock = Minitest::Mock.new.expect(:call, response, [:get, '/api/4.0/user', nil, {query:{bar:"foo"}}])
|
90
|
+
mock = Minitest::Mock.new.expect :call, response do | verb, route, body, h=nil, **kw |
|
91
|
+
verb == :get && route == '/api/4.0/user' && body.nil? && ( h={query:{bar:"foo"}} || kw = {query:{bar:"foo"}} )
|
92
|
+
end
|
84
93
|
with_stub(Sawyer::Agent, :new, mock) do
|
85
94
|
sdk.me({bar:'foo'})
|
86
95
|
mock.verify
|
@@ -88,7 +97,10 @@ describe LookerSDK::Client::Dynamic do
|
|
88
97
|
end
|
89
98
|
|
90
99
|
it "get with params and query" do
|
91
|
-
mock =
|
100
|
+
#mock = Minitest::Mock.new.expect(:call, response, [:get, '/api/4.0/users/25', nil, {query:{bar:"foo"}}])
|
101
|
+
mock = Minitest::Mock.new.expect :call, response do | verb, route, body,h=nil, **kw |
|
102
|
+
verb == :get && route == '/api/4.0/users/25' && body.nil? && ( h={query:{bar:"foo"}} || kw = {query:{bar:"foo"}} )
|
103
|
+
end
|
92
104
|
with_stub(Sawyer::Agent, :new, mock) do
|
93
105
|
sdk.user(25, {bar:'foo'})
|
94
106
|
mock.verify
|
@@ -96,7 +108,10 @@ describe LookerSDK::Client::Dynamic do
|
|
96
108
|
end
|
97
109
|
|
98
110
|
it "post" do
|
99
|
-
mock =
|
111
|
+
#mock = Minitest::Mock.new.expect(:call, response, [:post, '/api/4.0/users', {first_name:'Joe'}, {:headers=>{:content_type=>"application/json"}}])
|
112
|
+
mock = Minitest::Mock.new.expect :call, response do | verb, route, body, h=nil, **kw |
|
113
|
+
verb == :post && route == '/api/4.0/users' && body == {first_name:'Joe'} && ( h={:headers=>{:content_type=>"application/json"}} || kw = {:headers=>{:content_type=>"application/json"}} )
|
114
|
+
end
|
100
115
|
with_stub(Sawyer::Agent, :new, mock) do
|
101
116
|
sdk.create_user({first_name:'Joe'})
|
102
117
|
mock.verify
|
@@ -104,7 +119,10 @@ describe LookerSDK::Client::Dynamic do
|
|
104
119
|
end
|
105
120
|
|
106
121
|
it "post with default body" do
|
107
|
-
mock =
|
122
|
+
#mock = Minitest::Mock.new.expect(:call, response, [:post, '/api/4.0/users', {}, {:headers=>{:content_type=>"application/json"}}])
|
123
|
+
mock = Minitest::Mock.new.expect :call, response do | verb, route, body, h=nil, **kw |
|
124
|
+
verb == :post && route == '/api/4.0/users' && body.empty? && ( h={:headers=>{:content_type=>"application/json"}} || kw = {:headers=>{:content_type=>"application/json"}} )
|
125
|
+
end
|
108
126
|
with_stub(Sawyer::Agent, :new, mock) do
|
109
127
|
sdk.create_user()
|
110
128
|
mock.verify
|
@@ -112,7 +130,10 @@ describe LookerSDK::Client::Dynamic do
|
|
112
130
|
end
|
113
131
|
|
114
132
|
it "patch" do
|
115
|
-
mock =
|
133
|
+
#mock = Minitest::Mock.new.expect(:call, response, [:patch, '/api/4.0/users/25', {first_name:'Jim'}, {:headers=>{:content_type=>"application/json"}}])
|
134
|
+
mock = Minitest::Mock.new.expect :call, response do | verb, route, body, h=nil, **kw |
|
135
|
+
verb == :patch && route == '/api/4.0/users/25' && body == {first_name:'Jim'} && ( h={:headers=>{:content_type=>"application/json"}} || kw = {:headers=>{:content_type=>"application/json"}} )
|
136
|
+
end
|
116
137
|
with_stub(Sawyer::Agent, :new, mock) do
|
117
138
|
sdk.update_user(25, {first_name:'Jim'})
|
118
139
|
mock.verify
|
@@ -120,7 +141,10 @@ describe LookerSDK::Client::Dynamic do
|
|
120
141
|
end
|
121
142
|
|
122
143
|
it "put" do
|
123
|
-
mock =
|
144
|
+
#mock = Minitest::Mock.new.expect(:call, response, [:put, '/api/4.0/users/25/roles', [10, 20], {:headers=>{:content_type=>"application/json"}}])
|
145
|
+
mock = Minitest::Mock.new.expect :call, response do | verb, route, body, h=nil, **kw |
|
146
|
+
verb == :put && route == '/api/4.0/users/25/roles' && body == [10, 20] && ( h={:headers=>{:content_type=>"application/json"}} || kw = {:headers=>{:content_type=>"application/json"}} )
|
147
|
+
end
|
124
148
|
with_stub(Sawyer::Agent, :new, mock) do
|
125
149
|
sdk.set_user_roles(25, [10,20])
|
126
150
|
mock.verify
|
@@ -128,7 +152,10 @@ describe LookerSDK::Client::Dynamic do
|
|
128
152
|
end
|
129
153
|
|
130
154
|
it "put with nil body" do
|
131
|
-
mock =
|
155
|
+
#mock = Minitest::Mock.new.expect(:call, response, [:put, '/api/4.0/users/25/roles', nil])
|
156
|
+
mock = Minitest::Mock.new.expect :call, response do | verb, route, body, h=nil, **kw |
|
157
|
+
verb == :put && route == '/api/4.0/users/25/roles' && body.nil?
|
158
|
+
end
|
132
159
|
with_stub(Sawyer::Agent, :new, mock) do
|
133
160
|
sdk.set_user_roles(25, nil)
|
134
161
|
mock.verify
|
@@ -136,7 +163,10 @@ describe LookerSDK::Client::Dynamic do
|
|
136
163
|
end
|
137
164
|
|
138
165
|
it "put with empty body" do
|
139
|
-
mock =
|
166
|
+
#mock = Minitest::Mock.new.expect(:call, response, [:put, '/api/4.0/users/25/roles', {}, {:headers=>{:content_type=>"application/json"}}])
|
167
|
+
mock = Minitest::Mock.new.expect :call, response do | verb, route, body, h=nil, **kw |
|
168
|
+
verb == :put && route == '/api/4.0/users/25/roles' && body.empty? && ( h={:headers=>{:content_type=>"application/json"}} || kw = {:headers=>{:content_type=>"application/json"}} )
|
169
|
+
end
|
140
170
|
with_stub(Sawyer::Agent, :new, mock) do
|
141
171
|
sdk.set_user_roles(25, {})
|
142
172
|
mock.verify
|
@@ -144,7 +174,10 @@ describe LookerSDK::Client::Dynamic do
|
|
144
174
|
end
|
145
175
|
|
146
176
|
it "delete" do
|
147
|
-
mock =
|
177
|
+
#mock = Minitest::Mock.new.expect(:call, delete_response, [:delete, '/api/4.0/users/25', nil])
|
178
|
+
mock = Minitest::Mock.new.expect :call, response do | verb, route, body, h=nil, **kw |
|
179
|
+
verb == :delete && route == '/api/4.0/users/25' && body.nil?
|
180
|
+
end
|
148
181
|
with_stub(Sawyer::Agent, :new, mock) do
|
149
182
|
sdk.delete_user(25)
|
150
183
|
mock.verify
|
@@ -0,0 +1,97 @@
|
|
1
|
+
############################################################################################
|
2
|
+
# The MIT License (MIT)
|
3
|
+
#
|
4
|
+
# Copyright (c) 2024 Google LLC
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files (the "Software"), to deal
|
8
|
+
# in the Software without restriction, including without limitation the rights
|
9
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
# copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be included in
|
14
|
+
# all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
+
# THE SOFTWARE.
|
23
|
+
############################################################################################
|
24
|
+
|
25
|
+
require_relative '../helper'
|
26
|
+
|
27
|
+
describe LookerSDK::Client do
|
28
|
+
|
29
|
+
before(:each) do
|
30
|
+
setup_sdk
|
31
|
+
end
|
32
|
+
|
33
|
+
base_url = ENV['LOOKERSDK_BASE_URL'] || 'https://localhost:19999'
|
34
|
+
verify_ssl = case ENV['LOOKERSDK_VERIFY_SSL']
|
35
|
+
when /false/i
|
36
|
+
false
|
37
|
+
when /f/i
|
38
|
+
false
|
39
|
+
when '0'
|
40
|
+
false
|
41
|
+
else
|
42
|
+
true
|
43
|
+
end
|
44
|
+
api_version = ENV['LOOKERSDK_API_VERSION'] || '4.0'
|
45
|
+
client_id = ENV['LOOKERSDK_CLIENT_ID']
|
46
|
+
client_secret = ENV['LOOKERSDK_CLIENT_SECRET']
|
47
|
+
|
48
|
+
opts = {}
|
49
|
+
if (client_id && client_secret) then
|
50
|
+
opts.merge!({
|
51
|
+
:client_id => client_id,
|
52
|
+
:client_secret => client_secret,
|
53
|
+
:api_endpoint => "#{base_url}/api/#{api_version}",
|
54
|
+
})
|
55
|
+
opts[:connection_options] = {:ssl => {:verify => false}} unless verify_ssl
|
56
|
+
else
|
57
|
+
opts.merge!({
|
58
|
+
:netrc => true,
|
59
|
+
:netrc_file => File.join(fixture_path, '.netrc'),
|
60
|
+
:connection_options => {:ssl => {:verify => false}},
|
61
|
+
})
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
describe "run inline query" do
|
66
|
+
it "blocking" do
|
67
|
+
LookerSDK.reset!
|
68
|
+
client = LookerSDK::Client.new(opts)
|
69
|
+
response = client.run_inline_query("csv",
|
70
|
+
{
|
71
|
+
"model": "system__activity",
|
72
|
+
"view": "history",
|
73
|
+
"fields": ["history.query_run_count", "query.model"],
|
74
|
+
"limit": 5000
|
75
|
+
}
|
76
|
+
)
|
77
|
+
assert response
|
78
|
+
end
|
79
|
+
|
80
|
+
it "streaming" do
|
81
|
+
LookerSDK.reset!
|
82
|
+
client = LookerSDK::Client.new(opts)
|
83
|
+
response = ""
|
84
|
+
client.run_inline_query("csv",
|
85
|
+
{
|
86
|
+
"model": "system__activity",
|
87
|
+
"view": "history",
|
88
|
+
"fields": ["history.query_run_count", "query.model"],
|
89
|
+
"limit": 5000
|
90
|
+
}
|
91
|
+
) do |data, progress|
|
92
|
+
response << data
|
93
|
+
end
|
94
|
+
assert response
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: looker-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Looker
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sawyer
|
@@ -110,43 +110,13 @@ executables: []
|
|
110
110
|
extensions: []
|
111
111
|
extra_rdoc_files: []
|
112
112
|
files:
|
113
|
-
- ".github/CODEOWNERS"
|
114
|
-
- ".github/scripts/wait_for_looker.sh"
|
115
|
-
- ".github/workflows/release-metrics.yml"
|
116
|
-
- ".github/workflows/release.yml"
|
117
|
-
- ".github/workflows/ruby-ci.yml"
|
118
|
-
- ".gitignore"
|
119
|
-
- ".ruby-gemset"
|
120
113
|
- CHANGELOG.md
|
121
114
|
- CODE_OF_CONDUCT.md
|
122
115
|
- CONTRIBUTING.md
|
123
|
-
- Gemfile
|
124
|
-
- Gemfile.lock
|
125
116
|
- LICENSE.md
|
126
|
-
- Makefile
|
127
117
|
- Octokit_LICENSE.md
|
128
118
|
- README.md
|
129
|
-
- Rakefile
|
130
119
|
- authentication.md
|
131
|
-
- examples/.netrc
|
132
|
-
- examples/add_delete_users.rb
|
133
|
-
- examples/change_credentials_email_address_for_users.rb
|
134
|
-
- examples/convert_look_to_lookless_tile.rb
|
135
|
-
- examples/create_credentials_email_for_users.rb
|
136
|
-
- examples/delete_all_user_sessions.rb
|
137
|
-
- examples/delete_credentials_google_for_users.rb
|
138
|
-
- examples/errors.rb
|
139
|
-
- examples/generate_password_reset_tokens_for_users.rb
|
140
|
-
- examples/ldap_roles_test.rb
|
141
|
-
- examples/me.rb
|
142
|
-
- examples/refresh_user_notification_addresses.rb
|
143
|
-
- examples/roles_and_users_with_permission.rb
|
144
|
-
- examples/sdk_setup.rb
|
145
|
-
- examples/streaming_downloads.rb
|
146
|
-
- examples/users_with_credentials_email.rb
|
147
|
-
- examples/users_with_credentials_embed.rb
|
148
|
-
- examples/users_with_credentials_google.rb
|
149
|
-
- examples/users_with_credentials_google_without_credentials_email.rb
|
150
120
|
- lib/looker-sdk.rb
|
151
121
|
- lib/looker-sdk/authentication.rb
|
152
122
|
- lib/looker-sdk/client.rb
|
@@ -158,27 +128,19 @@ files:
|
|
158
128
|
- lib/looker-sdk/response/raise_error.rb
|
159
129
|
- lib/looker-sdk/sawyer_patch.rb
|
160
130
|
- lib/looker-sdk/version.rb
|
161
|
-
- looker-sdk.gemspec
|
162
|
-
- shell.nix
|
163
|
-
- shell/.gitignore
|
164
|
-
- shell/.netrc
|
165
|
-
- shell/Gemfile
|
166
|
-
- shell/Gemfile.lock
|
167
|
-
- shell/readme.md
|
168
|
-
- shell/shell.rb
|
169
131
|
- streaming.md
|
170
|
-
- test/fixtures/.netrc.template
|
171
132
|
- test/helper.rb
|
172
133
|
- test/looker/swagger.json
|
173
134
|
- test/looker/test_client.rb
|
174
135
|
- test/looker/test_dynamic_client.rb
|
175
136
|
- test/looker/test_dynamic_client_agent.rb
|
137
|
+
- test/looker/test_inline_query.rb
|
176
138
|
- test/looker/user.json
|
177
139
|
homepage: https://github.com/looker-open-source/looker-sdk-ruby
|
178
140
|
licenses:
|
179
141
|
- MIT
|
180
142
|
metadata: {}
|
181
|
-
post_install_message:
|
143
|
+
post_install_message:
|
182
144
|
rdoc_options: []
|
183
145
|
require_paths:
|
184
146
|
- lib
|
@@ -195,7 +157,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
195
157
|
requirements:
|
196
158
|
- Looker version 4.0 or later
|
197
159
|
rubygems_version: 3.1.6
|
198
|
-
signing_key:
|
160
|
+
signing_key:
|
199
161
|
specification_version: 4
|
200
162
|
summary: Looker Ruby SDK
|
201
|
-
test_files:
|
163
|
+
test_files:
|
164
|
+
- test/helper.rb
|
165
|
+
- test/looker/test_dynamic_client.rb
|
166
|
+
- test/looker/test_inline_query.rb
|
167
|
+
- test/looker/test_dynamic_client_agent.rb
|
168
|
+
- test/looker/test_client.rb
|
169
|
+
- test/looker/user.json
|
170
|
+
- test/looker/swagger.json
|
data/.github/CODEOWNERS
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
* @looker-open-source/cloud-looker-devrel
|
@@ -1,35 +0,0 @@
|
|
1
|
-
#!/bin/sh
|
2
|
-
|
3
|
-
check_looker() {
|
4
|
-
status=$(curl --silent --insecure --write "%{http_code}" \
|
5
|
-
--data "client_id=$LOOKERSDK_CLIENT_ID&client_secret=$LOOKERSDK_CLIENT_SECRET"\
|
6
|
-
$LOOKERSDK_BASE_URL/api/${LOOKERSDK_API_VERSION:-4.0}/login\
|
7
|
-
-o /dev/null)
|
8
|
-
}
|
9
|
-
|
10
|
-
MAX_RETRIES=160
|
11
|
-
ATTEMPTS=1
|
12
|
-
status=0
|
13
|
-
check_looker
|
14
|
-
while [ $status -ne 200 ];
|
15
|
-
do
|
16
|
-
RETRY_MSG="after $ATTEMPTS attempts: $(expr $MAX_RETRIES - $ATTEMPTS) retries remaining."
|
17
|
-
if [ $ATTEMPTS -ge $MAX_RETRIES ];
|
18
|
-
then
|
19
|
-
echo 'Looker took too long to start'
|
20
|
-
exit 1
|
21
|
-
else
|
22
|
-
if [ $status -ne 0 ];
|
23
|
-
then
|
24
|
-
echo "Received status($status) from Looker $RETRY_MSG"
|
25
|
-
else
|
26
|
-
echo "Looker server connection rejected $RETRY_MSG"
|
27
|
-
fi
|
28
|
-
fi
|
29
|
-
|
30
|
-
sleep 2
|
31
|
-
ATTEMPTS=$(( $ATTEMPTS + 1 ))
|
32
|
-
check_looker
|
33
|
-
done
|
34
|
-
echo "Looker ready after $ATTEMPTS attempts"
|
35
|
-
exit 0
|