looker-sdk 0.0.6 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.github/scripts/wait_for_looker.sh +35 -0
  3. data/.github/workflows/release.yml +47 -0
  4. data/.github/workflows/ruby-ci.yml +60 -0
  5. data/.gitignore +3 -0
  6. data/CHANGELOG.md +13 -0
  7. data/CODE_OF_CONDUCT.md +73 -26
  8. data/CONTRIBUTING.md +29 -0
  9. data/Gemfile +1 -1
  10. data/LICENSE.md +33 -0
  11. data/Makefile +81 -0
  12. data/Rakefile +24 -27
  13. data/authentication.md +3 -3
  14. data/examples/add_delete_users.rb +24 -0
  15. data/examples/change_credentials_email_address_for_users.rb +24 -0
  16. data/examples/convert_look_to_lookless_tile.rb +71 -0
  17. data/examples/create_credentials_email_for_users.rb +24 -0
  18. data/examples/delete_all_user_sessions.rb +24 -0
  19. data/examples/delete_credentials_google_for_users.rb +24 -0
  20. data/examples/generate_password_reset_tokens_for_users.rb +24 -0
  21. data/examples/ldap_roles_test.rb +24 -0
  22. data/examples/me.rb +24 -0
  23. data/examples/refresh_user_notification_addresses.rb +24 -0
  24. data/examples/roles_and_users_with_permission.rb +24 -0
  25. data/examples/sdk_setup.rb +24 -0
  26. data/examples/streaming_downloads.rb +24 -0
  27. data/examples/users_with_credentials_email.rb +24 -0
  28. data/examples/users_with_credentials_embed.rb +24 -0
  29. data/examples/users_with_credentials_google.rb +23 -1
  30. data/examples/users_with_credentials_google_without_credentials_email.rb +24 -0
  31. data/lib/looker-sdk/authentication.rb +27 -2
  32. data/lib/looker-sdk/client/dynamic.rb +61 -11
  33. data/lib/looker-sdk/client.rb +52 -16
  34. data/lib/looker-sdk/configurable.rb +28 -2
  35. data/lib/looker-sdk/default.rb +30 -0
  36. data/lib/looker-sdk/error.rb +28 -0
  37. data/lib/looker-sdk/rate_limit.rb +24 -0
  38. data/lib/looker-sdk/response/raise_error.rb +25 -3
  39. data/lib/looker-sdk/sawyer_patch.rb +25 -1
  40. data/lib/looker-sdk/version.rb +25 -1
  41. data/lib/looker-sdk.rb +50 -0
  42. data/looker-sdk.gemspec +4 -4
  43. data/readme.md +9 -5
  44. data/shell/Gemfile +1 -1
  45. data/shell/shell.rb +24 -0
  46. data/test/fixtures/{.netrc → .netrc.template} +0 -0
  47. data/test/helper.rb +56 -6
  48. data/test/looker/swagger.json +1 -1
  49. data/test/looker/test_client.rb +117 -5
  50. data/test/looker/test_dynamic_client.rb +75 -3
  51. data/test/looker/test_dynamic_client_agent.rb +24 -0
  52. metadata +27 -21
  53. data/.travis.yml +0 -16
  54. data/LICENSE +0 -21
@@ -1,3 +1,27 @@
1
+ ############################################################################################
2
+ # The MIT License (MIT)
3
+ #
4
+ # Copyright (c) 2018 Looker Data Sciences, Inc.
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
+
1
25
  require 'sawyer'
2
26
  require 'ostruct'
3
27
  require 'looker-sdk/sawyer_patch'
@@ -34,7 +58,9 @@ module LookerSDK
34
58
  @original_options = options.dup
35
59
 
36
60
  load_credentials_from_netrc unless application_credentials?
37
- load_swagger
61
+ if !@lazy_swagger
62
+ load_swagger
63
+ end
38
64
  self.dynamic = true
39
65
  end
40
66
 
@@ -65,11 +91,12 @@ module LookerSDK
65
91
  #
66
92
  # @param url [String] The path, relative to {#api_endpoint}
67
93
  # @param options [Hash] Query and header params for request
