looker-sdk 0.0.5 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +3 -0
  3. data/.travis.yml +1 -2
  4. data/CODE_OF_CONDUCT.md +46 -0
  5. data/Gemfile +1 -1
  6. data/LICENSE.md +33 -0
  7. data/Makefile +81 -0
  8. data/Rakefile +24 -27
  9. data/authentication.md +3 -3
  10. data/examples/add_delete_users.rb +24 -0
  11. data/examples/change_credentials_email_address_for_users.rb +24 -0
  12. data/examples/convert_look_to_lookless_tile.rb +71 -0
  13. data/examples/create_credentials_email_for_users.rb +24 -0
  14. data/examples/delete_all_user_sessions.rb +24 -0
  15. data/examples/delete_credentials_google_for_users.rb +24 -0
  16. data/examples/generate_password_reset_tokens_for_users.rb +24 -0
  17. data/examples/ldap_roles_test.rb +24 -0
  18. data/examples/me.rb +24 -0
  19. data/examples/refresh_user_notification_addresses.rb +24 -0
  20. data/examples/roles_and_users_with_permission.rb +24 -0
  21. data/examples/sdk_setup.rb +24 -0
  22. data/examples/streaming_downloads.rb +24 -0
  23. data/examples/users_with_credentials_email.rb +24 -0
  24. data/examples/users_with_credentials_embed.rb +33 -0
  25. data/examples/users_with_credentials_google.rb +23 -1
  26. data/examples/users_with_credentials_google_without_credentials_email.rb +24 -0
  27. data/lib/looker-sdk/authentication.rb +27 -2
  28. data/lib/looker-sdk/client/dynamic.rb +61 -11
  29. data/lib/looker-sdk/client.rb +86 -21
  30. data/lib/looker-sdk/configurable.rb +28 -2
  31. data/lib/looker-sdk/default.rb +30 -0
  32. data/lib/looker-sdk/error.rb +28 -0
  33. data/lib/looker-sdk/rate_limit.rb +24 -0
  34. data/lib/looker-sdk/response/raise_error.rb +25 -3
  35. data/lib/looker-sdk/sawyer_patch.rb +25 -1
  36. data/lib/looker-sdk/version.rb +25 -1
  37. data/lib/looker-sdk.rb +50 -0
  38. data/looker-sdk.gemspec +4 -3
  39. data/readme.md +12 -9
  40. data/shell/.netrc +3 -1
  41. data/shell/shell.rb +27 -2
  42. data/test/fixtures/{.netrc → .netrc.template} +0 -0
  43. data/test/helper.rb +26 -2
  44. data/test/looker/swagger.json +74 -3
  45. data/test/looker/test_client.rb +102 -6
  46. data/test/looker/test_dynamic_client.rb +101 -4
  47. data/test/looker/test_dynamic_client_agent.rb +24 -0
  48. metadata +50 -22
  49. 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
  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.5"
29
+ VERSION = "0.1.1"
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,7 +7,7 @@ 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 = 'support@looker.com'
10
+ s.email = 'opensource+sdkruby@looker.com'
11
11
  s.homepage = 'https://github.com/looker/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 '+
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
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")
@@ -23,5 +23,6 @@ Gem::Specification.new do |s|
23
23
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
24
24
  s.require_paths = %w(lib)
25
25
  s.add_dependency 'jruby-openssl' if s.platform == :jruby
26
- s.add_dependency 'sawyer', '0.6'
26
+ s.add_dependency 'sawyer', '~> 0.8'
27
+ s.add_dependency 'faraday', ['>= 1.2', '< 2.0']
27
28
  end
data/readme.md CHANGED
@@ -4,7 +4,7 @@ This SDK supports secure/authenticated access to the Looker RESTful API. The SDK
4
4
 
5
5
  The Looker API uses OAuth2 authentication. 'API3' keys can be generated by Looker admins for any Looker user account from the Looker admin panel. These 'keys' each consist of a client_id/client_secret pair. These keys should be carefully protected as one would with any critical password. When using the SDK, one creates a client object that is initialized with a client_id/client_secret pair and the base URL of the Looker instance's API endpoint. The SDK transparently logs in to the API with that key pair to generate a short-term auth token that it sends to the API with each subsequent call to provide authentication for that call.
6
6
 
7
- All calls to the Looker API must be done over a TSL/SSL connection. Requests and responses are then encrypted at that transport layer. It is highly recommended that Looker instance https endpoints use certificates that are properly signed by a trusted certificate authority. The SDK will, by default, validate server certificates. It is possible to disable that validation when creating an SDK client object if necessary. But, that configuration is discouraged.
7
+ All calls to the Looker API must be done over a TLS/SSL connection. Requests and responses are then encrypted at that transport layer. It is highly recommended that Looker instance https endpoints use certificates that are properly signed by a trusted certificate authority. The SDK will, by default, validate server certificates. It is possible to disable that validation when creating an SDK client object if necessary. But, that configuration is discouraged.
8
8
 
