google-cloud-core 1.0.0 → 1.1.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
- SHA1:
3
- metadata.gz: f3b3286a9a2e4ebe6bf7cfd228acba475b78dc40
4
- data.tar.gz: e8d02970e3a8ba6ef1c72a046c0e6c6065f8b75f
2
+ SHA256:
3
+ metadata.gz: e44ada22e203f330c8b70e746ce7b7fe79ff7a40587f993126f18438e18bebf1
4
+ data.tar.gz: a3eba190acf8259d8c9dd8c14ce8db08fa7f133a1c38c81958dac03cb74c3eeb
5
5
  SHA512:
6
- metadata.gz: 0e43a9d267eff76d96bbb39236ec953ac5d8fee64614bb2d5374f464c3d58d7faf2d94c3ee6b993525fe489532c9f1b3f68c27130e7a69705f8ac58fa0e39066
7
- data.tar.gz: 14cf2efe270c65f98e5f668b00abaf58aa54af634a031e654bd84c9b8eae75dbc1155699bce00daf11b2ab614a59567297cf34441aa8942366e41c0462b6f3ac
6
+ metadata.gz: e230827b88d66edb003623e9955e522f5695ffd7a5d7b095bf678ae886a049014917511bfc4d79a23dfa5d16a6b64f445c985a8e57dae0298354b243a9cf3e36
7
+ data.tar.gz: 4248b6744703cae1c167d6fcfc59c69a0ca99d155a17b5a7deef3137c197b7e625382d7935dab26383a64649ef692f713a933528e3a79f46406dfb94b2d6d2e4
@@ -39,10 +39,11 @@ module Google
39
39
  # For more information on connecting to Google Cloud see the [Authentication
40
40
  # Guide](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/guides/authentication).
41
41
  #
42
- # @param [String] project Project identifier for the Pub/Sub service you are
42
+ # @param [String] project_id Project identifier for the service you are
43
43
  # connecting to.
44
- # @param [String, Hash] keyfile Keyfile downloaded from Google Cloud. If
45
- # file path the file must be readable.
44
+ # @param [String, Hash, Google::Auth::Credentials] credentials The path to
45
+ # the keyfile as a String, the contents of the keyfile as a Hash, or a
46
+ # Google::Auth::Credentials object.
46
47
  # @param [Integer] retries Number of times to retry requests on server
47
48
  # error. The default value is `3`. Optional.
48
49
  # @param [Integer] timeout Default timeout to use in requests. Optional.
@@ -57,12 +58,12 @@ module Google
57
58
  # pubsub = gcloud.pubsub
58
59
  # storage = gcloud.storage
59
60
  #
60
- def self.new project = nil, keyfile = nil, retries: nil, timeout: nil
61
+ def self.new project_id = nil, credentials = nil, retries: nil, timeout: nil
61
62
  gcloud = Object.new
62
- gcloud.instance_variable_set "@project", project
63
- gcloud.instance_variable_set "@keyfile", keyfile
64
- gcloud.instance_variable_set "@retries", retries
65
- gcloud.instance_variable_set "@timeout", timeout
63
+ gcloud.instance_variable_set :@project, project_id
64
+ gcloud.instance_variable_set :@keyfile, credentials
65
+ gcloud.instance_variable_set :@retries, retries
66
+ gcloud.instance_variable_set :@timeout, timeout
66
67
  gcloud.extend Google::Cloud
67
68
  gcloud
68
69
  end
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Core
19
- VERSION = "1.0.0"
19
+ VERSION = "1.1.0"
20
20
  end
21
21
  end
22
22
  end
@@ -12,6 +12,10 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ # This file is now considered DEPRECATED.
16
+ # Libraries that depend on google-cloud-core ~> 1.1 should not use this file.
17
+ # Keep the implementation in place to remain compatible with so older gems.
18
+
15
19
 
16
20
  require "json"
17
21
  require "signet/oauth_2/client"
@@ -13,11 +13,123 @@
13
13
  # limitations under the License.
14
14
 
15
15
 
16
+ require "English"
17
+
16
18
  module Google
17
19
  module Cloud
18
20
  ##
19
21
  # Base google-cloud exception class.
20
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
+ # @returns [Object, nil]
50
+ def status_code
51
+ return nil unless cause && 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
+ # @returns [Object, nil]
63
+ def body
64
+ return nil unless cause && 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
+ # @returns [Object, nil]
76
+ def header
77
+ return nil unless cause && 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
+ # @returns [Object, nil]
89
+ def code
90
+ return nil unless cause && 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
+ # @returns [Object, nil]
102
+ def details
103
+ return nil unless cause && 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
+ # @returns [Object, nil]
115
+ def metadata
116
+ return nil unless cause && 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
+ # @returns [Object, nil]
128
+ def status_details
129
+ return nil unless cause && cause.respond_to?(:status_details)
130
+ cause.status_details
131
+ end
132
+
21
133
  # @private Create a new error object from a client error
22
134
  def self.from_error error
23
135
  klass = if error.respond_to? :code
@@ -50,6 +162,7 @@ module Google
50
162
  403 => PermissionDeniedError,
51
163
  404 => NotFoundError,
52
164
  409 => AlreadyExistsError, # AbortedError
165
+ 412 => FailedPreconditionError,
53
166
  429 => ResourceExhaustedError,
54
167
  499 => CanceledError,
55
168
  500 => InternalError, # UnknownError/DataLossError
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.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Moore
@@ -9,22 +9,8 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-04-01 00:00:00.000000000 Z
12
+ date: 2017-11-14 00:00:00.000000000 Z
13
13
  dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: googleauth
16
- requirement: !ruby/object:Gem::Requirement
17
- requirements:
18
- - - "~>"
19
- - !ruby/object:Gem::Version
20
- version: 0.5.1
21
- type: :runtime
22
- prerelease: false
23
- version_requirements: !ruby/object:Gem::Requirement
24
- requirements:
25
- - - "~>"
26
- - !ruby/object:Gem::Version
27
- version: 0.5.1
28
14
  - !ruby/object:Gem::Dependency
29
15
  name: google-cloud-env
30
16
  requirement: !ruby/object:Gem::Requirement
@@ -180,7 +166,7 @@ files:
180
166
  - lib/google/cloud/core/version.rb
181
167
  - lib/google/cloud/credentials.rb
182
168
  - lib/google/cloud/errors.rb
183
- homepage: http://googlecloudplatform.github.io/google-cloud-ruby/
169
+ homepage: https://github.com/GoogleCloudPlatform/google-cloud-ruby/tree/master/google-cloud-core
184
170
  licenses:
185
171
  - Apache-2.0
186
172
  metadata: {}
@@ -200,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
200
186
  version: '0'
201
187
  requirements: []
202
188
  rubyforge_project:
203
- rubygems_version: 2.6.11
189
+ rubygems_version: 2.7.2
204
190
  signing_key:
205
191
  specification_version: 4
206
192
  summary: Internal shared library for google-cloud-ruby