looker-sdk 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.travis.yml +0 -1
- data/LICENSE.md +33 -0
- data/Rakefile +25 -1
- data/examples/add_delete_users.rb +24 -0
- data/examples/change_credentials_email_address_for_users.rb +24 -0
- data/examples/convert_look_to_lookless_tile.rb +71 -0
- data/examples/create_credentials_email_for_users.rb +24 -0
- data/examples/delete_all_user_sessions.rb +24 -0
- data/examples/delete_credentials_google_for_users.rb +24 -0
- data/examples/generate_password_reset_tokens_for_users.rb +24 -0
- data/examples/ldap_roles_test.rb +24 -0
- data/examples/me.rb +24 -0
- data/examples/refresh_user_notification_addresses.rb +24 -0
- data/examples/roles_and_users_with_permission.rb +24 -0
- data/examples/sdk_setup.rb +24 -0
- data/examples/streaming_downloads.rb +24 -0
- data/examples/users_with_credentials_email.rb +24 -0
- data/examples/users_with_credentials_embed.rb +24 -0
- data/examples/users_with_credentials_google.rb +23 -1
- data/examples/users_with_credentials_google_without_credentials_email.rb +24 -0
- data/lib/looker-sdk.rb +51 -0
- data/lib/looker-sdk/authentication.rb +27 -2
- data/lib/looker-sdk/client.rb +24 -0
- data/lib/looker-sdk/client/dynamic.rb +45 -2
- data/lib/looker-sdk/configurable.rb +24 -0
- data/lib/looker-sdk/default.rb +24 -0
- data/lib/looker-sdk/error.rb +28 -0
- data/lib/looker-sdk/rate_limit.rb +24 -0
- data/lib/looker-sdk/response/raise_error.rb +24 -0
- data/lib/looker-sdk/sawyer_patch.rb +25 -1
- data/lib/looker-sdk/version.rb +25 -1
- data/looker-sdk.gemspec +1 -1
- data/shell/shell.rb +24 -0
- data/test/helper.rb +24 -0
- data/test/looker/test_client.rb +24 -0
- data/test/looker/test_dynamic_client.rb +56 -0
- data/test/looker/test_dynamic_client_agent.rb +24 -0
- metadata +6 -5
- data/LICENSE +0 -21
data/examples/sdk_setup.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
|
|
@@ -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 './sdk_setup'
|
2
26
|
|
3
27
|
# This snippet shows how to download sdk responses using http streaming.
|
@@ -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 './sdk_setup'
|
2
26
|
|
3
27
|
users = sdk.all_users(:fields => 'id, is_disabled, credentials_email').
|
@@ -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 './sdk_setup'
|
2
26
|
|
3
27
|
users = sdk.all_users(fields:'id, is_disabled, display_name, credentials_embed').map do |u|
|
@@ -1,4 +1,26 @@
|
|
1
|
-
|
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
|
+
############################################################################################
|
2
24
|
|
3
25
|
require './sdk_setup'
|
4
26
|
|
@@ -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 './sdk_setup'
|
2
26
|
|
3
27
|
users = sdk.all_users(:fields => 'id, is_disabled, credentials_email, credentials_google').
|
data/lib/looker-sdk.rb
CHANGED
@@ -1,3 +1,54 @@
|
|
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/upload_io'
|
47
|
+
require 'faraday/utils'
|
48
|
+
|
49
|
+
#require 'rack'
|
50
|
+
#require 'rack/mock_response'
|
51
|
+
|
1
52
|
require 'looker-sdk/client'
|
2
53
|
require 'looker-sdk/default'
|
3
54
|
|
@@ -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
|
# Authentication methods for {LookerSDK::Client}
|
@@ -27,7 +51,8 @@ module LookerSDK
|
|
27
51
|
|
28
52
|
set_access_token_from_params(nil)
|
29
53
|
without_authentication do
|
30
|
-
|
54
|
+
encoded_auth = Faraday::Utils.build_query application_credentials
|
55
|
+
post("#{URI.parse(api_endpoint).path}/login", encoded_auth, header: {:'Content-Type' => 'application/x-www-form-urlencoded'})
|
31
56
|
raise "login failure #{last_response.status}" unless last_response.status == 200
|
32
57
|
set_access_token_from_params(last_response.data)
|
33
58
|
end
|
@@ -46,7 +71,7 @@ module LookerSDK
|
|
46
71
|
|
47
72
|
def logout
|
48
73
|
without_authentication do
|
49
|
-
result = !!@access_token && ((delete(
|
74
|
+
result = !!@access_token && ((delete("#{URI.parse(api_endpoint).path}/logout") ; delete_succeeded?) rescue false)
|
50
75
|
set_access_token_from_params(nil)
|
51
76
|
result
|
52
77
|
end
|
data/lib/looker-sdk/client.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 'sawyer'
|
2
26
|
require 'ostruct'
|
3
27
|
require 'looker-sdk/sawyer_patch'
|
@@ -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 Client
|
3
27
|
|
@@ -25,8 +49,27 @@ module LookerSDK
|
|
25
49
|
def load_swagger
|
26
50
|
# We only need the swagger if we are going to be building our own 'operations' hash
|
27
51
|
return if shared_swagger && @@sharable_operations[api_endpoint]
|
28
|
-
#
|
29
|
-
@swagger ||= without_authentication {try_load_swagger}
|
52
|
+
# First, try to load swagger.json w/o authenticating
|
53
|
+
@swagger ||= without_authentication { try_load_swagger }
|
54
|
+
|
55
|
+
unless @swagger
|
56
|
+
# capture the bits we may need later, avoiding potential buffer reuse in last_response between requests
|
57
|
+
response_wo_auth_status = last_response&.status
|
58
|
+
response_wo_auth_data = last_response&.data
|
59
|
+
|
60
|
+
# try again, this time with authentication
|
61
|
+
@swagger = try_load_swagger
|
62
|
+
end
|
63
|
+
|
64
|
+
# in unit tests, @swagger may be nil and last_response nil because no HTTP request was made
|
65
|
+
if @swagger.nil? && (response_wo_auth_status || last_response)
|
66
|
+
msg = "Load of swagger.json failed. "
|
67
|
+
msg << "Without authentication HTTP response status: (#{response_wo_auth_status}) data: #{response_wo_auth_data}. " if response_wo_auth_status
|
68
|
+
msg << "WITH authentication HTTP response status: (#{last_response.status}) data: #{last_response.data}" if last_response
|
69
|
+
looker_warn(msg)
|
70
|
+
end
|
71
|
+
|
72
|
+
@swagger
|
30
73
|
end
|
31
74
|
|
32
75
|
def operations
|
@@ -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
|
data/lib/looker-sdk/default.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 'looker-sdk/response/raise_error'
|
2
26
|
require 'looker-sdk/version'
|
3
27
|
|
data/lib/looker-sdk/error.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
|
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
|
|