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
|
@@ -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,12 +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
|
module Gcloud
|
|
17
17
|
module Bigquery
|
|
18
18
|
##
|
|
19
19
|
# InsertResponse
|
|
20
20
|
class InsertResponse
|
|
21
|
-
|
|
21
|
+
# @private
|
|
22
|
+
def initialize rows, gapi
|
|
22
23
|
@rows = rows
|
|
23
24
|
@gapi = gapi
|
|
24
25
|
end
|
|
@@ -59,7 +60,8 @@ module Gcloud
|
|
|
59
60
|
[]
|
|
60
61
|
end
|
|
61
62
|
|
|
62
|
-
|
|
63
|
+
# @private
|
|
64
|
+
def self.from_gapi rows, gapi
|
|
63
65
|
gapi = gapi.to_hash if gapi.respond_to? :to_hash
|
|
64
66
|
new rows, gapi
|
|
65
67
|
end
|
|
@@ -70,7 +72,8 @@ module Gcloud
|
|
|
70
72
|
attr_reader :row
|
|
71
73
|
attr_reader :errors
|
|
72
74
|
|
|
73
|
-
|
|
75
|
+
# @private
|
|
76
|
+
def initialize row, errors
|
|
74
77
|
@row = row
|
|
75
78
|
@errors = errors
|
|
76
79
|
end
|
data/lib/gcloud/bigquery/job.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 "gcloud/bigquery/query_data"
|
|
17
17
|
require "gcloud/bigquery/job/list"
|
|
18
18
|
require "gcloud/bigquery/errors"
|
|
@@ -20,22 +20,23 @@ require "gcloud/bigquery/errors"
|
|
|
20
20
|
module Gcloud
|
|
21
21
|
module Bigquery
|
|
22
22
|
##
|
|
23
|
-
#
|
|
23
|
+
# # Job
|
|
24
24
|
#
|
|
25
|
-
# Represents a generic Job that may be performed on a Table.
|
|
25
|
+
# Represents a generic Job that may be performed on a {Table}.
|
|
26
26
|
#
|
|
27
|
-
#
|
|
28
|
-
# }
|
|
29
|
-
# for an overview of BigQuery jobs, and the {Jobs API
|
|
30
|
-
# reference}[https://cloud.google.com/bigquery/docs/reference/v2/jobs]
|
|
31
|
-
# for details.
|
|
27
|
+
# The subclasses of Job represent the specific BigQuery job types:
|
|
28
|
+
# {CopyJob}, {ExtractJob}, {LoadJob}, and {QueryJob}.
|
|
32
29
|
#
|
|
33
|
-
#
|
|
34
|
-
#
|
|
30
|
+
# A job instance is created when you call {Project#query_job},
|
|
31
|
+
# {Dataset#query_job}, {Table#copy}, {Table#extract}, {Table#load}, or
|
|
32
|
+
# {View#data}.
|
|
35
33
|
#
|
|
36
|
-
#
|
|
37
|
-
#
|
|
34
|
+
# @see https://cloud.google.com/bigquery/docs/managing_jobs_datasets_projects
|
|
35
|
+
# Managing Jobs, Datasets, and Projects
|
|
36
|
+
# @see https://cloud.google.com/bigquery/docs/reference/v2/jobs Jobs API
|
|
37
|
+
# reference
|
|
38
38
|
#
|
|
39
|
+
# @example
|
|
39
40
|
# require "gcloud"
|
|
40
41
|
#
|
|
41
42
|
# gcloud = Gcloud.new
|
|
@@ -54,16 +55,16 @@ module Gcloud
|
|
|
54
55
|
#
|
|
55
56
|
class Job
|
|
56
57
|
##
|
|
57
|
-
# The Connection object.
|
|
58
|
-
attr_accessor :connection
|
|
58
|
+
# @private The Connection object.
|
|
59
|
+
attr_accessor :connection
|
|
59
60
|
|
|
60
61
|
##
|
|
61
|
-
# The Google API Client object.
|
|
62
|
-
attr_accessor :gapi
|
|
62
|
+
# @private The Google API Client object.
|
|
63
|
+
attr_accessor :gapi
|
|
63
64
|
|
|
64
65
|
##
|
|
65
|
-
# Create an empty Job object.
|
|
66
|
-
def initialize
|
|
66
|
+
# @private Create an empty Job object.
|
|
67
|
+
def initialize
|
|
67
68
|
@connection = nil
|
|
68
69
|
@gapi = {}
|
|
69
70
|
end
|
|
@@ -81,9 +82,9 @@ module Gcloud
|
|
|
81
82
|
end
|
|
82
83
|
|
|
83
84
|
##
|
|
84
|
-
# The current state of the job. The possible values are
|
|
85
|
-
#
|
|
86
|
-
# completed successfully. Use #failed? to discover if an error occurred
|
|
85
|
+
# The current state of the job. The possible values are `PENDING`,
|
|
86
|
+
# `RUNNING`, and `DONE`. A `DONE` state does not mean that the job
|
|
87
|
+
# completed successfully. Use {#failed?} to discover if an error occurred
|
|
87
88
|
# or if the job was successful.
|
|
88
89
|
def state
|
|
89
90
|
return nil if @gapi["status"].nil?
|
|
@@ -91,23 +92,23 @@ module Gcloud
|
|
|
91
92
|
end
|
|
92
93
|
|
|
93
94
|
##
|
|
94
|
-
# Checks if the job's state is
|
|
95
|
+
# Checks if the job's state is `RUNNING`.
|
|
95
96
|
def running?
|
|
96
97
|
return false if state.nil?
|
|
97
98
|
"running".casecmp(state).zero?
|
|
98
99
|
end
|
|
99
100
|
|
|
100
101
|
##
|
|
101
|
-
# Checks if the job's state is
|
|
102
|
+
# Checks if the job's state is `PENDING`.
|
|
102
103
|
def pending?
|
|
103
104
|
return false if state.nil?
|
|
104
105
|
"pending".casecmp(state).zero?
|
|
105
106
|
end
|
|
106
107
|
|
|
107
108
|
##
|
|
108
|
-
# Checks if the job's state is
|
|
109
|
-
# running. However, a
|
|
110
|
-
# successfully. Use #failed? to detect if an error occurred or if the
|
|
109
|
+
# Checks if the job's state is `DONE`. When `true`, the job has stopped
|
|
110
|
+
# running. However, a `DONE` state does not mean that the job completed
|
|
111
|
+
# successfully. Use {#failed?} to detect if an error occurred or if the
|
|
111
112
|
# job was successful.
|
|
112
113
|
def done?
|
|
113
114
|
return false if state.nil?
|
|
@@ -130,8 +131,8 @@ module Gcloud
|
|
|
130
131
|
|
|
131
132
|
##
|
|
132
133
|
# The time when the job was started.
|
|
133
|
-
# This field is present after the job's state changes from
|
|
134
|
-
# to either
|
|
134
|
+
# This field is present after the job's state changes from `PENDING`
|
|
135
|
+
# to either `RUNNING` or `DONE`.
|
|
135
136
|
def started_at
|
|
136
137
|
return nil if @gapi["statistics"].nil?
|
|
137
138
|
return nil if @gapi["statistics"]["startTime"].nil?
|
|
@@ -140,7 +141,7 @@ module Gcloud
|
|
|
140
141
|
|
|
141
142
|
##
|
|
142
143
|
# The time when the job ended.
|
|
143
|
-
# This field is present when the job's state is
|
|
144
|
+
# This field is present when the job's state is `DONE`.
|
|
144
145
|
def ended_at
|
|
145
146
|
return nil if @gapi["statistics"].nil?
|
|
146
147
|
return nil if @gapi["statistics"]["endTime"].nil?
|
|
@@ -148,8 +149,10 @@ module Gcloud
|
|
|
148
149
|
end
|
|
149
150
|
|
|
150
151
|
##
|
|
151
|
-
# The configuration for the job. Returns a hash.
|
|
152
|
-
#
|
|
152
|
+
# The configuration for the job. Returns a hash.
|
|
153
|
+
#
|
|
154
|
+
# @see https://cloud.google.com/bigquery/docs/reference/v2/jobs Jobs API
|
|
155
|
+
# reference
|
|
153
156
|
def configuration
|
|
154
157
|
hash = @gapi["configuration"] || {}
|
|
155
158
|
hash = hash.to_hash if hash.respond_to? :to_hash
|
|
@@ -158,8 +161,10 @@ module Gcloud
|
|
|
158
161
|
alias_method :config, :configuration
|
|
159
162
|
|
|
160
163
|
##
|
|
161
|
-
# The statistics for the job. Returns a hash.
|
|
162
|
-
#
|
|
164
|
+
# The statistics for the job. Returns a hash.
|
|
165
|
+
#
|
|
166
|
+
# @see https://cloud.google.com/bigquery/docs/reference/v2/jobs Jobs API
|
|
167
|
+
# reference
|
|
163
168
|
def statistics
|
|
164
169
|
hash = @gapi["statistics"] || {}
|
|
165
170
|
hash = hash.to_hash if hash.respond_to? :to_hash
|
|
@@ -169,7 +174,7 @@ module Gcloud
|
|
|
169
174
|
|
|
170
175
|
##
|
|
171
176
|
# The job's status. Returns a hash. The values contained in the hash are
|
|
172
|
-
# also exposed by #state, #error, and #errors.
|
|
177
|
+
# also exposed by {#state}, {#error}, and {#errors}.
|
|
173
178
|
def status
|
|
174
179
|
hash = @gapi["status"] || {}
|
|
175
180
|
hash = hash.to_hash if hash.respond_to? :to_hash
|
|
@@ -178,12 +183,12 @@ module Gcloud
|
|
|
178
183
|
|
|
179
184
|
##
|
|
180
185
|
# The last error for the job, if any errors have occurred. Returns a
|
|
181
|
-
# hash.
|
|
182
|
-
# reference}[https://cloud.google.com/bigquery/docs/reference/v2/jobs].
|
|
186
|
+
# hash.
|
|
183
187
|
#
|
|
184
|
-
#
|
|
188
|
+
# @see https://cloud.google.com/bigquery/docs/reference/v2/jobs Jobs API
|
|
189
|
+
# reference
|
|
185
190
|
#
|
|
186
|
-
#
|
|
191
|
+
# @return [Hash] Returns a hash containing `reason` and `message` keys:
|
|
187
192
|
#
|
|
188
193
|
# {
|
|
189
194
|
# "reason"=>"notFound",
|
|
@@ -196,7 +201,7 @@ module Gcloud
|
|
|
196
201
|
|
|
197
202
|
##
|
|
198
203
|
# The errors for the job, if any errors have occurred. Returns an array
|
|
199
|
-
# of hash objects. See #error.
|
|
204
|
+
# of hash objects. See {#error}.
|
|
200
205
|
def errors
|
|
201
206
|
Array status["errors"]
|
|
202
207
|
end
|
|
@@ -227,11 +232,10 @@ module Gcloud
|
|
|
227
232
|
alias_method :refresh!, :reload!
|
|
228
233
|
|
|
229
234
|
##
|
|
230
|
-
# Refreshes the job until the job is
|
|
235
|
+
# Refreshes the job until the job is `DONE`.
|
|
231
236
|
# The delay between refreshes will incrementally increase.
|
|
232
237
|
#
|
|
233
|
-
#
|
|
234
|
-
#
|
|
238
|
+
# @example
|
|
235
239
|
# require "gcloud"
|
|
236
240
|
#
|
|
237
241
|
# gcloud = Gcloud.new
|
|
@@ -254,8 +258,8 @@ module Gcloud
|
|
|
254
258
|
end
|
|
255
259
|
|
|
256
260
|
##
|
|
257
|
-
# New Job from a Google API Client object.
|
|
258
|
-
def self.from_gapi gapi, conn
|
|
261
|
+
# @private New Job from a Google API Client object.
|
|
262
|
+
def self.from_gapi gapi, conn
|
|
259
263
|
klass = klass_for gapi
|
|
260
264
|
klass.new.tap do |f|
|
|
261
265
|
f.gapi = gapi
|
|
@@ -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
|
|
@@ -39,8 +39,8 @@ module Gcloud
|
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
##
|
|
42
|
-
# New Job::List from a response object.
|
|
43
|
-
def self.from_response resp, conn
|
|
42
|
+
# @private New Job::List from a response object.
|
|
43
|
+
def self.from_response resp, conn
|
|
44
44
|
jobs = List.new(Array(resp.data["jobs"]).map do |gapi_object|
|
|
45
45
|
Job.from_gapi gapi_object, conn
|
|
46
46
|
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,19 +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
|
##
|
|
19
|
-
#
|
|
19
|
+
# # LoadJob
|
|
20
20
|
#
|
|
21
|
-
# A Job subclass representing a load operation that may be performed
|
|
22
|
-
# on a Table. A LoadJob instance is created when you call Table#load.
|
|
21
|
+
# A {Job} subclass representing a load operation that may be performed
|
|
22
|
+
# on a {Table}. A LoadJob instance is created when you call {Table#load}.
|
|
23
23
|
#
|
|
24
|
-
#
|
|
25
|
-
# BigQuery
|
|
26
|
-
#
|
|
27
|
-
#
|
|
28
|
-
# for details.
|
|
24
|
+
# @see https://cloud.google.com/bigquery/loading-data-into-bigquery Loading
|
|
25
|
+
# Data Into BigQuery
|
|
26
|
+
# @see https://cloud.google.com/bigquery/docs/reference/v2/jobs Jobs API
|
|
27
|
+
# reference
|
|
29
28
|
#
|
|
30
29
|
class LoadJob < Job
|
|
31
30
|
##
|
|
@@ -37,7 +36,7 @@ module Gcloud
|
|
|
37
36
|
|
|
38
37
|
##
|
|
39
38
|
# The table into which the operation loads data. This is the table on
|
|
40
|
-
# which Table#load was invoked. Returns a Table instance.
|
|
39
|
+
# which {Table#load} was invoked. Returns a {Table} instance.
|
|
41
40
|
def destination
|
|
42
41
|
table = config["load"]["destinationTable"]
|
|
43
42
|
return nil unless table
|
|
@@ -55,7 +54,7 @@ module Gcloud
|
|
|
55
54
|
|
|
56
55
|
##
|
|
57
56
|
# The number of header rows at the top of a CSV file to skip. The default
|
|
58
|
-
# value is
|
|
57
|
+
# value is `0`.
|
|
59
58
|
def skip_leading_rows
|
|
60
59
|
config["load"]["skipLeadingRows"] || 0
|
|
61
60
|
end
|
|
@@ -78,10 +77,10 @@ module Gcloud
|
|
|
78
77
|
|
|
79
78
|
##
|
|
80
79
|
# The value that is used to quote data sections in a CSV file.
|
|
81
|
-
# The default value is a double-quote (
|
|
80
|
+
# The default value is a double-quote (`"`). If your data does not contain
|
|
82
81
|
# quoted sections, the value should be an empty string. If your data
|
|
83
|
-
# contains quoted newline characters, #quoted_newlines? should return
|
|
84
|
-
#
|
|
82
|
+
# contains quoted newline characters, {#quoted_newlines?} should return
|
|
83
|
+
# `true`.
|
|
85
84
|
def quote
|
|
86
85
|
val = config["load"]["quote"]
|
|
87
86
|
val = "\"" if val.nil?
|
|
@@ -91,7 +90,7 @@ module Gcloud
|
|
|
91
90
|
##
|
|
92
91
|
# The maximum number of bad records that the load operation can ignore. If
|
|
93
92
|
# the number of bad records exceeds this value, an error is
|
|
94
|
-
# returned. The default value is
|
|
93
|
+
# returned. The default value is `0`, which requires that all records be
|
|
95
94
|
# valid.
|
|
96
95
|
def max_bad_records
|
|
97
96
|
val = config["load"]["maxBadRecords"]
|
|
@@ -101,7 +100,7 @@ module Gcloud
|
|
|
101
100
|
|
|
102
101
|
##
|
|
103
102
|
# Checks if quoted data sections may contain newline characters in a CSV
|
|
104
|
-
# file. The default is
|
|
103
|
+
# file. The default is `false`.
|
|
105
104
|
def quoted_newlines?
|
|
106
105
|
val = config["load"]["allowQuotedNewlines"]
|
|
107
106
|
val = true if val.nil?
|
|
@@ -110,14 +109,14 @@ module Gcloud
|
|
|
110
109
|
|
|
111
110
|
##
|
|
112
111
|
# Checks if the format of the source data is
|
|
113
|
-
#
|
|
112
|
+
# [newline-delimited JSON](http://jsonlines.org/). The default is `false`.
|
|
114
113
|
def json?
|
|
115
114
|
val = config["load"]["sourceFormat"]
|
|
116
115
|
val == "NEWLINE_DELIMITED_JSON"
|
|
117
116
|
end
|
|
118
117
|
|
|
119
118
|
##
|
|
120
|
-
# Checks if the format of the source data is CSV. The default is
|
|
119
|
+
# Checks if the format of the source data is CSV. The default is `true`.
|
|
121
120
|
def csv?
|
|
122
121
|
val = config["load"]["sourceFormat"]
|
|
123
122
|
return true if val.nil?
|
|
@@ -133,10 +132,10 @@ module Gcloud
|
|
|
133
132
|
|
|
134
133
|
##
|
|
135
134
|
# Checks if the load operation accepts rows that are missing trailing
|
|
136
|
-
# optional columns. The missing values are treated as nulls. If
|
|
135
|
+
# optional columns. The missing values are treated as nulls. If `false`,
|
|
137
136
|
# records with missing trailing columns are treated as bad records, and
|
|
138
137
|
# if there are too many bad records, an error is returned. The default
|
|
139
|
-
# value is
|
|
138
|
+
# value is `false`. Only applicable to CSV, ignored for other formats.
|
|
140
139
|
def allow_jagged_rows?
|
|
141
140
|
val = config["load"]["allowJaggedRows"]
|
|
142
141
|
val = false if val.nil?
|
|
@@ -145,10 +144,10 @@ module Gcloud
|
|
|
145
144
|
|
|
146
145
|
##
|
|
147
146
|
# Checks if the load operation allows extra values that are not
|
|
148
|
-
# represented in the table schema. If
|
|
149
|
-
# ignored. If
|
|
147
|
+
# represented in the table schema. If `true`, the extra values are
|
|
148
|
+
# ignored. If `false`, records with extra columns are treated as bad
|
|
150
149
|
# records, and if there are too many bad records, an invalid error is
|
|
151
|
-
# returned. The default is
|
|
150
|
+
# returned. The default is `false`.
|
|
152
151
|
def ignore_unknown_values?
|
|
153
152
|
val = config["load"]["ignoreUnknownValues"]
|
|
154
153
|
val = false if val.nil?
|
|
@@ -157,8 +156,8 @@ module Gcloud
|
|
|
157
156
|
|
|
158
157
|
##
|
|
159
158
|
# The schema for the data. Returns a hash. Can be empty if the table
|
|
160
|
-
# has already has the correct schema (see Table#schema= and
|
|
161
|
-
# or if the schema can be inferred from the loaded data.
|
|
159
|
+
# has already has the correct schema (see {Table#schema=} and
|
|
160
|
+
# {Table#schema}), or if the schema can be inferred from the loaded data.
|
|
162
161
|
def schema
|
|
163
162
|
val = config["load"]["schema"]
|
|
164
163
|
val = {} if val.nil?
|
|
@@ -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/gce"
|
|
17
17
|
require "gcloud/bigquery/connection"
|
|
18
18
|
require "gcloud/bigquery/credentials"
|
|
@@ -24,16 +24,19 @@ require "gcloud/bigquery/query_data"
|
|
|
24
24
|
module Gcloud
|
|
25
25
|
module Bigquery
|
|
26
26
|
##
|
|
27
|
-
#
|
|
27
|
+
# # Project
|
|
28
28
|
#
|
|
29
29
|
# Projects are top-level containers in Google Cloud Platform. They store
|
|
30
30
|
# information about billing and authorized users, and they contain BigQuery
|
|
31
31
|
# data. Each project has a friendly name and a unique ID.
|
|
32
32
|
#
|
|
33
33
|
# Gcloud::Bigquery::Project is the main object for interacting with
|
|
34
|
-
# Google BigQuery. Gcloud::Bigquery::Dataset objects are created,
|
|
34
|
+
# Google BigQuery. {Gcloud::Bigquery::Dataset} objects are created,
|
|
35
35
|
# accessed, and deleted by Gcloud::Bigquery::Project.
|
|
36
36
|
#
|
|
37
|
+
# See {Gcloud#bigquery}
|
|
38
|
+
#
|
|
39
|
+
# @example
|
|
37
40
|
# require "gcloud"
|
|
38
41
|
#
|
|
39
42
|
# gcloud = Gcloud.new
|
|
@@ -41,16 +44,15 @@ module Gcloud
|
|
|
41
44
|
# dataset = bigquery.dataset "my_dataset"
|
|
42
45
|
# table = dataset.table "my_table"
|
|
43
46
|
#
|
|
44
|
-
# See Gcloud#bigquery
|
|
45
47
|
class Project
|
|
46
48
|
##
|
|
47
|
-
# The Connection object.
|
|
48
|
-
attr_accessor :connection
|
|
49
|
+
# @private The Connection object.
|
|
50
|
+
attr_accessor :connection
|
|
49
51
|
|
|
50
52
|
##
|
|
51
53
|
# Creates a new Connection instance.
|
|
52
54
|
#
|
|
53
|
-
# See Gcloud.bigquery
|
|
55
|
+
# See {Gcloud.bigquery}
|
|
54
56
|
def initialize project, credentials
|
|
55
57
|
project = project.to_s # Always cast to a string
|
|
56
58
|
fail ArgumentError, "project is missing" if project.empty?
|
|
@@ -60,8 +62,7 @@ module Gcloud
|
|
|
60
62
|
##
|
|
61
63
|
# The BigQuery project connected to.
|
|
62
64
|
#
|
|
63
|
-
#
|
|
64
|
-
#
|
|
65
|
+
# @example
|
|
65
66
|
# require "gcloud"
|
|
66
67
|
#
|
|
67
68
|
# gcloud = Gcloud.new "my-todo-project", "/path/to/keyfile.json"
|
|
@@ -74,8 +75,8 @@ module Gcloud
|
|
|
74
75
|
end
|
|
75
76
|
|
|
76
77
|
##
|
|
77
|
-
# Default project.
|
|
78
|
-
def self.default_project
|
|
78
|
+
# @private Default project.
|
|
79
|
+
def self.default_project
|
|
79
80
|
ENV["BIGQUERY_PROJECT"] ||
|
|
80
81
|
ENV["GCLOUD_PROJECT"] ||
|
|
81
82
|
ENV["GOOGLE_CLOUD_PROJECT"] ||
|
|
@@ -83,61 +84,53 @@ module Gcloud
|
|
|
83
84
|
end
|
|
84
85
|
|
|
85
86
|
##
|
|
86
|
-
# Queries data using the
|
|
87
|
-
# method
|
|
88
|
-
#
|
|
89
|
-
# === Parameters
|
|
87
|
+
# Queries data using the [asynchronous
|
|
88
|
+
# method](https://cloud.google.com/bigquery/querying-data).
|
|
90
89
|
#
|
|
91
|
-
#
|
|
92
|
-
#
|
|
93
|
-
# syntax}[https://cloud.google.com/bigquery/query-reference], of the
|
|
90
|
+
# @param [String] query A query string, following the BigQuery [query
|
|
91
|
+
# syntax](https://cloud.google.com/bigquery/query-reference), of the
|
|
94
92
|
# query to execute. Example: "SELECT count(f1) FROM
|
|
95
|
-
# [myProjectId:myDatasetId.myTableId]".
|
|
96
|
-
#
|
|
97
|
-
#
|
|
98
|
-
#
|
|
99
|
-
#
|
|
100
|
-
#
|
|
101
|
-
#
|
|
102
|
-
#
|
|
103
|
-
#
|
|
104
|
-
#
|
|
105
|
-
#
|
|
106
|
-
#
|
|
107
|
-
#
|
|
108
|
-
#
|
|
93
|
+
# [myProjectId:myDatasetId.myTableId]".
|
|
94
|
+
# @param [String] priority Specifies a priority for the query. Possible
|
|
95
|
+
# values include `INTERACTIVE` and `BATCH`. The default value is
|
|
96
|
+
# `INTERACTIVE`.
|
|
97
|
+
# @param [Boolean] cache Whether to look for the result in the query
|
|
98
|
+
# cache. The query cache is a best-effort cache that will be flushed
|
|
99
|
+
# whenever tables in the query are modified. The default value is true.
|
|
100
|
+
# For more information, see [query
|
|
101
|
+
# caching](https://developers.google.com/bigquery/querying-data).
|
|
102
|
+
# @param [Table] table The destination table where the query results
|
|
103
|
+
# should be stored. If not present, a new table will be created to store
|
|
104
|
+
# the results.
|
|
105
|
+
# @param [String] create Specifies whether the job is allowed to create
|
|
106
|
+
# new tables.
|
|
109
107
|
#
|
|
110
108
|
# The following values are supported:
|
|
111
|
-
#
|
|
112
|
-
# *
|
|
109
|
+
#
|
|
110
|
+
# * `needed` - Create the table if it does not exist.
|
|
111
|
+
# * `never` - The table must already exist. A 'notFound' error is
|
|
113
112
|
# raised if the table does not exist.
|
|
114
|
-
#
|
|
115
|
-
#
|
|
116
|
-
# exists. (+String+)
|
|
113
|
+
# @param [String] write Specifies the action that occurs if the
|
|
114
|
+
# destination table already exists.
|
|
117
115
|
#
|
|
118
116
|
# The following values are supported:
|
|
119
|
-
# * +truncate+ - BigQuery overwrites the table data.
|
|
120
|
-
# * +append+ - BigQuery appends the data to the table.
|
|
121
|
-
# * +empty+ - A 'duplicate' error is returned in the job result if the
|
|
122
|
-
# table exists and contains data.
|
|
123
|
-
# +large_results+::
|
|
124
|
-
# If +true+, allows the query to produce arbitrarily large result tables
|
|
125
|
-
# at a slight cost in performance. Requires +table+ parameter to be set.
|
|
126
|
-
# (+Boolean+)
|
|
127
|
-
# +flatten+::
|
|
128
|
-
# Flattens all nested and repeated fields in the query results. The
|
|
129
|
-
# default value is +true+. +large_results+ parameter must be +true+ if
|
|
130
|
-
# this is set to +false+. (+Boolean+)
|
|
131
|
-
# +dataset+::
|
|
132
|
-
# Specifies the default dataset to use for unqualified table names in
|
|
133
|
-
# the query. (+Dataset+ or +String+)
|
|
134
|
-
#
|
|
135
|
-
# === Returns
|
|
136
|
-
#
|
|
137
|
-
# Gcloud::Bigquery::QueryJob
|
|
138
|
-
#
|
|
139
|
-
# === Example
|
|
140
117
|
#
|
|
118
|
+
# * `truncate` - BigQuery overwrites the table data.
|
|
119
|
+
# * `append` - BigQuery appends the data to the table.
|
|
120
|
+
# * `empty` - A 'duplicate' error is returned in the job result if the
|
|
121
|
+
# table exists and contains data.
|
|
122
|
+
# @param [Boolean] large_results If `true`, allows the query to produce
|
|
123
|
+
# arbitrarily large result tables at a slight cost in performance.
|
|
124
|
+
# Requires `table` parameter to be set.
|
|
125
|
+
# @param [Boolean] flatten Flattens all nested and repeated fields in the
|
|
126
|
+
# query results. The default value is `true`. `large_results` parameter
|
|
127
|
+
# must be `true` if this is set to `false`.
|
|
128
|
+
# @param [Dataset, String] dataset Specifies the default dataset to use
|
|
129
|
+
# for unqualified table names in the query.
|
|
130
|
+
#
|
|
131
|
+
# @return [Gcloud::Bigquery::QueryJob]
|
|
132
|
+
#
|
|
133
|
+
# @example
|
|
141
134
|
# require "gcloud"
|
|
142
135
|
#
|
|
143
136
|
# gcloud = Gcloud.new
|
|
@@ -168,56 +161,45 @@ module Gcloud
|
|
|
168
161
|
end
|
|
169
162
|
|
|
170
163
|
##
|
|
171
|
-
# Queries data using the
|
|
172
|
-
# method
|
|
164
|
+
# Queries data using the [synchronous
|
|
165
|
+
# method](https://cloud.google.com/bigquery/querying-data).
|
|
173
166
|
#
|
|
174
|
-
#
|
|
175
|
-
#
|
|
176
|
-
# +query+::
|
|
177
|
-
# A query string, following the BigQuery {query
|
|
178
|
-
# syntax}[https://cloud.google.com/bigquery/query-reference], of the
|
|
167
|
+
# @param [String] query A query string, following the BigQuery [query
|
|
168
|
+
# syntax](https://cloud.google.com/bigquery/query-reference), of the
|
|
179
169
|
# query to execute. Example: "SELECT count(f1) FROM
|
|
180
|
-
# [myProjectId:myDatasetId.myTableId]".
|
|
181
|
-
#
|
|
182
|
-
#
|
|
183
|
-
#
|
|
184
|
-
#
|
|
185
|
-
#
|
|
186
|
-
#
|
|
187
|
-
#
|
|
188
|
-
#
|
|
189
|
-
#
|
|
190
|
-
#
|
|
191
|
-
#
|
|
192
|
-
#
|
|
193
|
-
#
|
|
194
|
-
#
|
|
195
|
-
#
|
|
196
|
-
#
|
|
197
|
-
#
|
|
198
|
-
#
|
|
199
|
-
# The default value is
|
|
200
|
-
#
|
|
201
|
-
#
|
|
202
|
-
#
|
|
203
|
-
#
|
|
204
|
-
#
|
|
205
|
-
#
|
|
206
|
-
#
|
|
207
|
-
#
|
|
208
|
-
#
|
|
209
|
-
#
|
|
210
|
-
#
|
|
211
|
-
#
|
|
212
|
-
#
|
|
213
|
-
# names in the query. Only used if +dataset+ option is set. (+String+)
|
|
214
|
-
#
|
|
215
|
-
# === Returns
|
|
216
|
-
#
|
|
217
|
-
# Gcloud::Bigquery::QueryData
|
|
218
|
-
#
|
|
219
|
-
# === Example
|
|
220
|
-
#
|
|
170
|
+
# [myProjectId:myDatasetId.myTableId]".
|
|
171
|
+
# @param [Integer] max The maximum number of rows of data to return per
|
|
172
|
+
# page of results. Setting this flag to a small value such as 1000 and
|
|
173
|
+
# then paging through results might improve reliability when the query
|
|
174
|
+
# result set is large. In addition to this limit, responses are also
|
|
175
|
+
# limited to 10 MB. By default, there is no maximum row count, and only
|
|
176
|
+
# the byte limit applies.
|
|
177
|
+
# @param [Integer] timeout How long to wait for the query to complete, in
|
|
178
|
+
# milliseconds, before the request times out and returns. Note that this
|
|
179
|
+
# is only a timeout for the request, not the query. If the query takes
|
|
180
|
+
# longer to run than the timeout value, the call returns without any
|
|
181
|
+
# results and with QueryData#complete? set to false. The default value
|
|
182
|
+
# is 10000 milliseconds (10 seconds).
|
|
183
|
+
# @param [Boolean] dryrun If set to `true`, BigQuery doesn't run the job.
|
|
184
|
+
# Instead, if the query is valid, BigQuery returns statistics about the
|
|
185
|
+
# job such as how many bytes would be processed. If the query is
|
|
186
|
+
# invalid, an error returns. The default value is `false`.
|
|
187
|
+
# @param [Boolean] cache Whether to look for the result in the query
|
|
188
|
+
# cache. The query cache is a best-effort cache that will be flushed
|
|
189
|
+
# whenever tables in the query are modified. The default value is true.
|
|
190
|
+
# For more information, see [query
|
|
191
|
+
# caching](https://developers.google.com/bigquery/querying-data).
|
|
192
|
+
# @param [String] dataset Specifies the default datasetId and projectId to
|
|
193
|
+
# assume for any unqualified table names in the query. If not set, all
|
|
194
|
+
# table names in the query string must be qualified in the format
|
|
195
|
+
# 'datasetId.tableId'.
|
|
196
|
+
# @param [String] project Specifies the default projectId to assume for
|
|
197
|
+
# any unqualified table names in the query. Only used if `dataset`
|
|
198
|
+
# option is set.
|
|
199
|
+
#
|
|
200
|
+
# @return [Gcloud::Bigquery::QueryData]
|
|
201
|
+
#
|
|
202
|
+
# @example
|
|
221
203
|
# require "gcloud"
|
|
222
204
|
#
|
|
223
205
|
# gcloud = Gcloud.new
|
|
@@ -244,17 +226,12 @@ module Gcloud
|
|
|
244
226
|
##
|
|
245
227
|
# Retrieves an existing dataset by ID.
|
|
246
228
|
#
|
|
247
|
-
#
|
|
229
|
+
# @param [String] dataset_id The ID of a dataset.
|
|
248
230
|
#
|
|
249
|
-
#
|
|
250
|
-
#
|
|
251
|
-
#
|
|
252
|
-
# === Returns
|
|
253
|
-
#
|
|
254
|
-
# Gcloud::Bigquery::Dataset or nil if dataset does not exist
|
|
255
|
-
#
|
|
256
|
-
# === Example
|
|
231
|
+
# @return [Gcloud::Bigquery::Dataset, nil] Returns `nil` if the dataset
|
|
232
|
+
# does not exist.
|
|
257
233
|
#
|
|
234
|
+
# @example
|
|
258
235
|
# require "gcloud"
|
|
259
236
|
#
|
|
260
237
|
# gcloud = Gcloud.new
|
|
@@ -277,34 +254,28 @@ module Gcloud
|
|
|
277
254
|
##
|
|
278
255
|
# Creates a new dataset.
|
|
279
256
|
#
|
|
280
|
-
#
|
|
281
|
-
#
|
|
282
|
-
#
|
|
283
|
-
#
|
|
284
|
-
#
|
|
285
|
-
#
|
|
286
|
-
#
|
|
287
|
-
#
|
|
288
|
-
#
|
|
289
|
-
#
|
|
290
|
-
#
|
|
291
|
-
#
|
|
292
|
-
#
|
|
293
|
-
#
|
|
294
|
-
#
|
|
295
|
-
#
|
|
296
|
-
#
|
|
297
|
-
#
|
|
298
|
-
#
|
|
299
|
-
#
|
|
300
|
-
#
|
|
301
|
-
#
|
|
302
|
-
# === Returns
|
|
303
|
-
#
|
|
304
|
-
# Gcloud::Bigquery::Dataset
|
|
305
|
-
#
|
|
306
|
-
# === Examples
|
|
307
|
-
#
|
|
257
|
+
# @param [String] dataset_id A unique ID for this dataset, without the
|
|
258
|
+
# project name. The ID must contain only letters (a-z, A-Z), numbers
|
|
259
|
+
# (0-9), or underscores (_). The maximum length is 1,024 characters.
|
|
260
|
+
# @param [String] name A descriptive name for the dataset.
|
|
261
|
+
# @param [String] description A user-friendly description of the dataset.
|
|
262
|
+
# @param [Integer] expiration The default lifetime of all tables in the
|
|
263
|
+
# dataset, in milliseconds. The minimum value is 3600000 milliseconds
|
|
264
|
+
# (one hour).
|
|
265
|
+
# @param [Array<Hash>] access The access rules for a Dataset using the
|
|
266
|
+
# Google Cloud Datastore API data structure of an array of hashes. See
|
|
267
|
+
# [BigQuery Access
|
|
268
|
+
# Control](https://cloud.google.com/bigquery/access-control) for more
|
|
269
|
+
# information.
|
|
270
|
+
# @param [String] location The geographic location where the dataset
|
|
271
|
+
# should reside. Possible values include `EU` and `US`. The default
|
|
272
|
+
# value is `US`.
|
|
273
|
+
# @yield [access] a block for setting rules
|
|
274
|
+
# @yieldparam [Dataset::Access] access the object accepting rules
|
|
275
|
+
#
|
|
276
|
+
# @return [Gcloud::Bigquery::Dataset]
|
|
277
|
+
#
|
|
278
|
+
# @example
|
|
308
279
|
# require "gcloud"
|
|
309
280
|
#
|
|
310
281
|
# gcloud = Gcloud.new
|
|
@@ -312,8 +283,7 @@ module Gcloud
|
|
|
312
283
|
#
|
|
313
284
|
# dataset = bigquery.create_dataset "my_dataset"
|
|
314
285
|
#
|
|
315
|
-
# A name and description can be provided:
|
|
316
|
-
#
|
|
286
|
+
# @example A name and description can be provided:
|
|
317
287
|
# require "gcloud"
|
|
318
288
|
#
|
|
319
289
|
# gcloud = Gcloud.new
|
|
@@ -323,8 +293,7 @@ module Gcloud
|
|
|
323
293
|
# name: "My Dataset",
|
|
324
294
|
# description: "This is my Dataset"
|
|
325
295
|
#
|
|
326
|
-
# Access rules can be provided with the
|
|
327
|
-
#
|
|
296
|
+
# @example Access rules can be provided with the `access` option:
|
|
328
297
|
# require "gcloud"
|
|
329
298
|
#
|
|
330
299
|
# gcloud = Gcloud.new
|
|
@@ -333,9 +302,7 @@ module Gcloud
|
|
|
333
302
|
# dataset = bigquery.create_dataset "my_dataset",
|
|
334
303
|
# access: [{"role"=>"WRITER", "userByEmail"=>"writers@example.com"}]
|
|
335
304
|
#
|
|
336
|
-
# Or access
|
|
337
|
-
# (See Dataset::Access)
|
|
338
|
-
#
|
|
305
|
+
# @example Or, configure access with a block: (See {Dataset::Access})
|
|
339
306
|
# require "gcloud"
|
|
340
307
|
#
|
|
341
308
|
# gcloud = Gcloud.new
|
|
@@ -365,23 +332,16 @@ module Gcloud
|
|
|
365
332
|
##
|
|
366
333
|
# Retrieves the list of datasets belonging to the project.
|
|
367
334
|
#
|
|
368
|
-
#
|
|
369
|
-
#
|
|
370
|
-
#
|
|
371
|
-
#
|
|
372
|
-
#
|
|
373
|
-
# +token+::
|
|
374
|
-
# A previously-returned page token representing part of the larger set
|
|
375
|
-
# of results to view. (+String+)
|
|
376
|
-
# +max+::
|
|
377
|
-
# Maximum number of datasets to return. (+Integer+)
|
|
335
|
+
# @param [Boolean] all Whether to list all datasets, including hidden
|
|
336
|
+
# ones. The default is `false`.
|
|
337
|
+
# @param [String] token A previously-returned page token representing part
|
|
338
|
+
# of the larger set of results to view.
|
|
339
|
+
# @param [Integer] max Maximum number of datasets to return.
|
|
378
340
|
#
|
|
379
|
-
#
|
|
380
|
-
#
|
|
381
|
-
# Array of Gcloud::Bigquery::Dataset (See Gcloud::Bigquery::Dataset::List)
|
|
382
|
-
#
|
|
383
|
-
# === Examples
|
|
341
|
+
# @return [Array<Gcloud::Bigquery::Dataset>] (See
|
|
342
|
+
# {Gcloud::Bigquery::Dataset::List})
|
|
384
343
|
#
|
|
344
|
+
# @example
|
|
385
345
|
# require "gcloud"
|
|
386
346
|
#
|
|
387
347
|
# gcloud = Gcloud.new
|
|
@@ -392,9 +352,7 @@ module Gcloud
|
|
|
392
352
|
# puts dataset.name
|
|
393
353
|
# end
|
|
394
354
|
#
|
|
395
|
-
#
|
|
396
|
-
# the +:all+ option:
|
|
397
|
-
#
|
|
355
|
+
# @example Retrieve all datasets, including hidden ones, with `:all`:
|
|
398
356
|
# require "gcloud"
|
|
399
357
|
#
|
|
400
358
|
# gcloud = Gcloud.new
|
|
@@ -402,9 +360,7 @@ module Gcloud
|
|
|
402
360
|
#
|
|
403
361
|
# all_datasets = bigquery.datasets, all: true
|
|
404
362
|
#
|
|
405
|
-
#
|
|
406
|
-
# through them: (See Dataset::List#token)
|
|
407
|
-
#
|
|
363
|
+
# @example With pagination: (See {Dataset::List#token})
|
|
408
364
|
# require "gcloud"
|
|
409
365
|
#
|
|
410
366
|
# gcloud = Gcloud.new
|
|
@@ -436,17 +392,12 @@ module Gcloud
|
|
|
436
392
|
##
|
|
437
393
|
# Retrieves an existing job by ID.
|
|
438
394
|
#
|
|
439
|
-
#
|
|
395
|
+
# @param [String] job_id The ID of a job.
|
|
440
396
|
#
|
|
441
|
-
#
|
|
442
|
-
#
|
|
443
|
-
#
|
|
444
|
-
# === Returns
|
|
445
|
-
#
|
|
446
|
-
# Gcloud::Bigquery::Job or nil if job does not exist
|
|
447
|
-
#
|
|
448
|
-
# === Example
|
|
397
|
+
# @return [Gcloud::Bigquery::Job, nil] Returns `nil` if the job does not
|
|
398
|
+
# exist.
|
|
449
399
|
#
|
|
400
|
+
# @example
|
|
450
401
|
# require "gcloud"
|
|
451
402
|
#
|
|
452
403
|
# gcloud = Gcloud.new
|
|
@@ -468,30 +419,23 @@ module Gcloud
|
|
|
468
419
|
##
|
|
469
420
|
# Retrieves the list of jobs belonging to the project.
|
|
470
421
|
#
|
|
471
|
-
#
|
|
472
|
-
#
|
|
473
|
-
#
|
|
474
|
-
#
|
|
475
|
-
#
|
|
476
|
-
#
|
|
477
|
-
# A previously-returned page token representing part of the larger set
|
|
478
|
-
# of results to view. (+String+)
|
|
479
|
-
# +max+::
|
|
480
|
-
# Maximum number of jobs to return. (+Integer+)
|
|
481
|
-
# +filter+::
|
|
482
|
-
# A filter for job state. (+String+)
|
|
422
|
+
# @param [Boolean] all Whether to display jobs owned by all users in the
|
|
423
|
+
# project. The default is `false`.
|
|
424
|
+
# @param [String] token A previously-returned page token representing part
|
|
425
|
+
# of the larger set of results to view.
|
|
426
|
+
# @param [Integer] max Maximum number of jobs to return.
|
|
427
|
+
# @param [String] filter A filter for job state.
|
|
483
428
|
#
|
|
484
429
|
# Acceptable values are:
|
|
485
|
-
# * +done+ - Finished jobs
|
|
486
|
-
# * +pending+ - Pending jobs
|
|
487
|
-
# * +running+ - Running jobs
|
|
488
430
|
#
|
|
489
|
-
#
|
|
431
|
+
# * `done` - Finished jobs
|
|
432
|
+
# * `pending` - Pending jobs
|
|
433
|
+
# * `running` - Running jobs
|
|
490
434
|
#
|
|
491
|
-
# Array
|
|
492
|
-
#
|
|
493
|
-
# === Examples
|
|
435
|
+
# @return [Array<Gcloud::Bigquery::Job>] (See
|
|
436
|
+
# {Gcloud::Bigquery::Job::List})
|
|
494
437
|
#
|
|
438
|
+
# @example
|
|
495
439
|
# require "gcloud"
|
|
496
440
|
#
|
|
497
441
|
# gcloud = Gcloud.new
|
|
@@ -499,8 +443,7 @@ module Gcloud
|
|
|
499
443
|
#
|
|
500
444
|
# jobs = bigquery.jobs
|
|
501
445
|
#
|
|
502
|
-
#
|
|
503
|
-
#
|
|
446
|
+
# @example Retrieve only running jobs using the `:filter` option:
|
|
504
447
|
# require "gcloud"
|
|
505
448
|
#
|
|
506
449
|
# gcloud = Gcloud.new
|
|
@@ -508,9 +451,7 @@ module Gcloud
|
|
|
508
451
|
#
|
|
509
452
|
# running_jobs = bigquery.jobs filter: "running"
|
|
510
453
|
#
|
|
511
|
-
#
|
|
512
|
-
# through them: (See Job::List#token)
|
|
513
|
-
#
|
|
454
|
+
# @example With pagination: (See {Job::List#token})
|
|
514
455
|
# require "gcloud"
|
|
515
456
|
#
|
|
516
457
|
# gcloud = Gcloud.new
|