google-cloud-storage 1.40.0 → 1.42.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: 7eae657ab195e86fc8c483f9920ffc030e19b3754d118b13d49053f7f3fdc544
4
- data.tar.gz: 259b1d1c5138ad671e06a88cb461ed18e03bc6872dfe3d66f90bc3a01eb6907a
3
+ metadata.gz: 24a6e0506ffc44db974accb0e91b5d9efd1f9898a07b15bb286d8d9428c83ec1
4
+ data.tar.gz: f51a2efcd382bb9bc5b2c04503456eca85cdf400897995a32a3612e56839e6e9
5
5
  SHA512:
6
- metadata.gz: bac1d42f4566defbfb79814ec6d1d6aa440b4facf26cd860b1b956bb34d832b0109cf0ef1ffe706fba78f447be8eda3c3b29c9ad3e55b30204354538c2675b99
7
- data.tar.gz: 8c90e04918e20961dd33f1e734c65f3d942f3600484cb9ccc697016b3843cc138cb9cd0cb8db0c760f0fcfde655759ce15dad9748115a603cde8a7201e9064c6
6
+ metadata.gz: 4ccaa608e3aa4e9ffc214885ce11a798d622d216a18a686f80972e6f6b469b6763535871228b6eb75af7c1e1a0b918c2343f15c114f9422925da8c7ae13b5c5e
7
+ data.tar.gz: 2c7b4e5b998be2a49f10077024590d6898384da1dcc44a4e5995cf0a55419be421671fe6e78c669844c79ea1193566dbe303a34f208dd3d29ee0fba900f8b036
data/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Release History
2
2
 
