gcloud 0.6.3 → 0.7.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 +8 -8
- data/AUTHENTICATION.md +13 -9
- data/CHANGELOG.md +8 -3
- data/OVERVIEW.md +46 -8
- data/lib/gcloud.rb +123 -117
- data/lib/gcloud/backoff.rb +43 -15
- data/lib/gcloud/bigquery.rb +211 -195
- data/lib/gcloud/bigquery/connection.rb +9 -9
- data/lib/gcloud/bigquery/copy_job.rb +15 -16
- data/lib/gcloud/bigquery/credentials.rb +3 -3
- data/lib/gcloud/bigquery/data.rb +12 -11
- data/lib/gcloud/bigquery/dataset.rb +162 -216
- data/lib/gcloud/bigquery/dataset/access.rb +59 -43
- data/lib/gcloud/bigquery/dataset/list.rb +3 -3
- data/lib/gcloud/bigquery/errors.rb +9 -5
- data/lib/gcloud/bigquery/extract_job.rb +18 -18
- data/lib/gcloud/bigquery/insert_response.rb +7 -4
- data/lib/gcloud/bigquery/job.rb +48 -44
- data/lib/gcloud/bigquery/job/list.rb +3 -3
- data/lib/gcloud/bigquery/load_job.rb +24 -25
- data/lib/gcloud/bigquery/project.rb +145 -204
- data/lib/gcloud/bigquery/query_data.rb +10 -9
- data/lib/gcloud/bigquery/query_job.rb +23 -32
- data/lib/gcloud/bigquery/table.rb +238 -280
- data/lib/gcloud/bigquery/table/list.rb +3 -3
- data/lib/gcloud/bigquery/table/schema.rb +79 -87
- data/lib/gcloud/bigquery/view.rb +69 -82
- data/lib/gcloud/credentials.rb +3 -9
- data/lib/gcloud/datastore.rb +194 -170
- data/lib/gcloud/datastore/connection.rb +12 -8
- data/lib/gcloud/datastore/credentials.rb +6 -4
- data/lib/gcloud/datastore/dataset.rb +74 -141
- data/lib/gcloud/datastore/dataset/lookup_results.rb +6 -4
- data/lib/gcloud/datastore/dataset/query_results.rb +6 -4
- data/lib/gcloud/datastore/entity.rb +81 -76
- data/lib/gcloud/datastore/errors.rb +10 -8
- data/lib/gcloud/datastore/key.rb +41 -77
- data/lib/gcloud/datastore/properties.rb +3 -3
- data/lib/gcloud/datastore/proto.rb +7 -4
- data/lib/gcloud/datastore/query.rb +26 -3
- data/lib/gcloud/datastore/transaction.rb +12 -8
- data/lib/gcloud/dns.rb +180 -152
- data/lib/gcloud/dns/change.rb +16 -16
- data/lib/gcloud/dns/change/list.rb +3 -3
- data/lib/gcloud/dns/connection.rb +9 -10
- data/lib/gcloud/dns/credentials.rb +3 -3
- data/lib/gcloud/dns/errors.rb +9 -5
- data/lib/gcloud/dns/importer.rb +17 -23
- data/lib/gcloud/dns/project.rb +42 -64
- data/lib/gcloud/dns/record.rb +58 -46
- data/lib/gcloud/dns/record/list.rb +6 -7
- data/lib/gcloud/dns/zone.rb +198 -289
- data/lib/gcloud/dns/zone/list.rb +3 -3
- data/lib/gcloud/dns/zone/transaction.rb +56 -72
- data/lib/gcloud/errors.rb +174 -3
- data/lib/gcloud/gce.rb +3 -4
- data/lib/gcloud/grpc_utils.rb +76 -0
- data/lib/gcloud/logging.rb +308 -0
- data/lib/gcloud/logging/credentials.rb +29 -0
- data/lib/gcloud/logging/entry.rb +303 -0
- data/lib/gcloud/logging/entry/http_request.rb +141 -0
- data/lib/gcloud/logging/entry/list.rb +111 -0
- data/lib/gcloud/logging/entry/operation.rb +90 -0
- data/lib/gcloud/logging/logger.rb +307 -0
- data/lib/gcloud/logging/metric.rb +175 -0
- data/lib/gcloud/logging/metric/list.rb +98 -0
- data/lib/gcloud/logging/project.rb +650 -0
- data/lib/gcloud/logging/resource.rb +95 -0
- data/lib/gcloud/logging/resource_descriptor.rb +140 -0
- data/lib/gcloud/logging/resource_descriptor/list.rb +78 -0
- data/lib/gcloud/logging/service.rb +258 -0
- data/lib/gcloud/logging/sink.rb +233 -0
- data/lib/gcloud/logging/sink/list.rb +97 -0
- data/lib/gcloud/pubsub.rb +241 -199
- data/lib/gcloud/pubsub/credentials.rb +3 -3
- data/lib/gcloud/pubsub/message.rb +26 -20
- data/lib/gcloud/pubsub/project.rb +166 -233
- data/lib/gcloud/pubsub/received_message.rb +28 -38
- data/lib/gcloud/pubsub/service.rb +323 -0
- data/lib/gcloud/pubsub/subscription.rb +172 -242
- data/lib/gcloud/pubsub/subscription/list.rb +11 -9
- data/lib/gcloud/pubsub/topic.rb +152 -271
- data/lib/gcloud/pubsub/topic/batch.rb +66 -0
- data/lib/gcloud/pubsub/topic/list.rb +9 -7
- data/lib/gcloud/resource_manager.rb +158 -138
- data/lib/gcloud/resource_manager/connection.rb +6 -5
- data/lib/gcloud/resource_manager/credentials.rb +3 -3
- data/lib/gcloud/resource_manager/errors.rb +9 -5
- data/lib/gcloud/resource_manager/manager.rb +54 -86
- data/lib/gcloud/resource_manager/project.rb +69 -88
- data/lib/gcloud/resource_manager/project/list.rb +4 -5
- data/lib/gcloud/resource_manager/project/updater.rb +12 -14
- data/lib/gcloud/search.rb +158 -135
- data/lib/gcloud/search/api_client.rb +7 -7
- data/lib/gcloud/search/connection.rb +8 -8
- data/lib/gcloud/search/credentials.rb +3 -3
- data/lib/gcloud/search/document.rb +64 -87
- data/lib/gcloud/search/document/list.rb +5 -5
- data/lib/gcloud/search/errors.rb +9 -5
- data/lib/gcloud/search/field_value.rb +32 -38
- data/lib/gcloud/search/field_values.rb +50 -80
- data/lib/gcloud/search/fields.rb +44 -65
- data/lib/gcloud/search/index.rb +163 -204
- data/lib/gcloud/search/index/list.rb +5 -5
- data/lib/gcloud/search/project.rb +31 -47
- data/lib/gcloud/search/result.rb +27 -31
- data/lib/gcloud/search/result/list.rb +6 -6
- data/lib/gcloud/storage.rb +224 -190
- data/lib/gcloud/storage/bucket.rb +202 -227
- data/lib/gcloud/storage/bucket/acl.rb +83 -170
- data/lib/gcloud/storage/bucket/cors.rb +31 -34
- data/lib/gcloud/storage/bucket/list.rb +3 -3
- data/lib/gcloud/storage/connection.rb +11 -7
- data/lib/gcloud/storage/credentials.rb +3 -3
- data/lib/gcloud/storage/errors.rb +11 -8
- data/lib/gcloud/storage/file.rb +129 -171
- data/lib/gcloud/storage/file/acl.rb +51 -99
- data/lib/gcloud/storage/file/list.rb +3 -3
- data/lib/gcloud/storage/file/verifier.rb +3 -2
- data/lib/gcloud/storage/project.rb +111 -132
- data/lib/gcloud/upload.rb +4 -7
- data/lib/gcloud/version.rb +2 -4
- data/lib/google/api/annotations.rb +14 -0
- data/lib/google/api/http.rb +30 -0
- data/lib/google/api/label.rb +24 -0
- data/lib/google/api/monitored_resource.rb +25 -0
- data/lib/google/datastore/v1beta3/datastore.rb +115 -0
- data/lib/google/datastore/v1beta3/datastore_services.rb +33 -0
- data/lib/google/datastore/v1beta3/entity.rb +63 -0
- data/lib/google/datastore/v1beta3/query.rb +128 -0
- data/lib/google/devtools/cloudtrace/v1/trace.rb +78 -0
- data/lib/google/devtools/cloudtrace/v1/trace_services.rb +32 -0
- data/lib/google/example/library/v1/library.rb +91 -0
- data/lib/google/example/library/v1/library_services.rb +40 -0
- data/lib/google/iam/v1/iam_policy.rb +33 -0
- data/lib/google/iam/v1/iam_policy_services.rb +30 -0
- data/lib/google/iam/v1/policy.rb +25 -0
- data/lib/google/logging/type/http_request.rb +28 -0
- data/lib/google/logging/type/log_severity.rb +27 -0
- data/lib/google/logging/v2/log_entry.rb +44 -0
- data/lib/google/logging/v2/logging.rb +56 -0
- data/lib/google/logging/v2/logging_config.rb +59 -0
- data/lib/google/logging/v2/logging_config_services.rb +32 -0
- data/lib/google/logging/v2/logging_metrics.rb +51 -0
- data/lib/google/logging/v2/logging_metrics_services.rb +32 -0
- data/lib/google/logging/v2/logging_services.rb +31 -0
- data/lib/google/longrunning/operations.rb +50 -0
- data/lib/google/longrunning/operations_services.rb +29 -0
- data/lib/google/protobuf/any.rb +17 -0
- data/lib/google/protobuf/api.rb +31 -0
- data/lib/google/protobuf/descriptor.rb +0 -0
- data/lib/google/protobuf/duration.rb +17 -0
- data/lib/google/protobuf/empty.rb +15 -0
- data/lib/google/protobuf/field_mask.rb +16 -0
- data/lib/google/protobuf/source_context.rb +16 -0
- data/lib/google/protobuf/struct.rb +35 -0
- data/lib/google/protobuf/timestamp.rb +17 -0
- data/lib/google/protobuf/type.rb +79 -0
- data/lib/google/protobuf/wrappers.rb +48 -0
- data/lib/google/pubsub/v1/pubsub.rb +129 -0
- data/lib/google/pubsub/v1/pubsub_services.rb +56 -0
- data/lib/google/pubsub/v1beta2/pubsub.rb +126 -0
- data/lib/google/pubsub/v1beta2/pubsub_services.rb +56 -0
- data/lib/google/rpc/code.rb +32 -0
- data/lib/google/rpc/error_details.rb +61 -0
- data/lib/google/rpc/status.rb +19 -0
- data/lib/google/type/color.rb +20 -0
- data/lib/google/type/date.rb +18 -0
- data/lib/google/type/dayofweek.rb +23 -0
- data/lib/google/type/latlng.rb +17 -0
- data/lib/google/type/money.rb +18 -0
- data/lib/google/type/timeofday.rb +19 -0
- metadata +101 -4
- data/lib/gcloud/pubsub/connection.rb +0 -295
- data/lib/gcloud/pubsub/errors.rb +0 -93
data/lib/gcloud/dns/zone/list.rb
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
#--
|
|
2
1
|
# Copyright 2015 Google Inc. All rights reserved.
|
|
3
2
|
#
|
|
4
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -13,6 +12,7 @@
|
|
|
13
12
|
# See the License for the specific language governing permissions and
|
|
14
13
|
# limitations under the License.
|
|
15
14
|
|
|
15
|
+
|
|
16
16
|
require "delegate"
|
|
17
17
|
|
|
18
18
|
module Gcloud
|
|
@@ -52,8 +52,8 @@ module Gcloud
|
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
##
|
|
55
|
-
# New Zones::List from a response object.
|
|
56
|
-
def self.from_response resp, conn
|
|
55
|
+
# @private New Zones::List from a response object.
|
|
56
|
+
def self.from_response resp, conn
|
|
57
57
|
zones = new(Array(resp.data["managedZones"]).map do |gapi_object|
|
|
58
58
|
Zone.from_gapi gapi_object, conn
|
|
59
59
|
end)
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
#--
|
|
2
1
|
# Copyright 2015 Google Inc. All rights reserved.
|
|
3
2
|
#
|
|
4
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -13,16 +12,18 @@
|
|
|
13
12
|
# See the License for the specific language governing permissions and
|
|
14
13
|
# limitations under the License.
|
|
15
14
|
|
|
15
|
+
|
|
16
16
|
module Gcloud
|
|
17
17
|
module Dns
|
|
18
18
|
class Zone
|
|
19
19
|
##
|
|
20
|
-
#
|
|
20
|
+
# # DNS Zone Transaction
|
|
21
21
|
#
|
|
22
|
-
# This object is used by Zone#update when passed a block. These methods
|
|
22
|
+
# This object is used by {Zone#update} when passed a block. These methods
|
|
23
23
|
# are used to update the records that are sent to the Google Cloud DNS
|
|
24
24
|
# API.
|
|
25
25
|
#
|
|
26
|
+
# @example
|
|
26
27
|
# require "gcloud"
|
|
27
28
|
#
|
|
28
29
|
# gcloud = Gcloud.new
|
|
@@ -39,11 +40,12 @@ module Gcloud
|
|
|
39
40
|
# end
|
|
40
41
|
#
|
|
41
42
|
class Transaction
|
|
42
|
-
|
|
43
|
+
# @private
|
|
44
|
+
attr_reader :additions, :deletions
|
|
43
45
|
|
|
44
46
|
##
|
|
45
|
-
# Creates a new transaction.
|
|
46
|
-
def initialize zone
|
|
47
|
+
# @private Creates a new transaction.
|
|
48
|
+
def initialize zone
|
|
47
49
|
@zone = zone
|
|
48
50
|
@additions = []
|
|
49
51
|
@deletions = []
|
|
@@ -52,27 +54,21 @@ module Gcloud
|
|
|
52
54
|
##
|
|
53
55
|
# Adds a record to the Zone.
|
|
54
56
|
#
|
|
55
|
-
#
|
|
56
|
-
#
|
|
57
|
-
#
|
|
58
|
-
#
|
|
59
|
-
#
|
|
60
|
-
#
|
|
61
|
-
#
|
|
62
|
-
#
|
|
63
|
-
#
|
|
64
|
-
#
|
|
65
|
-
# (
|
|
66
|
-
#
|
|
67
|
-
#
|
|
68
|
-
#
|
|
69
|
-
#
|
|
70
|
-
# 3.6.1)}[http://tools.ietf.org/html/rfc1034#section-3.6.1]. For
|
|
71
|
-
# example: +192.0.2.1+ or +example.com.+. (+String+ or +Array+ of
|
|
72
|
-
# +String+)
|
|
73
|
-
#
|
|
74
|
-
# === Example
|
|
75
|
-
#
|
|
57
|
+
# @param [String] name The owner of the record. For example:
|
|
58
|
+
# `example.com.`.
|
|
59
|
+
# @param [String] type The identifier of a [supported record
|
|
60
|
+
# type](https://cloud.google.com/dns/what-is-cloud-dns).
|
|
61
|
+
# For example: `A`, `AAAA`, `CNAME`, `MX`, or `TXT`.
|
|
62
|
+
# @param [Integer] ttl The number of seconds that the record can be
|
|
63
|
+
# cached by resolvers.
|
|
64
|
+
# @param [String, Array<String>] data The resource record data, as
|
|
65
|
+
# determined by `type` and defined in
|
|
66
|
+
# [RFC 1035 (section 5)](http://tools.ietf.org/html/rfc1035#section-5)
|
|
67
|
+
# and [RFC 1034 (section
|
|
68
|
+
# 3.6.1)](http://tools.ietf.org/html/rfc1034#section-3.6.1). For
|
|
69
|
+
# example: `192.0.2.1` or `example.com.`.
|
|
70
|
+
#
|
|
71
|
+
# @example
|
|
76
72
|
# require "gcloud"
|
|
77
73
|
#
|
|
78
74
|
# gcloud = Gcloud.new
|
|
@@ -90,17 +86,13 @@ module Gcloud
|
|
|
90
86
|
# Removes records from the Zone. The records are looked up before they
|
|
91
87
|
# are removed.
|
|
92
88
|
#
|
|
93
|
-
#
|
|
94
|
-
#
|
|
95
|
-
#
|
|
96
|
-
#
|
|
97
|
-
#
|
|
98
|
-
# The identifier of a {supported record
|
|
99
|
-
# type}[https://cloud.google.com/dns/what-is-cloud-dns].
|
|
100
|
-
# For example: +A+, +AAAA+, +CNAME+, +MX+, or +TXT+. (+String+)
|
|
101
|
-
#
|
|
102
|
-
# === Example
|
|
89
|
+
# @param [String] name The owner of the record. For example:
|
|
90
|
+
# `example.com.`.
|
|
91
|
+
# @param [String] type The identifier of a [supported record
|
|
92
|
+
# type](https://cloud.google.com/dns/what-is-cloud-dns).
|
|
93
|
+
# For example: `A`, `AAAA`, `CNAME`, `MX`, or `TXT`.
|
|
103
94
|
#
|
|
95
|
+
# @example
|
|
104
96
|
# require "gcloud"
|
|
105
97
|
#
|
|
106
98
|
# gcloud = Gcloud.new
|
|
@@ -115,30 +107,24 @@ module Gcloud
|
|
|
115
107
|
end
|
|
116
108
|
|
|
117
109
|
##
|
|
118
|
-
# Replaces existing records on the Zone. Records matching the
|
|
119
|
-
#
|
|
120
|
-
#
|
|
121
|
-
#
|
|
122
|
-
#
|
|
123
|
-
#
|
|
124
|
-
#
|
|
125
|
-
#
|
|
126
|
-
#
|
|
127
|
-
#
|
|
128
|
-
#
|
|
129
|
-
#
|
|
130
|
-
#
|
|
131
|
-
# (
|
|
132
|
-
#
|
|
133
|
-
#
|
|
134
|
-
#
|
|
135
|
-
#
|
|
136
|
-
# 3.6.1)}[http://tools.ietf.org/html/rfc1034#section-3.6.1]. For
|
|
137
|
-
# example: +192.0.2.1+ or +example.com.+. (+String+ or +Array+ of
|
|
138
|
-
# +String+)
|
|
139
|
-
#
|
|
140
|
-
# === Example
|
|
141
|
-
#
|
|
110
|
+
# Replaces existing records on the Zone. Records matching the `name` and
|
|
111
|
+
# `type` are replaced.
|
|
112
|
+
#
|
|
113
|
+
# @param [String] name The owner of the record. For example:
|
|
114
|
+
# `example.com.`.
|
|
115
|
+
# @param [String] type The identifier of a [supported record
|
|
116
|
+
# type](https://cloud.google.com/dns/what-is-cloud-dns).
|
|
117
|
+
# For example: `A`, `AAAA`, `CNAME`, `MX`, or `TXT`.
|
|
118
|
+
# @param [Integer] ttl The number of seconds that the record can be
|
|
119
|
+
# cached by resolvers.
|
|
120
|
+
# @param [String, Array<String>] data The resource record data, as
|
|
121
|
+
# determined by `type` and defined in
|
|
122
|
+
# [RFC 1035 (section 5)](http://tools.ietf.org/html/rfc1035#section-5)
|
|
123
|
+
# and [RFC 1034 (section
|
|
124
|
+
# 3.6.1)](http://tools.ietf.org/html/rfc1034#section-3.6.1). For
|
|
125
|
+
# example: `192.0.2.1` or `example.com.`.
|
|
126
|
+
#
|
|
127
|
+
# @example
|
|
142
128
|
# require "gcloud"
|
|
143
129
|
#
|
|
144
130
|
# gcloud = Gcloud.new
|
|
@@ -155,20 +141,18 @@ module Gcloud
|
|
|
155
141
|
end
|
|
156
142
|
|
|
157
143
|
##
|
|
158
|
-
# Modifies records on the Zone. Records matching the
|
|
144
|
+
# Modifies records on the Zone. Records matching the `name` and `type`
|
|
159
145
|
# are yielded to the block where they can be modified.
|
|
160
146
|
#
|
|
161
|
-
#
|
|
162
|
-
#
|
|
163
|
-
#
|
|
164
|
-
#
|
|
165
|
-
#
|
|
166
|
-
#
|
|
167
|
-
#
|
|
168
|
-
# For example: +A+, +AAAA+, +CNAME+, +MX+, or +TXT+. (+String+)
|
|
169
|
-
#
|
|
170
|
-
# === Example
|
|
147
|
+
# @param [String] name The owner of the record. For example:
|
|
148
|
+
# `example.com.`.
|
|
149
|
+
# @param [String] type The identifier of a [supported record
|
|
150
|
+
# type](https://cloud.google.com/dns/what-is-cloud-dns).
|
|
151
|
+
# For example: `A`, `AAAA`, `CNAME`, `MX`, or `TXT`.
|
|
152
|
+
# @yield [record] a block yielding each matching record
|
|
153
|
+
# @yieldparam [Record] record the record to be modified
|
|
171
154
|
#
|
|
155
|
+
# @example
|
|
172
156
|
# require "gcloud"
|
|
173
157
|
#
|
|
174
158
|
# gcloud = Gcloud.new
|
data/lib/gcloud/errors.rb
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
#--
|
|
2
1
|
# Copyright 2015 Google Inc. All rights reserved.
|
|
3
2
|
#
|
|
4
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -13,11 +12,183 @@
|
|
|
13
12
|
# See the License for the specific language governing permissions and
|
|
14
13
|
# limitations under the License.
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
# Google Cloud Errors
|
|
15
|
+
|
|
18
16
|
module Gcloud
|
|
19
17
|
##
|
|
20
18
|
# Base Gcloud exception class.
|
|
21
19
|
class Error < StandardError
|
|
20
|
+
##
|
|
21
|
+
# The inner error object.
|
|
22
|
+
attr_reader :inner
|
|
23
|
+
|
|
24
|
+
##
|
|
25
|
+
# Create a new error object.
|
|
26
|
+
def initialize message = nil, error = nil
|
|
27
|
+
super message
|
|
28
|
+
@inner = error
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# @private Create a new error object.
|
|
32
|
+
def self.from_error error
|
|
33
|
+
klass_for(error).new error.message, error
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# @private Identify the subclass for an error
|
|
37
|
+
def self.klass_for error
|
|
38
|
+
return self.class unless error.is_a? GRPC::BadStatus
|
|
39
|
+
# The gRPC status code 0 is for a successful response.
|
|
40
|
+
# So there is no error subclass for a 0 status code, use current class.
|
|
41
|
+
[self.class, CanceledError, UnknownError, InvalidArgumentError,
|
|
42
|
+
DeadlineExceededError, NotFoundError, AlreadyExistsError,
|
|
43
|
+
PermissionDeniedError, ResourceExhaustedError, FailedPreconditionError,
|
|
44
|
+
AbortedError, OutOfRangeError, UnimplementedError, InternalError,
|
|
45
|
+
UnavailableError, DataLossError, UnauthenticatedError
|
|
46
|
+
][error.code] || self.class
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
##
|
|
51
|
+
# Canceled indicates the operation was cancelled (typically by the caller).
|
|
52
|
+
class CanceledError < Error
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
##
|
|
56
|
+
# Unknown error. An example of where this error may be returned is
|
|
57
|
+
# if a Status value received from another address space belongs to
|
|
58
|
+
# an error-space that is not known in this address space. Also
|
|
59
|
+
# errors raised by APIs that do not return enough error information
|
|
60
|
+
# may be converted to this error.
|
|
61
|
+
class UnknownError < Error
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
##
|
|
65
|
+
# InvalidArgument indicates client specified an invalid argument.
|
|
66
|
+
# Note that this differs from FailedPrecondition. It indicates arguments
|
|
67
|
+
# that are problematic regardless of the state of the system
|
|
68
|
+
# (e.g., a malformed file name).
|
|
69
|
+
class InvalidArgumentError < Error
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
##
|
|
73
|
+
# DeadlineExceeded means operation expired before completion.
|
|
74
|
+
# For operations that change the state of the system, this error may be
|
|
75
|
+
# returned even if the operation has completed successfully. For
|
|
76
|
+
# example, a successful response from a server could have been delayed
|
|
77
|
+
# long enough for the deadline to expire.
|
|
78
|
+
class DeadlineExceededError < Error
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
##
|
|
82
|
+
# NotFound means some requested entity (e.g., file or directory) was
|
|
83
|
+
# not found.
|
|
84
|
+
class NotFoundError < Error
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
##
|
|
88
|
+
# AlreadyExists means an attempt to create an entity failed because one
|
|
89
|
+
# already exists.
|
|
90
|
+
class AlreadyExistsError < Error
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
##
|
|
94
|
+
# PermissionDenied indicates the caller does not have permission to
|
|
95
|
+
# execute the specified operation. It must not be used for rejections
|
|
96
|
+
# caused by exhausting some resource (use ResourceExhausted
|
|
97
|
+
# instead for those errors). It must not be
|
|
98
|
+
# used if the caller cannot be identified (use Unauthenticated
|
|
99
|
+
# instead for those errors).
|
|
100
|
+
class PermissionDeniedError < Error
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
##
|
|
104
|
+
# Unauthenticated indicates the request does not have valid
|
|
105
|
+
# authentication credentials for the operation.
|
|
106
|
+
class UnauthenticatedError < Error
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
##
|
|
110
|
+
# ResourceExhausted indicates some resource has been exhausted, perhaps
|
|
111
|
+
# a per-user quota, or perhaps the entire file system is out of space.
|
|
112
|
+
class ResourceExhaustedError < Error
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
##
|
|
116
|
+
# FailedPrecondition indicates operation was rejected because the
|
|
117
|
+
# system is not in a state required for the operation's execution.
|
|
118
|
+
# For example, directory to be deleted may be non-empty, an rmdir
|
|
119
|
+
# operation is applied to a non-directory, etc.
|
|
120
|
+
#
|
|
121
|
+
# A litmus test that may help a service implementor in deciding
|
|
122
|
+
# between FailedPrecondition, Aborted, and Unavailable:
|
|
123
|
+
# (a) Use Unavailable if the client can retry just the failing call.
|
|
124
|
+
# (b) Use Aborted if the client should retry at a higher-level
|
|
125
|
+
# (e.g., restarting a read-modify-write sequence).
|
|
126
|
+
# (c) Use FailedPrecondition if the client should not retry until
|
|
127
|
+
# the system state has been explicitly fixed. E.g., if an "rmdir"
|
|
128
|
+
# fails because the directory is non-empty, FailedPrecondition
|
|
129
|
+
# should be returned since the client should not retry unless
|
|
130
|
+
# they have first fixed up the directory by deleting files from it.
|
|
131
|
+
# (d) Use FailedPrecondition if the client performs conditional
|
|
132
|
+
# REST Get/Update/Delete on a resource and the resource on the
|
|
133
|
+
# server does not match the condition. E.g., conflicting
|
|
134
|
+
# read-modify-write on the same resource.
|
|
135
|
+
class FailedPreconditionError < Error
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
##
|
|
139
|
+
# Aborted indicates the operation was aborted, typically due to a
|
|
140
|
+
# concurrency issue like sequencer check failures, transaction aborts,
|
|
141
|
+
# etc.
|
|
142
|
+
#
|
|
143
|
+
# See litmus test above for deciding between FailedPrecondition,
|
|
144
|
+
# Aborted, and Unavailable.
|
|
145
|
+
class AbortedError < Error
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
##
|
|
149
|
+
# OutOfRange means operation was attempted past the valid range.
|
|
150
|
+
# E.g., seeking or reading past end of file.
|
|
151
|
+
#
|
|
152
|
+
# Unlike InvalidArgument, this error indicates a problem that may
|
|
153
|
+
# be fixed if the system state changes. For example, a 32-bit file
|
|
154
|
+
# system will generate InvalidArgument if asked to read at an
|
|
155
|
+
# offset that is not in the range [0,2^32-1], but it will generate
|
|
156
|
+
# OutOfRange if asked to read from an offset past the current
|
|
157
|
+
# file size.
|
|
158
|
+
#
|
|
159
|
+
# There is a fair bit of overlap between FailedPrecondition and
|
|
160
|
+
# OutOfRange. We recommend using OutOfRange (the more specific
|
|
161
|
+
# error) when it applies so that callers who are iterating through
|
|
162
|
+
# a space can easily look for an OutOfRange error to detect when
|
|
163
|
+
# they are done.
|
|
164
|
+
class OutOfRangeError < Error
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
##
|
|
168
|
+
# Unimplemented indicates operation is not implemented or not
|
|
169
|
+
# supported/enabled in this service.
|
|
170
|
+
class UnimplementedError < Error
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
##
|
|
174
|
+
# Internal errors. Means some invariants expected by underlying
|
|
175
|
+
# system has been broken. If you see one of these errors,
|
|
176
|
+
# something is very broken.
|
|
177
|
+
class InternalError < Error
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
##
|
|
181
|
+
# Unavailable indicates the service is currently unavailable.
|
|
182
|
+
# This is a most likely a transient condition and may be corrected
|
|
183
|
+
# by retrying with a backoff.
|
|
184
|
+
#
|
|
185
|
+
# See litmus test above for deciding between FailedPrecondition,
|
|
186
|
+
# Aborted, and Unavailable.
|
|
187
|
+
class UnavailableError < Error
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
##
|
|
191
|
+
# DataLoss indicates unrecoverable data loss or corruption.
|
|
192
|
+
class DataLossError < Error
|
|
22
193
|
end
|
|
23
194
|
end
|
data/lib/gcloud/gce.rb
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
#--
|
|
2
1
|
# Copyright 2015 Google Inc. All rights reserved.
|
|
3
2
|
#
|
|
4
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -13,14 +12,14 @@
|
|
|
13
12
|
# See the License for the specific language governing permissions and
|
|
14
13
|
# limitations under the License.
|
|
15
14
|
|
|
15
|
+
|
|
16
16
|
require "faraday"
|
|
17
17
|
|
|
18
|
-
#--
|
|
19
|
-
# Google Cloud Compute Engine
|
|
20
18
|
module Gcloud
|
|
21
19
|
##
|
|
20
|
+
# @private
|
|
22
21
|
# Represents the Google Compute Engine environment.
|
|
23
|
-
module GCE
|
|
22
|
+
module GCE
|
|
24
23
|
CHECK_URI = "http://169.254.169.254"
|
|
25
24
|
PROJECT_URI = "#{CHECK_URI}/computeMetadata/v1/project/project-id"
|
|
26
25
|
|
|
@@ -0,0 +1,76 @@
|
|
|
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 "gcloud"
|
|
17
|
+
require "google/protobuf/struct"
|
|
18
|
+
|
|
19
|
+
module Gcloud
|
|
20
|
+
##
|
|
21
|
+
# @private Conversion to/from GRPC objects.
|
|
22
|
+
module GRPCUtils
|
|
23
|
+
##
|
|
24
|
+
# @private Convert a Hash to a Google::Protobuf::Struct.
|
|
25
|
+
def self.hash_to_struct hash
|
|
26
|
+
# TODO: ArgumentError if hash is not a Hash
|
|
27
|
+
Google::Protobuf::Struct.new fields:
|
|
28
|
+
Hash[hash.map { |k, v| [String(k), object_to_value(v)] }]
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
##
|
|
32
|
+
# @private Convert a Google::Protobuf::Struct to a Hash.
|
|
33
|
+
def self.struct_to_hash struct
|
|
34
|
+
# TODO: ArgumentError if struct is not a Google::Protobuf::Struct
|
|
35
|
+
Hash[struct.fields.map { |k, v| [k, value_to_object(v)] }]
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
##
|
|
39
|
+
# @private Convert a Google::Protobuf::Value to an Object.
|
|
40
|
+
def self.value_to_object value
|
|
41
|
+
# TODO: ArgumentError if struct is not a Google::Protobuf::Value
|
|
42
|
+
if value.null_value
|
|
43
|
+
nil
|
|
44
|
+
elsif value.number_value
|
|
45
|
+
value.number_value
|
|
46
|
+
elsif value.struct_value
|
|
47
|
+
struct_to_hash value.struct_value
|
|
48
|
+
elsif value.list_value
|
|
49
|
+
value.list_value.values.map { |v| value_to_object(v) }
|
|
50
|
+
elsif !value.bool_value.nil? # Make sure its a bool, not nil
|
|
51
|
+
value.bool_value
|
|
52
|
+
else
|
|
53
|
+
nil # just in case
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
##
|
|
58
|
+
# @private Convert an Object to a Google::Protobuf::Value.
|
|
59
|
+
def self.object_to_value obj
|
|
60
|
+
case obj
|
|
61
|
+
when String then Google::Protobuf::Value.new string_value: obj
|
|
62
|
+
when Array then Google::Protobuf::ListValue.new(values:
|
|
63
|
+
obj.map { |o| object_to_value(o) })
|
|
64
|
+
when Hash then Google::Protobuf::Value.new struct_value:
|
|
65
|
+
hash_to_struct(obj)
|
|
66
|
+
when Numeric then Google::Protobuf::Value.new number_value: obj
|
|
67
|
+
when TrueClass then Google::Protobuf::Value.new bool_value: true
|
|
68
|
+
when FalseClass then Google::Protobuf::Value.new bool_value: false
|
|
69
|
+
when NilClass then Google::Protobuf::Value.new null_value: :NULL_VALUE
|
|
70
|
+
else
|
|
71
|
+
# We could raise ArgumentError here, or we could convert to a string...
|
|
72
|
+
Google::Protobuf::Value.new string_value: obj.to_s
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|