google-cloud-storage 1.45.0 → 1.57.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1a00be88dfffe243057e1ffe70891fabb483caadc76a7a37e8b82dcdb5f95395
4
- data.tar.gz: 2190d664457e1419b26b95266d8911728a612647d404790b35f37586dfe59e02
3
+ metadata.gz: 2ba3f85cab0b6bd616c783973578f6f3610d23bd9679e74a42f77eda3e5b7b20
4
+ data.tar.gz: c5399ac6a4e32d290f3c112ee435696d176c4afe329213acbca36cc629a1f647
5
5
  SHA512:
6
- metadata.gz: e5b129dba88921e6aeec6476d60bb17ee603f0cb641194bbeb09531aff568c2290e17ab3f0f290d87976a0b0f35d4f10674dab8fea6deef70d424738a4ce767c
7
- data.tar.gz: 87e4411cda889bb7bdbf0ccddc2a343ae475614c5cab19d8461bcd646ac78016b6be35975255e14c1af1efcd3c5087c9b769b674260a82f936ef4c0456566a19
6
+ metadata.gz: 3655fcc4fe59d97a956c1dd4ab3d98abdcf406261b2bb4d30a3c300d4c64aa37d2c7262c99484befa1538758ba4240b5e0a51d0ed753066a850db3d82a74b9ea
7
+ data.tar.gz: 9f0c4e40ecc8f906259d2a2c027b419c464519b65b83309e574f5cd4f7bc9eae55dd5c0735798e96be8b5696af75e315f1ee299dc4e91cba374c6119b3258e78
data/CHANGELOG.md CHANGED
@@ -1,5 +1,91 @@
1
1
  # Release History
2
2
 