94
+ # @param encoded [Boolean] true: url already encoded, false: url needs encoding
68
95
  # @param &block [Block] Block to be called with |response, chunk| for each chunk of the body from
69
96
  # the server. The block must return true to continue, or false to abort streaming.
70
97
  # @return [Sawyer::Resource]
71
- def get(url, options = {}, &block)
72
- request :get, url, nil, parse_query_and_convenience_headers(options), &block
98
+ def get(url, options = {}, encoded=false, &block)
99
+ request :get, url, nil, parse_query_and_convenience_headers(options), encoded, &block
73
100
  end
74
101
 
75
102
  # Make a HTTP POST request
@@ -77,11 +104,12 @@ module LookerSDK
77
104
  # @param url [String] The path, relative to {#api_endpoint}
78
105
  # @param data [String|Array|Hash] Body and optionally header params for request
79
106
  # @param options [Hash] Optional header params for request
107
+ # @param encoded [Boolean] true: url already encoded, false: url needs encoding
80
108
  # @param &block [Block] Block to be called with |response, chunk| for each chunk of the body from
81
109
  # the server. The block must return true to continue, or false to abort streaming.
82
110
  # @return [Sawyer::Resource]
83
- def post(url, data = {}, options = {}, &block)
84
- request :post, url, data, parse_query_and_convenience_headers(options), &block
111
+ def post(url, data = {}, options = {}, encoded=false, &block)
112
+ request :post, url, data, parse_query_and_convenience_headers(options), encoded, &block
85
113
  end
86
114
 
87
115
  # Make a HTTP PUT request
@@ -89,11 +117,12 @@ module LookerSDK
89
117
  # @param url [String] The path, relative to {#api_endpoint}
90
118
  # @param data [String|Array|Hash] Body and optionally header params for request
91
119
  # @param options [Hash] Optional header params for request
120
+ # @param encoded [Boolean] true: url already encoded, false: url needs encoding
92
121
  # @param &block [Block] Block to be called with |response, chunk| for each chunk of the body from
93
122
  # the server. The block must return true to continue, or false to abort streaming.
94
123
  # @return [Sawyer::Resource]
95
- def put(url, data = {}, options = {}, &block)
96
- request :put, url, data, parse_query_and_convenience_headers(options), &block
124
+ def put(url, data = {}, options = {}, encoded=false, &block)
125
+ request :put, url, data, parse_query_and_convenience_headers(options), encoded, &block
97
126
  end
98
127
 
99
128
  # Make a HTTP PATCH request
@@ -101,29 +130,32 @@ module LookerSDK
101
130
  # @param url [String] The path, relative to {#api_endpoint}
102
131
  # @param data [String|Array|Hash] Body and optionally header params for request
103
132
  # @param options [Hash] Optional header params for request
133
+ # @param encoded [Boolean] true: url already encoded, false: url needs encoding
104
134
  # @param &block [Block] Block to be called with |response, chunk| for each chunk of the body from
105
135
  # the server. The block must return true to continue, or false to abort streaming.
106
136
  # @return [Sawyer::Resource]
107
- def patch(url, data = {}, options = {}, &block)
108
- request :patch, url, data, parse_query_and_convenience_headers(options), &block
137
+ def patch(url, data = {}, options = {}, encoded=false, &block)
138
+ request :patch, url, data, parse_query_and_convenience_headers(options), encoded, &block
109
139
  end
110
140
 
111
141
  # Make a HTTP DELETE request
112
142
  #
113
143
  # @param url [String] The path, relative to {#api_endpoint}
114
144
  # @param options [Hash] Query and header params for request
145
+ # @param encoded [Boolean] true: url already encoded, false: url needs encoding
115
146
  # @return [Sawyer::Resource]
116
- def delete(url, options = {}, &block)
117
- request :delete, url, nil, parse_query_and_convenience_headers(options)
147
+ def delete(url, options = {}, encoded=false, &block)
148
+ request :delete, url, nil, parse_query_and_convenience_headers(options), encoded, &block
118
149
  end
119
150
 
120
151
  # Make a HTTP HEAD request
121
152
  #
122
153
  # @param url [String] The path, relative to {#api_endpoint}
123
154
  # @param options [Hash] Query and header params for request
