looker-sdk 0.1.6 → 0.1.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +19 -0
  3. data/lib/looker-sdk/client.rb +8 -6
  4. data/lib/looker-sdk/error.rb +1 -1
  5. data/lib/looker-sdk/version.rb +1 -1
  6. data/test/helper.rb +11 -5
  7. data/test/looker/swagger.json +42011 -1117
  8. data/test/looker/test_client.rb +19 -15
  9. data/test/looker/test_dynamic_client.rb +36 -34
  10. data/test/looker/test_dynamic_client_agent.rb +45 -12
  11. metadata +9 -40
  12. data/.github/scripts/wait_for_looker.sh +0 -35
  13. data/.github/workflows/release-metrics.yml +0 -44
  14. data/.github/workflows/release.yml +0 -47
  15. data/.github/workflows/ruby-ci.yml +0 -137
  16. data/.gitignore +0 -60
  17. data/.ruby-gemset +0 -1
  18. data/Gemfile +0 -22
  19. data/Gemfile.lock +0 -73
  20. data/Makefile +0 -81
  21. data/Rakefile +0 -38
  22. data/examples/.netrc +0 -1
  23. data/examples/add_delete_users.rb +0 -118
  24. data/examples/change_credentials_email_address_for_users.rb +0 -47
  25. data/examples/convert_look_to_lookless_tile.rb +0 -71
  26. data/examples/create_credentials_email_for_users.rb +0 -43
  27. data/examples/delete_all_user_sessions.rb +0 -39
  28. data/examples/delete_credentials_google_for_users.rb +0 -43
  29. data/examples/errors.rb +0 -47
  30. data/examples/generate_password_reset_tokens_for_users.rb +0 -43
  31. data/examples/ldap_roles_test.rb +0 -74
  32. data/examples/me.rb +0 -27
  33. data/examples/refresh_user_notification_addresses.rb +0 -34
  34. data/examples/roles_and_users_with_permission.rb +0 -46
  35. data/examples/sdk_setup.rb +0 -45
  36. data/examples/streaming_downloads.rb +0 -44
  37. data/examples/users_with_credentials_email.rb +0 -30
  38. data/examples/users_with_credentials_embed.rb +0 -33
  39. data/examples/users_with_credentials_google.rb +0 -30
  40. data/examples/users_with_credentials_google_without_credentials_email.rb +0 -30
  41. data/looker-sdk.gemspec +0 -32
  42. data/shell/.gitignore +0 -41
  43. data/shell/.netrc +0 -3
  44. data/shell/Gemfile +0 -6
  45. data/shell/readme.md +0 -18
  46. data/shell/shell.rb +0 -62
  47. data/shell.nix +0 -38
  48. data/test/fixtures/.netrc.template +0 -1
@@ -287,24 +287,28 @@ describe LookerSDK::Client do
287
287
  end
288
288
 
