looker-sdk 0.1.10 → 0.1.11

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 962fdcc584f53a5888bda532f4c35d10f7e1e9afb36132c8f5b3befa6e658e40
4
- data.tar.gz: 2aa006572f93e9da8f9c0a12a0bcdd41799561b99ccda67f22d2b791a47141ef
3
+ metadata.gz: bd7f1ae1fc17049a2495fbe59b5daa30922eeee81324c198a14bd6e39714e4d6
4
+ data.tar.gz: 000eec5248e5cdee93e02a780822460a7c7adf10ebee87c645379a97eb8e2cf3
5
5
  SHA512:
6
- metadata.gz: 2e65b9e2fe9c4a262a7240cbcd661ee43df2be13cdefd192a0c8a269bbfd9b07e8bf3fb435e05299e7443297e19a2ec9bd9a9e4a758a3243f9b2c72cbd06da5f
7
- data.tar.gz: 10c0aed18b69b6f59c919016ad26725506a4cfbc02048b112a19cf6ca99f795f9482900760559abf1a3374b6682c591ebeb0551bcec6b5230fbbf78499425727
6
+ metadata.gz: 5d11ee93d5ea36eae97c8a2fff92c5505a3b1df8c750609cef85d431ca744ca188adfe8a1d17850ada2d9ac8bdf31129daef06713f5080303327f7360d366089
7
+ data.tar.gz: af88d3c1185927d26624900e6ed9794b3091415038aeba1f92a65c8d51daff308b3cc17f297709bd644cbb28e36d34011eccac83fa3f9aa0b3197e6af713dec6
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.1.11](https://github.com/looker-open-source/looker-sdk-ruby/compare/v0.1.10...v0.1.11) (2025-01-13)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * add error handling for streaming client ([69b8064](https://github.com/looker-open-source/looker-sdk-ruby/commit/69b8064818161d273872eb658be16bb17ed6df56))
9
+ * handle all variety of http response codes. ([6d75ee2](https://github.com/looker-open-source/looker-sdk-ruby/commit/6d75ee2c30521d48b4e68b910c75ff5fe9ff22e7))
10
+ * raise TypeError on marshal_dump ([#100](https://github.com/looker-open-source/looker-sdk-ruby/issues/100)) ([9e486ff](https://github.com/looker-open-source/looker-sdk-ruby/commit/9e486ff413f1951e557a9816729007067bf8588f))
11
+ * update rexml to 3.3.9 to eliminate ReDos vulnerability ([#102](https://github.com/looker-open-source/looker-sdk-ruby/issues/102)) ([42c5cd3](https://github.com/looker-open-source/looker-sdk-ruby/commit/42c5cd349231457fd7e75e541a0a208bae625c39))
12
+
3
13
  ## [0.1.10](https://github.com/looker-open-source/looker-sdk-ruby/compare/v0.1.7...v0.1.10) (2024-10-07)
4
14
 
5
15
 
@@ -22,6 +22,8 @@
22
22
  # THE SOFTWARE.
23
23
  ############################################################################################
24
24
 
25
+ require 'ruby2_keywords'
26
+
25
27
  module LookerSDK
26
28
  class Client
27
29
 
@@ -97,12 +99,12 @@ module LookerSDK
97
99
  # Callers can explicitly 'invoke' remote methods or let 'method_missing' do the trick.
98
100
  # If nothing else, this gives clients a way to deal with potential conflicts between remote method
99
101
  # names and names of methods on client itself.
100
- def invoke(method_name, *args, &block)
102
+ ruby2_keywords def invoke(method_name, *args, &block)
101
103
  entry = find_entry(method_name) || raise(NameError, "undefined remote method '#{method_name}'")
102
104
  invoke_remote(entry, method_name, *args, &block)
103
105
  end
104
106
 
105
- def method_missing(method_name, *args, &block)
107
+ ruby2_keywords def method_missing(method_name, *args, &block)
106
108
  entry = find_entry(method_name) || (return super)
107
109
  invoke_remote(entry, method_name, *args, &block)
108
110
  end
@@ -117,7 +119,7 @@ module LookerSDK
117
119
  operations && operations[method_name.to_sym] if dynamic
118
120
  end
119
121
 
120
- def invoke_remote(entry, method_name, *args, &block)
122
+ ruby2_keywords def invoke_remote(entry, method_name, *args, &block)
121
123
  args = (args || []).dup
122
124
  route = entry[:route].to_s.dup
123
125
  params = (entry[:info][:parameters] || []).select {|param| param[:in] == 'path'}
@@ -1,7 +1,7 @@
1
1
  ############################################################################################
2
2
  # The MIT License (MIT)
3
3
  #
4
- # Copyright (c) 2022 Looker Data Sciences, Inc.
4
+ # Copyright (c) 2024 Google, LLC
5
5
  #
6
6
  # Permission is hereby granted, free of charge, to any person obtaining a copy
7
7
  # of this software and associated documentation files (the "Software"), to deal
@@ -29,6 +29,8 @@ require 'looker-sdk/configurable'
29
29
  require 'looker-sdk/authentication'
30
30
  require 'looker-sdk/rate_limit'
31
31
  require 'looker-sdk/client/dynamic'
32
+ require 'looker-sdk/error'
33
+ require 'ruby2_keywords'
32
34
 
33
35
  module LookerSDK
34
36
 
@@ -292,7 +294,7 @@ module LookerSDK
292
294
  # LOOKER_SILENT is set to true.
293
295
  #
294
296
  # @return [nil]
295
- def looker_warn(*message)
297
+ ruby2_keywords def looker_warn(*message)
296
298
  unless ENV['LOOKER_SILENT']
297
299
  warn message
298
300
  end
@@ -396,8 +398,15 @@ module LookerSDK
396
398
  http.read_timeout = connection.options.timeout rescue 60
397
399
 
398
400
  http.request(http_request) do |response|
399
- progress = Progress.new(response)
400
- if response.code == "200"
401
+ case response.code.to_i
402
+ when 400..599 then
403
+ error = LookerSDK::Error.from_response(response)
404
+ raise error
405
+ when 300..399 then
406
+ error = LookerSDK::Error.new("3xx response from streaming request")
407
+ raise error
408
+ when 200..299 then
409
+ progress = Progress.new(response)
401
410
  response.read_body do |chunk|
402
411
  next unless chunk.length > 0
403
412
  progress.add_chunk(chunk)
@@ -31,7 +31,7 @@ module LookerSDK
31
31
  module Default
32
32
 
33
33
  # Default API endpoint look TODO update this as needed
34
- API_ENDPOINT = "https://localhost:19999/api/3.0/".freeze
34
+ API_ENDPOINT = "https://localhost:19999/api/4.0/".freeze
35
35
 
36
36
  # Default User Agent header string
37
37
  USER_AGENT = "Looker Ruby Gem #{LookerSDK::VERSION}".freeze
@@ -1,7 +1,7 @@
1
1
  ############################################################################################
2
2
  # The MIT License (MIT)
3
3
  #
4
- # Copyright (c) 2022 Looker Data Sciences, Inc.
4
+ # Copyright (c) 2024 Google, LLC
5
5
  #
6
6
  # Permission is hereby granted, free of charge, to any person obtaining a copy
7
7
  # of this software and associated documentation files (the "Software"), to deal
@@ -76,6 +76,12 @@ module LookerSDK
76
76
  response_message
77
77
  end
78
78
 
79
+ # Looker SDK error objects (e.g. LookerSDK::BadRequest) raise a
80
+ # WebMock::NetConnectNotAllowedError if they are marshal dumped.
81
+ def marshal_dump
82
+ raise TypeError.new("Refusing to marshal")
83
+ end
84
+
79
85
  # Error Doc URL
80
86
  #
81
87
  # @return [String]
@@ -26,6 +26,6 @@ module LookerSDK
26
26
 
27
27
  # Current version
28
28
  # @return [String]
29
- VERSION = "0.1.10"
29
+ VERSION = "0.1.11"
30
30
 
31
31
  end
data/lib/looker-sdk.rb CHANGED
@@ -50,6 +50,7 @@ end
50
50
 
51
51
  #require 'rack'
52
52
  #require 'rack/mock_response'
53
+ require 'ruby2_keywords'
53
54
 
54
55
  require 'looker-sdk/client'
55
56
  require 'looker-sdk/default'
@@ -74,7 +75,7 @@ module LookerSDK
74
75
 
75
76
  private
76
77
 
77
- def method_missing(method_name, *args, &block)
78
+ ruby2_keywords def method_missing(method_name, *args, &block)
78
79
  return super unless client.respond_to?(method_name)
79
80
  client.send(method_name, *args, &block)
80
81
  end
@@ -0,0 +1,97 @@
1
+ ############################################################################################
2
+ # The MIT License (MIT)
3
+ #
4
+ # Copyright (c) 2024 Google LLC
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ # of this software and associated documentation files (the "Software"), to deal
8
+ # in the Software without restriction, including without limitation the rights
9
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ # copies of the Software, and to permit persons to whom the Software is
11
+ # furnished to do so, subject to the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be included in
14
+ # all copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ # THE SOFTWARE.
23
+ ############################################################################################
24
+
25
+ require_relative '../helper'
26
+
27
+ describe LookerSDK::Client do
28
+
29
+ before(:each) do
30
+ setup_sdk
31
+ end
32
+
33
+ base_url = ENV['LOOKERSDK_BASE_URL'] || 'https://localhost:19999'
34
+ verify_ssl = case ENV['LOOKERSDK_VERIFY_SSL']
35
+ when /false/i
36
+ false
37
+ when /f/i
38
+ false
39
+ when '0'
40
+ false
41
+ else
42
+ true
43
+ end
44
+ api_version = ENV['LOOKERSDK_API_VERSION'] || '4.0'
45
+ client_id = ENV['LOOKERSDK_CLIENT_ID']
46
+ client_secret = ENV['LOOKERSDK_CLIENT_SECRET']
47
+
48
+ opts = {}
49
+ if (client_id && client_secret) then
50
+ opts.merge!({
51
+ :client_id => client_id,
52
+ :client_secret => client_secret,
53
+ :api_endpoint => "#{base_url}/api/#{api_version}",
54
+ })
55
+ opts[:connection_options] = {:ssl => {:verify => false}} unless verify_ssl
56
+ else
57
+ opts.merge!({
58
+ :netrc => true,
59
+ :netrc_file => File.join(fixture_path, '.netrc'),
60
+ :connection_options => {:ssl => {:verify => false}},
61
+ })
62
+
63
+ end
64
+
65
+ describe "run inline query" do
66
+ it "blocking" do
67
+ LookerSDK.reset!
68
+ client = LookerSDK::Client.new(opts)
69
+ response = client.run_inline_query("csv",
70
+ {
71
+ "model": "system__activity",
72
+ "view": "history",
73
+ "fields": ["history.query_run_count", "query.model"],
74
+ "limit": 5000
75
+ }
76
+ )
77
+ assert response
78
+ end
79
+
80
+ it "streaming" do
81
+ LookerSDK.reset!
82
+ client = LookerSDK::Client.new(opts)
83
+ response = ""
84
+ client.run_inline_query("csv",
85
+ {
86
+ "model": "system__activity",
87
+ "view": "history",
88
+ "fields": ["history.query_run_count", "query.model"],
89
+ "limit": 5000
90
+ }
91
+ ) do |data, progress|
92
+ response << data
93
+ end
94
+ assert response
95
+ end
96
+ end
97
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: looker-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Looker
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-07 00:00:00.000000000 Z
11
+ date: 2025-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sawyer
@@ -134,12 +134,13 @@ files:
134
134
  - test/looker/test_client.rb
135
135
  - test/looker/test_dynamic_client.rb
136
136
  - test/looker/test_dynamic_client_agent.rb
137
+ - test/looker/test_inline_query.rb
137
138
  - test/looker/user.json
138
139
  homepage: https://github.com/looker-open-source/looker-sdk-ruby
139
140
  licenses:
140
141
  - MIT
141
142
  metadata: {}
142
- post_install_message:
143
+ post_install_message:
143
144
  rdoc_options: []
144
145
  require_paths:
145
146
  - lib
@@ -156,13 +157,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
156
157
  requirements:
157
158
  - Looker version 4.0 or later
158
159
  rubygems_version: 3.1.6
159
- signing_key:
160
+ signing_key:
160
161
  specification_version: 4
161
162
  summary: Looker Ruby SDK
162
163
  test_files:
163
164
  - test/helper.rb
164
- - test/looker/test_client.rb
165
165
  - test/looker/test_dynamic_client.rb
166
- - test/looker/swagger.json
167
- - test/looker/user.json
166
+ - test/looker/test_inline_query.rb
168
167
  - test/looker/test_dynamic_client_agent.rb
168
+ - test/looker/test_client.rb
169
+ - test/looker/user.json
170
+ - test/looker/swagger.json