google-cloud-storage 1.30.0 → 1.39.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -191,7 +191,7 @@ module Google
191
191
  # @return [Integer]
192
192
  #
193
193
  def size
194
- @gapi.size.to_i if @gapi.size
194
+ @gapi.size&.to_i
195
195
  end
196
196
 
197
197
  ##
@@ -260,6 +260,9 @@ module Google
260
260
  # directive for the file data. If omitted, and the file is accessible
261
261
  # to all anonymous users, the default will be `public, max-age=3600`.
262
262
  #
263
+ # To pass generation and/or metageneration preconditions, call this
264
+ # method within a block passed to {#update}.
265
+ #
263
266
  # @param [String] cache_control The Cache-Control directive.
264
267
  #
265
268
  def cache_control= cache_control
@@ -281,6 +284,9 @@ module Google
281
284
  # Updates the [Content-Disposition](https://tools.ietf.org/html/rfc6266)
282
285
  # of the file data.
283
286
  #
287
+ # To pass generation and/or metageneration preconditions, call this
288
+ # method within a block passed to {#update}.
289
+ #
284
290
  # @param [String] content_disposition The Content-Disposition of the
285
291
  # file.
286
292
  #
@@ -305,6 +311,9 @@ module Google
305
311
  # ](https://tools.ietf.org/html/rfc7231#section-3.1.2.2) of the file
306
312
  # data.
307
313
  #
314
+ # To pass generation and/or metageneration preconditions, call this
315
+ # method within a block passed to {#update}.
316
+ #
308
317
  # @param [String] content_encoding The Content-Encoding of the file.
309
318
  #
310
319
  def content_encoding= content_encoding
@@ -326,6 +335,9 @@ module Google
326
335
  # Updates the [Content-Language](http://tools.ietf.org/html/bcp47) of
327
336
  # the file data.
328
337
  #
338
+ # To pass generation and/or metageneration preconditions, call this
339
+ # method within a block passed to {#update}.
340
+ #
329
341
  # @param [String] content_language The Content-Language of the file.
330
342
  #
331
343
  def content_language= content_language
@@ -348,6 +360,9 @@ module Google
348
360
  # [Content-Type](https://tools.ietf.org/html/rfc2616#section-14.17) of
349
361
  # the file data.
350
362
  #
363
+ # To pass generation and/or metageneration preconditions, call this
364
+ # method within a block passed to {#update}.
365
+ #
351
366
  # @param [String] content_type The Content-Type of the file.
352
367
  #
353
368
  def content_type= content_type
@@ -370,6 +385,9 @@ module Google
370
385
  # future. If custom_time must be unset, you must either perform a rewrite
371
386
  # operation, or upload the data again and create a new file.
372
387
  #
388
+ # To pass generation and/or metageneration preconditions, call this
389
+ # method within a block passed to {#update}.
390
+ #
373
391
  # @param [DateTime] custom_time A custom time specified by the user
374
392
  # for the file.
375
393
  #
@@ -396,6 +414,9 @@ module Google
396
414
  # string values that will returned with requests for the file as
397
415
  # "x-goog-meta-" response headers.
398
416
  #
417
+ # To pass generation and/or metageneration preconditions, call this
418
+ # method within a block passed to {#update}.
419
+ #
399
420
  # @param [Hash(String => String)] metadata The user-provided metadata,
400
421
  # in key/value pairs.
401
422
  #
@@ -465,6 +486,9 @@ module Google
465
486
  # The default value is the default storage class for the bucket. See
466
487
  # {Bucket#storage_class}.
467
488
  #
489
+ # To pass generation and/or metageneration preconditions, call this
490
+ # method within a block passed to {#update}.
491
+ #
468
492
  # @param [Symbol, String] storage_class Storage class of the file.
469
493
  #
470
494
  def storage_class= storage_class
@@ -505,6 +529,9 @@ module Google
505
529
  # removed, the file's `retention_expires_at` date is not changed. The
506
530
  # default value is `false`.
507
531
  #
