google-apis-core 0.11.2 → 0.16.0

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: 82086ecd9dad2239ce9089b943519c39de9b7574a9f1d089bee6cf6531c10eea
4
- data.tar.gz: defab5fb9d8dc49ee7e0dc228a9d687d173444ad477f41060c0b418212354058
3
+ metadata.gz: ea35d9daac9481979c51a054b42778f861d4d3fa7d1a8a384e1d955d9c49e0e9
4
+ data.tar.gz: 9aae36827cc936b1125aeacd887beee6ca92012e8e2c48b4a429aaac925aa775
5
5
  SHA512:
6
- metadata.gz: d28bfc73a1293291b6e16ddc520082404030a34d9d78c4eb6e88c81bb038ef13996235ae49f436736e9d2cf82850ed54869141508de0f24f19c96c1a30bd0c4e
7
- data.tar.gz: 035f5285444a0af8631f87e6164d5cc52554534e5c4e94cfaef122236937bd73597b58c0c475d89c795d04d76051051b16279d3f8437aa671eef86fb455d3c8c
6
+ metadata.gz: 4591582657b1d9f1ff151cc74379113bc11a591e943a1257ee1371051db844023e2906234b5af3c8f55b1bb7c0ec6115c83f0a3258a3001f251aeba5419669bd
7
+ data.tar.gz: 2ca6704eb8a9f1c86def9c644bf5868e1fe3b5442d3e1d6da9b5408e989d908ff4eb2ba07af56268ff2022e531c80bd26db435abd0031877345b9e740f668d42
data/CHANGELOG.md CHANGED
@@ -1,5 +1,56 @@
1
1
  # Release History
2
2
 
