google-cloud-storage 1.56.0 → 1.58.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: 37d818583b06d396a9b237a24187b677bb5261c31e3a139714ef4f8fd868e4ec
4
- data.tar.gz: d8ed3812b144e20a747c79147fd26642a7f8d4c9a5e017e925144f9e33afa717
3
+ metadata.gz: d5702660db1aed635fecb508a9f704e9f42fab5aa79db322097e775fbe0c60eb
4
+ data.tar.gz: e4ce8ea28ef05a416e3f1f751365f7fef62b2599be2d5b22dcd91d5a735b0cd4
5
5
  SHA512:
6
- metadata.gz: 519fe7bc2cf869c804bbfac6ce300b300f99f065a594673d36cf344b3cacff1ff1fb4eec086903ddcbc4a4be108c66082f05d539ef9508570d43ec9c678893be
7
- data.tar.gz: a82b8ddd47b64d71c5035491a87021912419213538a0b2105de3facf4a09aac927379b1c980e5612629426cc7e0ec5de3590480fcdc265fb1bdf172f28d1be05
6
+ metadata.gz: e981b3eddd57eb932728eeb6f3e19d4442e4d88f190aba854e764d95b901e4756b164142b835088407e3993c7f989ccfd24aac17432f02aff87fe8c3b4ccf921
7
+ data.tar.gz: dbe8ece884a8bbb25416806c236098e279eadd3b8d3e223a3134de71f76f40fc307a1a54dcedcf45512ae1e0e925eec3adc90ba3831b5a436fd7a531e55c190d
data/AUTHENTICATION.md CHANGED
@@ -28,6 +28,12 @@ providing **Project ID** and **Service Account Credentials** directly in code.
28
28
 
29
29
  **Credentials** are discovered in the following order:
30
30
 
31
+ > [!WARNING]
32
+ > If you accept a credential configuration (JSON file or Hash) from an
33
+ > external source for authentication to Google Cloud, you must validate it before
34
+ > providing it to a Google API client library. Providing an unvalidated credential
35
+ > configuration to Google APIs can compromise the security of your systems and data.
36
+
31
37
  1. Specify credentials in method arguments
32
38
  2. Specify credentials in configuration
33
39
  3. Discover credentials path in environment variables
@@ -81,11 +87,17 @@ The **Project ID** and the path to the **Credentials JSON** file can be configur
81
87
  instead of placing them in environment variables or providing them as arguments.
82
88
 
83
89
  ```ruby
90
+ require "googleauth"
84
91
  require "google/cloud/storage"
85
92
 
93
+ credentials = ::Google::Auth::ServiceAccountCredentials.make_creds(
94
+ json_key_io: ::File.open("/path/to/keyfile.json"),
95
+ scope: "https://www.googleapis.com/auth/devstorage.full_control"
96
+ )
97
+
86
98
  Google::Cloud::Storage.configure do |config|
87
99
  config.project_id = "my-project-id"
88
- config.credentials = "path/to/keyfile.json"
100
+ config.credentials = credentials
89
101
  end
90
102
 
91
103
  storage = Google::Cloud::Storage.new
data/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Release History
2
2
 
3
+ ### 1.58.0 (2026-01-08)
4
+
5
+ #### Features
6
+
7
+ * Adding support for partial success bucket list ([#32173](https://github.com/googleapis/google-cloud-ruby/issues/32173))
8
+
9
+ ### 1.57.1 (2025-11-04)
10
+
11
+ #### Documentation
12
+
13
+ * add warning about loading unvalidated credentials ([#31776](https://github.com/googleapis/google-cloud-ruby/issues/31776))
14
+
15
+ ### 1.57.0 (2025-08-15)
16
+
17
+ #### Features
18
+
19
+ * Require Ruby 3.1 or later ([#30765](https://github.com/googleapis/google-cloud-ruby/issues/30765))
20
+ * Support for using Faraday for HTTP requests ([#30759](https://github.com/googleapis/google-cloud-ruby/issues/30759))
21
+
3
22
  ### 1.56.0 (2025-04-21)
4
23
 
5
24
  #### Features
data/OVERVIEW.md CHANGED
@@ -14,11 +14,17 @@ your code or via environment variables. Read more about the options for
14
14
  connecting in the {file:AUTHENTICATION.md Authentication Guide}.
15
15
 
16
16
  ```ruby
17
+ require "googleauth"
17
18
  require "google/cloud/storage"
