google-cloud-storage 1.37.0 → 1.38.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 +6 -0
- data/lib/google/cloud/storage/bucket.rb +14 -0
- data/lib/google/cloud/storage/project.rb +6 -4
- data/lib/google/cloud/storage/service.rb +1 -157
- data/lib/google/cloud/storage/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7377748053d6da28b196231e893002e4d80849cf558b5e983003926c19526a6c
|
|
4
|
+
data.tar.gz: b00e59073ea7230b4b654de40e6323766d6e36a562d765ad2545c8d154b16d2d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 65b18a6857817dd24246d287c3e51cabfb2ec61fffda26f3fc00462fd030e60c506a893ccc86a14cfc1034d882c6d488b5220e744ee2fe3316d55271c9fdaadc
|
|
7
|
+
data.tar.gz: fede3f8da08220a89dc1642fd1937cc75ea6b57ee9d210bd8a8dc4efcb5c11ff5dab0d2962c7c25f383cda4e9aa548fe8764c0ec06867abf46ca91d7fbbd33e3
|
data/CHANGELOG.md
CHANGED
|
@@ -301,6 +301,20 @@ module Google
|
|
|
301
301
|
@gapi.location_type
|
|
302
302
|
end
|
|
303
303
|
|
|
304
|
+
##
|
|
305
|
+
# Returns the list of regional locations for custom dual-region buckets.
|
|
306
|
+
#
|
|
307
|
+
# @return [String, nil] Returns nil if the property has not been set before creation,
|
|
308
|
+
# if the bucket's resource has not been loaded from the server,
|
|
309
|
+
# or if the bucket is not a dual-regions bucket.
|
|
310
|
+
|
|
311
|
+
# @see https://cloud.google.com/storage/docs/json_api/v1/buckets and
|
|
312
|
+
# https://cloud.google.com/storage/docs/locations
|
|
313
|
+
#
|
|
314
|
+
def data_locations
|
|
315
|
+
@gapi.custom_placement_config&.data_locations
|
|
316
|
+
end
|
|
317
|
+
|
|
304
318
|
##
|
|
305
319
|
# The destination bucket name for the bucket's logs.
|
|
306
320
|
#
|
|
@@ -290,9 +290,9 @@ module Google
|
|
|
290
290
|
# access, and allUsers get READER access.
|
|
291
291
|
# @param [String] location The location of the bucket. Optional.
|
|
292
292
|
# If not passed, the default location, 'US', will be used.
|
|
293
|
-
# If specifying a dual-region location, the
|
|
294
|
-
#
|
|
295
|
-
# [Storage
|
|
293
|
+
# If specifying a dual-region location, the `customPlacementConfig`
|
|
294
|
+
# property should be set in conjunction. See:
|
|
295
|
+
# [Storage Locations](https://cloud.google.com/storage/docs/locations).
|
|
296
296
|
# @param [String] logging_bucket The destination bucket for the bucket's
|
|
297
297
|
# logs. For more information, see [Access
|
|
298
298
|
# Logs](https://cloud.google.com/storage/docs/access-logs).
|
|
@@ -367,6 +367,7 @@ module Google
|
|
|
367
367
|
acl: nil,
|
|
368
368
|
default_acl: nil,
|
|
369
369
|
location: nil,
|
|
370
|
+
custom_placement_config: nil,
|
|
370
371
|
storage_class: nil,
|
|
371
372
|
logging_bucket: nil,
|
|
372
373
|
logging_prefix: nil,
|
|
@@ -377,7 +378,8 @@ module Google
|
|
|
377
378
|
user_project: nil
|
|
378
379
|
params = {
|
|
379
380
|
name: bucket_name,
|
|
380
|
-
location: location
|
|
381
|
+
location: location,
|
|
382
|
+
custom_placement_config: custom_placement_config
|
|
381
383
|
}.delete_if { |_, v| v.nil? }
|
|
382
384
|
new_bucket = Google::Apis::StorageV1::Bucket.new(**params)
|
|
383
385
|
storage_class = storage_class_for storage_class
|
|
@@ -488,7 +488,7 @@ module Google
|
|
|
488
488
|
options = range_header options, range
|
|
489
489
|
|
|
490
490
|
execute do
|
|
491
|
-
service.
|
|
491
|
+
service.get_object \
|
|
492
492
|
bucket_name, file_path,
|
|
493
493
|
download_dest: target_path, generation: generation,
|
|
494
494
|
user_project: user_project(user_project),
|
|
@@ -774,160 +774,4 @@ module Google
|
|
|
774
774
|
end
|
|
775
775
|
end
|
|
776
776
|
end
|
|
777
|
-
|
|
778
|
-
# rubocop:disable all
|
|
779
|
-
|
|
780
|
-
# @private
|
|
781
|
-
#
|
|
782
|
-
# IMPORTANT: These monkey-patches of Apis::StorageV1::StorageService and
|
|
783
|
-
# Apis::Core::DownloadCommand must be verified and updated (if needed) for
|
|
784
|
-
# every upgrade of google-api-client.
|
|
785
|
-
#
|
|
786
|
-
# The purpose of these modifications is to provide access to response headers
|
|
787
|
-
# (in particular, the Content-Encoding header) for the #download_file method,
|
|
788
|
-
# above. If google-api-client is modified to expose response headers to its
|
|
789
|
-
# clients, this code should be removed, and #download_file updated to use that
|
|
790
|
-
# solution instead.
|
|
791
|
-
#
|
|
792
|
-
module Apis
|
|
793
|
-
# @private
|
|
794
|
-
module StorageV1
|
|
795
|
-
# @private
|
|
796
|
-
class StorageService
|
|
797
|
-
# Returns a two-element array containing:
|
|
798
|
-
# * The `result` that is the usual return type of #get_object.
|
|
799
|
-
# * The `http_resp` from DownloadCommand#execute_once.
|
|
800
|
-
def get_object_with_response(bucket, object, generation: nil, if_generation_match: nil, if_generation_not_match: nil, if_metageneration_match: nil, if_metageneration_not_match: nil, projection: nil, user_project: nil, fields: nil, quota_user: nil, user_ip: nil, download_dest: nil, options: nil, &block)
|
|
801
|
-
if download_dest.nil?
|
|
802
|
-
command = make_simple_command(:get, 'b/{bucket}/o/{object}', options)
|
|
803
|
-
else
|
|
804
|
-
command = make_download_command(:get, 'b/{bucket}/o/{object}', options)
|
|
805
|
-
command.download_dest = download_dest
|
|
806
|
-
end
|
|
807
|
-
command.response_representation = Google::Apis::StorageV1::Object::Representation
|
|
808
|
-
command.response_class = Google::Apis::StorageV1::Object
|
|
809
|
-
command.params['bucket'] = bucket unless bucket.nil?
|
|
810
|
-
command.params['object'] = object unless object.nil?
|
|
811
|
-
command.query['generation'] = generation unless generation.nil?
|
|
812
|
-
command.query['ifGenerationMatch'] = if_generation_match unless if_generation_match.nil?
|
|
813
|
-
command.query['ifGenerationNotMatch'] = if_generation_not_match unless if_generation_not_match.nil?
|
|
814
|
-
command.query['ifMetagenerationMatch'] = if_metageneration_match unless if_metageneration_match.nil?
|
|
815
|
-
command.query['ifMetagenerationNotMatch'] = if_metageneration_not_match unless if_metageneration_not_match.nil?
|
|
816
|
-
command.query['projection'] = projection unless projection.nil?
|
|
817
|
-
command.query['userProject'] = user_project unless user_project.nil?
|
|
818
|
-
command.query['fields'] = fields unless fields.nil?
|
|
819
|
-
command.query['quotaUser'] = quota_user unless quota_user.nil?
|
|
820
|
-
command.query['userIp'] = user_ip unless user_ip.nil?
|
|
821
|
-
execute_or_queue_command_with_response(command, &block)
|
|
822
|
-
end
|
|
823
|
-
|
|
824
|
-
# Returns a two-element array containing:
|
|
825
|
-
# * The `result` that is the usual return type of #execute_or_queue_command.
|
|
826
|
-
# * The `http_resp` from DownloadCommand#execute_once.
|
|
827
|
-
def execute_or_queue_command_with_response(command, &callback)
|
|
828
|
-
batch_command = current_batch
|
|
829
|
-
if batch_command
|
|
830
|
-
raise "Can not combine services in a batch" if Thread.current[:google_api_batch_service] != self
|
|
831
|
-
batch_command.add(command, &callback)
|
|
832
|
-
nil
|
|
833
|
-
else
|
|
834
|
-
command.execute_with_response(client, &callback)
|
|
835
|
-
end
|
|
836
|
-
end
|
|
837
|
-
end
|
|
838
|
-
end
|
|
839
|
-
# @private
|
|
840
|
-
module Core
|
|
841
|
-
# @private
|
|
842
|
-
# Streaming/resumable media download support
|
|
843
|
-
class DownloadCommand < ApiCommand
|
|
844
|
-
# Returns a two-element array containing:
|
|
845
|
-
# * The `result` that is the usual return type of #execute.
|
|
846
|
-
# * The `http_resp` from #execute_once.
|
|
847
|
-
def execute_with_response(client)
|
|
848
|
-
prepare!
|
|
849
|
-
begin
|
|
850
|
-
Retriable.retriable tries: options.retries + 1,
|
|
851
|
-
base_interval: 1,
|
|
852
|
-
multiplier: 2,
|
|
853
|
-
on: RETRIABLE_ERRORS do |try|
|
|
854
|
-
# This 2nd level retriable only catches auth errors, and supports 1 retry, which allows
|
|
855
|
-
# auth to be re-attempted without having to retry all sorts of other failures like
|
|
856
|
-
# NotFound, etc
|
|
857
|
-
auth_tries = (try == 1 && authorization_refreshable? ? 2 : 1)
|
|
858
|
-
Retriable.retriable tries: auth_tries,
|
|
859
|
-
on: [Google::Apis::AuthorizationError, Signet::AuthorizationError],
|
|
860
|
-
on_retry: proc { |*| refresh_authorization } do
|
|
861
|
-
execute_once_with_response(client).tap do |result|
|
|
862
|
-
if block_given?
|
|
863
|
-
yield result, nil
|
|
864
|
-
end
|
|
865
|
-
end
|
|
866
|
-
end
|
|
867
|
-
end
|
|
868
|
-
rescue => e
|
|
869
|
-
if block_given?
|
|
870
|
-
yield nil, e
|
|
871
|
-
else
|
|
872
|
-
raise e
|
|
873
|
-
end
|
|
874
|
-
end
|
|
875
|
-
ensure
|
|
876
|
-
release!
|
|
877
|
-
end
|
|
878
|
-
|
|
879
|
-
# Returns a two-element array containing:
|
|
880
|
-
# * The `result` that is the usual return type of #execute_once.
|
|
881
|
-
# * The `http_resp`.
|
|
882
|
-
def execute_once_with_response(client, &block)
|
|
883
|
-
request_header = header.dup
|
|
884
|
-
apply_request_options(request_header)
|
|
885
|
-
download_offset = nil
|
|
886
|
-
|
|
887
|
-
if @offset > 0
|
|
888
|
-
logger.debug { sprintf('Resuming download from offset %d', @offset) }
|
|
889
|
-
request_header[RANGE_HEADER] = sprintf('bytes=%d-', @offset)
|
|
890
|
-
end
|
|
891
|
-
|
|
892
|
-
http_res = client.get(url.to_s,
|
|
893
|
-
query: query,
|
|
894
|
-
header: request_header,
|
|
895
|
-
follow_redirect: true) do |res, chunk|
|
|
896
|
-
status = res.http_header.status_code.to_i
|
|
897
|
-
next unless OK_STATUS.include?(status)
|
|
898
|
-
|
|
899
|
-
download_offset ||= (status == 206 ? @offset : 0)
|
|
900
|
-
download_offset += chunk.bytesize
|
|
901
|
-
|
|
902
|
-
if download_offset - chunk.bytesize == @offset
|
|
903
|
-
next_chunk = chunk
|
|
904
|
-
else
|
|
905
|
-
# Oh no! Requested a chunk, but received the entire content
|
|
906
|
-
chunk_index = @offset - (download_offset - chunk.bytesize)
|
|
907
|
-
next_chunk = chunk.byteslice(chunk_index..-1)
|
|
908
|
-
next if next_chunk.nil?
|
|
909
|
-
end
|
|
910
|
-
# logger.debug { sprintf('Writing chunk (%d bytes, %d total)', chunk.length, bytes_read) }
|
|
911
|
-
@download_io.write(next_chunk)
|
|
912
|
-
|
|
913
|
-
@offset += next_chunk.bytesize
|
|
914
|
-
end
|
|
915
|
-
|
|
916
|
-
@download_io.flush
|
|
917
|
-
|
|
918
|
-
if @close_io_on_finish
|
|
919
|
-
result = nil
|
|
920
|
-
else
|
|
921
|
-
result = @download_io
|
|
922
|
-
end
|
|
923
|
-
check_status(http_res.status.to_i, http_res.header, http_res.body)
|
|
924
|
-
success([result, http_res], &block)
|
|
925
|
-
rescue => e
|
|
926
|
-
@download_io.flush
|
|
927
|
-
error(e, rethrow: true, &block)
|
|
928
|
-
end
|
|
929
|
-
end
|
|
930
|
-
end
|
|
931
|
-
end
|
|
932
|
-
# rubocop:enable all
|
|
933
777
|
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.
|
|
4
|
+
version: 1.38.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-
|
|
12
|
+
date: 2022-08-01 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:
|
|
48
|
+
version: 0.17.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:
|
|
55
|
+
version: 0.17.0
|
|
56
56
|
- !ruby/object:Gem::Dependency
|
|
57
57
|
name: googleauth
|
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|