google-cloud-core 1.4.1 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d9ad04201bcaa94845823bbf1bf5558844c152b9556e64a666f08aa08d7e05fb
4
- data.tar.gz: 9aad4b1d3dcec0f9eb880713ad3d6bee7daac5e15721d87a7d0697f20cd59152
3
+ metadata.gz: 8335e0770899a3b55e53c76dd3d971f44aa00609b25131147063f86a27cef04d
4
+ data.tar.gz: fb986a63f272e2f6071e477bcedaa6e4d9cc01b7750b3164dce7f83404fb2e90
5
5
  SHA512:
6
- metadata.gz: 8176cfb9c7ec536b4636be3c9d5fe89600a3514258b51d02b580da031f9b25582edce4f4caaa9a2188d39f12fa652035f4a3d9b536647780e6f32502972b18b1
7
- data.tar.gz: e743baa12cf868972a5df1464275d6a67ad4a88a16aefec8b88688527405ba6f6cd36e978864f6ff8d43d009c555e93708339a0bd0bde395d42f280005a99654
6
+ metadata.gz: 5c1666693b48cedae86d152f695249a3ca0d793aaea0fac53321c45743e49ff98d1fe13334b49fae3e1edbd7efdb4742f3919ca47cb242d18364e5ca0c6794ac
7
+ data.tar.gz: c5986aba8797b57094a9cf7129175c61f4e02d07364141ffd2fdc1c93b0738edc315bfc4dd9c8dc7e344b146d180f46ffcf7c7297324e3137042d2135e8f7929
@@ -121,73 +121,6 @@ module Google
121
121
  end
122
122
  end
123
123
 
124
- # Update the supported and recommended version thresholds according to the
125
- # MRI support schedule: supported means non-EOL, and recommended means in
126
- # normal (rather than security) maintenance. Generally, this means updating
127
- # these at the end of March each year, if the previous year patterns hold.
128
- # See https://www.ruby-lang.org/en/downloads/branches/
129
-
130
- ##
131
- # Minimum "supported" Ruby version (non-EOL)
132
- # @private
133
- #
134
- SUPPORTED_VERSION_THRESHOLD = "2.3".freeze
135
-
136
- ##
137
- # Minimum "recommended" Ruby version (normal maintenance)
138
- # @private
139
- #
140
- RECOMMENDED_VERSION_THRESHOLD = "2.4".freeze
141
-
142
- ##
143
- # Check Ruby version and emit a warning if it is old
144
- # @private
145
- #
146
- def self.warn_on_old_ruby_version \
147
- supported_version: SUPPORTED_VERSION_THRESHOLD,
148
- recommended_version: RECOMMENDED_VERSION_THRESHOLD
149
- return if ENV["GOOGLE_CLOUD_SUPPRESS_RUBY_WARNINGS"]
150
- cur_version = Gem::Version.new RUBY_VERSION
151
- if cur_version < Gem::Version.new(supported_version)
152
- warn_unsupported_ruby cur_version, recommended_version
153
- elsif cur_version < Gem::Version.new(recommended_version)
154
- warn_nonrecommended_ruby cur_version, recommended_version
155
- end
156
- rescue ArgumentError
157
- warn "Unable to determine current Ruby version."
158
- end
159
-
160
- ##
161
- # Print a warning for an EOL version of Ruby
162
- # @private
163
- #
164
- def self.warn_unsupported_ruby cur_version, recommended_version
165
- warn "WARNING: You are running Ruby #{cur_version}, which has reached" \
166
- " end-of-life and is no longer supported by Ruby Core."
167
- warn "The Google Cloud API clients work best on supported versions of" \
168
- " Ruby. It is strongly recommended that you upgrade to Ruby" \
169
- " #{recommended_version} or later."
170
- warn "See https://www.ruby-lang.org/en/downloads/branches/ for more" \
171
- " info on the Ruby maintenance schedule."
172
- warn "To suppress this message, set the" \
173
- " GOOGLE_CLOUD_SUPPRESS_RUBY_WARNINGS environment variable."
174
- end
175
-
176
- ##
177
- # Print a warning for a supported but nearing EOL version of Ruby
178
- # @private
179
- #
180
- def self.warn_nonrecommended_ruby cur_version, recommended_version
181
- warn "WARNING: You are running Ruby #{cur_version}, which is nearing" \
182
- " end-of-life."
183
- warn "The Google Cloud API clients work best on supported versions of" \
184
- " Ruby. Consider upgrading to Ruby #{recommended_version} or later."
185
- warn "See https://www.ruby-lang.org/en/downloads/branches/ for more" \
186
- " info on the Ruby maintenance schedule."
187
- warn "To suppress this message, set the" \
188
- " GOOGLE_CLOUD_SUPPRESS_RUBY_WARNINGS environment variable."
189
- end
190
-
191
124
  ##