532
+ # To pass generation and/or metageneration preconditions, call this
533
+ # method within a block passed to {#update}.
534
+ #
508
535
  # See {#retention_expires_at}.
509
536
  #
510
537
  # @example
@@ -533,6 +560,9 @@ module Google
533
560
  #
534
561
  # See {#retention_expires_at}.
535
562
  #
563
+ # To pass generation and/or metageneration preconditions, call this
564
+ # method within a block passed to {#update}.
565
+ #
536
566
  # @example
537
567
  # require "google/cloud/storage"
538
568
  #
@@ -643,6 +673,9 @@ module Google
643
673
  # holds released prior to the effective date of the new policy may
644
674
  # have already been deleted by the user.
645
675
  #
676
+ # To pass generation and/or metageneration preconditions, call this
677
+ # method within a block passed to {#update}.
678
+ #
646
679
  # @example
647
680
  # require "google/cloud/storage"
648
681
  #
@@ -681,6 +714,9 @@ module Google
681
714
  # {Bucket#default_event_based_hold?} and
682
715
  # {Bucket#default_event_based_hold=}.
683
716
  #
717
+ # To pass generation and/or metageneration preconditions, call this
718
+ # method within a block passed to {#update}.
719
+ #
684
720
  # @example
685
721
  # require "google/cloud/storage"
686
722
  #
@@ -774,6 +810,22 @@ module Google
774
810
  # accessible in the block is completely mutable and will be included in the
775
811
  # request.
776
812
  #
813
+ # @param [Integer] generation Select a specific revision of the file to
814
+ # update. The default is the latest version.
815
+ # @param [Integer] if_generation_match Makes the operation conditional
816
+ # on whether the file's current generation matches the given value.
817
+ # Setting to 0 makes the operation succeed only if there are no live
818
+ # versions of the file.
819
+ # @param [Integer] if_generation_not_match Makes the operation conditional
820
+ # on whether the file's current generation does not match the given
821
+ # value. If no live file exists, the precondition fails. Setting to 0
822
+ # makes the operation succeed only if there is a live version of the file.
823
+ # @param [Integer] if_metageneration_match Makes the operation conditional
824
+ # on whether the file's current metageneration matches the given value.
825
+ # @param [Integer] if_metageneration_not_match Makes the operation
826
+ # conditional on whether the file's current metageneration does not
827
+ # match the given value.
828
+ #
777
829
  # @yield [file] a block yielding a delegate object for updating the file
778
830
  #
779
831
  # @example
@@ -796,11 +848,34 @@ module Google
796
848
  # f.metadata["score"] = "10"
797
849
  # end
798
850
  #
799
- def update
851
+ # @example With a `if_generation_match` precondition:
852
+ # require "google/cloud/storage"
853
+ #
854
+ # storage = Google::Cloud::Storage.new
855
+ #
856
+ # bucket = storage.bucket "my-bucket"
857
+ #
858
+ # file = bucket.file "path/to/my-file.ext"
859
+ #
860
+ # file.update if_generation_match: 1602263125261858 do |f|
861
+ # f.cache_control = "private, max-age=0, no-cache"
862
+ # end
863
+ #
864
+ def update generation: nil,
865
+ if_generation_match: nil,
866
+ if_generation_not_match: nil,
867
+ if_metageneration_match: nil,
868
+ if_metageneration_not_match: nil
800
869
  updater = Updater.new gapi
801
870
  yield updater
802
871
  updater.check_for_changed_metadata!
803
- update_gapi! updater.updates unless updater.updates.empty?
872
+ return if updater.updates.empty?
873
+ update_gapi! updater.updates,
874
+ generation: generation,
875
+ if_generation_match: if_generation_match,
876
+ if_generation_not_match: if_generation_not_match,
877
+ if_metageneration_match: if_metageneration_match,
878
+ if_metageneration_not_match: if_metageneration_not_match
804
879
  end
805
880
 
806
881
  ##
@@ -1138,6 +1213,27 @@ module Google
1138
1213
  # access, and allUsers get READER access.
1139
1214
  # @param [Integer] generation Select a specific revision of the file to
