gcloud 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG.md +8 -0
- data/lib/gcloud.rb +48 -30
- data/lib/gcloud/bigquery.rb +4 -6
- data/lib/gcloud/bigquery/connection.rb +2 -14
- data/lib/gcloud/bigquery/dataset.rb +41 -42
- data/lib/gcloud/bigquery/project.rb +50 -46
- data/lib/gcloud/bigquery/query_job.rb +7 -8
- data/lib/gcloud/bigquery/table.rb +54 -55
- data/lib/gcloud/bigquery/table/schema.rb +30 -40
- data/lib/gcloud/bigquery/view.rb +10 -11
- data/lib/gcloud/credentials.rb +19 -25
- data/lib/gcloud/datastore.rb +4 -6
- data/lib/gcloud/datastore/dataset.rb +3 -5
- data/lib/gcloud/dns.rb +4 -6
- data/lib/gcloud/dns/connection.rb +17 -16
- data/lib/gcloud/dns/importer.rb +5 -11
- data/lib/gcloud/dns/project.rb +11 -12
- data/lib/gcloud/dns/zone.rb +52 -92
- data/lib/gcloud/dns/zone/transaction.rb +2 -2
- data/lib/gcloud/pubsub.rb +4 -6
- data/lib/gcloud/pubsub/connection.rb +1 -12
- data/lib/gcloud/pubsub/project.rb +30 -36
- data/lib/gcloud/pubsub/subscription.rb +18 -26
- data/lib/gcloud/pubsub/topic.rb +16 -26
- data/lib/gcloud/resource_manager.rb +5 -6
- data/lib/gcloud/resource_manager/connection.rb +4 -4
- data/lib/gcloud/resource_manager/manager.rb +10 -14
- data/lib/gcloud/resource_manager/project.rb +3 -5
- data/lib/gcloud/search.rb +295 -0
- data/lib/gcloud/search/api_client.rb +144 -0
- data/lib/gcloud/search/connection.rb +146 -0
- data/lib/gcloud/search/credentials.rb +30 -0
- data/lib/gcloud/search/document.rb +301 -0
- data/lib/gcloud/search/document/list.rb +85 -0
- data/lib/gcloud/search/errors.rb +67 -0
- data/lib/gcloud/search/field_value.rb +164 -0
- data/lib/gcloud/search/field_values.rb +263 -0
- data/lib/gcloud/search/fields.rb +267 -0
- data/lib/gcloud/search/index.rb +613 -0
- data/lib/gcloud/search/index/list.rb +90 -0
- data/lib/gcloud/search/project.rb +197 -0
- data/lib/gcloud/search/result.rb +169 -0
- data/lib/gcloud/search/result/list.rb +95 -0
- data/lib/gcloud/storage.rb +4 -6
- data/lib/gcloud/storage/bucket.rb +55 -43
- data/lib/gcloud/storage/bucket/cors.rb +5 -7
- data/lib/gcloud/storage/file.rb +35 -30
- data/lib/gcloud/storage/file/acl.rb +12 -16
- data/lib/gcloud/storage/project.rb +56 -22
- data/lib/gcloud/version.rb +1 -1
- metadata +20 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MzYyZTAzYjI3MDRlNWZmODg4OTlmMzU4MWVhOWJjNTg2NTFjZjgyMw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MTBlNzFkOGIxMTFmYzFhZWVkZmIzZGE0NzAxYjExMDM1MDU1ZjQ2ZA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MTdiZTVjZjViOTM4ZmQxZDZjMGZiMmQ1MDAzNmFmYWU1N2Q2ZTg2NTAzMjQx
|
10
|
+
NTk4YTU2NmQ1ZGVjOTFjOGQ5OThhMDIxNDU0YjNmZTczMTc3ZTQ1ZDRmNTVi
|
11
|
+
YzJhMWY2YTJlNTQwZDcyMmYyOWE3ZjkzY2YwYjRlZTZlYzFlYzU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YTI5YjRiMWE2YTE0ZjJlYzk5OWNhNjkyNjQ4ZWM1NGQwOTRkZjllZGU0MGFk
|
14
|
+
MWEyMmFkYTFiODk3NGNiZmE3ZDA5YTMxODliNjFiY2IzNDEzMjNkZGZmYzZm
|
15
|
+
MGQ0MzA5ZjNhOTlhOGZkMTQ3YjMyNjM0ZTJkMDczODFhY2Q3Njc=
|
data/CHANGELOG.md
CHANGED
data/lib/gcloud.rb
CHANGED
@@ -72,9 +72,7 @@ module Gcloud
|
|
72
72
|
#
|
73
73
|
# === Parameters
|
74
74
|
#
|
75
|
-
# +
|
76
|
-
# An optional Hash for controlling additional behavior. (+Hash+)
|
77
|
-
# <code>options[:scope]</code>::
|
75
|
+
# +scope+::
|
78
76
|
# The OAuth 2.0 scopes controlling the set of resources and operations that
|
79
77
|
# the connection can access. See {Using OAuth 2.0 to Access Google
|
80
78
|
# APIs}[https://developers.google.com/identity/protocols/OAuth2]. (+String+
|
@@ -112,9 +110,9 @@ module Gcloud
|
|
112
110
|
# platform_scope = "https://www.googleapis.com/auth/cloud-platform"
|
113
111
|
# dataset = gcloud.datastore scope: platform_scope
|
114
112
|
#
|
115
|
-
def datastore
|
113
|
+
def datastore scope: nil
|
116
114
|
require "gcloud/datastore"
|
117
|
-
Gcloud.datastore @project, @keyfile,
|
115
|
+
Gcloud.datastore @project, @keyfile, scope: scope
|
118
116
|
end
|
119
117
|
|
120
118
|
##
|
@@ -123,9 +121,7 @@ module Gcloud
|
|
123
121
|
#
|
124
122
|
# === Parameters
|
125
123
|
#
|
126
|
-
# +
|
127
|
-
# An optional Hash for controlling additional behavior. (+Hash+)
|
128
|
-
# <code>options[:scope]</code>::
|
124
|
+
# +scope+::
|
129
125
|
# The OAuth 2.0 scopes controlling the set of resources and operations that
|
130
126
|
# the connection can access. See {Using OAuth 2.0 to Access Google
|
131
127
|
# APIs}[https://developers.google.com/identity/protocols/OAuth2]. (+String+
|
@@ -158,9 +154,9 @@ module Gcloud
|
|
158
154
|
# readonly_scope = "https://www.googleapis.com/auth/devstorage.read_only"
|
159
155
|
# readonly_storage = gcloud.storage scope: readonly_scope
|
160
156
|
#
|
161
|
-
def storage
|
157
|
+
def storage scope: nil
|
162
158
|
require "gcloud/storage"
|
163
|
-
Gcloud.storage @project, @keyfile,
|
159
|
+
Gcloud.storage @project, @keyfile, scope: scope
|
164
160
|
end
|
165
161
|
|
166
162
|
##
|
@@ -169,9 +165,7 @@ module Gcloud
|
|
169
165
|
#
|
170
166
|
# === Parameters
|
171
167
|
#
|
172
|
-
# +
|
173
|
-
# An optional Hash for controlling additional behavior. (+Hash+)
|
174
|
-
# <code>options[:scope]</code>::
|
168
|
+
# +scope+::
|
175
169
|
# The OAuth 2.0 scopes controlling the set of resources and operations that
|
176
170
|
# the connection can access. See {Using OAuth 2.0 to Access Google
|
177
171
|
# APIs}[https://developers.google.com/identity/protocols/OAuth2]. (+String+
|
@@ -202,9 +196,9 @@ module Gcloud
|
|
202
196
|
# platform_scope = "https://www.googleapis.com/auth/cloud-platform"
|
203
197
|
# pubsub = gcloud.pubsub scope: platform_scope
|
204
198
|
#
|
205
|
-
def pubsub
|
199
|
+
def pubsub scope: nil
|
206
200
|
require "gcloud/pubsub"
|
207
|
-
Gcloud.pubsub @project, @keyfile,
|
201
|
+
Gcloud.pubsub @project, @keyfile, scope: scope
|
208
202
|
end
|
209
203
|
|
210
204
|
##
|
@@ -213,9 +207,7 @@ module Gcloud
|
|
213
207
|
#
|
214
208
|
# === Parameters
|
215
209
|
#
|
216
|
-
# +
|
217
|
-
# An optional Hash for controlling additional behavior. (+Hash+)
|
218
|
-
# <code>options[:scope]</code>::
|
210
|
+
# +scope+::
|
219
211
|
# The OAuth 2.0 scopes controlling the set of resources and operations that
|
220
212
|
# the connection can access. See {Using OAuth 2.0 to Access Google
|
221
213
|
# APIs}[https://developers.google.com/identity/protocols/OAuth2]. (+String+
|
@@ -249,9 +241,9 @@ module Gcloud
|
|
249
241
|
# platform_scope = "https://www.googleapis.com/auth/cloud-platform"
|
250
242
|
# bigquery = gcloud.bigquery scope: platform_scope
|
251
243
|
#
|
252
|
-
def bigquery
|
244
|
+
def bigquery scope: nil
|
253
245
|
require "gcloud/bigquery"
|
254
|
-
Gcloud.bigquery @project, @keyfile,
|
246
|
+
Gcloud.bigquery @project, @keyfile, scope: scope
|
255
247
|
end
|
256
248
|
|
257
249
|
##
|
@@ -260,9 +252,7 @@ module Gcloud
|
|
260
252
|
#
|
261
253
|
# === Parameters
|
262
254
|
#
|
263
|
-
# +
|
264
|
-
# An optional Hash for controlling additional behavior. (+Hash+)
|
265
|
-
# <code>options[:scope]</code>::
|
255
|
+
# +scope+::
|
266
256
|
# The OAuth 2.0 scopes controlling the set of resources and operations that
|
267
257
|
# the connection can access. See {Using OAuth 2.0 to Access Google
|
268
258
|
# APIs}[https://developers.google.com/identity/protocols/OAuth2]. (+String+
|
@@ -295,9 +285,9 @@ module Gcloud
|
|
295
285
|
# readonly_scope = "https://www.googleapis.com/auth/ndev.clouddns.readonly"
|
296
286
|
# dns = gcloud.dns scope: readonly_scope
|
297
287
|
#
|
298
|
-
def dns
|
288
|
+
def dns scope: nil
|
299
289
|
require "gcloud/dns"
|
300
|
-
Gcloud.dns @project, @keyfile,
|
290
|
+
Gcloud.dns @project, @keyfile, scope: scope
|
301
291
|
end
|
302
292
|
|
303
293
|
# rubocop:disable Metrics/LineLength
|
@@ -310,9 +300,7 @@ module Gcloud
|
|
310
300
|
#
|
311
301
|
# === Parameters
|
312
302
|
#
|
313
|
-
# +
|
314
|
-
# An optional Hash for controlling additional behavior. (+Hash+)
|
315
|
-
# <code>options[:scope]</code>::
|
303
|
+
# +scope+::
|
316
304
|
# The OAuth 2.0 scopes controlling the set of resources and operations that
|
317
305
|
# the connection can access. See {Using OAuth 2.0 to Access Google
|
318
306
|
# APIs}[https://developers.google.com/identity/protocols/OAuth2]. (+String+
|
@@ -344,10 +332,40 @@ module Gcloud
|
|
344
332
|
# readonly_scope = "https://www.googleapis.com/auth/cloudresourcemanager.readonly"
|
345
333
|
# resource_manager = gcloud.resource_manager scope: readonly_scope
|
346
334
|
#
|
347
|
-
def resource_manager
|
335
|
+
def resource_manager scope: nil
|
348
336
|
require "gcloud/resource_manager"
|
349
|
-
Gcloud.resource_manager @keyfile,
|
337
|
+
Gcloud.resource_manager @keyfile, scope: scope
|
350
338
|
end
|
351
339
|
|
352
340
|
# rubocop:enable Metrics/LineLength
|
341
|
+
|
342
|
+
##
|
343
|
+
# Creates a new object for connecting to the Search service.
|
344
|
+
# Each call creates a new connection.
|
345
|
+
#
|
346
|
+
# === Parameters
|
347
|
+
#
|
348
|
+
# +scope+::
|
349
|
+
# The OAuth 2.0 scopes controlling the set of resources and operations that
|
350
|
+
# the connection can access. See {Using OAuth 2.0 to Access Google
|
351
|
+
# APIs}[https://developers.google.com/identity/protocols/OAuth2]. (+String+
|
352
|
+
# or +Array+)
|
353
|
+
#
|
354
|
+
# The default scopes are:
|
355
|
+
#
|
356
|
+
# * +https://www.googleapis.com/auth/cloudsearch+
|
357
|
+
# * +https://www.googleapis.com/auth/userinfo.email+
|
358
|
+
#
|
359
|
+
# === Returns
|
360
|
+
#
|
361
|
+
# Gcloud::Search::Project
|
362
|
+
#
|
363
|
+
# === Examples
|
364
|
+
#
|
365
|
+
# require "gcloud"
|
366
|
+
#
|
367
|
+
def search scope: nil
|
368
|
+
require "gcloud/search"
|
369
|
+
Gcloud.search @project, @keyfile, scope: scope
|
370
|
+
end
|
353
371
|
end
|
data/lib/gcloud/bigquery.rb
CHANGED
@@ -30,9 +30,7 @@ module Gcloud
|
|
30
30
|
# +keyfile+::
|
31
31
|
# Keyfile downloaded from Google Cloud. If file path the file must be
|
32
32
|
# readable. (+String+ or +Hash+)
|
33
|
-
# +
|
34
|
-
# An optional Hash for controlling additional behavior. (+Hash+)
|
35
|
-
# <code>options[:scope]</code>::
|
33
|
+
# +scope+::
|
36
34
|
# The OAuth 2.0 scopes controlling the set of resources and operations that
|
37
35
|
# the connection can access. See {Using OAuth 2.0 to Access Google
|
38
36
|
# APIs}[https://developers.google.com/identity/protocols/OAuth2]. (+String+
|
@@ -54,12 +52,12 @@ module Gcloud
|
|
54
52
|
# dataset = bigquery.dataset "my_dataset"
|
55
53
|
# table = dataset.table "my_table"
|
56
54
|
#
|
57
|
-
def self.bigquery project = nil, keyfile = nil,
|
55
|
+
def self.bigquery project = nil, keyfile = nil, scope: nil
|
58
56
|
project ||= Gcloud::Bigquery::Project.default_project
|
59
57
|
if keyfile.nil?
|
60
|
-
credentials = Gcloud::Bigquery::Credentials.default
|
58
|
+
credentials = Gcloud::Bigquery::Credentials.default scope: scope
|
61
59
|
else
|
62
|
-
credentials = Gcloud::Bigquery::Credentials.new keyfile,
|
60
|
+
credentials = Gcloud::Bigquery::Credentials.new keyfile, scope: scope
|
63
61
|
end
|
64
62
|
Gcloud::Bigquery::Project.new project, credentials
|
65
63
|
end
|
@@ -94,11 +94,11 @@ module Gcloud
|
|
94
94
|
# either manually or by specifying force: true in options.
|
95
95
|
# Immediately after deletion, you can create another dataset with
|
96
96
|
# the same name.
|
97
|
-
def delete_dataset dataset_id,
|
97
|
+
def delete_dataset dataset_id, force = nil
|
98
98
|
@client.execute(
|
99
99
|
api_method: @bigquery.datasets.delete,
|
100
100
|
parameters: { projectId: @project, datasetId: dataset_id,
|
101
|
-
deleteContents:
|
101
|
+
deleteContents: force
|
102
102
|
}.delete_if { |_, v| v.nil? }
|
103
103
|
)
|
104
104
|
end
|
@@ -344,17 +344,6 @@ module Gcloud
|
|
344
344
|
|
345
345
|
protected
|
346
346
|
|
347
|
-
##
|
348
|
-
# Make sure the object is converted to a hash
|
349
|
-
# Ruby 1.9.3 doesn't support to_h, so here we are.
|
350
|
-
def hashify hash
|
351
|
-
if hash.respond_to? :to_h
|
352
|
-
hash.to_h
|
353
|
-
else
|
354
|
-
Hash.try_convert(hash) || {}
|
355
|
-
end
|
356
|
-
end
|
357
|
-
|
358
347
|
##
|
359
348
|
# Create the HTTP body for insert dataset
|
360
349
|
def insert_dataset_request dataset_id, options = {}
|
@@ -482,7 +471,6 @@ module Gcloud
|
|
482
471
|
"defaultDataset" => dataset_config,
|
483
472
|
"timeoutMs" => options[:timeout],
|
484
473
|
"dryRun" => options[:dryrun],
|
485
|
-
"preserveNulls" => options[:preserve_nulls],
|
486
474
|
"useQueryCache" => options[:cache]
|
487
475
|
}.delete_if { |_, v| v.nil? }
|
488
476
|
end
|
@@ -281,9 +281,7 @@ module Gcloud
|
|
281
281
|
#
|
282
282
|
# === Parameters
|
283
283
|
#
|
284
|
-
# +
|
285
|
-
# An optional Hash for controlling additional behavior. (+Hash+)
|
286
|
-
# <code>options[:force]</code>::
|
284
|
+
# +force+::
|
287
285
|
# If +true+, delete all the tables in the dataset. If +false+ and the
|
288
286
|
# dataset contains tables, the request will fail. Default is +false+.
|
289
287
|
# (+Boolean+)
|
@@ -304,9 +302,9 @@ module Gcloud
|
|
304
302
|
#
|
305
303
|
# :category: Lifecycle
|
306
304
|
#
|
307
|
-
def delete
|
305
|
+
def delete force: nil
|
308
306
|
ensure_connection!
|
309
|
-
resp = connection.delete_dataset dataset_id,
|
307
|
+
resp = connection.delete_dataset dataset_id, force
|
310
308
|
if resp.success?
|
311
309
|
true
|
312
310
|
else
|
@@ -323,13 +321,11 @@ module Gcloud
|
|
323
321
|
# The ID of the table. The ID must contain only letters (a-z, A-Z),
|
324
322
|
# numbers (0-9), or underscores (_). The maximum length is 1,024
|
325
323
|
# characters. (+String+)
|
326
|
-
# +
|
327
|
-
# An optional Hash for controlling additional behavior. (+Hash+)
|
328
|
-
# <code>options[:name]</code>::
|
324
|
+
# +name+::
|
329
325
|
# A descriptive name for the table. (+String+)
|
330
|
-
#
|
326
|
+
# +description+::
|
331
327
|
# A user-friendly description of the table. (+String+)
|
332
|
-
#
|
328
|
+
# +schema+::
|
333
329
|
# A hash specifying fields and data types for the table. A block may be
|
334
330
|
# passed instead (see examples.) For the format of this hash, see the
|
335
331
|
# {Tables resource
|
@@ -415,16 +411,17 @@ module Gcloud
|
|
415
411
|
#
|
416
412
|
# :category: Table
|
417
413
|
#
|
418
|
-
def create_table table_id,
|
414
|
+
def create_table table_id, name: nil, description: nil, schema: nil
|
419
415
|
ensure_connection!
|
420
416
|
if block_given?
|
421
|
-
if
|
417
|
+
if schema
|
422
418
|
fail ArgumentError, "only schema block or schema option is allowed"
|
423
419
|
end
|
424
420
|
schema_builder = Table::Schema.new nil
|
425
421
|
yield schema_builder
|
426
|
-
|
422
|
+
schema = schema_builder.schema if schema_builder.changed?
|
427
423
|
end
|
424
|
+
options = { name: name, description: description, schema: schema }
|
428
425
|
insert_table table_id, options
|
429
426
|
end
|
430
427
|
|
@@ -440,11 +437,9 @@ module Gcloud
|
|
440
437
|
# +query+::
|
441
438
|
# The query that BigQuery executes when the view is referenced.
|
442
439
|
# (+String+)
|
443
|
-
# +
|
444
|
-
# An optional Hash for controlling additional behavior. (+Hash+)
|
445
|
-
# <code>options[:name]</code>::
|
440
|
+
# +name+::
|
446
441
|
# A descriptive name for the table. (+String+)
|
447
|
-
#
|
442
|
+
# +description+::
|
448
443
|
# A user-friendly description of the table. (+String+)
|
449
444
|
#
|
450
445
|
# === Returns
|
@@ -474,9 +469,9 @@ module Gcloud
|
|
474
469
|
#
|
475
470
|
# :category: Table
|
476
471
|
#
|
477
|
-
def create_view table_id, query,
|
478
|
-
options
|
479
|
-
|
472
|
+
def create_view table_id, query, name: nil, description: nil
|
473
|
+
options = { query: query, name: name, description: description }
|
474
|
+
insert_table table_id, options
|
480
475
|
end
|
481
476
|
|
482
477
|
##
|
@@ -519,12 +514,10 @@ module Gcloud
|
|
519
514
|
#
|
520
515
|
# === Parameters
|
521
516
|
#
|
522
|
-
# +
|
523
|
-
# An optional Hash for controlling additional behavior. (+Hash+)
|
524
|
-
# <code>options[:token]</code>::
|
517
|
+
# +token+::
|
525
518
|
# A previously-returned page token representing part of the larger set
|
526
519
|
# of results to view. (+String+)
|
527
|
-
#
|
520
|
+
# +max+::
|
528
521
|
# Maximum number of tables to return. (+Integer+)
|
529
522
|
#
|
530
523
|
# === Returns
|
@@ -567,8 +560,9 @@ module Gcloud
|
|
567
560
|
#
|
568
561
|
# :category: Table
|
569
562
|
#
|
570
|
-
def tables
|
563
|
+
def tables token: nil, max: nil
|
571
564
|
ensure_connection!
|
565
|
+
options = { token: token, max: max }
|
572
566
|
resp = connection.list_tables dataset_id, options
|
573
567
|
if resp.success?
|
574
568
|
Table::List.from_response resp, connection
|
@@ -591,25 +585,25 @@ module Gcloud
|
|
591
585
|
# syntax}[https://cloud.google.com/bigquery/query-reference], of the
|
592
586
|
# query to execute. Example: "SELECT count(f1) FROM
|
593
587
|
# [myProjectId:myDatasetId.myTableId]". (+String+)
|
594
|
-
#
|
588
|
+
# +priority+::
|
595
589
|
# Specifies a priority for the query. Possible values include
|
596
590
|
# +INTERACTIVE+ and +BATCH+. The default value is +INTERACTIVE+.
|
597
591
|
# (+String+)
|
598
|
-
#
|
592
|
+
# +cache+::
|
599
593
|
# Whether to look for the result in the query cache. The query cache is
|
600
594
|
# a best-effort cache that will be flushed whenever tables in the query
|
601
595
|
# are modified. The default value is +true+. (+Boolean+)
|
602
|
-
#
|
596
|
+
# +table+::
|
603
597
|
# The destination table where the query results should be stored. If not
|
604
598
|
# present, a new table will be created to store the results. (+Table+)
|
605
|
-
#
|
599
|
+
# +create+::
|
606
600
|
# Specifies whether the job is allowed to create new tables. (+String+)
|
607
601
|
#
|
608
602
|
# The following values are supported:
|
609
603
|
# * +needed+ - Create the table if it does not exist.
|
610
604
|
# * +never+ - The table must already exist. A 'notFound' error is
|
611
605
|
# raised if the table does not exist.
|
612
|
-
#
|
606
|
+
# +write+::
|
613
607
|
# Specifies the action that occurs if the destination table already
|
614
608
|
# exists. (+String+)
|
615
609
|
#
|
@@ -618,14 +612,14 @@ module Gcloud
|
|
618
612
|
# * +append+ - BigQuery appends the data to the table.
|
619
613
|
# * +empty+ - A 'duplicate' error is returned in the job result if the
|
620
614
|
# table exists and contains data.
|
621
|
-
#
|
615
|
+
# +large_results+::
|
622
616
|
# If +true+, allows the query to produce arbitrarily large result tables
|
623
|
-
# at a slight cost in performance. Requires
|
624
|
-
#
|
625
|
-
#
|
617
|
+
# at a slight cost in performance. Requires +table+ parameter to be set.
|
618
|
+
# (+Boolean+)
|
619
|
+
# +flatten+::
|
626
620
|
# Flattens all nested and repeated fields in the query results. The
|
627
|
-
# default value is +true+.
|
628
|
-
#
|
621
|
+
# default value is +true+. +large_results+ parameter must be +true+ if
|
622
|
+
# this is set to +false+. (+Boolean+)
|
629
623
|
#
|
630
624
|
# === Returns
|
631
625
|
#
|
@@ -649,7 +643,11 @@ module Gcloud
|
|
649
643
|
#
|
650
644
|
# :category: Data
|
651
645
|
#
|
652
|
-
def query_job query,
|
646
|
+
def query_job query, priority: "INTERACTIVE", cache: true, table: nil,
|
647
|
+
create: nil, write: nil, large_results: nil, flatten: nil
|
648
|
+
options = { priority: priority, cache: cache, table: table,
|
649
|
+
create: create, write: write, large_results: large_results,
|
650
|
+
flatten: flatten }
|
653
651
|
options[:dataset] ||= self
|
654
652
|
ensure_connection!
|
655
653
|
resp = connection.query_job query, options
|
@@ -674,26 +672,26 @@ module Gcloud
|
|
674
672
|
# syntax}[https://cloud.google.com/bigquery/query-reference], of the
|
675
673
|
# query to execute. Example: "SELECT count(f1) FROM
|
676
674
|
# [myProjectId:myDatasetId.myTableId]". (+String+)
|
677
|
-
#
|
675
|
+
# +max+::
|
678
676
|
# The maximum number of rows of data to return per page of results.
|
679
677
|
# Setting this flag to a small value such as 1000 and then paging
|
680
678
|
# through results might improve reliability when the query result set is
|
681
679
|
# large. In addition to this limit, responses are also limited to 10 MB.
|
682
680
|
# By default, there is no maximum row count, and only the byte limit
|
683
681
|
# applies. (+Integer+)
|
684
|
-
#
|
682
|
+
# +timeout+::
|
685
683
|
# How long to wait for the query to complete, in milliseconds, before
|
686
684
|
# the request times out and returns. Note that this is only a timeout
|
687
685
|
# for the request, not the query. If the query takes longer to run than
|
688
686
|
# the timeout value, the call returns without any results and with
|
689
687
|
# QueryData#complete? set to false. The default value is 10000
|
690
688
|
# milliseconds (10 seconds). (+Integer+)
|
691
|
-
#
|
689
|
+
# +dryrun+::
|
692
690
|
# If set to +true+, BigQuery doesn't run the job. Instead, if the query
|
693
691
|
# is valid, BigQuery returns statistics about the job such as how many
|
694
692
|
# bytes would be processed. If the query is invalid, an error returns.
|
695
693
|
# The default value is +false+. (+Boolean+)
|
696
|
-
#
|
694
|
+
# +cache+::
|
697
695
|
# Whether to look for the result in the query cache. The query cache is
|
698
696
|
# a best-effort cache that will be flushed whenever tables in the query
|
699
697
|
# are modified. The default value is true. For more information, see
|
@@ -718,7 +716,8 @@ module Gcloud
|
|
718
716
|
#
|
719
717
|
# :category: Data
|
720
718
|
#
|
721
|
-
def query query,
|
719
|
+
def query query, max: nil, timeout: 10000, dryrun: nil, cache: true
|
720
|
+
options = { max: max, timeout: timeout, dryrun: dryrun, cache: cache }
|
722
721
|
options[:dataset] ||= dataset_id
|
723
722
|
options[:project] ||= project_id
|
724
723
|
ensure_connection!
|