192
125
  # Safely load all google-cloud-* gems.
193
126
  # @private
@@ -233,8 +166,5 @@ end
233
166
  # Set the default top-level configuration
234
167
  Google::Cloud.init_configuration
235
168
 
236
- # Emit a warning if current Ruby is at or nearing end-of-life
237
- Google::Cloud.warn_on_old_ruby_version
238
-
239
169
  # Auto-load all Google Cloud service gems.
240
170
  Google::Cloud.auto_load_gems
@@ -336,6 +336,7 @@ module Google
336
336
  def field? key
337
337
  @validators[key.to_sym].is_a? ::Proc
338
338
  end
339
+ alias respond_to? field?
339
340
 
340
341
  ##
341
342
  # Check if the given key has been explicitly added as a subconfig name.
@@ -395,11 +396,12 @@ module Google
395
396
  def to_s!
396
397
  elems = @validators.keys.map do |k|
397
398
  v = @values[k]
398
- vstr = Config.config?(v) ? v.to_s! : value.inspect
399
+ vstr = Config.config?(v) ? v.to_s! : v.inspect
399
400
  " #{k}=#{vstr}"
400
401
  end
401
402
  "<Config:#{elems.join}>"
402
403
  end
404
+ alias inspect to_s!
403
405
 
404
406
  ##
405
407
  # Returns a nested hash representation of this configuration state,
@@ -495,9 +497,11 @@ module Google
495
497
  #
496
498
  ILLEGAL_KEYS = [:add_options,
497
499
  :initialize,
500
+ :inspect,
498
501
  :instance_eval,
499
502
  :instance_exec,
500
503
  :method_missing,
504
+ :send,
501
505
  :singleton_method_added,
502
506
  :singleton_method_removed,
503
507
  :singleton_method_undefined].freeze
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Core
19
- VERSION = "1.4.1".freeze
19
+ VERSION = "1.5.0".freeze
20
20
  end
21
21
  end
22
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-cloud-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.5.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: 2019-10-30 00:00:00.000000000 Z
12
+ date: 2020-01-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: google-cloud-env
@@ -25,6 +25,20 @@ dependencies:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
27
  version: '1.0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: google-cloud-errors
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '1.0'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '1.0'
28
42
  - !ruby/object:Gem::Dependency
29
43
  name: autotest-suffix
30
44
  requirement: !ruby/object:Gem::Requirement
@@ -183,7 +197,6 @@ files:
183
197
  - lib/google/cloud/config.rb
184
198
  - lib/google/cloud/core/version.rb
185
199
  - lib/google/cloud/credentials.rb
186
- - lib/google/cloud/errors.rb
187
200
  homepage: https://github.com/googleapis/google-cloud-ruby/tree/master/google-cloud-core
188
201
  licenses:
189
202
  - Apache-2.0