1140
1215
  # rewrite. The default is the latest version.
1216
+ # @param [Integer] if_generation_match Makes the operation conditional
1217
+ # on whether the destination file's current generation matches the given value.
1218
+ # Setting to 0 makes the operation succeed only if there are no live
1219
+ # versions of the file.
1220
+ # @param [Integer] if_generation_not_match Makes the operation conditional
1221
+ # on whether the destination file's current generation does not match the given
1222
+ # value. If no live file exists, the precondition fails. Setting to 0
1223
+ # makes the operation succeed only if there is a live version of the file.
1224
+ # @param [Integer] if_metageneration_match Makes the operation conditional
1225
+ # on whether the destination file's current metageneration matches the given value.
1226
+ # @param [Integer] if_metageneration_not_match Makes the operation
1227
+ # conditional on whether the destination file's current metageneration does not
1228
+ # match the given value.
1229
+ # @param [Integer] if_source_generation_match Makes the operation conditional on
1230
+ # whether the source object's current generation matches the given value.
1231
+ # @param [Integer] if_source_generation_not_match Makes the operation conditional
1232
+ # on whether the source object's current generation does not match the given value.
1233
+ # @param [Integer] if_source_metageneration_match Makes the operation conditional
1234
+ # on whether the source object's current metageneration matches the given value.
1235
+ # @param [Integer] if_source_metageneration_not_match Makes the operation conditional
1236
+ # on whether the source object's current metageneration does not match the given value.
1141
1237
  # @param [String] encryption_key Optional. The customer-supplied,
1142
1238
  # AES-256 encryption key used to decrypt the file, if the existing
1143
1239
  # file is encrypted.
@@ -1259,11 +1355,24 @@ module Google
1259
1355
  # f.metadata["rewritten_from"] = "#{file.bucket}/#{file.name}"
1260
1356
  # end
1261
1357
  #
1262
- def rewrite dest_bucket_or_path, dest_path = nil, acl: nil, generation: nil, encryption_key: nil,
1263
- new_encryption_key: nil, new_kms_key: nil, force_copy_metadata: nil
1358
+ def rewrite dest_bucket_or_path,
1359
+ dest_path = nil,
1360
+ acl: nil,
1361
+ generation: nil,
1362
+ if_generation_match: nil,
1363
+ if_generation_not_match: nil,
1364
+ if_metageneration_match: nil,
1365
+ if_metageneration_not_match: nil,
1366
+ if_source_generation_match: nil,
1367
+ if_source_generation_not_match: nil,
1368
+ if_source_metageneration_match: nil,
1369
+ if_source_metageneration_not_match: nil,
1370
+ encryption_key: nil,
1371
+ new_encryption_key: nil,
1372
+ new_kms_key: nil,
1373
+ force_copy_metadata: nil
1264
1374
  ensure_service!
1265
- dest_bucket, dest_path = fix_rewrite_args dest_bucket_or_path,
1266
- dest_path
1375
+ dest_bucket, dest_path = fix_rewrite_args dest_bucket_or_path, dest_path
1267
1376
 
1268
1377
  update_gapi = nil
1269
1378
  if block_given?
@@ -1276,9 +1385,21 @@ module Google
1276
1385
  end
1277
1386
  end
1278
1387
 
1279
- new_gapi = rewrite_gapi bucket, name, update_gapi,
1280
- new_bucket: dest_bucket, new_name: dest_path,
1281
- acl: acl, generation: generation,
1388
+ new_gapi = rewrite_gapi bucket,
1389
+ name,
1390
+ update_gapi,
1391
+ new_bucket: dest_bucket,
1392
+ new_name: dest_path,
1393
+ acl: acl,
1394
+ generation: generation,
1395
+ if_generation_match: if_generation_match,
1396
+ if_generation_not_match: if_generation_not_match,
1397
+ if_metageneration_match: if_metageneration_match,
1398
+ if_metageneration_not_match: if_metageneration_not_match,
1399
+ if_source_generation_match: if_source_generation_match,
1400
+ if_source_generation_not_match: if_source_generation_not_match,
1401
+ if_source_metageneration_match: if_source_metageneration_match,
1402
+ if_source_metageneration_not_match: if_source_metageneration_not_match,
1282
1403
  encryption_key: encryption_key,
