google-cloud-storage 1.46.0 → 1.47.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: 9180138623d24136aba3789a2999158c8e1936ccc483be54e96d7ad5ce0270cd
4
- data.tar.gz: db71d2a866acb5b3c63a55d26393ef4d4b05dbdbdc529f51b4e8343d0674ec3d
3
+ metadata.gz: fb6046c8eb979e1cbd733518d8fd242e1332813d6241f85e65b07f6d7d9e631f
4
+ data.tar.gz: 1124d71be6c1954b38f3fb6c8c3814891d9dd108fc0862f2c5436db18c111782
5
5
  SHA512:
6
- metadata.gz: 33f397b67897fb16738284a45998c6df621cf7cc7a26cf57582c092ec0ff40b3fa38c2cc7a74489ff46debcad240cb82a1e4293302dd0eb6214e261aa7972e4d
7
- data.tar.gz: d52e0f8e792f8dc9359d24c58cba4c1dbc7714114078be630c40ce8d652bef3e4b336785c3b7f440b6df41f61f2699fa69d3073113e1c985a504d69a24debf2c
6
+ metadata.gz: 2e8598d2cf01a52f20c7bd554b593d7049134a367f17571721e2779a0634013452ad42025c22d59f8542c030a411092c3f2f63edfe8489fee0a9dcb9ccb5c774
7
+ data.tar.gz: 4918a472cd83aab2c7d1a5ffe6be9957c0113686a00769f082522799fd9cc713c3315de8d8b2d87caa22b37d7d54c2c82702fb2b5b9e1ed30ef011319dc841cf
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Release History
2
2
 
