gcloud 0.6.3 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -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,15 +12,19 @@
|
|
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 Bigquery
|
18
18
|
class Dataset
|
19
19
|
##
|
20
|
-
#
|
20
|
+
# # Dataset Access Control
|
21
|
+
#
|
22
|
+
# Represents the Access rules for a {Dataset}.
|
21
23
|
#
|
22
|
-
#
|
23
|
-
#
|
24
|
+
# @see https://cloud.google.com/bigquery/access-control BigQuery Access
|
25
|
+
# Control
|
24
26
|
#
|
27
|
+
# @example
|
25
28
|
# require "gcloud"
|
26
29
|
#
|
27
30
|
# gcloud = Gcloud.new
|
@@ -37,10 +40,12 @@ module Gcloud
|
|
37
40
|
# end
|
38
41
|
#
|
39
42
|
class Access
|
43
|
+
# @private
|
40
44
|
ROLES = { "reader" => "READER",
|
41
45
|
"writer" => "WRITER",
|
42
|
-
"owner" => "OWNER" }
|
46
|
+
"owner" => "OWNER" }
|
43
47
|
|
48
|
+
# @private
|
44
49
|
SCOPES = { "user" => "userByEmail",
|
45
50
|
"user_by_email" => "userByEmail",
|
46
51
|
"userByEmail" => "userByEmail",
|
@@ -51,8 +56,9 @@ module Gcloud
|
|
51
56
|
"special" => "specialGroup",
|
52
57
|
"special_group" => "specialGroup",
|
53
58
|
"specialGroup" => "specialGroup",
|
54
|
-
"view" => "view" }
|
59
|
+
"view" => "view" }
|
55
60
|
|
61
|
+
# @private
|
56
62
|
GROUPS = { "owners" => "projectOwners",
|
57
63
|
"project_owners" => "projectOwners",
|
58
64
|
"projectOwners" => "projectOwners",
|
@@ -66,18 +72,21 @@ module Gcloud
|
|
66
72
|
"all_authenticated_users" => "allAuthenticatedUsers",
|
67
73
|
"allAuthenticatedUsers" => "allAuthenticatedUsers" }
|
68
74
|
|
69
|
-
|
75
|
+
# @private
|
76
|
+
attr_reader :access
|
70
77
|
|
71
78
|
##
|
79
|
+
# @private
|
72
80
|
# Initialized a new Access object.
|
73
81
|
# Must provide a valid Dataset object.
|
74
|
-
def initialize access, context
|
82
|
+
def initialize access, context
|
75
83
|
@original = access.dup
|
76
84
|
@access = access.dup
|
77
85
|
@context = context
|
78
86
|
end
|
79
87
|
|
80
|
-
|
88
|
+
# @private
|
89
|
+
def changed?
|
81
90
|
@original != @access
|
82
91
|
end
|
83
92
|
|
@@ -101,7 +110,7 @@ module Gcloud
|
|
101
110
|
|
102
111
|
##
|
103
112
|
# Add reader access to a special group.
|
104
|
-
# Accepted values are
|
113
|
+
# Accepted values are `owners`, `writers`, `readers`, and `all`.
|
105
114
|
def add_reader_special group
|
106
115
|
add_access_role_scope_value :reader, :special, group
|
107
116
|
end
|
@@ -110,8 +119,8 @@ module Gcloud
|
|
110
119
|
# Add reader access to a view.
|
111
120
|
# The view can be a Gcloud::Bigquery::View object,
|
112
121
|
# or a string identifier as specified by the
|
113
|
-
#
|
114
|
-
# Reference
|
122
|
+
# [Query
|
123
|
+
# Reference](https://cloud.google.com/bigquery/query-reference#from):
|
115
124
|
# +project_name:datasetId.tableId+.
|
116
125
|
def add_reader_view view
|
117
126
|
add_access_role_scope_value :reader, :view, view
|
@@ -137,7 +146,7 @@ module Gcloud
|
|
137
146
|
|
138
147
|
##
|
139
148
|
# Add writer access to a special group.
|
140
|
-
# Accepted values are
|
149
|
+
# Accepted values are `owners`, `writers`, `readers`, and `all`.
|
141
150
|
def add_writer_special group
|
142
151
|
add_access_role_scope_value :writer, :special, group
|
143
152
|
end
|
@@ -146,8 +155,8 @@ module Gcloud
|
|
146
155
|
# Add writer access to a view.
|
147
156
|
# The view can be a Gcloud::Bigquery::View object,
|
148
157
|
# or a string identifier as specified by the
|
149
|
-
#
|
150
|
-
# Reference
|
158
|
+
# [Query
|
159
|
+
# Reference](https://cloud.google.com/bigquery/query-reference#from):
|
151
160
|
# +project_name:datasetId.tableId+.
|
152
161
|
def add_writer_view view
|
153
162
|
add_access_role_scope_value :writer, :view, view
|
@@ -173,7 +182,7 @@ module Gcloud
|
|
173
182
|
|
174
183
|
##
|
175
184
|
# Add owner access to a special group.
|
176
|
-
# Accepted values are
|
185
|
+
# Accepted values are `owners`, `writers`, `readers`, and `all`.
|
177
186
|
def add_owner_special group
|
178
187
|
add_access_role_scope_value :owner, :special, group
|
179
188
|
end
|
@@ -182,8 +191,8 @@ module Gcloud
|
|
182
191
|
# Add owner access to a view.
|
183
192
|
# The view can be a Gcloud::Bigquery::View object,
|
184
193
|
# or a string identifier as specified by the
|
185
|
-
#
|
186
|
-
# Reference
|
194
|
+
# [Query
|
195
|
+
# Reference](https://cloud.google.com/bigquery/query-reference#from):
|
187
196
|
# +project_name:datasetId.tableId+.
|
188
197
|
def add_owner_view view
|
189
198
|
add_access_role_scope_value :owner, :view, view
|
@@ -209,7 +218,7 @@ module Gcloud
|
|
209
218
|
|
210
219
|
##
|
211
220
|
# Remove reader access from a special group.
|
212
|
-
# Accepted values are
|
221
|
+
# Accepted values are `owners`, `writers`, `readers`, and `all`.
|
213
222
|
def remove_reader_special group
|
214
223
|
remove_access_role_scope_value :reader, :special, group
|
215
224
|
end
|
@@ -218,8 +227,8 @@ module Gcloud
|
|
218
227
|
# Remove reader access from a view.
|
219
228
|
# The view can be a Gcloud::Bigquery::View object,
|
220
229
|
# or a string identifier as specified by the
|
221
|
-
#
|
222
|
-
# Reference
|
230
|
+
# [Query
|
231
|
+
# Reference](https://cloud.google.com/bigquery/query-reference#from):
|
223
232
|
# +project_name:datasetId.tableId+.
|
224
233
|
def remove_reader_view view
|
225
234
|
remove_access_role_scope_value :reader, :view, view
|
@@ -245,7 +254,7 @@ module Gcloud
|
|
245
254
|
|
246
255
|
##
|
247
256
|
# Remove writer access from a special group.
|
248
|
-
# Accepted values are
|
257
|
+
# Accepted values are `owners`, `writers`, `readers`, and `all`.
|
249
258
|
def remove_writer_special group
|
250
259
|
remove_access_role_scope_value :writer, :special, group
|
251
260
|
end
|
@@ -254,8 +263,8 @@ module Gcloud
|
|
254
263
|
# Remove writer access from a view.
|
255
264
|
# The view can be a Gcloud::Bigquery::View object,
|
256
265
|
# or a string identifier as specified by the
|
257
|
-
#
|
258
|
-
# Reference
|
266
|
+
# [Query
|
267
|
+
# Reference](https://cloud.google.com/bigquery/query-reference#from):
|
259
268
|
# +project_name:datasetId.tableId+.
|
260
269
|
def remove_writer_view view
|
261
270
|
remove_access_role_scope_value :writer, :view, view
|
@@ -281,7 +290,7 @@ module Gcloud
|
|
281
290
|
|
282
291
|
##
|
283
292
|
# Remove owner access from a special group.
|
284
|
-
# Accepted values are
|
293
|
+
# Accepted values are `owners`, `writers`, `readers`, and `all`.
|
285
294
|
def remove_owner_special group
|
286
295
|
remove_access_role_scope_value :owner, :special, group
|
287
296
|
end
|
@@ -290,8 +299,8 @@ module Gcloud
|
|
290
299
|
# Remove owner access from a view.
|
291
300
|
# The view can be a Gcloud::Bigquery::View object,
|
292
301
|
# or a string identifier as specified by the
|
293
|
-
#
|
294
|
-
# Reference
|
302
|
+
# [Query
|
303
|
+
# Reference](https://cloud.google.com/bigquery/query-reference#from):
|
295
304
|
# +project_name:datasetId.tableId+.
|
296
305
|
def remove_owner_view view
|
297
306
|
remove_access_role_scope_value :owner, :view, view
|
@@ -317,7 +326,7 @@ module Gcloud
|
|
317
326
|
|
318
327
|
##
|
319
328
|
# Checks reader access for a special group.
|
320
|
-
# Accepted values are
|
329
|
+
# Accepted values are `owners`, `writers`, `readers`, and `all`.
|
321
330
|
def reader_special? group
|
322
331
|
lookup_access_role_scope_value :reader, :special, group
|
323
332
|
end
|
@@ -326,8 +335,8 @@ module Gcloud
|
|
326
335
|
# Checks reader access for a view.
|
327
336
|
# The view can be a Gcloud::Bigquery::View object,
|
328
337
|
# or a string identifier as specified by the
|
329
|
-
#
|
330
|
-
# Reference
|
338
|
+
# [Query
|
339
|
+
# Reference](https://cloud.google.com/bigquery/query-reference#from):
|
331
340
|
# +project_name:datasetId.tableId+.
|
332
341
|
def reader_view? view
|
333
342
|
lookup_access_role_scope_value :reader, :view, view
|
@@ -353,7 +362,7 @@ module Gcloud
|
|
353
362
|
|
354
363
|
##
|
355
364
|
# Checks writer access for a special group.
|
356
|
-
# Accepted values are
|
365
|
+
# Accepted values are `owners`, `writers`, `readers`, and `all`.
|
357
366
|
def writer_special? group
|
358
367
|
lookup_access_role_scope_value :writer, :special, group
|
359
368
|
end
|
@@ -362,8 +371,8 @@ module Gcloud
|
|
362
371
|
# Checks writer access for a view.
|
363
372
|
# The view can be a Gcloud::Bigquery::View object,
|
364
373
|
# or a string identifier as specified by the
|
365
|
-
#
|
366
|
-
# Reference
|
374
|
+
# [Query
|
375
|
+
# Reference](https://cloud.google.com/bigquery/query-reference#from):
|
367
376
|
# +project_name:datasetId.tableId+.
|
368
377
|
def writer_view? view
|
369
378
|
lookup_access_role_scope_value :writer, :view, view
|
@@ -389,7 +398,7 @@ module Gcloud
|
|
389
398
|
|
390
399
|
##
|
391
400
|
# Checks owner access for a special group.
|
392
|
-
# Accepted values are
|
401
|
+
# Accepted values are `owners`, `writers`, `readers`, and `all`.
|
393
402
|
def owner_special? group
|
394
403
|
lookup_access_role_scope_value :owner, :special, group
|
395
404
|
end
|
@@ -398,8 +407,8 @@ module Gcloud
|
|
398
407
|
# Checks owner access for a view.
|
399
408
|
# The view can be a Gcloud::Bigquery::View object,
|
400
409
|
# or a string identifier as specified by the
|
401
|
-
#
|
402
|
-
# Reference
|
410
|
+
# [Query
|
411
|
+
# Reference](https://cloud.google.com/bigquery/query-reference#from):
|
403
412
|
# +project_name:datasetId.tableId+.
|
404
413
|
def owner_view? view
|
405
414
|
lookup_access_role_scope_value :owner, :view, view
|
@@ -407,7 +416,8 @@ module Gcloud
|
|
407
416
|
|
408
417
|
protected
|
409
418
|
|
410
|
-
|
419
|
+
# @private
|
420
|
+
def validate_role role
|
411
421
|
good_role = ROLES[role.to_s]
|
412
422
|
if good_role.nil?
|
413
423
|
fail ArgumentError "Unable to determine role for #{role}"
|
@@ -415,7 +425,8 @@ module Gcloud
|
|
415
425
|
good_role
|
416
426
|
end
|
417
427
|
|
418
|
-
|
428
|
+
# @private
|
429
|
+
def validate_scope scope
|
419
430
|
good_scope = SCOPES[scope.to_s]
|
420
431
|
if good_scope.nil?
|
421
432
|
fail ArgumentError "Unable to determine scope for #{scope}"
|
@@ -423,13 +434,15 @@ module Gcloud
|
|
423
434
|
good_scope
|
424
435
|
end
|
425
436
|
|
426
|
-
|
437
|
+
# @private
|
438
|
+
def validate_special_group value
|
427
439
|
good_value = GROUPS[value.to_s]
|
428
440
|
return good_value unless good_value.nil?
|
429
441
|
value
|
430
442
|
end
|
431
443
|
|
432
|
-
|
444
|
+
# @private
|
445
|
+
def validate_view view
|
433
446
|
if view.respond_to? :table_ref
|
434
447
|
view.table_ref
|
435
448
|
else
|
@@ -437,7 +450,8 @@ module Gcloud
|
|
437
450
|
end
|
438
451
|
end
|
439
452
|
|
440
|
-
|
453
|
+
# @private
|
454
|
+
def add_access_role_scope_value role, scope, value
|
441
455
|
role = validate_role role
|
442
456
|
scope = validate_scope scope
|
443
457
|
# If scope is special group, make sure value is in the list
|
@@ -450,7 +464,8 @@ module Gcloud
|
|
450
464
|
access << { "role" => role, scope => value }
|
451
465
|
end
|
452
466
|
|
453
|
-
|
467
|
+
# @private
|
468
|
+
def remove_access_role_scope_value role, scope, value
|
454
469
|
role = validate_role role
|
455
470
|
scope = validate_scope scope
|
456
471
|
# If scope is special group, make sure value is in the list
|
@@ -461,7 +476,8 @@ module Gcloud
|
|
461
476
|
access.reject! { |h| h["role"] == role && h[scope] == value }
|
462
477
|
end
|
463
478
|
|
464
|
-
|
479
|
+
# @private
|
480
|
+
def lookup_access_role_scope_value role, scope, value
|
465
481
|
role = validate_role role
|
466
482
|
scope = validate_scope scope
|
467
483
|
# If scope is special group, make sure value is in the list
|
@@ -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
|
@@ -36,8 +36,8 @@ module Gcloud
|
|
36
36
|
end
|
37
37
|
|
38
38
|
##
|
39
|
-
# New Dataset::List from a response object.
|
40
|
-
def self.from_response resp, conn
|
39
|
+
# @private New Dataset::List from a response object.
|
40
|
+
def self.from_response resp, conn
|
41
41
|
datasets = List.new(Array(resp.data["datasets"]).map do |gapi_object|
|
42
42
|
Dataset.from_gapi gapi_object, conn
|
43
43
|
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,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 "gcloud/errors"
|
17
17
|
|
18
18
|
module Gcloud
|
@@ -33,13 +33,15 @@ module Gcloud
|
|
33
33
|
# The errors encountered.
|
34
34
|
attr_reader :errors
|
35
35
|
|
36
|
-
|
36
|
+
# @private
|
37
|
+
def initialize message, code, errors = []
|
37
38
|
super message
|
38
39
|
@code = code
|
39
40
|
@errors = errors
|
40
41
|
end
|
41
42
|
|
42
|
-
|
43
|
+
# @private
|
44
|
+
def self.from_response resp
|
43
45
|
if resp.data? && resp.data["error"]
|
44
46
|
from_response_data resp.data["error"]
|
45
47
|
else
|
@@ -47,11 +49,13 @@ module Gcloud
|
|
47
49
|
end
|
48
50
|
end
|
49
51
|
|
50
|
-
|
52
|
+
# @private
|
53
|
+
def self.from_response_data error
|
51
54
|
new error["message"], error["code"], error["errors"]
|
52
55
|
end
|
53
56
|
|
54
|
-
|
57
|
+
# @private
|
58
|
+
def self.from_response_status resp
|
55
59
|
if resp.status == 404
|
56
60
|
new "#{resp.error_message}: #{resp.request.uri.request_uri}",
|
57
61
|
resp.status
|
@@ -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,19 +12,20 @@
|
|
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 Bigquery
|
18
18
|
##
|
19
|
-
#
|
19
|
+
# # ExtractJob
|
20
20
|
#
|
21
|
-
# A Job subclass representing an export operation that may be performed
|
22
|
-
# on a Table. A ExtractJob instance is created when you call
|
21
|
+
# A {Job} subclass representing an export operation that may be performed
|
22
|
+
# on a {Table}. A ExtractJob instance is created when you call
|
23
|
+
# {Table#extract}.
|
23
24
|
#
|
24
|
-
#
|
25
|
-
# BigQuery
|
26
|
-
#
|
27
|
-
#
|
28
|
-
# for details.
|
25
|
+
# @see https://cloud.google.com/bigquery/exporting-data-from-bigquery
|
26
|
+
# Exporting Data From BigQuery
|
27
|
+
# @see https://cloud.google.com/bigquery/docs/reference/v2/jobs Jobs API
|
28
|
+
# reference
|
29
29
|
#
|
30
30
|
class ExtractJob < Job
|
31
31
|
##
|
@@ -37,7 +37,7 @@ module Gcloud
|
|
37
37
|
|
38
38
|
##
|
39
39
|
# The table from which the data is exported. This is the table upon
|
40
|
-
# which Table#extract was called. Returns a Table instance.
|
40
|
+
# which {Table#extract} was called. Returns a {Table} instance.
|
41
41
|
def source
|
42
42
|
table = config["extract"]["sourceTable"]
|
43
43
|
return nil unless table
|
@@ -48,15 +48,15 @@ module Gcloud
|
|
48
48
|
|
49
49
|
##
|
50
50
|
# Checks if the export operation compresses the data using gzip. The
|
51
|
-
# default is
|
51
|
+
# default is `false`.
|
52
52
|
def compression?
|
53
53
|
val = config["extract"]["compression"]
|
54
54
|
val == "GZIP"
|
55
55
|
end
|
56
56
|
|
57
57
|
##
|
58
|
-
# Checks if the destination format for the data is
|
59
|
-
# JSON
|
58
|
+
# Checks if the destination format for the data is [newline-delimited
|
59
|
+
# JSON](http://jsonlines.org/). The default is `false`.
|
60
60
|
def json?
|
61
61
|
val = config["extract"]["destinationFormat"]
|
62
62
|
val == "NEWLINE_DELIMITED_JSON"
|
@@ -64,7 +64,7 @@ module Gcloud
|
|
64
64
|
|
65
65
|
##
|
66
66
|
# Checks if the destination format for the data is CSV. Tables with nested
|
67
|
-
# or repeated fields cannot be exported as CSV. The default is
|
67
|
+
# or repeated fields cannot be exported as CSV. The default is `true`.
|
68
68
|
def csv?
|
69
69
|
val = config["extract"]["destinationFormat"]
|
70
70
|
return true if val.nil?
|
@@ -73,7 +73,7 @@ module Gcloud
|
|
73
73
|
|
74
74
|
##
|
75
75
|
# Checks if the destination format for the data is
|
76
|
-
#
|
76
|
+
# [Avro](http://avro.apache.org/). The default is `false`.
|
77
77
|
def avro?
|
78
78
|
val = config["extract"]["destinationFormat"]
|
79
79
|
val == "AVRO"
|
@@ -90,7 +90,7 @@ module Gcloud
|
|
90
90
|
|
91
91
|
##
|
92
92
|
# Checks if the exported data contains a header row. The default is
|
93
|
-
#
|
93
|
+
# `true`.
|
94
94
|
def print_header?
|
95
95
|
val = config["extract"]["printHeader"]
|
96
96
|
val = true if val.nil?
|
@@ -99,7 +99,7 @@ module Gcloud
|
|
99
99
|
|
100
100
|
##
|
101
101
|
# The count of files per destination URI or URI pattern specified in
|
102
|
-
# #destinations. Returns an Array of values in the same order as the URI
|
102
|
+
# {#destinations}. Returns an Array of values in the same order as the URI
|
103
103
|
# patterns.
|
104
104
|
def destinations_file_counts
|
105
105
|
Array stats["extract"]["destinationUriFileCounts"]
|
@@ -107,7 +107,7 @@ module Gcloud
|
|
107
107
|
|
108
108
|
##
|
109
109
|
# The count of files per destination URI or URI pattern specified in
|
110
|
-
# #destinations. Returns a Hash with the URI patterns as keys and the
|
110
|
+
# {#destinations}. Returns a Hash with the URI patterns as keys and the
|
111
111
|
# counts as values.
|
112
112
|
def destinations_counts
|
113
113
|
Hash[destinations.zip destinations_file_counts]
|