289
289
  [
290
- [:get, '/api/3.0/users/foo%2Fbar', false],
291
- [:get, '/api/3.0/users/foo%252Fbar', true],
292
- [:post, '/api/3.0/users/foo%2Fbar', false],
293
- [:post, '/api/3.0/users/foo%252Fbar', true],
294
- [:put, '/api/3.0/users/foo%2Fbar', false],
295
- [:put, '/api/3.0/users/foo%252Fbar', true],
296
- [:patch, '/api/3.0/users/foo%2Fbar', false],
297
- [:patch, '/api/3.0/users/foo%252Fbar', true],
298
- [:delete, '/api/3.0/users/foo%2Fbar', false],
299
- [:delete, '/api/3.0/users/foo%252Fbar', true],
300
- [:head, '/api/3.0/users/foo%2Fbar', false],
301
- [:head, '/api/3.0/users/foo%252Fbar', true],
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/3.0/users/foo%252Fbar'
304
+ expected_path = '/api/4.0/users/foo%252Fbar'
305
305
 
306
306
  resp = OpenStruct.new(:data => "hi", :status => 204)
307
- mock = MiniTest::Mock.new.expect(:call, resp, [method, expected_path, nil, {}])
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 *args
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 LookerDynamicClientTest < MiniTest::Spec
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.gets || ''
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 => e
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 = MiniTest::Mock.new.expect(:call, response){|env| confirm_env(env, method, path, body, query, content_type)}
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 = MiniTest::Mock.new.expect(:call, nil) {raise "no swagger for you"}
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 = MiniTest::Mock.new.expect(:call, resp, [Hash])
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 = MiniTest::Mock.new.expect(:call, nil) {raise "login first!"}
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/3.0/user') do |sdk|
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/3.0/user') do |sdk|
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/3.0/user') do |sdk|
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/3.0/users/25') do |sdk|
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/3.0/users/foo%2Fbar') do |sdk|
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/3.0/users/foo%2Fbar') do |sdk|
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/3.0/user', '', {bar:"foo"}) do |sdk|
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/3.0/users/25', '', {bar:"foo"}) do |sdk|
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/3.0/users/1/attribute_values','',{user_attribute_ids: '2,3,4'}) do |sdk|
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/3.0/users/1/attribute_values','',{user_attribute_ids: ['2','3','4']}) do |sdk|
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/3.0/users', {first_name:'Joe'}) do |sdk|
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/3.0/users', {}) do |sdk|
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/3.0/users', {}, {}, "application/json") do |sdk|
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/3.0/users', {}, {}, "application/vnd.BOGUS1+json") do |sdk|
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/3.0/users', {}, {}, "application/vnd.BOGUS2+json") do |sdk|
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
- it "post with file upload" do
224
- verify(response, :post, '/api/3.0/users', {first_name:'Joe', last_name:'User'}, {}, "application/vnd.BOGUS3+json") do |sdk|
225
- name = File.join(File.dirname(__FILE__), 'user.json')
226
- if Gem.loaded_specs['faraday'].version < Gem::Version.new('2.0')
227
- sdk.create_user(Faraday::UploadIO.new(name, "application/vnd.BOGUS3+json"))
228
- else
229
- sdk.create_user(Faraday::FilePart.new(name, "application/vnd.BOGUS3+json"))
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
230
233
  end
231
-
232
234
  end
233
235
  end
234
236
 
235
237
  it "patch" do
236
- verify(response, :patch, '/api/3.0/users/25', {first_name:'Jim'}) do |sdk|
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/3.0/users', {first_name:'Jim'}, {foo:'bar', baz:'bla'}) do |sdk|
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/3.0/users/25/roles', [10, 20]) do |sdk|
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/3.0/users/25') do |sdk|
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 = MiniTest::Mock.new.expect(:call, response, [:get, '/api/3.0/user', nil, {}])
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 parms" do
75
- mock = MiniTest::Mock.new.expect(:call, response, [:get, '/api/3.0/users/25', nil, {}])
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 = MiniTest::Mock.new.expect(:call, response, [:get, '/api/3.0/user', nil, {query:{bar:"foo"}}])
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 = MiniTest::Mock.new.expect(:call, response, [:get, '/api/3.0/users/25', nil, {query:{bar:"foo"}}])
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 = MiniTest::Mock.new.expect(:call, response, [:post, '/api/3.0/users', {first_name:'Joe'}, {:headers=>{:content_type=>"application/json"}}])
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 = MiniTest::Mock.new.expect(:call, response, [:post, '/api/3.0/users', {}, {:headers=>{:content_type=>"application/json"}}])
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 = MiniTest::Mock.new.expect(:call, response, [:patch, '/api/3.0/users/25', {first_name:'Jim'}, {:headers=>{:content_type=>"application/json"}}])
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 = MiniTest::Mock.new.expect(:call, response, [:put, '/api/3.0/users/25/roles', [10, 20], {:headers=>{:content_type=>"application/json"}}])
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 = MiniTest::Mock.new.expect(:call, response, [:put, '/api/3.0/users/25/roles', nil, {}])
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 = MiniTest::Mock.new.expect(:call, response, [:put, '/api/3.0/users/25/roles', {}, {:headers=>{:content_type=>"application/json"}}])
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 = MiniTest::Mock.new.expect(:call, delete_response, [:delete, '/api/3.0/users/25', nil, {}])
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
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.6
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Looker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-28 00:00:00.000000000 Z
11
+ date: 2024-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sawyer
@@ -110,42 +110,13 @@ executables: []
110
110
  extensions: []
111
111
  extra_rdoc_files: []
112
112
  files:
113
- - ".github/scripts/wait_for_looker.sh"
114
- - ".github/workflows/release-metrics.yml"
115
- - ".github/workflows/release.yml"
116
- - ".github/workflows/ruby-ci.yml"
117
- - ".gitignore"
118
- - ".ruby-gemset"
119
113
  - CHANGELOG.md
120
114
  - CODE_OF_CONDUCT.md
121
115
  - CONTRIBUTING.md
122
- - Gemfile
123
- - Gemfile.lock
124
116
  - LICENSE.md
125
- - Makefile
126
117
  - Octokit_LICENSE.md
127
118
  - README.md
128
- - Rakefile
129
119
  - authentication.md
130
- - examples/.netrc
131
- - examples/add_delete_users.rb
132
- - examples/change_credentials_email_address_for_users.rb
133
- - examples/convert_look_to_lookless_tile.rb
134
- - examples/create_credentials_email_for_users.rb
135
- - examples/delete_all_user_sessions.rb
136
- - examples/delete_credentials_google_for_users.rb
137
- - examples/errors.rb
138
- - examples/generate_password_reset_tokens_for_users.rb
139
- - examples/ldap_roles_test.rb
140
- - examples/me.rb
141
- - examples/refresh_user_notification_addresses.rb
142
- - examples/roles_and_users_with_permission.rb
143
- - examples/sdk_setup.rb
144
- - examples/streaming_downloads.rb
145
- - examples/users_with_credentials_email.rb
146
- - examples/users_with_credentials_embed.rb
147
- - examples/users_with_credentials_google.rb
148
- - examples/users_with_credentials_google_without_credentials_email.rb
149
120
  - lib/looker-sdk.rb
150
121
  - lib/looker-sdk/authentication.rb
151
122
  - lib/looker-sdk/client.rb
@@ -157,15 +128,7 @@ files:
157
128
  - lib/looker-sdk/response/raise_error.rb
158
129
  - lib/looker-sdk/sawyer_patch.rb
159
130
  - lib/looker-sdk/version.rb
160
- - looker-sdk.gemspec
161
- - shell.nix
162
- - shell/.gitignore
163
- - shell/.netrc
164
- - shell/Gemfile
165
- - shell/readme.md
166
- - shell/shell.rb
167
131
  - streaming.md
168
- - test/fixtures/.netrc.template
169
132
  - test/helper.rb
170
133
  - test/looker/swagger.json
171
134
  - test/looker/test_client.rb
@@ -196,4 +159,10 @@ rubygems_version: 3.1.6
196
159
  signing_key:
197
160
  specification_version: 4
198
161
  summary: Looker Ruby SDK
199
- test_files: []
162
+ test_files:
163
+ - test/helper.rb
164
+ - test/looker/test_client.rb
165
+ - test/looker/test_dynamic_client.rb
166
+ - test/looker/swagger.json
167
+ - test/looker/user.json
168
+ - test/looker/test_dynamic_client_agent.rb
@@ -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
@@ -1,44 +0,0 @@
1
- name: Send publish metrics to bigquery
2
- on:
3
- release:
4
- types: published
5
- jobs:
6
- publish:
7
- runs-on: ubuntu-latest
8
- steps:
9
- - name: Set up Cloud SDK
10
- uses: google-github-actions/setup-gcloud@v0.2.0
11
- with:
12
- project_id: ${{ secrets.GCP_PROJECT_ID }}
13
- service_account_key: ${{ secrets.GCP_BQ_METRICS_KEY }}
14
- export_default_credentials: true
15
-
16
- - name: Debug event json
17
- run: cat $GITHUB_EVENT_PATH
18
-
19
- - name: Check for release key
20
- run: echo "HAS_RELEASE_KEY=$(jq 'has("release")' $GITHUB_EVENT_PATH)" >> $GITHUB_ENV
21
-
22
- - name: Write release json
23
- if: ${{env.HAS_RELEASE_KEY== 'true'}}
24
- run: 'jq -c ''.release |
25
- {
26
- package_name: .name | split(" ")[0],
27
- name,
28
- tag_name,
29
- version: try(.tag_name | split("-v")[1]),
30
- html_url,
31
- target_commitish,
32
- created_at,
33
- published_at,
34
- draft,
35
- prerelease
36
- }'' $GITHUB_EVENT_PATH > releases.json'
37
-
38
- - name: Debug release json
39
- if: ${{env.HAS_RELEASE_KEY== 'true'}}
40
- run: cat releases.json
41
-
42
- - name: Send release.json to BQ
43
- if: ${{env.HAS_RELEASE_KEY== 'true'}}
44
- run: bq load --source_format=NEWLINE_DELIMITED_JSON metrics.releases releases.json
@@ -1,47 +0,0 @@
1
- # .github/workflows/release.yml
2
-
3
- name: release
4
-
5
- on:
6
- push:
7
- branches:
8
- - main
9
-
10
- jobs:
11
- release-please:
12
- runs-on: ubuntu-latest
13
- steps:
14
- - uses: GoogleCloudPlatform/release-please-action@v3
15
- id: release
16
- with:
17
- release-type: ruby
18
- package-name: looker-sdk
19
- bump-minor-pre-major: true
20
- bump-patch-for-minor-pre-major: true
21
- version-file: "lib/looker-sdk/version.rb"
22
- token: ${{ secrets.LOS_AUTO_BOT_RP_TOKEN }}
23
- # Checkout code if release was created
24
- - uses: actions/checkout@v2
25
- if: ${{ steps.release.outputs.release_created }}
26
- # Setup ruby if a release was created
27
- - uses: ruby/setup-ruby@v1
28
- with:
29
- ruby-version: 2.7.7
30
- if: ${{ steps.release.outputs.release_created }}
31
- # Bundle install
32
- - run: bundle install
33
- if: ${{ steps.release.outputs.release_created }}
34
- # Publish
35
- - name: publish gem
36
- run: |
37
- mkdir -p $HOME/.gem
38
- touch $HOME/.gem/credentials
39
- chmod 0600 $HOME/.gem/credentials
40
- printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
41
- gem build *.gemspec
42
- gem push *.gem
43
- env:
44
- # Make sure to update the secret name
45
- # if yours isn't named RUBYGEMS_AUTH_TOKEN
46
- GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
47
- if: ${{ steps.release.outputs.release_created }}