google-cloud-storage 1.57.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: 2ba3f85cab0b6bd616c783973578f6f3610d23bd9679e74a42f77eda3e5b7b20
4
- data.tar.gz: c5399ac6a4e32d290f3c112ee435696d176c4afe329213acbca36cc629a1f647
3
+ metadata.gz: d5702660db1aed635fecb508a9f704e9f42fab5aa79db322097e775fbe0c60eb
4
+ data.tar.gz: e4ce8ea28ef05a416e3f1f751365f7fef62b2599be2d5b22dcd91d5a735b0cd4
5
5
  SHA512:
6
- metadata.gz: 3655fcc4fe59d97a956c1dd4ab3d98abdcf406261b2bb4d30a3c300d4c64aa37d2c7262c99484befa1538758ba4240b5e0a51d0ed753066a850db3d82a74b9ea
7
- data.tar.gz: 9f0c4e40ecc8f906259d2a2c027b419c464519b65b83309e574f5cd4f7bc9eae55dd5c0735798e96be8b5696af75e315f1ee299dc4e91cba374c6119b3258e78
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,17 @@
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
+
3
15
  ### 1.57.0 (2025-08-15)
4
16
 
5
17
  #### 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"
@@ -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 = [
@@ -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.57.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,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.57.0
4
+ version: 1.58.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Moore