google-cloud-storage 1.36.1 → 1.38.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: bc6820f05140317dddb52acc3fe9ff73f4e2c27fec1661080c5158c1b25d37fc
4
- data.tar.gz: 8da3883d38b1438e6111ca85d816bc61eab0a39eed10c15a16fdfc1216d90da7
3
+ metadata.gz: 7377748053d6da28b196231e893002e4d80849cf558b5e983003926c19526a6c
4
+ data.tar.gz: b00e59073ea7230b4b654de40e6323766d6e36a562d765ad2545c8d154b16d2d
5
5
  SHA512:
6
- metadata.gz: f78459e6fafec440e7992c55e6eea6bf4516e0bfc42b86814f6cce57a9e1888e920211aed3e765752bf8be8dde5bb7acbc848847479a6f972bf910c865b2e53f
7
- data.tar.gz: 1d83247cb0c0f8bb092f47e43997f6070ecdf93804413e2af5f1c3a0144cbcc45d9d4b77ec23e5c8bfbd69dd1892fab1eb0d5b31169c960639bf7e3a5dd49b0e
6
+ metadata.gz: 65b18a6857817dd24246d287c3e51cabfb2ec61fffda26f3fc00462fd030e60c506a893ccc86a14cfc1034d882c6d488b5220e744ee2fe3316d55271c9fdaadc
7
+ data.tar.gz: fede3f8da08220a89dc1642fd1937cc75ea6b57ee9d210bd8a8dc4efcb5c11ff5dab0d2962c7c25f383cda4e9aa548fe8764c0ec06867abf46ca91d7fbbd33e3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # Release History
2
2
 