9
9
  Looker instances expose API documentation at: https://mygreatcompany.looker.com:19999/api-docs/index.html (the exact URL can be set in the Looker admin panel). By default, the documentation page requires a client_id/client_secret pair to load the detailed API information. That page also supports "Try it out!" links so that you can experiment with the API right from the documentation. The documentation is intended to show how to call the API endpoints via either raw RESTful https requests or using the SDK.
10
10
 
@@ -23,10 +23,13 @@ $ rake install
23
23
 
24
24
  ### Development
25
25
 
26
+ Rename test/fixtures/.netrc.template to test/fixtures/.netrc and add API3
27
+ credentials for tests to pass.
28
+ Comment out coverage configuration in test/helper.rb for debugging.
26
29
  ```bash
27
30
  $ bundle install
28
31
  $ rake test # run the test suite
29
- $ rake test:all # run the test suite on all supported Rubies
32
+ $ make install test # run the test suite on all supported Rubies
30
33
  ```
31
34
 
32
35
  ### Basic Usage
@@ -39,7 +42,7 @@ require 'looker-sdk'
39
42
  sdk = LookerSDK::Client.new(
40
43
  :client_id => "4CN7jzm7yrkcy2MC4CCG",
41
44
  :client_secret => "Js3rZZ7vHfbc2hBynSj7zqKh",
42
- :api_endpoint => "https://mygreatcompany.looker.com:19999/api/3.0"
45
+ :api_endpoint => "https://mygreatcompany.looker.com:19999/api/4.0"
43
46
  )
44
47
 
45
48
  # If you don't want to provide explicit credentials: (trust me you don't)
@@ -53,16 +56,16 @@ sdk = LookerSDK::Client.new(
53
56
  sdk = LookerSDK::Client.new(
54
57
  :netrc => true,
55
58
  :netrc_file => "~/.net_rc",
56
- :api_endpoint => "https://mygreatcompany.looker.com:19999/api/3.0",
59
+ :api_endpoint => "https://mygreatcompany.looker.com:19999/api/4.0",
57
60
 
58
- # Disable cert verification if the looker has a self-signed cert.
61
+ # Set longer timeout to allow for long running queries. The default is 60 seconds and can be problematic.
62
+ :connection_options => {:request => {:timeout => 60 * 60, :open_timeout => 30}},
63
+
64
+ # Alternately, disable cert verification if the looker has a self-signed cert.
59
65
  # Avoid this if using real certificates; verification of the server cert is a very good thing for production.
60
66
  # :connection_options => {:ssl => {:verify => false}},
61
67
 
62
- # Set longer timeout to allow for long running queries.
63
- # :connection_options => {:request => {:timeout => 60 * 60, :open_timeout => 30}},
64
-
65
- # Support self-signed cert *and* set longer timeout to allow for long running queries.
68
+ # Alternately, support self-signed cert *and* set longer timeout to allow for long running queries.
66
69
  # :connection_options => {:ssl => {:verify => false}, :request => {:timeout => 60 * 60, :open_timeout => 30}},
67
70
  )
68
71
 
data/shell/.netrc CHANGED
@@ -1 +1,3 @@
1
- machine self-signed.looker.com login CGc9B7v7J48dQSJvQjp9 password nNVS9cSS3xNpSC9JdsBv7BdF
1
+ machine localhost
2
+ login xyYBxzSPYYP29wQJ3Q5k
3
+ password VY5sj6z5qjxZsvdvf8yNvKcQ
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
 
@@ -16,7 +40,7 @@ def sdk
16
40
  # Support self-signed cert *and* set longer timeout to allow for long running queries.
17
41
  :connection_options => {:ssl => {:verify => false}, :request => {:timeout => 60 * 60, :open_timeout => 30}},
18
42
 
19
- :api_endpoint => "https://self-signed.looker.com:19999/api/3.0",
43
+ :api_endpoint => "https://localhost:19999/api/3.0",
20
44
 
21
45
  # Customize to use your specific looker instance
22
46
  # :connection_options => {:ssl => {:verify => true}},
@@ -26,7 +50,8 @@ end
26
50
 
27
51
  begin
28
52
  puts "Connecting to Looker at '#{sdk.api_endpoint}'"
29
- puts (code = sdk.alive) == 200 ? "Looker is alive!" : "Sad Looker: #{code}"
53
+ puts sdk.alive? ? "Looker is alive!" : "Sad Looker, can't connect:\n #{sdk.last_error}"
54
+ puts sdk.authenticated? ? "Authenticated!" : "Sad Looker, can't authenticate:\n #{sdk.last_error}"
30
55
 
31
56
  binding.pry self
32
57
  rescue Exception => e
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
@@ -33,6 +57,7 @@ fix_netrc_permissions(File.join(fixture_path, '.netrc'))
33
57
  def setup_sdk
34
58
  LookerSDK.reset!
35
59
  LookerSDK.configure do |c|
60
+ c.lazy_swagger = true
36
61
  c.connection_options = {:ssl => {:verify => false}}
37
62
  c.netrc = true
38
63
  c.netrc_file = File.join(fixture_path, '.netrc')
@@ -40,7 +65,6 @@ def setup_sdk
40
65
  end
41
66
 
42
67
  def teardown_sdk
68
+ setup_sdk # put back initial config
43
69
  LookerSDK.logout
44
70
  end
45
-
46
-
@@ -3,13 +3,13 @@
3
3
  "info": {
4
4
  "version": "3.0.0",
5
5
  "title": "Looker API",
6
- "description": "This document describes the Looker API.",
6
+ "description": "This document is a representative sample (subset) of the Looker API that should only be used to unit test the Looker ruby sdk. To get the current, actual Looker API metadata visit /api/3.0/swagger.json on your Looker instance.",
7
7
  "contact": {
8
- "name": "Looker Team <support@looker.com>"
8
+ "name": "Looker Team <https://help.looker.com>"
9
9
  },
10
10
  "license": {
11
11
  "name": "EULA",
12
- "url": "https://localhost:9999/eula"
12
+ "url": "https://learn.looker.com/eula"
13
13
  }
14
14
  },
15
15
  "basePath": "/api/3.0",
@@ -1253,6 +1253,77 @@
1253
1253
  }
