google-cloud-storage 1.29.2 → 1.47.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,25 @@ 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
+ # @param [Boolean] override_unlocked_retention
829
+ # Must be true to remove the retention configuration, reduce its unlocked
830
+ # retention period, or change its mode from unlocked to locked.
831
+ #
777
832
  # @yield [file] a block yielding a delegate object for updating the file
778
833
  #
779
834
  # @example
@@ -796,11 +851,36 @@ module Google
796
851
  # f.metadata["score"] = "10"
797
852
  # end
798
853
  #
799
- def update
854
+ # @example With a `if_generation_match` precondition:
855
+ # require "google/cloud/storage"
856
+ #
857
+ # storage = Google::Cloud::Storage.new
858
+ #
859
+ # bucket = storage.bucket "my-bucket"
860
+ #
861
+ # file = bucket.file "path/to/my-file.ext"
862
+ #
863
+ # file.update if_generation_match: 1602263125261858 do |f|
864
+ # f.cache_control = "private, max-age=0, no-cache"
865
+ # end
866
+ #
867
+ def update generation: nil,
868
+ if_generation_match: nil,
869
+ if_generation_not_match: nil,
870
+ if_metageneration_match: nil,
871
+ if_metageneration_not_match: nil,
872
+ override_unlocked_retention: nil
800
873
  updater = Updater.new gapi
801
874
  yield updater
802
875
  updater.check_for_changed_metadata!
803
- update_gapi! updater.updates unless updater.updates.empty?
876
+ return if updater.updates.empty?
877
+ update_gapi! updater.updates,
878
+ generation: generation,
879
+ if_generation_match: if_generation_match,
880
+ if_generation_not_match: if_generation_not_match,
881
+ if_metageneration_match: if_metageneration_match,
882
+ if_metageneration_not_match: if_metageneration_not_match,
883
+ override_unlocked_retention: override_unlocked_retention
804
884
  end
805
885
 
806
886
  ##
@@ -1138,6 +1218,27 @@ module Google
1138
1218
  # access, and allUsers get READER access.
1139
1219
  # @param [Integer] generation Select a specific revision of the file to
1140
1220
  # rewrite. The default is the latest version.
1221
+ # @param [Integer] if_generation_match Makes the operation conditional
1222
+ # on whether the destination file's current generation matches the given value.
1223
+ # Setting to 0 makes the operation succeed only if there are no live
1224
+ # versions of the file.
1225
+ # @param [Integer] if_generation_not_match Makes the operation conditional
1226
+ # on whether the destination file's current generation does not match the given
1227
+ # value. If no live file exists, the precondition fails. Setting to 0
1228
+ # makes the operation succeed only if there is a live version of the file.
1229
+ # @param [Integer] if_metageneration_match Makes the operation conditional
1230
+ # on whether the destination file's current metageneration matches the given value.
1231
+ # @param [Integer] if_metageneration_not_match Makes the operation
1232
+ # conditional on whether the destination file's current metageneration does not
1233
+ # match the given value.
1234
+ # @param [Integer] if_source_generation_match Makes the operation conditional on
1235
+ # whether the source object's current generation matches the given value.
1236
+ # @param [Integer] if_source_generation_not_match Makes the operation conditional
1237
+ # on whether the source object's current generation does not match the given value.
1238
+ # @param [Integer] if_source_metageneration_match Makes the operation conditional
1239
+ # on whether the source object's current metageneration matches the given value.
1240
+ # @param [Integer] if_source_metageneration_not_match Makes the operation conditional
1241
+ # on whether the source object's current metageneration does not match the given value.
1141
1242
  # @param [String] encryption_key Optional. The customer-supplied,
1142
1243
  # AES-256 encryption key used to decrypt the file, if the existing
1143
1244
  # file is encrypted.
@@ -1259,11 +1360,24 @@ module Google
1259
1360
  # f.metadata["rewritten_from"] = "#{file.bucket}/#{file.name}"
1260
1361
  # end
