google-cloud-storage 1.49.0 → 1.50.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: f8a2a526a042472efc68bca61aecd13daab3329949890543c73e499d19b1bf91
4
- data.tar.gz: 152a633c29980d1c645e8d0c96100f60d245ea1d1844407bb12c8a689b231892
3
+ metadata.gz: 7e0893d52c3f3ee58e75361a0b79d172a04d37f1bc95295124a2e494b1a17a7a
4
+ data.tar.gz: e1ba0496153f4317461324fdfc2bc15de917616abf5eb844659e1fbc55c6c084
5
5
  SHA512:
6
- metadata.gz: 8086edce323f96ad7826ab121e5b3fc12d94a4695838259e5c7f90f0607414c6f6516c63318888c2d8022a4b0440692d06d57e016081a35f06c27c6591a1269a
7
- data.tar.gz: 286c58007dc3ef084ed5947e01a38aefa09aa01b7eb121f2a99eab34aef8d1577cd3c8c738d7b58d6ef51f5c1817a1618380b35c961bdb5ff5ac159c8d0f941e
6
+ metadata.gz: ad283cf07a70951aeb8f9e842d7dd20d2f3ef716f3bb4df8fbade6f1ab3f08cf052897176b10cf1c72d6925fae86ae688c214368da44b434ab3e76dd1a4420c8
7
+ data.tar.gz: 3067805b0d16ded711bd4cc2913cbefa290466b1d25bec4b7adb93f7d81a3d64db93b70cf165b8c1089de12460d772c112b61fd3e988b58d79278ed92bf053f4
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Release History
2
2
 