1254
1254
  }
1255
1255
  },
1256
+ "/users/{user_id}/attribute_values": {
1257
+ "get": {
1258
+ "tags": [
1259
+ "User"
1260
+ ],
1261
+ "operationId": "user_attribute_user_values",
1262
+ "summary": "Get User Attribute Values",
1263
+ "description": "### Get user attribute values for a given user.\n\nReturns the values of specified user attributes (or all user attributes) for a certain user.\n\nA value for each user attribute is searched for in the following locations, in this order:\n1. in the user's account information\n1. in groups that the user is a member of\n1. the default value of the user attribute\n\nIf more than one group has a value defined for a user attribute, the group with the lowest rank wins.\n\nThe response will only include user attributes for which values were found. Use `include_unset=true` to include\nempty records for user attributes with no value.\n\nThe value of all hidden user attributes will be blank.\n",
1264
+ "parameters": [
1265
+ {
1266
+ "name": "user_id",
1267
+ "in": "path",
1268
+ "description": "Id of user",
1269
+ "required": true,
1270
+ "type": "integer",
1271
+ "format": "int64"
1272
+ },
1273
+ {
1274
+ "name": "fields",
1275
+ "in": "query",
1276
+ "description": "Requested fields.",
1277
+ "required": false,
1278
+ "type": "string"
1279
+ },
1280
+ {
1281
+ "name": "user_attribute_ids",
1282
+ "in": "query",
1283
+ "description": "Specific user attributes to request. Omit or leave blank to request all user attributes.",
1284
+ "required": false,
1285
+ "type": "array",
1286
+ "items": {
1287
+ "type": "integer",
1288
+ "format": "int64"
1289
+ },
1290
+ "collectionFormat": "csv"
1291
+ },
1292
+ {
1293
+ "name": "all_values",
1294
+ "in": "query",
1295
+ "description": "If true, returns all values in the search path instead of just the first value found. Useful for debugging group precedence.",
1296
+ "required": false,
1297
+ "type": "boolean"
1298
+ },
1299
+ {
1300
+ "name": "include_unset",
1301
+ "in": "query",
1302
+ "description": "If true, returns an empty record for each requested attribute that has no user, group, or default value.",
1303
+ "required": false,
1304
+ "type": "boolean"
1305
+ }
1306
+ ],
1307
+ "responses": {
1308
+ "404": {
1309
+ "description": "Not Found",
1310
+ "schema": {
1311
+ "$ref": "#/definitions/Error"
1312
+ }
1313
+ },
1314
+ "200": {
1315
+ "description": "Value of user attribute.",
1316
+ "schema": {
1317
+ "type": "array",
1318
+ "items": {
1319
+ "$ref": "#/definitions/UserAttributeWithValue"
1320
+ }
1321
+ }
1322
+ }
1323
+ },
1324
+ "x-looker-status": "beta"
1325
+ }
1326
+ },
1256
1327
  "/users/{user_id}/roles": {
1257
1328
  "get": {
1258
1329
  "tags": [