google-cloud-storage 1.30.0 → 1.39.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/AUTHENTICATION.md +2 -1
- data/CHANGELOG.md +106 -0
- data/CONTRIBUTING.md +3 -4
- data/OVERVIEW.md +30 -0
- data/lib/google/cloud/storage/bucket/acl.rb +12 -14
- data/lib/google/cloud/storage/bucket/cors.rb +4 -1
- data/lib/google/cloud/storage/bucket/lifecycle.rb +99 -21
- data/lib/google/cloud/storage/bucket/list.rb +3 -3
- data/lib/google/cloud/storage/bucket.rb +421 -62
- data/lib/google/cloud/storage/credentials.rb +16 -14
- data/lib/google/cloud/storage/file/acl.rb +181 -20
- data/lib/google/cloud/storage/file/list.rb +3 -3
- data/lib/google/cloud/storage/file/signer_v2.rb +3 -5
- data/lib/google/cloud/storage/file/signer_v4.rb +12 -10
- data/lib/google/cloud/storage/file/verifier.rb +2 -2
- data/lib/google/cloud/storage/file.rb +223 -32
- data/lib/google/cloud/storage/hmac_key/list.rb +3 -3
- data/lib/google/cloud/storage/policy/binding.rb +5 -3
- data/lib/google/cloud/storage/policy/bindings.rb +2 -2
- data/lib/google/cloud/storage/policy/condition.rb +4 -2
- data/lib/google/cloud/storage/policy.rb +2 -2
- data/lib/google/cloud/storage/post_object.rb +2 -1
- data/lib/google/cloud/storage/project.rb +38 -18
- data/lib/google/cloud/storage/service.rb +352 -284
- data/lib/google/cloud/storage/version.rb +1 -1
- data/lib/google/cloud/storage.rb +66 -13
- data/lib/google-cloud-storage.rb +51 -7
- metadata +24 -18
data/lib/google/cloud/storage.rb
CHANGED
@@ -55,7 +55,16 @@ module Google
|
|
55
55
|
# * `https://www.googleapis.com/auth/devstorage.full_control`
|
56
56
|
# @param [Integer] retries Number of times to retry requests on server
|
57
57
|
# error. The default value is `3`. Optional.
|
58
|
-
# @param [Integer]
|
58
|
+
# @param [Integer] max_elapsed_time Total time in seconds that requests are allowed to keep being retried.
|
59
|
+
# @param [Float] base_interval The initial interval in seconds between tries.
|
60
|
+
# @param [Integer] max_interval The maximum interval in seconds that any individual retry can reach.
|
61
|
+
# @param [Integer] multiplier Each successive interval grows by this factor. A multipler of 1.5 means the next
|
62
|
+
# interval will be 1.5x the current interval.
|
63
|
+
# @param [Integer] timeout (default timeout) The max duration, in seconds, to wait before timing out. Optional.
|
64
|
+
# If left blank, the wait will be at most the time permitted by the underlying HTTP/RPC protocol.
|
65
|
+
# @param [Integer] open_timeout How long, in seconds, before failed connections time out. Optional.
|
66
|
+
# @param [Integer] read_timeout How long, in seconds, before requests time out. Optional.
|
67
|
+
# @param [Integer] send_timeout How long, in seconds, before receiving response from server times out. Optional.
|
59
68
|
# @param [String] endpoint Override of the endpoint host name. Optional.
|
60
69
|
# If the param is nil, uses the default endpoint.
|
61
70
|
# @param [String] project Alias for the `project_id` argument. Deprecated.
|
@@ -75,13 +84,24 @@ module Google
|
|
75
84
|
# bucket = storage.bucket "my-bucket"
|
76
85
|
# file = bucket.file "path/to/my-file.ext"
|
77
86
|
#
|
87
|
+
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/AbcSize
|
78
88
|
def self.new project_id: nil, credentials: nil, scope: nil, retries: nil,
|
79
|
-
timeout: nil,
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
89
|
+
timeout: nil, open_timeout: nil, read_timeout: nil,
|
90
|
+
send_timeout: nil, endpoint: nil, project: nil, keyfile: nil,
|
91
|
+
max_elapsed_time: nil, base_interval: nil, max_interval: nil,
|
92
|
+
multiplier: nil
|
93
|
+
scope ||= configure.scope
|
94
|
+
retries ||= configure.retries
|
95
|
+
timeout ||= configure.timeout
|
96
|
+
open_timeout ||= (configure.open_timeout || timeout)
|
97
|
+
read_timeout ||= (configure.read_timeout || timeout)
|
98
|
+
send_timeout ||= (configure.send_timeout || timeout)
|
99
|
+
endpoint ||= configure.endpoint
|
100
|
+
credentials ||= (keyfile || default_credentials(scope: scope))
|
101
|
+
max_elapsed_time ||= configure.max_elapsed_time
|
102
|
+
base_interval ||= configure.base_interval
|
103
|
+
max_interval ||= configure.max_interval
|
104
|
+
multiplier ||= configure.multiplier
|
85
105
|
|
86
106
|
unless credentials.is_a? Google::Auth::Credentials
|
87
107
|
credentials = Storage::Credentials.new credentials, scope: scope
|
@@ -93,11 +113,15 @@ module Google
|
|
93
113
|
Storage::Project.new(
|
94
114
|
Storage::Service.new(
|
95
115
|
project_id, credentials,
|
96
|
-
retries: retries, timeout: timeout,
|
97
|
-
|
116
|
+
retries: retries, timeout: timeout, open_timeout: open_timeout,
|
117
|
+
read_timeout: read_timeout, send_timeout: send_timeout,
|
118
|
+
host: endpoint, quota_project: configure.quota_project,
|
119
|
+
max_elapsed_time: max_elapsed_time, base_interval: base_interval,
|
120
|
+
max_interval: max_interval, multiplier: multiplier
|
98
121
|
)
|
99
122
|
)
|
100
123
|
end
|
124
|
+
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/AbcSize
|
101
125
|
|
102
126
|
##
|
103
127
|
# Creates an unauthenticated, anonymous client for retrieving public data
|
@@ -105,7 +129,16 @@ module Google
|
|
105
129
|
#
|
106
130
|
# @param [Integer] retries Number of times to retry requests on server
|
107
131
|
# error. The default value is `3`. Optional.
|
108
|
-
# @param [Integer]
|
132
|
+
# @param [Integer] max_elapsed_time Total time in seconds that requests are allowed to keep being retried.
|
133
|
+
# @param [Float] base_interval The initial interval in seconds between tries.
|
134
|
+
# @param [Integer] max_interval The maximum interval in seconds that any individual retry can reach.
|
135
|
+
# @param [Integer] multiplier Each successive interval grows by this factor. A multipler of 1.5 means the next
|
136
|
+
# interval will be 1.5x the current interval.
|
137
|
+
# @param [Integer] timeout (default timeout) The max duration, in seconds, to wait before timing out. Optional.
|
138
|
+
# If left blank, the wait will be at most the time permitted by the underlying HTTP/RPC protocol.
|
139
|
+
# @param [Integer] open_timeout How long, in seconds, before failed connections time out. Optional.
|
140
|
+
# @param [Integer] read_timeout How long, in seconds, before requests time out. Optional.
|
141
|
+
# @param [Integer] send_timeout How long, in seconds, before receiving response from server times out. Optional.
|
109
142
|
# @param [String] endpoint Override of the endpoint host name. Optional.
|
110
143
|
# If the param is nil, uses the default endpoint.
|
111
144
|
#
|
@@ -123,10 +156,19 @@ module Google
|
|
123
156
|
# downloaded.rewind
|
124
157
|
# downloaded.read #=> "Hello world!"
|
125
158
|
#
|
126
|
-
def self.anonymous retries: nil, timeout: nil,
|
159
|
+
def self.anonymous retries: nil, timeout: nil, open_timeout: nil,
|
160
|
+
read_timeout: nil, send_timeout: nil, endpoint: nil,
|
161
|
+
max_elapsed_time: nil, base_interval: nil, max_interval: nil,
|
162
|
+
multiplier: nil
|
163
|
+
open_timeout ||= timeout
|
164
|
+
read_timeout ||= timeout
|
165
|
+
send_timeout ||= timeout
|
127
166
|
Storage::Project.new(
|
128
167
|
Storage::Service.new(
|
129
|
-
nil, nil, retries: retries, timeout: timeout,
|
168
|
+
nil, nil, retries: retries, timeout: timeout, open_timeout: open_timeout,
|
169
|
+
read_timeout: read_timeout, send_timeout: send_timeout, host: endpoint,
|
170
|
+
max_elapsed_time: max_elapsed_time, base_interval: base_interval,
|
171
|
+
max_interval: max_interval, multiplier: multiplier
|
130
172
|
)
|
131
173
|
)
|
132
174
|
end
|
@@ -148,7 +190,18 @@ module Google
|
|
148
190
|
# the set of resources and operations that the connection can access.
|
149
191
|
# * `retries` - (Integer) Number of times to retry requests on server
|
150
192
|
# error.
|
151
|
-
# * `
|
193
|
+
# * `max_elapsed_time` - (Integer) Total time in seconds that requests
|
194
|
+
# are allowed to keep being retried.
|
195
|
+
# * `base_interval` - (Float) The initial interval in seconds between tries.
|
196
|
+
# * `max_interval` - (Integer) The maximum interval in seconds that any
|
197
|
+
# individual retry can reach.
|
198
|
+
# * `multiplier` - (Integer) Each successive interval grows by this factor.
|
199
|
+
# A multipler of 1.5 means the next interval will be 1.5x the current interval.
|
200
|
+
# * `timeout` - (Integer) (default timeout) The max duration, in seconds, to wait before timing out.
|
201
|
+
# If left blank, the wait will be at most the time permitted by the underlying HTTP/RPC protocol.
|
202
|
+
# * `open_timeout` - (Integer) How long, in seconds, before failed connections time out.
|
203
|
+
# * `read_timeout` - (Integer) How long, in seconds, before requests time out.
|
204
|
+
# * `send_timeout` - (Integer) How long, in seconds, before receiving response from server times out.
|
152
205
|
#
|
153
206
|
# @return [Google::Cloud::Config] The configuration object the
|
154
207
|
# Google::Cloud::Storage library uses.
|
data/lib/google-cloud-storage.rb
CHANGED
@@ -45,7 +45,16 @@ module Google
|
|
45
45
|
# * `https://www.googleapis.com/auth/devstorage.full_control`
|
46
46
|
# @param [Integer] retries Number of times to retry requests on server
|
47
47
|
# error. The default value is `3`. Optional.
|
48
|
-
# @param [Integer]
|
48
|
+
# @param [Integer] max_elapsed_time Total time in seconds that requests are allowed to keep being retried.
|
49
|
+
# @param [Float] base_interval The initial interval in seconds between tries.
|
50
|
+
# @param [Integer] max_interval The maximum interval in seconds that any individual retry can reach.
|
51
|
+
# @param [Integer] multiplier Each successive interval grows by this factor. A multipler of 1.5 means the next
|
52
|
+
# interval will be 1.5x the current interval.
|
53
|
+
# @param [Integer] timeout (default timeout) The max duration, in seconds, to wait before timing out. Optional.
|
54
|
+
# If left blank, the wait will be at most the time permitted by the underlying HTTP/RPC protocol.
|
55
|
+
# @param [Integer] open_timeout How long, in seconds, before failed connections time out. Optional.
|
56
|
+
# @param [Integer] read_timeout How long, in seconds, before requests time out. Optional.
|
57
|
+
# @param [Integer] send_timeout How long, in seconds, before receiving response from server times out. Optional.
|
49
58
|
#
|
50
59
|
# @return [Google::Cloud::Storage::Project]
|
51
60
|
#
|
@@ -64,10 +73,18 @@ module Google
|
|
64
73
|
# readonly_scope = "https://www.googleapis.com/auth/devstorage.read_only"
|
65
74
|
# readonly_storage = gcloud.storage scope: readonly_scope
|
66
75
|
#
|
67
|
-
def storage scope: nil, retries: nil, timeout: nil
|
76
|
+
def storage scope: nil, retries: nil, timeout: nil, open_timeout: nil, read_timeout: nil, send_timeout: nil,
|
77
|
+
max_elapsed_time: nil, base_interval: nil, max_interval: nil, multiplier: nil
|
68
78
|
Google::Cloud.storage @project, @keyfile, scope: scope,
|
69
79
|
retries: (retries || @retries),
|
70
|
-
timeout: (timeout || @timeout)
|
80
|
+
timeout: (timeout || @timeout),
|
81
|
+
open_timeout: (open_timeout || timeout),
|
82
|
+
read_timeout: (read_timeout || timeout),
|
83
|
+
send_timeout: (send_timeout || timeout),
|
84
|
+
max_elapsed_time: max_elapsed_time,
|
85
|
+
base_interval: base_interval,
|
86
|
+
max_interval: max_interval,
|
87
|
+
multiplier: multiplier
|
71
88
|
end
|
72
89
|
|
73
90
|
##
|
@@ -93,7 +110,16 @@ module Google
|
|
93
110
|
# * `https://www.googleapis.com/auth/devstorage.full_control`
|
94
111
|
# @param [Integer] retries Number of times to retry requests on server
|
95
112
|
# error. The default value is `3`. Optional.
|
96
|
-
# @param [Integer]
|
113
|
+
# @param [Integer] max_elapsed_time Total time in seconds that requests are allowed to keep being retried.
|
114
|
+
# @param [Float] base_interval The initial interval in seconds between tries.
|
115
|
+
# @param [Integer] max_interval The maximum interval in seconds that any individual retry can reach.
|
116
|
+
# @param [Integer] multiplier Each successive interval grows by this factor. A multipler of 1.5 means the next
|
117
|
+
# interval will be 1.5x the current interval.
|
118
|
+
# @param [Integer] timeout (default timeout) The max duration, in seconds, to wait before timing out. Optional.
|
119
|
+
# If left blank, the wait will be at most the time permitted by the underlying HTTP/RPC protocol.
|
120
|
+
# @param [Integer] open_timeout How long, in seconds, before failed connections time out. Optional.
|
121
|
+
# @param [Integer] read_timeout How long, in seconds, before requests time out. Optional.
|
122
|
+
# @param [Integer] send_timeout How long, in seconds, before receiving response from server times out. Optional.
|
97
123
|
#
|
98
124
|
# @return [Google::Cloud::Storage::Project]
|
99
125
|
#
|
@@ -107,17 +133,27 @@ module Google
|
|
107
133
|
# file = bucket.file "path/to/my-file.ext"
|
108
134
|
#
|
109
135
|
def self.storage project_id = nil, credentials = nil, scope: nil,
|
110
|
-
retries: nil, timeout: nil
|
136
|
+
retries: nil, timeout: nil, open_timeout: nil, read_timeout: nil, send_timeout: nil,
|
137
|
+
max_elapsed_time: nil, base_interval: nil, max_interval: nil, multiplier: nil
|
111
138
|
require "google/cloud/storage"
|
112
139
|
Google::Cloud::Storage.new project_id: project_id,
|
113
140
|
credentials: credentials,
|
114
|
-
scope: scope,
|
115
|
-
|
141
|
+
scope: scope,
|
142
|
+
retries: retries,
|
143
|
+
timeout: timeout,
|
144
|
+
open_timeout: (open_timeout || timeout),
|
145
|
+
read_timeout: (read_timeout || timeout),
|
146
|
+
send_timeout: (send_timeout || timeout),
|
147
|
+
max_elapsed_time: max_elapsed_time,
|
148
|
+
base_interval: base_interval,
|
149
|
+
max_interval: max_interval,
|
150
|
+
multiplier: multiplier
|
116
151
|
end
|
117
152
|
end
|
118
153
|
end
|
119
154
|
|
120
155
|
# Set the default storage configuration
|
156
|
+
# rubocop:disable Metrics/BlockLength
|
121
157
|
Google::Cloud.configure.add_config! :storage do |config|
|
122
158
|
default_project = Google::Cloud::Config.deferred do
|
123
159
|
ENV["STORAGE_PROJECT"]
|
@@ -138,7 +174,15 @@ Google::Cloud.configure.add_config! :storage do |config|
|
|
138
174
|
config.add_field! :scope, nil, match: [String, Array]
|
139
175
|
config.add_field! :quota_project, nil, match: String
|
140
176
|
config.add_field! :retries, nil, match: Integer
|
177
|
+
config.add_field! :max_elapsed_time, nil, match: Integer
|
178
|
+
config.add_field! :base_interval, nil, match: Float
|
179
|
+
config.add_field! :max_interval, nil, match: Integer
|
180
|
+
config.add_field! :multiplier, nil, match: Integer
|
141
181
|
config.add_field! :timeout, nil, match: Integer
|
182
|
+
config.add_field! :open_timeout, nil, match: Integer
|
183
|
+
config.add_field! :read_timeout, nil, match: Integer
|
184
|
+
config.add_field! :send_timeout, nil, match: Integer
|
142
185
|
# TODO: Remove once discovery document is updated.
|
143
186
|
config.add_field! :endpoint, "https://storage.googleapis.com/", match: String
|
144
187
|
end
|
188
|
+
# rubocop:enable Metrics/BlockLength
|
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.39.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:
|
12
|
+
date: 2022-08-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: google-cloud-core
|
@@ -17,14 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '1.
|
20
|
+
version: '1.6'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: '1.
|
27
|
+
version: '1.6'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: google-apis-iamcredentials_v1
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -45,28 +45,34 @@ 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
|
59
59
|
requirements:
|
60
|
-
- - "
|
60
|
+
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version:
|
62
|
+
version: 0.16.2
|
63
|
+
- - "<"
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 2.a
|
63
66
|
type: :runtime
|
64
67
|
prerelease: false
|
65
68
|
version_requirements: !ruby/object:Gem::Requirement
|
66
69
|
requirements:
|
67
|
-
- - "
|
70
|
+
- - ">="
|
68
71
|
- !ruby/object:Gem::Version
|
69
|
-
version:
|
72
|
+
version: 0.16.2
|
73
|
+
- - "<"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 2.a
|
70
76
|
- !ruby/object:Gem::Dependency
|
71
77
|
name: digest-crc
|
72
78
|
requirement: !ruby/object:Gem::Requirement
|
@@ -87,14 +93,14 @@ dependencies:
|
|
87
93
|
requirements:
|
88
94
|
- - "~>"
|
89
95
|
- !ruby/object:Gem::Version
|
90
|
-
version: '2.
|
96
|
+
version: '2.8'
|
91
97
|
type: :runtime
|
92
98
|
prerelease: false
|
93
99
|
version_requirements: !ruby/object:Gem::Requirement
|
94
100
|
requirements:
|
95
101
|
- - "~>"
|
96
102
|
- !ruby/object:Gem::Version
|
97
|
-
version: '2.
|
103
|
+
version: '2.8'
|
98
104
|
- !ruby/object:Gem::Dependency
|
99
105
|
name: mini_mime
|
100
106
|
requirement: !ruby/object:Gem::Requirement
|
@@ -115,28 +121,28 @@ dependencies:
|
|
115
121
|
requirements:
|
116
122
|
- - "~>"
|
117
123
|
- !ruby/object:Gem::Version
|
118
|
-
version: 1.
|
124
|
+
version: 1.25.1
|
119
125
|
type: :development
|
120
126
|
prerelease: false
|
121
127
|
version_requirements: !ruby/object:Gem::Requirement
|
122
128
|
requirements:
|
123
129
|
- - "~>"
|
124
130
|
- !ruby/object:Gem::Version
|
125
|
-
version: 1.
|
131
|
+
version: 1.25.1
|
126
132
|
- !ruby/object:Gem::Dependency
|
127
133
|
name: minitest
|
128
134
|
requirement: !ruby/object:Gem::Requirement
|
129
135
|
requirements:
|
130
136
|
- - "~>"
|
131
137
|
- !ruby/object:Gem::Version
|
132
|
-
version: '5.
|
138
|
+
version: '5.16'
|
133
139
|
type: :development
|
134
140
|
prerelease: false
|
135
141
|
version_requirements: !ruby/object:Gem::Requirement
|
136
142
|
requirements:
|
137
143
|
- - "~>"
|
138
144
|
- !ruby/object:Gem::Version
|
139
|
-
version: '5.
|
145
|
+
version: '5.16'
|
140
146
|
- !ruby/object:Gem::Dependency
|
141
147
|
name: minitest-autotest
|
142
148
|
requirement: !ruby/object:Gem::Requirement
|
@@ -305,14 +311,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
305
311
|
requirements:
|
306
312
|
- - ">="
|
307
313
|
- !ruby/object:Gem::Version
|
308
|
-
version: '2.
|
314
|
+
version: '2.5'
|
309
315
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
310
316
|
requirements:
|
311
317
|
- - ">="
|
312
318
|
- !ruby/object:Gem::Version
|
313
319
|
version: '0'
|
314
320
|
requirements: []
|
315
|
-
rubygems_version: 3.
|
321
|
+
rubygems_version: 3.3.14
|
316
322
|
signing_key:
|
317
323
|
specification_version: 4
|
318
324
|
summary: API Client library for Google Cloud Storage
|