google-cloud-storage 1.52.0 → 1.56.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 +4 -4
- data/CHANGELOG.md +28 -0
- data/lib/google/cloud/storage/bucket/cors.rb +2 -2
- data/lib/google/cloud/storage/bucket/list.rb +4 -2
- data/lib/google/cloud/storage/bucket.rb +75 -5
- data/lib/google/cloud/storage/file/signer_v2.rb +3 -3
- data/lib/google/cloud/storage/file/signer_v4.rb +4 -4
- data/lib/google/cloud/storage/file.rb +48 -6
- data/lib/google/cloud/storage/project.rb +58 -6
- data/lib/google/cloud/storage/service.rb +59 -11
- data/lib/google/cloud/storage/version.rb +1 -1
- data/lib/google/cloud/storage.rb +4 -4
- data/lib/google-cloud-storage.rb +8 -10
- metadata +10 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37d818583b06d396a9b237a24187b677bb5261c31e3a139714ef4f8fd868e4ec
|
4
|
+
data.tar.gz: d8ed3812b144e20a747c79147fd26642a7f8d4c9a5e017e925144f9e33afa717
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 519fe7bc2cf869c804bbfac6ce300b300f99f065a594673d36cf344b3cacff1ff1fb4eec086903ddcbc4a4be108c66082f05d539ef9508570d43ec9c678893be
|
7
|
+
data.tar.gz: a82b8ddd47b64d71c5035491a87021912419213538a0b2105de3facf4a09aac927379b1c980e5612629426cc7e0ec5de3590480fcdc265fb1bdf172f28d1be05
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,33 @@
|
|
1
1
|
# Release History
|
2
2
|
|
3
|
+
### 1.56.0 (2025-04-21)
|
4
|
+
|
5
|
+
#### Features
|
6
|
+
|
7
|
+
* move_object within hns bucket ([#29391](https://github.com/googleapis/google-cloud-ruby/issues/29391))
|
8
|
+
|
9
|
+
### 1.55.0 (2025-02-13)
|
10
|
+
|
11
|
+
#### Features
|
12
|
+
|
13
|
+
* Soft deleted Bucket Restore ([#28138](https://github.com/googleapis/google-cloud-ruby/issues/28138))
|
14
|
+
#### Documentation
|
15
|
+
|
16
|
+
* updating the encryption key GCS sample ([#28815](https://github.com/googleapis/google-cloud-ruby/issues/28815))
|
17
|
+
|
18
|
+
### 1.54.0 (2024-12-11)
|
19
|
+
|
20
|
+
#### Features
|
21
|
+
|
22
|
+
* Updated required Ruby version to 3.0 or later ([#27599](https://github.com/googleapis/google-cloud-ruby/issues/27599))
|
23
|
+
|
24
|
+
### 1.53.0 (2024-12-04)
|
25
|
+
|
26
|
+
#### Features
|
27
|
+
|
28
|
+
* add integration test for universe domain ([#27384](https://github.com/googleapis/google-cloud-ruby/issues/27384))
|
29
|
+
* fetch file and bucket details from url ([#27322](https://github.com/googleapis/google-cloud-ruby/issues/27322))
|
30
|
+
|
3
31
|
### 1.52.0 (2024-05-31)
|
4
32
|
|
5
33
|
#### Features
|
@@ -182,7 +182,7 @@ module Google
|
|
182
182
|
@origin = Array(origin)
|
183
183
|
@methods = Array(methods)
|
184
184
|
@headers = Array(headers)
|
185
|
-
@max_age =
|
185
|
+
@max_age = max_age || 1800
|
186
186
|
end
|
187
187
|
|
188
188
|
# @private
|
@@ -195,7 +195,7 @@ module Google
|
|
195
195
|
|
196
196
|
# @private
|
197
197
|
def self.from_gapi gapi
|
198
|
-
new gapi.origin.dup, gapi.http_method.dup,
|
198
|
+
new gapi.origin.dup, gapi.http_method.dup,
|
199
199
|
headers: gapi.response_header.dup,
|
200
200
|
max_age: gapi.max_age_seconds
|
201
201
|
end
|
@@ -72,7 +72,8 @@ module Google
|
|
72
72
|
return nil unless next?
|
73
73
|
ensure_service!
|
74
74
|
gapi = @service.list_buckets prefix: @prefix, token: @token,
|
75
|
-
max: @max, user_project: @user_project
|
75
|
+
max: @max, user_project: @user_project,
|
76
|
+
soft_deleted: @soft_deleted
|
76
77
|
Bucket::List.from_gapi gapi, @service, @prefix, @max,
|
77
78
|
user_project: @user_project
|
78
79
|
end
|
@@ -146,7 +147,7 @@ module Google
|
|
146
147
|
# @private New Bucket::List from a Google API Client
|
147
148
|
# Google::Apis::StorageV1::Buckets object.
|
148
149
|
def self.from_gapi gapi_list, service, prefix = nil, max = nil,
|
149
|
-
user_project: nil
|
150
|
+
user_project: nil, soft_deleted: nil
|
150
151
|
buckets = new(Array(gapi_list.items).map do |gapi_object|
|
151
152
|
Bucket.from_gapi gapi_object, service, user_project: user_project
|
152
153
|
end)
|
@@ -155,6 +156,7 @@ module Google
|
|
155
156
|
buckets.instance_variable_set :@prefix, prefix
|
156
157
|
buckets.instance_variable_set :@max, max
|
157
158
|
buckets.instance_variable_set :@user_project, user_project
|
159
|
+
buckets.instance_variable_set :@soft_deleted, soft_deleted
|
158
160
|
buckets
|
159
161
|
end
|
160
162
|
|
@@ -982,7 +982,7 @@ module Google
|
|
982
982
|
#
|
983
983
|
def uniform_bucket_level_access= new_uniform_bucket_level_access
|
984
984
|
@gapi.iam_configuration ||= API::Bucket::IamConfiguration.new
|
985
|
-
@gapi.iam_configuration.uniform_bucket_level_access ||=
|
985
|
+
@gapi.iam_configuration.uniform_bucket_level_access ||=
|
986
986
|
API::Bucket::IamConfiguration::UniformBucketLevelAccess.new
|
987
987
|
@gapi.iam_configuration.uniform_bucket_level_access.enabled = new_uniform_bucket_level_access
|
988
988
|
patch_gapi! :iam_configuration
|
@@ -2280,6 +2280,31 @@ module Google
|
|
2280
2280
|
end
|
2281
2281
|
end
|
2282
2282
|
|
2283
|
+
# Fetches generation of the bucket
|
2284
|
+
# @example
|
2285
|
+
# require "google/cloud/storage"
|
2286
|
+
# storage = Google::Cloud::Storage.new
|
2287
|
+
# bucket = storage.bucket "my-bucket"
|
2288
|
+
# generation= bucket.generation
|
2289
|
+
def generation
|
2290
|
+
@gapi.generation
|
2291
|
+
end
|
2292
|
+
|
2293
|
+
# Fetches soft_delete_time of a soft deleted bucket
|
2294
|
+
# @example
|
2295
|
+
# bucket.delete
|
2296
|
+
# bucket.soft_delete_time
|
2297
|
+
def soft_delete_time
|
2298
|
+
@gapi.soft_delete_time
|
2299
|
+
end
|
2300
|
+
|
2301
|
+
# Fetches hard_delete_time of a soft deleted bucket
|
2302
|
+
# @example
|
2303
|
+
# bucket.hard_delete_time
|
2304
|
+
def hard_delete_time
|
2305
|
+
@gapi.hard_delete_time
|
2306
|
+
end
|
2307
|
+
|
2283
2308
|
##
|
2284
2309
|
# Generate a PostObject that includes the fields and URL to
|
2285
2310
|
# upload objects via HTML forms.
|
@@ -3118,6 +3143,51 @@ module Google
|
|
3118
3143
|
end
|
3119
3144
|
alias refresh! reload!
|
3120
3145
|
|
3146
|
+
##
|
3147
|
+
# Moves File from source to destination path within the same HNS-enabled bucket
|
3148
|
+
# This Operation is being performed at server side
|
3149
|
+
# @param [String] source_file The file name in existing bucket
|
3150
|
+
# @param [String] destination_file The new filename to be created on bucket
|
3151
|
+
# If the destination path includes non-existent parent folders, they will be created.
|
3152
|
+
# @example
|
3153
|
+
# require "google/cloud/storage"
|
3154
|
+
# storage = Google::Cloud::Storage.new
|
3155
|
+
# bucket = storage.bucket bucket_name, skip_lookup: true
|
3156
|
+
# bucket.move_file source_file_name, destination_file_name
|
3157
|
+
def move_file source_file,
|
3158
|
+
destination_file,
|
3159
|
+
if_generation_match: nil,
|
3160
|
+
if_generation_not_match: nil,
|
3161
|
+
if_metageneration_match: nil,
|
3162
|
+
if_metageneration_not_match: nil,
|
3163
|
+
if_source_generation_match: nil,
|
3164
|
+
if_source_generation_not_match: nil,
|
3165
|
+
if_source_metageneration_match: nil,
|
3166
|
+
if_source_metageneration_not_match: nil,
|
3167
|
+
user_project: nil,
|
3168
|
+
fields: nil,
|
3169
|
+
quota_user: nil,
|
3170
|
+
user_ip: nil,
|
3171
|
+
options: {}
|
3172
|
+
ensure_service!
|
3173
|
+
service.move_file name,
|
3174
|
+
source_file,
|
3175
|
+
destination_file,
|
3176
|
+
if_generation_match: if_generation_match,
|
3177
|
+
if_generation_not_match: if_generation_not_match,
|
3178
|
+
if_metageneration_match: if_metageneration_match,
|
3179
|
+
if_metageneration_not_match: if_metageneration_not_match,
|
3180
|
+
if_source_generation_match: if_source_generation_match,
|
3181
|
+
if_source_generation_not_match: if_source_generation_not_match,
|
3182
|
+
if_source_metageneration_match: if_source_metageneration_match,
|
3183
|
+
if_source_metageneration_not_match: if_source_metageneration_not_match,
|
3184
|
+
user_project: user_project,
|
3185
|
+
fields: fields,
|
3186
|
+
quota_user: quota_user,
|
3187
|
+
user_ip: user_ip,
|
3188
|
+
options: options
|
3189
|
+
end
|
3190
|
+
|
3121
3191
|
##
|
3122
3192
|
# Determines whether the bucket exists in the Storage service.
|
3123
3193
|
#
|
@@ -3187,9 +3257,9 @@ module Google
|
|
3187
3257
|
attributes.flatten!
|
3188
3258
|
return if attributes.empty?
|
3189
3259
|
ensure_service!
|
3190
|
-
patch_args =
|
3260
|
+
patch_args = attributes.to_h do |attr|
|
3191
3261
|
[attr, @gapi.send(attr)]
|
3192
|
-
end
|
3262
|
+
end
|
3193
3263
|
patch_gapi = API::Bucket.new(**patch_args)
|
3194
3264
|
@gapi = service.patch_bucket name,
|
3195
3265
|
patch_gapi,
|
@@ -3207,9 +3277,9 @@ module Google
|
|
3207
3277
|
attributes.flatten!
|
3208
3278
|
return if attributes.empty?
|
3209
3279
|
ensure_service!
|
3210
|
-
update_args =
|
3280
|
+
update_args = attributes.to_h do |attr|
|
3211
3281
|
[attr, @gapi.send(attr)]
|
3212
|
-
end
|
3282
|
+
end
|
3213
3283
|
update_gapi = API::Bucket.new(**update_args)
|
3214
3284
|
@gapi = service.update_bucket name,
|
3215
3285
|
update_gapi,
|
@@ -92,7 +92,7 @@ module Google
|
|
92
92
|
|
93
93
|
def error_msg attr_name
|
94
94
|
"Service account credentials '#{attr_name}' is missing. To generate service account credentials " \
|
95
|
-
|
95
|
+
"see https://cloud.google.com/iam/docs/service-accounts"
|
96
96
|
end
|
97
97
|
|
98
98
|
def post_object options
|
@@ -145,8 +145,8 @@ module Google
|
|
145
145
|
|
146
146
|
def generate_signed_url issuer, signed_string, expires, query
|
147
147
|
url = "#{ext_url}?GoogleAccessId=#{url_escape issuer}" \
|
148
|
-
|
149
|
-
|
148
|
+
"&Expires=#{expires}" \
|
149
|
+
"&Signature=#{url_escape signed_string}"
|
150
150
|
|
151
151
|
query&.each do |name, value|
|
152
152
|
url << "&#{url_escape name}=#{url_escape value}"
|
@@ -131,7 +131,7 @@ module Google
|
|
131
131
|
# methods below are public visibility only for unit testing
|
132
132
|
# rubocop:disable Style/StringLiterals
|
133
133
|
def escape_characters str
|
134
|
-
str.
|
134
|
+
str.chars.map do |s|
|
135
135
|
if s.ascii_only?
|
136
136
|
case s
|
137
137
|
when "\\"
|
@@ -207,7 +207,7 @@ module Google
|
|
207
207
|
|
208
208
|
def error_msg attr_name
|
209
209
|
"Service account credentials '#{attr_name}' is missing. To generate service account credentials " \
|
210
|
-
|
210
|
+
"see https://cloud.google.com/iam/docs/service-accounts"
|
211
211
|
end
|
212
212
|
|
213
213
|
def service_account_signer signer
|
@@ -243,7 +243,7 @@ module Google
|
|
243
243
|
headers_arr = canonical_headers.map do |k, v|
|
244
244
|
[k.downcase, v.strip.gsub(/[^\S\t]+/, " ").gsub(/\t+/, " ")]
|
245
245
|
end
|
246
|
-
canonical_headers =
|
246
|
+
canonical_headers = headers_arr.to_h
|
247
247
|
canonical_headers["host"] = host_name virtual_hosted_style, bucket_bound_hostname
|
248
248
|
|
249
249
|
canonical_headers = canonical_headers.sort_by(&:first).to_h
|
@@ -295,7 +295,7 @@ module Google
|
|
295
295
|
##
|
296
296
|
# The external path to the bucket, with trailing slash.
|
297
297
|
def bucket_path path_style
|
298
|
-
|
298
|
+
"/#{@bucket_name}/" if path_style
|
299
299
|
end
|
300
300
|
|
301
301
|
##
|
@@ -2072,15 +2072,59 @@ module Google
|
|
2072
2072
|
def self.gapi_from_attrs gapi, attributes
|
2073
2073
|
attributes.flatten!
|
2074
2074
|
return nil if attributes.empty?
|
2075
|
-
attr_params =
|
2076
|
-
|
2077
|
-
|
2075
|
+
attr_params = attributes.to_h do |attr|
|
2076
|
+
[attr, gapi.send(attr)]
|
2077
|
+
end
|
2078
2078
|
# Sending nil metadata results in an Apiary runtime error:
|
2079
2079
|
# NoMethodError: undefined method `each' for nil:NilClass
|
2080
2080
|
attr_params.reject! { |k, v| k == :metadata && v.nil? }
|
2081
2081
|
Google::Apis::StorageV1::Object.new(**attr_params)
|
2082
2082
|
end
|
2083
2083
|
|
2084
|
+
##
|
2085
|
+
# from_gs_url is a method to fetch bucket details and file details from a gs url
|
2086
|
+
#
|
2087
|
+
# @return [Hash(String => String)]
|
2088
|
+
#
|
2089
|
+
# @example Fetch bucket_name and file_Path from gs url:
|
2090
|
+
# require "google/cloud/storage"
|
2091
|
+
# gs_url= "gs://my-todo-app/avatars/heidi.jpeg"
|
2092
|
+
# file=Google::Cloud::Storage::File
|
2093
|
+
# file.from_gs_url(gs_url)
|
2094
|
+
# =>
|
2095
|
+
# {"bucket_name"=>"my-todo-app", "file_path"=>"avatars/heidi.jpeg"}
|
2096
|
+
#
|
2097
|
+
# @example Fetch bucket_name , file_Path and other query params from gs url:
|
2098
|
+
# require "google/cloud/storage"
|
2099
|
+
# gs_url= "gs://my-todo-app/test_sub_folder/heidi.jpeg?params1=test1¶ms2=test2"
|
2100
|
+
# file=Google::Cloud::Storage::File
|
2101
|
+
# file.from_gs_url(gs_url)
|
2102
|
+
# =>{
|
2103
|
+
# "bucket_name"=>"my-todo-app",
|
2104
|
+
# "file_path"=>"test_sub_folder/heidi.jpeg",
|
2105
|
+
# "options" => {
|
2106
|
+
# "params1"=>"test1",
|
2107
|
+
# "params2"=>"test2"
|
2108
|
+
# }
|
2109
|
+
# }
|
2110
|
+
|
2111
|
+
def self.from_gs_url gs_url
|
2112
|
+
prefix = "gs://".freeze
|
2113
|
+
raise ArgumentError, "Invalid GCS URL" unless gs_url.start_with? prefix
|
2114
|
+
# seprating params from input url
|
2115
|
+
path, query = gs_url.sub(prefix, "").split("?", 2)
|
2116
|
+
# parsing the url
|
2117
|
+
bucket_name, file_path = path.split "/", 2
|
2118
|
+
query_params = URI.decode_www_form(query).to_h if query
|
2119
|
+
url_items = {
|
2120
|
+
"bucket_name" => bucket_name,
|
2121
|
+
"file_path" => file_path
|
2122
|
+
}
|
2123
|
+
# adding url params to output hash
|
2124
|
+
url_items.merge! "options" => query_params if query
|
2125
|
+
url_items
|
2126
|
+
end
|
2127
|
+
|
2084
2128
|
protected
|
2085
2129
|
|
2086
2130
|
##
|
@@ -2196,10 +2240,8 @@ module Google
|
|
2196
2240
|
[dest_bucket, dest_path]
|
2197
2241
|
end
|
2198
2242
|
|
2199
|
-
# rubocop:disable Style/MultipleComparison
|
2200
|
-
|
2201
2243
|
def verify_file! file, verify = :md5
|
2202
|
-
verify_md5 = verify == :md5
|
2244
|
+
verify_md5 = verify == :md5 || verify == :all
|
2203
2245
|
verify_crc32c = verify == :crc32c || verify == :all
|
2204
2246
|
Verifier.verify_md5! self, file if verify_md5 && md5
|
2205
2247
|
Verifier.verify_crc32c! self, file if verify_crc32c && crc32c
|
@@ -99,8 +99,7 @@ module Google
|
|
99
99
|
# @return [String] The service account email address.
|
100
100
|
#
|
101
101
|
def service_account_email
|
102
|
-
@service_account_email ||=
|
103
|
-
service.project_service_account.email_address
|
102
|
+
@service_account_email ||= service.project_service_account.email_address
|
104
103
|
end
|
105
104
|
|
106
105
|
##
|
@@ -193,11 +192,20 @@ module Google
|
|
193
192
|
# puts bucket.name
|
194
193
|
# end
|
195
194
|
#
|
196
|
-
|
195
|
+
# @example Retrieve soft deleted buckets
|
196
|
+
# require "google/cloud/storage"
|
197
|
+
#
|
198
|
+
# storage = Google::Cloud::Storage.new
|
199
|
+
#
|
200
|
+
# soft_deleted_buckets = storage.buckets soft_deleted: true
|
201
|
+
# soft_deleted_buckets.each do |bucket|
|
202
|
+
# puts bucket.name
|
203
|
+
# end
|
204
|
+
def buckets prefix: nil, token: nil, max: nil, user_project: nil, soft_deleted: nil
|
197
205
|
gapi = service.list_buckets \
|
198
|
-
prefix: prefix, token: token, max: max, user_project: user_project
|
206
|
+
prefix: prefix, token: token, max: max, user_project: user_project, soft_deleted: soft_deleted
|
199
207
|
Bucket::List.from_gapi \
|
200
|
-
gapi, service, prefix, max, user_project: user_project
|
208
|
+
gapi, service, prefix, max, user_project: user_project, soft_deleted: soft_deleted
|
201
209
|
end
|
202
210
|
alias find_buckets buckets
|
203
211
|
|
@@ -223,6 +231,10 @@ module Google
|
|
223
231
|
# account, transit costs will be billed to the given project. This
|
224
232
|
# parameter is required with requester pays-enabled buckets. The
|
225
233
|
# default is `nil`.
|
234
|
+
# @param [Integer] generation generation no of bucket
|
235
|
+
# on whether the bucket's current metageneration matches the given value.
|
236
|
+
# @param [Boolean] soft_deleted If true, returns the soft-deleted bucket.
|
237
|
+
# This parameter is required if generation is specified.
|
226
238
|
#
|
227
239
|
# The value provided will be applied to all operations on the returned
|
228
240
|
# bucket instance and its files.
|
@@ -256,9 +268,20 @@ module Google
|
|
256
268
|
# bucket = storage.bucket "other-project-bucket",
|
257
269
|
# user_project: "my-other-project"
|
258
270
|
# files = bucket.files # Billed to "my-other-project"
|
271
|
+
# @example With `soft_deleted` set to true and generation specified:
|
272
|
+
# require "google/cloud/storage"
|
273
|
+
#
|
274
|
+
# storage = Google::Cloud::Storage.new
|
275
|
+
#
|
276
|
+
# bucket = storage.bucket "my-bucket",
|
277
|
+
# soft_deleted: true,
|
278
|
+
# generation: 1234567889
|
279
|
+
# puts bucket.name
|
259
280
|
#
|
260
281
|
def bucket bucket_name,
|
261
282
|
skip_lookup: false,
|
283
|
+
generation: nil,
|
284
|
+
soft_deleted: nil,
|
262
285
|
if_metageneration_match: nil,
|
263
286
|
if_metageneration_not_match: nil,
|
264
287
|
user_project: nil
|
@@ -269,7 +292,10 @@ module Google
|
|
269
292
|
gapi = service.get_bucket bucket_name,
|
270
293
|
if_metageneration_match: if_metageneration_match,
|
271
294
|
if_metageneration_not_match: if_metageneration_not_match,
|
272
|
-
user_project: user_project
|
295
|
+
user_project: user_project,
|
296
|
+
soft_deleted: soft_deleted,
|
297
|
+
generation: generation
|
298
|
+
|
273
299
|
Bucket.from_gapi gapi, service, user_project: user_project
|
274
300
|
rescue Google::Cloud::NotFoundError
|
275
301
|
nil
|
@@ -554,6 +580,32 @@ module Google
|
|
554
580
|
max: max, user_project: user_project
|
555
581
|
end
|
556
582
|
|
583
|
+
##
|
584
|
+
# Restores a soft deleted bucket with bucket name and generation.
|
585
|
+
#
|
586
|
+
# @param [String] bucket_name Name of the bucket.
|
587
|
+
# @param [Fixnum] generation Generation of the bucket.
|
588
|
+
#
|
589
|
+
# @return [Google::Cloud::Storage::Bucket, nil] Returns nil if bucket
|
590
|
+
# does not exist
|
591
|
+
#
|
592
|
+
# @example
|
593
|
+
# require "google/cloud/storage"
|
594
|
+
#
|
595
|
+
# storage = Google::Cloud::Storage.new
|
596
|
+
# generation= 123
|
597
|
+
#
|
598
|
+
# bucket = storage.restore_bucket "my-bucket", generation
|
599
|
+
# puts bucket.name
|
600
|
+
#
|
601
|
+
def restore_bucket bucket_name,
|
602
|
+
generation,
|
603
|
+
options: {}
|
604
|
+
gapi = service.restore_bucket bucket_name, generation,
|
605
|
+
options: options
|
606
|
+
Bucket.from_gapi gapi, service
|
607
|
+
end
|
608
|
+
|
557
609
|
##
|
558
610
|
# Generates a signed URL. See [Signed
|
559
611
|
# URLs](https://cloud.google.com/storage/docs/access-control/signed-urls)
|
@@ -55,15 +55,14 @@ module Google
|
|
55
55
|
@credentials = credentials
|
56
56
|
@service = API::StorageService.new
|
57
57
|
@service.client_options.application_name = "gcloud-ruby"
|
58
|
-
@service.client_options.application_version =
|
59
|
-
Google::Cloud::Storage::VERSION
|
58
|
+
@service.client_options.application_version = Google::Cloud::Storage::VERSION
|
60
59
|
@service.client_options.open_timeout_sec = (open_timeout || timeout)
|
61
60
|
@service.client_options.read_timeout_sec = (read_timeout || timeout)
|
62
61
|
@service.client_options.send_timeout_sec = (send_timeout || timeout)
|
63
62
|
@service.client_options.transparent_gzip_decompression = false
|
64
63
|
@service.request_options.retries = retries || 3
|
65
64
|
@service.request_options.header ||= {}
|
66
|
-
@service.request_options.header["x-goog-api-client"] =
|
65
|
+
@service.request_options.header["x-goog-api-client"] =
|
67
66
|
"gl-ruby/#{RUBY_VERSION} gccl/#{Google::Cloud::Storage::VERSION}"
|
68
67
|
@service.request_options.header["Accept-Encoding"] = "gzip"
|
69
68
|
@service.request_options.quota_project = quota_project if quota_project
|
@@ -97,11 +96,12 @@ module Google
|
|
97
96
|
|
98
97
|
##
|
99
98
|
# Retrieves a list of buckets for the given project.
|
100
|
-
def list_buckets prefix: nil, token: nil, max: nil, user_project: nil, options: {}
|
99
|
+
def list_buckets prefix: nil, token: nil, max: nil, user_project: nil, soft_deleted: nil, options: {}
|
101
100
|
execute do
|
102
101
|
service.list_buckets \
|
103
102
|
@project, prefix: prefix, page_token: token, max_results: max,
|
104
|
-
user_project: user_project(user_project),
|
103
|
+
user_project: user_project(user_project),
|
104
|
+
soft_deleted: soft_deleted, options: options
|
105
105
|
end
|
106
106
|
end
|
107
107
|
|
@@ -112,12 +112,16 @@ module Google
|
|
112
112
|
if_metageneration_match: nil,
|
113
113
|
if_metageneration_not_match: nil,
|
114
114
|
user_project: nil,
|
115
|
+
soft_deleted: nil,
|
116
|
+
generation: nil,
|
115
117
|
options: {}
|
116
118
|
execute do
|
117
119
|
service.get_bucket bucket_name,
|
118
120
|
if_metageneration_match: if_metageneration_match,
|
119
121
|
if_metageneration_not_match: if_metageneration_not_match,
|
120
122
|
user_project: user_project(user_project),
|
123
|
+
soft_deleted: soft_deleted,
|
124
|
+
generation: generation,
|
121
125
|
options: options
|
122
126
|
end
|
123
127
|
end
|
@@ -543,7 +547,6 @@ module Google
|
|
543
547
|
if_metageneration_match: nil,
|
544
548
|
user_project: nil,
|
545
549
|
options: {}
|
546
|
-
|
547
550
|
source_objects = compose_file_source_objects source_files, if_source_generation_match
|
548
551
|
compose_req = Google::Apis::StorageV1::ComposeRequest.new source_objects: source_objects,
|
549
552
|
destination: destination_gapi
|
@@ -627,6 +630,44 @@ module Google
|
|
627
630
|
end
|
628
631
|
end
|
629
632
|
|
633
|
+
##
|
634
|
+
# Moves file from source to destination path within bucket
|
635
|
+
def move_file name,
|
636
|
+
source_file,
|
637
|
+
destination_file,
|
638
|
+
if_generation_match: nil,
|
639
|
+
if_generation_not_match: nil,
|
640
|
+
if_metageneration_match: nil,
|
641
|
+
if_metageneration_not_match: nil,
|
642
|
+
if_source_generation_match: nil,
|
643
|
+
if_source_generation_not_match: nil,
|
644
|
+
if_source_metageneration_match: nil,
|
645
|
+
if_source_metageneration_not_match: nil,
|
646
|
+
user_project: nil,
|
647
|
+
fields: nil,
|
648
|
+
quota_user: nil,
|
649
|
+
user_ip: nil,
|
650
|
+
options: {}
|
651
|
+
execute do
|
652
|
+
service.move_object name,
|
653
|
+
source_file,
|
654
|
+
destination_file,
|
655
|
+
if_generation_match: if_generation_match,
|
656
|
+
if_generation_not_match: if_generation_not_match,
|
657
|
+
if_metageneration_match: if_metageneration_match,
|
658
|
+
if_metageneration_not_match: if_metageneration_not_match,
|
659
|
+
if_source_generation_match: if_source_generation_match,
|
660
|
+
if_source_generation_not_match: if_source_generation_not_match,
|
661
|
+
if_source_metageneration_match: if_source_metageneration_match,
|
662
|
+
if_source_metageneration_not_match: if_source_metageneration_not_match,
|
663
|
+
user_project: user_project(user_project),
|
664
|
+
fields: fields,
|
665
|
+
quota_user: quota_user,
|
666
|
+
user_ip: user_ip,
|
667
|
+
options: options
|
668
|
+
end
|
669
|
+
end
|
670
|
+
|
630
671
|
##
|
631
672
|
# Permanently deletes a file.
|
632
673
|
def delete_file bucket_name,
|
@@ -638,7 +679,6 @@ module Google
|
|
638
679
|
if_metageneration_not_match: nil,
|
639
680
|
user_project: nil,
|
640
681
|
options: {}
|
641
|
-
|
642
682
|
if options[:retries].nil?
|
643
683
|
is_idempotent = retry? generation: generation, if_generation_match: if_generation_match
|
644
684
|
options = is_idempotent ? {} : { retries: 0 }
|
@@ -656,6 +696,17 @@ module Google
|
|
656
696
|
end
|
657
697
|
end
|
658
698
|
|
699
|
+
##
|
700
|
+
# Restore soft deleted bucket
|
701
|
+
def restore_bucket bucket_name,
|
702
|
+
generation,
|
703
|
+
options: {}
|
704
|
+
execute do
|
705
|
+
service.restore_bucket bucket_name, generation,
|
706
|
+
options: options
|
707
|
+
end
|
708
|
+
end
|
709
|
+
|
659
710
|
##
|
660
711
|
# Restores a soft-deleted object.
|
661
712
|
def restore_file bucket_name,
|
@@ -670,7 +721,6 @@ module Google
|
|
670
721
|
user_project: nil,
|
671
722
|
fields: nil,
|
672
723
|
options: {}
|
673
|
-
|
674
724
|
if options[:retries].nil?
|
675
725
|
is_idempotent = retry? generation: generation, if_generation_match: if_generation_match
|
676
726
|
options = is_idempotent ? {} : { retries: 0 }
|
@@ -738,7 +788,6 @@ module Google
|
|
738
788
|
# Returns Google::Apis::StorageV1::HmacKey.
|
739
789
|
def create_hmac_key service_account_email, project_id: nil,
|
740
790
|
user_project: nil, options: {}
|
741
|
-
|
742
791
|
if options[:retries].nil?
|
743
792
|
options = options.merge({ retries: 0 })
|
744
793
|
end
|
@@ -899,8 +948,7 @@ module Google
|
|
899
948
|
headers = (options[:header] ||= {})
|
900
949
|
headers["x-goog-#{source}encryption-algorithm"] = "AES256"
|
901
950
|
headers["x-goog-#{source}encryption-key"] = Base64.strict_encode64 key
|
902
|
-
headers["x-goog-#{source}encryption-key-sha256"] =
|
903
|
-
Base64.strict_encode64 key_sha256
|
951
|
+
headers["x-goog-#{source}encryption-key-sha256"] = Base64.strict_encode64 key_sha256
|
904
952
|
options
|
905
953
|
end
|
906
954
|
|
data/lib/google/cloud/storage.rb
CHANGED
@@ -98,11 +98,11 @@ module Google
|
|
98
98
|
scope ||= configure.scope
|
99
99
|
retries ||= configure.retries
|
100
100
|
timeout ||= configure.timeout
|
101
|
-
open_timeout ||=
|
102
|
-
read_timeout ||=
|
103
|
-
send_timeout ||=
|
101
|
+
open_timeout ||= configure.open_timeout || timeout
|
102
|
+
read_timeout ||= configure.read_timeout || timeout
|
103
|
+
send_timeout ||= configure.send_timeout || timeout
|
104
104
|
endpoint ||= configure.endpoint
|
105
|
-
credentials ||=
|
105
|
+
credentials ||= keyfile || default_credentials(scope: scope)
|
106
106
|
max_elapsed_time ||= configure.max_elapsed_time
|
107
107
|
base_interval ||= configure.base_interval
|
108
108
|
max_interval ||= configure.max_interval
|
data/lib/google-cloud-storage.rb
CHANGED
@@ -79,11 +79,11 @@ module Google
|
|
79
79
|
def storage scope: nil, retries: nil, timeout: nil, open_timeout: nil, read_timeout: nil, send_timeout: nil,
|
80
80
|
max_elapsed_time: nil, base_interval: nil, max_interval: nil, multiplier: nil, upload_chunk_size: nil
|
81
81
|
Google::Cloud.storage @project, @keyfile, scope: scope,
|
82
|
-
retries:
|
83
|
-
timeout:
|
84
|
-
open_timeout:
|
85
|
-
read_timeout:
|
86
|
-
send_timeout:
|
82
|
+
retries: retries || @retries,
|
83
|
+
timeout: timeout || @timeout,
|
84
|
+
open_timeout: open_timeout || timeout,
|
85
|
+
read_timeout: read_timeout || timeout,
|
86
|
+
send_timeout: send_timeout || timeout,
|
87
87
|
max_elapsed_time: max_elapsed_time,
|
88
88
|
base_interval: base_interval,
|
89
89
|
max_interval: max_interval,
|
@@ -149,9 +149,9 @@ module Google
|
|
149
149
|
scope: scope,
|
150
150
|
retries: retries,
|
151
151
|
timeout: timeout,
|
152
|
-
open_timeout:
|
153
|
-
read_timeout:
|
154
|
-
send_timeout:
|
152
|
+
open_timeout: open_timeout || timeout,
|
153
|
+
read_timeout: read_timeout || timeout,
|
154
|
+
send_timeout: send_timeout || timeout,
|
155
155
|
max_elapsed_time: max_elapsed_time,
|
156
156
|
base_interval: base_interval,
|
157
157
|
max_interval: max_interval,
|
@@ -162,7 +162,6 @@ module Google
|
|
162
162
|
end
|
163
163
|
|
164
164
|
# Set the default storage configuration
|
165
|
-
# rubocop:disable Metrics/BlockLength
|
166
165
|
Google::Cloud.configure.add_config! :storage do |config|
|
167
166
|
default_project = Google::Cloud::Config.deferred do
|
168
167
|
ENV["STORAGE_PROJECT"]
|
@@ -195,4 +194,3 @@ Google::Cloud.configure.add_config! :storage do |config|
|
|
195
194
|
config.add_field! :endpoint, nil, match: String, allow_nil: true
|
196
195
|
config.add_field! :universe_domain, nil, match: String, allow_nil: true
|
197
196
|
end
|
198
|
-
# rubocop:enable Metrics/BlockLength
|
metadata
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-cloud-storage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.56.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Moore
|
8
8
|
- Chris Smith
|
9
|
-
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2025-04-21 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: google-cloud-core
|
@@ -57,16 +56,16 @@ dependencies:
|
|
57
56
|
name: google-apis-storage_v1
|
58
57
|
requirement: !ruby/object:Gem::Requirement
|
59
58
|
requirements:
|
60
|
-
- - "
|
59
|
+
- - ">="
|
61
60
|
- !ruby/object:Gem::Version
|
62
|
-
version: '0.
|
61
|
+
version: '0.42'
|
63
62
|
type: :runtime
|
64
63
|
prerelease: false
|
65
64
|
version_requirements: !ruby/object:Gem::Requirement
|
66
65
|
requirements:
|
67
|
-
- - "
|
66
|
+
- - ">="
|
68
67
|
- !ruby/object:Gem::Version
|
69
|
-
version: '0.
|
68
|
+
version: '0.42'
|
70
69
|
- !ruby/object:Gem::Dependency
|
71
70
|
name: googleauth
|
72
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -129,14 +128,14 @@ dependencies:
|
|
129
128
|
requirements:
|
130
129
|
- - "~>"
|
131
130
|
- !ruby/object:Gem::Version
|
132
|
-
version: 1.
|
131
|
+
version: 1.30.0
|
133
132
|
type: :development
|
134
133
|
prerelease: false
|
135
134
|
version_requirements: !ruby/object:Gem::Requirement
|
136
135
|
requirements:
|
137
136
|
- - "~>"
|
138
137
|
- !ruby/object:Gem::Version
|
139
|
-
version: 1.
|
138
|
+
version: 1.30.0
|
140
139
|
- !ruby/object:Gem::Dependency
|
141
140
|
name: minitest
|
142
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -325,7 +324,6 @@ homepage: https://github.com/googleapis/google-cloud-ruby/tree/master/google-clo
|
|
325
324
|
licenses:
|
326
325
|
- Apache-2.0
|
327
326
|
metadata: {}
|
328
|
-
post_install_message:
|
329
327
|
rdoc_options: []
|
330
328
|
require_paths:
|
331
329
|
- lib
|
@@ -333,15 +331,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
333
331
|
requirements:
|
334
332
|
- - ">="
|
335
333
|
- !ruby/object:Gem::Version
|
336
|
-
version:
|
334
|
+
version: 3.0.0
|
337
335
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
338
336
|
requirements:
|
339
337
|
- - ">="
|
340
338
|
- !ruby/object:Gem::Version
|
341
339
|
version: '0'
|
342
340
|
requirements: []
|
343
|
-
rubygems_version: 3.5
|
344
|
-
signing_key:
|
341
|
+
rubygems_version: 3.6.5
|
345
342
|
specification_version: 4
|
346
343
|
summary: API Client library for Google Cloud Storage
|
347
344
|
test_files: []
|