google-cloud-spanner 0.22.0 → 0.23.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0d52caffdd789f039f91609da3f8dba633459c82
4
- data.tar.gz: ecc7cca28368c261123342f43e9b055f13c22d70
3
+ metadata.gz: 58a2867ec67cc68fb7e895762160e57037f00ca5
4
+ data.tar.gz: 12452e56b67a6c1aab33dc22c82367524ab9bf5b
5
5
  SHA512:
6
- metadata.gz: cfd38cc3172d32788a6891d78e44e349b8410c23285bcaa2bd79b582a58a48ce167f45251fec7ceff4df44b8f9fc6484f83d4feb7d744958ca6d8c99b1f2d457
7
- data.tar.gz: 41f84f6f1432833bc79ca731f8b99d29ea6edd70bc71ebdc6b34afe7a7b16f0b1709968d2d358aee5ba6df91f052cd6324a53590a6d7c5d8d73e544b42f5b9df
6
+ metadata.gz: 7aed04532cb3a027b83ee3f07ea5da86a0fa6915b384af19b716b670bd0ce0f09daa4e2a7c8fb14143f2ffda229d3f16bfd89f65e78711eacb5c5d6c0f99e2ba
7
+ data.tar.gz: 2ba0d3b5c978d323f4ceebcb7355d28ce013f120a209c8caae4733238fb0a1492b8615dbd573e96857fa3e01f0eee363647b49deab374431b74d49b52dbe550e
@@ -12,6 +12,7 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ require "google/cloud/spanner/status"
15
16
 
16
17
  module Google
17
18
  module Cloud
@@ -121,6 +122,30 @@ module Google
121
122
  @grpc.error?
122
123
  end
123
124
 
125
+ ##
126
+ # The status if the operation associated with this job produced an
127
+ # error.
128
+ #
129
+ # @return [Google::Cloud::Spanner::Status, nil] A status object with
130
+ # the status code and message, or `nil` if no error occurred.
131
+ #
132
+ # @example
133
+ # require "google/cloud/spanner"
134
+ #
135
+ # spanner = Google::Cloud::Spanner.new
136
+ #
137
+ # job = spanner.create_database "my-instance",
138
+ # "my-new-database"
139
+ #
140
+ # job.error? # true
141
+ #
142
+ # error = job.error
143
+ #
144
+ def error
145
+ return nil unless error?
146
+ Google::Cloud::Spanner::Status.from_grpc @grpc.error
147
+ end
148
+
124
149
  ##
125
150
  # Reloads the job with current data from the long-running,
126
151
  # asynchronous processing of a database operation.
@@ -12,6 +12,7 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ require "google/cloud/spanner/status"
15
16
 
16
17
  module Google
17
18
  module Cloud
@@ -133,6 +134,33 @@ module Google
133
134
  @grpc.error?
134
135
  end
135
136
 
137
+ ##
138
+ # The status if the operation associated with this job produced an
139
+ # error.
140
+ #
141
+ # @return [Google::Cloud::Spanner::Status, nil] A status object with
142
+ # the status code and message, or `nil` if no error occurred.
143
+ #
144
+ # @example
145
+ # require "google/cloud/spanner"
146
+ #
147
+ # spanner = Google::Cloud::Spanner.new
148
+ #
149
+ # job = spanner.create_instance "my-new-instance",
150
+ # name: "My New Instance",
151
+ # config: "regional-us-central1",
152
+ # nodes: 5,
153
+ # labels: { production: :env }
154
+ #
155
+ # job.error? # true
156
+ #
157
+ # error = job.error
158
+ #
159
+ def error
160
+ return nil unless error?
161
+ Google::Cloud::Spanner::Status.from_grpc @grpc.error
162
+ end
163
+
136
164
  ##
137
165
  # Reloads the job with current data from the long-running,
138
166
  # asynchronous processing of an instance operation.
@@ -0,0 +1,81 @@
1
+ # Copyright 2016 Google Inc. All rights reserved.
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
+ # http://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 "google/cloud/spanner/errors"
17
+
18
+ module Google
19
+ module Cloud
20
+ module Spanner
21
+ ##
22
+ # # Status
23
+ #
24
+ # Represents a logical error model from the Spanner service, containing an
25
+ # error code, an error message, and optional error details.
26
+ #
27
+ # @attr [Integer] code The status code, which should be an enum value of
28
+ # [google.rpc.Code](https://github.com/googleapis/googleapis/blob/master/google/rpc/code.proto).
29
+ # @attr [String] description The human-readable description for the status
30
+ # code, which should be an enum value of
31
+ # [google.rpc.Code](https://github.com/googleapis/googleapis/blob/master/google/rpc/code.proto).
32
+ # For example, `INVALID_ARGUMENT`.
33
+ # @attr [String] message A developer-facing error message, which should be
34
+ # in English.
35
+ # @attr [Array, nil] details A list of messages that carry the error
36
+ # details.
37
+ #
38
+ # @example
39
+ # require "google/cloud/spanner"
40
+ #
41
+ # spanner = Google::Cloud::Spanner.new
42
+ #
43
+ # job = spanner.create_database "my-instance",
44
+ # "my-new-database"
45
+ #
46
+ # job.error? # true
47
+ #
48
+ # status = job.error
49
+ #
50
+ class Status
51
+ attr_reader :code, :description, :message, :details
52
+
53
+ ##
54
+ # @private Creates a Status object.
55
+ def initialize code, description, message, details
56
+ @code = code
57
+ @description = description
58
+ @message = message
59
+ @details = details
60
+ end
61
+
62
+ ##
63
+ # @private New Status from a Google::Rpc::Status object.
64
+ def self.from_grpc grpc
65
+ new grpc.code, description_for(grpc.code), grpc.message, grpc.details
66
+ end
67
+
68
+ # @private Get a descriptive symbol for a google.rpc.Code integer
69
+ def self.description_for code
70
+ descriptions = %w(
71
+ OK CANCELLED UNKNOWN INVALID_ARGUMENT DEADLINE_EXCEEDED NOT_FOUND
72
+ ALREADY_EXISTS PERMISSION_DENIED RESOURCE_EXHAUSTED
73
+ FAILED_PRECONDITION ABORTED OUT_OF_RANGE UNIMPLEMENTED INTERNAL
74
+ UNAVAILABLE DATA_LOSS UNAUTHENTICATED
75
+ )
76
+ descriptions[code]
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Spanner
19
- VERSION = "0.22.0"
19
+ VERSION = "0.23.0"
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-spanner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.22.0
4
+ version: 0.23.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: 2017-07-11 00:00:00.000000000 Z
12
+ date: 2017-07-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: google-cloud-core
@@ -256,6 +256,7 @@ files:
256
256
  - lib/google/cloud/spanner/service.rb
257
257
  - lib/google/cloud/spanner/session.rb
258
258
  - lib/google/cloud/spanner/snapshot.rb
259
+ - lib/google/cloud/spanner/status.rb
259
260
  - lib/google/cloud/spanner/transaction.rb
260
261
  - lib/google/cloud/spanner/v1.rb
261
262
  - lib/google/cloud/spanner/v1/doc/google/protobuf/duration.rb