google-cloud-storage 1.29.2 → 1.33.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.
@@ -198,7 +198,7 @@ module Google
198
198
  gapi = @service.insert_bucket_acl @bucket, entity, "OWNER",
199
199
  user_project: user_project
200
200
  entity = gapi.entity
201
- @owners.push entity unless @owners.nil?
201
+ @owners&.push entity
202
202
  entity
203
203
  end
204
204
 
@@ -243,7 +243,7 @@ module Google
243
243
  gapi = @service.insert_bucket_acl @bucket, entity, "WRITER",
244
244
  user_project: user_project
245
245
  entity = gapi.entity
246
- @writers.push entity unless @writers.nil?
246
+ @writers&.push entity
247
247
  entity
248
248
  end
249
249
 
@@ -288,7 +288,7 @@ module Google
288
288
  gapi = @service.insert_bucket_acl @bucket, entity, "READER",
289
289
  user_project: user_project
290
290
  entity = gapi.entity
291
- @readers.push entity unless @readers.nil?
291
+ @readers&.push entity
292
292
  entity
293
293
  end
294
294
 
@@ -323,9 +323,9 @@ module Google
323
323
  def delete entity
324
324
  @service.delete_bucket_acl @bucket, entity,
325
325
  user_project: user_project
326
- @owners.delete entity unless @owners.nil?
327
- @writers.delete entity unless @writers.nil?
328
- @readers.delete entity unless @readers.nil?
326
+ @owners&.delete entity
327
+ @writers&.delete entity
328
+ @readers&.delete entity
329
329
  true
330
330
  end
331
331
 
@@ -445,8 +445,7 @@ module Google
445
445
 
446
446
  def entities_from_acls acls, role
447
447
  selected = acls.select { |acl| acl.role == role }
448
- entities = selected.map(&:entity)
449
- entities
448
+ selected.map(&:entity)
450
449
  end
451
450
  end
452
451
 
@@ -614,7 +613,7 @@ module Google
614
613
  gapi = @service.insert_default_acl @bucket, entity, "OWNER",
615
614
  user_project: user_project
616
615
  entity = gapi.entity
617
- @owners.push entity unless @owners.nil?
616
+ @owners&.push entity
618
617
  entity
619
618
  end
620
619
 
@@ -657,7 +656,7 @@ module Google
657
656
  gapi = @service.insert_default_acl @bucket, entity, "READER",
658
657
  user_project: user_project
659
658
  entity = gapi.entity
660
- @readers.push entity unless @readers.nil?
659
+ @readers&.push entity
661
660
  entity
662
661
  end
663
662
 
@@ -690,8 +689,8 @@ module Google
690
689
  def delete entity
691
690
  @service.delete_default_acl @bucket, entity,
692
691
  user_project: user_project
693
- @owners.delete entity unless @owners.nil?
694
- @readers.delete entity unless @readers.nil?
692
+ @owners&.delete entity
693
+ @readers&.delete entity
695
694
  true
696
695
  end
697
696
 
@@ -829,8 +828,7 @@ module Google
829
828
 
830
829
  def entities_from_acls acls, role
831
830
  selected = acls.select { |acl| acl.role == role }
832
- entities = selected.map(&:entity)
833
- entities
831
+ selected.map(&:entity)
834
832
  end
835
833
  end
836
834
  end
@@ -172,7 +172,10 @@ module Google
172
172
  # rule.max_age #=> 3600
173
173
  #
174
174
  class Rule
175
- attr_accessor :origin, :methods, :headers, :max_age
175
+ attr_accessor :origin
176
+ attr_accessor :methods
177
+ attr_accessor :headers
178
+ attr_accessor :max_age
176
179
 
177
180
  # @private
178
181
  def initialize origin, methods, headers: nil, max_age: nil
@@ -371,17 +371,17 @@ module Google
371
371
  # end
372
372
  #
373
373
  class Rule
374
- attr_accessor :action,
375
- :storage_class,
376
- :age,
377
- :created_before,
378
- :custom_time_before,
379
- :days_since_custom_time,
380
- :days_since_noncurrent_time,
381
- :is_live,
382
- :matches_storage_class,
383
- :noncurrent_time_before,
384
- :num_newer_versions
374
+ attr_accessor :action
375
+ attr_accessor :storage_class
376
+ attr_accessor :age
377
+ attr_accessor :created_before
378
+ attr_accessor :custom_time_before
379
+ attr_accessor :days_since_custom_time
380
+ attr_accessor :days_since_noncurrent_time
381
+ attr_accessor :is_live
382
+ attr_accessor :matches_storage_class
383
+ attr_accessor :noncurrent_time_before
384
+ attr_accessor :num_newer_versions
385
385
 
386
386
  # @private
387
387
  def initialize action,
@@ -125,17 +125,17 @@ module Google
125
125
  # puts bucket.name
126
126
  # end
127
127
  #
128
- def all request_limit: nil
128
+ def all request_limit: nil, &block
129
129
  request_limit = request_limit.to_i if request_limit
130
130
  unless block_given?
131
131
  return enum_for :all, request_limit: request_limit
132
132
  end
133
133
  results = self
134
134
  loop do
135
- results.each { |r| yield r }
135
+ results.each(&block)
136
136
  if request_limit
137
137
  request_limit -= 1
138
- break if request_limit < 0
138
+ break if request_limit.negative?
139
139
  end
140
140
  break unless results.next?
141
141
  results = results.next
@@ -38,20 +38,22 @@ module Google
38
38
  # storage.project_id #=> "my-project"
39
39
  #
40
40
  class Credentials < Google::Auth::Credentials
41
- SCOPE = \
42
- ["https://www.googleapis.com/auth/devstorage.full_control"].freeze
43
- PATH_ENV_VARS = %w[STORAGE_CREDENTIALS
44
- STORAGE_KEYFILE
45
- GOOGLE_CLOUD_CREDENTIALS
46
- GOOGLE_CLOUD_KEYFILE
47
- GCLOUD_KEYFILE].freeze
48
- JSON_ENV_VARS = %w[STORAGE_CREDENTIALS_JSON
49
- STORAGE_KEYFILE_JSON
50
- GOOGLE_CLOUD_CREDENTIALS_JSON
51
- GOOGLE_CLOUD_KEYFILE_JSON
52
- GCLOUD_KEYFILE_JSON].freeze
53
- DEFAULT_PATHS = \
54
- ["~/.config/gcloud/application_default_credentials.json"].freeze
41
+ SCOPE = ["https://www.googleapis.com/auth/devstorage.full_control"].freeze
42
+ PATH_ENV_VARS = [
43
+ "STORAGE_CREDENTIALS",
44
+ "STORAGE_KEYFILE",
45
+ "GOOGLE_CLOUD_CREDENTIALS",
46
+ "GOOGLE_CLOUD_KEYFILE",
47
+ "GCLOUD_KEYFILE"
48
+ ].freeze
49
+ JSON_ENV_VARS = [
50
+ "STORAGE_CREDENTIALS_JSON",
51
+ "STORAGE_KEYFILE_JSON",
52
+ "GOOGLE_CLOUD_CREDENTIALS_JSON",
53
+ "GOOGLE_CLOUD_KEYFILE_JSON",
54
+ "GCLOUD_KEYFILE_JSON"
55
+ ].freeze
56
+ DEFAULT_PATHS = ["~/.config/gcloud/application_default_credentials.json"].freeze
55
57
  end
56
58
  end
57
59
  end
@@ -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