155
+ # @param encoded [Boolean] true: url already encoded, false: url needs encoding
124
156
  # @return [Sawyer::Resource]
125
- def head(url, options = {}, &block)
126
- request :head, url, nil, parse_query_and_convenience_headers(options)
157
+ def head(url, options = {}, encoded=false, &block)
158
+ request :head, url, nil, parse_query_and_convenience_headers(options), encoded
127
159
  end
128
160
 
129
161
  # Make one or more HTTP GET requests, optionally fetching
@@ -168,7 +200,7 @@ module LookerSDK
168
200
  Sawyer::Agent.new(api_endpoint, options) do |http|
169
201
  http.headers[:accept] = default_media_type
170
202
  http.headers[:user_agent] = user_agent
171
- http.authorization('token', @access_token) if token_authenticated?
203
+ http.headers[:authorization] = "token #{@access_token}" if token_authenticated?
172
204
  end
173
205
  end
174
206
 
@@ -272,12 +304,16 @@ module LookerSDK
272
304
  @agent = nil
273
305
  end
274
306
 
275
- def request(method, path, data, options, &block)
307
+ def request(method, path, data, options, encoded, &block)
276
308
  ensure_logged_in
277
309
  begin
310
+ path = path.to_s
311
+ if !encoded
312
+ path = URI::Parser.new.escape(path)
313
+ end
278
314
  @last_response = @last_error = nil
279
315
  return stream_request(method, path, data, options, &block) if block_given?
280
- @last_response = response = agent.call(method, URI::Parser.new.escape(path.to_s), data, options)
316
+ @last_response = response = agent.call(method, path, data, options)
281
317
  @raw_responses ? response : response.data
282
318
  rescue StandardError => e
283
319
  @last_error = e
@@ -1,3 +1,27 @@
1
+ ############################################################################################
2
+ # The MIT License (MIT)
3
+ #
4
+ # Copyright (c) 2018 Looker Data Sciences, Inc.
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
+
1
25
  module LookerSDK
2
26
 
3
27
  # Configuration options for {Client}, defaulting to values
@@ -42,7 +66,8 @@ module LookerSDK
42
66
  attr_accessor :access_token, :auto_paginate, :client_id,
43
67
  :client_secret, :default_media_type, :connection_options,
44
68
  :middleware, :netrc, :netrc_file,
45
- :per_page, :proxy, :user_agent, :faraday, :swagger, :shared_swagger, :raw_responses
69
+ :per_page, :proxy, :user_agent, :faraday, :swagger, :shared_swagger, :raw_responses,
70
+ :lazy_swagger
46
71
  attr_writer :web_endpoint, :api_endpoint
47
72
 
48
73
  class << self
@@ -68,7 +93,8 @@ module LookerSDK
68
93
  :shared_swagger,
69
94
  :swagger,
70
95
  :raw_responses,
71
- :web_endpoint
96
+ :web_endpoint,
97
+ :lazy_swagger,
72
98
  ]
73
99
  end
74
100
  end
@@ -1,3 +1,27 @@
1
+ ############################################################################################
2
+ # The MIT License (MIT)
3
+ #
4
+ # Copyright (c) 2018 Looker Data Sciences, Inc.
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
+
1
25
  require 'looker-sdk/response/raise_error'
2
26
  require 'looker-sdk/version'
3
27
 
@@ -101,6 +125,12 @@ module LookerSDK
101
125
  false
102
126
  end
103
127
 
128
+ # Default behavior for loading swagger during initialization or at first call
129
+ # @return [Boolean]
130
+ def lazy_swagger
131
+ false
132
+ end
133
+
104
134
  def raw_responses
105
135
  false
106
136
  end
@@ -1,3 +1,27 @@
1
+ ############################################################################################
2
+ # The MIT License (MIT)
3
+ #
4
+ # Copyright (c) 2018 Looker Data Sciences, Inc.
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
+
1
25
  module LookerSDK
2
26
  class Error < StandardError
3
27
 
@@ -21,6 +45,7 @@ module LookerSDK
21
45
  when 409 then LookerSDK::Conflict
22
46
  when 415 then LookerSDK::UnsupportedMediaType
23
47
  when 422 then LookerSDK::UnprocessableEntity
