google-cloud-storage 1.48.1 → 1.50.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0ba208497567ec78a35a17309d8f7510a26cbfa304522fef436c32b607c7a295
4
- data.tar.gz: 2e9294c55434f76c3723d1408c5b777c7bd195f4405ec08d88b8d33903136b60
3
+ metadata.gz: 7e0893d52c3f3ee58e75361a0b79d172a04d37f1bc95295124a2e494b1a17a7a
4
+ data.tar.gz: e1ba0496153f4317461324fdfc2bc15de917616abf5eb844659e1fbc55c6c084
5
5
  SHA512:
6
- metadata.gz: 0f31dd1e06029deba139bd8da0551d44664890b88cb6259428f1d150268693aabc3f9e05892108cf38d2c25d18d8046f200c4fbdc6087594f12e8761dc2e7f90
7
- data.tar.gz: f0d6919dbb3d252c069ed2673e3dbef881f94409ee6dd7ee73bd1ec63425f8c1afcd0ef19e87095001a69ebc80c6fe253d2e76712b9f412c2745ccbf3d55bdac
6
+ metadata.gz: ad283cf07a70951aeb8f9e842d7dd20d2f3ef716f3bb4df8fbade6f1ab3f08cf052897176b10cf1c72d6925fae86ae688c214368da44b434ab3e76dd1a4420c8
7
+ data.tar.gz: 3067805b0d16ded711bd4cc2913cbefa290466b1d25bec4b7adb93f7d81a3d64db93b70cf165b8c1089de12460d772c112b61fd3e988b58d79278ed92bf053f4
data/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
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
+
12
+ ### 1.49.0 (2024-02-21)
13
+
14
+ #### Features
15
+
16
+ * Support of Managed Folders ([#24809](https://github.com/googleapis/google-cloud-ruby/issues/24809))
17
+
3
18
  ### 1.48.1 (2024-01-26)
4
19
 
5
20
  #### Bug Fixes
@@ -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},
@@ -1319,6 +1378,11 @@ module Google
1319
1378
  # as distinct results. The default is `false`. For more information,
1320
1379
  # see [Object Versioning
1321
1380
  # ](https://cloud.google.com/storage/docs/object-versioning).
1381
+ # @param [Boolean] include_folders_as_prefixes If `true`, will also include
1382
+ # folders and managed folders, besides objects, in the returned prefixes.
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.
1322
1386
  #
1323
1387
  # @return [Array<Google::Cloud::Storage::File>] (See
1324
1388
  # {Google::Cloud::Storage::File::List})
@@ -1346,17 +1410,22 @@ module Google
1346
1410
  # end
1347
1411
  #
1348
1412
  def files prefix: nil, delimiter: nil, token: nil, max: nil,
1349
- versions: nil, match_glob: nil
1413
+ versions: nil, match_glob: nil, include_folders_as_prefixes: nil,
1414
+ soft_deleted: nil
1350
1415
  ensure_service!
1351
1416
  gapi = service.list_files name, prefix: prefix, delimiter: delimiter,
1352
1417
  token: token, max: max,
1353
1418
  versions: versions,
1354
1419
  user_project: user_project,
1355
- match_glob: match_glob
1420
+ match_glob: match_glob,
1421
+ include_folders_as_prefixes: include_folders_as_prefixes,
1422
+ soft_deleted: soft_deleted
1356
1423
  File::List.from_gapi gapi, service, name, prefix, delimiter, max,
1357
1424
  versions,
1358
1425
  user_project: user_project,
1359
- match_glob: match_glob
1426
+ match_glob: match_glob,
1427
+ include_folders_as_prefixes: include_folders_as_prefixes,
1428
+ soft_deleted: soft_deleted
1360
1429
  end
1361
1430
  alias find_files files
1362
1431
 
@@ -1392,6 +1461,8 @@ module Google
1392
1461
  # @param [String] encryption_key Optional. The customer-supplied,
1393
1462
  # AES-256 encryption key used to encrypt the file, if one was provided
1394
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.
1395
1466
  #
1396
1467
  # @return [Google::Cloud::Storage::File, nil] Returns nil if file does
1397
1468
  # not exist
@@ -1413,7 +1484,8 @@ module Google
1413
1484
  if_metageneration_match: nil,
1414
1485
  if_metageneration_not_match: nil,
1415
1486
  skip_lookup: nil,
1416
- encryption_key: nil
1487
+ encryption_key: nil,
1488
+ soft_deleted: nil
1417
1489
  ensure_service!
1418
1490
  if skip_lookup
1419
1491
  return File.new_lazy name, path, service,
@@ -1426,7 +1498,8 @@ module Google
1426
1498
  if_metageneration_match: if_metageneration_match,
1427
1499
  if_metageneration_not_match: if_metageneration_not_match,
1428
1500
  key: encryption_key,
1429
- user_project: user_project
1501
+ user_project: user_project,
1502
+ soft_deleted: soft_deleted
1430
1503
  File.from_gapi gapi, service, user_project: user_project
1431
1504
  rescue Google::Cloud::NotFoundError
1432
1505
  nil
@@ -1707,6 +1780,77 @@ module Google
1707
1780
  alias upload_file create_file
1708
1781
  alias new_file create_file
1709
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
+
1710
1854
  ##
1711
1855
  # Concatenates a list of existing files in the bucket into a new file in
1712
1856
  # the bucket. There is a limit (currently 32) to the number of files
@@ -165,8 +165,9 @@ module Google
165
165
  # Google::Apis::StorageV1::Objects object.
166
166
  def self.from_gapi gapi_list, service, bucket = nil, prefix = nil,
167
167
  delimiter = nil, max = nil, versions = nil,
168
- user_project: nil,
169
- match_glob: nil
168
+ user_project: nil, match_glob: 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)
@@ -180,6 +181,8 @@ module Google
180
181
  files.instance_variable_set :@versions, versions
