google-cloud-storage 1.45.0 → 1.52.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: 94e0030c8442262a0d7670a5ccc0090efe44f6cdad9170cc7eb800a6acffad9c
4
+ data.tar.gz: 7e4360bab08faa20b814df568f73f708ec8cdd31bb5d90f5fb56292b34636ae3
5
5
  SHA512:
6
- metadata.gz: e5b129dba88921e6aeec6476d60bb17ee603f0cb641194bbeb09531aff568c2290e17ab3f0f290d87976a0b0f35d4f10674dab8fea6deef70d424738a4ce767c
7
- data.tar.gz: 87e4411cda889bb7bdbf0ccddc2a343ae475614c5cab19d8461bcd646ac78016b6be35975255e14c1af1efcd3c5087c9b769b674260a82f936ef4c0456566a19
6
+ metadata.gz: f7180d3b2fa31de1ba73eb811439540c4d12a0cc417500566d1d7316d50c5249e66704fef719bc18417682a757a7a538722628fd4bcf3b31f43aca5d083f23e2
7
+ data.tar.gz: b2a8b010890f3cffcced823aa66806bed2e2b61f4a547848a8c520d0d6d140280522869af668518ca608fcc6a1904541fc626090b5f110bf89f5109fac8a3ba7
data/CHANGELOG.md CHANGED
@@ -1,5 +1,56 @@
1
1
  # Release History
2
2
 