18
19
 
20
+ credentials = ::Google::Auth::ServiceAccountCredentials.make_creds(
21
+ json_key_io: ::File.open("/path/to/keyfile.json"),
22
+ scope: "https://www.googleapis.com/auth/devstorage.full_control"
23
+ )
24
+
19
25
  storage = Google::Cloud::Storage.new(
20
26
  project_id: "my-project",
21
- credentials: "/path/to/keyfile.json"
27
+ credentials: credentials
22
28
  )
23
29
 
24
30
  bucket = storage.bucket "my-bucket"
@@ -531,14 +537,23 @@ created and owns the topic.)
531
537
  require "google/cloud/pubsub"
532
538
  require "google/cloud/storage"
533
539
 
534
- pubsub = Google::Cloud::Pubsub.new
540
+ pubsub = Google::Cloud::PubSub.new
535
541
  storage = Google::Cloud::Storage.new
536
542
 
537
- topic = pubsub.create_topic "my-topic"
538
- topic.policy do |p|
539
- p.add "roles/pubsub.publisher",
540
- "serviceAccount:#{storage.service_account_email}"
541
- end
543
+ topic_admin = pubsub.topic_admin
544
+ topic_path = pubsub.topic_path "my-topic"
545
+ topic = topic_admin.create_topic name: topic_path
546
+
547
+ policy = {
548
+ bindings: [
549
+ {
550
+ role: "roles/pubsub.publisher",
551
+ members: ["serviceAccount:#{storage.service_account_email}"]
552
+ }
553
+ ]
554
+ }
555
+
556
+ pubsub.iam.set_iam_policy resource: topic_path, policy: policy
542
557
 
543
558
  bucket = storage.bucket "my-bucket"
544
559
 
@@ -352,7 +352,7 @@ module Google
352
352
  def auth! if_metageneration_match: nil
353
353
  update_predefined_acl! "authenticatedRead", if_metageneration_match: if_metageneration_match
354
354
  end
355
- alias authenticatedRead! auth!
355
+ alias authenticatedRead! auth! # rubocop:disable Naming/MethodName
356
356
  alias auth_read! auth!
357
357
  alias authenticated! auth!
358
358
  alias authenticated_read! auth!
@@ -390,7 +390,7 @@ module Google
390
390
  def project_private! if_metageneration_match: nil
391
391
  update_predefined_acl! "projectPrivate", if_metageneration_match: if_metageneration_match
392
392
  end
393
- alias projectPrivate! project_private!
393
+ alias projectPrivate! project_private! # rubocop:disable Naming/MethodName
394
394
 
395
395
  ##
396
396
  # Convenience method to apply the `publicRead` predefined ACL
@@ -408,7 +408,7 @@ module Google
408
408
  def public! if_metageneration_match: nil
409
409
  update_predefined_acl! "publicRead", if_metageneration_match: if_metageneration_match
410
410
  end
411
- alias publicRead! public!
411
+ alias publicRead! public! # rubocop:disable Naming/MethodName
412
412
  alias public_read! public!
413
413
 
414
414
  # Convenience method to apply the `publicReadWrite` predefined ACL
@@ -426,7 +426,7 @@ module Google
426
426
  def public_write! if_metageneration_match: nil
427
427
  update_predefined_acl! "publicReadWrite", if_metageneration_match: if_metageneration_match
428
428
  end
429
- alias publicReadWrite! public_write!
429
+ alias publicReadWrite! public_write! # rubocop:disable Naming/MethodName
430
430
 
431
431
  protected
432
432
 
@@ -718,7 +718,7 @@ module Google
718
718
  def auth! if_metageneration_match: nil
719
719
  update_predefined_default_acl! "authenticatedRead", if_metageneration_match: if_metageneration_match
720
720
  end
721
- alias authenticatedRead! auth!
721
+ alias authenticatedRead! auth! # rubocop:disable Naming/MethodName
722
722
  alias auth_read! auth!
723
723
  alias authenticated! auth!
724
724
  alias authenticated_read! auth!
@@ -739,7 +739,7 @@ module Google
739
739
  def owner_full! if_metageneration_match: nil
740
740
  update_predefined_default_acl! "bucketOwnerFullControl", if_metageneration_match: if_metageneration_match
741
741
  end
742
- alias bucketOwnerFullControl! owner_full!
742
+ alias bucketOwnerFullControl! owner_full! # rubocop:disable Naming/MethodName
743
743
 