3
+ ### 0.16.0 (2025-01-12)
4
+
5
+ #### Features
6
+
7
+ * add ECONNRESET error as retriable error ([#20354](https://github.com/googleapis/google-api-ruby-client/issues/20354))
8
+
9
+ ### 0.15.1 (2024-07-29)
10
+
11
+ #### Bug Fixes
12
+
13
+ * remove rexml from dependencies ([#19971](https://github.com/googleapis/google-api-ruby-client/issues/19971))
14
+
15
+ ### 0.15.0 (2024-05-13)
16
+
17
+ #### Features
18
+
19
+ * Introduce api_version to discovery clients ([#18969](https://github.com/googleapis/google-api-ruby-client/issues/18969))
20
+
21
+ ### 0.14.1 (2024-03-13)
22
+
23
+ #### Bug Fixes
24
+
25
+ * fixes uninitialized Pathname issue ([#18480](https://github.com/googleapis/google-api-ruby-client/issues/18480))
26
+
27
+ ### 0.14.0 (2024-02-23)
28
+
29
+ #### Features
30
+
31
+ * Update minimum Ruby version to 2.7 ([#17896](https://github.com/googleapis/google-api-ruby-client/issues/17896))
32
+ #### Bug Fixes
33
+
34
+ * allow BaseService#root_url to be an Addressable::URI ([#17895](https://github.com/googleapis/google-api-ruby-client/issues/17895))
35
+
36
+ ### 0.13.0 (2024-01-26)
37
+
38
+ #### Features
39
+
40
+ * Verify credential universe domain against configured universe domain ([#17569](https://github.com/googleapis/google-api-ruby-client/issues/17569))
41
+
42
+ ### 0.12.0 (2024-01-22)
43
+
44
+ #### Features
45
+
46
+ * Support for universe_domain ([#17131](https://github.com/googleapis/google-api-ruby-client/issues/17131))
47
+
48
+ ### 0.11.3 (2024-01-17)
49
+
50
+ #### Bug Fixes
51
+
52
+ * download with destination as pathname ([#17120](https://github.com/googleapis/google-api-ruby-client/issues/17120))
53
+
3
54
  ### 0.11.2 (2023-10-27)
4
55
 
5
56
  #### Bug Fixes
@@ -93,11 +93,49 @@ module Google
93
93
  # Base service for all APIs. Not to be used directly.
94
94
  #
95
95
  class BaseService
96
+ ##
97
+ # A substitution string for the universe domain in an endpoint template
98
+ # @return [String]
99
+ #
100
+ ENDPOINT_SUBSTITUTION = "$UNIVERSE_DOMAIN$".freeze
101
+
96
102
  include Logging
97
103
 
104
+ # Universe domain
105
+ # @return [String]
106
+ attr_reader :universe_domain
107
+
108
+ # Set the universe domain.
109
+ # If the root URL was set with a universe domain substitution, it is
110
+ # updated to reflect the new universe domain.
111
+ #
112
+ # @param new_ud [String,nil] The new universe domain, or nil to use the Google Default Universe
113
+ def universe_domain= new_ud
114
+ new_ud ||= ENV["GOOGLE_CLOUD_UNIVERSE_DOMAIN"] || "googleapis.com"
115
+ if @root_url_template
116
+ @root_url = @root_url_template.gsub ENDPOINT_SUBSTITUTION, new_ud
117
+ end
118
+ @universe_domain = new_ud
119
+ end
120
+
98
121
  # Root URL (host/port) for the API
99
- # @return [Addressable::URI]
100
- attr_accessor :root_url
122
+ # @return [Addressable::URI, String]
123
+ attr_reader :root_url
124
+
125
+ # Set the root URL.
126
+ # If the given url includes a universe domain substitution, it is
127
+ # resolved in the current universe domain
128
+ #
129
+ # @param url_or_template [Addressable::URI, String] The URL, which can include a universe domain substitution
130
+ def root_url= url_or_template
131
+ if url_or_template.is_a?(String) && url_or_template.include?(ENDPOINT_SUBSTITUTION)
132
+ @root_url_template = url_or_template
133
+ @root_url = url_or_template.gsub ENDPOINT_SUBSTITUTION, universe_domain
134
+ else
135
+ @root_url_template = nil
136
+ @root_url = url_or_template
137
+ end
138
+ end
101
139
 
102
140
  # Additional path prefix for all API methods
103
141
  # @return [Addressable::URI]
@@ -136,7 +174,9 @@ module Google
136
174
  # @param [String,Addressable::URI] base_path
137
175
  # Additional path prefix for all API methods
138
176
  # @api private
139
- def initialize(root_url, base_path, client_name: nil, client_version: nil)
177
+ def initialize(root_url, base_path, client_name: nil, client_version: nil, universe_domain: nil)
178
+ @root_url_template = nil
179
+ self.universe_domain = universe_domain
140
180
  self.root_url = root_url
141
181
  self.base_path = base_path
142
182
  self.client_name = client_name || 'google-api-ruby-client'
@@ -279,7 +319,7 @@ module Google
279
319
  # Name of the field in the result containing the items. Defaults to :items
280
320
  # @param [Boolean] cache
281
321
  # True (default) if results should be cached so multiple iterations can be used.
282
- # @return [Enumerble]
322
+ # @return [Enumerable]
283
323
  # @yield [token, service]
284
324
  # Current page token & service instance
285
325
  # @yieldparam [String] token
@@ -296,6 +336,20 @@ module Google
296
336
  return PagedResults.new(self, max: max, items: items, cache: cache, response_page_token: response_page_token, &block)
297
337
  end
298
338
 
339
+ # Verify that the universe domain setting matches the universe domain
340
+ # in the credentials, if present.
341
+ #
342
+ # @raise [Google::Apis::UniverseDomainError] if there is a mismatch
343
+ def verify_universe_domain!
344
+ auth = authorization
345
+ auth_universe_domain = auth.universe_domain if auth.respond_to? :universe_domain
346
+ if auth_universe_domain && auth_universe_domain != universe_domain
347
+ raise UniverseDomainError,
348
+ "Universe domain is #{universe_domain} but credentials are in #{auth_universe_domain}"
349
+ end
350
+ true
351
+ end
352
+
299
353
  protected
300
354
 
301
355
  # Create a new upload command.
@@ -308,6 +362,7 @@ module Google
308
362
  # Request-specific options
309
363
  # @return [Google::Apis::Core::UploadCommand]
310
364
  def make_upload_command(method, path, options)
365
+ verify_universe_domain!
311
366
  template = Addressable::Template.new(root_url + upload_path + path)
312
367
  if batch?
313
368
  command = MultipartUploadCommand.new(method, template, client_version: client_version)
@@ -332,6 +387,7 @@ module Google
332
387
  # Request-specific options
333
388
  # @return [Google::Apis::Core::StorageUploadCommand]
334
389
  def make_storage_upload_command(method, path, options)
390
+ verify_universe_domain!
335
391
  template = Addressable::Template.new(root_url + upload_path + path)
336
392
  command = StorageUploadCommand.new(method, template, client_version: client_version)
337
393
  command.options = request_options.merge(options)
@@ -349,6 +405,7 @@ module Google
349
405
  # Request-specific options
350
406
  # @return [Google::Apis::Core::DownloadCommand]
351
407
  def make_download_command(method, path, options)
408
+ verify_universe_domain!
352
409
  template = Addressable::Template.new(root_url + base_path + path)
353
410
  command = DownloadCommand.new(method, template, client_version: client_version)
354
411
  command.options = request_options.merge(options)
@@ -368,6 +425,7 @@ module Google
368
425
  # Request-specific options
369
426
  # @return [Google::Apis::Core::StorageDownloadCommand]
370
427
  def make_storage_download_command(method, path, options)
428
+ verify_universe_domain!
371
429
  template = Addressable::Template.new(root_url + base_path + path)
372
430
  command = StorageDownloadCommand.new(method, template, client_version: client_version)
373
431
  command.options = request_options.merge(options)
@@ -386,6 +444,7 @@ module Google
386
444
  # Request-specific options
387
445
  # @return [Google::Apis::Core::DownloadCommand]
388
446
  def make_simple_command(method, path, options)
447
+ verify_universe_domain!
389
448
  full_path =
390
449
  if path.start_with? "/"
391
450
  path[1..-1]
@@ -15,6 +15,7 @@
15
15
  require 'google/apis/core/api_command'
16
16
  require 'google/apis/errors'
17
17
  require 'addressable/uri'
18
+ require 'pathname'
18
19
 
19
20
  module Google
20
21
  module Apis
@@ -35,7 +36,10 @@ module Google
35
36
  @state = :start
36
37
  @download_url = nil
37
38
  @offset = 0
38
- if download_dest.respond_to?(:write)
39
+ if @download_dest.is_a?(Pathname)
40
+ @download_io = File.open(download_dest, 'wb')
41
+ @close_io_on_finish = true
42
+ elsif download_dest.respond_to?(:write)
39
43
  @download_io = download_dest
40
44
  @close_io_on_finish = false
41
45
  elsif download_dest.is_a?(String)
@@ -292,7 +292,12 @@ module Google
292
292
  rescue Google::Apis::Error => e
293
293
  err = e
294
294
  end
295
- elsif err.is_a?(HTTPClient::TimeoutError) || err.is_a?(SocketError) || err.is_a?(HTTPClient::KeepAliveDisconnected) || err.is_a?(Errno::ECONNREFUSED) || err.is_a?(Errno::ETIMEDOUT)
295
+ elsif err.is_a?(HTTPClient::TimeoutError) ||
296
+ err.is_a?(SocketError) ||
297
+ err.is_a?(HTTPClient::KeepAliveDisconnected) ||
298
+ err.is_a?(Errno::ECONNREFUSED) ||
299
+ err.is_a?(Errno::ETIMEDOUT) ||
300
+ err.is_a?(Errno::ECONNRESET)
296
301
  err = Google::Apis::TransmissionError.new(err)
297
302
  end
298
303
  block.call(nil, err) if block_given?
@@ -348,6 +353,12 @@ module Google
348
353
  [:post, :put].include?(method) && body.nil?
349
354
  end
350
355
 
356
+ # Set the API version header for the service if not empty.
357
+ # @return [void]
358
+ def set_api_version_header api_version
359
+ self.header['X-Goog-Api-Version'] = api_version unless api_version.empty?
360
+ end
361
+
351
362
  private
352
363
 
353
364
  UNSAFE_CLASS_NAMES = [
@@ -25,7 +25,7 @@ module Google
25
25
 
26
26
  # Execute the upload request once. Overrides the default implementation to handle streaming/chunking
27
27
  # of file content.
28
- # Note: This method is overriden from DownloadCommand in order to respond back with
28
+ # Note: This method is overridden from DownloadCommand in order to respond back with
29
29
  # http header. All changes made to `execute_once` of DownloadCommand, should be made
30
30
  # here too.
31
31
  #
@@ -16,7 +16,7 @@ module Google
16
16
  module Apis
17
17
  module Core
18
18
  # Core version
19
- VERSION = "0.11.2".freeze
19
+ VERSION = "0.16.0".freeze
20
20
  end
21
21
  end
22
22
  end
@@ -89,5 +89,9 @@ module Google
89
89
  # Error class for problems in batch requests.
90
90
  class BatchError < Error
91
91
  end
92
+
93
+ # Error class for universe domain issues
94
+ class UniverseDomainError < Error
95
+ end
92
96
  end
93
97
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-apis-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.2
4
+ version: 0.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Google LLC
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2023-10-27 00:00:00.000000000 Z
10
+ date: 2025-01-15 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: representable
@@ -82,29 +81,23 @@ dependencies:
82
81
  name: googleauth
83
82
  requirement: !ruby/object:Gem::Requirement
84
83
  requirements:
85
- - - ">="
86
- - !ruby/object:Gem::Version
87
- version: 0.16.2
88
- - - "<"
84
+ - - "~>"
89
85
  - !ruby/object:Gem::Version
90
- version: 2.a
86
+ version: '1.9'
91
87
  type: :runtime
92
88
  prerelease: false
93
89
  version_requirements: !ruby/object:Gem::Requirement
94
90
  requirements:
95
- - - ">="
96
- - !ruby/object:Gem::Version
97
- version: 0.16.2
98
- - - "<"
91
+ - - "~>"
99
92
  - !ruby/object:Gem::Version
100
- version: 2.a
93
+ version: '1.9'
101
94
  - !ruby/object:Gem::Dependency
102
95
  name: httpclient
103
96
  requirement: !ruby/object:Gem::Requirement
104
97
  requirements:
105
98
  - - ">="
106
99
  - !ruby/object:Gem::Version
107
- version: 2.8.1
100
+ version: 2.8.3
108
101
  - - "<"
109
102
  - !ruby/object:Gem::Version
110
103
  version: 3.a
@@ -114,26 +107,12 @@ dependencies:
114
107
  requirements:
115
108
  - - ">="
116
109
  - !ruby/object:Gem::Version
117
- version: 2.8.1
110
+ version: 2.8.3
118
111
  - - "<"
119
112
  - !ruby/object:Gem::Version
120
113
  version: 3.a
121
114
  - !ruby/object:Gem::Dependency
122
- name: rexml
123
- requirement: !ruby/object:Gem::Requirement
124
- requirements:
125
- - - ">="
126
- - !ruby/object:Gem::Version
127
- version: '0'
128
- type: :runtime
129
- prerelease: false
130
- version_requirements: !ruby/object:Gem::Requirement
131
- requirements:
132
- - - ">="
133
- - !ruby/object:Gem::Version
134
- version: '0'
135
- - !ruby/object:Gem::Dependency
136
- name: webrick
115
+ name: mutex_m
137
116
  requirement: !ruby/object:Gem::Requirement
138
117
  requirements:
139
118
  - - ">="
@@ -146,7 +125,6 @@ dependencies:
146
125
  - - ">="
147
126
  - !ruby/object:Gem::Version
148
127
  version: '0'
149
- description:
150
128
  email: googleapis-packages@google.com
151
129
  executables: []
152
130
  extensions: []
@@ -186,9 +164,8 @@ licenses:
186
164
  metadata:
187
165
  bug_tracker_uri: https://github.com/googleapis/google-api-ruby-client/issues
188
166
  changelog_uri: https://github.com/googleapis/google-api-ruby-client/tree/main/google-apis-core/CHANGELOG.md
189
- documentation_uri: https://googleapis.dev/ruby/google-apis-core/v0.11.2
167
+ documentation_uri: https://googleapis.dev/ruby/google-apis-core/v0.16.0
190
168
  source_code_uri: https://github.com/googleapis/google-api-ruby-client/tree/main/google-apis-core
191
- post_install_message:
192
169
  rdoc_options: []
193
170
  require_paths:
194
171
  - lib
@@ -196,15 +173,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
196
173
  requirements:
197
174
  - - ">="
198
175
  - !ruby/object:Gem::Version
199
- version: '2.5'
176
+ version: '2.7'
200
177
  required_rubygems_version: !ruby/object:Gem::Requirement
201
178
  requirements:
202
179
  - - ">="
203
180
  - !ruby/object:Gem::Version
204
181
  version: '0'
205
182
  requirements: []
206
- rubygems_version: 3.4.19
207
- signing_key:
183
+ rubygems_version: 3.6.2
208
184
  specification_version: 4
209
185
  summary: Common utility and base classes for legacy Google REST clients
210
186
  test_files: []