3
+ ### 1.52.0 (2024-05-31)
4
+
5
+ #### Features
6
+
7
+ * support for hierarchical namespace (folders) ([#25967](https://github.com/googleapis/google-cloud-ruby/issues/25967))
8
+
9
+ ### 1.51.0 (2024-04-25)
10
+
11
+ #### Features
12
+
13
+ * Respect custom endpoint for signed_url ([#25469](https://github.com/googleapis/google-cloud-ruby/issues/25469))
14
+
15
+ ### 1.50.0 (2024-04-19)
16
+
17
+ #### Features
18
+
19
+ * Add support for soft deletion ([#25340](https://github.com/googleapis/google-cloud-ruby/issues/25340))
20
+ #### Bug Fixes
21
+
22
+ * Set configured univer_domain and endpoint when initializing through Service ([#25665](https://github.com/googleapis/google-cloud-ruby/issues/25665))
23
+
24
+ ### 1.49.0 (2024-02-21)
25
+
26
+ #### Features
27
+
28
+ * Support of Managed Folders ([#24809](https://github.com/googleapis/google-cloud-ruby/issues/24809))
29
+
30
+ ### 1.48.1 (2024-01-26)
31
+
32
+ #### Bug Fixes
33
+
34
+ * Raise an error on mismatching universe domain ([#24486](https://github.com/googleapis/google-cloud-ruby/issues/24486))
35
+
36
+ ### 1.48.0 (2024-01-25)
37
+
38
+ #### Features
39
+
40
+ * Support for universe_domain ([#24449](https://github.com/googleapis/google-cloud-ruby/issues/24449))
41
+
42
+ ### 1.47.0 (2024-01-09)
43
+
44
+ #### Features
45
+
46
+ * support for object lock / retention ([#23732](https://github.com/googleapis/google-cloud-ruby/issues/23732))
47
+
48
+ ### 1.46.0 (2024-01-08)
49
+
50
+ #### Features
51
+
52
+ * support match_glob for Object.list
53
+
3
54
  ### 1.45.0 (2023-11-06)
4
55
 
5
56
  #### Features
@@ -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
  #
@@ -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
@@ -83,10 +83,12 @@ module Google
83
83
  token: @token,
84
84
  max: @max,
85
85
  versions: @versions,
86
- user_project: @user_project
86
+ user_project: @user_project,
87
+ match_glob: @match_glob
87
88
  File::List.from_gapi gapi, @service, @bucket, @prefix,
88
89
  @delimiter, @max, @versions,
89
- user_project: @user_project
90
+ user_project: @user_project,
91
+ match_glob: @match_glob
90
92
  end
91
93
 
92
94
  ##
@@ -163,7 +165,9 @@ module Google
163
165
  # Google::Apis::StorageV1::Objects object.
164
166
  def self.from_gapi gapi_list, service, bucket = nil, prefix = nil,
165
167
  delimiter = nil, max = nil, versions = nil,
166
- user_project: nil
168
+ user_project: nil, match_glob: nil,
169
+ include_folders_as_prefixes: nil,
170
+ soft_deleted: nil
167
171
  files = new(Array(gapi_list.items).map do |gapi_object|
168
172
  File.from_gapi gapi_object, service, user_project: user_project
169
173
  end)
@@ -176,6 +180,9 @@ module Google
176
180
  files.instance_variable_set :@max, max
177
181
  files.instance_variable_set :@versions, versions
178
182
  files.instance_variable_set :@user_project, user_project
183
+ files.instance_variable_set :@match_glob, match_glob
184
+ files.instance_variable_set :@include_folders_as_prefixes, include_folders_as_prefixes
185
+ files.instance_variable_set :@soft_deleted, soft_deleted
179
186
  files
180
187
  end
181
188
 
@@ -60,7 +60,8 @@ module Google
60
60
  ##
61
61
  # The external url to the file.
62
62
  def ext_url
63
- "#{GOOGLEAPIS_URL}#{ext_path}"
63
+ root_url = @service.service.root_url.chomp "/"
64
+ "#{root_url}#{ext_path}"
64
65
  end
65
66
 
66
67
  def apply_option_defaults options
@@ -301,7 +301,7 @@ module Google
301
301
  ##
302
302
  # The external url to the file.
303
303
  def ext_url scheme, virtual_hosted_style, bucket_bound_hostname
304
- url = GOOGLEAPIS_URL.dup
304
+ url = @service.service.root_url.chomp "/"
305
305
  if virtual_hosted_style
306
306
  parts = url.split "//"
307
307
  parts[1] = "#{@bucket_name}.#{parts[1]}"
@@ -763,6 +763,30 @@ module Google
763
763
  @gapi.retention_expiration_time
764
764
  end
765
765
 
766
+ ##
767
+ # This soft delete time is the time when the object became
768
+ # soft-deleted.
769
+ #
770
+ # @return [DateTime, nil] A DateTime representing the time at
771
+ # which the object became soft-deleted, or `nil` if the file was
772
+ # not deleted.
773
+ #
774
+ def soft_delete_time
775
+ @gapi.soft_delete_time
776
+ end
777
+
778
+ ##
779
+ # This hard delete time is The time when the file will be permanently
780
+ # deleted.
781
+ #
782
+ # @return [DateTime, nil] A DateTime representing the time at
783
+ # which the file will be permanently deleted, or `nil` if the file is
784
+ # not soft deleted.
785
+ #
786
+ def hard_delete_time
787
+ @gapi.hard_delete_time
788
+ end
789
+
766
790
  ##
767
791
  # Retrieves a list of versioned files for the current object.
768
792
  #
@@ -825,6 +849,9 @@ module Google
825
849
  # @param [Integer] if_metageneration_not_match Makes the operation
826
850
  # conditional on whether the file's current metageneration does not
827
851
  # match the given value.
852
+ # @param [Boolean] override_unlocked_retention
853
+ # Must be true to remove the retention configuration, reduce its unlocked
854
+ # retention period, or change its mode from unlocked to locked.
828
855
  #
829
856
  # @yield [file] a block yielding a delegate object for updating the file
830
857
  #
@@ -865,7 +892,8 @@ module Google
865
892
  if_generation_match: nil,
866
893
  if_generation_not_match: nil,
867
894
  if_metageneration_match: nil,
868
- if_metageneration_not_match: nil
895
+ if_metageneration_not_match: nil,
896
+ override_unlocked_retention: nil
869
897
  updater = Updater.new gapi
870
898
  yield updater
871
899
  updater.check_for_changed_metadata!
@@ -875,7 +903,8 @@ module Google
875
903
  if_generation_match: if_generation_match,
876
904
  if_generation_not_match: if_generation_not_match,
877
905
  if_metageneration_match: if_metageneration_match,
878
- if_metageneration_not_match: if_metageneration_not_match
906
+ if_metageneration_not_match: if_metageneration_not_match,
907
+ override_unlocked_retention: override_unlocked_retention
879
908
  end
880
909
 
881
910
  ##
@@ -1560,6 +1589,64 @@ module Google
1560
1589
  true
1561
1590
  end
1562
1591
 
1592
+ # Mode of object level retention configuration.
1593
+ # Valid values are 'Locked' or 'Unlocked'
1594
+ #
1595
+ # @return [String]
1596
+ def retention_mode
1597
+ @gapi.retention&.mode
1598
+ end
1599
+
1600
+ # The earliest time in RFC 3339 UTC "Zulu" format that the object can
1601
+ # be deleted or replaced.
1602
+ #
1603
+ # @return [DateTime]
1604
+ def retention_retain_until_time
1605
+ @gapi.retention&.retain_until_time
1606
+ end
1607
+
1608
+ # A collection of object level retention parameters.
1609
+ # The full list of available options are outlined at the [JSON API docs]
1610
+ # (https://cloud.google.com/storage/docs/json_api/v1/objects/insert#request-body).
1611
+ #
1612
+ # @return [Google::Apis::StorageV1::Object::Retention]
1613
+ def retention
1614
+ @gapi.retention
1615
+ end
1616
+
1617
+ ##
1618
+ # Update method to update retention parameter of an object / file
1619
+ # It accepts params as a Hash of attributes in the following format:
1620
+ #
1621
+ # { mode: 'Locked|Unlocked', retain_until_time: '2023-12-19T03:22:23+00:00' }
1622
+ #
1623
+ # @param [Hash(String => String)] new_retention_attributes
1624
+ #
1625
+ # @example Update retention parameters for the File / Object
1626
+ # require "google/cloud/storage"
1627
+ # storage = Google::Cloud::Storage.new
1628
+ # bucket = storage.bucket "my-bucket"
1629
+ # file = bucket.file "avatars/heidi/400x400.png"
1630
+ # retention_params = { mode: 'Unlocked', retain_until_time: '2023-12-19T03:22:23+00:00'.to_datetime }
1631
+ # file.retention = retention_params
1632
+ #
1633
+ # @example Update retention parameters for the File / Object with override enabled
1634
+ # require "google/cloud/storage"
1635
+ # storage = Google::Cloud::Storage.new
1636
+ # bucket = storage.bucket "my-bucket"
1637
+ # file = bucket.file "avatars/heidi/400x400.png"
1638
+ # retention_params = { mode: 'Unlocked',
1639
+ # retain_until_time: '2023-12-19T03:22:23+00:00'.to_datetime,
1640
+ # override_unlocked_retention: true }
1641
+ # file.retention = retention_params
1642
+ #
1643
+ def retention= new_retention_attributes
1644
+ @gapi.retention ||= Google::Apis::StorageV1::Object::Retention.new
1645
+ @gapi.retention.mode = new_retention_attributes[:mode]
1646
+ @gapi.retention.retain_until_time = new_retention_attributes[:retain_until_time]
1647
+ update_gapi! :retention, override_unlocked_retention: new_retention_attributes[:override_unlocked_retention]
1648
+ end
1649
+
1563
1650
  ##
1564
1651
  # Public URL to access the file. If the file is not public, requests to
1565
1652
  # the URL will return an error. (See {File::Acl#public!} and
@@ -2015,7 +2102,8 @@ module Google
2015
2102
  if_generation_match: nil,
2016
2103
  if_generation_not_match: nil,
2017
2104
  if_metageneration_match: nil,
2018
- if_metageneration_not_match: nil
2105
+ if_metageneration_not_match: nil,
2106
+ override_unlocked_retention: nil
2019
2107
  attributes = Array(attributes)
2020
2108
  attributes.flatten!
2021
2109
  return if attributes.empty?
@@ -2044,7 +2132,8 @@ module Google
2044
2132
  if_generation_not_match: if_generation_not_match,
2045
2133
  if_metageneration_match: if_metageneration_match,
2046
2134
  if_metageneration_not_match: if_metageneration_not_match,
2047
- user_project: user_project
2135
+ user_project: user_project,
2136
+ override_unlocked_retention: override_unlocked_retention
2048
2137
  end
2049
2138
  end
2050
2139
 
@@ -62,6 +62,15 @@ module Google
62
62
  @service = service
63
63
  end
64
64
 
65
+ ##
66
+ # The universe domain the client is connected to
67
+ #
68
+ # @return [String]
69
+ #
70
+ def universe_domain
71
+ service.universe_domain
72
+ end
73
+
65
74
  ##
66
75
  # The Storage project connected to.
67
76
  #
@@ -372,6 +381,8 @@ module Google
372
381
  # bucket instance and its files.
373
382
  #
374
383
  # See also {Bucket#requester_pays=} and {Bucket#requester_pays}.
384
+ # @param [Boolean] enable_object_retention
385
+ # When set to true, object retention is enabled for this bucket.
375
386
  #
376
387
  # @yield [bucket] a block for configuring the bucket before it is
377
388
  # created
@@ -386,6 +397,13 @@ module Google
386
397
  #
387
398
  # bucket = storage.create_bucket "my-bucket"
388
399
  #
400
+ # @example
401
+ # require "google/cloud/storage"
402
+ #
403
+ # storage = Google::Cloud::Storage.new
404
+ #
405
+ # bucket = storage.create_bucket "my-bucket", enable_object_retention: true
406
+ #
389
407
  # @example Configure the bucket in a block:
390
408
  # require "google/cloud/storage"
391
409
  #
@@ -403,6 +421,7 @@ module Google
403
421
  # b.lifecycle.add_set_storage_class_rule "COLDLINE", age: 10
404
422
  # end
405
423
  #
424
+ # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
406
425
  def create_bucket bucket_name,
407
426
  acl: nil,
408
427
  default_acl: nil,
@@ -416,11 +435,14 @@ module Google
416
435
  versioning: nil,
417
436
  requester_pays: nil,
418
437
  user_project: nil,
419
- autoclass_enabled: false
438
+ autoclass_enabled: false,
439
+ enable_object_retention: nil,
440
+ hierarchical_namespace: nil
420
441
  params = {
421
442
  name: bucket_name,
422
443
  location: location,
423
- custom_placement_config: custom_placement_config
444
+ custom_placement_config: custom_placement_config,
445
+ hierarchical_namespace: hierarchical_namespace
424
446
  }.delete_if { |_, v| v.nil? }
425
447
  new_bucket = Google::Apis::StorageV1::Bucket.new(**params)
426
448
  storage_class = storage_class_for storage_class
@@ -433,6 +455,7 @@ module Google
433
455
  b.website_404 = website_404 unless website_404.nil?
434
456
  b.versioning = versioning unless versioning.nil?
435
457
  b.requester_pays = requester_pays unless requester_pays.nil?
458
+ b.hierarchical_namespace = hierarchical_namespace unless hierarchical_namespace.nil?
436
459
  end
437
460
  yield updater if block_given?
438
461
  updater.check_for_changed_labels!
@@ -440,9 +463,11 @@ module Google
440
463
  updater.check_for_mutable_lifecycle!
441
464
  gapi = service.insert_bucket \
442
465
  new_bucket, acl: acl_rule(acl), default_acl: acl_rule(default_acl),
443
- user_project: user_project
466
+ user_project: user_project,
467
+ enable_object_retention: enable_object_retention
444
468
  Bucket.from_gapi gapi, service, user_project: user_project
445
469
  end
470
+ # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
446
471
 
447
472
  ##
448
473
  # Creates a new HMAC key.
@@ -15,6 +15,7 @@
15
15
 
16
16
  require "google/cloud/storage/version"
17
17
  require "google/apis/storage_v1"
18
+ require "google/cloud/config"
18
19
  require "digest"
19
20
  require "mini_mime"
20
21
  require "pathname"
@@ -36,6 +37,11 @@ module Google
36
37
  # @private
37
38
  attr_accessor :credentials
38
39
 
40
+ # @private
41
+ def universe_domain
42
+ service.universe_domain
43
+ end
44
+
39
45
  ##
40
46
  # Creates a new Service instance.
41
47
  # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
@@ -43,7 +49,8 @@ module Google
43
49
  timeout: nil, open_timeout: nil, read_timeout: nil,
44
50
  send_timeout: nil, host: nil, quota_project: nil,
45
51
  max_elapsed_time: nil, base_interval: nil, max_interval: nil,
46
- multiplier: nil, upload_chunk_size: nil
52
+ multiplier: nil, upload_chunk_size: nil, universe_domain: nil
53
+ host ||= Google::Cloud::Storage.configure.endpoint
47
54
  @project = project
48
55
  @credentials = credentials
49
56
  @service = API::StorageService.new
@@ -68,6 +75,13 @@ module Google
68
75
  @service.request_options.upload_chunk_size = upload_chunk_size if upload_chunk_size
69
76
  @service.authorization = @credentials.client if @credentials
70
77
  @service.root_url = host if host
78
+ @service.universe_domain = universe_domain || Google::Cloud::Storage.configure.universe_domain
79
+ begin
80
+ @service.verify_universe_domain!
81
+ rescue Google::Apis::UniverseDomainError => e
82
+ # TODO: Create a Google::Cloud::Error subclass for this.
83
+ raise Google::Cloud::Error, e.message
84
+ end
71
85
  end
72
86
  # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
73
87
 
@@ -112,14 +126,16 @@ module Google
112
126
  # Creates a new bucket.
113
127
  # Returns Google::Apis::StorageV1::Bucket.
114
128
  def insert_bucket bucket_gapi, acl: nil, default_acl: nil,
115
- user_project: nil, options: {}
129
+ user_project: nil, enable_object_retention: nil,
130
+ options: {}
116
131
  execute do
117
132
  service.insert_bucket \
118
133
  @project, bucket_gapi,
119
134
  predefined_acl: acl,
120
135
  predefined_default_object_acl: default_acl,
121
136
  user_project: user_project(user_project),
122
- options: options
137
+ options: options,
138
+ enable_object_retention: enable_object_retention
123
139
  end
124
140
  end
125
141
 
@@ -349,13 +365,17 @@ module Google
349
365
  # Retrieves a list of files matching the criteria.
350
366
  def list_files bucket_name, delimiter: nil, max: nil, token: nil,
351
367
  prefix: nil, versions: nil, user_project: nil,
352
- options: {}
368
+ match_glob: nil, include_folders_as_prefixes: nil,
369
+ soft_deleted: nil, options: {}
353
370
  execute do
354
371
  service.list_objects \
355
372
  bucket_name, delimiter: delimiter, max_results: max,
356
373
  page_token: token, prefix: prefix,
357
374
  versions: versions,
358
375
  user_project: user_project(user_project),
376
+ match_glob: match_glob,
377
+ include_folders_as_prefixes: include_folders_as_prefixes,
378
+ soft_deleted: soft_deleted,
359
379
  options: options
360
380
  end
361
381
  end
@@ -439,6 +459,7 @@ module Google
439
459
  if_metageneration_not_match: nil,
440
460
  key: nil,
441
461
  user_project: nil,
462
+ soft_deleted: nil,
442
463
  options: {}
443
464
  execute do
444
465
  service.get_object \
@@ -449,6 +470,7 @@ module Google
449
470
  if_metageneration_match: if_metageneration_match,
450
471
  if_metageneration_not_match: if_metageneration_not_match,
451
472
  user_project: user_project(user_project),
473
+ soft_deleted: soft_deleted,
452
474
  options: key_options(key).merge(options)
453
475
  end
454
476
  end
@@ -580,6 +602,7 @@ module Google
580
602
  if_metageneration_not_match: nil,
581
603
  predefined_acl: nil,
582
604
  user_project: nil,
605
+ override_unlocked_retention: nil,
583
606
  options: {}
584
607
  file_gapi ||= Google::Apis::StorageV1::Object.new
585
608
 
@@ -599,6 +622,7 @@ module Google
599
622
  if_metageneration_not_match: if_metageneration_not_match,
600
623
  predefined_acl: predefined_acl,
601
624
  user_project: user_project(user_project),
625
+ override_unlocked_retention: override_unlocked_retention,
602
626
  options: options
603
627
  end
604
628
  end
@@ -632,6 +656,40 @@ module Google
632
656
  end
633
657
  end
634
658
 
659
+ ##
660
+ # Restores a soft-deleted object.
661
+ def restore_file bucket_name,
662
+ file_path,
663
+ generation,
664
+ copy_source_acl: nil,
665
+ if_generation_match: nil,
666
+ if_generation_not_match: nil,
667
+ if_metageneration_match: nil,
668
+ if_metageneration_not_match: nil,
669
+ projection: nil,
670
+ user_project: nil,
671
+ fields: nil,
672
+ options: {}
673
+
674
+ if options[:retries].nil?
675
+ is_idempotent = retry? generation: generation, if_generation_match: if_generation_match
676
+ options = is_idempotent ? {} : { retries: 0 }
677
+ end
678
+
679
+ execute do
680
+ service.restore_object bucket_name, file_path, generation,
681
+ copy_source_acl: copy_source_acl,
682
+ if_generation_match: if_generation_match,
683
+ if_generation_not_match: if_generation_not_match,
684
+ if_metageneration_match: if_metageneration_match,
685
+ if_metageneration_not_match: if_metageneration_not_match,
686
+ projection: projection,
687
+ user_project: user_project(user_project),
688
+ fields: fields,
689
+ options: options
690
+ end
691
+ end
692
+
635
693
  ##
636
694
  # Retrieves a list of ACLs for the given file.
637
695
  def list_file_acls bucket_name, file_name, user_project: nil, options: {}
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Storage
19
- VERSION = "1.45.0".freeze
19
+ VERSION = "1.52.0".freeze
20
20
  end
21
21
  end
22
22
  end
@@ -67,6 +67,8 @@ module Google
67
67
  # @param [Integer] send_timeout How long, in seconds, before receiving response from server times out. Optional.
68
68
  # @param [String] endpoint Override of the endpoint host name. Optional.
69
69
  # If the param is nil, uses the default endpoint.
70
+ # @param universe_domain [String] Override of the universe domain. Optional.
71
+ # If unset or nil, uses the default unvierse domain
70
72
  # @param [Integer] upload_chunk_size The chunk size of storage upload, in bytes.
71
73
  # The default value is 100 MB, i.e. 104_857_600 bytes. To disable chunking and upload
72
74
  # the complete file regardless of size, pass 0 as the chunk size.
@@ -92,7 +94,7 @@ module Google
92
94
  timeout: nil, open_timeout: nil, read_timeout: nil,
93
95
  send_timeout: nil, endpoint: nil, project: nil, keyfile: nil,
94
96
  max_elapsed_time: nil, base_interval: nil, max_interval: nil,
95
- multiplier: nil, upload_chunk_size: nil
97
+ multiplier: nil, upload_chunk_size: nil, universe_domain: nil
96
98
  scope ||= configure.scope
97
99
  retries ||= configure.retries
98
100
  timeout ||= configure.timeout
@@ -106,6 +108,7 @@ module Google
106
108
  max_interval ||= configure.max_interval
107
109
  multiplier ||= configure.multiplier
108
110
  upload_chunk_size ||= configure.upload_chunk_size
111
+ universe_domain ||= configure.universe_domain
109
112
 
110
113
  unless credentials.is_a? Google::Auth::Credentials
111
114
  credentials = Storage::Credentials.new credentials, scope: scope
@@ -121,7 +124,8 @@ module Google
121
124
  read_timeout: read_timeout, send_timeout: send_timeout,
122
125
  host: endpoint, quota_project: configure.quota_project,
123
126
  max_elapsed_time: max_elapsed_time, base_interval: base_interval,
124
- max_interval: max_interval, multiplier: multiplier, upload_chunk_size: upload_chunk_size
127
+ max_interval: max_interval, multiplier: multiplier, upload_chunk_size: upload_chunk_size,
128
+ universe_domain: universe_domain
125
129
  )
126
130
  )
127
131
  end
@@ -145,6 +149,8 @@ module Google
145
149
  # @param [Integer] send_timeout How long, in seconds, before receiving response from server times out. Optional.
146
150
  # @param [String] endpoint Override of the endpoint host name. Optional.
147
151
  # If the param is nil, uses the default endpoint.
152
+ # @param universe_domain [String] Override of the universe domain. Optional.
153
+ # If unset or nil, uses the default unvierse domain
148
154
  # @param [Integer] upload_chunk_size The chunk size of storage upload, in bytes.
149
155
  # The default value is 100 MB, i.e. 104_857_600 bytes. To disable chunking and upload
150
156
  # the complete file regardless of size, pass 0 as the chunk size.
@@ -166,7 +172,7 @@ module Google
166
172
  def self.anonymous retries: nil, timeout: nil, open_timeout: nil,
167
173
  read_timeout: nil, send_timeout: nil, endpoint: nil,
168
174
  max_elapsed_time: nil, base_interval: nil, max_interval: nil,
169
- multiplier: nil, upload_chunk_size: nil
175
+ multiplier: nil, upload_chunk_size: nil, universe_domain: nil
170
176
  open_timeout ||= timeout
171
177
  read_timeout ||= timeout
172
178
  send_timeout ||= timeout
@@ -175,7 +181,8 @@ module Google
175
181
  nil, nil, retries: retries, timeout: timeout, open_timeout: open_timeout,
176
182
  read_timeout: read_timeout, send_timeout: send_timeout, host: endpoint,
177
183
  max_elapsed_time: max_elapsed_time, base_interval: base_interval,
178
- max_interval: max_interval, multiplier: multiplier, upload_chunk_size: upload_chunk_size
184
+ max_interval: max_interval, multiplier: multiplier, upload_chunk_size: upload_chunk_size,
185
+ universe_domain: universe_domain
179
186
  )
180
187
  )
181
188
  end
@@ -192,7 +192,7 @@ Google::Cloud.configure.add_config! :storage do |config|
192
192
  config.add_field! :read_timeout, nil, match: Integer
193
193
  config.add_field! :send_timeout, nil, match: Integer
194
194
  config.add_field! :upload_chunk_size, nil, match: Integer
195
- # TODO: Remove once discovery document is updated.
196
- config.add_field! :endpoint, "https://storage.googleapis.com/", match: String
195
+ config.add_field! :endpoint, nil, match: String, allow_nil: true
196
+ config.add_field! :universe_domain, nil, match: String, allow_nil: true
197
197
  end
198
198
  # rubocop:enable Metrics/BlockLength
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-cloud-storage
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.45.0
4
+ version: 1.52.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Moore
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-11-06 00:00:00.000000000 Z
12
+ date: 2024-05-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: google-cloud-core
@@ -25,54 +25,62 @@ dependencies:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
27
  version: '1.6'
28
+ - !ruby/object:Gem::Dependency
29
+ name: google-apis-core
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '0.13'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '0.13'
28
42
  - !ruby/object:Gem::Dependency
29
43
  name: google-apis-iamcredentials_v1
30
44
  requirement: !ruby/object:Gem::Requirement
31
45
  requirements:
32
46
  - - "~>"
33
47
  - !ruby/object:Gem::Version
34
- version: '0.1'
48
+ version: '0.18'
35
49
  type: :runtime
36
50
  prerelease: false
37
51
  version_requirements: !ruby/object:Gem::Requirement
38
52
  requirements:
39
53
  - - "~>"
40
54
  - !ruby/object:Gem::Version
41
- version: '0.1'
55
+ version: '0.18'
42
56
  - !ruby/object:Gem::Dependency
43
57
  name: google-apis-storage_v1
44
58
  requirement: !ruby/object:Gem::Requirement
45
59
  requirements:
46
60
  - - "~>"
47
61
  - !ruby/object:Gem::Version
48
- version: 0.29.0
62
+ version: '0.38'
49
63
  type: :runtime
50
64
  prerelease: false
51
65
  version_requirements: !ruby/object:Gem::Requirement
52
66
  requirements:
53
67
  - - "~>"
54
68
  - !ruby/object:Gem::Version
55
- version: 0.29.0
69
+ version: '0.38'
56
70
  - !ruby/object:Gem::Dependency
57
71
  name: googleauth
58
72
  requirement: !ruby/object:Gem::Requirement
59
73
  requirements:
60
- - - ">="
61
- - !ruby/object:Gem::Version
62
- version: 0.16.2
63
- - - "<"
74
+ - - "~>"
64
75
  - !ruby/object:Gem::Version
65
- version: 2.a
76
+ version: '1.9'
66
77
  type: :runtime
67
78
  prerelease: false
68
79
  version_requirements: !ruby/object:Gem::Requirement
69
80
  requirements:
70
- - - ">="
71
- - !ruby/object:Gem::Version
72
- version: 0.16.2
73
- - - "<"
81
+ - - "~>"
74
82
  - !ruby/object:Gem::Version
75
- version: 2.a
83
+ version: '1.9'
76
84
  - !ruby/object:Gem::Dependency
77
85
  name: digest-crc
78
86
  requirement: !ruby/object:Gem::Requirement
@@ -325,14 +333,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
325
333
  requirements:
326
334
  - - ">="
327
335
  - !ruby/object:Gem::Version
328
- version: '2.5'
336
+ version: '2.7'
329
337
  required_rubygems_version: !ruby/object:Gem::Requirement
330
338
  requirements:
331
339
  - - ">="
332
340
  - !ruby/object:Gem::Version
333
341
  version: '0'
334
342
  requirements: []
335
- rubygems_version: 3.4.19
343
+ rubygems_version: 3.5.6
336
344
  signing_key:
337
345
  specification_version: 4
338
346
  summary: API Client library for Google Cloud Storage