google-apis-core 0.11.3 → 0.14.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f085e1d76ff530d5ad81f7971fc851fe8e2f65bc5c4f618ae4cd4d4a83ebb791
4
- data.tar.gz: a6257b235ec0141d76a40ef7e04f9c77da805ca67a7445c34ce54aaf1aac16b0
3
+ metadata.gz: c3c57ca24b4836ea6e800df3a184b040c9c51c64149d743d4d3335d6ac76094d
4
+ data.tar.gz: 42a724598b2ff3656cac8df432bae7428e5a4a53bede1366ee92080d0738d5c7
5
5
  SHA512:
6
- metadata.gz: 8f4e051906ec4aa5ceb984e962d96b7eb07ed23782e7b56bc5ae24423993357b36af896de75d35d54374355e09fa93de3e1aa467f3e907a02a546665b33e6012
7
- data.tar.gz: 66b09b1c8f9fcaa8751815f9967d4a409c5cef642482cf4b5695ed719e9043ae0d9249f203e2804f4586549fe4d1a9dde6156e3ddfc3b9b4cf65da384c431904
6
+ metadata.gz: 28b3c7e49fde2eab1cd10bb5a1e898b5c99f1ee14930b4f8a2b7d66d6ac77731eb6bdfd5e7fa0940f044d58c5ceb8205b460ffc56ea9331f7e166da88504c808
7
+ data.tar.gz: 95cedbafcc1a7d1dd7a8dc8ce63090bba5a1c4c96b8cb247ae0c4dc1851e98b78afcd3a162aeca50c94a6a8a37fa0c8cf7afcdb6f838a5f3fc73858898bf82a8
data/CHANGELOG.md CHANGED
@@ -1,5 +1,32 @@
1
1
  # Release History
2
2
 
3
+ ### 0.14.1 (2024-03-13)
4
+
5
+ #### Bug Fixes
6
+
7
+ * fixes uninitialized Pathname issue ([#18480](https://github.com/googleapis/google-api-ruby-client/issues/18480))
8
+
9
+ ### 0.14.0 (2024-02-23)
10
+
11
+ #### Features
12
+
13
+ * Update minimum Ruby version to 2.7 ([#17896](https://github.com/googleapis/google-api-ruby-client/issues/17896))
14
+ #### Bug Fixes
15
+
16
+ * allow BaseService#root_url to be an Addressable::URI ([#17895](https://github.com/googleapis/google-api-ruby-client/issues/17895))
17
+
18
+ ### 0.13.0 (2024-01-26)
19
+
20
+ #### Features
21
+
22
+ * Verify credential universe domain against configured universe domain ([#17569](https://github.com/googleapis/google-api-ruby-client/issues/17569))
23
+
24
+ ### 0.12.0 (2024-01-22)
25
+
26
+ #### Features
27
+
28
+ * Support for universe_domain ([#17131](https://github.com/googleapis/google-api-ruby-client/issues/17131))
29
+
3
30
  ### 0.11.3 (2024-01-17)
4
31
 
5
32
  #### 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
@@ -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.3".freeze
19
+ VERSION = "0.14.1".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,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-apis-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.3
4
+ version: 0.14.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Google LLC
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-17 00:00:00.000000000 Z
11
+ date: 2024-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: representable
@@ -82,22 +82,16 @@ dependencies:
82
82
  name: googleauth
83
83
  requirement: !ruby/object:Gem::Requirement
84
84
  requirements:
85
- - - ">="
86
- - !ruby/object:Gem::Version
87
- version: 0.16.2
88
- - - "<"
85
+ - - "~>"
89
86
  - !ruby/object:Gem::Version
90
- version: 2.a
87
+ version: '1.9'
91
88
  type: :runtime
92
89
  prerelease: false
93
90
  version_requirements: !ruby/object:Gem::Requirement
94
91
  requirements:
95
- - - ">="
96
- - !ruby/object:Gem::Version
97
- version: 0.16.2
98
- - - "<"
92
+ - - "~>"
99
93
  - !ruby/object:Gem::Version
100
- version: 2.a
94
+ version: '1.9'
101
95
  - !ruby/object:Gem::Dependency
102
96
  name: httpclient
103
97
  requirement: !ruby/object:Gem::Requirement
@@ -172,7 +166,7 @@ licenses:
172
166
  metadata:
173
167
  bug_tracker_uri: https://github.com/googleapis/google-api-ruby-client/issues
174
168
  changelog_uri: https://github.com/googleapis/google-api-ruby-client/tree/main/google-apis-core/CHANGELOG.md
175
- documentation_uri: https://googleapis.dev/ruby/google-apis-core/v0.11.3
169
+ documentation_uri: https://googleapis.dev/ruby/google-apis-core/v0.14.1
176
170
  source_code_uri: https://github.com/googleapis/google-api-ruby-client/tree/main/google-apis-core
177
171
  post_install_message:
178
172
  rdoc_options: []
@@ -182,14 +176,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
182
176
  requirements:
183
177
  - - ">="
184
178
  - !ruby/object:Gem::Version
185
- version: '2.5'
179
+ version: '2.7'
186
180
  required_rubygems_version: !ruby/object:Gem::Requirement
187
181
  requirements:
188
182
  - - ">="
189
183
  - !ruby/object:Gem::Version
190
184
  version: '0'
191
185
  requirements: []
192
- rubygems_version: 3.5.3
186
+ rubygems_version: 3.5.6
193
187
  signing_key:
194
188
  specification_version: 4
195
189
  summary: Common utility and base classes for legacy Google REST clients