1283
1404
  new_encryption_key: new_encryption_key,
1284
1405
  new_kms_key: new_kms_key,
@@ -1375,6 +1496,20 @@ module Google
1375
1496
  # {#generation}. The default behavior is to delete the latest version
1376
1497
  # of the file (regardless of the version to which the file is set,
1377
1498
  # which is the version returned by {#generation}.)
1499
+ # @param [Integer] if_generation_match Makes the operation conditional
1500
+ # on whether the file's current generation matches the given value.
1501
+ # Setting to 0 makes the operation succeed only if there are no live
1502
+ # versions of the file.
1503
+ # @param [Integer] if_generation_not_match Makes the operation conditional
1504
+ # on whether the file's current generation does not match the given
1505
+ # value. If no live file exists, the precondition fails. Setting to 0
1506
+ # makes the operation succeed only if there is a live version of the file.
1507
+ # @param [Integer] if_metageneration_match Makes the operation conditional
1508
+ # on whether the file's current metageneration matches the given value.
1509
+ # @param [Integer] if_metageneration_not_match Makes the operation
1510
+ # conditional on whether the file's current metageneration does not
1511
+ # match the given value.
1512
+ #
1378
1513
  # @return [Boolean] Returns `true` if the file was deleted.
1379
1514
  #
1380
1515
  # @example
@@ -1407,11 +1542,21 @@ module Google
1407
1542
  # file = bucket.file "path/to/my-file.ext"
1408
1543
  # file.delete generation: 123456
1409
1544
  #
1410
- def delete generation: nil
1545
+ def delete generation: nil,
1546
+ if_generation_match: nil,
1547
+ if_generation_not_match: nil,
1548
+ if_metageneration_match: nil,
1549
+ if_metageneration_not_match: nil
1411
1550
  generation = self.generation if generation == true
1412
1551
  ensure_service!
1413
- service.delete_file bucket, name, generation: generation,
1414
- user_project: user_project
1552
+ service.delete_file bucket,
1553
+ name,
1554
+ generation: generation,
1555
+ if_generation_match: if_generation_match,
1556
+ if_generation_not_match: if_generation_not_match,
1557
+ if_metageneration_match: if_metageneration_match,
1558
+ if_metageneration_not_match: if_metageneration_not_match,
1559
+ user_project: user_project
1415
1560
  true
1416
1561
  end
1417
1562
 
@@ -1618,11 +1763,11 @@ module Google
1618
1763
  # scopes = ["https://www.googleapis.com/auth/iam"]
1619
1764
  # iam_client.authorization = Google::Auth.get_application_default scopes
1620
1765
  #
1621
- # request = {
1622
- # "payload": string_to_sign,
1623
- # }
1766
+ # request = Google::Apis::IamcredentialsV1::SignBlobRequest.new(
1767
+ # payload: string_to_sign
1768
+ # )
1624
1769
  # resource = "projects/-/serviceAccounts/#{issuer}"
1625
- # response = iam_client.sign_service_account_blob resource, request, {}
1770
+ # response = iam_client.sign_service_account_blob resource, request
1626
1771
  # response.signed_blob
1627
1772
  # end
1628
1773
  #
@@ -1865,7 +2010,13 @@ module Google
1865
2010
  reload! generation: true
1866
2011
  end
1867
2012
 
1868
- def update_gapi! *attributes
2013
+ def update_gapi! attributes,
2014
+ generation: nil,
2015
+ if_generation_match: nil,
2016
+ if_generation_not_match: nil,
2017
+ if_metageneration_match: nil,
2018
+ if_metageneration_not_match: nil
2019
+ attributes = Array(attributes)
1869
2020
  attributes.flatten!
1870
2021
  return if attributes.empty?
1871
2022
  update_gapi = self.class.gapi_from_attrs @gapi, attributes