1261
1362
  #
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
1363
+ def rewrite dest_bucket_or_path,
1364
+ dest_path = nil,
1365
+ acl: nil,
1366
+ generation: nil,
1367
+ if_generation_match: nil,
1368
+ if_generation_not_match: nil,
1369
+ if_metageneration_match: nil,
1370
+ if_metageneration_not_match: nil,
1371
+ if_source_generation_match: nil,
1372
+ if_source_generation_not_match: nil,
1373
+ if_source_metageneration_match: nil,
1374
+ if_source_metageneration_not_match: nil,
1375
+ encryption_key: nil,
1376
+ new_encryption_key: nil,
1377
+ new_kms_key: nil,
1378
+ force_copy_metadata: nil
1264
1379
  ensure_service!
1265
- dest_bucket, dest_path = fix_rewrite_args dest_bucket_or_path,
1266
- dest_path
1380
+ dest_bucket, dest_path = fix_rewrite_args dest_bucket_or_path, dest_path
1267
1381
 
1268
1382
  update_gapi = nil
1269
1383
  if block_given?
@@ -1276,9 +1390,21 @@ module Google
1276
1390
  end
1277
1391
  end
1278
1392
 
1279
- new_gapi = rewrite_gapi bucket, name, update_gapi,
1280
- new_bucket: dest_bucket, new_name: dest_path,
1281
- acl: acl, generation: generation,
1393
+ new_gapi = rewrite_gapi bucket,
1394
+ name,
1395
+ update_gapi,
1396
+ new_bucket: dest_bucket,
1397
+ new_name: dest_path,
1398
+ acl: acl,
1399
+ generation: generation,
1400
+ if_generation_match: if_generation_match,
1401
+ if_generation_not_match: if_generation_not_match,
1402
+ if_metageneration_match: if_metageneration_match,
1403
+ if_metageneration_not_match: if_metageneration_not_match,
1404
+ if_source_generation_match: if_source_generation_match,
1405
+ if_source_generation_not_match: if_source_generation_not_match,
1406
+ if_source_metageneration_match: if_source_metageneration_match,
1407
+ if_source_metageneration_not_match: if_source_metageneration_not_match,
1282
1408
  encryption_key: encryption_key,
1283
1409
  new_encryption_key: new_encryption_key,
1284
1410
  new_kms_key: new_kms_key,
@@ -1375,6 +1501,20 @@ module Google
1375
1501
  # {#generation}. The default behavior is to delete the latest version
1376
1502
  # of the file (regardless of the version to which the file is set,
1377
1503
  # which is the version returned by {#generation}.)
1504
+ # @param [Integer] if_generation_match Makes the operation conditional
1505
+ # on whether the file's current generation matches the given value.
1506
+ # Setting to 0 makes the operation succeed only if there are no live
1507
+ # versions of the file.
1508
+ # @param [Integer] if_generation_not_match Makes the operation conditional
1509
+ # on whether the file's current generation does not match the given
1510
+ # value. If no live file exists, the precondition fails. Setting to 0
1511
+ # makes the operation succeed only if there is a live version of the file.
1512
+ # @param [Integer] if_metageneration_match Makes the operation conditional
1513
+ # on whether the file's current metageneration matches the given value.
1514
+ # @param [Integer] if_metageneration_not_match Makes the operation
1515
+ # conditional on whether the file's current metageneration does not
1516
+ # match the given value.
1517
+ #
1378
1518
  # @return [Boolean] Returns `true` if the file was deleted.
1379
1519
  #
1380
1520
  # @example
@@ -1407,14 +1547,82 @@ module Google
1407
1547
  # file = bucket.file "path/to/my-file.ext"
1408
1548
  # file.delete generation: 123456
1409
1549
  #
1410
- def delete generation: nil
1550
+ def delete generation: nil,
1551
+ if_generation_match: nil,
1552
+ if_generation_not_match: nil,
1553
+ if_metageneration_match: nil,
1554
+ if_metageneration_not_match: nil
1411
1555
  generation = self.generation if generation == true
1412
1556
  ensure_service!
1413
- service.delete_file bucket, name, generation: generation,
1414
- user_project: user_project
1557
+ service.delete_file bucket,
1558
+ name,
1559
+ generation: generation,
1560
+ if_generation_match: if_generation_match,
1561
+ if_generation_not_match: if_generation_not_match,
1562
+ if_metageneration_match: if_metageneration_match,
1563
+ if_metageneration_not_match: if_metageneration_not_match,
1564
+ user_project: user_project
1415
1565
  true