744
744
  ##
745
745
  # Convenience method to apply the default `bucketOwnerRead`
@@ -757,7 +757,7 @@ module Google
757
757
  def owner_read! if_metageneration_match: nil
758
758
  update_predefined_default_acl! "bucketOwnerRead", if_metageneration_match: if_metageneration_match
759
759
  end
760
- alias bucketOwnerRead! owner_read!
760
+ alias bucketOwnerRead! owner_read! # rubocop:disable Naming/MethodName
761
761
 
762
762
  ##
763
763
  # Convenience method to apply the default `private`
@@ -792,7 +792,7 @@ module Google
792
792
  def project_private! if_metageneration_match: nil
793
793
  update_predefined_default_acl! "projectPrivate", if_metageneration_match: if_metageneration_match
794
794
  end
795
- alias projectPrivate! project_private!
795
+ alias projectPrivate! project_private! # rubocop:disable Naming/MethodName
796
796
 
797
797
  ##
798
798
  # Convenience method to apply the default `publicRead`
@@ -810,7 +810,7 @@ module Google
810
810
  def public! if_metageneration_match: nil
811
811
  update_predefined_default_acl! "publicRead", if_metageneration_match: if_metageneration_match
812
812
  end
813
- alias publicRead! public!
813
+ alias publicRead! public! # rubocop:disable Naming/MethodName
814
814
  alias public_read! public!
815
815
 
816
816
  protected
@@ -27,6 +27,14 @@ module Google
27
27
  # that match the request and this value should be passed to
28
28
  # the next {Google::Cloud::Storage::Project#buckets} to continue.
29
29
  attr_accessor :token
30
+ ##
31
+ # Provides a list of bucket names that are unreachable.
32
+ #
33
+ # This is only populated when `return_partial_success` is set to `true`
34
+ # in the call to {Google::Cloud::Storage::Project#buckets}.
35
+ #
36
+ # @return [Array<String>]
37
+ attr_reader :unreachable
30
38
 
31
39
  ##
32
40
  # @private Create a new Bucket::List with an array of values.
@@ -147,7 +155,7 @@ module Google
147
155
  # @private New Bucket::List from a Google API Client
148
156
  # Google::Apis::StorageV1::Buckets object.
149
157
  def self.from_gapi gapi_list, service, prefix = nil, max = nil,
150
- user_project: nil, soft_deleted: nil
158
+ user_project: nil, soft_deleted: nil, return_partial_success: nil
151
159
  buckets = new(Array(gapi_list.items).map do |gapi_object|
152
160
  Bucket.from_gapi gapi_object, service, user_project: user_project
153
161
  end)
@@ -157,6 +165,7 @@ module Google
157
165
  buckets.instance_variable_set :@max, max
158
166
  buckets.instance_variable_set :@user_project, user_project
159
167
  buckets.instance_variable_set :@soft_deleted, soft_deleted
168
+ buckets.instance_variable_set :@unreachable, Array(gapi_list.unreachable) if return_partial_success
160
169
  buckets
161
170
  end
162
171
 
@@ -25,18 +25,29 @@ module Google
25
25
  # Storage API.
26
26
  #
27
27
  # @example
28
+ # # The recommended way to provide credentials is to use the `make_creds` method
29
+ # # on the appropriate credentials class for your environment.
30
+ #
31
+ # require "googleauth"
28
32
  # require "google/cloud/storage"
29
33
  #
30
- # keyfile = "/path/to/keyfile.json"
31
- # creds = Google::Cloud::Storage::Credentials.new keyfile
34
+ # credentials = ::Google::Auth::ServiceAccountCredentials.make_creds(
35
+ # json_key_io: ::File.open("/path/to/keyfile.json"),
36
+ # scope: "https://www.googleapis.com/auth/devstorage.full_control"
37
+ # )
32
38
  #
33
39
  # storage = Google::Cloud::Storage.new(
34
40
  # project_id: "my-project",
35
- # credentials: creds
41
+ # credentials: credentials
36
42
  # )
37
43
  #
38
44
  # storage.project_id #=> "my-project"
39
45
  #
46
+ # @note Warning: If you accept a credential configuration (JSON file or Hash) from an
47
+ # external source for authentication to Google Cloud, you must validate it before
48
+ # providing it to a Google API client library. Providing an unvalidated credential
49
+ # configuration to Google APIs can compromise the security of your systems and data.
50
+ #
40
51
  class Credentials < Google::Auth::Credentials