48
+ when 429 then LookerSDK::RateLimitExceeded
24
49
  when 400..499 then LookerSDK::ClientError
25
50
  when 500 then LookerSDK::InternalServerError
26
51
  when 501 then LookerSDK::NotImplemented
@@ -211,6 +236,9 @@ module LookerSDK
211
236
  # Raised when Looker returns a 422 HTTP status code
212
237
  class UnprocessableEntity < ClientError; end
213
238
 
239
+ # Raised when Looker returns a 429 HTTP status code
240
+ class RateLimitExceeded < ClientError; end
241
+
214
242
  # Raised on errors in the 500-599 range
215
243
  class ServerError < Error; end
216
244
 
@@ -1,3 +1,27 @@
1
+ ############################################################################################
2
+ # The MIT License (MIT)
3
+ #
4
+ # Copyright (c) 2018 Looker Data Sciences, Inc.
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
+
1
25
  module LookerSDK
2
26
 
3
27
  # Class for API Rate Limit info
@@ -1,3 +1,27 @@
1
+ ############################################################################################
2
+ # The MIT License (MIT)
3
+ #
4
+ # Copyright (c) 2018 Looker Data Sciences, Inc.
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
+
1
25
  require 'faraday'
2
26
  require 'looker-sdk/error'
3
27
 
@@ -6,9 +30,7 @@ module LookerSDK
6
30
  module Response
7
31
 
8
32
  # HTTP status codes returned by the API
9
- class RaiseError < Faraday::Response::Middleware
10
-
11
- private
33
+ class RaiseError < Faraday::Middleware
12
34
 
13
35
  def on_complete(response)
14
36
  if error = LookerSDK::Error.from_response(response)
@@ -1,3 +1,27 @@
1
+ ############################################################################################
2
+ # The MIT License (MIT)
3
+ #
4
+ # Copyright (c) 2018 Looker Data Sciences, Inc.
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
+
1
25
  # Make Sawyer decode the body lazily.
2
26
  # This is a temp monkey-patch until sawyer has: https://github.com/lostisland/sawyer/pull/31
3
27
  # At that point we can remove this and update our dependency to the new Sawyer release version.
@@ -30,4 +54,4 @@ module Sawyer
30
54
  end
31
55
 
32
56
  end
33
- end
57
+ end
@@ -1,7 +1,31 @@
1
+ ############################################################################################
2
+ # The MIT License (MIT)
3
+ #
4
+ # Copyright (c) 2018 Looker Data Sciences, Inc.
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
+
1
25
  module LookerSDK
2
26
 
3
27
  # Current version
4
28
  # @return [String]
5
- VERSION = "0.0.6"
29
+ VERSION = "0.1.2"
6
30
 
7
31
  end
data/lib/looker-sdk.rb CHANGED
@@ -1,3 +1,53 @@
1
+ ############################################################################################
2
+ # The MIT License (MIT)
3
+ #
4
+ # Copyright (c) 2018 Looker Data Sciences, Inc.
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 'faraday'
26
+ # The Faraday autoload scheme is supposed to work to load other dependencies on demand.
27
+ # It does work, but there are race condition problems upon first load of a given file
28
+ # that have caused intermittent failures in our ruby and integration tests - and could bite in production.
29
+ # The simple/safe solution is to just pre-require these parts that are actually used
30
+ # by the looker-sdk to prevent a race condition later.
31
+ # See https://github.com/lostisland/faraday/issues/181
32
+ # and https://bugs.ruby-lang.org/issues/921
33
+ require 'faraday/autoload'
34
+ require 'faraday/adapter'
35
+ require 'faraday/adapter/rack'
36
+ require 'faraday/adapter/net_http'
37
+ require 'faraday/connection'
38
+ require 'faraday/error'
39
+ require 'faraday/middleware'
40
+ require 'faraday/options'
41
+ require 'faraday/parameters'
42
+ require 'faraday/rack_builder'
43
+ require 'faraday/request'
44
+ require 'faraday/request/authorization'
45
+ require 'faraday/response'
46
+ require 'faraday/utils'
47
+
48
+ #require 'rack'
49
+ #require 'rack/mock_response'
50
+
1
51
  require 'looker-sdk/client'