3
+ ### 1.38.0 (2022-07-31)
4
+
5
+ #### Features
6
+
7
+ * Add support for dual region gcs buckets ([#18862](https://github.com/googleapis/google-cloud-ruby/issues/18862))
8
+
9
+ ### 1.37.0 (2022-06-30)
10
+
11
+ #### Features
12
+
13
+ * support OLM Prefix/Suffix ([#18190](https://github.com/googleapis/google-cloud-ruby/issues/18190))
14
+ * allow retry options to be configurable on client initialization ([#18332](https://github.com/googleapis/google-cloud-ruby/issues/18332))
15
+ #### Bug Fixes
16
+
17
+ * update object path parsing to handle hashes in them
18
+
19
+ ### 1.36.2 (2022-04-20)
20
+
21
+ #### Documentation
22
+
23
+ * Document support for dual region buckets
24
+
3
25
  ### 1.36.1 / 2022-02-08
4
26
 
5
27
  #### Documentation
@@ -53,6 +53,8 @@ module Google
53
53
  # rule.storage_class #=> "COLDLINE"
54
54
  # rule.age #=> 10
55
55
  # rule.matches_storage_class #=> ["STANDARD", "NEARLINE"]
56
+ # rule.matches_prefix #=> ["myprefix/foo"]
57
+ # rule.matches_suffix #=> [".jpg", ".png"]
56
58
  #
57
59
  # @example Updating the bucket's lifecycle management rules in a block.
58
60
  # require "google/cloud/storage"
@@ -138,6 +140,12 @@ module Google
138
140
  # files. If the value is N, this condition is satisfied when there
139
141
  # are at least N versions (including the live version) newer than
140
142
  # this version of the file.
143
+ # @param [Array<String,Symbol>] matches_prefix
144
+ # Files having their name with the specified list of prefixs will be matched.
145
+ # Arguments will be converted from symbols to strings.
146
+ # @param [Array<String,Symbol>] matches_suffix
147
+ # Files having their name with the specified list of suffixes will be matched.
148
+ # Arguments will be converted from symbols to strings.
141
149
  #
142
150
  # @example
143
151
  # require "google/cloud/storage"
@@ -157,7 +165,9 @@ module Google
157
165
  is_live: nil,
158
166
  matches_storage_class: nil,
159
167
  noncurrent_time_before: nil,
160
- num_newer_versions: nil
168
+ num_newer_versions: nil,
169
+ matches_prefix: nil,
170
+ matches_suffix: nil
161
171
  push Rule.new(
162
172
  "SetStorageClass",
163
173
  storage_class: storage_class_for(storage_class),
@@ -169,12 +179,14 @@ module Google
169
179
  is_live: is_live,
170
180
  matches_storage_class: storage_class_for(matches_storage_class),
171
181
  noncurrent_time_before: noncurrent_time_before,
172
- num_newer_versions: num_newer_versions
182
+ num_newer_versions: num_newer_versions,
183
+ matches_prefix: Array(matches_prefix),
184
+ matches_suffix: Array(matches_suffix)
173
185
  )
174
186
  end
175
187
 
176
188
  ##
177
- # Adds a SetStorageClass lifecycle rule to the Object Lifecycle
189
+ # Adds a Delete lifecycle rule to the Object Lifecycle
178
190
  # Management rules for a bucket.
179
191
  #
180
192
  # @see https://cloud.google.com/storage/docs/lifecycle Object
@@ -221,6 +233,12 @@ module Google
221
233
  # files. If the value is N, this condition is satisfied when there
222
234
  # are at least N versions (including the live version) newer than
223
235
  # this version of the file.
236
+ # @param [Array<String,Symbol>] matches_prefix
237
+ # Files having their name with the specified list of prefixs will be matched.
238
+ # Arguments will be converted from symbols to strings.
239
+ # @param [Array<String,Symbol>] matches_suffix
240
+ # Files having their name with the specified list of suffixes will be matched.
241
+ # Arguments will be converted from symbols to strings.
224
242
  #
225
243
  # @example
226
244
  # require "google/cloud/storage"
@@ -239,7 +257,9 @@ module Google
239
257
  is_live: nil,
240
258
  matches_storage_class: nil,
241
259
  noncurrent_time_before: nil,
242
- num_newer_versions: nil
260
+ num_newer_versions: nil,
261
+ matches_prefix: nil,
262
+ matches_suffix: nil
243
263
  push Rule.new(
244
264
  "Delete",
245
265
  age: age,
@@ -250,7 +270,49 @@ module Google
250
270
  is_live: is_live,
251
271
  matches_storage_class: storage_class_for(matches_storage_class),
252
272
  noncurrent_time_before: noncurrent_time_before,
253
- num_newer_versions: num_newer_versions
273
+ num_newer_versions: num_newer_versions,
274
+ matches_prefix: Array(matches_prefix),
275
+ matches_suffix: Array(matches_suffix)
276
+ )
277
+ end
278
+
279
+ ##
280
+ # Adds a AbortIncompleteMultipartUpload lifecycle rule to the Object Lifecycle
281
+ # Management rules for a bucket.
282
+ #
283
+ # @see https://cloud.google.com/storage/docs/lifecycle Object
284
+ # Lifecycle Management
285
+ # @see https://cloud.google.com/storage/docs/managing-lifecycles
286
+ # Managing Object Lifecycles
287
+ #
288
+ # @param [Integer] age The age of a file (in days). This condition is
289
+ # satisfied when a file reaches the specified age.
290
+ # @param [Array<String,Symbol>] matches_prefix
291
+ # Files having their name with the specified list of prefixs will be matched.
292
+ # Arguments will be converted from symbols to strings.
293
+ # @param [Array<String,Symbol>] matches_suffix
294
+ # Files having their name with the specified list of suffixes will be matched.
295
+ # Arguments will be converted from symbols to strings.
296
+ #
297
+ # @example
298
+ # require "google/cloud/storage"
299
+ #
300
+ # storage = Google::Cloud::Storage.new
301
+ #
302
+ # bucket = storage.create_bucket "my-bucket" do |b|
303
+ # b.lifecycle.add_abort_incomplete_multipart_upload_rule age: 10,
304
+ # matches_prefix: ["images/"],
305
+ # matches_suffix: [".pdf"]
306
+ # end
307
+ #
308
+ def add_abort_incomplete_multipart_upload_rule age: nil,
309
+ matches_prefix: nil,
310
+ matches_suffix: nil
311
+ push Rule.new(
312
+ "AbortIncompleteMultipartUpload",
313
+ age: age,
314
+ matches_prefix: Array(matches_prefix),
315
+ matches_suffix: Array(matches_suffix)
254
316
  )
255
317
  end
256
318
 
@@ -346,6 +408,8 @@ module Google
346
408
  # rule.storage_class #=> "COLDLINE"
347
409
  # rule.age #=> 10
348
410
  # rule.matches_storage_class #=> ["STANDARD", "NEARLINE"]
411
+ # rule.matches_prefix #=> ["myprefix/foo"]
412
+ # rule.matches_suffix #=> [".jpg", ".png"]
349
413
  #
350
414
  # @example Updating the bucket's lifecycle rules in a block.
351
415
  # require "google/cloud/storage"
@@ -382,6 +446,8 @@ module Google
382
446
  attr_accessor :matches_storage_class
383
447
  attr_accessor :noncurrent_time_before
384
448
  attr_accessor :num_newer_versions
449
+ attr_accessor :matches_prefix
450
+ attr_accessor :matches_suffix
385
451
 
386
452
  # @private
387
453
  def initialize action,
@@ -394,7 +460,9 @@ module Google
394
460
  is_live: nil,
395
461
  matches_storage_class: nil,
396
462
  noncurrent_time_before: nil,
397
- num_newer_versions: nil
463
+ num_newer_versions: nil,
464
+ matches_prefix: nil,
465
+ matches_suffix: nil
398
466
  @action = action
399
467
  @storage_class = storage_class
400
468
  @age = age
@@ -406,6 +474,8 @@ module Google
406
474
  @matches_storage_class = Array(matches_storage_class)
407
475
  @noncurrent_time_before = noncurrent_time_before
408
476
  @num_newer_versions = num_newer_versions
477
+ @matches_prefix = Array(matches_prefix)
478
+ @matches_suffix = Array(matches_suffix)
409
479
  end
410
480
 
411
481
  # @private
@@ -420,7 +490,9 @@ module Google
420
490
  is_live,
421
491
  matches_storage_class,
422
492
  noncurrent_time_before,
423
- num_newer_versions
493
+ num_newer_versions,
494
+ matches_prefix,
495
+ matches_suffix
424
496
  )
425
497
  Google::Apis::StorageV1::Bucket::Lifecycle::Rule.new(
426
498
  action: action_gapi(action, storage_class),
@@ -445,7 +517,9 @@ module Google
445
517
  is_live,
446
518
  matches_storage_class,
447
519
  noncurrent_time_before,
448
- num_newer_versions
520
+ num_newer_versions,
521
+ matches_prefix,
522
+ matches_suffix
449
523
  Google::Apis::StorageV1::Bucket::Lifecycle::Rule::Condition.new(
450
524
  age: age,
451
525
  created_before: created_before,
@@ -455,7 +529,9 @@ module Google
455
529
  is_live: is_live,
456
530
  matches_storage_class: Array(matches_storage_class),
457
531
  noncurrent_time_before: noncurrent_time_before,
458
- num_newer_versions: num_newer_versions
532
+ num_newer_versions: num_newer_versions,
533
+ matches_prefix: Array(matches_prefix),
534
+ matches_suffix: Array(matches_suffix)
459
535
  )
460
536
  end
461
537
 
@@ -475,7 +551,9 @@ module Google
475
551
  is_live: c.is_live,
476
552
  matches_storage_class: c.matches_storage_class,
477
553
  noncurrent_time_before: c.noncurrent_time_before,
478
- num_newer_versions: c.num_newer_versions
554
+ num_newer_versions: c.num_newer_versions,
555
+ matches_prefix: c.matches_prefix,
556
+ matches_suffix: c.matches_suffix
479
557
  )
480
558
  end
481
559
 
@@ -279,7 +279,7 @@ module Google
279
279
  #
280
280
  # @return [String]
281
281
  #
282
- # @see https://cloud.google.com/storage/docs/concepts-techniques
282
+ # @see https://cloud.google.com/storage/docs/locations
283
283
  #
284
284
  def location
285
285
  @gapi.location
@@ -301,6 +301,20 @@ module Google
301
301
  @gapi.location_type
302
302
  end
303
303
 
304
+ ##
305
+ # Returns the list of regional locations for custom dual-region buckets.
306
+ #
307
+ # @return [String, nil] Returns nil if the property has not been set before creation,
308
+ # if the bucket's resource has not been loaded from the server,
309
+ # or if the bucket is not a dual-regions bucket.
310
+
311
+ # @see https://cloud.google.com/storage/docs/json_api/v1/buckets and
312
+ # https://cloud.google.com/storage/docs/locations
313
+ #
314
+ def data_locations
315
+ @gapi.custom_placement_config&.data_locations
316
+ end
317
+
304
318
  ##
305
319
  # The destination bucket name for the bucket's logs.
306
320
  #
@@ -48,7 +48,7 @@ module Google
48
48
  #
49
49
  def ext_path
50
50
  path = "/#{@bucket}/#{@path}"
51
- escaped = Addressable::URI.escape path
51
+ escaped = Addressable::URI.encode_component path, Addressable::URI::CharacterClasses::PATH
52
52
  special_var = "${filename}"
53
53
  # Restore the unencoded `${filename}` variable, if present.
54
54
  if path.include? special_var
@@ -326,7 +326,7 @@ module Google
326
326
  #
327
327
  def post_object_ext_path
328
328
  path = "/#{@bucket_name}/#{@file_name}"
329
- escaped = Addressable::URI.escape path
329
+ escaped = Addressable::URI.encode_component path, Addressable::URI::CharacterClasses::PATH
330
330
  special_var = "${filename}"
331
331
  # Restore the unencoded `${filename}` variable, if present.
332
332
  if path.include? special_var
@@ -288,12 +288,11 @@ module Google
288
288
  # roles.
289
289
  # * `public`, `public_read`, `publicRead` - File owner gets OWNER
290
290
  # access, and allUsers get READER access.
291
- # @param [String] location The location of the bucket. Object data for
292
- # objects in the bucket resides in physical storage within this
293
- # region. Possible values include `ASIA`, `EU`, and `US`. (See the
294
- # [developer's
295
- # guide](https://cloud.google.com/storage/docs/bucket-locations) for
296
- # the authoritative list. The default value is `US`.
291
+ # @param [String] location The location of the bucket. Optional.
292
+ # If not passed, the default location, 'US', will be used.
293
+ # If specifying a dual-region location, the `customPlacementConfig`
294
+ # property should be set in conjunction. See:
295
+ # [Storage Locations](https://cloud.google.com/storage/docs/locations).
297
296
  # @param [String] logging_bucket The destination bucket for the bucket's
298
297
  # logs. For more information, see [Access
299
298
  # Logs](https://cloud.google.com/storage/docs/access-logs).
@@ -368,6 +367,7 @@ module Google
368
367
  acl: nil,
369
368
  default_acl: nil,
370
369
  location: nil,
370
+ custom_placement_config: nil,
371
371
  storage_class: nil,
372
372
  logging_bucket: nil,
373
373
  logging_prefix: nil,
@@ -378,7 +378,8 @@ module Google
378
378
  user_project: nil
379
379
  params = {
380
380
  name: bucket_name,
381
- location: location
381
+ location: location,
382
+ custom_placement_config: custom_placement_config
382
383
  }.delete_if { |_, v| v.nil? }
383
384
  new_bucket = Google::Apis::StorageV1::Bucket.new(**params)
384
385
  storage_class = storage_class_for storage_class
@@ -38,9 +38,12 @@ module Google
38
38
 
39
39
  ##
40
40
  # Creates a new Service instance.
41
+ # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
41
42
  def initialize project, credentials, retries: nil,
42
43
  timeout: nil, open_timeout: nil, read_timeout: nil,
43
- send_timeout: nil, host: nil, quota_project: nil
44
+ send_timeout: nil, host: nil, quota_project: nil,
45
+ max_elapsed_time: nil, base_interval: nil, max_interval: nil,
46
+ multiplier: nil
44
47
  @project = project
45
48
  @credentials = credentials
46
49
  @service = API::StorageService.new
@@ -57,9 +60,14 @@ module Google
57
60
  "gl-ruby/#{RUBY_VERSION} gccl/#{Google::Cloud::Storage::VERSION}"
58
61
  @service.request_options.header["Accept-Encoding"] = "gzip"
59
62
  @service.request_options.quota_project = quota_project if quota_project
63
+ @service.request_options.max_elapsed_time = max_elapsed_time if max_elapsed_time
64
+ @service.request_options.base_interval = base_interval if base_interval
65
+ @service.request_options.max_interval = max_interval if max_interval
66
+ @service.request_options.multiplier = multiplier if multiplier
60
67
  @service.authorization = @credentials.client if @credentials
61
68
  @service.root_url = host if host
62
69
  end
70
+ # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
63
71
 
64
72
  def service
65
73
  return mocked_service if mocked_service
@@ -480,7 +488,7 @@ module Google
480
488
  options = range_header options, range
481
489
 
482
490
  execute do
483
- service.get_object_with_response \
491
+ service.get_object \
484
492
  bucket_name, file_path,
485
493
  download_dest: target_path, generation: generation,
486
494
  user_project: user_project(user_project),
@@ -766,160 +774,4 @@ module Google
766
774
  end
767
775
  end
768
776
  end
769
-
770
- # rubocop:disable all
771
-
772
- # @private
773
- #
774
- # IMPORTANT: These monkey-patches of Apis::StorageV1::StorageService and
775
- # Apis::Core::DownloadCommand must be verified and updated (if needed) for
776
- # every upgrade of google-api-client.
777
- #
778
- # The purpose of these modifications is to provide access to response headers
779
- # (in particular, the Content-Encoding header) for the #download_file method,
780
- # above. If google-api-client is modified to expose response headers to its
781
- # clients, this code should be removed, and #download_file updated to use that
782
- # solution instead.
783
- #
784
- module Apis
785
- # @private
786
- module StorageV1
787
- # @private
788
- class StorageService
789
- # Returns a two-element array containing:
790
- # * The `result` that is the usual return type of #get_object.
791
- # * The `http_resp` from DownloadCommand#execute_once.
792
- def get_object_with_response(bucket, object, generation: nil, if_generation_match: nil, if_generation_not_match: nil, if_metageneration_match: nil, if_metageneration_not_match: nil, projection: nil, user_project: nil, fields: nil, quota_user: nil, user_ip: nil, download_dest: nil, options: nil, &block)
793
- if download_dest.nil?
794
- command = make_simple_command(:get, 'b/{bucket}/o/{object}', options)
795
- else
796
- command = make_download_command(:get, 'b/{bucket}/o/{object}', options)
797
- command.download_dest = download_dest
798
- end
799
- command.response_representation = Google::Apis::StorageV1::Object::Representation
800
- command.response_class = Google::Apis::StorageV1::Object
801
- command.params['bucket'] = bucket unless bucket.nil?
802
- command.params['object'] = object unless object.nil?
803
- command.query['generation'] = generation unless generation.nil?
804
- command.query['ifGenerationMatch'] = if_generation_match unless if_generation_match.nil?
805
- command.query['ifGenerationNotMatch'] = if_generation_not_match unless if_generation_not_match.nil?
806
- command.query['ifMetagenerationMatch'] = if_metageneration_match unless if_metageneration_match.nil?
807
- command.query['ifMetagenerationNotMatch'] = if_metageneration_not_match unless if_metageneration_not_match.nil?
808
- command.query['projection'] = projection unless projection.nil?
809
- command.query['userProject'] = user_project unless user_project.nil?
810
- command.query['fields'] = fields unless fields.nil?
811
- command.query['quotaUser'] = quota_user unless quota_user.nil?
812
- command.query['userIp'] = user_ip unless user_ip.nil?
813
- execute_or_queue_command_with_response(command, &block)
814
- end
815
-
816
- # Returns a two-element array containing:
817
- # * The `result` that is the usual return type of #execute_or_queue_command.
818
- # * The `http_resp` from DownloadCommand#execute_once.
819
- def execute_or_queue_command_with_response(command, &callback)
820
- batch_command = current_batch
821
- if batch_command
822
- raise "Can not combine services in a batch" if Thread.current[:google_api_batch_service] != self
823
- batch_command.add(command, &callback)
824
- nil
825
- else
826
- command.execute_with_response(client, &callback)
827
- end
828
- end
829
- end
830
- end
831
- # @private
832
- module Core
833
- # @private
834
- # Streaming/resumable media download support
835
- class DownloadCommand < ApiCommand
836
- # Returns a two-element array containing:
837
- # * The `result` that is the usual return type of #execute.
838
- # * The `http_resp` from #execute_once.
839
- def execute_with_response(client)
840
- prepare!
841
- begin
842
- Retriable.retriable tries: options.retries + 1,
843
- base_interval: 1,
844
- multiplier: 2,
845
- on: RETRIABLE_ERRORS do |try|
846
- # This 2nd level retriable only catches auth errors, and supports 1 retry, which allows
847
- # auth to be re-attempted without having to retry all sorts of other failures like
848
- # NotFound, etc
849
- auth_tries = (try == 1 && authorization_refreshable? ? 2 : 1)
850
- Retriable.retriable tries: auth_tries,
851
- on: [Google::Apis::AuthorizationError, Signet::AuthorizationError],
852
- on_retry: proc { |*| refresh_authorization } do
853
- execute_once_with_response(client).tap do |result|
854
- if block_given?
855
- yield result, nil
856
- end
857
- end
858
- end
859
- end
860
- rescue => e
861
- if block_given?
862
- yield nil, e
863
- else
864
- raise e
865
- end
866
- end
867
- ensure
868
- release!
869
- end
870
-
871
- # Returns a two-element array containing:
872
- # * The `result` that is the usual return type of #execute_once.
873
- # * The `http_resp`.
874
- def execute_once_with_response(client, &block)
875
- request_header = header.dup
876
- apply_request_options(request_header)
877
- download_offset = nil
878
-
879
- if @offset > 0
880
- logger.debug { sprintf('Resuming download from offset %d', @offset) }
881
- request_header[RANGE_HEADER] = sprintf('bytes=%d-', @offset)
882
- end
883
-
884
- http_res = client.get(url.to_s,
885
- query: query,
886
- header: request_header,
887
- follow_redirect: true) do |res, chunk|
888
- status = res.http_header.status_code.to_i
889
- next unless OK_STATUS.include?(status)
890
-
891
- download_offset ||= (status == 206 ? @offset : 0)
892
- download_offset += chunk.bytesize
893
-
894
- if download_offset - chunk.bytesize == @offset
895
- next_chunk = chunk
896
- else
897
- # Oh no! Requested a chunk, but received the entire content
898
- chunk_index = @offset - (download_offset - chunk.bytesize)
899
- next_chunk = chunk.byteslice(chunk_index..-1)
900
- next if next_chunk.nil?
901
- end
902
- # logger.debug { sprintf('Writing chunk (%d bytes, %d total)', chunk.length, bytes_read) }
903
- @download_io.write(next_chunk)
904
-
905
- @offset += next_chunk.bytesize
906
- end
907
-
908
- @download_io.flush
909
-
910
- if @close_io_on_finish
911
- result = nil
912
- else
913
- result = @download_io
914
- end
915
- check_status(http_res.status.to_i, http_res.header, http_res.body)
916
- success([result, http_res], &block)
917
- rescue => e
918
- @download_io.flush
919
- error(e, rethrow: true, &block)
920
- end
921
- end
922
- end
923
- end
924
- # rubocop:enable all
925
777
  end
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Storage
19
- VERSION = "1.36.1".freeze
19
+ VERSION = "1.38.0".freeze
20
20
  end
21
21
  end
22
22
  end
@@ -55,6 +55,11 @@ module Google
55
55
  # * `https://www.googleapis.com/auth/devstorage.full_control`
56
56
  # @param [Integer] retries Number of times to retry requests on server
57
57
  # error. The default value is `3`. Optional.
58
+ # @param [Integer] max_elapsed_time Total time in seconds that requests are allowed to keep being retried.
59
+ # @param [Float] base_interval The initial interval in seconds between tries.
60
+ # @param [Integer] max_interval The maximum interval in seconds that any individual retry can reach.
61
+ # @param [Integer] multiplier Each successive interval grows by this factor. A multipler of 1.5 means the next
62
+ # interval will be 1.5x the current interval.
58
63
  # @param [Integer] timeout (default timeout) The max duration, in seconds, to wait before timing out. Optional.
59
64
  # If left blank, the wait will be at most the time permitted by the underlying HTTP/RPC protocol.
60
65
  # @param [Integer] open_timeout How long, in seconds, before failed connections time out. Optional.
@@ -79,18 +84,24 @@ module Google
79
84
  # bucket = storage.bucket "my-bucket"
80
85
  # file = bucket.file "path/to/my-file.ext"
81
86
  #
82
- # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
87
+ # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/AbcSize
83
88
  def self.new project_id: nil, credentials: nil, scope: nil, retries: nil,
84
89
  timeout: nil, open_timeout: nil, read_timeout: nil,
85
- send_timeout: nil, endpoint: nil, project: nil, keyfile: nil
86
- scope ||= configure.scope
87
- retries ||= configure.retries
88
- timeout ||= configure.timeout
89
- open_timeout ||= (configure.open_timeout || timeout)
90
- read_timeout ||= (configure.read_timeout || timeout)
91
- send_timeout ||= (configure.send_timeout || timeout)
92
- endpoint ||= configure.endpoint
93
- credentials ||= (keyfile || default_credentials(scope: scope))
90
+ send_timeout: nil, endpoint: nil, project: nil, keyfile: nil,
91
+ max_elapsed_time: nil, base_interval: nil, max_interval: nil,
92
+ multiplier: nil
93
+ scope ||= configure.scope
94
+ retries ||= configure.retries
95
+ timeout ||= configure.timeout
96
+ open_timeout ||= (configure.open_timeout || timeout)
97
+ read_timeout ||= (configure.read_timeout || timeout)
98
+ send_timeout ||= (configure.send_timeout || timeout)
99
+ endpoint ||= configure.endpoint
100
+ credentials ||= (keyfile || default_credentials(scope: scope))
101
+ max_elapsed_time ||= configure.max_elapsed_time
102
+ base_interval ||= configure.base_interval
103
+ max_interval ||= configure.max_interval
104
+ multiplier ||= configure.multiplier
94
105
 
95
106
  unless credentials.is_a? Google::Auth::Credentials
96
107
  credentials = Storage::Credentials.new credentials, scope: scope
@@ -104,11 +115,13 @@ module Google
104
115
  project_id, credentials,
105
116
  retries: retries, timeout: timeout, open_timeout: open_timeout,
106
117
  read_timeout: read_timeout, send_timeout: send_timeout,
107
- host: endpoint, quota_project: configure.quota_project
118
+ host: endpoint, quota_project: configure.quota_project,
119
+ max_elapsed_time: max_elapsed_time, base_interval: base_interval,
120
+ max_interval: max_interval, multiplier: multiplier
108
121
  )
109
122
  )
110
123
  end
111
- # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
124
+ # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/AbcSize
112
125
 
113
126
  ##
114
127
  # Creates an unauthenticated, anonymous client for retrieving public data
@@ -116,6 +129,11 @@ module Google
116
129
  #
117
130
  # @param [Integer] retries Number of times to retry requests on server
118
131
  # error. The default value is `3`. Optional.
132
+ # @param [Integer] max_elapsed_time Total time in seconds that requests are allowed to keep being retried.
133
+ # @param [Float] base_interval The initial interval in seconds between tries.
134
+ # @param [Integer] max_interval The maximum interval in seconds that any individual retry can reach.
135
+ # @param [Integer] multiplier Each successive interval grows by this factor. A multipler of 1.5 means the next
136
+ # interval will be 1.5x the current interval.
119
137
  # @param [Integer] timeout (default timeout) The max duration, in seconds, to wait before timing out. Optional.
120
138
  # If left blank, the wait will be at most the time permitted by the underlying HTTP/RPC protocol.
121
139
  # @param [Integer] open_timeout How long, in seconds, before failed connections time out. Optional.
@@ -139,14 +157,18 @@ module Google
139
157
  # downloaded.read #=> "Hello world!"
140
158
  #
141
159
  def self.anonymous retries: nil, timeout: nil, open_timeout: nil,
142
- read_timeout: nil, send_timeout: nil, endpoint: nil
160
+ read_timeout: nil, send_timeout: nil, endpoint: nil,
161
+ max_elapsed_time: nil, base_interval: nil, max_interval: nil,
162
+ multiplier: nil
143
163
  open_timeout ||= timeout
144
164
  read_timeout ||= timeout
145
165
  send_timeout ||= timeout
146
166
  Storage::Project.new(
147
167
  Storage::Service.new(
148
168
  nil, nil, retries: retries, timeout: timeout, open_timeout: open_timeout,
149
- read_timeout: read_timeout, send_timeout: send_timeout, host: endpoint
169
+ read_timeout: read_timeout, send_timeout: send_timeout, host: endpoint,
170
+ max_elapsed_time: max_elapsed_time, base_interval: base_interval,
171
+ max_interval: max_interval, multiplier: multiplier
150
172
  )
151
173
  )
152
174
  end
@@ -168,6 +190,13 @@ module Google
168
190
  # the set of resources and operations that the connection can access.
169
191
  # * `retries` - (Integer) Number of times to retry requests on server
170
192
  # error.
193
+ # * `max_elapsed_time` - (Integer) Total time in seconds that requests
194
+ # are allowed to keep being retried.
195
+ # * `base_interval` - (Float) The initial interval in seconds between tries.
196
+ # * `max_interval` - (Integer) The maximum interval in seconds that any
197
+ # individual retry can reach.
198
+ # * `multiplier` - (Integer) Each successive interval grows by this factor.
199
+ # A multipler of 1.5 means the next interval will be 1.5x the current interval.
171
200
  # * `timeout` - (Integer) (default timeout) The max duration, in seconds, to wait before timing out.
172
201
  # If left blank, the wait will be at most the time permitted by the underlying HTTP/RPC protocol.
173
202
  # * `open_timeout` - (Integer) How long, in seconds, before failed connections time out.
@@ -45,8 +45,13 @@ module Google
45
45
  # * `https://www.googleapis.com/auth/devstorage.full_control`
46
46
  # @param [Integer] retries Number of times to retry requests on server
47
47
  # error. The default value is `3`. Optional.
48
+ # @param [Integer] max_elapsed_time Total time in seconds that requests are allowed to keep being retried.
49
+ # @param [Float] base_interval The initial interval in seconds between tries.
50
+ # @param [Integer] max_interval The maximum interval in seconds that any individual retry can reach.
51
+ # @param [Integer] multiplier Each successive interval grows by this factor. A multipler of 1.5 means the next
52
+ # interval will be 1.5x the current interval.
48
53
  # @param [Integer] timeout (default timeout) The max duration, in seconds, to wait before timing out. Optional.
49
- # If left blank, the wait will be at most the time permitted by the underlying HTTP/RPC protocol.
54
+ # If left blank, the wait will be at most the time permitted by the underlying HTTP/RPC protocol.
50
55
  # @param [Integer] open_timeout How long, in seconds, before failed connections time out. Optional.
51
56
  # @param [Integer] read_timeout How long, in seconds, before requests time out. Optional.
52
57
  # @param [Integer] send_timeout How long, in seconds, before receiving response from server times out. Optional.
@@ -68,13 +73,18 @@ module Google
68
73
  # readonly_scope = "https://www.googleapis.com/auth/devstorage.read_only"
69
74
  # readonly_storage = gcloud.storage scope: readonly_scope
70
75
  #
71
- def storage scope: nil, retries: nil, timeout: nil, open_timeout: nil, read_timeout: nil, send_timeout: nil
76
+ def storage scope: nil, retries: nil, timeout: nil, open_timeout: nil, read_timeout: nil, send_timeout: nil,
77
+ max_elapsed_time: nil, base_interval: nil, max_interval: nil, multiplier: nil
72
78
  Google::Cloud.storage @project, @keyfile, scope: scope,
73
79
  retries: (retries || @retries),
74
80
  timeout: (timeout || @timeout),
75
81
  open_timeout: (open_timeout || timeout),
76
82
  read_timeout: (read_timeout || timeout),
77
- send_timeout: (send_timeout || timeout)
83
+ send_timeout: (send_timeout || timeout),
84
+ max_elapsed_time: max_elapsed_time,
85
+ base_interval: base_interval,
86
+ max_interval: max_interval,
87
+ multiplier: multiplier
78
88
  end
79
89
 
80
90
  ##
@@ -100,6 +110,11 @@ module Google
100
110
  # * `https://www.googleapis.com/auth/devstorage.full_control`
101
111
  # @param [Integer] retries Number of times to retry requests on server
102
112
  # error. The default value is `3`. Optional.
113
+ # @param [Integer] max_elapsed_time Total time in seconds that requests are allowed to keep being retried.
114
+ # @param [Float] base_interval The initial interval in seconds between tries.
115
+ # @param [Integer] max_interval The maximum interval in seconds that any individual retry can reach.
116
+ # @param [Integer] multiplier Each successive interval grows by this factor. A multipler of 1.5 means the next
117
+ # interval will be 1.5x the current interval.
103
118
  # @param [Integer] timeout (default timeout) The max duration, in seconds, to wait before timing out. Optional.
104
119
  # If left blank, the wait will be at most the time permitted by the underlying HTTP/RPC protocol.
105
120
  # @param [Integer] open_timeout How long, in seconds, before failed connections time out. Optional.
@@ -118,7 +133,8 @@ module Google
118
133
  # file = bucket.file "path/to/my-file.ext"
119
134
  #
120
135
  def self.storage project_id = nil, credentials = nil, scope: nil,
121
- retries: nil, timeout: nil, open_timeout: nil, read_timeout: nil, send_timeout: nil
136
+ retries: nil, timeout: nil, open_timeout: nil, read_timeout: nil, send_timeout: nil,
137
+ max_elapsed_time: nil, base_interval: nil, max_interval: nil, multiplier: nil
122
138
  require "google/cloud/storage"
123
139
  Google::Cloud::Storage.new project_id: project_id,
124
140
  credentials: credentials,
@@ -127,12 +143,17 @@ module Google
127
143
  timeout: timeout,
128
144
  open_timeout: (open_timeout || timeout),
129
145
  read_timeout: (read_timeout || timeout),
130
- send_timeout: (send_timeout || timeout)
146
+ send_timeout: (send_timeout || timeout),
147
+ max_elapsed_time: max_elapsed_time,
148
+ base_interval: base_interval,
149
+ max_interval: max_interval,
150
+ multiplier: multiplier
131
151
  end
132
152
  end
133
153
  end
134
154
 
135
155
  # Set the default storage configuration
156
+ # rubocop:disable Metrics/BlockLength
136
157
  Google::Cloud.configure.add_config! :storage do |config|
137
158
  default_project = Google::Cloud::Config.deferred do
138
159
  ENV["STORAGE_PROJECT"]
@@ -153,6 +174,10 @@ Google::Cloud.configure.add_config! :storage do |config|
153
174
  config.add_field! :scope, nil, match: [String, Array]
154
175
  config.add_field! :quota_project, nil, match: String
155
176
  config.add_field! :retries, nil, match: Integer
177
+ config.add_field! :max_elapsed_time, nil, match: Integer
178
+ config.add_field! :base_interval, nil, match: Float
179
+ config.add_field! :max_interval, nil, match: Integer
180
+ config.add_field! :multiplier, nil, match: Integer
156
181
  config.add_field! :timeout, nil, match: Integer
157
182
  config.add_field! :open_timeout, nil, match: Integer
158
183
  config.add_field! :read_timeout, nil, match: Integer
@@ -160,3 +185,4 @@ Google::Cloud.configure.add_config! :storage do |config|
160
185
  # TODO: Remove once discovery document is updated.
161
186
  config.add_field! :endpoint, "https://storage.googleapis.com/", match: String
162
187
  end
188
+ # rubocop:enable Metrics/BlockLength
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-cloud-storage
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.36.1
4
+ version: 1.38.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Moore
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-02-11 00:00:00.000000000 Z
12
+ date: 2022-08-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: google-cloud-core
@@ -45,14 +45,14 @@ dependencies:
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: '0.1'
48
+ version: 0.17.0
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: '0.1'
55
+ version: 0.17.0
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: googleauth
58
58
  requirement: !ruby/object:Gem::Requirement
@@ -135,14 +135,14 @@ dependencies:
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: '5.10'
138
+ version: '5.16'
139
139
  type: :development
140
140
  prerelease: false
141
141
  version_requirements: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: '5.10'
145
+ version: '5.16'
146
146
  - !ruby/object:Gem::Dependency
147
147
  name: minitest-autotest
148
148
  requirement: !ruby/object:Gem::Requirement
@@ -318,7 +318,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
318
318
  - !ruby/object:Gem::Version
319
319
  version: '0'
320
320
  requirements: []
321
- rubygems_version: 3.3.5
321
+ rubygems_version: 3.3.14
322
322
  signing_key:
323
323
  specification_version: 4
324
324
  summary: API Client library for Google Cloud Storage