3
+ ### 1.50.0 (2024-04-19)
4
+
5
+ #### Features
6
+
7
+ * Add support for soft deletion ([#25340](https://github.com/googleapis/google-cloud-ruby/issues/25340))
8
+ #### Bug Fixes
9
+
10
+ * Set configured univer_domain and endpoint when initializing through Service ([#25665](https://github.com/googleapis/google-cloud-ruby/issues/25665))
11
+
3
12
  ### 1.49.0 (2024-02-21)
4
13
 
5
14
  #### Features
@@ -1194,6 +1194,65 @@ module Google
1194
1194
  patch_gapi! :rpo
1195
1195
  end
1196
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
+
1197
1256
  ##
1198
1257
  # Updates the bucket with changes made in the given block in a single
1199
1258
  # PATCH request. The following attributes may be set: {#cors},
@@ -1322,6 +1381,8 @@ module Google
1322
1381
  # @param [Boolean] include_folders_as_prefixes If `true`, will also include
1323
1382
  # folders and managed folders, besides objects, in the returned prefixes.
1324
1383
  # Only applicable if delimiter is set to '/'.
1384
+ # @param [Boolean] soft_deleted If true, only soft-deleted object
1385
+ # versions will be listed. The default is false.
1325
1386
  #
1326
1387
  # @return [Array<Google::Cloud::Storage::File>] (See
1327
1388
  # {Google::Cloud::Storage::File::List})
@@ -1349,19 +1410,22 @@ module Google
1349
1410
  # end
1350
1411
  #
1351
1412
  def files prefix: nil, delimiter: nil, token: nil, max: nil,
1352
- versions: nil, match_glob: nil, include_folders_as_prefixes: nil
1413
+ versions: nil, match_glob: nil, include_folders_as_prefixes: nil,
1414
+ soft_deleted: nil
1353
1415
  ensure_service!
1354
1416
  gapi = service.list_files name, prefix: prefix, delimiter: delimiter,
1355
1417
  token: token, max: max,
1356
1418
  versions: versions,
1357
1419
  user_project: user_project,
1358
1420
  match_glob: match_glob,
1359
- include_folders_as_prefixes: include_folders_as_prefixes
1421
+ include_folders_as_prefixes: include_folders_as_prefixes,
1422
+ soft_deleted: soft_deleted
1360
1423
  File::List.from_gapi gapi, service, name, prefix, delimiter, max,
1361
1424
  versions,
1362
1425
  user_project: user_project,
1363
1426
  match_glob: match_glob,
1364
- include_folders_as_prefixes: include_folders_as_prefixes
1427
+ include_folders_as_prefixes: include_folders_as_prefixes,
1428
+ soft_deleted: soft_deleted
1365
1429
  end
1366
1430
  alias find_files files
1367
1431
 
@@ -1397,6 +1461,8 @@ module Google
1397
1461
  # @param [String] encryption_key Optional. The customer-supplied,
1398
1462
  # AES-256 encryption key used to encrypt the file, if one was provided
1399
1463
  # to {#create_file}. (Not used if `skip_lookup` is also set.)
1464
+ # @param [Boolean] soft_deleted Optional. If true, only soft-deleted
1465
+ # object versions will be listed. The default is false.
1400
1466
  #
1401
1467
  # @return [Google::Cloud::Storage::File, nil] Returns nil if file does
1402
1468
  # not exist
@@ -1418,7 +1484,8 @@ module Google
1418
1484
  if_metageneration_match: nil,
1419
1485
  if_metageneration_not_match: nil,
1420
1486
  skip_lookup: nil,
1421
- encryption_key: nil
1487
+ encryption_key: nil,
1488
+ soft_deleted: nil
1422
1489
  ensure_service!
1423
1490
  if skip_lookup
1424
1491
  return File.new_lazy name, path, service,
@@ -1431,7 +1498,8 @@ module Google
1431
1498
  if_metageneration_match: if_metageneration_match,
1432
1499
  if_metageneration_not_match: if_metageneration_not_match,
1433
1500
  key: encryption_key,
1434
- user_project: user_project
1501
+ user_project: user_project,
1502
+ soft_deleted: soft_deleted
1435
1503
  File.from_gapi gapi, service, user_project: user_project
1436
1504
  rescue Google::Cloud::NotFoundError
1437
1505
  nil
@@ -1712,6 +1780,77 @@ module Google
1712
1780
  alias upload_file create_file
1713
1781
  alias new_file create_file
1714
1782
 
1783
+ ##
1784
+ # Restores a soft-deleted object.
1785
+ #
1786
+ # @param [String] file_path
1787
+ # Name of the file.
1788
+ # @param [Fixnum] generation
1789
+ # Selects a specific revision of this object.
1790
+ # @param [Boolean] copy_source_acl
1791
+ # If true, copies the source file's ACL; otherwise, uses the
1792
+ # bucket's default file ACL. The default is false.
1793
+ # @param [Fixnum] if_generation_match
1794
+ # Makes the operation conditional on whether the file's one live
1795
+ # generation matches the given value. Setting to 0 makes the
1796
+ # operation succeed only if there are no live versions of the file.
1797
+ # @param [Fixnum] if_generation_not_match
1798
+ # Makes the operation conditional on whether none of the file's live
1799
+ # generations match the given value. If no live file exists, the
1800
+ # precondition fails. Setting to 0 makes the operation succeed only
1801
+ # if there is a live version of the file.
1802
+ # @param [Fixnum] if_metageneration_match
1803
+ # Makes the operation conditional on whether the file's one live
1804
+ # metageneration matches the given value.
1805
+ # @param [Fixnum] if_metageneration_not_match
1806
+ # Makes the operation conditional on whether none of the object's
1807
+ # live metagenerations match the given value.
1808
+ # @param [String] projection
1809
+ # Set of properties to return. Defaults to full.
1810
+ # @param [String] user_project
1811
+ # The project to be billed for this request. Required for Requester
1812
+ # Pays buckets.
1813
+ # @param [String] fields
1814
+ # Selector specifying which fields to include in a partial response.
1815
+ #
1816
+ # @return [Google::Cloud::Storage::File]
1817
+ #
1818
+ # @example
1819
+ # require "google/cloud/storage"
1820
+ #
1821
+ # storage = Google::Cloud::Storage.new
1822
+ #
1823
+ # bucket = storage.bucket "my-bucket"
1824
+ #
1825
+ # bucket.restore_file "path/of/file", <generation-of-the-file>
1826
+ #
1827
+ def restore_file file_path,
1828
+ generation,
1829
+ copy_source_acl: nil,
1830
+ if_generation_match: nil,
1831
+ if_generation_not_match: nil,
1832
+ if_metageneration_match: nil,
1833
+ if_metageneration_not_match: nil,
1834
+ projection: nil,
1835
+ user_project: nil,
1836
+ fields: nil,
1837
+ options: {}
1838
+ ensure_service!
1839
+ gapi = service.restore_file name,
1840
+ file_path,
1841
+ generation,
1842
+ copy_source_acl: File::Acl.predefined_rule_for(copy_source_acl),
1843
+ if_generation_match: if_generation_match,
1844
+ if_generation_not_match: if_generation_not_match,
1845
+ if_metageneration_match: if_metageneration_match,
1846
+ if_metageneration_not_match: if_metageneration_not_match,
1847
+ projection: projection,
1848
+ user_project: user_project,
1849
+ fields: fields,
1850
+ options: options
1851
+ File.from_gapi gapi, service, user_project: user_project
1852
+ end
1853
+
1715
1854
  ##
1716
1855
  # Concatenates a list of existing files in the bucket into a new file in
1717
1856
  # the bucket. There is a limit (currently 32) to the number of files
@@ -166,7 +166,8 @@ module Google
166
166
  def self.from_gapi gapi_list, service, bucket = nil, prefix = nil,
167
167
  delimiter = nil, max = nil, versions = nil,
168
168
  user_project: nil, match_glob: nil,
169
- include_folders_as_prefixes: nil
169
+ include_folders_as_prefixes: nil,
170
+ soft_deleted: nil
170
171
  files = new(Array(gapi_list.items).map do |gapi_object|
171
172
  File.from_gapi gapi_object, service, user_project: user_project
172
173
  end)
@@ -181,6 +182,7 @@ module Google
181
182
  files.instance_variable_set :@user_project, user_project
182
183
  files.instance_variable_set :@match_glob, match_glob
183
184
  files.instance_variable_set :@include_folders_as_prefixes, include_folders_as_prefixes
185
+ files.instance_variable_set :@soft_deleted, soft_deleted
184
186
  files
185
187
  end
186
188
 
@@ -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
  #
@@ -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"
@@ -49,6 +50,7 @@ module Google
49
50
  send_timeout: nil, host: nil, quota_project: nil,
50
51
  max_elapsed_time: nil, base_interval: nil, max_interval: nil,
51
52
  multiplier: nil, upload_chunk_size: nil, universe_domain: nil
53
+ host ||= Google::Cloud::Storage.configure.endpoint
52
54
  @project = project
53
55
  @credentials = credentials
54
56
  @service = API::StorageService.new
@@ -73,7 +75,7 @@ module Google
73
75
  @service.request_options.upload_chunk_size = upload_chunk_size if upload_chunk_size
74
76
  @service.authorization = @credentials.client if @credentials
75
77
  @service.root_url = host if host
76
- @service.universe_domain = universe_domain
78
+ @service.universe_domain = universe_domain || Google::Cloud::Storage.configure.universe_domain
77
79
  begin
78
80
  @service.verify_universe_domain!
79
81
  rescue Google::Apis::UniverseDomainError => e
@@ -364,7 +366,7 @@ module Google
364
366
  def list_files bucket_name, delimiter: nil, max: nil, token: nil,
365
367
  prefix: nil, versions: nil, user_project: nil,
366
368
  match_glob: nil, include_folders_as_prefixes: nil,
367
- options: {}
369
+ soft_deleted: nil, options: {}
368
370
  execute do
369
371
  service.list_objects \
370
372
  bucket_name, delimiter: delimiter, max_results: max,
@@ -373,6 +375,7 @@ module Google
373
375
  user_project: user_project(user_project),
374
376
  match_glob: match_glob,
375
377
  include_folders_as_prefixes: include_folders_as_prefixes,
378
+ soft_deleted: soft_deleted,
376
379
  options: options
377
380
  end
378
381
  end
@@ -456,6 +459,7 @@ module Google
456
459
  if_metageneration_not_match: nil,
457
460
  key: nil,
458
461
  user_project: nil,
462
+ soft_deleted: nil,
459
463
  options: {}
460
464
  execute do
461
465
  service.get_object \
@@ -466,6 +470,7 @@ module Google
466
470
  if_metageneration_match: if_metageneration_match,
467
471
  if_metageneration_not_match: if_metageneration_not_match,
468
472
  user_project: user_project(user_project),
473
+ soft_deleted: soft_deleted,
469
474
  options: key_options(key).merge(options)
470
475
  end
471
476
  end
@@ -651,6 +656,40 @@ module Google
651
656
  end
652
657
  end
653
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
+
654
693
  ##
655
694
  # Retrieves a list of ACLs for the given file.
656
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.49.0".freeze
19
+ VERSION = "1.50.0".freeze
20
20
  end
21
21
  end
22
22
  end
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.49.0
4
+ version: 1.50.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: 2024-02-21 00:00:00.000000000 Z
12
+ date: 2024-04-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: google-cloud-core
@@ -59,14 +59,14 @@ dependencies:
59
59
  requirements:
60
60
  - - "~>"
61
61
  - !ruby/object:Gem::Version
62
- version: '0.33'
62
+ version: '0.37'
63
63
  type: :runtime
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - "~>"
68
68
  - !ruby/object:Gem::Version
69
- version: '0.33'
69
+ version: '0.37'
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: googleauth
72
72
  requirement: !ruby/object:Gem::Requirement
@@ -340,7 +340,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
340
340
  - !ruby/object:Gem::Version
341
341
  version: '0'
342
342
  requirements: []
343
- rubygems_version: 3.5.3
343
+ rubygems_version: 3.5.6
344
344
  signing_key:
345
345
  specification_version: 4
346
346
  summary: API Client library for Google Cloud Storage