@@ -1873,28 +2024,67 @@ module Google
1873
2024
 
1874
2025
  ensure_service!
1875
2026
 
1876
- rewrite_attrs = %i[storage_class kms_key_name]
2027
+ rewrite_attrs = [:storage_class, :kms_key_name]
1877
2028
  @gapi = if attributes.any? { |a| rewrite_attrs.include? a }
1878
- rewrite_gapi \
1879
- bucket, name, update_gapi, user_project: user_project
2029
+ rewrite_gapi bucket,
2030
+ name,
2031
+ update_gapi,
2032
+ generation: generation,
2033
+ if_generation_match: if_generation_match,
2034
+ if_generation_not_match: if_generation_not_match,
2035
+ if_metageneration_match: if_metageneration_match,
2036
+ if_metageneration_not_match: if_metageneration_not_match,
2037
+ user_project: user_project
1880
2038
  else
1881
- service.patch_file \
1882
- bucket, name, update_gapi, user_project: user_project
2039
+ service.patch_file bucket,
2040
+ name,
2041
+ update_gapi,
2042
+ generation: generation,
2043
+ if_generation_match: if_generation_match,
2044
+ if_generation_not_match: if_generation_not_match,
2045
+ if_metageneration_match: if_metageneration_match,
2046
+ if_metageneration_not_match: if_metageneration_not_match,
2047
+ user_project: user_project
1883
2048
  end
1884
2049
  end
1885
2050
 
1886
- def rewrite_gapi bucket, name, updated_gapi,
1887
- new_bucket: nil, new_name: nil, acl: nil,
1888
- generation: nil, encryption_key: nil,
1889
- new_encryption_key: nil, new_kms_key: nil,
2051
+ def rewrite_gapi bucket,
2052
+ name,
2053
+ updated_gapi,
2054
+ new_bucket: nil,
2055
+ new_name: nil,
2056
+ acl: nil,
2057
+ generation: nil,
2058
+ if_generation_match: nil,
2059
+ if_generation_not_match: nil,
2060
+ if_metageneration_match: nil,
2061
+ if_metageneration_not_match: nil,
2062
+ if_source_generation_match: nil,
2063
+ if_source_generation_not_match: nil,
2064
+ if_source_metageneration_match: nil,
2065
+ if_source_metageneration_not_match: nil,
2066
+ encryption_key: nil,
2067
+ new_encryption_key: nil,
2068
+ new_kms_key: nil,
1890
2069
  user_project: nil
1891
2070
  new_bucket ||= bucket
1892
2071
  new_name ||= name
1893
- options = { acl: File::Acl.predefined_rule_for(acl),
1894
- generation: generation, source_key: encryption_key,
1895
- destination_key: new_encryption_key,
1896
- destination_kms_key: new_kms_key,
1897
- user_project: user_project }.delete_if { |_k, v| v.nil? }
2072
+ options = {
2073
+ acl: File::Acl.predefined_rule_for(acl),
2074
+ generation: generation,
2075
+ if_generation_match: if_generation_match,
2076
+ if_generation_not_match: if_generation_not_match,
2077
+ if_metageneration_match: if_metageneration_match,
2078
+ if_metageneration_not_match: if_metageneration_not_match,
2079
+ if_source_generation_match: if_source_generation_match,
2080
+ if_source_generation_not_match: if_source_generation_not_match,
2081
+ if_source_metageneration_match: if_source_metageneration_match,
2082
+ if_source_metageneration_not_match: if_source_metageneration_not_match,
2083
+ source_key: encryption_key,
2084
+ destination_key: new_encryption_key,
2085
+ destination_kms_key: new_kms_key,
2086
+ user_project: user_project
2087
+ }.delete_if { |_k, v| v.nil? }
1898
2088
 
1899
2089
  resp = service.rewrite_file \
1900
2090
  bucket, name, new_bucket, new_name, updated_gapi, **options
@@ -1972,6 +2162,7 @@ module Google
1972
2162
  ##
1973
2163
  # @private Create an Updater object.
1974
2164
  def initialize gapi
2165
+ super()
1975
2166
  @updates = []
