google-cloud-storage 1.36.2 → 1.44.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 +4 -4
- data/CHANGELOG.md +56 -0
- data/OVERVIEW.md +32 -0
- data/lib/google/cloud/storage/bucket/acl.rb +28 -26
- data/lib/google/cloud/storage/bucket/lifecycle.rb +88 -10
- data/lib/google/cloud/storage/bucket.rb +83 -3
- 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/project.rb +14 -5
- data/lib/google/cloud/storage/service.rb +223 -226
- 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 +21 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7829a0c2c9afddc17d897bd33e73af95e922a4767bfd6d6e8474eec0bac46194
|
4
|
+
data.tar.gz: 41f4328eb840bb9f2373cd291e2271e95d6f066db1a0dd62dbb7354e9e9c8c0e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec55a9d4632ee6f5d3637e6b4dc5d156ba45fc01da7b20d7f2e69a1fa4945d55d300385ee6aafba2244edcdf8fe0f36be1340adb28c074920cfad4eca667af21
|
7
|
+
data.tar.gz: 2194c91da01d5719d35756e3a9e1aceb49bfd9e15fb0466ddd8a7c4fae64074e06be41ea14437d0ed8698c777ab7c81f5ea6d90d5932336603c7dd99c5907558
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,61 @@
|
|
1
1
|
# Release History
|
2
2
|
|
3
|
+
### 1.44.0 (2022-11-02)
|
4
|
+
|
5
|
+
#### Features
|
6
|
+
|
7
|
+
* support autoclass
|
8
|
+
|
9
|
+
### 1.43.0 (2022-09-30)
|
10
|
+
|
11
|
+
#### Features
|
12
|
+
|
13
|
+
* Add retry conformance test ([#18230](https://github.com/googleapis/google-cloud-ruby/issues/18230))
|
14
|
+
|
15
|
+
### 1.42.0 (2022-09-21)
|
16
|
+
|
17
|
+
#### Features
|
18
|
+
|
19
|
+
* send invocation_id header in all requests ([#19161](https://github.com/googleapis/google-cloud-ruby/issues/19161))
|
20
|
+
|
21
|
+
### 1.41.0 (2022-09-16)
|
22
|
+
|
23
|
+
#### Features
|
24
|
+
|
25
|
+
* add retry support for non-idempotent operations ([#19134](https://github.com/googleapis/google-cloud-ruby/issues/19134))
|
26
|
+
#### Bug Fixes
|
27
|
+
|
28
|
+
* Correct options checks in retry operations ([#19135](https://github.com/googleapis/google-cloud-ruby/issues/19135))
|
29
|
+
* Update api for bucket update ([#19110](https://github.com/googleapis/google-cloud-ruby/issues/19110))
|
30
|
+
|
31
|
+
### 1.40.0 (2022-09-13)
|
32
|
+
|
33
|
+
#### Features
|
34
|
+
|
35
|
+
* Update all patch bucket helper methods to accept preconditions ([#19117](https://github.com/googleapis/google-cloud-ruby/issues/19117))
|
36
|
+
|
37
|
+
### 1.39.0 (2022-08-24)
|
38
|
+
|
39
|
+
#### Features
|
40
|
+
|
41
|
+
* add support for conditional idempotent operations ([#18834](https://github.com/googleapis/google-cloud-ruby/issues/18834))
|
42
|
+
|
43
|
+
### 1.38.0 (2022-07-31)
|
44
|
+
|
45
|
+
#### Features
|
46
|
+
|
47
|
+
* Add support for dual region gcs buckets ([#18862](https://github.com/googleapis/google-cloud-ruby/issues/18862))
|
48
|
+
|
49
|
+
### 1.37.0 (2022-06-30)
|
50
|
+
|
51
|
+
#### Features
|
52
|
+
|
53
|
+
* support OLM Prefix/Suffix ([#18190](https://github.com/googleapis/google-cloud-ruby/issues/18190))
|
54
|
+
* allow retry options to be configurable on client initialization ([#18332](https://github.com/googleapis/google-cloud-ruby/issues/18332))
|
55
|
+
#### Bug Fixes
|
56
|
+
|
57
|
+
* update object path parsing to handle hashes in them
|
58
|
+
|
3
59
|
### 1.36.2 (2022-04-20)
|
4
60
|
|
5
61
|
#### Documentation
|
data/OVERVIEW.md
CHANGED
@@ -563,6 +563,38 @@ require "google/cloud/storage"
|
|
563
563
|
storage = Google::Cloud::Storage.new retries: 10, timeout: 120
|
564
564
|
```
|
565
565
|
|
566
|
+
The library by default retries all API requests which are always idempotent on a
|
567
|
+
"transient" error.
|
568
|
+
|
569
|
+
For API requests which are idempotent only if the some conditions are satisfied
|
570
|
+
(For ex. a file has the same "generation"), the library retries only if the
|
571
|
+
condition is specified.
|
572
|
+
|
573
|
+
Rather than using this default behaviour, you may choose to disable the retries
|
574
|
+
on your own.
|
575
|
+
|
576
|
+
You can pass `retries` as `0` to disable retries for all operations regardless
|
577
|
+
of their idempotencies.
|
578
|
+
|
579
|
+
```ruby
|
580
|
+
require "google/cloud/storage"
|
581
|
+
|
582
|
+
storage = Google::Cloud::Storage.new retries: 0
|
583
|
+
```
|
584
|
+
|
585
|
+
You can also disable retries for a particular operation by passing `retries` as
|
586
|
+
`0` in the `options` field.
|
587
|
+
|
588
|
+
```ruby
|
589
|
+
require "google/cloud/storage"
|
590
|
+
|
591
|
+
storage = Google::Cloud::Storage.new
|
592
|
+
service = storage.service
|
593
|
+
service.get_bucket bucket_name, options: {retries: 0}
|
594
|
+
```
|
595
|
+
|
596
|
+
For those API requests which are never idempotent, the library passes retries=0 by default, suppressing any retries.
|
597
|
+
|
566
598
|
See the [Storage status and error
|
567
599
|
codes](https://cloud.google.com/storage/docs/json_api/v1/status-codes)
|
568
600
|
for a list of error conditions.
|
@@ -349,8 +349,8 @@ module Google
|
|
349
349
|
#
|
350
350
|
# bucket.acl.auth!
|
351
351
|
#
|
352
|
-
def auth!
|
353
|
-
update_predefined_acl! "authenticatedRead"
|
352
|
+
def auth! if_metageneration_match: nil
|
353
|
+
update_predefined_acl! "authenticatedRead", if_metageneration_match: if_metageneration_match
|
354
354
|
end
|
355
355
|
alias authenticatedRead! auth!
|
356
356
|
alias auth_read! auth!
|
@@ -370,8 +370,8 @@ module Google
|
|
370
370
|
#
|
371
371
|
# bucket.acl.private!
|
372
372
|
#
|
373
|
-
def private!
|
374
|
-
update_predefined_acl! "private"
|
373
|
+
def private! if_metageneration_match: nil
|
374
|
+
update_predefined_acl! "private", if_metageneration_match: if_metageneration_match
|
375
375
|
end
|
376
376
|
|
377
377
|
##
|
@@ -387,8 +387,8 @@ module Google
|
|
387
387
|
#
|
388
388
|
# bucket.acl.project_private!
|
389
389
|
#
|
390
|
-
def project_private!
|
391
|
-
update_predefined_acl! "projectPrivate"
|
390
|
+
def project_private! if_metageneration_match: nil
|
391
|
+
update_predefined_acl! "projectPrivate", if_metageneration_match: if_metageneration_match
|
392
392
|
end
|
393
393
|
alias projectPrivate! project_private!
|
394
394
|
|
@@ -405,8 +405,8 @@ module Google
|
|
405
405
|
#
|
406
406
|
# bucket.acl.public!
|
407
407
|
#
|
408
|
-
def public!
|
409
|
-
update_predefined_acl! "publicRead"
|
408
|
+
def public! if_metageneration_match: nil
|
409
|
+
update_predefined_acl! "publicRead", if_metageneration_match: if_metageneration_match
|
410
410
|
end
|
411
411
|
alias publicRead! public!
|
412
412
|
alias public_read! public!
|
@@ -423,8 +423,8 @@ module Google
|
|
423
423
|
#
|
424
424
|
# bucket.acl.public_write!
|
425
425
|
#
|
426
|
-
def public_write!
|
427
|
-
update_predefined_acl! "publicReadWrite"
|
426
|
+
def public_write! if_metageneration_match: nil
|
427
|
+
update_predefined_acl! "publicReadWrite", if_metageneration_match: if_metageneration_match
|
428
428
|
end
|
429
429
|
alias publicReadWrite! public_write!
|
430
430
|
|
@@ -437,9 +437,10 @@ module Google
|
|
437
437
|
self
|
438
438
|
end
|
439
439
|
|
440
|
-
def update_predefined_acl! acl_role
|
440
|
+
def update_predefined_acl! acl_role, if_metageneration_match: nil
|
441
441
|
@service.patch_bucket @bucket, predefined_acl: acl_role,
|
442
|
-
user_project: user_project
|
442
|
+
user_project: user_project,
|
443
|
+
if_metageneration_match: if_metageneration_match
|
443
444
|
clear!
|
444
445
|
end
|
445
446
|
|
@@ -714,8 +715,8 @@ module Google
|
|
714
715
|
#
|
715
716
|
# bucket.default_acl.auth!
|
716
717
|
#
|
717
|
-
def auth!
|
718
|
-
update_predefined_default_acl! "authenticatedRead"
|
718
|
+
def auth! if_metageneration_match: nil
|
719
|
+
update_predefined_default_acl! "authenticatedRead", if_metageneration_match: if_metageneration_match
|
719
720
|
end
|
720
721
|
alias authenticatedRead! auth!
|
721
722
|
alias auth_read! auth!
|
@@ -735,8 +736,8 @@ module Google
|
|
735
736
|
#
|
736
737
|
# bucket.default_acl.owner_full!
|
737
738
|
#
|
738
|
-
def owner_full!
|
739
|
-
update_predefined_default_acl! "bucketOwnerFullControl"
|
739
|
+
def owner_full! if_metageneration_match: nil
|
740
|
+
update_predefined_default_acl! "bucketOwnerFullControl", if_metageneration_match: if_metageneration_match
|
740
741
|
end
|
741
742
|
alias bucketOwnerFullControl! owner_full!
|
742
743
|
|
@@ -753,8 +754,8 @@ module Google
|
|
753
754
|
#
|
754
755
|
# bucket.default_acl.owner_read!
|
755
756
|
#
|
756
|
-
def owner_read!
|
757
|
-
update_predefined_default_acl! "bucketOwnerRead"
|
757
|
+
def owner_read! if_metageneration_match: nil
|
758
|
+
update_predefined_default_acl! "bucketOwnerRead", if_metageneration_match: if_metageneration_match
|
758
759
|
end
|
759
760
|
alias bucketOwnerRead! owner_read!
|
760
761
|
|
@@ -771,8 +772,8 @@ module Google
|
|
771
772
|
#
|
772
773
|
# bucket.default_acl.private!
|
773
774
|
#
|
774
|
-
def private!
|
775
|
-
update_predefined_default_acl! "private"
|
775
|
+
def private! if_metageneration_match: nil
|
776
|
+
update_predefined_default_acl! "private", if_metageneration_match: if_metageneration_match
|
776
777
|
end
|
777
778
|
|
778
779
|
##
|
@@ -788,8 +789,8 @@ module Google
|
|
788
789
|
#
|
789
790
|
# bucket.default_acl.project_private!
|
790
791
|
#
|
791
|
-
def project_private!
|
792
|
-
update_predefined_default_acl! "projectPrivate"
|
792
|
+
def project_private! if_metageneration_match: nil
|
793
|
+
update_predefined_default_acl! "projectPrivate", if_metageneration_match: if_metageneration_match
|
793
794
|
end
|
794
795
|
alias projectPrivate! project_private!
|
795
796
|
|
@@ -806,8 +807,8 @@ module Google
|
|
806
807
|
#
|
807
808
|
# bucket.default_acl.public!
|
808
809
|
#
|
809
|
-
def public!
|
810
|
-
update_predefined_default_acl! "publicRead"
|
810
|
+
def public! if_metageneration_match: nil
|
811
|
+
update_predefined_default_acl! "publicRead", if_metageneration_match: if_metageneration_match
|
811
812
|
end
|
812
813
|
alias publicRead! public!
|
813
814
|
alias public_read! public!
|
@@ -820,9 +821,10 @@ module Google
|
|
820
821
|
self
|
821
822
|
end
|
822
823
|
|
823
|
-
def update_predefined_default_acl! acl_role
|
824
|
+
def update_predefined_default_acl! acl_role, if_metageneration_match: nil
|
824
825
|
@service.patch_bucket @bucket, predefined_default_acl: acl_role,
|
825
|
-
user_project: user_project
|
826
|
+
user_project: user_project,
|
827
|
+
if_metageneration_match: if_metageneration_match
|
826
828
|
clear!
|
827
829
|
end
|
828
830
|
|
@@ -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
|
|
@@ -109,6 +109,15 @@ module Google
|
|
109
109
|
@gapi.id
|
110
110
|
end
|
111
111
|
|
112
|
+
##
|
113
|
+
# The autoclass configuration of the bucket
|
114
|
+
#
|
115
|
+
# @return [Google::Apis::StorageV1::Bucket::Autoclass]
|
116
|
+
#
|
117
|
+
def autoclass
|
118
|
+
@gapi.autoclass
|
119
|
+
end
|
120
|
+
|
112
121
|
##
|
113
122
|
# The name of the bucket.
|
114
123
|
#
|
@@ -301,6 +310,20 @@ module Google
|
|
301
310
|
@gapi.location_type
|
302
311
|
end
|
303
312
|
|
313
|
+
##
|
314
|
+
# Returns the list of regional locations for custom dual-region buckets.
|
315
|
+
#
|
316
|
+
# @return [String, nil] Returns nil if the property has not been set before creation,
|
317
|
+
# if the bucket's resource has not been loaded from the server,
|
318
|
+
# or if the bucket is not a dual-regions bucket.
|
319
|
+
|
320
|
+
# @see https://cloud.google.com/storage/docs/json_api/v1/buckets and
|
321
|
+
# https://cloud.google.com/storage/docs/locations
|
322
|
+
#
|
323
|
+
def data_locations
|
324
|
+
@gapi.custom_placement_config&.data_locations
|
325
|
+
end
|
326
|
+
|
304
327
|
##
|
305
328
|
# The destination bucket name for the bucket's logs.
|
306
329
|
#
|
@@ -393,6 +416,43 @@ module Google
|
|
393
416
|
patch_gapi! :storage_class
|
394
417
|
end
|
395
418
|
|
419
|
+
##
|
420
|
+
# Whether Autoclass is enabled for the bucket.
|
421
|
+
#
|
422
|
+
# @return [Boolean]
|
423
|
+
#
|
424
|
+
def autoclass_enabled
|
425
|
+
@gapi.autoclass&.enabled?
|
426
|
+
end
|
427
|
+
|
428
|
+
##
|
429
|
+
# Toggle time of the autoclass
|
430
|
+
#
|
431
|
+
# @return [DateTime]
|
432
|
+
#
|
433
|
+
def autoclass_toggle_time
|
434
|
+
@gapi.autoclass&.toggle_time
|
435
|
+
end
|
436
|
+
|
437
|
+
##
|
438
|
+
# Updates bucket's autoclass configuration. This defines the default class for objects in the
|
439
|
+
# bucket and down/up-grades the storage class of objects based on the access patterns.
|
440
|
+
# Accepted values are `:false`, and `:true`.
|
441
|
+
#
|
442
|
+
# For more information, see [Storage
|
443
|
+
# Classes](https://cloud.google.com/storage/docs/using-autoclass).
|
444
|
+
#
|
445
|
+
# Note: Only patch requests that disable autoclass are currently supported.
|
446
|
+
# To enable autoclass, you must set it at bucket creation time.
|
447
|
+
#
|
448
|
+
# @param [Boolean] toggle for autoclass configuration of the bucket.
|
449
|
+
#
|
450
|
+
def autoclass_enabled= toggle
|
451
|
+
@gapi.autoclass ||= API::Bucket::Autoclass.new
|
452
|
+
@gapi.autoclass.enabled = toggle
|
453
|
+
patch_gapi! :autoclass
|
454
|
+
end
|
455
|
+
|
396
456
|
##
|
397
457
|
# Whether [Object
|
398
458
|
# Versioning](https://cloud.google.com/storage/docs/object-versioning)
|
@@ -1156,9 +1216,9 @@ module Google
|
|
1156
1216
|
updater.check_for_mutable_cors!
|
1157
1217
|
updater.check_for_mutable_lifecycle!
|
1158
1218
|
return if updater.updates.empty?
|
1159
|
-
|
1160
|
-
|
1161
|
-
|
1219
|
+
update_gapi! updater.updates,
|
1220
|
+
if_metageneration_match: if_metageneration_match,
|
1221
|
+
if_metageneration_not_match: if_metageneration_not_match
|
1162
1222
|
end
|
1163
1223
|
|
1164
1224
|
##
|
@@ -2891,6 +2951,26 @@ module Google
|
|
2891
2951
|
self
|
2892
2952
|
end
|
2893
2953
|
|
2954
|
+
def update_gapi! attributes,
|
2955
|
+
if_metageneration_match: nil,
|
2956
|
+
if_metageneration_not_match: nil
|
2957
|
+
attributes = Array(attributes)
|
2958
|
+
attributes.flatten!
|
2959
|
+
return if attributes.empty?
|
2960
|
+
ensure_service!
|
2961
|
+
update_args = Hash[attributes.map do |attr|
|
2962
|
+
[attr, @gapi.send(attr)]
|
2963
|
+
end]
|
2964
|
+
update_gapi = API::Bucket.new(**update_args)
|
2965
|
+
@gapi = service.update_bucket name,
|
2966
|
+
update_gapi,
|
2967
|
+
if_metageneration_match: if_metageneration_match,
|
2968
|
+
if_metageneration_not_match: if_metageneration_not_match,
|
2969
|
+
user_project: user_project
|
2970
|
+
@lazy = nil
|
2971
|
+
self
|
2972
|
+
end
|
2973
|
+
|
2894
2974
|
##
|
2895
2975
|
# Raise an error if the file is not found.
|
2896
2976
|
def ensure_io_or_file_exists! file
|
@@ -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
|
@@ -290,9 +290,9 @@ module Google
|
|
290
290
|
# access, and allUsers get READER access.
|
291
291
|
# @param [String] location The location of the bucket. Optional.
|
292
292
|
# If not passed, the default location, 'US', will be used.
|
293
|
-
# If specifying a dual-region location, the
|
294
|
-
#
|
295
|
-
# [Storage
|
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).
|
296
296
|
# @param [String] logging_bucket The destination bucket for the bucket's
|
297
297
|
# logs. For more information, see [Access
|
298
298
|
# Logs](https://cloud.google.com/storage/docs/access-logs).
|
@@ -327,6 +327,11 @@ module Google
|
|
327
327
|
# other than the current project, and that project is authorized for
|
328
328
|
# the currently authenticated service account, transit costs will be
|
329
329
|
# billed to the given project. The default is `nil`.
|
330
|
+
# @param [Boolean] autoclass_enabled The bucket's autoclass configuration.
|
331
|
+
# Buckets can have either StorageClass OLM rules or Autoclass, but
|
332
|
+
# not both. When Autoclass is enabled on a bucket, adding StorageClass
|
333
|
+
# OLM rules will result in failure. For more information, see
|
334
|
+
# [Autoclass](https://cloud.google.com/storage/docs/autoclass).
|
330
335
|
#
|
331
336
|
# The value provided will be applied to all operations on the returned
|
332
337
|
# bucket instance and its files.
|
@@ -367,6 +372,7 @@ module Google
|
|
367
372
|
acl: nil,
|
368
373
|
default_acl: nil,
|
369
374
|
location: nil,
|
375
|
+
custom_placement_config: nil,
|
370
376
|
storage_class: nil,
|
371
377
|
logging_bucket: nil,
|
372
378
|
logging_prefix: nil,
|
@@ -374,16 +380,19 @@ module Google
|
|
374
380
|
website_404: nil,
|
375
381
|
versioning: nil,
|
376
382
|
requester_pays: nil,
|
377
|
-
user_project: nil
|
383
|
+
user_project: nil,
|
384
|
+
autoclass_enabled: false
|
378
385
|
params = {
|
379
386
|
name: bucket_name,
|
380
|
-
location: location
|
387
|
+
location: location,
|
388
|
+
custom_placement_config: custom_placement_config
|
381
389
|
}.delete_if { |_, v| v.nil? }
|
382
390
|
new_bucket = Google::Apis::StorageV1::Bucket.new(**params)
|
383
391
|
storage_class = storage_class_for storage_class
|
384
392
|
updater = Bucket::Updater.new(new_bucket).tap do |b|
|
385
393
|
b.logging_bucket = logging_bucket unless logging_bucket.nil?
|
386
394
|
b.logging_prefix = logging_prefix unless logging_prefix.nil?
|
395
|
+
b.autoclass_enabled = autoclass_enabled
|
387
396
|
b.storage_class = storage_class unless storage_class.nil?
|
388
397
|
b.website_main = website_main unless website_main.nil?
|
389
398
|
b.website_404 = website_404 unless website_404.nil?
|