1416
1566
  end
1417
1567
 
1568
+ # Mode of object level retention configuration.
1569
+ # Valid values are 'Locked' or 'Unlocked'
1570
+ #
1571
+ # @return [String]
1572
+ def retention_mode
1573
+ @gapi.retention&.mode
1574
+ end
1575
+
1576
+ # The earliest time in RFC 3339 UTC "Zulu" format that the object can
1577
+ # be deleted or replaced.
1578
+ #
1579
+ # @return [DateTime]
1580
+ def retention_retain_until_time
1581
+ @gapi.retention&.retain_until_time
1582
+ end
1583
+
1584
+ # A collection of object level retention parameters.
1585
+ # The full list of available options are outlined at the [JSON API docs]
1586
+ # (https://cloud.google.com/storage/docs/json_api/v1/objects/insert#request-body).
1587
+ #
1588
+ # @return [Google::Apis::StorageV1::Object::Retention]
1589
+ def retention
1590
+ @gapi.retention
1591
+ end
1592
+
1593
+ ##
1594
+ # Update method to update retention parameter of an object / file
1595
+ # It accepts params as a Hash of attributes in the following format:
1596
+ #
1597
+ # { mode: 'Locked|Unlocked', retain_until_time: '2023-12-19T03:22:23+00:00' }
1598
+ #
1599
+ # @param [Hash(String => String)] new_retention_attributes
1600
+ #
1601
+ # @example Update retention parameters for the File / Object
1602
+ # require "google/cloud/storage"
1603
+ # storage = Google::Cloud::Storage.new
1604
+ # bucket = storage.bucket "my-bucket"
1605
+ # file = bucket.file "avatars/heidi/400x400.png"
1606
+ # retention_params = { mode: 'Unlocked', retain_until_time: '2023-12-19T03:22:23+00:00'.to_datetime }
1607
+ # file.retention = retention_params
1608
+ #
1609
+ # @example Update retention parameters for the File / Object with override enabled
1610
+ # require "google/cloud/storage"
1611
+ # storage = Google::Cloud::Storage.new
1612
+ # bucket = storage.bucket "my-bucket"
1613
+ # file = bucket.file "avatars/heidi/400x400.png"
1614
+ # retention_params = { mode: 'Unlocked',
1615
+ # retain_until_time: '2023-12-19T03:22:23+00:00'.to_datetime,
1616
+ # override_unlocked_retention: true }
1617
+ # file.retention = retention_params
1618
+ #
1619
+ def retention= new_retention_attributes
1620
+ @gapi.retention ||= Google::Apis::StorageV1::Object::Retention.new
1621
+ @gapi.retention.mode = new_retention_attributes[:mode]
1622
+ @gapi.retention.retain_until_time = new_retention_attributes[:retain_until_time]
1623
+ update_gapi! :retention, override_unlocked_retention: new_retention_attributes[:override_unlocked_retention]
1624
+ end
1625
+
1418
1626
  ##
1419
1627
  # Public URL to access the file. If the file is not public, requests to
1420
1628
  # the URL will return an error. (See {File::Acl#public!} and
@@ -1618,11 +1826,11 @@ module Google
1618
1826
  # scopes = ["https://www.googleapis.com/auth/iam"]
1619
1827
  # iam_client.authorization = Google::Auth.get_application_default scopes
1620
1828
  #
1621
- # request = {
1622
- # "payload": string_to_sign,
1623
- # }
1829
+ # request = Google::Apis::IamcredentialsV1::SignBlobRequest.new(
1830
+ # payload: string_to_sign
1831
+ # )
1624
1832
  # resource = "projects/-/serviceAccounts/#{issuer}"
1625
- # response = iam_client.sign_service_account_blob resource, request, {}
1833
+ # response = iam_client.sign_service_account_blob resource, request
1626
1834
  # response.signed_blob
1627
1835
  # end
1628
1836
  #
@@ -1865,7 +2073,14 @@ module Google
1865
2073
  reload! generation: true
1866
2074
  end
1867
2075
 