3
+ ### 1.47.0 (2024-01-09)
4
+
5
+ #### Features
6
+
7
+ * support for object lock / retention ([#23732](https://github.com/googleapis/google-cloud-ruby/issues/23732))
8
+
3
9
  ### 1.46.0 (2024-01-08)
4
10
 
5
11
  #### 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
  #
@@ -825,6 +825,9 @@ module Google
825
825
  # @param [Integer] if_metageneration_not_match Makes the operation
826
826
  # conditional on whether the file's current metageneration does not
827
827
  # match the given value.
828
+ # @param [Boolean] override_unlocked_retention
829
+ # Must be true to remove the retention configuration, reduce its unlocked
830
+ # retention period, or change its mode from unlocked to locked.
828
831
  #
829
832
  # @yield [file] a block yielding a delegate object for updating the file
830
833
  #
@@ -865,7 +868,8 @@ module Google
865
868
  if_generation_match: nil,
866
869
  if_generation_not_match: nil,
867
870
  if_metageneration_match: nil,
868
- if_metageneration_not_match: nil
871
+ if_metageneration_not_match: nil,
872
+ override_unlocked_retention: nil
869
873
  updater = Updater.new gapi
870
874
  yield updater
871
875
  updater.check_for_changed_metadata!
@@ -875,7 +879,8 @@ module Google
875
879
  if_generation_match: if_generation_match,
876
880
  if_generation_not_match: if_generation_not_match,
877
881
  if_metageneration_match: if_metageneration_match,
878
- if_metageneration_not_match: if_metageneration_not_match
882
+ if_metageneration_not_match: if_metageneration_not_match,
883
+ override_unlocked_retention: override_unlocked_retention
879
884
  end
880
885
 
881
886
  ##
@@ -1560,6 +1565,64 @@ module Google
1560
1565
  true
1561
1566
  end
1562
1567
 
1568
+ # Mode of object level retention configuration.
1569
+ # Valid values are 'Locked' or 'Unlocked'
1570
+ #
1571
+ # @return [String]
1572
+ def retention_mode
1573
+ @gapi.retention&.mode
1574
+ end
1575
+
1576
+ # The earliest time in RFC 3339 UTC "Zulu" format that the object can
1577
+ # be deleted or replaced.
1578
+ #
1579
+ # @return [DateTime]
1580
+ def retention_retain_until_time
1581
+ @gapi.retention&.retain_until_time
1582
+ end
1583
+
1584
+ # A collection of object level retention parameters.
1585
+ # The full list of available options are outlined at the [JSON API docs]
1586
+ # (https://cloud.google.com/storage/docs/json_api/v1/objects/insert#request-body).
1587
+ #
1588
+ # @return [Google::Apis::StorageV1::Object::Retention]
1589
+ def retention
1590
+ @gapi.retention
1591
+ end
1592
+
1593
+ ##
1594
+ # Update method to update retention parameter of an object / file
1595
+ # It accepts params as a Hash of attributes in the following format:
1596
+ #
1597
+ # { mode: 'Locked|Unlocked', retain_until_time: '2023-12-19T03:22:23+00:00' }
1598
+ #
1599
+ # @param [Hash(String => String)] new_retention_attributes
1600
+ #
1601
+ # @example Update retention parameters for the File / Object
1602
+ # require "google/cloud/storage"
1603
+ # storage = Google::Cloud::Storage.new
1604
+ # bucket = storage.bucket "my-bucket"
1605
+ # file = bucket.file "avatars/heidi/400x400.png"
1606
+ # retention_params = { mode: 'Unlocked', retain_until_time: '2023-12-19T03:22:23+00:00'.to_datetime }
1607
+ # file.retention = retention_params
1608
+ #
1609
+ # @example Update retention parameters for the File / Object with override enabled
1610
+ # require "google/cloud/storage"
1611
+ # storage = Google::Cloud::Storage.new
1612
+ # bucket = storage.bucket "my-bucket"
1613
+ # file = bucket.file "avatars/heidi/400x400.png"
1614
+ # retention_params = { mode: 'Unlocked',
1615
+ # retain_until_time: '2023-12-19T03:22:23+00:00'.to_datetime,
1616
+ # override_unlocked_retention: true }
1617
+ # file.retention = retention_params
1618
+ #
1619
+ def retention= new_retention_attributes
1620
+ @gapi.retention ||= Google::Apis::StorageV1::Object::Retention.new
1621
+ @gapi.retention.mode = new_retention_attributes[:mode]
1622
+ @gapi.retention.retain_until_time = new_retention_attributes[:retain_until_time]
1623
+ update_gapi! :retention, override_unlocked_retention: new_retention_attributes[:override_unlocked_retention]
1624
+ end
1625
+
1563
1626
  ##
1564
1627
  # Public URL to access the file. If the file is not public, requests to
1565
1628
  # the URL will return an error. (See {File::Acl#public!} and
@@ -2015,7 +2078,8 @@ module Google
2015
2078
  if_generation_match: nil,
2016
2079
  if_generation_not_match: nil,
2017
2080
  if_metageneration_match: nil,
2018
- if_metageneration_not_match: nil
2081
+ if_metageneration_not_match: nil,
2082
+ override_unlocked_retention: nil
2019
2083
  attributes = Array(attributes)
2020
2084
  attributes.flatten!
2021
2085
  return if attributes.empty?
@@ -2044,7 +2108,8 @@ module Google
2044
2108
  if_generation_not_match: if_generation_not_match,
2045
2109
  if_metageneration_match: if_metageneration_match,
2046
2110
  if_metageneration_not_match: if_metageneration_not_match,
2047
- user_project: user_project
2111
+ user_project: user_project,
2112
+ override_unlocked_retention: override_unlocked_retention
2048
2113
  end
2049
2114
  end
2050
2115
 
@@ -372,6 +372,8 @@ module Google
372
372
  # bucket instance and its files.
373
373
  #
374
374
  # See also {Bucket#requester_pays=} and {Bucket#requester_pays}.
375
+ # @param [Boolean] enable_object_retention
376
+ # When set to true, object retention is enabled for this bucket.
375
377
  #
376
378
  # @yield [bucket] a block for configuring the bucket before it is
377
379
  # created
@@ -386,6 +388,13 @@ module Google
386
388
  #
387
389
  # bucket = storage.create_bucket "my-bucket"
388
390
  #
391
+ # @example
392
+ # require "google/cloud/storage"
393
+ #
394
+ # storage = Google::Cloud::Storage.new
395
+ #
396
+ # bucket = storage.create_bucket "my-bucket", enable_object_retention: true
397
+ #
389
398
  # @example Configure the bucket in a block:
390
399
  # require "google/cloud/storage"
391
400
  #
@@ -416,7 +425,8 @@ module Google
416
425
  versioning: nil,
417
426
  requester_pays: nil,
418
427
  user_project: nil,
419
- autoclass_enabled: false
428
+ autoclass_enabled: false,
429
+ enable_object_retention: nil
420
430
  params = {
421
431
  name: bucket_name,
422
432
  location: location,
@@ -440,7 +450,8 @@ module Google
440
450
  updater.check_for_mutable_lifecycle!
441
451
  gapi = service.insert_bucket \
442
452
  new_bucket, acl: acl_rule(acl), default_acl: acl_rule(default_acl),
443
- user_project: user_project
453
+ user_project: user_project,
454
+ enable_object_retention: enable_object_retention
444
455
  Bucket.from_gapi gapi, service, user_project: user_project
445
456
  end
446
457
 
@@ -112,14 +112,16 @@ module Google
112
112
  # Creates a new bucket.
113
113
  # Returns Google::Apis::StorageV1::Bucket.
114
114
  def insert_bucket bucket_gapi, acl: nil, default_acl: nil,
115
- user_project: nil, options: {}
115
+ user_project: nil, enable_object_retention: nil,
116
+ options: {}
116
117
  execute do
117
118
  service.insert_bucket \
118
119
  @project, bucket_gapi,
119
120
  predefined_acl: acl,
120
121
  predefined_default_object_acl: default_acl,
121
122
  user_project: user_project(user_project),
122
- options: options
123
+ options: options,
124
+ enable_object_retention: enable_object_retention
123
125
  end
124
126
  end
125
127
 
@@ -582,6 +584,7 @@ module Google
582
584
  if_metageneration_not_match: nil,
583
585
  predefined_acl: nil,
584
586
  user_project: nil,
587
+ override_unlocked_retention: nil,
585
588
  options: {}
586
589
  file_gapi ||= Google::Apis::StorageV1::Object.new
587
590
 
@@ -601,6 +604,7 @@ module Google
601
604
  if_metageneration_not_match: if_metageneration_not_match,
602
605
  predefined_acl: predefined_acl,
603
606
  user_project: user_project(user_project),
607
+ override_unlocked_retention: override_unlocked_retention,
604
608
  options: options
605
609
  end
606
610
  end
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Storage
19
- VERSION = "1.46.0".freeze
19
+ VERSION = "1.47.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.46.0
4
+ version: 1.47.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-08 00:00:00.000000000 Z
12
+ date: 2024-01-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: google-cloud-core
@@ -45,14 +45,14 @@ dependencies:
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: 0.29.0
48
+ version: 0.31.0
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: 0.29.0
55
+ version: 0.31.0
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: googleauth
58
58
  requirement: !ruby/object:Gem::Requirement