1976
2167
  @gapi = gapi
1977
2168
  @metadata ||= @gapi.metadata.to_h.dup
@@ -131,17 +131,17 @@ module Google
131
131
  # puts key.access_id
132
132
  # end
133
133
  #
134
- def all request_limit: nil
134
+ def all request_limit: nil, &block
135
135
  request_limit = request_limit.to_i if request_limit
136
136
  unless block_given?
137
137
  return enum_for :all, request_limit: request_limit
138
138
  end
139
139
  results = self
140
140
  loop do
141
- results.each { |r| yield r }
141
+ results.each(&block)
142
142
  if request_limit
143
143
  request_limit -= 1
144
- break if request_limit < 0
144
+ break if request_limit.negative?
145
145
  end
146
146
  break unless results.next?
147
147
  results = results.next
@@ -89,7 +89,9 @@ module Google
89
89
  # end
90
90
  #
91
91
  class Binding
92
- attr_reader :role, :members, :condition
92
+ attr_reader :role
93
+ attr_reader :members
94
+ attr_reader :condition
93
95
 
94
96
  ##
95
97
  # Creates a Binding object.
@@ -128,8 +130,8 @@ module Google
128
130
  raise ArgumentError, "members is empty, must be provided" if @members.empty?
129
131
 
130
132
  condition = Condition.new(**condition) if condition.is_a? Hash
131
- if condition
132
- raise ArgumentError, "expected Condition, not #{condition.inspect}" unless condition.is_a? Condition
133
+ if condition && !(condition.is_a? Condition)
134
+ raise ArgumentError, "expected Condition, not #{condition.inspect}"
133
135
  end
134
136
  @condition = condition
135
137
  end
@@ -168,10 +168,10 @@ module Google
168
168
  # puts binding.role
169
169
  # end
170
170
  #
171
- def each
171
+ def each &block
172
172
  return enum_for :each unless block_given?
173
173
 
174
- @bindings.each { |binding| yield binding }
174
+ @bindings.each(&block)
175
175
  end
176
176
 
177
177
  ##
@@ -70,7 +70,9 @@ module Google
70
70
  # end
71
71
  #
72
72
  class Condition
73
- attr_reader :title, :description, :expression
73
+ attr_reader :title
74
+ attr_reader :description
75
+ attr_reader :expression
74
76
 
75
77
  ##
76
78
  # Creates a Condition object.
@@ -83,7 +85,7 @@ module Google
83
85
  # one attributes, and statements are combined using logic operators,
84
86
  # following CEL language specification. Required.
85
87
  #
86
- def initialize title:, description: nil, expression:
88
+ def initialize title:, expression:, description: nil
87
89
  @title = String title
88
90
  @description = String description
89
91
  @expression = String expression
@@ -212,8 +212,8 @@ module Google
212
212
  def deep_dup
213
213
  warn "DEPRECATED: Storage::PolicyV1#deep_dup"
214
214
  dup.tap do |p|
215
- roles_dup = p.roles.each_with_object({}) do |(k, v), memo|
216
- memo[k] = v.dup rescue value
215
+ roles_dup = p.roles.transform_values do |v|
216
+ v.dup rescue value
217
217
  end
218
218
  p.instance_variable_set :@roles, roles_dup
219
219
  end
@@ -59,7 +59,8 @@ module Google
59
59
  # post.fields["x-goog-signature"] #=> "4893a0e...cd82"
60
60
  #
61
61
  class PostObject
62
- attr_reader :url, :fields
62
+ attr_reader :url
63
+ attr_reader :fields
63
64
 
64
65
  # @private
65
66
  def initialize url, fields
@@ -165,6 +165,11 @@ module Google
165
165
  # without verifying the bucket resource exists on the Storage service.
166
166
  # Calls made on this object will raise errors if the bucket resource
167
167
  # does not exist. Default is `false`.
