gcloud 0.12.2 → 0.20.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (169) hide show
  1. checksums.yaml +5 -13
  2. data/lib/gcloud.rb +27 -456
  3. data/lib/gcloud/bigquery.rb +2 -382
  4. data/lib/gcloud/datastore.rb +2 -576
  5. data/lib/gcloud/dns.rb +2 -321
  6. data/lib/gcloud/logging.rb +1 -322
  7. data/lib/gcloud/pubsub.rb +2 -476
  8. data/lib/gcloud/resource_manager.rb +2 -273
  9. data/lib/gcloud/storage.rb +2 -440
  10. data/lib/gcloud/translate.rb +1 -250
  11. data/lib/gcloud/version.rb +2 -2
  12. data/lib/gcloud/vision.rb +1 -501
  13. metadata +36 -332
  14. data/AUTHENTICATION.md +0 -75
  15. data/CHANGELOG.md +0 -382
  16. data/OVERVIEW.md +0 -259
  17. data/lib/gcloud/backoff.rb +0 -150
  18. data/lib/gcloud/bigquery/copy_job.rb +0 -97
  19. data/lib/gcloud/bigquery/credentials.rb +0 -29
  20. data/lib/gcloud/bigquery/data.rb +0 -239
  21. data/lib/gcloud/bigquery/dataset.rb +0 -753
  22. data/lib/gcloud/bigquery/dataset/access.rb +0 -507
  23. data/lib/gcloud/bigquery/dataset/list.rb +0 -169
  24. data/lib/gcloud/bigquery/extract_job.rb +0 -117
  25. data/lib/gcloud/bigquery/insert_response.rb +0 -81
  26. data/lib/gcloud/bigquery/job.rb +0 -299
  27. data/lib/gcloud/bigquery/job/list.rb +0 -172
  28. data/lib/gcloud/bigquery/load_job.rb +0 -202
  29. data/lib/gcloud/bigquery/project.rb +0 -475
  30. data/lib/gcloud/bigquery/query_data.rb +0 -234
  31. data/lib/gcloud/bigquery/query_job.rb +0 -137
  32. data/lib/gcloud/bigquery/schema.rb +0 -359
  33. data/lib/gcloud/bigquery/service.rb +0 -506
  34. data/lib/gcloud/bigquery/table.rb +0 -1141
  35. data/lib/gcloud/bigquery/table/list.rb +0 -180
  36. data/lib/gcloud/bigquery/view.rb +0 -475
  37. data/lib/gcloud/credentials.rb +0 -129
  38. data/lib/gcloud/datastore/commit.rb +0 -148
  39. data/lib/gcloud/datastore/credentials.rb +0 -35
  40. data/lib/gcloud/datastore/cursor.rb +0 -76
  41. data/lib/gcloud/datastore/dataset.rb +0 -660
  42. data/lib/gcloud/datastore/dataset/lookup_results.rb +0 -219
  43. data/lib/gcloud/datastore/dataset/query_results.rb +0 -386
  44. data/lib/gcloud/datastore/entity.rb +0 -449
  45. data/lib/gcloud/datastore/errors.rb +0 -41
  46. data/lib/gcloud/datastore/gql_query.rb +0 -211
  47. data/lib/gcloud/datastore/grpc_utils.rb +0 -132
  48. data/lib/gcloud/datastore/key.rb +0 -281
  49. data/lib/gcloud/datastore/properties.rb +0 -128
  50. data/lib/gcloud/datastore/query.rb +0 -348
  51. data/lib/gcloud/datastore/service.rb +0 -167
  52. data/lib/gcloud/datastore/transaction.rb +0 -362
  53. data/lib/gcloud/dns/change.rb +0 -158
  54. data/lib/gcloud/dns/change/list.rb +0 -173
  55. data/lib/gcloud/dns/credentials.rb +0 -29
  56. data/lib/gcloud/dns/importer.rb +0 -183
  57. data/lib/gcloud/dns/project.rb +0 -247
  58. data/lib/gcloud/dns/record.rb +0 -170
  59. data/lib/gcloud/dns/record/list.rb +0 -174
  60. data/lib/gcloud/dns/service.rb +0 -167
  61. data/lib/gcloud/dns/zone.rb +0 -759
  62. data/lib/gcloud/dns/zone/list.rb +0 -168
  63. data/lib/gcloud/dns/zone/transaction.rb +0 -176
  64. data/lib/gcloud/errors.rb +0 -206
  65. data/lib/gcloud/gce.rb +0 -56
  66. data/lib/gcloud/grpc_utils.rb +0 -87
  67. data/lib/gcloud/logging/credentials.rb +0 -29
  68. data/lib/gcloud/logging/entry.rb +0 -465
  69. data/lib/gcloud/logging/entry/http_request.rb +0 -141
  70. data/lib/gcloud/logging/entry/list.rb +0 -177
  71. data/lib/gcloud/logging/entry/operation.rb +0 -90
  72. data/lib/gcloud/logging/logger.rb +0 -307
  73. data/lib/gcloud/logging/metric.rb +0 -169
  74. data/lib/gcloud/logging/metric/list.rb +0 -172
  75. data/lib/gcloud/logging/project.rb +0 -642
  76. data/lib/gcloud/logging/resource.rb +0 -84
  77. data/lib/gcloud/logging/resource_descriptor.rb +0 -137
  78. data/lib/gcloud/logging/resource_descriptor/list.rb +0 -174
  79. data/lib/gcloud/logging/service.rb +0 -267
  80. data/lib/gcloud/logging/sink.rb +0 -227
  81. data/lib/gcloud/logging/sink/list.rb +0 -171
  82. data/lib/gcloud/pubsub/credentials.rb +0 -29
  83. data/lib/gcloud/pubsub/message.rb +0 -94
  84. data/lib/gcloud/pubsub/policy.rb +0 -204
  85. data/lib/gcloud/pubsub/project.rb +0 -482
  86. data/lib/gcloud/pubsub/received_message.rb +0 -160
  87. data/lib/gcloud/pubsub/service.rb +0 -334
  88. data/lib/gcloud/pubsub/subscription.rb +0 -565
  89. data/lib/gcloud/pubsub/subscription/list.rb +0 -208
  90. data/lib/gcloud/pubsub/topic.rb +0 -511
  91. data/lib/gcloud/pubsub/topic/list.rb +0 -174
  92. data/lib/gcloud/pubsub/topic/publisher.rb +0 -85
  93. data/lib/gcloud/resource_manager/credentials.rb +0 -30
  94. data/lib/gcloud/resource_manager/manager.rb +0 -266
  95. data/lib/gcloud/resource_manager/policy.rb +0 -211
  96. data/lib/gcloud/resource_manager/project.rb +0 -484
  97. data/lib/gcloud/resource_manager/project/list.rb +0 -167
  98. data/lib/gcloud/resource_manager/project/updater.rb +0 -130
  99. data/lib/gcloud/resource_manager/service.rb +0 -127
  100. data/lib/gcloud/storage/bucket.rb +0 -775
  101. data/lib/gcloud/storage/bucket/acl.rb +0 -810
  102. data/lib/gcloud/storage/bucket/cors.rb +0 -153
  103. data/lib/gcloud/storage/bucket/list.rb +0 -172
  104. data/lib/gcloud/storage/credentials.rb +0 -29
  105. data/lib/gcloud/storage/errors.rb +0 -65
  106. data/lib/gcloud/storage/file.rb +0 -842
  107. data/lib/gcloud/storage/file/acl.rb +0 -425
  108. data/lib/gcloud/storage/file/list.rb +0 -191
  109. data/lib/gcloud/storage/file/verifier.rb +0 -67
  110. data/lib/gcloud/storage/project.rb +0 -316
  111. data/lib/gcloud/storage/service.rb +0 -347
  112. data/lib/gcloud/translate/api.rb +0 -241
  113. data/lib/gcloud/translate/detection.rb +0 -137
  114. data/lib/gcloud/translate/language.rb +0 -69
  115. data/lib/gcloud/translate/service.rb +0 -80
  116. data/lib/gcloud/translate/translation.rb +0 -112
  117. data/lib/gcloud/vision/annotate.rb +0 -224
  118. data/lib/gcloud/vision/annotation.rb +0 -455
  119. data/lib/gcloud/vision/annotation/entity.rb +0 -234
  120. data/lib/gcloud/vision/annotation/face.rb +0 -1750
  121. data/lib/gcloud/vision/annotation/properties.rb +0 -245
  122. data/lib/gcloud/vision/annotation/safe_search.rb +0 -161
  123. data/lib/gcloud/vision/annotation/text.rb +0 -236
  124. data/lib/gcloud/vision/annotation/vertex.rb +0 -108
  125. data/lib/gcloud/vision/credentials.rb +0 -29
  126. data/lib/gcloud/vision/image.rb +0 -590
  127. data/lib/gcloud/vision/location.rb +0 -115
  128. data/lib/gcloud/vision/project.rb +0 -278
  129. data/lib/gcloud/vision/service.rb +0 -66
  130. data/lib/google/api/annotations.rb +0 -14
  131. data/lib/google/api/http.rb +0 -30
  132. data/lib/google/api/label.rb +0 -24
  133. data/lib/google/api/monitored_resource.rb +0 -25
  134. data/lib/google/datastore/v1beta3/datastore.rb +0 -115
  135. data/lib/google/datastore/v1beta3/datastore_services.rb +0 -33
  136. data/lib/google/datastore/v1beta3/entity.rb +0 -63
  137. data/lib/google/datastore/v1beta3/query.rb +0 -128
  138. data/lib/google/devtools/cloudtrace/v1/trace.rb +0 -78
  139. data/lib/google/devtools/cloudtrace/v1/trace_services.rb +0 -32
  140. data/lib/google/example/library/v1/library.rb +0 -91
  141. data/lib/google/example/library/v1/library_services.rb +0 -40
  142. data/lib/google/iam/v1/iam_policy.rb +0 -33
  143. data/lib/google/iam/v1/iam_policy_services.rb +0 -30
  144. data/lib/google/iam/v1/policy.rb +0 -25
  145. data/lib/google/logging/type/http_request.rb +0 -28
  146. data/lib/google/logging/type/log_severity.rb +0 -27
  147. data/lib/google/logging/v2/log_entry.rb +0 -44
  148. data/lib/google/logging/v2/logging.rb +0 -56
  149. data/lib/google/logging/v2/logging_config.rb +0 -59
  150. data/lib/google/logging/v2/logging_config_services.rb +0 -32
  151. data/lib/google/logging/v2/logging_metrics.rb +0 -51
  152. data/lib/google/logging/v2/logging_metrics_services.rb +0 -32
  153. data/lib/google/logging/v2/logging_services.rb +0 -31
  154. data/lib/google/longrunning/operations.rb +0 -50
  155. data/lib/google/longrunning/operations_services.rb +0 -29
  156. data/lib/google/protobuf/descriptor.rb +0 -0
  157. data/lib/google/pubsub/v1/pubsub.rb +0 -129
  158. data/lib/google/pubsub/v1/pubsub_services.rb +0 -56
  159. data/lib/google/pubsub/v1beta2/pubsub.rb +0 -126
  160. data/lib/google/pubsub/v1beta2/pubsub_services.rb +0 -56
  161. data/lib/google/rpc/code.rb +0 -32
  162. data/lib/google/rpc/error_details.rb +0 -61
  163. data/lib/google/rpc/status.rb +0 -19
  164. data/lib/google/type/color.rb +0 -20
  165. data/lib/google/type/date.rb +0 -18
  166. data/lib/google/type/dayofweek.rb +0 -23
  167. data/lib/google/type/latlng.rb +0 -17
  168. data/lib/google/type/money.rb +0 -18
  169. data/lib/google/type/timeofday.rb +0 -19