181
182
  files.instance_variable_set :@user_project, user_project
182
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
183
186
  files
184
187
  end
185
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
@@ -363,8 +365,8 @@ module Google
363
365
  # Retrieves a list of files matching the criteria.
364
366
  def list_files bucket_name, delimiter: nil, max: nil, token: nil,
365
367
  prefix: nil, versions: nil, user_project: nil,
366
- match_glob: nil,
367
- options: {}
368
+ match_glob: nil, include_folders_as_prefixes: nil,
369
+ soft_deleted: nil, options: {}
368
370
  execute do
369
371
  service.list_objects \
370
372
  bucket_name, delimiter: delimiter, max_results: max,
@@ -372,6 +374,8 @@ module Google
372
374
  versions: versions,
373
375
  user_project: user_project(user_project),
374
376
  match_glob: match_glob,
377
+ include_folders_as_prefixes: include_folders_as_prefixes,
378
+ soft_deleted: soft_deleted,
375
379
  options: options
376
380
  end
377
381
  end
@@ -455,6 +459,7 @@ module Google
455
459
  if_metageneration_not_match: nil,
456
460
  key: nil,
457
461
  user_project: nil,
462
+ soft_deleted: nil,
458
463
  options: {}
459
464
  execute do
460
465
  service.get_object \
@@ -465,6 +470,7 @@ module Google
465
470
  if_metageneration_match: if_metageneration_match,
466
471
  if_metageneration_not_match: if_metageneration_not_match,
467
472
  user_project: user_project(user_project),
473
+ soft_deleted: soft_deleted,
468
474
  options: key_options(key).merge(options)
469
475
  end
470
476
  end
@@ -650,6 +656,40 @@ module Google
650
656
  end
651
657
  end
652
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
+
653
693
  ##
654
694
  # Retrieves a list of ACLs for the given file.
655
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.48.1".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.48.1
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-01-26 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