3
+ ### 1.42.0 (2022-09-21)
4
+
5
+ #### Features
6
+
7
+ * send invocation_id header in all requests ([#19161](https://github.com/googleapis/google-cloud-ruby/issues/19161))
8
+
9
+ ### 1.41.0 (2022-09-16)
10
+
11
+ #### Features
12
+
13
+ * add retry support for non-idempotent operations ([#19134](https://github.com/googleapis/google-cloud-ruby/issues/19134))
14
+ #### Bug Fixes
15
+
16
+ * Correct options checks in retry operations ([#19135](https://github.com/googleapis/google-cloud-ruby/issues/19135))
17
+ * Update api for bucket update ([#19110](https://github.com/googleapis/google-cloud-ruby/issues/19110))
18
+
3
19
  ### 1.40.0 (2022-09-13)
4
20
 
5
21
  #### Features
data/OVERVIEW.md CHANGED
@@ -593,6 +593,8 @@ service = storage.service
593
593
  service.get_bucket bucket_name, options: {retries: 0}
594
594
  ```
595
595
 
596
+ For those API requests which are never idempotent, the library passes retries=0 by default, suppressing any retries.
597
+
596
598
  See the [Storage status and error
597
599
  codes](https://cloud.google.com/storage/docs/json_api/v1/status-codes)
598
600
  for a list of error conditions.
@@ -1170,9 +1170,9 @@ module Google
1170
1170
  updater.check_for_mutable_cors!
1171
1171
  updater.check_for_mutable_lifecycle!
1172
1172
  return if updater.updates.empty?
1173
- patch_gapi! updater.updates,
1174
- if_metageneration_match: if_metageneration_match,
1175
- if_metageneration_not_match: if_metageneration_not_match
1173
+ update_gapi! updater.updates,
1174
+ if_metageneration_match: if_metageneration_match,
1175
+ if_metageneration_not_match: if_metageneration_not_match
1176
1176
  end
1177
1177
 
1178
1178
  ##
@@ -2905,6 +2905,26 @@ module Google
2905
2905
  self
2906
2906
  end
2907
2907
 
2908
+ def update_gapi! attributes,
2909
+ if_metageneration_match: nil,
2910
+ if_metageneration_not_match: nil
2911
+ attributes = Array(attributes)
2912
+ attributes.flatten!
2913
+ return if attributes.empty?
2914
+ ensure_service!
2915
+ update_args = Hash[attributes.map do |attr|
2916
+ [attr, @gapi.send(attr)]
2917
+ end]
2918
+ update_gapi = API::Bucket.new(**update_args)
2919
+ @gapi = service.update_bucket name,
2920
+ update_gapi,
2921
+ if_metageneration_match: if_metageneration_match,
2922
+ if_metageneration_not_match: if_metageneration_not_match,
2923
+ user_project: user_project
2924
+ @lazy = nil
2925
+ self
2926
+ end
2927
+
2908
2928
  ##
2909
2929
  # Raise an error if the file is not found.
2910
2930
  def ensure_io_or_file_exists! file
@@ -64,6 +64,7 @@ module Google
64
64
  @service.request_options.base_interval = base_interval if base_interval
65
65
  @service.request_options.max_interval = max_interval if max_interval
66
66
  @service.request_options.multiplier = multiplier if multiplier
67
+ @service.request_options.add_invocation_id_header = true
67
68
  @service.authorization = @credentials.client if @credentials
68
69
  @service.root_url = host if host
69
70
  end
@@ -135,7 +136,7 @@ module Google
135
136
  bucket_gapi.acl = [] if predefined_acl
136
137
  bucket_gapi.default_object_acl = [] if predefined_default_acl
137
138
 
138
- if options[:retry].nil?
139
+ if options[:retries].nil?
139
140
  is_idempotent = retry? if_metageneration_match: if_metageneration_match
140
141
  options = is_idempotent ? {} : { retries: 0 }
141
142
  end
@@ -196,6 +197,9 @@ module Google
196
197
  def insert_bucket_acl bucket_name, entity, role, user_project: nil, options: {}
197
198
  params = { entity: entity, role: role }.delete_if { |_k, v| v.nil? }
198
199
  new_acl = Google::Apis::StorageV1::BucketAccessControl.new(**params)
200
+ if options[:retries].nil?
201
+ options = options.merge({ retries: 0 })
202
+ end
199
203
  execute do
200
204
  service.insert_bucket_access_control \
201
205
  bucket_name, new_acl, user_project: user_project(user_project),
@@ -206,6 +210,9 @@ module Google
206
210
  ##
207
211
  # Permanently deletes a bucket ACL.
208
212
  def delete_bucket_acl bucket_name, entity, user_project: nil, options: {}
213
+ if options[:retries].nil?
214
+ options = options.merge({ retries: 0 })
215
+ end
209
216
  execute do
210
217
  service.delete_bucket_access_control \
211
218
  bucket_name, entity, user_project: user_project(user_project),
@@ -226,6 +233,9 @@ module Google
226
233
  ##
227
234
  # Creates a new default ACL.
228
235
  def insert_default_acl bucket_name, entity, role, user_project: nil, options: {}
236
+ if options[:retries].nil?
237
+ options = options.merge({ retries: 0 })
238
+ end
229
239
  param = { entity: entity, role: role }.delete_if { |_k, v| v.nil? }
230
240
  new_acl = Google::Apis::StorageV1::ObjectAccessControl.new(**param)
231
241
  execute do
@@ -238,6 +248,9 @@ module Google
238
248
  ##
239
249
  # Permanently deletes a default ACL.
240
250
  def delete_default_acl bucket_name, entity, user_project: nil, options: {}
251
+ if options[:retries].nil?
252
+ options = options.merge({ retries: 0 })
253
+ end
241
254
  execute do
242
255
  service.delete_default_object_access_control \
243
256
  bucket_name, entity, user_project: user_project(user_project),
@@ -299,6 +312,10 @@ module Google
299
312
  topic: topic_path(topic_name) }.delete_if { |_k, v| v.nil? }
300
313
  new_notification = Google::Apis::StorageV1::Notification.new(**params)
301
314
 
315
+ if options[:retries].nil?
316
+ options = options.merge({ retries: 0 })
317
+ end
318
+
302
319
  execute do
303
320
  service.insert_notification \
304
321
  bucket_name, new_notification,
@@ -385,7 +402,7 @@ module Google
385
402
  file_obj = Google::Apis::StorageV1::Object.new(**params)
386
403
  content_type ||= mime_type_for(path || Pathname(source).to_path)
387
404
 
388
- if options[:retry].nil?
405
+ if options[:retries].nil?
389
406
  is_idempotent = retry? if_generation_match: if_generation_match
390
407
  options = is_idempotent ? key_options(key) : key_options(key).merge(retries: 0)
391
408
  else
@@ -460,7 +477,7 @@ module Google
460
477
  options: {}
461
478
  key_options = rewrite_key_options source_key, destination_key
462
479
 
463
- if options[:retry].nil?
480
+ if options[:retries].nil?
464
481
  is_idempotent = retry? if_generation_match: if_generation_match
465
482
  options = is_idempotent ? key_options : key_options.merge(retries: 0)
466
483
  else
@@ -508,7 +525,7 @@ module Google
508
525
  compose_req = Google::Apis::StorageV1::ComposeRequest.new source_objects: source_objects,
509
526
  destination: destination_gapi
510
527
 
511
- if options[:retry].nil?
528
+ if options[:retries].nil?
512
529
  is_idempotent = retry? if_generation_match: if_generation_match
513
530
  options = is_idempotent ? key_options(key) : key_options(key).merge(retries: 0)
514
531
  else
@@ -565,7 +582,7 @@ module Google
565
582
  options: {}
566
583
  file_gapi ||= Google::Apis::StorageV1::Object.new
567
584
 
568
- if options[:retry].nil?
585
+ if options[:retries].nil?
569
586
  is_idempotent = retry? if_metageneration_match: if_metageneration_match
570
587
  options = is_idempotent ? {} : { retries: 0 }
571
588
  end
@@ -597,7 +614,7 @@ module Google
597
614
  user_project: nil,
598
615
  options: {}
599
616
 
600
- if options[:retry].nil?
617
+ if options[:retries].nil?
601
618
  is_idempotent = retry? generation: generation, if_generation_match: if_generation_match
602
619
  options = is_idempotent ? {} : { retries: 0 }
603
620
  end
@@ -629,6 +646,9 @@ module Google
629
646
  def insert_file_acl bucket_name, file_name, entity, role,
630
647
  generation: nil, user_project: nil,
631
648
  options: {}
649
+ if options[:retries].nil?
650
+ options = options.merge({ retries: 0 })
651
+ end
632
652
  params = { entity: entity, role: role }.delete_if { |_k, v| v.nil? }
633
653
  new_acl = Google::Apis::StorageV1::ObjectAccessControl.new(**params)
634
654
  execute do
@@ -643,6 +663,9 @@ module Google
643
663
  # Permanently deletes a file ACL.
644
664
  def delete_file_acl bucket_name, file_name, entity, generation: nil,
645
665
  user_project: nil, options: {}
666
+ if options[:retries].nil?
667
+ options = options.merge({ retries: 0 })
668
+ end
646
669
  execute do
647
670
  service.delete_object_access_control \
648
671
  bucket_name, file_name, entity,
@@ -656,6 +679,11 @@ module Google
656
679
  # Returns Google::Apis::StorageV1::HmacKey.
657
680
  def create_hmac_key service_account_email, project_id: nil,
658
681
  user_project: nil, options: {}
682
+
683
+ if options[:retries].nil?
684
+ options = options.merge({ retries: 0 })
685
+ end
686
+
659
687
  execute do
660
688
  service.create_project_hmac_key \
661
689
  (project_id || @project), service_account_email,
@@ -721,6 +749,37 @@ module Google
721
749
  end
722
750
  end
723
751
 
752
+ ##
753
+ # Updates a bucket, including its ACL metadata.
754
+ def update_bucket bucket_name,
755
+ bucket_gapi = nil,
756
+ predefined_acl: nil,
757
+ predefined_default_acl: nil,
758
+ if_metageneration_match: nil,
759
+ if_metageneration_not_match: nil,
760
+ user_project: nil,
761
+ options: {}
762
+ bucket_gapi ||= Google::Apis::StorageV1::Bucket.new
763
+ bucket_gapi.acl = [] if predefined_acl
764
+ bucket_gapi.default_object_acl = [] if predefined_default_acl
765
+
766
+ if options[:retries].nil?
767
+ is_idempotent = retry? if_metageneration_match: if_metageneration_match
768
+ options = is_idempotent ? {} : { retries: 0 }
769
+ end
770
+
771
+ execute do
772
+ service.update_bucket bucket_name,
773
+ bucket_gapi,
774
+ predefined_acl: predefined_acl,
775
+ predefined_default_object_acl: predefined_default_acl,
776
+ if_metageneration_match: if_metageneration_match,
777
+ if_metageneration_not_match: if_metageneration_not_match,
778
+ user_project: user_project(user_project),
779
+ options: options
780
+ end
781
+ end
782
+
724
783
  ##
725
784
  # Retrieves the mime-type for a file path.
726
785
  # An empty string is returned if no mime-type can be found.
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Storage
19
- VERSION = "1.40.0".freeze
19
+ VERSION = "1.42.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.40.0
4
+ version: 1.42.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: 2022-09-14 00:00:00.000000000 Z
12
+ date: 2022-09-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: google-cloud-core