3
+ ### 1.57.0 (2025-08-15)
4
+
5
+ #### Features
6
+
7
+ * Require Ruby 3.1 or later ([#30765](https://github.com/googleapis/google-cloud-ruby/issues/30765))
8
+ * Support for using Faraday for HTTP requests ([#30759](https://github.com/googleapis/google-cloud-ruby/issues/30759))
9
+
10
+ ### 1.56.0 (2025-04-21)
11
+
12
+ #### Features
13
+
14
+ * move_object within hns bucket ([#29391](https://github.com/googleapis/google-cloud-ruby/issues/29391))
15
+
16
+ ### 1.55.0 (2025-02-13)
17
+
18
+ #### Features
19
+
20
+ * Soft deleted Bucket Restore ([#28138](https://github.com/googleapis/google-cloud-ruby/issues/28138))
21
+ #### Documentation
22
+
23
+ * updating the encryption key GCS sample ([#28815](https://github.com/googleapis/google-cloud-ruby/issues/28815))
24
+
25
+ ### 1.54.0 (2024-12-11)
26
+
27
+ #### Features
28
+
29
+ * Updated required Ruby version to 3.0 or later ([#27599](https://github.com/googleapis/google-cloud-ruby/issues/27599))
30
+
31
+ ### 1.53.0 (2024-12-04)
32
+
33
+ #### Features
34
+
35
+ * add integration test for universe domain ([#27384](https://github.com/googleapis/google-cloud-ruby/issues/27384))
36
+ * fetch file and bucket details from url ([#27322](https://github.com/googleapis/google-cloud-ruby/issues/27322))
37
+
38
+ ### 1.52.0 (2024-05-31)
39
+
40
+ #### Features
41
+
42
+ * support for hierarchical namespace (folders) ([#25967](https://github.com/googleapis/google-cloud-ruby/issues/25967))
43
+
44
+ ### 1.51.0 (2024-04-25)
45
+
46
+ #### Features
47
+
48
+ * Respect custom endpoint for signed_url ([#25469](https://github.com/googleapis/google-cloud-ruby/issues/25469))
49
+
50
+ ### 1.50.0 (2024-04-19)
51
+
52
+ #### Features
53
+
54
+ * Add support for soft deletion ([#25340](https://github.com/googleapis/google-cloud-ruby/issues/25340))
55
+ #### Bug Fixes
56
+
57
+ * Set configured univer_domain and endpoint when initializing through Service ([#25665](https://github.com/googleapis/google-cloud-ruby/issues/25665))
58
+
59
+ ### 1.49.0 (2024-02-21)
60
+
61
+ #### Features
62
+
63
+ * Support of Managed Folders ([#24809](https://github.com/googleapis/google-cloud-ruby/issues/24809))
64
+
65
+ ### 1.48.1 (2024-01-26)
66
+
67
+ #### Bug Fixes
68
+
69
+ * Raise an error on mismatching universe domain ([#24486](https://github.com/googleapis/google-cloud-ruby/issues/24486))
70
+
71
+ ### 1.48.0 (2024-01-25)
72
+
73
+ #### Features
74
+
75
+ * Support for universe_domain ([#24449](https://github.com/googleapis/google-cloud-ruby/issues/24449))
76
+
77
+ ### 1.47.0 (2024-01-09)
78
+
79
+ #### Features
80
+
81
+ * support for object lock / retention ([#23732](https://github.com/googleapis/google-cloud-ruby/issues/23732))
82
+
83
+ ### 1.46.0 (2024-01-08)
84
+
85
+ #### Features
86
+
87
+ * support match_glob for Object.list
88
+
3
89
  ### 1.45.0 (2023-11-06)
4
90
 
5
91
  #### Features
data/OVERVIEW.md CHANGED
@@ -531,14 +531,23 @@ created and owns the topic.)
531
531
  require "google/cloud/pubsub"
532
532
  require "google/cloud/storage"
533
533
 
534
- pubsub = Google::Cloud::Pubsub.new
534
+ pubsub = Google::Cloud::PubSub.new
535
535
  storage = Google::Cloud::Storage.new
536
536
 
537
- topic = pubsub.create_topic "my-topic"
538
- topic.policy do |p|
539
- p.add "roles/pubsub.publisher",
540
- "serviceAccount:#{storage.service_account_email}"
541
- end
537
+ topic_admin = pubsub.topic_admin
538
+ topic_path = pubsub.topic_path "my-topic"
539
+ topic = topic_admin.create_topic name: topic_path
540
+
541
+ policy = {
542
+ bindings: [
543
+ {
544
+ role: "roles/pubsub.publisher",
545
+ members: ["serviceAccount:#{storage.service_account_email}"]
546
+ }
547
+ ]
548
+ }
549
+
550
+ pubsub.iam.set_iam_policy resource: topic_path, policy: policy
542
551
 
543
552
  bucket = storage.bucket "my-bucket"
544
553
 
@@ -352,7 +352,7 @@ module Google
352
352
  def auth! if_metageneration_match: nil
353
353
  update_predefined_acl! "authenticatedRead", if_metageneration_match: if_metageneration_match
354
354
  end
355
- alias authenticatedRead! auth!
355
+ alias authenticatedRead! auth! # rubocop:disable Naming/MethodName
356
356
  alias auth_read! auth!
357
357
  alias authenticated! auth!
358
358
  alias authenticated_read! auth!
@@ -390,7 +390,7 @@ module Google
390
390
  def project_private! if_metageneration_match: nil
391
391
  update_predefined_acl! "projectPrivate", if_metageneration_match: if_metageneration_match
392
392
  end
393
- alias projectPrivate! project_private!
393
+ alias projectPrivate! project_private! # rubocop:disable Naming/MethodName
394
394
 
395
395
  ##
396
396
  # Convenience method to apply the `publicRead` predefined ACL
@@ -408,7 +408,7 @@ module Google
408
408
  def public! if_metageneration_match: nil
409
409
  update_predefined_acl! "publicRead", if_metageneration_match: if_metageneration_match
410
410
  end
411
- alias publicRead! public!
411
+ alias publicRead! public! # rubocop:disable Naming/MethodName
412
412
  alias public_read! public!
413
413
 
414
414
  # Convenience method to apply the `publicReadWrite` predefined ACL
@@ -426,7 +426,7 @@ module Google
426
426
  def public_write! if_metageneration_match: nil
427
427
  update_predefined_acl! "publicReadWrite", if_metageneration_match: if_metageneration_match
428
428
  end
429
- alias publicReadWrite! public_write!
429
+ alias publicReadWrite! public_write! # rubocop:disable Naming/MethodName
430
430
 
431
431
  protected
432
432
 
@@ -718,7 +718,7 @@ module Google
718
718
  def auth! if_metageneration_match: nil
719
719
  update_predefined_default_acl! "authenticatedRead", if_metageneration_match: if_metageneration_match
720
720
  end
721
- alias authenticatedRead! auth!
721
+ alias authenticatedRead! auth! # rubocop:disable Naming/MethodName
722
722
  alias auth_read! auth!
723
723
  alias authenticated! auth!
724
724
  alias authenticated_read! auth!
@@ -739,7 +739,7 @@ module Google
739
739
  def owner_full! if_metageneration_match: nil
740
740
  update_predefined_default_acl! "bucketOwnerFullControl", if_metageneration_match: if_metageneration_match
741
741
  end
742
- alias bucketOwnerFullControl! owner_full!
742
+ alias bucketOwnerFullControl! owner_full! # rubocop:disable Naming/MethodName
743
743
 
744
744
  ##
745
745
  # Convenience method to apply the default `bucketOwnerRead`
@@ -757,7 +757,7 @@ module Google
757
757
  def owner_read! if_metageneration_match: nil
758
758
  update_predefined_default_acl! "bucketOwnerRead", if_metageneration_match: if_metageneration_match
759
759
  end
760
- alias bucketOwnerRead! owner_read!
760
+ alias bucketOwnerRead! owner_read! # rubocop:disable Naming/MethodName
761
761
 
762
762
  ##
763
763
  # Convenience method to apply the default `private`
@@ -792,7 +792,7 @@ module Google
792
792
  def project_private! if_metageneration_match: nil
793
793
  update_predefined_default_acl! "projectPrivate", if_metageneration_match: if_metageneration_match
794
794
  end
795
- alias projectPrivate! project_private!
795
+ alias projectPrivate! project_private! # rubocop:disable Naming/MethodName
796
796
 
797
797
  ##
798
798
  # Convenience method to apply the default `publicRead`
@@ -810,7 +810,7 @@ module Google
810
810
  def public! if_metageneration_match: nil
811
811
  update_predefined_default_acl! "publicRead", if_metageneration_match: if_metageneration_match
812
812
  end
813
- alias publicRead! public!
813
+ alias publicRead! public! # rubocop:disable Naming/MethodName
814
814
  alias public_read! public!
815
815
 
816
816
  protected
@@ -182,7 +182,7 @@ module Google
182
182
  @origin = Array(origin)
183
183
  @methods = Array(methods)
184
184
  @headers = Array(headers)
185
- @max_age = (max_age || 1800)
185
+ @max_age = max_age || 1800
186
186
  end
187
187
 
188
188
  # @private
@@ -195,7 +195,7 @@ module Google
195
195
 
196
196
  # @private
197
197
  def self.from_gapi gapi
198
- new gapi.origin.dup, gapi.http_method.dup, \
198
+ new gapi.origin.dup, gapi.http_method.dup,
199
199
  headers: gapi.response_header.dup,
200
200
  max_age: gapi.max_age_seconds
201
201
  end
@@ -72,7 +72,8 @@ module Google
72
72
  return nil unless next?
73
73
  ensure_service!
74
74
  gapi = @service.list_buckets prefix: @prefix, token: @token,
75
- max: @max, user_project: @user_project
75
+ max: @max, user_project: @user_project,
76
+ soft_deleted: @soft_deleted
76
77
  Bucket::List.from_gapi gapi, @service, @prefix, @max,
77
78
  user_project: @user_project
78
79
  end
@@ -146,7 +147,7 @@ module Google
146
147
  # @private New Bucket::List from a Google API Client
147
148
  # Google::Apis::StorageV1::Buckets object.
148
149
  def self.from_gapi gapi_list, service, prefix = nil, max = nil,
149
- user_project: nil
150
+ user_project: nil, soft_deleted: nil
150
151
  buckets = new(Array(gapi_list.items).map do |gapi_object|
151
152
  Bucket.from_gapi gapi_object, service, user_project: user_project
152
153
  end)
@@ -155,6 +156,7 @@ module Google
155
156
  buckets.instance_variable_set :@prefix, prefix
156
157
  buckets.instance_variable_set :@max, max
157
158
  buckets.instance_variable_set :@user_project, user_project
159
+ buckets.instance_variable_set :@soft_deleted, soft_deleted
158
160
  buckets
159
161
  end
160
162
 
@@ -118,6 +118,15 @@ module Google
118
118
  @gapi.autoclass
119
119
  end
120
120
 
121
+ ##
122
+ # The object retention configuration of the bucket
123
+ #
124
+ # @return [Google::Apis::StorageV1::Bucket::ObjectRetention]
125
+ #
126
+ def object_retention
127
+ @gapi.object_retention
128
+ end
129
+
121
130
  ##
122
131
  # The name of the bucket.
123
132
  #
@@ -973,7 +982,7 @@ module Google
973
982
  #
974
983
  def uniform_bucket_level_access= new_uniform_bucket_level_access
975
984
  @gapi.iam_configuration ||= API::Bucket::IamConfiguration.new
976
- @gapi.iam_configuration.uniform_bucket_level_access ||= \
985
+ @gapi.iam_configuration.uniform_bucket_level_access ||=
977
986
  API::Bucket::IamConfiguration::UniformBucketLevelAccess.new
978
987
  @gapi.iam_configuration.uniform_bucket_level_access.enabled = new_uniform_bucket_level_access
979
988
  patch_gapi! :iam_configuration
@@ -1185,6 +1194,121 @@ module Google
1185
1194
  patch_gapi! :rpo
1186
1195
  end
1187
1196
 
1197
+ ##
1198
+ # The bucket's soft delete policy. If this policy is set, any deleted
1199
+ # objects will be soft-deleted according to the time specified in the
1200
+ # policy.
1201
+ # This value can be modified by calling {#soft_delete_policy=}.
1202
+ #
1203
+ # @return [Google::Apis::StorageV1::Bucket::SoftDeletePolicy] The default retention policy is for 7
1204
+ # days.
1205
+ #
1206
+ # @example
1207
+ # require "google/cloud/storage"
1208
+ #
1209
+ # storage = Google::Cloud::Storage.new
1210
+ #
1211
+ # bucket = storage.bucket "my-bucket"
1212
+ #
1213
+ # bucket.soft_delete_policy
1214
+ #
1215
+ def soft_delete_policy
1216
+ @gapi.soft_delete_policy
1217
+ end
1218
+
1219
+ ##
1220
+ # Sets the value for Soft Delete Policy in the bucket. This value can
1221
+ # be queried by calling {#soft_delete_policy}.
1222
+ #
1223
+ # @param [Google::Apis::StorageV1::Bucket::SoftDeletePolicy,
1224
+ # Hash(String => String)] new_soft_delete_policy The bucket's
1225
+ # new Soft Delete Policy.
1226
+ #
1227
+ # @example Set Soft Delete Policy to 10 days using SoftDeletePolicy class:
1228
+ # require "google/cloud/storage"
1229
+ # require "date"
1230
+ #
1231
+ # storage = Google::Cloud::Storage.new
1232
+ #
1233
+ # bucket = storage.bucket "my-bucket"
1234
+ #
1235
+ # soft_delete_policy = Google::Apis::StorageV1::Bucket::SoftDeletePolicy.new
1236
+ # soft_delete_policy.retention_duration_seconds = 10*24*60*60
1237
+ #
1238
+ # bucket.soft_delete_policy = soft_delete_policy
1239
+ #
1240
+ # @example Set Soft Delete Policy to 5 days using Hash:
1241
+ # require "google/cloud/storage"
1242
+ # require "date"
1243
+ #
1244
+ # storage = Google::Cloud::Storage.new
1245
+ #
1246
+ # bucket = storage.bucket "my-bucket"
1247
+ #
1248
+ # soft_delete_policy = { retention_duration_seconds: 432000 }
1249
+ # bucket.soft_delete_policy = soft_delete_policy
1250
+ #
1251
+ def soft_delete_policy= new_soft_delete_policy
1252
+ @gapi.soft_delete_policy = new_soft_delete_policy || {}
1253
+ patch_gapi! :soft_delete_policy
1254
+ end
1255
+
1256
+ ##
1257
+ # The bucket's hierarchical namespace (Folders) configuration.
1258
+ # This value can be modified by calling {#hierarchical_namespace=}.
1259
+ #
1260
+ # @return [Google::Apis::StorageV1::Bucket::HierarchicalNamespace]
1261
+ #
1262
+ # @example
1263
+ # require "google/cloud/storage"
1264
+ #
1265
+ # storage = Google::Cloud::Storage.new
1266
+ #
1267
+ # bucket = storage.bucket "my-bucket"
1268
+ #
1269
+ # bucket.hierarchical_namespace
1270
+ #
1271
+ def hierarchical_namespace
1272
+ @gapi.hierarchical_namespace
1273
+ end
1274
+
1275
+ ##
1276
+ # Sets the value of Hierarchical Namespace (Folders) for the bucket.
1277
+ # This can only be enabled at bucket create time. If this is enabled,
1278
+ # Uniform Bucket-Level Access must also be enabled.
1279
+ # This value can be queried by calling {#hierarchical_namespace}.
1280
+ #
1281
+ # @param [Google::Apis::StorageV1::Bucket::HierarchicalNamespace,
1282
+ # Hash(String => String)] new_hierarchical_namespace The
1283
+ # bucket's new Hierarchical Namespace Configuration.
1284
+ #
1285
+ # @example Enabled Hierarchical Namespace using HierarchicalNamespace class:
1286
+ # require "google/cloud/storage"
1287
+ #
1288
+ # storage = Google::Cloud::Storage.new
1289
+ #
1290
+ # bucket = storage.bucket "my-bucket"
1291
+ #
1292
+ # hierarchical_namespace = Google::Apis::StorageV1::Bucket::HierarchicalNamespace.new
1293
+ # hierarchical_namespace.enabled = true
1294
+ #
1295
+ # bucket.hierarchical_namespace = hierarchical_namespace
1296
+ #
1297
+ # @example Disable Hierarchical Namespace using Hash:
1298
+ # require "google/cloud/storage"
1299
+ #
1300
+ # storage = Google::Cloud::Storage.new
1301
+ #
1302
+ # bucket = storage.bucket "my-bucket"
1303
+ #
1304
+ # hierarchical_namespace = { enabled: false }
1305
+ # bucket.hierarchical_namespace = hierarchical_namespace
1306
+ #
1307
+ def hierarchical_namespace= new_hierarchical_namespace
1308
+ @gapi.hierarchical_namespace = new_hierarchical_namespace || {}
1309
+ patch_gapi! :hierarchical_namespace
1310
+ end
1311
+
1188
1312
  ##
1189
1313
  # Updates the bucket with changes made in the given block in a single
1190
1314
  # PATCH request. The following attributes may be set: {#cors},
@@ -1299,6 +1423,9 @@ module Google
1299
1423
  # `prefixes` are omitted.
1300
1424
  # @param [String] token A previously-returned page token representing
1301
1425
  # part of the larger set of results to view.
1426
+ # @param [String] match_glob A glob pattern used to filter results returned in items (e.g. `foo*bar`).
1427
+ # The string value must be UTF-8 encoded. See:
1428
+ # https://cloud.google.com/storage/docs/json_api/v1/objects/list#list-object-glob
1302
1429
  # @param [Integer] max Maximum number of items plus prefixes to return.
1303
1430
  # As duplicate prefixes are omitted, fewer total results may be
1304
1431
  # returned than requested. The default value of this parameter is
@@ -1307,6 +1434,11 @@ module Google
1307
1434
  # as distinct results. The default is `false`. For more information,
1308
1435
  # see [Object Versioning
1309
1436
  # ](https://cloud.google.com/storage/docs/object-versioning).
1437
+ # @param [Boolean] include_folders_as_prefixes If `true`, will also include
1438
+ # folders and managed folders, besides objects, in the returned prefixes.
1439
+ # Only applicable if delimiter is set to '/'.
1440
+ # @param [Boolean] soft_deleted If true, only soft-deleted object
1441
+ # versions will be listed. The default is false.
1310
1442
  #
1311
1443
  # @return [Array<Google::Cloud::Storage::File>] (See
1312
1444
  # {Google::Cloud::Storage::File::List})
@@ -1334,14 +1466,22 @@ module Google
1334
1466
  # end
1335
1467
  #
1336
1468
  def files prefix: nil, delimiter: nil, token: nil, max: nil,
1337
- versions: nil
1469
+ versions: nil, match_glob: nil, include_folders_as_prefixes: nil,
1470
+ soft_deleted: nil
1338
1471
  ensure_service!
1339
1472
  gapi = service.list_files name, prefix: prefix, delimiter: delimiter,
1340
1473
  token: token, max: max,
1341
1474
  versions: versions,
1342
- user_project: user_project
1475
+ user_project: user_project,
1476
+ match_glob: match_glob,
1477
+ include_folders_as_prefixes: include_folders_as_prefixes,
1478
+ soft_deleted: soft_deleted
1343
1479
  File::List.from_gapi gapi, service, name, prefix, delimiter, max,
1344
- versions, user_project: user_project
1480
+ versions,
1481
+ user_project: user_project,
1482
+ match_glob: match_glob,
1483
+ include_folders_as_prefixes: include_folders_as_prefixes,
1484
+ soft_deleted: soft_deleted
1345
1485
  end
1346
1486
  alias find_files files
1347
1487
 
@@ -1377,6 +1517,8 @@ module Google
1377
1517
  # @param [String] encryption_key Optional. The customer-supplied,
1378
1518
  # AES-256 encryption key used to encrypt the file, if one was provided
1379
1519
  # to {#create_file}. (Not used if `skip_lookup` is also set.)
1520
+ # @param [Boolean] soft_deleted Optional. If true, only soft-deleted
1521
+ # object versions will be listed. The default is false.
1380
1522
  #
1381
1523
  # @return [Google::Cloud::Storage::File, nil] Returns nil if file does
1382
1524
  # not exist
@@ -1398,7 +1540,8 @@ module Google
1398
1540
  if_metageneration_match: nil,
1399
1541
  if_metageneration_not_match: nil,
1400
1542
  skip_lookup: nil,
1401
- encryption_key: nil
1543
+ encryption_key: nil,
1544
+ soft_deleted: nil
1402
1545
  ensure_service!
1403
1546
  if skip_lookup
1404
1547
  return File.new_lazy name, path, service,
@@ -1411,7 +1554,8 @@ module Google
1411
1554
  if_metageneration_match: if_metageneration_match,
1412
1555
  if_metageneration_not_match: if_metageneration_not_match,
1413
1556
  key: encryption_key,
1414
- user_project: user_project
1557
+ user_project: user_project,
1558
+ soft_deleted: soft_deleted
1415
1559
  File.from_gapi gapi, service, user_project: user_project
1416
1560
  rescue Google::Cloud::NotFoundError
1417
1561
  nil
@@ -1692,6 +1836,77 @@ module Google
1692
1836
  alias upload_file create_file
1693
1837
  alias new_file create_file
1694
1838
 
1839
+ ##
1840
+ # Restores a soft-deleted object.
1841
+ #
1842
+ # @param [String] file_path
1843
+ # Name of the file.
1844
+ # @param [Fixnum] generation
1845
+ # Selects a specific revision of this object.
1846
+ # @param [Boolean] copy_source_acl
1847
+ # If true, copies the source file's ACL; otherwise, uses the
1848
+ # bucket's default file ACL. The default is false.
1849
+ # @param [Fixnum] if_generation_match
1850
+ # Makes the operation conditional on whether the file's one live
1851
+ # generation matches the given value. Setting to 0 makes the
1852
+ # operation succeed only if there are no live versions of the file.
1853
+ # @param [Fixnum] if_generation_not_match
1854
+ # Makes the operation conditional on whether none of the file's live
1855
+ # generations match the given value. If no live file exists, the
1856
+ # precondition fails. Setting to 0 makes the operation succeed only
1857
+ # if there is a live version of the file.
1858
+ # @param [Fixnum] if_metageneration_match
1859
+ # Makes the operation conditional on whether the file's one live
1860
+ # metageneration matches the given value.
1861
+ # @param [Fixnum] if_metageneration_not_match
1862
+ # Makes the operation conditional on whether none of the object's
1863
+ # live metagenerations match the given value.
1864
+ # @param [String] projection
1865
+ # Set of properties to return. Defaults to full.
1866
+ # @param [String] user_project
1867
+ # The project to be billed for this request. Required for Requester
1868
+ # Pays buckets.
1869
+ # @param [String] fields
1870
+ # Selector specifying which fields to include in a partial response.
1871
+ #
1872
+ # @return [Google::Cloud::Storage::File]
1873
+ #
1874
+ # @example
1875
+ # require "google/cloud/storage"
1876
+ #
1877
+ # storage = Google::Cloud::Storage.new
1878
+ #
1879
+ # bucket = storage.bucket "my-bucket"
1880
+ #
1881
+ # bucket.restore_file "path/of/file", <generation-of-the-file>
1882
+ #
1883
+ def restore_file file_path,
1884
+ generation,
1885
+ copy_source_acl: nil,
1886
+ if_generation_match: nil,
1887
+ if_generation_not_match: nil,
1888
+ if_metageneration_match: nil,
1889
+ if_metageneration_not_match: nil,
1890
+ projection: nil,
1891
+ user_project: nil,
1892
+ fields: nil,
1893
+ options: {}
1894
+ ensure_service!
1895
+ gapi = service.restore_file name,
1896
+ file_path,
1897
+ generation,
1898
+ copy_source_acl: File::Acl.predefined_rule_for(copy_source_acl),
1899
+ if_generation_match: if_generation_match,
1900
+ if_generation_not_match: if_generation_not_match,
1901
+ if_metageneration_match: if_metageneration_match,
1902
+ if_metageneration_not_match: if_metageneration_not_match,
1903
+ projection: projection,
1904
+ user_project: user_project,
1905
+ fields: fields,
1906
+ options: options
1907
+ File.from_gapi gapi, service, user_project: user_project
1908
+ end
1909
+
1695
1910
  ##
1696
1911
  # Concatenates a list of existing files in the bucket into a new file in
1697
1912
  # the bucket. There is a limit (currently 32) to the number of files
@@ -2065,6 +2280,31 @@ module Google
2065
2280
  end
2066
2281
  end
2067
2282
 
2283
+ # Fetches generation of the bucket
2284
+ # @example
2285
+ # require "google/cloud/storage"
2286
+ # storage = Google::Cloud::Storage.new
2287
+ # bucket = storage.bucket "my-bucket"
2288
+ # generation= bucket.generation
2289
+ def generation
2290
+ @gapi.generation
2291
+ end
2292
+
2293
+ # Fetches soft_delete_time of a soft deleted bucket
2294
+ # @example
2295
+ # bucket.delete
2296
+ # bucket.soft_delete_time
2297
+ def soft_delete_time
2298
+ @gapi.soft_delete_time
2299
+ end
2300
+
2301
+ # Fetches hard_delete_time of a soft deleted bucket
2302
+ # @example
2303
+ # bucket.hard_delete_time
2304
+ def hard_delete_time
2305
+ @gapi.hard_delete_time
2306
+ end
2307
+
2068
2308
  ##
2069
2309
  # Generate a PostObject that includes the fields and URL to
2070
2310
  # upload objects via HTML forms.
@@ -2903,6 +3143,51 @@ module Google
2903
3143
  end
2904
3144
  alias refresh! reload!
2905
3145
 
3146
+ ##
3147
+ # Moves File from source to destination path within the same HNS-enabled bucket
3148
+ # This Operation is being performed at server side
3149
+ # @param [String] source_file The file name in existing bucket
3150
+ # @param [String] destination_file The new filename to be created on bucket
3151
+ # If the destination path includes non-existent parent folders, they will be created.
3152
+ # @example
3153
+ # require "google/cloud/storage"
3154
+ # storage = Google::Cloud::Storage.new
3155
+ # bucket = storage.bucket bucket_name, skip_lookup: true
3156
+ # bucket.move_file source_file_name, destination_file_name
3157
+ def move_file source_file,
3158
+ destination_file,
3159
+ if_generation_match: nil,
3160
+ if_generation_not_match: nil,
3161
+ if_metageneration_match: nil,
3162
+ if_metageneration_not_match: nil,
3163
+ if_source_generation_match: nil,
3164
+ if_source_generation_not_match: nil,
3165
+ if_source_metageneration_match: nil,
3166
+ if_source_metageneration_not_match: nil,
3167
+ user_project: nil,
3168
+ fields: nil,
3169
+ quota_user: nil,
3170
+ user_ip: nil,
3171
+ options: {}
3172
+ ensure_service!
3173
+ service.move_file name,
3174
+ source_file,
3175
+ destination_file,
3176
+ if_generation_match: if_generation_match,
3177
+ if_generation_not_match: if_generation_not_match,
3178
+ if_metageneration_match: if_metageneration_match,
3179
+ if_metageneration_not_match: if_metageneration_not_match,
3180
+ if_source_generation_match: if_source_generation_match,
3181
+ if_source_generation_not_match: if_source_generation_not_match,
3182
+ if_source_metageneration_match: if_source_metageneration_match,
3183
+ if_source_metageneration_not_match: if_source_metageneration_not_match,
3184
+ user_project: user_project,
3185
+ fields: fields,
3186
+ quota_user: quota_user,
3187
+ user_ip: user_ip,
3188
+ options: options
3189
+ end
3190
+
2906
3191
  ##
2907
3192
  # Determines whether the bucket exists in the Storage service.
2908
3193
  #
@@ -2972,9 +3257,9 @@ module Google
2972
3257
  attributes.flatten!
2973
3258
  return if attributes.empty?
2974
3259
  ensure_service!
2975
- patch_args = Hash[attributes.map do |attr|
3260
+ patch_args = attributes.to_h do |attr|
2976
3261
  [attr, @gapi.send(attr)]
2977
- end]
3262
+ end
2978
3263
  patch_gapi = API::Bucket.new(**patch_args)
2979
3264
  @gapi = service.patch_bucket name,
2980
3265
  patch_gapi,
@@ -2992,9 +3277,9 @@ module Google
2992
3277
  attributes.flatten!
2993
3278
  return if attributes.empty?
2994
3279
  ensure_service!
2995
- update_args = Hash[attributes.map do |attr|
3280
+ update_args = attributes.to_h do |attr|
2996
3281
  [attr, @gapi.send(attr)]
2997
- end]
3282
+ end
2998
3283
  update_gapi = API::Bucket.new(**update_args)
2999
3284
  @gapi = service.update_bucket name,
3000
3285
  update_gapi,