google-cloud-storage 1.36.2 → 1.37.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/lib/google/cloud/storage/bucket/lifecycle.rb +88 -10
- data/lib/google/cloud/storage/file/signer_v2.rb +1 -1
- data/lib/google/cloud/storage/file/signer_v4.rb +1 -1
- data/lib/google/cloud/storage/service.rb +9 -1
- data/lib/google/cloud/storage/version.rb +1 -1
- data/lib/google/cloud/storage.rb +43 -14
- data/lib/google-cloud-storage.rb +31 -5
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4978faf0cccd7a12e58085b8a5eb44a0bdfb54446c17e5c377ef66e443a93671
|
4
|
+
data.tar.gz: 7487e0b96eabba4902ebc21992b651e08261523175d49c4477e820e941757be3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e0728273ad8a402031e43930695f11c0f908c7379a2a80c28b68f6278034f8957a47f980161aa490ffa261e16559b699eabd5526f7304176167493e8bf1b7c0
|
7
|
+
data.tar.gz: 3cebdabf2dbefc4f8f4a23f8c6df43b25770cda527c0fc502e7a2cd8ab9ac9cfa8a82a1fc108c28168becc6e9f9a624a5c588c5ef8657f1f83b2dfafecd9f413
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# Release History
|
2
2
|
|
3
|
+
### 1.37.0 (2022-06-30)
|
4
|
+
|
5
|
+
#### Features
|
6
|
+
|
7
|
+
* support OLM Prefix/Suffix ([#18190](https://github.com/googleapis/google-cloud-ruby/issues/18190))
|
8
|
+
* allow retry options to be configurable on client initialization ([#18332](https://github.com/googleapis/google-cloud-ruby/issues/18332))
|
9
|
+
#### Bug Fixes
|
10
|
+
|
11
|
+
* update object path parsing to handle hashes in them
|
12
|
+
|
3
13
|
### 1.36.2 (2022-04-20)
|
4
14
|
|
5
15
|
#### 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
|
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
|
|
@@ -48,7 +48,7 @@ module Google
|
|
48
48
|
#
|
49
49
|
def ext_path
|
50
50
|
path = "/#{@bucket}/#{@path}"
|
51
|
-
escaped = Addressable::URI.
|
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.
|
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
|
@@ -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
|
data/lib/google/cloud/storage.rb
CHANGED
@@ -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
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
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.
|
data/lib/google-cloud-storage.rb
CHANGED
@@ -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
|
-
#
|
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.
|
4
|
+
version: 1.37.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-
|
12
|
+
date: 2022-06-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: google-cloud-core
|
@@ -135,14 +135,14 @@ dependencies:
|
|
135
135
|
requirements:
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: '5.
|
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.
|
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.
|
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
|