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,16 +12,17 @@
|
|
|
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/version"
|
|
17
17
|
require "google/api_client"
|
|
18
18
|
|
|
19
19
|
module Gcloud
|
|
20
20
|
module Search
|
|
21
21
|
##
|
|
22
|
-
# Temporary substitute for Google::APIClient. Once the Search API
|
|
23
|
-
# discoverable, initialization of this class in Connection should be
|
|
22
|
+
# @private Temporary substitute for Google::APIClient. Once the Search API
|
|
23
|
+
# is discoverable, initialization of this class in Connection should be
|
|
24
24
|
# replaced with the Google API Client.
|
|
25
|
-
class APIClient
|
|
25
|
+
class APIClient
|
|
26
26
|
attr_accessor :authorization, :connection
|
|
27
27
|
|
|
28
28
|
##
|
|
@@ -50,7 +50,7 @@ module Gcloud
|
|
|
50
50
|
|
|
51
51
|
##
|
|
52
52
|
# Return type for APIClient#discovered_api
|
|
53
|
-
class DiscoveredApi
|
|
53
|
+
class DiscoveredApi
|
|
54
54
|
def initialize name, version
|
|
55
55
|
@name = name
|
|
56
56
|
@version = version
|
|
@@ -70,7 +70,7 @@ module Gcloud
|
|
|
70
70
|
|
|
71
71
|
##
|
|
72
72
|
# Return type for DiscoveredApi http verb methods
|
|
73
|
-
class ResourcePath
|
|
73
|
+
class ResourcePath
|
|
74
74
|
def initialize api_name, api_version, resource_root, resource_id_param
|
|
75
75
|
@root = "https://#{api_name}.googleapis.com/#{api_version}" \
|
|
76
76
|
"/projects/{projectId}/#{resource_root}"
|
|
@@ -100,7 +100,7 @@ module Gcloud
|
|
|
100
100
|
|
|
101
101
|
##
|
|
102
102
|
# Special-case return type for DiscoveredApi http search verb method
|
|
103
|
-
class IndexResourcePath < ResourcePath
|
|
103
|
+
class IndexResourcePath < ResourcePath
|
|
104
104
|
def search
|
|
105
105
|
api_method :get, "/{indexId}/search"
|
|
106
106
|
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,25 +12,26 @@
|
|
|
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/version"
|
|
17
17
|
require "gcloud/search/api_client"
|
|
18
18
|
|
|
19
19
|
module Gcloud
|
|
20
20
|
module Search
|
|
21
21
|
##
|
|
22
|
-
# Represents the connection to Search,
|
|
22
|
+
# @private Represents the connection to Search,
|
|
23
23
|
# as well as expose the API calls.
|
|
24
|
-
class Connection
|
|
24
|
+
class Connection
|
|
25
25
|
API_VERSION = "v1"
|
|
26
26
|
|
|
27
27
|
attr_accessor :project
|
|
28
|
-
attr_accessor :credentials
|
|
29
|
-
attr_accessor :client
|
|
30
|
-
attr_accessor :connection
|
|
28
|
+
attr_accessor :credentials
|
|
29
|
+
attr_accessor :client
|
|
30
|
+
attr_accessor :connection
|
|
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_config = {
|
|
@@ -120,7 +120,7 @@ module Gcloud
|
|
|
120
120
|
)
|
|
121
121
|
end
|
|
122
122
|
|
|
123
|
-
def inspect
|
|
123
|
+
def inspect
|
|
124
124
|
"#{self.class}(#{@project})"
|
|
125
125
|
end
|
|
126
126
|
|
|
@@ -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 Search
|
|
20
20
|
##
|
|
21
|
-
# Represents the Oauth2 signing logic for Search.
|
|
22
|
-
class Credentials < Gcloud::Credentials
|
|
21
|
+
# @private Represents the Oauth2 signing logic for Search.
|
|
22
|
+
class Credentials < Gcloud::Credentials
|
|
23
23
|
SCOPE = ["https://www.googleapis.com/auth/cloudsearch",
|
|
24
24
|
"https://www.googleapis.com/auth/userinfo.email"]
|
|
25
25
|
PATH_ENV_VARS = %w(SEARCH_KEYFILE GCLOUD_KEYFILE GOOGLE_CLOUD_KEYFILE)
|
|
@@ -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/search/document/list"
|
|
17
17
|
require "gcloud/search/connection"
|
|
18
18
|
require "gcloud/search/fields"
|
|
@@ -20,14 +20,16 @@ require "gcloud/search/fields"
|
|
|
20
20
|
module Gcloud
|
|
21
21
|
module Search
|
|
22
22
|
##
|
|
23
|
-
#
|
|
23
|
+
# # Document
|
|
24
24
|
#
|
|
25
25
|
# A document is an object that stores data that can be searched. Each
|
|
26
|
-
# document has a #doc_id that is
|
|
27
|
-
#
|
|
28
|
-
# data. Its field
|
|
29
|
-
#
|
|
26
|
+
# document has a {Gcloud::Search::Document#doc_id} that is unique within its
|
|
27
|
+
# index, a {Gcloud::Search::Document#rank}, and a list of
|
|
28
|
+
# {Gcloud::Search::Document#fields} that contain typed data. Its field
|
|
29
|
+
# values can be accessed through hash-like methods such as
|
|
30
|
+
# {Gcloud::Search::Document#[]} and {Gcloud::Search::Document#each}.
|
|
30
31
|
#
|
|
32
|
+
# @example
|
|
31
33
|
# require "gcloud"
|
|
32
34
|
#
|
|
33
35
|
# gcloud = Gcloud.new
|
|
@@ -40,22 +42,23 @@ module Gcloud
|
|
|
40
42
|
# document.rank #=> 1443648166
|
|
41
43
|
# document["price"] #=> 24.95
|
|
42
44
|
#
|
|
43
|
-
#
|
|
44
|
-
#
|
|
45
|
+
# @see https://cloud.google.com/search/documents_indexes Documents and
|
|
46
|
+
# Indexes
|
|
45
47
|
#
|
|
46
48
|
class Document
|
|
47
49
|
##
|
|
48
|
-
# Creates a new Document instance.
|
|
50
|
+
# @private Creates a new Document instance.
|
|
49
51
|
#
|
|
50
|
-
def initialize
|
|
52
|
+
def initialize
|
|
51
53
|
@fields = Fields.new
|
|
52
54
|
@raw = {}
|
|
53
55
|
end
|
|
54
56
|
|
|
55
57
|
##
|
|
56
58
|
# The unique identifier for the document. Can be set explicitly when the
|
|
57
|
-
# document is saved. (See Index#document and
|
|
58
|
-
#
|
|
59
|
+
# document is saved. (See {Gcloud::Search::Index#document} and
|
|
60
|
+
# {Gcloud::Search::Document#doc_id=}.) If missing, it is automatically
|
|
61
|
+
# assigned to the document when saved.
|
|
59
62
|
def doc_id
|
|
60
63
|
@raw["docId"]
|
|
61
64
|
end
|
|
@@ -74,8 +77,9 @@ module Gcloud
|
|
|
74
77
|
##
|
|
75
78
|
# A positive integer which determines the default ordering of documents
|
|
76
79
|
# returned from a search. The rank can be set explicitly when the document
|
|
77
|
-
# is saved. (See Index#document and
|
|
78
|
-
#
|
|
80
|
+
# is saved. (See {Gcloud::Search::Index#document} and
|
|
81
|
+
# {Gcloud::Search::Document#rank=}.) If missing, it is automatically
|
|
82
|
+
# assigned to the document when saved.
|
|
79
83
|
def rank
|
|
80
84
|
@raw["rank"]
|
|
81
85
|
end
|
|
@@ -83,12 +87,12 @@ module Gcloud
|
|
|
83
87
|
##
|
|
84
88
|
# Sets the rank of the document.
|
|
85
89
|
#
|
|
86
|
-
# The same rank should not be assigned to many documents, and should
|
|
87
|
-
#
|
|
88
|
-
#
|
|
89
|
-
#
|
|
90
|
-
#
|
|
91
|
-
#
|
|
90
|
+
# The same rank should not be assigned to many documents, and should never
|
|
91
|
+
# be assigned to more than 10,000 documents. By default (when it is not
|
|
92
|
+
# specified or set to 0), it is set at the time the document is created to
|
|
93
|
+
# the number of seconds since January 1, 2011. The rank can be used in
|
|
94
|
+
# {Gcloud::Search::Index#search} options `expressions`, `order`, and
|
|
95
|
+
# `fields`, where it is referenced as `rank`.
|
|
92
96
|
def rank= new_rank
|
|
93
97
|
@raw["rank"] = new_rank
|
|
94
98
|
end
|
|
@@ -96,18 +100,12 @@ module Gcloud
|
|
|
96
100
|
##
|
|
97
101
|
# Retrieve the field values associated to a field name.
|
|
98
102
|
#
|
|
99
|
-
#
|
|
100
|
-
#
|
|
101
|
-
# +name+::
|
|
102
|
-
# The name of the field. New values will be configured with this name.
|
|
103
|
-
# (+String+)
|
|
104
|
-
#
|
|
105
|
-
# === Returns
|
|
106
|
-
#
|
|
107
|
-
# FieldValues
|
|
103
|
+
# @param [String] name The name of the field. New values will be
|
|
104
|
+
# configured with this name.
|
|
108
105
|
#
|
|
109
|
-
#
|
|
106
|
+
# @return [FieldValues]
|
|
110
107
|
#
|
|
108
|
+
# @example
|
|
111
109
|
# require "gcloud"
|
|
112
110
|
#
|
|
113
111
|
# gcloud = Gcloud.new
|
|
@@ -124,64 +122,49 @@ module Gcloud
|
|
|
124
122
|
@fields[name]
|
|
125
123
|
end
|
|
126
124
|
|
|
127
|
-
#
|
|
128
|
-
# Disable rubocop because we want .fields to be listed with the other
|
|
129
|
-
# methods on the class.
|
|
125
|
+
# Trivial accessor because we want .fields to be listed with methods.
|
|
130
126
|
|
|
131
127
|
##
|
|
132
128
|
# The fields in the document. Each field has a name (String) and a list of
|
|
133
|
-
# values (FieldValues). (See Fields)
|
|
129
|
+
# values ({FieldValues}). (See {Fields})
|
|
134
130
|
def fields
|
|
135
131
|
@fields
|
|
136
132
|
end
|
|
137
133
|
|
|
138
|
-
# rubocop:enable Style/TrivialAccessors
|
|
139
|
-
|
|
140
|
-
# rubocop:disable Metrics/LineLength
|
|
141
|
-
# Disabled because there are links in the docs that are long.
|
|
142
|
-
|
|
143
134
|
##
|
|
144
135
|
# Add a new value. If the field name does not exist it will be added. If
|
|
145
136
|
# the field value is a DateTime or Numeric, or the type is set to
|
|
146
|
-
#
|
|
147
|
-
# values of the same type (since there can be only one).
|
|
148
|
-
#
|
|
149
|
-
# === Parameters
|
|
137
|
+
# `:datetime` or `:number`, then the added value will replace any existing
|
|
138
|
+
# values of the same type (since there can be only one).
|
|
150
139
|
#
|
|
151
|
-
#
|
|
152
|
-
#
|
|
153
|
-
#
|
|
154
|
-
#
|
|
155
|
-
#
|
|
156
|
-
#
|
|
157
|
-
#
|
|
158
|
-
# +:geo+ values. A field can have multiple values with same or different
|
|
159
|
-
# types; however, it cannot have multiple +:datetime+ or +:number+
|
|
160
|
-
# values. (+Symbol+)
|
|
140
|
+
# @param [String] name The name of the field.
|
|
141
|
+
# @param [String, Datetime, Float] value The value to add to the field.
|
|
142
|
+
# @param [Symbol] type The type of the field value. An attempt is made to
|
|
143
|
+
# set the correct type when this option is missing, although it must be
|
|
144
|
+
# provided for `:geo` values. A field can have multiple values with same
|
|
145
|
+
# or different types; however, it cannot have multiple `:datetime` or
|
|
146
|
+
# `:number` values.
|
|
161
147
|
#
|
|
162
148
|
# The following values are supported:
|
|
163
|
-
#
|
|
149
|
+
#
|
|
150
|
+
# * `:default` - The value is a string. The format will be automatically
|
|
164
151
|
# detected. This is the default value for strings.
|
|
165
|
-
# *
|
|
152
|
+
# * `:text` - The value is a string with maximum length 1024**2
|
|
166
153
|
# characters.
|
|
167
|
-
# *
|
|
154
|
+
# * `:html` - The value is an HTML-formatted string with maximum length
|
|
168
155
|
# 1024**2 characters.
|
|
169
|
-
# *
|
|
170
|
-
# *
|
|
156
|
+
# * `:atom` - The value is a string with maximum length 500 characters.
|
|
157
|
+
# * `:geo` - The value is a point on earth described by latitude and
|
|
171
158
|
# longitude coordinates, represented in string with any of the listed
|
|
172
|
-
#
|
|
173
|
-
#
|
|
174
|
-
# *
|
|
175
|
-
# * +:number+ - The value is a +Numeric+ between -2,147,483,647 and
|
|
159
|
+
# [ways of writing coordinates](http://en.wikipedia.org/wiki/Geographic_coordinate_conversion).
|
|
160
|
+
# * `:datetime` - The value is a `DateTime`.
|
|
161
|
+
# * `:number` - The value is a `Numeric` between -2,147,483,647 and
|
|
176
162
|
# 2,147,483,647. The value will be stored as a double precision
|
|
177
163
|
# floating point value in Cloud Search.
|
|
178
|
-
#
|
|
179
|
-
#
|
|
180
|
-
# code}[https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes].
|
|
181
|
-
# (+String+)
|
|
182
|
-
#
|
|
183
|
-
# === Example
|
|
164
|
+
# @param [String] lang The language of a string value. Must be a valid
|
|
165
|
+
# [ISO 639-1 code](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes).
|
|
184
166
|
#
|
|
167
|
+
# @example
|
|
185
168
|
# require "gcloud"
|
|
186
169
|
#
|
|
187
170
|
# gcloud = Gcloud.new
|
|
@@ -200,18 +183,12 @@ module Gcloud
|
|
|
200
183
|
@fields[name].add value, type: type, lang: lang
|
|
201
184
|
end
|
|
202
185
|
|
|
203
|
-
# rubocop:enable Metrics/LineLength
|
|
204
|
-
|
|
205
186
|
##
|
|
206
|
-
# Deletes a field and all values. (See Fields#delete)
|
|
187
|
+
# Deletes a field and all values. (See {Fields#delete})
|
|
207
188
|
#
|
|
208
|
-
#
|
|
209
|
-
#
|
|
210
|
-
# +name+::
|
|
211
|
-
# The name of the field. (+String+)
|
|
212
|
-
#
|
|
213
|
-
# === Example
|
|
189
|
+
# @param [String] name The name of the field.
|
|
214
190
|
#
|
|
191
|
+
# @example
|
|
215
192
|
# require "gcloud"
|
|
216
193
|
#
|
|
217
194
|
# gcloud = Gcloud.new
|
|
@@ -228,10 +205,9 @@ module Gcloud
|
|
|
228
205
|
##
|
|
229
206
|
# Calls block once for each field, passing the field name and values pair
|
|
230
207
|
# as parameters. If no block is given an enumerator is returned instead.
|
|
231
|
-
# (See Fields#each)
|
|
232
|
-
#
|
|
233
|
-
# === Example
|
|
208
|
+
# (See {Fields#each})
|
|
234
209
|
#
|
|
210
|
+
# @example
|
|
235
211
|
# require "gcloud"
|
|
236
212
|
#
|
|
237
213
|
# gcloud = Gcloud.new
|
|
@@ -253,8 +229,9 @@ module Gcloud
|
|
|
253
229
|
|
|
254
230
|
##
|
|
255
231
|
# Returns a new array populated with all the field names.
|
|
256
|
-
# (See Fields#names)
|
|
232
|
+
# (See {Fields#names})
|
|
257
233
|
#
|
|
234
|
+
# @example
|
|
258
235
|
# require "gcloud"
|
|
259
236
|
#
|
|
260
237
|
# gcloud = Gcloud.new
|
|
@@ -272,8 +249,8 @@ module Gcloud
|
|
|
272
249
|
end
|
|
273
250
|
|
|
274
251
|
##
|
|
275
|
-
# Override to keep working in interactive shells manageable.
|
|
276
|
-
def inspect
|
|
252
|
+
# @private Override to keep working in interactive shells manageable.
|
|
253
|
+
def inspect
|
|
277
254
|
insp_rank = ""
|
|
278
255
|
insp_rank = ", rank: #{rank}" if rank
|
|
279
256
|
insp_fields = ", fields: (#{fields.names.map(&:inspect).join ', '})"
|
|
@@ -281,8 +258,8 @@ module Gcloud
|
|
|
281
258
|
end
|
|
282
259
|
|
|
283
260
|
##
|
|
284
|
-
# New Document from a raw data object.
|
|
285
|
-
def self.from_hash hash
|
|
261
|
+
# @private New Document from a raw data object.
|
|
262
|
+
def self.from_hash hash
|
|
286
263
|
doc = new
|
|
287
264
|
doc.instance_variable_set "@raw", hash
|
|
288
265
|
doc.instance_variable_set "@fields", Fields.from_raw(hash["fields"])
|
|
@@ -290,8 +267,8 @@ module Gcloud
|
|
|
290
267
|
end
|
|
291
268
|
|
|
292
269
|
##
|
|
293
|
-
# Returns the Document data as a hash
|
|
294
|
-
def to_hash
|
|
270
|
+
# @private Returns the Document data as a hash
|
|
271
|
+
def to_hash
|
|
295
272
|
hash = @raw.dup
|
|
296
273
|
hash["fields"] = @fields.to_raw
|
|
297
274
|
hash
|
|
@@ -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
|
module Gcloud
|
|
17
17
|
module Search
|
|
18
18
|
class Document
|
|
@@ -25,7 +25,7 @@ module Gcloud
|
|
|
25
25
|
attr_accessor :token
|
|
26
26
|
|
|
27
27
|
##
|
|
28
|
-
# Create a new Document::List with an array of Document instances.
|
|
28
|
+
# Create a new Document::List with an array of {Document} instances.
|
|
29
29
|
def initialize arr = []
|
|
30
30
|
super arr
|
|
31
31
|
end
|
|
@@ -45,7 +45,7 @@ module Gcloud
|
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
##
|
|
48
|
-
# Retrieves all documents by repeatedly loading pages until #next?
|
|
48
|
+
# Retrieves all documents by repeatedly loading pages until {#next?}
|
|
49
49
|
# returns false. Returns the list instance for method chaining.
|
|
50
50
|
def all
|
|
51
51
|
while next?
|
|
@@ -57,8 +57,8 @@ module Gcloud
|
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
##
|
|
60
|
-
# New Documents::List from a response object.
|
|
61
|
-
def self.from_response resp, index
|
|
60
|
+
# @private New Documents::List from a response object.
|
|
61
|
+
def self.from_response resp, index
|
|
62
62
|
data = JSON.parse resp.body
|
|
63
63
|
documents = new(Array(data["documents"]).map do |doc_hash|
|
|
64
64
|
Document.from_hash doc_hash
|
data/lib/gcloud/search/errors.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/errors"
|
|
17
17
|
|
|
18
18
|
module Gcloud
|
|
@@ -33,13 +33,15 @@ module Gcloud
|
|
|
33
33
|
# The errors encountered.
|
|
34
34
|
attr_reader :errors
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
# @private
|
|
37
|
+
def initialize message, code, errors = []
|
|
37
38
|
super message
|
|
38
39
|
@code = code
|
|
39
40
|
@errors = errors
|
|
40
41
|
end
|
|
41
42
|
|
|
42
|
-
|
|
43
|
+
# @private
|
|
44
|
+
def self.from_response resp
|
|
43
45
|
data = JSON.parse resp.body
|
|
44
46
|
if data["error"]
|
|
45
47
|
from_response_data data["error"]
|
|
@@ -50,11 +52,13 @@ module Gcloud
|
|
|
50
52
|
from_response_status resp
|
|
51
53
|
end
|
|
52
54
|
|
|
53
|
-
|
|
55
|
+
# @private
|
|
56
|
+
def self.from_response_data error
|
|
54
57
|
new error["message"], error["code"], error["errors"]
|
|
55
58
|
end
|
|
56
59
|
|
|
57
|
-
|
|
60
|
+
# @private
|
|
61
|
+
def self.from_response_status resp
|
|
58
62
|
if resp.status == 404
|
|
59
63
|
new "#{resp.body}: #{resp.request.uri.request_uri}",
|
|
60
64
|
resp.status
|