168
+ # @param [Integer] if_metageneration_match Makes the operation conditional
169
+ # on whether the bucket's current metageneration matches the given value.
170
+ # @param [Integer] if_metageneration_not_match Makes the operation
171
+ # conditional on whether the bucket's current metageneration does not
172
+ # match the given value.
168
173
  # @param [Boolean, String] user_project If this parameter is set to
169
174
  # `true`, transit costs for operations on the requested bucket or a
170
175
  # file it contains will be billed to the current project for this
@@ -208,12 +213,19 @@ module Google
208
213
  # user_project: "my-other-project"
209
214
  # files = bucket.files # Billed to "my-other-project"
210
215
  #
211
- def bucket bucket_name, skip_lookup: false, user_project: nil
216
+ def bucket bucket_name,
217
+ skip_lookup: false,
218
+ if_metageneration_match: nil,
219
+ if_metageneration_not_match: nil,
220
+ user_project: nil
212
221
  if skip_lookup
213
222
  return Bucket.new_lazy bucket_name, service,
214
223
  user_project: user_project
215
224
  end
216
- gapi = service.get_bucket bucket_name, user_project: user_project
225
+ gapi = service.get_bucket bucket_name,
226
+ if_metageneration_match: if_metageneration_match,
227
+ if_metageneration_not_match: if_metageneration_not_match,
228
+ user_project: user_project
217
229
  Bucket.from_gapi gapi, service, user_project: user_project
218
230
  rescue Google::Cloud::NotFoundError
219
231
  nil
@@ -276,12 +288,11 @@ module Google
276
288
  # roles.
277
289
  # * `public`, `public_read`, `publicRead` - File owner gets OWNER
278
290
  # access, and allUsers get READER access.
279
- # @param [String] location The location of the bucket. Object data for
280
- # objects in the bucket resides in physical storage within this
281
- # region. Possible values include `ASIA`, `EU`, and `US`. (See the
282
- # [developer's
283
- # guide](https://cloud.google.com/storage/docs/bucket-locations) for
284
- # 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).
285
296
  # @param [String] logging_bucket The destination bucket for the bucket's
286
297
  # logs. For more information, see [Access
287
298
  # Logs](https://cloud.google.com/storage/docs/access-logs).
@@ -352,14 +363,23 @@ module Google
352
363
  # b.lifecycle.add_set_storage_class_rule "COLDLINE", age: 10
353
364
  # end
354
365
  #
355
- def create_bucket bucket_name, acl: nil, default_acl: nil,
356
- location: nil, storage_class: nil,
357
- logging_bucket: nil, logging_prefix: nil,
358
- website_main: nil, website_404: nil, versioning: nil,
359
- requester_pays: nil, user_project: nil
366
+ def create_bucket bucket_name,
367
+ acl: nil,
368
+ default_acl: nil,
369
+ location: nil,
370
+ custom_placement_config: nil,
371
+ storage_class: nil,
372
+ logging_bucket: nil,
373
+ logging_prefix: nil,
374
+ website_main: nil,
375
+ website_404: nil,
376
+ versioning: nil,
377
+ requester_pays: nil,
378
+ user_project: nil
360
379
  params = {
361
380
  name: bucket_name,
362
- location: location
381
+ location: location,
382
+ custom_placement_config: custom_placement_config
363
383
  }.delete_if { |_, v| v.nil? }
364
384
  new_bucket = Google::Apis::StorageV1::Bucket.new(**params)
365
385
  storage_class = storage_class_for storage_class
@@ -611,11 +631,11 @@ module Google
611
631
  # scopes = ["https://www.googleapis.com/auth/iam"]
612
632
  # iam_client.authorization = Google::Auth.get_application_default scopes
613
633
  #
614
- # request = {
615
- # "payload": string_to_sign,
616
- # }
634
+ # request = Google::Apis::IamcredentialsV1::SignBlobRequest.new(
635
+ # payload: string_to_sign
636
+ # )
617
637
  # resource = "projects/-/serviceAccounts/#{issuer}"
618
- # response = iam_client.sign_service_account_blob resource, request, {}
638
+ # response = iam_client.sign_service_account_blob resource, request
619
639
  # response.signed_blob
620
640
  # end
621
641
  #