41
52
  SCOPE = ["https://www.googleapis.com/auth/devstorage.full_control"].freeze
42
53
  PATH_ENV_VARS = [
@@ -335,7 +335,7 @@ module Google
335
335
  if_metageneration_match: if_metageneration_match,
336
336
  if_metageneration_not_match: if_metageneration_not_match
337
337
  end
338
- alias authenticatedRead! auth!
338
+ alias authenticatedRead! auth! # rubocop:disable Naming/MethodName
339
339
  alias auth_read! auth!
340
340
  alias authenticated! auth!
341
341
  alias authenticated_read! auth!
@@ -382,7 +382,7 @@ module Google
382
382
  if_metageneration_match: if_metageneration_match,
383
383
  if_metageneration_not_match: if_metageneration_not_match
384
384
  end
385
- alias bucketOwnerFullControl! owner_full!
385
+ alias bucketOwnerFullControl! owner_full! # rubocop:disable Naming/MethodName
386
386
 
387
387
  ##
388
388
  # Convenience method to apply the `bucketOwnerRead` predefined ACL
@@ -426,7 +426,7 @@ module Google
426
426
  if_metageneration_match: if_metageneration_match,
427
427
  if_metageneration_not_match: if_metageneration_not_match
428
428
  end
429
- alias bucketOwnerRead! owner_read!
429
+ alias bucketOwnerRead! owner_read! # rubocop:disable Naming/MethodName
430
430
 
431
431
  ##
432
432
  # Convenience method to apply the `private` predefined ACL
@@ -513,7 +513,7 @@ module Google
513
513
  if_metageneration_match: if_metageneration_match,
514
514
  if_metageneration_not_match: if_metageneration_not_match
515
515
  end
516
- alias projectPrivate! project_private!
516
+ alias projectPrivate! project_private! # rubocop:disable Naming/MethodName
517
517
 
518
518
  ##
519
519
  # Convenience method to apply the `publicRead` predefined ACL
@@ -557,7 +557,7 @@ module Google
557
557
  if_metageneration_match: if_metageneration_match,
558
558
  if_metageneration_not_match: if_metageneration_not_match
559
559
  end
560
- alias publicRead! public!
560
+ alias publicRead! public! # rubocop:disable Naming/MethodName
561
561
  alias public_read! public!
562
562
 
563
563
  protected
@@ -168,10 +168,10 @@ module Google
168
168
  # puts binding.role
169
169
  # end
170
170
  #
171
- def each &block
171
+ def each(&)
172
172
  return enum_for :each unless block_given?
173
173
 
174
- @bindings.each(&block)
174
+ @bindings.each(&)
175
175
  end
176
176
 
177
177
  ##
@@ -158,6 +158,9 @@ module Google
158
158
  # bucket instances and their files.
159
159
  #
160
160
  # See also {Bucket#requester_pays=} and {Bucket#requester_pays}.
161
+ # @param [Boolean] return_partial_success
162
+ # If true, the response will contain a list of unreachable buckets.
163
+ # If false, ListBuckets will throw an error if there are any unreachable buckets.
161
164
  #
162
165
  # @return [Array<Google::Cloud::Storage::Bucket>] (See
163
166
  # {Google::Cloud::Storage::Bucket::List})
@@ -201,11 +204,22 @@ module Google
201
204
  # soft_deleted_buckets.each do |bucket|
202
205
  # puts bucket.name
203
206
  # end
204
- def buckets prefix: nil, token: nil, max: nil, user_project: nil, soft_deleted: nil
207
+ # @example Retrieve list of unreachable buckets
208
+ # require "google/cloud/storage"
209
+ #
210
+ # storage = Google::Cloud::Storage.new
211
+ #
212
+ # buckets = storage.buckets return_partial_success: true
213
+ # buckets.unreachable.each do |unreachable_bucket_name|
214
+ # puts unreachable_bucket_name
215
+ # end
216
+ #
217
+ def buckets prefix: nil, token: nil, max: nil, user_project: nil, soft_deleted: nil, return_partial_success: nil
205
218
  gapi = service.list_buckets \
206
- prefix: prefix, token: token, max: max, user_project: user_project, soft_deleted: soft_deleted
219
+ prefix: prefix, token: token, max: max, user_project: user_project, soft_deleted: soft_deleted, return_partial_success: return_partial_success
207
220
  Bucket::List.from_gapi \
208
- gapi, service, prefix, max, user_project: user_project, soft_deleted: soft_deleted
221
+ gapi, service, prefix, max, user_project: user_project, soft_deleted: soft_deleted, return_partial_success: return_partial_success
222
+
209
223
  end
210
224
  alias find_buckets buckets
211
225
 
@@ -96,12 +96,14 @@ module Google
96
96
 
97
97
  ##
98
98
  # Retrieves a list of buckets for the given project.
99
- def list_buckets prefix: nil, token: nil, max: nil, user_project: nil, soft_deleted: nil, options: {}
99
+ def list_buckets prefix: nil, token: nil, max: nil, user_project: nil, soft_deleted: nil, return_partial_success: nil, options: {}
100
100
  execute do
101
101
  service.list_buckets \
102
102
  @project, prefix: prefix, page_token: token, max_results: max,
103
103
  user_project: user_project(user_project),
104
- soft_deleted: soft_deleted, options: options
104
+ soft_deleted: soft_deleted,
105
+ return_partial_success: return_partial_success,
106
+ options: options
105
107
  end
106
108
  end
107
109
 
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Storage
19
- VERSION = "1.56.0".freeze
19
+ VERSION = "1.58.0".freeze
20
20
  end
21
21
  end
22
22
  end
@@ -42,9 +42,12 @@ module Google
42
42
  # @param [String] project_id Project identifier for the Storage service
43
43
  # you are connecting to. If not present, the default project for the
44
44
  # credentials is used.
45
- # @param [String, Hash, Google::Auth::Credentials] credentials The path to
46
- # the keyfile as a String, the contents of the keyfile as a Hash, or a
47
- # Google::Auth::Credentials object. (See {Storage::Credentials})
45
+ # @param [Google::Auth::Credentials] credentials A Google::Auth::Credentials
46
+ # object. (See {Storage::Credentials})
47
+ # @note Warning: Passing a `String` to a keyfile path or a `Hash` of
48
+ # credentials is deprecated. Providing an unvalidated credential
49
+ # configuration to Google APIs can compromise the security of your
50
+ # systems and data.
48
51
  # @param [String, Array<String>] scope The OAuth 2.0 scopes controlling
49
52
  # the set of resources and operations that the connection can access.
50
53
  # See [Using OAuth 2.0 to Access Google
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-cloud-storage
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.56.0
4
+ version: 1.58.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Moore
8
8
  - Chris Smith
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-04-21 00:00:00.000000000 Z
11
+ date: 1980-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-cloud-core
@@ -28,16 +28,22 @@ dependencies:
28
28
  name: google-apis-core
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0.18'
34
+ - - "<"
32
35
  - !ruby/object:Gem::Version
33
- version: '0.13'
36
+ version: '2'
34
37
  type: :runtime
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
38
- - - "~>"
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '0.18'
44
+ - - "<"
39
45
  - !ruby/object:Gem::Version
40
- version: '0.13'
46
+ version: '2'
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: google-apis-iamcredentials_v1
43
49
  requirement: !ruby/object:Gem::Requirement
@@ -128,14 +134,14 @@ dependencies:
128
134
  requirements:
129
135
  - - "~>"
130
136
  - !ruby/object:Gem::Version
131
- version: 1.30.0
137
+ version: 1.31.1
132
138
  type: :development
133
139
  prerelease: false
134
140
  version_requirements: !ruby/object:Gem::Requirement
135
141
  requirements:
136
142
  - - "~>"
137
143
  - !ruby/object:Gem::Version
138
- version: 1.30.0
144
+ version: 1.31.1
139
145
  - !ruby/object:Gem::Dependency
140
146
  name: minitest
141
147
  requirement: !ruby/object:Gem::Requirement
@@ -331,14 +337,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
331
337
  requirements:
332
338
  - - ">="
333
339
  - !ruby/object:Gem::Version
334
- version: 3.0.0
340
+ version: 3.1.0
335
341
  required_rubygems_version: !ruby/object:Gem::Requirement
336
342
  requirements:
337
343
  - - ">="
338
344
  - !ruby/object:Gem::Version
339
345
  version: '0'
340
346
  requirements: []
341
- rubygems_version: 3.6.5
347
+ rubygems_version: 3.6.9
342
348
  specification_version: 4
343
349
  summary: API Client library for Google Cloud Storage
344
350
  test_files: []