@@ -1,168 +0,0 @@
1
- # Copyright 2015 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 "delegate"
17
-
18
- module Gcloud
19
- module Dns
20
- class Zone
21
- ##
22
- # Zone::List is a special case Array with additional values.
23
- class List < DelegateClass(::Array)
24
- ##
25
- # If not empty, indicates that there are more zones that match
26
- # the request and this value should be passed to continue.
27
- attr_accessor :token
28
-
29
- ##
30
- # @private Create a new Zone::List with an array of Zone instances.
31
- def initialize arr = []
32
- super arr
33
- end
34
-
35
- ##
36
- # Whether there a next page of zones.
37
- #
38
- # @return [Boolean]
39
- #
40
- # @example
41
- # require "gcloud"
42
- #
43
- # gcloud = Gcloud.new
44
- # dns = gcloud.dns
45
- #
46
- # zones = dns.zones
47
- # if zones.next?
48
- # next_zones = zones.next
49
- # end
50
- #
51
- def next?
52
- !token.nil?
53
- end
54
-
55
- ##
56
- # Retrieve the next page of zones.
57
- #
58
- # @return [Zone::List]
59
- #
60
- # @example
61
- # require "gcloud"
62
- #
63
- # gcloud = Gcloud.new
64
- # dns = gcloud.dns
65
- #
66
- # zones = dns.zones
67
- # if zones.next?
68
- # next_zones = zones.next
69
- # end
70
- #
71
- def next
72
- return nil unless next?
73
- ensure_service!
74
- gapi = @service.list_zones token: token, max: @max
75
- Zone::List.from_gapi gapi, @service, @max
76
- end
77
-
78
- ##
79
- # Retrieves all zones by repeatedly loading {#next} until {#next?}
80
- # returns `false`. Calls the given block once for each zone, which is
81
- # passed as the parameter.
82
- #
83
- # An Enumerator is returned if no block is given.
84
- #
85
- # This method may make several API calls until all zones are retrieved.
86
- # Be sure to use as narrow a search criteria as possible. Please use
87
- # with caution.
88
- #
89
- # @param [Integer] request_limit The upper limit of API requests to make
90
- # to load all zones. Default is no limit.
91
- # @yield [zone] The block for accessing each zone.
92
- # @yieldparam [Zone] zone The zone object.
93
- #
94
- # @return [Enumerator]
95
- #
96
- # @example Iterating each zone by passing a block:
97
- # require "gcloud"
98
- #
99
- # gcloud = Gcloud.new
100
- # dns = gcloud.dns
101
- # zones = dns.zones
102
- #
103
- # zones.all do |zone|
104
- # puts zone.name
105
- # end
106
- #
107
- # @example Using the enumerator by not passing a block:
108
- # require "gcloud"
109
- #
110
- # gcloud = Gcloud.new
111
- # dns = gcloud.dns
112
- # zones = dns.zones
113
- #
114
- # all_names = zones.all.map do |zone|
115
- # zone.name
116
- # end
117
- #
118
- # @example Limit the number of API calls made:
119
- # require "gcloud"
120
- #
121
- # gcloud = Gcloud.new
122
- # dns = gcloud.dns
123
- # zones = dns.zones
124
- #
125
- # zones.all(request_limit: 10) do |zone|
126
- # puts zone.name
127
- # end
128
- #
129
- def all request_limit: nil
130
- request_limit = request_limit.to_i if request_limit
131
- unless block_given?
132
- return enum_for(:all, request_limit: request_limit)
133
- end
134
- results = self
135
- loop do
136
- results.each { |r| yield r }
137
- if request_limit
138
- request_limit -= 1
139
- break if request_limit < 0
140
- end
141
- break unless results.next?
142
- results = results.next
143
- end
144
- end
145
-
146
- ##
147
- # @private New Zones::List from a ListManagedZonesResponse object.
148
- def self.from_gapi gapi, conn, max = nil
149
- zones = new(Array(gapi.managed_zones).map do |g|
150
- Zone.from_gapi g, conn
151
- end)
152
- zones.instance_variable_set "@token", gapi.next_page_token
153
- zones.instance_variable_set "@service", conn
154
- zones.instance_variable_set "@max", max
155
- zones
156
- end
157
-
158
- protected
159
-
160
- ##
161
- # Raise an error unless an active connection is available.
162
- def ensure_service!
163
- fail "Must have active connection" unless @service
164
- end
165
- end
166
- end
167
- end
168
- end
@@ -1,176 +0,0 @@
1
- # Copyright 2015 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
- module Gcloud
17
- module Dns
18
- class Zone
19
- ##
20
- # # DNS Zone Transaction
21
- #
22
- # This object is used by {Zone#update} when passed a block. These methods
23
- # are used to update the records that are sent to the Google Cloud DNS
24
- # API.
25
- #
26
- # @example
27
- # require "gcloud"
28
- #
29
- # gcloud = Gcloud.new
30
- # dns = gcloud.dns
31
- # zone = dns.zone "example-com"
32
- # zone.update do |tx|
33
- # tx.add "example.com.", "A", 86400, "1.2.3.4"
34
- # tx.remove "example.com.", "TXT"
35
- # tx.replace "example.com.", "MX", 86400, ["10 mail1.example.com.",
36
- # "20 mail2.example.com."]
37
- # tx.modify "www.example.com.", "CNAME" do |cname|
38
- # cname.ttl = 86400 # only change the TTL
39
- # end
40
- # end
41
- #
42
- class Transaction
43
- # @private
44
- attr_reader :additions, :deletions
45
-
46
- ##
47
- # @private Creates a new transaction.
48
- def initialize zone
49
- @zone = zone
50
- @additions = []
51
- @deletions = []
52
- end
53
-
54
- ##
55
- # Adds a record to the Zone.
56
- #
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
72
- # require "gcloud"
73
- #
74
- # gcloud = Gcloud.new
75
- # dns = gcloud.dns
76
- # zone = dns.zone "example-com"
77
- # zone.update do |tx|
78
- # tx.add "example.com.", "A", 86400, "1.2.3.4"
79
- # end
80
- #
81
- def add name, type, ttl, data
82
- @additions += Array(@zone.record(name, type, ttl, data))
83
- end
84
-
85
- ##
86
- # Removes records from the Zone. The records are looked up before they
87
- # are removed.
88
- #
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`.
94
- #
95
- # @example
96
- # require "gcloud"
97
- #
98
- # gcloud = Gcloud.new
99
- # dns = gcloud.dns
100
- # zone = dns.zone "example-com"
101
- # zone.update do |tx|
102
- # tx.remove "example.com.", "TXT"
103
- # end
104
- #
105
- def remove name, type
106
- @deletions += @zone.records(name, type).all.to_a
107
- end
108
-
109
- ##
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
128
- # require "gcloud"
129
- #
130
- # gcloud = Gcloud.new
131
- # dns = gcloud.dns
132
- # zone = dns.zone "example-com"
133
- # zone.update do |tx|
134
- # tx.replace "example.com.", "MX", 86400, ["10 mail1.example.com.",
135
- # "20 mail2.example.com."]
136
- # end
137
- #
138
- def replace name, type, ttl, data
139
- remove name, type
140
- add name, type, ttl, data
141
- end
142
-
143
- ##
144
- # Modifies records on the Zone. Records matching the `name` and `type`
145
- # are yielded to the block where they can be modified.
146
- #
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
154
- #
155
- # @example
156
- # require "gcloud"
157
- #
158
- # gcloud = Gcloud.new
159
- # dns = gcloud.dns
160
- # zone.update do |tx|
161
- # tx.modify "www.example.com.", "CNAME" do |cname|
162
- # cname.ttl = 86400 # only change the TTL
163
- # end
164
- # end
165
- #
166
- def modify name, type
167
- existing = @zone.records(name, type).all.to_a
168
- updated = existing.map(&:dup)
169
- updated.each { |r| yield r }
170
- @additions += updated
171
- @deletions += existing
172
- end
173
- end
174
- end
175
- end
176
- end
data/lib/gcloud/errors.rb DELETED
@@ -1,206 +0,0 @@
1
- # Copyright 2015 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
- module Gcloud
17
- ##
18
- # Base gcloud-ruby exception class.
19
- class Error < StandardError
20
- # @private Create a new error object from a client error
21
- def self.from_error error
22
- klass = if error.respond_to? :code
23
- grpc_error_class_for error.code
24
- elsif error.respond_to? :status_code
25
- gapi_error_class_for error.status_code
26
- else
27
- self
28
- end
29
- klass.new error.message
30
- end
31
-
32
- # @private Identify the subclass for a gRPC error
33
- def self.grpc_error_class_for grpc_error_code
34
- # The gRPC status code 0 is for a successful response.
35
- # So there is no error subclass for a 0 status code, use current class.
36
- [self, CanceledError, UnknownError, InvalidArgumentError,
37
- DeadlineExceededError, NotFoundError, AlreadyExistsError,
38
- PermissionDeniedError, ResourceExhaustedError, FailedPreconditionError,
39
- AbortedError, OutOfRangeError, UnimplementedError, InternalError,
40
- UnavailableError, DataLossError, UnauthenticatedError
41
- ][grpc_error_code] || self
42
- end
43
-
44
- # @private Identify the subclass for a Google API Client error
45
- def self.gapi_error_class_for http_status_code
46
- # The http status codes mapped to their error classes.
47
- { 400 => InvalidArgumentError, # FailedPreconditionError/OutOfRangeError
48
- 401 => UnauthenticatedError,
49
- 403 => PermissionDeniedError,
50
- 404 => NotFoundError,
51
- 409 => AlreadyExistsError, # AbortedError
52
- 429 => ResourceExhaustedError,
53
- 499 => CanceledError,
54
- 500 => InternalError, # UnknownError/DataLossError
55
- 501 => UnimplementedError,
56
- 503 => UnavailableError,
57
- 504 => DeadlineExceededError
58
- }[http_status_code] || self
59
- end
60
- end
61
-
62
- ##
63
- # Canceled indicates the operation was cancelled (typically by the caller).
64
- class CanceledError < Error
65
- end
66
-
67
- ##
68
- # Unknown error. An example of where this error may be returned is
69
- # if a Status value received from another address space belongs to
70
- # an error-space that is not known in this address space. Also
71
- # errors raised by APIs that do not return enough error information
72
- # may be converted to this error.
73
- class UnknownError < Error
74
- end
75
-
76
- ##
77
- # InvalidArgument indicates client specified an invalid argument.
78
- # Note that this differs from FailedPrecondition. It indicates arguments
79
- # that are problematic regardless of the state of the system
80
- # (e.g., a malformed file name).
81
- class InvalidArgumentError < Error
82
- end
83
-
84
- ##
85
- # DeadlineExceeded means operation expired before completion.
86
- # For operations that change the state of the system, this error may be
87
- # returned even if the operation has completed successfully. For
88
- # example, a successful response from a server could have been delayed
89
- # long enough for the deadline to expire.
90
- class DeadlineExceededError < Error
91
- end
92
-
93
- ##
94
- # NotFound means some requested entity (e.g., file or directory) was
95
- # not found.
96
- class NotFoundError < Error
97
- end
98
-
99
- ##
100
- # AlreadyExists means an attempt to create an entity failed because one
101
- # already exists.
102
- class AlreadyExistsError < Error
103
- end
104
-
105
- ##
106
- # PermissionDenied indicates the caller does not have permission to
107
- # execute the specified operation. It must not be used for rejections
108
- # caused by exhausting some resource (use ResourceExhausted
109
- # instead for those errors). It must not be
110
- # used if the caller cannot be identified (use Unauthenticated
111
- # instead for those errors).
112
- class PermissionDeniedError < Error
113
- end
114
-
115
- ##
116
- # Unauthenticated indicates the request does not have valid
117
- # authentication credentials for the operation.
118
- class UnauthenticatedError < Error
119
- end
120
-
121
- ##
122
- # ResourceExhausted indicates some resource has been exhausted, perhaps
123
- # a per-user quota, or perhaps the entire file system is out of space.
124
- class ResourceExhaustedError < Error
125
- end
126
-
127
- ##
128
- # FailedPrecondition indicates operation was rejected because the
129
- # system is not in a state required for the operation's execution.
130
- # For example, directory to be deleted may be non-empty, an rmdir
131
- # operation is applied to a non-directory, etc.
132
- #
133
- # A litmus test that may help a service implementor in deciding
134
- # between FailedPrecondition, Aborted, and Unavailable:
135
- # (a) Use Unavailable if the client can retry just the failing call.
136
- # (b) Use Aborted if the client should retry at a higher-level
137
- # (e.g., restarting a read-modify-write sequence).
138
- # (c) Use FailedPrecondition if the client should not retry until
139
- # the system state has been explicitly fixed. E.g., if an "rmdir"
140
- # fails because the directory is non-empty, FailedPrecondition
141
- # should be returned since the client should not retry unless
142
- # they have first fixed up the directory by deleting files from it.
143
- # (d) Use FailedPrecondition if the client performs conditional
144
- # REST Get/Update/Delete on a resource and the resource on the
145
- # server does not match the condition. E.g., conflicting
146
- # read-modify-write on the same resource.
147
- class FailedPreconditionError < Error
148
- end
149
-
150
- ##
151
- # Aborted indicates the operation was aborted, typically due to a
152
- # concurrency issue like sequencer check failures, transaction aborts,
153
- # etc.
154
- #
155
- # See litmus test above for deciding between FailedPrecondition,
156
- # Aborted, and Unavailable.
157
- class AbortedError < Error
158
- end
159
-
160
- ##
161
- # OutOfRange means operation was attempted past the valid range.
162
- # E.g., seeking or reading past end of file.
163
- #
164
- # Unlike InvalidArgument, this error indicates a problem that may
165
- # be fixed if the system state changes. For example, a 32-bit file
166
- # system will generate InvalidArgument if asked to read at an
167
- # offset that is not in the range [0,2^32-1], but it will generate
168
- # OutOfRange if asked to read from an offset past the current
169
- # file size.
170
- #
171
- # There is a fair bit of overlap between FailedPrecondition and
172
- # OutOfRange. We recommend using OutOfRange (the more specific
173
- # error) when it applies so that callers who are iterating through
174
- # a space can easily look for an OutOfRange error to detect when
175
- # they are done.
176
- class OutOfRangeError < Error
177
- end
178
-
179
- ##
180
- # Unimplemented indicates operation is not implemented or not
181
- # supported/enabled in this service.
182
- class UnimplementedError < Error
183
- end
184
-
185
- ##
186
- # Internal errors. Means some invariants expected by underlying
187
- # system has been broken. If you see one of these errors,
188
- # something is very broken.
189
- class InternalError < Error
190
- end
191
-
192
- ##
193
- # Unavailable indicates the service is currently unavailable.
194
- # This is a most likely a transient condition and may be corrected
195
- # by retrying with a backoff.
196
- #
197
- # See litmus test above for deciding between FailedPrecondition,
198
- # Aborted, and Unavailable.
199
- class UnavailableError < Error
200
- end
201
-
202
- ##
203
- # DataLoss indicates unrecoverable data loss or corruption.
204
- class DataLossError < Error
205
- end
206
- end