@@ -1,324 +0,0 @@
1
- # Copyright 2015 Google LLC
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
-
16
- require "English"
17
-
18
- module Google
19
- module Cloud
20
- ##
21
- # Base google-cloud exception class.
22
- class Error < StandardError
23
- ##
24
- # Construct a new Google::Cloud::Error object, optionally passing in a
25
- # message.
26
- def initialize msg = nil
27
- super
28
- @cause = $ERROR_INFO
29
- end
30
-
31
- # Add Error#cause (introduced in 2.1) to Ruby 2.0.
32
- unless respond_to? :cause
33
- ##
34
- # The previous exception at the time this exception was raised. This is
35
- # useful for wrapping exceptions and retaining the original exception
36
- # information.
37
- define_method :cause do
38
- @cause
39
- end
40
- end
41
-
42
- ##
43
- # Returns the value of `status_code` from the underlying cause error
44
- # object, if both are present. Otherwise returns `nil`.
45
- #
46
- # This is typically present on errors originating from calls to an API
47
- # over HTTP/REST.
48
- #
49
- # @return [Object, nil]
50
- def status_code
51
- return nil unless cause&.respond_to? :status_code
52
- cause.status_code
53
- end
54
-
55
- ##
56
- # Returns the value of `body` from the underlying cause error
57
- # object, if both are present. Otherwise returns `nil`.
58
- #
59
- # This is typically present on errors originating from calls to an API
60
- # over HTTP/REST.
61
- #
62
- # @return [Object, nil]
63
- def body
64
- return nil unless cause&.respond_to? :body
65
- cause.body
66
- end
67
-
68
- ##
69
- # Returns the value of `header` from the underlying cause error
70
- # object, if both are present. Otherwise returns `nil`.
71
- #
72
- # This is typically present on errors originating from calls to an API
73
- # over HTTP/REST.
74
- #
75
- # @return [Object, nil]
76
- def header
77
- return nil unless cause&.respond_to? :header
78
- cause.header
79
- end
80
-
81
- ##
82
- # Returns the value of `code` from the underlying cause error
83
- # object, if both are present. Otherwise returns `nil`.
84
- #
85
- # This is typically present on errors originating from calls to an API
86
- # over gRPC.
87
- #
88
- # @return [Object, nil]
89
- def code
90
- return nil unless cause&.respond_to? :code
91
- cause.code
92
- end
93
-
94
- ##
95
- # Returns the value of `details` from the underlying cause error
96
- # object, if both are present. Otherwise returns `nil`.
97
- #
98
- # This is typically present on errors originating from calls to an API
99
- # over gRPC.
100
- #
101
- # @return [Object, nil]
102
- def details
103
- return nil unless cause&.respond_to? :details
104
- cause.details
105
- end
106
-
107
- ##
108
- # Returns the value of `metadata` from the underlying cause error
109
- # object, if both are present. Otherwise returns `nil`.
110
- #
111
- # This is typically present on errors originating from calls to an API
112
- # over gRPC.
113
- #
114
- # @return [Object, nil]
115
- def metadata
116
- return nil unless cause&.respond_to? :metadata
117
- cause.metadata
118
- end
119
-
120
- ##
121
- # Returns the value of `status_details` from the underlying cause error
122
- # object, if both are present. Otherwise returns `nil`.
123
- #
124
- # This is typically present on errors originating from calls to an API
125
- # over gRPC.
126
- #
127
- # @return [Object, nil]
128
- def status_details
129
- return nil unless cause&.respond_to? :status_details
130
- cause.status_details
131
- end
132
-
133
- # @private Create a new error object from a client error
134
- def self.from_error error
135
- klass = if error.respond_to? :code
136
- grpc_error_class_for error.code
137
- elsif error.respond_to? :status_code
138
- gapi_error_class_for error.status_code
139
- else
140
- self
141
- end
142
- klass.new error.message
143
- end
144
-
145
- # @private Identify the subclass for a gRPC error
146
- def self.grpc_error_class_for grpc_error_code
147
- # The gRPC status code 0 is for a successful response.
148
- # So there is no error subclass for a 0 status code, use current class.
149
- [
150
- self, CanceledError, UnknownError, InvalidArgumentError,
151
- DeadlineExceededError, NotFoundError, AlreadyExistsError,
152
- PermissionDeniedError, ResourceExhaustedError,
153
- FailedPreconditionError, AbortedError, OutOfRangeError,
154
- UnimplementedError, InternalError, UnavailableError, DataLossError,
155
- UnauthenticatedError
156
- ][grpc_error_code] || self
157
- end
158
-
159
- # @private Identify the subclass for a Google API Client error
160
- def self.gapi_error_class_for http_status_code
161
- # The http status codes mapped to their error classes.
162
- {
163
- 400 => InvalidArgumentError, # FailedPreconditionError/OutOfRangeError
164
- 401 => UnauthenticatedError,
165
- 403 => PermissionDeniedError,
166
- 404 => NotFoundError,
167
- 409 => AlreadyExistsError, # AbortedError
168
- 412 => FailedPreconditionError,
169
- 429 => ResourceExhaustedError,
170
- 499 => CanceledError,
171
- 500 => InternalError, # UnknownError/DataLossError
172
- 501 => UnimplementedError,
173
- 503 => UnavailableError,
174
- 504 => DeadlineExceededError
175
- }[http_status_code] || self
176
- end
177
- end
178
-
179
- ##
180
- # Canceled indicates the operation was cancelled (typically by the caller).
181
- class CanceledError < Error
182
- end
183
-
184
- ##
185
- # Unknown error. An example of where this error may be returned is
186
- # if a Status value received from another address space belongs to
187
- # an error-space that is not known in this address space. Also
188
- # errors raised by APIs that do not return enough error information
189
- # may be converted to this error.
190
- class UnknownError < Error
191
- end
192
-
193
- ##
194
- # InvalidArgument indicates client specified an invalid argument.
195
- # Note that this differs from FailedPrecondition. It indicates arguments
196
- # that are problematic regardless of the state of the system
197
- # (e.g., a malformed file name).
198
- class InvalidArgumentError < Error
199
- end
200
-
201
- ##
202
- # DeadlineExceeded means operation expired before completion.
203
- # For operations that change the state of the system, this error may be
204
- # returned even if the operation has completed successfully. For
205
- # example, a successful response from a server could have been delayed
206
- # long enough for the deadline to expire.
207
- class DeadlineExceededError < Error
208
- end
209
-
210
- ##
211
- # NotFound means some requested entity (e.g., file or directory) was
212
- # not found.
213
- class NotFoundError < Error
214
- end
215
-
216
- ##
217
- # AlreadyExists means an attempt to create an entity failed because one
218
- # already exists.
219
- class AlreadyExistsError < Error
220
- end
221
-
222
- ##
223
- # PermissionDenied indicates the caller does not have permission to
224
- # execute the specified operation. It must not be used for rejections
225
- # caused by exhausting some resource (use ResourceExhausted
226
- # instead for those errors). It must not be
227
- # used if the caller cannot be identified (use Unauthenticated
228
- # instead for those errors).
229
- class PermissionDeniedError < Error
230
- end
231
-
232
- ##
233
- # Unauthenticated indicates the request does not have valid
234
- # authentication credentials for the operation.
235
- class UnauthenticatedError < Error
236
- end
237
-
238
- ##
239
- # ResourceExhausted indicates some resource has been exhausted, perhaps
240
- # a per-user quota, or perhaps the entire file system is out of space.
241
- class ResourceExhaustedError < Error
242
- end
243
-
244
- ##
245
- # FailedPrecondition indicates operation was rejected because the
246
- # system is not in a state required for the operation's execution.
247
- # For example, directory to be deleted may be non-empty, an rmdir
248
- # operation is applied to a non-directory, etc.
249
- #
250
- # A litmus test that may help a service implementor in deciding
251
- # between FailedPrecondition, Aborted, and Unavailable:
252
- # (a) Use Unavailable if the client can retry just the failing call.
253
- # (b) Use Aborted if the client should retry at a higher-level
254
- # (e.g., restarting a read-modify-write sequence).
255
- # (c) Use FailedPrecondition if the client should not retry until
256
- # the system state has been explicitly fixed. E.g., if an "rmdir"
257
- # fails because the directory is non-empty, FailedPrecondition
258
- # should be returned since the client should not retry unless
259
- # they have first fixed up the directory by deleting files from it.
260
- # (d) Use FailedPrecondition if the client performs conditional
261
- # REST Get/Update/Delete on a resource and the resource on the
262
- # server does not match the condition. E.g., conflicting
263
- # read-modify-write on the same resource.
264
- class FailedPreconditionError < Error
265
- end
266
-
267
- ##
268
- # Aborted indicates the operation was aborted, typically due to a
269
- # concurrency issue like sequencer check failures, transaction aborts,
270
- # etc.
271
- #
272
- # See litmus test above for deciding between FailedPrecondition,
273
- # Aborted, and Unavailable.
274
- class AbortedError < Error
275
- end
276
-
277
- ##
278
- # OutOfRange means operation was attempted past the valid range.
279
- # E.g., seeking or reading past end of file.
280
- #
281
- # Unlike InvalidArgument, this error indicates a problem that may
282
- # be fixed if the system state changes. For example, a 32-bit file
283
- # system will generate InvalidArgument if asked to read at an
284
- # offset that is not in the range [0,2^32-1], but it will generate
285
- # OutOfRange if asked to read from an offset past the current
286
- # file size.
287
- #
288
- # There is a fair bit of overlap between FailedPrecondition and
289
- # OutOfRange. We recommend using OutOfRange (the more specific
290
- # error) when it applies so that callers who are iterating through
291
- # a space can easily look for an OutOfRange error to detect when
292
- # they are done.
293
- class OutOfRangeError < Error
294
- end
295
-
296
- ##
297
- # Unimplemented indicates operation is not implemented or not
298
- # supported/enabled in this service.
299
- class UnimplementedError < Error
300
- end
301
-
302
- ##
303
- # Internal errors. Means some invariants expected by underlying
304
- # system has been broken. If you see one of these errors,
305
- # something is very broken.
306
- class InternalError < Error
307
- end
308
-
309
- ##
310
- # Unavailable indicates the service is currently unavailable.
311
- # This is a most likely a transient condition and may be corrected
312
- # by retrying with a backoff.
313
- #
314
- # See litmus test above for deciding between FailedPrecondition,
315
- # Aborted, and Unavailable.
316
- class UnavailableError < Error
317
- end
318
-
319
- ##
320
- # DataLoss indicates unrecoverable data loss or corruption.
321
- class DataLossError < Error
322
- end
323
- end
324
- end