2
52
  require 'looker-sdk/default'
3
53
 
data/looker-sdk.gemspec CHANGED
@@ -7,15 +7,15 @@ Gem::Specification.new do |s|
7
7
  s.version = LookerSDK::VERSION
8
8
  s.date = "#{Time.now.strftime('%F')}"
9
9
  s.authors = ['Looker']
10
- s.email = 'opensource+sdkruby@looker.com'
11
- s.homepage = 'https://github.com/looker/looker-sdk-ruby'
10
+ s.email = 'drstrangelove@google.com'
11
+ s.homepage = 'https://github.com/looker-open-source/looker-sdk-ruby'
12
12
  s.summary = %q{Looker Ruby SDK}
13
13
  s.description = 'Use this SDK to access the Looker API. The Looker API provides functions to perform administrative '+
14
14
  'tasks such as provisioning users, configuring database connections, and so on. It also enables you to leverage '+
15
15
  'the Looker data analytics engine to fetch data or render visualizations defined in your Looker data models. '+
16
16
  'For more information, see https://looker.com.'
17
17
  s.license = 'MIT'
18
- s.required_ruby_version = '>= 1.9.3'
18
+ s.required_ruby_version = '>= 2.5'
19
19
  s.requirements = 'Looker version 4.0 or later' # informational
20
20
 
21
21
  s.files = `git ls-files`.split("\n")
@@ -24,5 +24,5 @@ Gem::Specification.new do |s|
24
24
  s.require_paths = %w(lib)
25
25
  s.add_dependency 'jruby-openssl' if s.platform == :jruby
26
26
  s.add_dependency 'sawyer', '~> 0.8'
27
- s.add_dependency 'faraday', ['>= 0.9.0', '< 1.0']
27
+ s.add_dependency 'faraday', ['>= 1.2', '< 2.0']
28
28
  end