1868
- def update_gapi! *attributes
2076
+ def update_gapi! attributes,
2077
+ generation: nil,
2078
+ if_generation_match: nil,
2079
+ if_generation_not_match: nil,
2080
+ if_metageneration_match: nil,
2081
+ if_metageneration_not_match: nil,
2082
+ override_unlocked_retention: nil
2083
+ attributes = Array(attributes)
1869
2084
  attributes.flatten!
1870
2085
  return if attributes.empty?
1871
2086
  update_gapi = self.class.gapi_from_attrs @gapi, attributes
@@ -1873,28 +2088,68 @@ module Google
1873
2088
 
1874
2089
  ensure_service!
1875
2090
 
1876
- rewrite_attrs = %i[storage_class kms_key_name]
2091
+ rewrite_attrs = [:storage_class, :kms_key_name]
1877
2092
  @gapi = if attributes.any? { |a| rewrite_attrs.include? a }
1878
- rewrite_gapi \
1879
- bucket, name, update_gapi, user_project: user_project
2093
+ rewrite_gapi bucket,
2094
+ name,
2095
+ update_gapi,
2096
+ generation: generation,
2097
+ if_generation_match: if_generation_match,
2098
+ if_generation_not_match: if_generation_not_match,
2099
+ if_metageneration_match: if_metageneration_match,
2100
+ if_metageneration_not_match: if_metageneration_not_match,
2101
+ user_project: user_project
1880
2102
  else
1881
- service.patch_file \
1882
- bucket, name, update_gapi, user_project: user_project
2103
+ service.patch_file bucket,
2104
+ name,
2105
+ update_gapi,
2106
+ generation: generation,
2107
+ if_generation_match: if_generation_match,
2108
+ if_generation_not_match: if_generation_not_match,
2109
+ if_metageneration_match: if_metageneration_match,
2110
+ if_metageneration_not_match: if_metageneration_not_match,
2111
+ user_project: user_project,
2112
+ override_unlocked_retention: override_unlocked_retention
1883
2113
  end
1884
2114
  end
1885
2115
 
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,
2116
+ def rewrite_gapi bucket,
2117
+ name,
2118
+ updated_gapi,
2119
+ new_bucket: nil,
2120
+ new_name: nil,
2121
+ acl: nil,
2122
+ generation: nil,
2123
+ if_generation_match: nil,
2124
+ if_generation_not_match: nil,
2125
+ if_metageneration_match: nil,
2126
+ if_metageneration_not_match: nil,
2127
+ if_source_generation_match: nil,
2128
+ if_source_generation_not_match: nil,
2129
+ if_source_metageneration_match: nil,
2130
+ if_source_metageneration_not_match: nil,
2131
+ encryption_key: nil,
2132
+ new_encryption_key: nil,
2133
+ new_kms_key: nil,
1890
2134
  user_project: nil
1891
2135
  new_bucket ||= bucket
1892
2136
  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? }
2137
+ options = {
2138
+ acl: File::Acl.predefined_rule_for(acl),
2139
+ generation: generation,
2140
+ if_generation_match: if_generation_match,
2141
+ if_generation_not_match: if_generation_not_match,
2142
+ if_metageneration_match: if_metageneration_match,
2143
+ if_metageneration_not_match: if_metageneration_not_match,
2144
+ if_source_generation_match: if_source_generation_match,
2145
+ if_source_generation_not_match: if_source_generation_not_match,
2146
+ if_source_metageneration_match: if_source_metageneration_match,
2147
+ if_source_metageneration_not_match: if_source_metageneration_not_match,
2148
+ source_key: encryption_key,
2149
+ destination_key: new_encryption_key,
2150
+ destination_kms_key: new_kms_key,
2151
+ user_project: user_project
2152
+ }.delete_if { |_k, v| v.nil? }
1898
2153
 
1899
2154
  resp = service.rewrite_file \
1900
2155
  bucket, name, new_bucket, new_name, updated_gapi, **options
@@ -1972,6 +2227,7 @@ module Google
1972
2227
  ##
1973
2228
  # @private Create an Updater object.
1974
2229
  def initialize gapi
2230
+ super()
1975
2231
  @updates = []
1976
2232
  @gapi = gapi
1977
2233
  @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