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,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 "pathname"
|
|
17
17
|
require "gcloud/version"
|
|
18
18
|
require "google/api_client"
|
|
@@ -21,17 +21,17 @@ require "digest/md5"
|
|
|
21
21
|
module Gcloud
|
|
22
22
|
module Bigquery
|
|
23
23
|
##
|
|
24
|
-
# Represents the connection to Bigquery,
|
|
24
|
+
# @private Represents the connection to Bigquery,
|
|
25
25
|
# as well as expose the API calls.
|
|
26
|
-
class Connection
|
|
26
|
+
class Connection
|
|
27
27
|
API_VERSION = "v2"
|
|
28
28
|
|
|
29
29
|
attr_accessor :project
|
|
30
|
-
attr_accessor :credentials
|
|
30
|
+
attr_accessor :credentials
|
|
31
31
|
|
|
32
32
|
##
|
|
33
33
|
# Creates a new Connection instance.
|
|
34
|
-
def initialize project, credentials
|
|
34
|
+
def initialize project, credentials
|
|
35
35
|
@project = project
|
|
36
36
|
@credentials = credentials
|
|
37
37
|
@client = Google::APIClient.new application_name: "gcloud-ruby",
|
|
@@ -322,7 +322,7 @@ module Gcloud
|
|
|
322
322
|
end
|
|
323
323
|
|
|
324
324
|
##
|
|
325
|
-
# Extracts at least
|
|
325
|
+
# Extracts at least `tbl` group, and possibly `dts` and `prj` groups,
|
|
326
326
|
# from strings in the formats: "my_table", "my_dataset.my_table", or
|
|
327
327
|
# "my-project:my_dataset.my_table". Then merges project_id and
|
|
328
328
|
# dataset_id from the default table if they are missing.
|
|
@@ -338,7 +338,7 @@ module Gcloud
|
|
|
338
338
|
default_table_ref.merge str_table_ref
|
|
339
339
|
end
|
|
340
340
|
|
|
341
|
-
def inspect
|
|
341
|
+
def inspect
|
|
342
342
|
"#{self.class}(#{@project})"
|
|
343
343
|
end
|
|
344
344
|
|
|
@@ -555,7 +555,7 @@ module Gcloud
|
|
|
555
555
|
}
|
|
556
556
|
end
|
|
557
557
|
|
|
558
|
-
def create_disposition str
|
|
558
|
+
def create_disposition str
|
|
559
559
|
{ "create_if_needed" => "CREATE_IF_NEEDED",
|
|
560
560
|
"createifneeded" => "CREATE_IF_NEEDED",
|
|
561
561
|
"if_needed" => "CREATE_IF_NEEDED",
|
|
@@ -565,7 +565,7 @@ module Gcloud
|
|
|
565
565
|
"never" => "CREATE_NEVER" }[str.to_s.downcase]
|
|
566
566
|
end
|
|
567
567
|
|
|
568
|
-
def write_disposition str
|
|
568
|
+
def write_disposition str
|
|
569
569
|
{ "write_truncate" => "WRITE_TRUNCATE",
|
|
570
570
|
"writetruncate" => "WRITE_TRUNCATE",
|
|
571
571
|
"truncate" => "WRITE_TRUNCATE",
|
|
@@ -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,24 +12,24 @@
|
|
|
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
|
+
# # CopyJob
|
|
20
20
|
#
|
|
21
|
-
# A Job subclass representing a copy operation that may be performed on a
|
|
22
|
-
# Table. A CopyJob instance is created when you call Table#copy.
|
|
21
|
+
# A {Job} subclass representing a copy operation that may be performed on a
|
|
22
|
+
# {Table}. A CopyJob instance is created when you call {Table#copy}.
|
|
23
23
|
#
|
|
24
|
-
#
|
|
25
|
-
# Table
|
|
26
|
-
#
|
|
27
|
-
#
|
|
28
|
-
# for details.
|
|
24
|
+
# @see https://cloud.google.com/bigquery/docs/tables#copyingtable Copying an
|
|
25
|
+
# Existing Table
|
|
26
|
+
# @see https://cloud.google.com/bigquery/docs/reference/v2/jobs Jobs API
|
|
27
|
+
# reference
|
|
29
28
|
#
|
|
30
29
|
class CopyJob < Job
|
|
31
30
|
##
|
|
32
31
|
# The table from which data is copied. This is the table on
|
|
33
|
-
# which Table#copy was called. Returns a Table instance.
|
|
32
|
+
# which {Table#copy} was called. Returns a {Table} instance.
|
|
34
33
|
def source
|
|
35
34
|
table = config["copy"]["sourceTable"]
|
|
36
35
|
return nil unless table
|
|
@@ -40,7 +39,7 @@ module Gcloud
|
|
|
40
39
|
end
|
|
41
40
|
|
|
42
41
|
##
|
|
43
|
-
# The table to which data is copied. Returns a Table instance.
|
|
42
|
+
# The table to which data is copied. Returns a {Table} instance.
|
|
44
43
|
def destination
|
|
45
44
|
table = config["copy"]["destinationTable"]
|
|
46
45
|
return nil unless table
|
|
@@ -50,7 +49,7 @@ module Gcloud
|
|
|
50
49
|
end
|
|
51
50
|
|
|
52
51
|
##
|
|
53
|
-
# Checks if the create disposition for the job is
|
|
52
|
+
# Checks if the create disposition for the job is `CREATE_IF_NEEDED`,
|
|
54
53
|
# which provides the following behavior: If the table does not exist,
|
|
55
54
|
# the copy operation creates the table. This is the default.
|
|
56
55
|
def create_if_needed?
|
|
@@ -59,7 +58,7 @@ module Gcloud
|
|
|
59
58
|
end
|
|
60
59
|
|
|
61
60
|
##
|
|
62
|
-
# Checks if the create disposition for the job is
|
|
61
|
+
# Checks if the create disposition for the job is `CREATE_NEVER`, which
|
|
63
62
|
# provides the following behavior: The table must already exist; if it
|
|
64
63
|
# does not, an error is returned in the job result.
|
|
65
64
|
def create_never?
|
|
@@ -68,7 +67,7 @@ module Gcloud
|
|
|
68
67
|
end
|
|
69
68
|
|
|
70
69
|
##
|
|
71
|
-
# Checks if the write disposition for the job is
|
|
70
|
+
# Checks if the write disposition for the job is `WRITE_TRUNCATE`, which
|
|
72
71
|
# provides the following behavior: If the table already exists, the copy
|
|
73
72
|
# operation overwrites the table data.
|
|
74
73
|
def write_truncate?
|
|
@@ -77,7 +76,7 @@ module Gcloud
|
|
|
77
76
|
end
|
|
78
77
|
|
|
79
78
|
##
|
|
80
|
-
# Checks if the write disposition for the job is
|
|
79
|
+
# Checks if the write disposition for the job is `WRITE_APPEND`, which
|
|
81
80
|
# provides the following behavior: If the table already exists, the copy
|
|
82
81
|
# operation appends the data to the table.
|
|
83
82
|
def write_append?
|
|
@@ -86,7 +85,7 @@ module Gcloud
|
|
|
86
85
|
end
|
|
87
86
|
|
|
88
87
|
##
|
|
89
|
-
# Checks if the write disposition for the job is
|
|
88
|
+
# Checks if the write disposition for the job is `WRITE_EMPTY`, which
|
|
90
89
|
# provides the following behavior: If the table already exists and
|
|
91
90
|
# contains data, the job will have an error. This is the default.
|
|
92
91
|
def write_empty?
|
|
@@ -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,13 +12,14 @@
|
|
|
13
12
|
# See the License for the specific language governing permissions and
|
|
14
13
|
# limitations under the License.
|
|
15
14
|
|
|
15
|
+
|
|
16
16
|
require "gcloud/credentials"
|
|
17
17
|
|
|
18
18
|
module Gcloud
|
|
19
19
|
module Bigquery
|
|
20
20
|
##
|
|
21
|
-
# Represents the Oauth2 signing logic for Bigquery.
|
|
22
|
-
class Credentials < Gcloud::Credentials
|
|
21
|
+
# @private Represents the Oauth2 signing logic for Bigquery.
|
|
22
|
+
class Credentials < Gcloud::Credentials
|
|
23
23
|
SCOPE = ["https://www.googleapis.com/auth/bigquery"]
|
|
24
24
|
PATH_ENV_VARS = %w(BIGQUERY_KEYFILE GCLOUD_KEYFILE GOOGLE_CLOUD_KEYFILE)
|
|
25
25
|
JSON_ENV_VARS = %w(BIGQUERY_KEYFILE_JSON GCLOUD_KEYFILE_JSON
|
data/lib/gcloud/bigquery/data.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,25 +12,27 @@
|
|
|
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
|
|
19
19
|
module Bigquery
|
|
20
20
|
##
|
|
21
|
-
#
|
|
21
|
+
# # Data
|
|
22
22
|
#
|
|
23
|
-
# Represents Table Data as a list of name/value pairs.
|
|
24
|
-
# Also contains metadata such as
|
|
23
|
+
# Represents {Table} Data as a list of name/value pairs.
|
|
24
|
+
# Also contains metadata such as `etag` and `total`.
|
|
25
25
|
class Data < DelegateClass(::Array)
|
|
26
26
|
##
|
|
27
|
-
# The Table object the data belongs to.
|
|
28
|
-
attr_accessor :table
|
|
27
|
+
# @private The {Table} object the data belongs to.
|
|
28
|
+
attr_accessor :table
|
|
29
29
|
|
|
30
30
|
##
|
|
31
|
-
# The Google API Client object.
|
|
32
|
-
attr_accessor :gapi
|
|
31
|
+
# @private The Google API Client object.
|
|
32
|
+
attr_accessor :gapi
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
# @private
|
|
35
|
+
def initialize arr = []
|
|
35
36
|
@table = nil
|
|
36
37
|
@gapi = {}
|
|
37
38
|
super arr
|
|
@@ -79,8 +80,8 @@ module Gcloud
|
|
|
79
80
|
end
|
|
80
81
|
|
|
81
82
|
##
|
|
82
|
-
# New Data from a response object.
|
|
83
|
-
def self.from_response resp, table
|
|
83
|
+
# @private New Data from a response object.
|
|
84
|
+
def self.from_response resp, table
|
|
84
85
|
formatted_rows = format_rows resp.data["rows"], table.fields
|
|
85
86
|
|
|
86
87
|
data = new formatted_rows
|
|
@@ -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 "json"
|
|
17
17
|
require "gcloud/bigquery/errors"
|
|
18
18
|
require "gcloud/bigquery/table"
|
|
@@ -23,13 +23,14 @@ require "gcloud/bigquery/dataset/access"
|
|
|
23
23
|
module Gcloud
|
|
24
24
|
module Bigquery
|
|
25
25
|
##
|
|
26
|
-
#
|
|
26
|
+
# # Dataset
|
|
27
27
|
#
|
|
28
28
|
# Represents a Dataset. A dataset is a grouping mechanism that holds zero or
|
|
29
29
|
# more tables. Datasets are the lowest level unit of access control; you
|
|
30
30
|
# cannot control access at the table level. A dataset is contained within a
|
|
31
31
|
# specific project.
|
|
32
32
|
#
|
|
33
|
+
# @example
|
|
33
34
|
# require "gcloud"
|
|
34
35
|
#
|
|
35
36
|
# gcloud = Gcloud.new
|
|
@@ -41,16 +42,16 @@ module Gcloud
|
|
|
41
42
|
#
|
|
42
43
|
class Dataset
|
|
43
44
|
##
|
|
44
|
-
# The Connection object.
|
|
45
|
-
attr_accessor :connection
|
|
45
|
+
# @private The Connection object.
|
|
46
|
+
attr_accessor :connection
|
|
46
47
|
|
|
47
48
|
##
|
|
48
|
-
# The Google API Client object.
|
|
49
|
-
attr_accessor :gapi
|
|
49
|
+
# @private The Google API Client object.
|
|
50
|
+
attr_accessor :gapi
|
|
50
51
|
|
|
51
52
|
##
|
|
52
|
-
# Create an empty Dataset object.
|
|
53
|
-
def initialize
|
|
53
|
+
# @private Create an empty Dataset object.
|
|
54
|
+
def initialize
|
|
54
55
|
@connection = nil
|
|
55
56
|
@gapi = {}
|
|
56
57
|
end
|
|
@@ -60,7 +61,7 @@ module Gcloud
|
|
|
60
61
|
# The ID must contain only letters (a-z, A-Z), numbers (0-9),
|
|
61
62
|
# or underscores (_). The maximum length is 1,024 characters.
|
|
62
63
|
#
|
|
63
|
-
#
|
|
64
|
+
# @!group Attributes
|
|
64
65
|
#
|
|
65
66
|
def dataset_id
|
|
66
67
|
@gapi["datasetReference"]["datasetId"]
|
|
@@ -69,16 +70,17 @@ module Gcloud
|
|
|
69
70
|
##
|
|
70
71
|
# The ID of the project containing this dataset.
|
|
71
72
|
#
|
|
72
|
-
#
|
|
73
|
+
# @!group Attributes
|
|
73
74
|
#
|
|
74
75
|
def project_id
|
|
75
76
|
@gapi["datasetReference"]["projectId"]
|
|
76
77
|
end
|
|
77
78
|
|
|
78
79
|
##
|
|
80
|
+
# @private
|
|
79
81
|
# The gapi fragment containing the Project ID and Dataset ID as a
|
|
80
82
|
# camel-cased hash.
|
|
81
|
-
def dataset_ref
|
|
83
|
+
def dataset_ref
|
|
82
84
|
dataset_ref = @gapi["datasetReference"]
|
|
83
85
|
dataset_ref = dataset_ref.to_hash if dataset_ref.respond_to? :to_hash
|
|
84
86
|
dataset_ref
|
|
@@ -87,7 +89,7 @@ module Gcloud
|
|
|
87
89
|
##
|
|
88
90
|
# A descriptive name for the dataset.
|
|
89
91
|
#
|
|
90
|
-
#
|
|
92
|
+
# @!group Attributes
|
|
91
93
|
#
|
|
92
94
|
def name
|
|
93
95
|
@gapi["friendlyName"]
|
|
@@ -96,7 +98,7 @@ module Gcloud
|
|
|
96
98
|
##
|
|
97
99
|
# Updates the descriptive name for the dataset.
|
|
98
100
|
#
|
|
99
|
-
#
|
|
101
|
+
# @!group Attributes
|
|
100
102
|
#
|
|
101
103
|
def name= new_name
|
|
102
104
|
patch_gapi! name: new_name
|
|
@@ -105,7 +107,7 @@ module Gcloud
|
|
|
105
107
|
##
|
|
106
108
|
# A string hash of the dataset.
|
|
107
109
|
#
|
|
108
|
-
#
|
|
110
|
+
# @!group Attributes
|
|
109
111
|
#
|
|
110
112
|
def etag
|
|
111
113
|
ensure_full_data!
|
|
@@ -115,7 +117,7 @@ module Gcloud
|
|
|
115
117
|
##
|
|
116
118
|
# A URL that can be used to access the dataset using the REST API.
|
|
117
119
|
#
|
|
118
|
-
#
|
|
120
|
+
# @!group Attributes
|
|
119
121
|
#
|
|
120
122
|
def api_url
|
|
121
123
|
ensure_full_data!
|
|
@@ -125,7 +127,7 @@ module Gcloud
|
|
|
125
127
|
##
|
|
126
128
|
# A user-friendly description of the dataset.
|
|
127
129
|
#
|
|
128
|
-
#
|
|
130
|
+
# @!group Attributes
|
|
129
131
|
#
|
|
130
132
|
def description
|
|
131
133
|
ensure_full_data!
|
|
@@ -135,7 +137,7 @@ module Gcloud
|
|
|
135
137
|
##
|
|
136
138
|
# Updates the user-friendly description of the dataset.
|
|
137
139
|
#
|
|
138
|
-
#
|
|
140
|
+
# @!group Attributes
|
|
139
141
|
#
|
|
140
142
|
def description= new_description
|
|
141
143
|
patch_gapi! description: new_description
|
|
@@ -144,7 +146,7 @@ module Gcloud
|
|
|
144
146
|
##
|
|
145
147
|
# The default lifetime of all tables in the dataset, in milliseconds.
|
|
146
148
|
#
|
|
147
|
-
#
|
|
149
|
+
# @!group Attributes
|
|
148
150
|
#
|
|
149
151
|
def default_expiration
|
|
150
152
|
ensure_full_data!
|
|
@@ -155,7 +157,7 @@ module Gcloud
|
|
|
155
157
|
# Updates the default lifetime of all tables in the dataset, in
|
|
156
158
|
# milliseconds.
|
|
157
159
|
#
|
|
158
|
-
#
|
|
160
|
+
# @!group Attributes
|
|
159
161
|
#
|
|
160
162
|
def default_expiration= new_default_expiration
|
|
161
163
|
patch_gapi! default_expiration: new_default_expiration
|
|
@@ -164,7 +166,7 @@ module Gcloud
|
|
|
164
166
|
##
|
|
165
167
|
# The time when this dataset was created.
|
|
166
168
|
#
|
|
167
|
-
#
|
|
169
|
+
# @!group Attributes
|
|
168
170
|
#
|
|
169
171
|
def created_at
|
|
170
172
|
ensure_full_data!
|
|
@@ -174,7 +176,7 @@ module Gcloud
|
|
|
174
176
|
##
|
|
175
177
|
# The date when this dataset or any of its tables was last modified.
|
|
176
178
|
#
|
|
177
|
-
#
|
|
179
|
+
# @!group Attributes
|
|
178
180
|
#
|
|
179
181
|
def modified_at
|
|
180
182
|
ensure_full_data!
|
|
@@ -185,7 +187,7 @@ module Gcloud
|
|
|
185
187
|
# The geographic location where the dataset should reside. Possible
|
|
186
188
|
# values include EU and US. The default value is US.
|
|
187
189
|
#
|
|
188
|
-
#
|
|
190
|
+
# @!group Attributes
|
|
189
191
|
#
|
|
190
192
|
def location
|
|
191
193
|
ensure_full_data!
|
|
@@ -195,13 +197,16 @@ module Gcloud
|
|
|
195
197
|
##
|
|
196
198
|
# Retrieves the access rules for a Dataset using the Google Cloud
|
|
197
199
|
# Datastore API data structure of an array of hashes. The rules can be
|
|
198
|
-
# updated when passing a block, see Dataset::Access for all the methods
|
|
199
|
-
# available.
|
|
200
|
-
#
|
|
201
|
-
#
|
|
200
|
+
# updated when passing a block, see {Dataset::Access} for all the methods
|
|
201
|
+
# available.
|
|
202
|
+
#
|
|
203
|
+
# @see https://cloud.google.com/bigquery/access-control BigQuery Access
|
|
204
|
+
# Control
|
|
202
205
|
#
|
|
203
|
-
#
|
|
206
|
+
# @yield [access] a block for setting rules
|
|
207
|
+
# @yieldparam [Dataset::Access] access the object accepting rules
|
|
204
208
|
#
|
|
209
|
+
# @example
|
|
205
210
|
# require "gcloud"
|
|
206
211
|
#
|
|
207
212
|
# gcloud = Gcloud.new
|
|
@@ -217,8 +222,7 @@ module Gcloud
|
|
|
217
222
|
# # {"role"=>"OWNER",
|
|
218
223
|
# # "userByEmail"=>"123456789-...com"}]
|
|
219
224
|
#
|
|
220
|
-
# Manage the access rules by passing a block
|
|
221
|
-
#
|
|
225
|
+
# @example Manage the access rules by passing a block:
|
|
222
226
|
# require "gcloud"
|
|
223
227
|
#
|
|
224
228
|
# gcloud = Gcloud.new
|
|
@@ -246,16 +250,15 @@ module Gcloud
|
|
|
246
250
|
|
|
247
251
|
##
|
|
248
252
|
# Sets the access rules for a Dataset using the Google Cloud Datastore API
|
|
249
|
-
# data structure of an array of hashes. See
|
|
250
|
-
# Control
|
|
253
|
+
# data structure of an array of hashes. See [BigQuery Access
|
|
254
|
+
# Control](https://cloud.google.com/bigquery/access-control) for more
|
|
251
255
|
# information.
|
|
252
256
|
#
|
|
253
257
|
# This method is provided for advanced usage of managing the access rules.
|
|
254
|
-
# Calling #access with a block is the preferred way to manage access
|
|
258
|
+
# Calling {#access} with a block is the preferred way to manage access
|
|
255
259
|
# rules.
|
|
256
260
|
#
|
|
257
|
-
#
|
|
258
|
-
#
|
|
261
|
+
# @example
|
|
259
262
|
# require "gcloud"
|
|
260
263
|
#
|
|
261
264
|
# gcloud = Gcloud.new
|
|
@@ -277,21 +280,15 @@ module Gcloud
|
|
|
277
280
|
|
|
278
281
|
##
|
|
279
282
|
# Permanently deletes the dataset. The dataset must be empty before it can
|
|
280
|
-
# be deleted unless the
|
|
283
|
+
# be deleted unless the `force` option is set to `true`.
|
|
281
284
|
#
|
|
282
|
-
#
|
|
285
|
+
# @param [Boolean] force If `true`, delete all the tables in the dataset.
|
|
286
|
+
# If `false` and the dataset contains tables, the request will fail.
|
|
287
|
+
# Default is `false`.
|
|
283
288
|
#
|
|
284
|
-
#
|
|
285
|
-
# If +true+, delete all the tables in the dataset. If +false+ and the
|
|
286
|
-
# dataset contains tables, the request will fail. Default is +false+.
|
|
287
|
-
# (+Boolean+)
|
|
288
|
-
#
|
|
289
|
-
# === Returns
|
|
290
|
-
#
|
|
291
|
-
# +true+ if the dataset was deleted.
|
|
292
|
-
#
|
|
293
|
-
# === Example
|
|
289
|
+
# @return [Boolean] Returns `true` if the dataset was deleted.
|
|
294
290
|
#
|
|
291
|
+
# @example
|
|
295
292
|
# require "gcloud"
|
|
296
293
|
#
|
|
297
294
|
# gcloud = Gcloud.new
|
|
@@ -300,7 +297,7 @@ module Gcloud
|
|
|
300
297
|
# dataset = bigquery.dataset "my_dataset"
|
|
301
298
|
# dataset.delete
|
|
302
299
|
#
|
|
303
|
-
#
|
|
300
|
+
# @!group Lifecycle
|
|
304
301
|
#
|
|
305
302
|
def delete force: nil
|
|
306
303
|
ensure_connection!
|
|
@@ -313,31 +310,27 @@ module Gcloud
|
|
|
313
310
|
end
|
|
314
311
|
|
|
315
312
|
##
|
|
316
|
-
# Creates a new table.
|
|
317
|
-
#
|
|
318
|
-
#
|
|
319
|
-
#
|
|
320
|
-
#
|
|
321
|
-
#
|
|
322
|
-
# numbers (0-9), or underscores (_). The maximum
|
|
323
|
-
# characters.
|
|
324
|
-
#
|
|
325
|
-
#
|
|
326
|
-
#
|
|
327
|
-
# A
|
|
328
|
-
#
|
|
329
|
-
#
|
|
330
|
-
#
|
|
331
|
-
#
|
|
332
|
-
#
|
|
333
|
-
#
|
|
334
|
-
#
|
|
335
|
-
#
|
|
336
|
-
#
|
|
337
|
-
# Gcloud::Bigquery::Table
|
|
338
|
-
#
|
|
339
|
-
# === Examples
|
|
340
|
-
#
|
|
313
|
+
# Creates a new table. If you are adapting existing code that was written
|
|
314
|
+
# for the [Rest API
|
|
315
|
+
# ](https://cloud.google.com/bigquery/docs/reference/v2/tables#resource),
|
|
316
|
+
# you can pass the table's schema as a hash (see example.)
|
|
317
|
+
#
|
|
318
|
+
# @param [String] table_id The ID of the table. The ID must contain only
|
|
319
|
+
# letters (a-z, A-Z), numbers (0-9), or underscores (_). The maximum
|
|
320
|
+
# length is 1,024 characters.
|
|
321
|
+
# @param [String] name A descriptive name for the table.
|
|
322
|
+
# @param [String] description A user-friendly description of the table.
|
|
323
|
+
# @param [Hash] schema A hash specifying fields and data types for the
|
|
324
|
+
# table. A block may be passed instead (see examples.) For the format of
|
|
325
|
+
# this hash, see the [Tables resource
|
|
326
|
+
# ](https://cloud.google.com/bigquery/docs/reference/v2/tables#resource)
|
|
327
|
+
# .
|
|
328
|
+
# @yield [schema] a block for setting the schema
|
|
329
|
+
# @yieldparam [Table::Schema] schema the object accepting the schema
|
|
330
|
+
#
|
|
331
|
+
# @return [Gcloud::Bigquery::Table]
|
|
332
|
+
#
|
|
333
|
+
# @example
|
|
341
334
|
# require "gcloud"
|
|
342
335
|
#
|
|
343
336
|
# gcloud = Gcloud.new
|
|
@@ -345,8 +338,7 @@ module Gcloud
|
|
|
345
338
|
# dataset = bigquery.dataset "my_dataset"
|
|
346
339
|
# table = dataset.create_table "my_table"
|
|
347
340
|
#
|
|
348
|
-
# You can also pass name and description options.
|
|
349
|
-
#
|
|
341
|
+
# @example You can also pass name and description options.
|
|
350
342
|
# require "gcloud"
|
|
351
343
|
#
|
|
352
344
|
# gcloud = Gcloud.new
|
|
@@ -356,8 +348,7 @@ module Gcloud
|
|
|
356
348
|
# name: "My Table",
|
|
357
349
|
# description: "A description of my table."
|
|
358
350
|
#
|
|
359
|
-
# You can define the table's schema using a block.
|
|
360
|
-
#
|
|
351
|
+
# @example You can define the table's schema using a block.
|
|
361
352
|
# require "gcloud"
|
|
362
353
|
#
|
|
363
354
|
# gcloud = Gcloud.new
|
|
@@ -371,10 +362,7 @@ module Gcloud
|
|
|
371
362
|
# end
|
|
372
363
|
# end
|
|
373
364
|
#
|
|
374
|
-
#
|
|
375
|
-
# }[https://cloud.google.com/bigquery/docs/reference/v2/tables#resource],
|
|
376
|
-
# you can pass the table's schema as a hash.
|
|
377
|
-
#
|
|
365
|
+
# @example You can pass the table's schema as a hash.
|
|
378
366
|
# require "gcloud"
|
|
379
367
|
#
|
|
380
368
|
# gcloud = Gcloud.new
|
|
@@ -409,7 +397,7 @@ module Gcloud
|
|
|
409
397
|
# }
|
|
410
398
|
# table = dataset.create_table "my_table", schema: schema
|
|
411
399
|
#
|
|
412
|
-
#
|
|
400
|
+
# @!group Table
|
|
413
401
|
#
|
|
414
402
|
def create_table table_id, name: nil, description: nil, schema: nil
|
|
415
403
|
ensure_connection!
|
|
@@ -428,26 +416,17 @@ module Gcloud
|
|
|
428
416
|
##
|
|
429
417
|
# Creates a new view table from the given query.
|
|
430
418
|
#
|
|
431
|
-
#
|
|
432
|
-
#
|
|
433
|
-
#
|
|
434
|
-
#
|
|
435
|
-
#
|
|
436
|
-
#
|
|
437
|
-
#
|
|
438
|
-
# The query that BigQuery executes when the view is referenced.
|
|
439
|
-
# (+String+)
|
|
440
|
-
# +name+::
|
|
441
|
-
# A descriptive name for the table. (+String+)
|
|
442
|
-
# +description+::
|
|
443
|
-
# A user-friendly description of the table. (+String+)
|
|
419
|
+
# @param [String] table_id The ID of the view table. The ID must contain
|
|
420
|
+
# only letters (a-z, A-Z), numbers (0-9), or underscores (_). The
|
|
421
|
+
# maximum length is 1,024 characters.
|
|
422
|
+
# @param [String] query The query that BigQuery executes when the view is
|
|
423
|
+
# referenced.
|
|
424
|
+
# @param [String] name A descriptive name for the table.
|
|
425
|
+
# @param [String] description A user-friendly description of the table.
|
|
444
426
|
#
|
|
445
|
-
#
|
|
446
|
-
#
|
|
447
|
-
# Gcloud::Bigquery::View
|
|
448
|
-
#
|
|
449
|
-
# === Examples
|
|
427
|
+
# @return [Gcloud::Bigquery::View]
|
|
450
428
|
#
|
|
429
|
+
# @example
|
|
451
430
|
# require "gcloud"
|
|
452
431
|
#
|
|
453
432
|
# gcloud = Gcloud.new
|
|
@@ -456,8 +435,7 @@ module Gcloud
|
|
|
456
435
|
# view = dataset.create_view "my_view",
|
|
457
436
|
# "SELECT name, age FROM [proj:dataset.users]"
|
|
458
437
|
#
|
|
459
|
-
# A name and description can be provided:
|
|
460
|
-
#
|
|
438
|
+
# @example A name and description can be provided:
|
|
461
439
|
# require "gcloud"
|
|
462
440
|
#
|
|
463
441
|
# gcloud = Gcloud.new
|
|
@@ -467,7 +445,7 @@ module Gcloud
|
|
|
467
445
|
# "SELECT name, age FROM [proj:dataset.users]",
|
|
468
446
|
# name: "My View", description: "This is my view"
|
|
469
447
|
#
|
|
470
|
-
#
|
|
448
|
+
# @!group Table
|
|
471
449
|
#
|
|
472
450
|
def create_view table_id, query, name: nil, description: nil
|
|
473
451
|
options = { query: query, name: name, description: description }
|
|
@@ -477,18 +455,12 @@ module Gcloud
|
|
|
477
455
|
##
|
|
478
456
|
# Retrieves an existing table by ID.
|
|
479
457
|
#
|
|
480
|
-
#
|
|
481
|
-
#
|
|
482
|
-
# +table_id+::
|
|
483
|
-
# The ID of a table. (+String+)
|
|
484
|
-
#
|
|
485
|
-
# === Returns
|
|
458
|
+
# @param [String] table_id The ID of a table.
|
|
486
459
|
#
|
|
487
|
-
# Gcloud::Bigquery::Table
|
|
488
|
-
# does not exist
|
|
489
|
-
#
|
|
490
|
-
# === Example
|
|
460
|
+
# @return [Gcloud::Bigquery::Table, Gcloud::Bigquery::View, nil] Returns
|
|
461
|
+
# `nil` if the table does not exist
|
|
491
462
|
#
|
|
463
|
+
# @example
|
|
492
464
|
# require "gcloud"
|
|
493
465
|
#
|
|
494
466
|
# gcloud = Gcloud.new
|
|
@@ -497,7 +469,7 @@ module Gcloud
|
|
|
497
469
|
# table = dataset.table "my_table"
|
|
498
470
|
# puts table.name
|
|
499
471
|
#
|
|
500
|
-
#
|
|
472
|
+
# @!group Table
|
|
501
473
|
#
|
|
502
474
|
def table table_id
|
|
503
475
|
ensure_connection!
|
|
@@ -512,21 +484,14 @@ module Gcloud
|
|
|
512
484
|
##
|
|
513
485
|
# Retrieves the list of tables belonging to the dataset.
|
|
514
486
|
#
|
|
515
|
-
#
|
|
516
|
-
#
|
|
517
|
-
#
|
|
518
|
-
# A previously-returned page token representing part of the larger set
|
|
519
|
-
# of results to view. (+String+)
|
|
520
|
-
# +max+::
|
|
521
|
-
# Maximum number of tables to return. (+Integer+)
|
|
522
|
-
#
|
|
523
|
-
# === Returns
|
|
524
|
-
#
|
|
525
|
-
# Array of Gcloud::Bigquery::Table or Gcloud::Bigquery::View
|
|
526
|
-
# (See Gcloud::Bigquery::Table::List)
|
|
487
|
+
# @param [String] token A previously-returned page token representing part
|
|
488
|
+
# of the larger set of results to view.
|
|
489
|
+
# @param [Integer] max Maximum number of tables to return.
|
|
527
490
|
#
|
|
528
|
-
#
|
|
491
|
+
# @return [Array<Gcloud::Bigquery::Table>, Array<Gcloud::Bigquery::View>]
|
|
492
|
+
# (See {Gcloud::Bigquery::Table::List})
|
|
529
493
|
#
|
|
494
|
+
# @example
|
|
530
495
|
# require "gcloud"
|
|
531
496
|
#
|
|
532
497
|
# gcloud = Gcloud.new
|
|
@@ -537,9 +502,7 @@ module Gcloud
|
|
|
537
502
|
# puts table.name
|
|
538
503
|
# end
|
|
539
504
|
#
|
|
540
|
-
#
|
|
541
|
-
# through them: (See Dataset::List#token)
|
|
542
|
-
#
|
|
505
|
+
# @example With pagination: (See {Dataset::List#token})
|
|
543
506
|
# require "gcloud"
|
|
544
507
|
#
|
|
545
508
|
# gcloud = Gcloud.new
|
|
@@ -558,7 +521,7 @@ module Gcloud
|
|
|
558
521
|
# tmp_tables = dataset.tables token: tmp_tables.token
|
|
559
522
|
# end
|
|
560
523
|
#
|
|
561
|
-
#
|
|
524
|
+
# @!group Table
|
|
562
525
|
#
|
|
563
526
|
def tables token: nil, max: nil
|
|
564
527
|
ensure_connection!
|
|
@@ -572,61 +535,54 @@ module Gcloud
|
|
|
572
535
|
end
|
|
573
536
|
|
|
574
537
|
##
|
|
575
|
-
# Queries data using the
|
|
576
|
-
# method
|
|
538
|
+
# Queries data using the [asynchronous
|
|
539
|
+
# method](https://cloud.google.com/bigquery/querying-data).
|
|
577
540
|
#
|
|
578
541
|
# Sets the current dataset as the default dataset in the query. Useful for
|
|
579
542
|
# using unqualified table names.
|
|
580
543
|
#
|
|
581
|
-
#
|
|
582
|
-
#
|
|
583
|
-
# +query+::
|
|
584
|
-
# A query string, following the BigQuery {query
|
|
585
|
-
# syntax}[https://cloud.google.com/bigquery/query-reference], of the
|
|
544
|
+
# @param [String] query A query string, following the BigQuery [query
|
|
545
|
+
# syntax](https://cloud.google.com/bigquery/query-reference), of the
|
|
586
546
|
# query to execute. Example: "SELECT count(f1) FROM
|
|
587
|
-
# [myProjectId:myDatasetId.myTableId]".
|
|
588
|
-
#
|
|
589
|
-
#
|
|
590
|
-
#
|
|
591
|
-
#
|
|
592
|
-
#
|
|
593
|
-
#
|
|
594
|
-
#
|
|
595
|
-
#
|
|
596
|
-
#
|
|
597
|
-
#
|
|
598
|
-
#
|
|
599
|
-
#
|
|
600
|
-
#
|
|
547
|
+
# [myProjectId:myDatasetId.myTableId]".
|
|
548
|
+
# @param [String] priority Specifies a priority for the query. Possible
|
|
549
|
+
# values include `INTERACTIVE` and `BATCH`. The default value is
|
|
550
|
+
# `INTERACTIVE`.
|
|
551
|
+
# @param [Boolean] cache Whether to look for the result in the query
|
|
552
|
+
# cache. The query cache is a best-effort cache that will be flushed
|
|
553
|
+
# whenever tables in the query are modified. The default value is true.
|
|
554
|
+
# For more information, see [query
|
|
555
|
+
# caching](https://developers.google.com/bigquery/querying-data).
|
|
556
|
+
# @param [Table] table The destination table where the query results
|
|
557
|
+
# should be stored. If not present, a new table will be created to store
|
|
558
|
+
# the results.
|
|
559
|
+
# @param [String] create Specifies whether the job is allowed to create
|
|
560
|
+
# new tables.
|
|
601
561
|
#
|
|
602
562
|
# The following values are supported:
|
|
603
|
-
#
|
|
604
|
-
# *
|
|
563
|
+
#
|
|
564
|
+
# * `needed` - Create the table if it does not exist.
|
|
565
|
+
# * `never` - The table must already exist. A 'notFound' error is
|
|
605
566
|
# raised if the table does not exist.
|
|
606
|
-
#
|
|
607
|
-
#
|
|
608
|
-
# exists. (+String+)
|
|
567
|
+
# @param [String] write Specifies the action that occurs if the
|
|
568
|
+
# destination table already exists.
|
|
609
569
|
#
|
|
610
570
|
# The following values are supported:
|
|
611
|
-
# * +truncate+ - BigQuery overwrites the table data.
|
|
612
|
-
# * +append+ - BigQuery appends the data to the table.
|
|
613
|
-
# * +empty+ - A 'duplicate' error is returned in the job result if the
|
|
614
|
-
# table exists and contains data.
|
|
615
|
-
# +large_results+::
|
|
616
|
-
# If +true+, allows the query to produce arbitrarily large result tables
|
|
617
|
-
# at a slight cost in performance. Requires +table+ parameter to be set.
|
|
618
|
-
# (+Boolean+)
|
|
619
|
-
# +flatten+::
|
|
620
|
-
# Flattens all nested and repeated fields in the query results. The
|
|
621
|
-
# default value is +true+. +large_results+ parameter must be +true+ if
|
|
622
|
-
# this is set to +false+. (+Boolean+)
|
|
623
571
|
#
|
|
624
|
-
#
|
|
625
|
-
#
|
|
626
|
-
#
|
|
572
|
+
# * `truncate` - BigQuery overwrites the table data.
|
|
573
|
+
# * `append` - BigQuery appends the data to the table.
|
|
574
|
+
# * `empty` - A 'duplicate' error is returned in the job result if the
|
|
575
|
+
# table exists and contains data.
|
|
576
|
+
# @param [Boolean] large_results If `true`, allows the query to produce
|
|
577
|
+
# arbitrarily large result tables at a slight cost in performance.
|
|
578
|
+
# Requires `table` parameter to be set.
|
|
579
|
+
# @param [Boolean] flatten Flattens all nested and repeated fields in the
|
|
580
|
+
# query results. The default value is `true`. `large_results` parameter
|
|
581
|
+
# must be `true` if this is set to `false`.
|
|
627
582
|
#
|
|
628
|
-
#
|
|
583
|
+
# @return [Gcloud::Bigquery::QueryJob]
|
|
629
584
|
#
|
|
585
|
+
# @example
|
|
630
586
|
# require "gcloud"
|
|
631
587
|
#
|
|
632
588
|
# gcloud = Gcloud.new
|
|
@@ -641,7 +597,7 @@ module Gcloud
|
|
|
641
597
|
# end
|
|
642
598
|
# end
|
|
643
599
|
#
|
|
644
|
-
#
|
|
600
|
+
# @!group Data
|
|
645
601
|
#
|
|
646
602
|
def query_job query, priority: "INTERACTIVE", cache: true, table: nil,
|
|
647
603
|
create: nil, write: nil, large_results: nil, flatten: nil
|
|
@@ -659,51 +615,41 @@ module Gcloud
|
|
|
659
615
|
end
|
|
660
616
|
|
|
661
617
|
##
|
|
662
|
-
# Queries data using the
|
|
663
|
-
# method
|
|
618
|
+
# Queries data using the [synchronous
|
|
619
|
+
# method](https://cloud.google.com/bigquery/querying-data).
|
|
664
620
|
#
|
|
665
621
|
# Sets the current dataset as the default dataset in the query. Useful for
|
|
666
622
|
# using unqualified table names.
|
|
667
623
|
#
|
|
668
|
-
#
|
|
669
|
-
#
|
|
670
|
-
# +query+::
|
|
671
|
-
# A query string, following the BigQuery {query
|
|
672
|
-
# syntax}[https://cloud.google.com/bigquery/query-reference], of the
|
|
624
|
+
# @param [String] query A query string, following the BigQuery [query
|
|
625
|
+
# syntax](https://cloud.google.com/bigquery/query-reference), of the
|
|
673
626
|
# query to execute. Example: "SELECT count(f1) FROM
|
|
674
|
-
# [myProjectId:myDatasetId.myTableId]".
|
|
675
|
-
#
|
|
676
|
-
#
|
|
677
|
-
#
|
|
678
|
-
#
|
|
679
|
-
#
|
|
680
|
-
#
|
|
681
|
-
#
|
|
682
|
-
#
|
|
683
|
-
#
|
|
684
|
-
#
|
|
685
|
-
#
|
|
686
|
-
#
|
|
687
|
-
#
|
|
688
|
-
#
|
|
689
|
-
#
|
|
690
|
-
#
|
|
691
|
-
#
|
|
692
|
-
#
|
|
693
|
-
# The default value is
|
|
694
|
-
#
|
|
695
|
-
#
|
|
696
|
-
#
|
|
697
|
-
#
|
|
698
|
-
#
|
|
699
|
-
#
|
|
700
|
-
#
|
|
701
|
-
# === Returns
|
|
702
|
-
#
|
|
703
|
-
# Gcloud::Bigquery::QueryData
|
|
704
|
-
#
|
|
705
|
-
# === Example
|
|
706
|
-
#
|
|
627
|
+
# [myProjectId:myDatasetId.myTableId]".
|
|
628
|
+
# @param [Integer] max The maximum number of rows of data to return per
|
|
629
|
+
# page of results. Setting this flag to a small value such as 1000 and
|
|
630
|
+
# then paging through results might improve reliability when the query
|
|
631
|
+
# result set is large. In addition to this limit, responses are also
|
|
632
|
+
# limited to 10 MB. By default, there is no maximum row count, and only
|
|
633
|
+
# the byte limit applies.
|
|
634
|
+
# @param [Integer] timeout How long to wait for the query to complete, in
|
|
635
|
+
# milliseconds, before the request times out and returns. Note that this
|
|
636
|
+
# is only a timeout for the request, not the query. If the query takes
|
|
637
|
+
# longer to run than the timeout value, the call returns without any
|
|
638
|
+
# results and with QueryData#complete? set to false. The default value
|
|
639
|
+
# is 10000 milliseconds (10 seconds).
|
|
640
|
+
# @param [Boolean] dryrun If set to `true`, BigQuery doesn't run the job.
|
|
641
|
+
# Instead, if the query is valid, BigQuery returns statistics about the
|
|
642
|
+
# job such as how many bytes would be processed. If the query is
|
|
643
|
+
# invalid, an error returns. The default value is `false`.
|
|
644
|
+
# @param [Boolean] cache Whether to look for the result in the query
|
|
645
|
+
# cache. The query cache is a best-effort cache that will be flushed
|
|
646
|
+
# whenever tables in the query are modified. The default value is true.
|
|
647
|
+
# For more information, see [query
|
|
648
|
+
# caching](https://developers.google.com/bigquery/querying-data).
|
|
649
|
+
#
|
|
650
|
+
# @return [Gcloud::Bigquery::QueryData]
|
|
651
|
+
#
|
|
652
|
+
# @example
|
|
707
653
|
# require "gcloud"
|
|
708
654
|
#
|
|
709
655
|
# gcloud = Gcloud.new
|
|
@@ -714,7 +660,7 @@ module Gcloud
|
|
|
714
660
|
# puts row["name"]
|
|
715
661
|
# end
|
|
716
662
|
#
|
|
717
|
-
#
|
|
663
|
+
# @!group Data
|
|
718
664
|
#
|
|
719
665
|
def query query, max: nil, timeout: 10000, dryrun: nil, cache: true
|
|
720
666
|
options = { max: max, timeout: timeout, dryrun: dryrun, cache: cache }
|
|
@@ -730,8 +676,8 @@ module Gcloud
|
|
|
730
676
|
end
|
|
731
677
|
|
|
732
678
|
##
|
|
733
|
-
# New Dataset from a Google API Client object.
|
|
734
|
-
def self.from_gapi gapi, conn
|
|
679
|
+
# @private New Dataset from a Google API Client object.
|
|
680
|
+
def self.from_gapi gapi, conn
|
|
735
681
|
new.tap do |f|
|
|
736
682
|
f.gapi = gapi
|
|
737
683
|
f.connection = conn
|