data/readme.md CHANGED
@@ -1,4 +1,5 @@
1
- # [Looker](http://looker.com/) SDK for Ruby [![Build Status](https://travis-ci.org/looker/looker-sdk-ruby.svg)](https://travis-ci.org/looker/looker-sdk-ruby)
1
+ [![Ruby-CI](https://github.com/looker-open-source/looker-sdk-ruby/actions/workflows/ruby-ci.yml/badge.svg?branch=main)](https://github.com/looker-open-source/looker-sdk-ruby/actions/workflows/ruby-ci.yml)
2
+ # [Looker](http://looker.com/) SDK for Ruby
2
3
  ### Overview
3
4
  This SDK supports secure/authenticated access to the Looker RESTful API. The SDK binds dynamically to the Looker API and builds mappings for the sets of API methods that the Looker instance exposes. This allows for writing straightforward Ruby scripts to interact with the Looker API. And, it allows the SDK to provide access to new Looker API features in each Looker release without requiring an update to the SDK each time.
4
5
 
@@ -14,7 +15,7 @@ When trying to access a resource with the API that the current user is not allow
14
15
 
15
16
  ### Installation
16
17
  ```bash
17
- $ git clone git@github.com:looker/looker-sdk-ruby.git looker-sdk
18
+ $ git clone git@github.com:looker-open-source/looker-sdk-ruby.git looker-sdk
18
19
  $ cd looker-sdk
19
20
  $ gem install bundle
20
21
  $ bundle install
@@ -23,10 +24,13 @@ $ rake install
23
24
 
24
25
  ### Development
25
26
 
27
+ Rename test/fixtures/.netrc.template to test/fixtures/.netrc and add API3
28
+ credentials for tests to pass.
29
+ Comment out coverage configuration in test/helper.rb for debugging.
26
30
  ```bash
27
31
  $ bundle install
28
32
  $ rake test # run the test suite
29
- $ rake test:all # run the test suite on all supported Rubies
33
+ $ make install test # run the test suite on all supported Rubies
30
34
  ```
31
35
 
32
36
  ### Basic Usage
@@ -39,7 +43,7 @@ require 'looker-sdk'
39
43
  sdk = LookerSDK::Client.new(
40
44
  :client_id => "4CN7jzm7yrkcy2MC4CCG",
41
45
  :client_secret => "Js3rZZ7vHfbc2hBynSj7zqKh",
42
- :api_endpoint => "https://mygreatcompany.looker.com:19999/api/3.0"
46
+ :api_endpoint => "https://mygreatcompany.looker.com:19999/api/4.0"
43
47
  )
44
48
 
45
49
  # If you don't want to provide explicit credentials: (trust me you don't)
@@ -53,7 +57,7 @@ sdk = LookerSDK::Client.new(
53
57
  sdk = LookerSDK::Client.new(
54
58
  :netrc => true,
55
59
  :netrc_file => "~/.net_rc",
56
- :api_endpoint => "https://mygreatcompany.looker.com:19999/api/3.0",
60
+ :api_endpoint => "https://mygreatcompany.looker.com:19999/api/4.0",
57
61
 
58
62
  # Set longer timeout to allow for long running queries. The default is 60 seconds and can be problematic.
59
63
  :connection_options => {:request => {:timeout => 60 * 60, :open_timeout => 30}},
data/shell/Gemfile CHANGED
@@ -2,5 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  gem 'pry', '~> 0.10.1'
4
4
  gem 'netrc', '~> 0.7.7'
5
- # gem 'looker-sdk', :git => 'git@github.com:looker/looker-sdk-ruby.git'
5
+ # gem 'looker-sdk', :git => 'git@github.com:looker-open-source/looker-sdk-ruby.git'
6
6
  gem 'looker-sdk', :path => '../'
data/shell/shell.rb CHANGED
@@ -1,3 +1,27 @@
1
+ ############################################################################################
2
+ # The MIT License (MIT)
3
+ #
4
+ # Copyright (c) 2018 Looker Data Sciences, Inc.
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
+
1
25
  require 'rubygems'
2
26
  require 'bundler/setup'
3
27
 
File without changes
data/test/helper.rb CHANGED
@@ -1,3 +1,27 @@
1
+ ############################################################################################
2
+ # The MIT License (MIT)
3
+ #
4
+ # Copyright (c) 2018 Looker Data Sciences, Inc.
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
+
1
25
  require 'simplecov'
2
26
  SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
3
27
  SimpleCov::Formatter::HTMLFormatter
@@ -28,19 +52,45 @@ def fix_netrc_permissions(path)
28
52
  File.chmod(0600, path) unless s.mode.to_s(8)[3..5] == "0600"
29
53
  end
30
54
 
31
- fix_netrc_permissions(File.join(fixture_path, '.netrc'))
55
+ begin
56
+ fix_netrc_permissions(File.join(fixture_path, '.netrc'))
57
+ rescue => e
58
+ puts e
59
+ end
32
60
 
33
61
  def setup_sdk
34
62
  LookerSDK.reset!
63
+
64
+ base_url = ENV['LOOKERSDK_BASE_URL'] || 'https://localhost:20000'
65
+ verify_ssl = case ENV['LOOKERSDK_VERIFY_SSL']
66
+ when /false/i
67
+ false
68
+ when /f/i
69
+ false
70
+ when '0'
71
+ false
72
+ else
73
+ true
74
+ end
75
+ api_version = ENV['LOOKERSDK_API_VERSION'] || '4.0'
76
+ client_id = ENV['LOOKERSDK_CLIENT_ID']
77
+ client_secret = ENV['LOOKERSDK_CLIENT_SECRET']
78
+
35
79
  LookerSDK.configure do |c|
36
- c.connection_options = {:ssl => {:verify => false}}
37
- c.netrc = true
38
- c.netrc_file = File.join(fixture_path, '.netrc')
80
+ c.lazy_swagger = true
81
+ c.connection_options = {:ssl => {:verify => false}} unless verify_ssl
82
+ if (client_id && client_secret) then
83
+ c.client_id = client_id
84
+ c.client_secret = client_secret
85
+ c.api_endpoint = "#{base_url}/api/#{api_version}"
86
+ else
87
+ c.netrc = true
88
+ c.netrc_file = File.join(fixture_path, '.netrc')
89
+ end
39
90
  end
40
91
  end
41
92
 
42
93
  def teardown_sdk
94
+ setup_sdk # put back initial config
43
95
  LookerSDK.logout
44
96
  end
45
-
46
-