gcloud 0.6.3 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. checksums.yaml +8 -8
  2. data/AUTHENTICATION.md +13 -9
  3. data/CHANGELOG.md +8 -3
  4. data/OVERVIEW.md +46 -8
  5. data/lib/gcloud.rb +123 -117
  6. data/lib/gcloud/backoff.rb +43 -15
  7. data/lib/gcloud/bigquery.rb +211 -195
  8. data/lib/gcloud/bigquery/connection.rb +9 -9
  9. data/lib/gcloud/bigquery/copy_job.rb +15 -16
  10. data/lib/gcloud/bigquery/credentials.rb +3 -3
  11. data/lib/gcloud/bigquery/data.rb +12 -11
  12. data/lib/gcloud/bigquery/dataset.rb +162 -216
  13. data/lib/gcloud/bigquery/dataset/access.rb +59 -43
  14. data/lib/gcloud/bigquery/dataset/list.rb +3 -3
  15. data/lib/gcloud/bigquery/errors.rb +9 -5
  16. data/lib/gcloud/bigquery/extract_job.rb +18 -18
  17. data/lib/gcloud/bigquery/insert_response.rb +7 -4
  18. data/lib/gcloud/bigquery/job.rb +48 -44
  19. data/lib/gcloud/bigquery/job/list.rb +3 -3
  20. data/lib/gcloud/bigquery/load_job.rb +24 -25
  21. data/lib/gcloud/bigquery/project.rb +145 -204
  22. data/lib/gcloud/bigquery/query_data.rb +10 -9
  23. data/lib/gcloud/bigquery/query_job.rb +23 -32
  24. data/lib/gcloud/bigquery/table.rb +238 -280
  25. data/lib/gcloud/bigquery/table/list.rb +3 -3
  26. data/lib/gcloud/bigquery/table/schema.rb +79 -87
  27. data/lib/gcloud/bigquery/view.rb +69 -82
  28. data/lib/gcloud/credentials.rb +3 -9
  29. data/lib/gcloud/datastore.rb +194 -170
  30. data/lib/gcloud/datastore/connection.rb +12 -8
  31. data/lib/gcloud/datastore/credentials.rb +6 -4
  32. data/lib/gcloud/datastore/dataset.rb +74 -141
  33. data/lib/gcloud/datastore/dataset/lookup_results.rb +6 -4
  34. data/lib/gcloud/datastore/dataset/query_results.rb +6 -4
  35. data/lib/gcloud/datastore/entity.rb +81 -76
  36. data/lib/gcloud/datastore/errors.rb +10 -8
  37. data/lib/gcloud/datastore/key.rb +41 -77
  38. data/lib/gcloud/datastore/properties.rb +3 -3
  39. data/lib/gcloud/datastore/proto.rb +7 -4
  40. data/lib/gcloud/datastore/query.rb +26 -3
  41. data/lib/gcloud/datastore/transaction.rb +12 -8
  42. data/lib/gcloud/dns.rb +180 -152
  43. data/lib/gcloud/dns/change.rb +16 -16
  44. data/lib/gcloud/dns/change/list.rb +3 -3
  45. data/lib/gcloud/dns/connection.rb +9 -10
  46. data/lib/gcloud/dns/credentials.rb +3 -3
  47. data/lib/gcloud/dns/errors.rb +9 -5
  48. data/lib/gcloud/dns/importer.rb +17 -23
  49. data/lib/gcloud/dns/project.rb +42 -64
  50. data/lib/gcloud/dns/record.rb +58 -46
  51. data/lib/gcloud/dns/record/list.rb +6 -7
  52. data/lib/gcloud/dns/zone.rb +198 -289
  53. data/lib/gcloud/dns/zone/list.rb +3 -3
  54. data/lib/gcloud/dns/zone/transaction.rb +56 -72
  55. data/lib/gcloud/errors.rb +174 -3
  56. data/lib/gcloud/gce.rb +3 -4
  57. data/lib/gcloud/grpc_utils.rb +76 -0
  58. data/lib/gcloud/logging.rb +308 -0
  59. data/lib/gcloud/logging/credentials.rb +29 -0
  60. data/lib/gcloud/logging/entry.rb +303 -0
  61. data/lib/gcloud/logging/entry/http_request.rb +141 -0
  62. data/lib/gcloud/logging/entry/list.rb +111 -0
  63. data/lib/gcloud/logging/entry/operation.rb +90 -0
  64. data/lib/gcloud/logging/logger.rb +307 -0
  65. data/lib/gcloud/logging/metric.rb +175 -0
  66. data/lib/gcloud/logging/metric/list.rb +98 -0
  67. data/lib/gcloud/logging/project.rb +650 -0
  68. data/lib/gcloud/logging/resource.rb +95 -0
  69. data/lib/gcloud/logging/resource_descriptor.rb +140 -0
  70. data/lib/gcloud/logging/resource_descriptor/list.rb +78 -0
  71. data/lib/gcloud/logging/service.rb +258 -0
  72. data/lib/gcloud/logging/sink.rb +233 -0
  73. data/lib/gcloud/logging/sink/list.rb +97 -0
  74. data/lib/gcloud/pubsub.rb +241 -199
  75. data/lib/gcloud/pubsub/credentials.rb +3 -3
  76. data/lib/gcloud/pubsub/message.rb +26 -20
  77. data/lib/gcloud/pubsub/project.rb +166 -233
  78. data/lib/gcloud/pubsub/received_message.rb +28 -38
  79. data/lib/gcloud/pubsub/service.rb +323 -0
  80. data/lib/gcloud/pubsub/subscription.rb +172 -242
  81. data/lib/gcloud/pubsub/subscription/list.rb +11 -9
  82. data/lib/gcloud/pubsub/topic.rb +152 -271
  83. data/lib/gcloud/pubsub/topic/batch.rb +66 -0
  84. data/lib/gcloud/pubsub/topic/list.rb +9 -7
  85. data/lib/gcloud/resource_manager.rb +158 -138
  86. data/lib/gcloud/resource_manager/connection.rb +6 -5
  87. data/lib/gcloud/resource_manager/credentials.rb +3 -3
  88. data/lib/gcloud/resource_manager/errors.rb +9 -5
  89. data/lib/gcloud/resource_manager/manager.rb +54 -86
  90. data/lib/gcloud/resource_manager/project.rb +69 -88
  91. data/lib/gcloud/resource_manager/project/list.rb +4 -5
  92. data/lib/gcloud/resource_manager/project/updater.rb +12 -14
  93. data/lib/gcloud/search.rb +158 -135
  94. data/lib/gcloud/search/api_client.rb +7 -7
  95. data/lib/gcloud/search/connection.rb +8 -8
  96. data/lib/gcloud/search/credentials.rb +3 -3
  97. data/lib/gcloud/search/document.rb +64 -87
  98. data/lib/gcloud/search/document/list.rb +5 -5
  99. data/lib/gcloud/search/errors.rb +9 -5
  100. data/lib/gcloud/search/field_value.rb +32 -38
  101. data/lib/gcloud/search/field_values.rb +50 -80
  102. data/lib/gcloud/search/fields.rb +44 -65
  103. data/lib/gcloud/search/index.rb +163 -204
  104. data/lib/gcloud/search/index/list.rb +5 -5
  105. data/lib/gcloud/search/project.rb +31 -47
  106. data/lib/gcloud/search/result.rb +27 -31
  107. data/lib/gcloud/search/result/list.rb +6 -6
  108. data/lib/gcloud/storage.rb +224 -190
  109. data/lib/gcloud/storage/bucket.rb +202 -227
  110. data/lib/gcloud/storage/bucket/acl.rb +83 -170
  111. data/lib/gcloud/storage/bucket/cors.rb +31 -34
  112. data/lib/gcloud/storage/bucket/list.rb +3 -3
  113. data/lib/gcloud/storage/connection.rb +11 -7
  114. data/lib/gcloud/storage/credentials.rb +3 -3
  115. data/lib/gcloud/storage/errors.rb +11 -8
  116. data/lib/gcloud/storage/file.rb +129 -171
  117. data/lib/gcloud/storage/file/acl.rb +51 -99
  118. data/lib/gcloud/storage/file/list.rb +3 -3
  119. data/lib/gcloud/storage/file/verifier.rb +3 -2
  120. data/lib/gcloud/storage/project.rb +111 -132
  121. data/lib/gcloud/upload.rb +4 -7
  122. data/lib/gcloud/version.rb +2 -4
  123. data/lib/google/api/annotations.rb +14 -0
  124. data/lib/google/api/http.rb +30 -0
  125. data/lib/google/api/label.rb +24 -0
  126. data/lib/google/api/monitored_resource.rb +25 -0
  127. data/lib/google/datastore/v1beta3/datastore.rb +115 -0
  128. data/lib/google/datastore/v1beta3/datastore_services.rb +33 -0
  129. data/lib/google/datastore/v1beta3/entity.rb +63 -0
  130. data/lib/google/datastore/v1beta3/query.rb +128 -0
  131. data/lib/google/devtools/cloudtrace/v1/trace.rb +78 -0
  132. data/lib/google/devtools/cloudtrace/v1/trace_services.rb +32 -0
  133. data/lib/google/example/library/v1/library.rb +91 -0
  134. data/lib/google/example/library/v1/library_services.rb +40 -0
  135. data/lib/google/iam/v1/iam_policy.rb +33 -0
  136. data/lib/google/iam/v1/iam_policy_services.rb +30 -0
  137. data/lib/google/iam/v1/policy.rb +25 -0
  138. data/lib/google/logging/type/http_request.rb +28 -0
  139. data/lib/google/logging/type/log_severity.rb +27 -0
  140. data/lib/google/logging/v2/log_entry.rb +44 -0
  141. data/lib/google/logging/v2/logging.rb +56 -0
  142. data/lib/google/logging/v2/logging_config.rb +59 -0
  143. data/lib/google/logging/v2/logging_config_services.rb +32 -0
  144. data/lib/google/logging/v2/logging_metrics.rb +51 -0
  145. data/lib/google/logging/v2/logging_metrics_services.rb +32 -0
  146. data/lib/google/logging/v2/logging_services.rb +31 -0
  147. data/lib/google/longrunning/operations.rb +50 -0
  148. data/lib/google/longrunning/operations_services.rb +29 -0
  149. data/lib/google/protobuf/any.rb +17 -0
  150. data/lib/google/protobuf/api.rb +31 -0
  151. data/lib/google/protobuf/descriptor.rb +0 -0
  152. data/lib/google/protobuf/duration.rb +17 -0
  153. data/lib/google/protobuf/empty.rb +15 -0
  154. data/lib/google/protobuf/field_mask.rb +16 -0
  155. data/lib/google/protobuf/source_context.rb +16 -0
  156. data/lib/google/protobuf/struct.rb +35 -0
  157. data/lib/google/protobuf/timestamp.rb +17 -0
  158. data/lib/google/protobuf/type.rb +79 -0
  159. data/lib/google/protobuf/wrappers.rb +48 -0
  160. data/lib/google/pubsub/v1/pubsub.rb +129 -0
  161. data/lib/google/pubsub/v1/pubsub_services.rb +56 -0
  162. data/lib/google/pubsub/v1beta2/pubsub.rb +126 -0
  163. data/lib/google/pubsub/v1beta2/pubsub_services.rb +56 -0
  164. data/lib/google/rpc/code.rb +32 -0
  165. data/lib/google/rpc/error_details.rb +61 -0
  166. data/lib/google/rpc/status.rb +19 -0
  167. data/lib/google/type/color.rb +20 -0
  168. data/lib/google/type/date.rb +18 -0
  169. data/lib/google/type/dayofweek.rb +23 -0
  170. data/lib/google/type/latlng.rb +17 -0
  171. data/lib/google/type/money.rb +18 -0
  172. data/lib/google/type/timeofday.rb +19 -0
  173. metadata +101 -4
  174. data/lib/gcloud/pubsub/connection.rb +0 -295
  175. 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
  module Gcloud
17
17
  module ResourceManager
18
18
  class Project
@@ -48,8 +48,7 @@ module Gcloud
48
48
  # Retrieves all projects by repeatedly loading pages until #next?
49
49
  # returns false. Returns the list instance for method chaining.
50
50
  #
51
- # === Example
52
- #
51
+ # @example
53
52
  # require "gcloud"
54
53
  #
55
54
  # gcloud = Gcloud.new
@@ -66,8 +65,8 @@ module Gcloud
66
65
  end
67
66
 
68
67
  ##
69
- # New Projects::List from a response object.
70
- def self.from_response resp, manager #:nodoc:
68
+ # @private New Projects::List from a response object.
69
+ def self.from_response resp, manager
71
70
  projects = new(Array(resp.data["projects"]).map do |gapi_object|
72
71
  Project.from_gapi gapi_object, manager.connection
73
72
  end)
@@ -1,4 +1,3 @@
1
- #--
2
1
  # Copyright 2015 Google Inc. All rights reserved.
3
2
  #
4
3
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,6 +12,7 @@
13
12
  # See the License for the specific language governing permissions and
14
13
  # limitations under the License.
15
14
 
15
+
16
16
  require "time"
17
17
  require "gcloud/resource_manager/errors"
18
18
 
@@ -20,11 +20,12 @@ module Gcloud
20
20
  module ResourceManager
21
21
  class Project
22
22
  ##
23
- # = Project Updater
23
+ # # Project Updater
24
24
  #
25
25
  # This object is used by Project#update when passed a block. These methods
26
26
  # are used to update the project data in a single API call.
27
27
  #
28
+ # @example
28
29
  # require "gcloud"
29
30
  #
30
31
  # gcloud = Gcloud.new
@@ -37,8 +38,8 @@ module Gcloud
37
38
  #
38
39
  class Updater < DelegateClass(Project)
39
40
  ##
40
- # Create an Updater object.
41
- def initialize project #:nodoc:
41
+ # @private Create an Updater object.
42
+ def initialize project
42
43
  super project
43
44
  end
44
45
 
@@ -49,8 +50,7 @@ module Gcloud
49
50
  # Allowed characters are: lowercase and uppercase letters, numbers,
50
51
  # hyphen, single-quote, double-quote, space, and exclamation point.
51
52
  #
52
- # === Example
53
- #
53
+ # @example
54
54
  # require "gcloud"
55
55
  #
56
56
  # gcloud = Gcloud.new
@@ -75,10 +75,9 @@ module Gcloud
75
75
  # to the regular expression <code>([a-z]([-a-z0-9]*[a-z0-9])?)?</code>.
76
76
  #
77
77
  # No more than 256 labels can be associated with a given resource.
78
- # (+Hash+)
79
- #
80
- # === Example
78
+ # (`Hash`)
81
79
  #
80
+ # @example
82
81
  # require "gcloud"
83
82
  #
84
83
  # gcloud = Gcloud.new
@@ -103,10 +102,9 @@ module Gcloud
103
102
  # to the regular expression <code>([a-z]([-a-z0-9]*[a-z0-9])?)?</code>.
104
103
  #
105
104
  # No more than 256 labels can be associated with a given resource.
106
- # (+Hash+)
107
- #
108
- # === Example
105
+ # (`Hash`)
109
106
  #
107
+ # @example
110
108
  # require "gcloud"
111
109
  #
112
110
  # gcloud = Gcloud.new
@@ -121,8 +119,8 @@ module Gcloud
121
119
  end
122
120
 
123
121
  ##
124
- # Create an Updater object.
125
- def self.from_project project #:nodoc:
122
+ # @private Create an Updater object.
123
+ def self.from_project project
126
124
  dupe_gapi = project.gapi.dup
127
125
  dupe_gapi = dupe_gapi.to_hash if dupe_gapi.respond_to? :to_hash
128
126
  if dupe_gapi["labels"].respond_to? :to_hash
data/lib/gcloud/search.rb CHANGED
@@ -12,38 +12,34 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+
15
16
  require "gcloud"
16
17
  require "gcloud/search/project"
17
18
 
18
- #--
19
- # Google Cloud Search
20
19
  module Gcloud
21
20
  ##
22
- # Creates a new +Project+ instance connected to the Search service.
21
+ # Creates a new `Project` instance connected to the Search service.
23
22
  # Each call creates a new connection.
24
23
  #
25
- # === Parameters
24
+ # For more information on connecting to Google Cloud see the [Authentication
25
+ # Guide](https://googlecloudplatform.github.io/gcloud-ruby/#/docs/guides/authentication).
26
26
  #
27
- # +project+::
28
- # Identifier for a Search project. If not present, the default project for
29
- # the credentials is used. (+String+)
30
- # +keyfile+::
31
- # Keyfile downloaded from Google Cloud. If file path the file must be
32
- # readable. (+String+ or +Hash+)
33
- # +scope::
34
- # The OAuth 2.0 scopes controlling the set of resources and operations that
35
- # the connection can access. See {Using OAuth 2.0 to Access Google
36
- # APIs}[https://developers.google.com/identity/protocols/OAuth2]. (+String+
37
- # or +Array+)
27
+ # @param [String] project Identifier for a Search project. If not present, the
28
+ # default project for the credentials is used.
29
+ # @param [String, Hash] keyfile Keyfile downloaded from Google Cloud. If file
30
+ # path the file must be readable.
31
+ # @param [String, Array<String>] scope The OAuth 2.0 scopes controlling the
32
+ # set of resources and operations that the connection can access. See [Using
33
+ # OAuth 2.0 to Access Google
34
+ # APIs](https://developers.google.com/identity/protocols/OAuth2).
38
35
  #
39
36
  # The default scopes are:
40
37
  #
41
- # * +https://www.googleapis.com/auth/cloudsearch+
42
- # * +https://www.googleapis.com/auth/userinfo.email+
38
+ # * `https://www.googleapis.com/auth/cloudsearch`
39
+ # * `https://www.googleapis.com/auth/userinfo.email`
43
40
  #
44
- # === Returns
41
+ # @return [Gcloud::Search::Project]
45
42
  #
46
- # Gcloud::Search::Project
47
43
  def self.search project = nil, keyfile = nil, scope: nil
48
44
  project ||= Gcloud::Search::Project.default_project
49
45
  if keyfile.nil?
@@ -58,7 +54,7 @@ module Gcloud
58
54
  # Disabled because there are links in the docs that are long.
59
55
 
60
56
  ##
61
- # = Google Cloud Search
57
+ # # Google Cloud Search
62
58
  #
63
59
  # Google Cloud Search allows an application to quickly perform full-text and
64
60
  # geo-spatial searches without having to spin up instances and without the
@@ -74,220 +70,247 @@ module Gcloud
74
70
  # backward-incompatible ways. It is not currently recommended for production
75
71
  # use. It is not subject to any SLA or deprecation policy.
76
72
  #
77
- # == Accessing the Service
73
+ # ## Accessing the Service
78
74
  #
79
75
  # Currently, the Cloud Search API is available only to white-listed users.
80
76
  # Contact your account manager or a member of the Google Cloud sales team if
81
77
  # you are interested in access.
82
78
  #
83
- # == Authentication
79
+ # ## Authentication
84
80
  #
85
- # Authentication is handled by Gcloud#search. You can provide the project and
81
+ # Authentication is handled by {Gcloud#search}. You can provide the project and
86
82
  # credential information to connect to the Cloud Search service, or if you are
87
83
  # running on Google Compute Engine this configuration is taken care of for
88
84
  # you. You can read more about the options for connecting in the
89
- # {Authentication Guide}[link:AUTHENTICATION.md].
85
+ # [Authentication
86
+ # Guide](https://googlecloudplatform.github.io/gcloud-ruby/#/docs/guides/authentication).
90
87
  #
91
- # == Managing Indexes
88
+ # ## Managing Indexes
92
89
  #
93
90
  # An Index is a searchable collection of documents that belongs to a Project.
94
91
  #
95
92
  # You can list the indexes in your current project:
96
93
  #
97
- # require "gcloud"
94
+ # ```ruby
95
+ # require "gcloud"
98
96
  #
99
- # gcloud = Gcloud.new
100
- # search = gcloud.search
97
+ # gcloud = Gcloud.new
98
+ # search = gcloud.search
101
99
  #
102
- # indexes = search.indexes # API call
103
- # indexes.each do |index|
104
- # puts index.index_id
105
- # end
100
+ # indexes = search.indexes # API call
101
+ # indexes.each do |index|
102
+ # puts index.index_id
103
+ # end
104
+ # ```
106
105
  #
107
106
  # And you can use the project to create new indexes:
108
107
  #
109
- # require "gcloud"
108
+ # ```ruby
109
+ # require "gcloud"
110
110
  #
111
- # gcloud = Gcloud.new
112
- # search = gcloud.search
111
+ # gcloud = Gcloud.new
112
+ # search = gcloud.search
113
113
  #
114
- # index = search.index "products", skip_lookup: true
114
+ # index = search.index "products", skip_lookup: true
115
+ # ```
115
116
  #
116
117
  # A new index is an unsaved value object. Indexes cannot be created,
117
118
  # updated, or deleted directly in the service: They are derived from the
118
119
  # documents which are created "within" them. A new index will exist in the
119
120
  # service once you save a document that references it.
120
121
  #
121
- # == Managing Documents
122
+ # ## Managing Documents
122
123
  #
123
124
  # Using an index, create a new, unsaved Document instance, providing
124
125
  # your own unique document ID, as shown below, or omitting this argument to
125
126
  # let the service assign the ID.
126
127
  #
127
- # require "gcloud"
128
+ # ```ruby
129
+ # require "gcloud"
128
130
  #
129
- # gcloud = Gcloud.new
130
- # search = gcloud.search
131
+ # gcloud = Gcloud.new
132
+ # search = gcloud.search
131
133
  #
132
- # index = search.index "products"
133
- # document = index.document "product-sku-000001"
134
- # index.find document # API call
135
- # #=> nil
136
- # document.rank #=> nil
134
+ # index = search.index "products"
135
+ # document = index.document "product-sku-000001"
136
+ # index.find document # API call
137
+ # #=> nil
138
+ # document.rank #=> nil
139
+ # ```
137
140
  #
138
- # Add one or more fields to the document. (See {Adding document fields}[#module-Gcloud::Search-label-Adding+document+fields], below.)
141
+ # Add one or more fields to the document. (See [Adding document fields](#module-Gcloud::Search-label-Adding`document`fields), below.)
139
142
  #
140
- # document.add "price", 24.95
143
+ # ```ruby
144
+ # document.add "price", 24.95
145
+ # ```
141
146
  #
142
147
  # When your document is complete, save it:
143
148
  #
144
- # index.save document # API call
145
- # document.rank # set by the server
146
- # #=> 1443648166
149
+ # ```ruby
150
+ # index.save document # API call
151
+ # document.rank # set by the server
152
+ # #=> 1443648166
153
+ # ```
147
154
  #
148
155
  # You can list the documents in an index:
149
156
  #
150
- # require "gcloud"
157
+ # ```ruby
158
+ # require "gcloud"
151
159
  #
152
- # gcloud = Gcloud.new
153
- # search = gcloud.search
154
- # index = search.index "products"
160
+ # gcloud = Gcloud.new
161
+ # search = gcloud.search
162
+ # index = search.index "products"
155
163
  #
156
- # documents = index.documents # API call
157
- # documents.map &:doc_id #=> ["product-sku-000001"]
164
+ # documents = index.documents # API call
165
+ # documents.map &:doc_id #=> ["product-sku-000001"]
166
+ # ```
158
167
  #
159
168
  # And you can delete documents:
160
169
  #
161
- # require "gcloud"
170
+ # ```ruby
171
+ # require "gcloud"
162
172
  #
163
- # gcloud = Gcloud.new
164
- # search = gcloud.search
165
- # index = search.index "products"
173
+ # gcloud = Gcloud.new
174
+ # search = gcloud.search
175
+ # index = search.index "products"
166
176
  #
167
- # document = index.find "product-sku-000001"
177
+ # document = index.find "product-sku-000001"
168
178
  #
169
- # document.delete # API call
170
- # index.find document # API call
171
- # #=> nil
179
+ # document.delete # API call
180
+ # index.find document # API call
181
+ # #=> nil
182
+ # ```
172
183
  #
173
184
  # To update a document after manipulating its fields or rank, just re-save it:
174
185
  #
175
- # require "gcloud"
186
+ # ```ruby
187
+ # require "gcloud"
176
188
  #
177
- # gcloud = Gcloud.new
178
- # search = gcloud.search
179
- # index = search.index "products"
189
+ # gcloud = Gcloud.new
190
+ # search = gcloud.search
191
+ # index = search.index "products"
180
192
  #
181
- # document = index.find "product-sku-000001"
193
+ # document = index.find "product-sku-000001"
182
194
  #
183
- # document.rank = 12345
184
- # document.add "price", 9.95 # replace existing number value
185
- # index.save document # API call
195
+ # document.rank = 12345
196
+ # document.add "price", 9.95 # replace existing number value
197
+ # index.save document # API call
198
+ # ```
186
199
  #
187
- # == Adding document fields
200
+ # ## Adding document fields
188
201
  #
189
202
  # Fields belong to documents and are the data that actually gets searched.
190
203
  # Each field has a FieldValues collection, which facilitates access to
191
204
  # FieldValue objects. Each FieldValue object will be saved as one of the
192
- # {Cloud Search types}[https://cloud.google.com/search/documents_indexes#document_fields_field_names_and_multi-valued_fields].
205
+ # [Cloud Search types](https://cloud.google.com/search/documents_indexes#document_fields_field_names_and_multi-valued_fields).
193
206
  # The type will be inferred from the value when possible, or you can
194
- # explicitly specify it by passing a symbol with the +type+ option to
195
- # Document#add.
207
+ # explicitly specify it by passing a symbol with the `type` option to
208
+ # {Gcloud::Search::Document#add}.
196
209
  #
197
- # - String (+:atom+, +:html+, +:text+, or +:default+)
198
- # - Number (+:number+)
199
- # - Timestamp (+:datetime+)
200
- # - Geovalue (+:geo+)
210
+ # - String (`:atom`, `:html`, `:text`, or `:default`)
211
+ # - Number (`:number`)
212
+ # - Timestamp (`:datetime`)
213
+ # - Geovalue (`:geo`)
201
214
  #
202
215
  # String values can be tokenized using one of three different types of
203
- # tokenization, which can be passed with the +type+ option when the value is
216
+ # tokenization, which can be passed with the `type` option when the value is
204
217
  # added:
205
218
  #
206
- # - +:atom+ means "don't tokenize this string", treat it as one
219
+ # - `:atom` means "don't tokenize this string", treat it as one
207
220
  # thing to compare against
208
221
  #
209
- # - +:html+ means "treat this string as HTML", not comparing against the
210
- # tags, and treating the rest of the content like +:text+
222
+ # - `:html` means "treat this string as HTML", not comparing against the
223
+ # tags, and treating the rest of the content like `:text`
211
224
  #
212
- # - +:text+ means "treat this string as normal text" and split words
225
+ # - `:text` means "treat this string as normal text" and split words
213
226
  # apart to be compared against
214
227
  #
215
228
  # Again, you can add more than one value to a field, and the values may be of
216
229
  # different types.
217
230
  #
218
- # require "gcloud"
231
+ # ```ruby
232
+ # require "gcloud"
219
233
  #
220
- # gcloud = Gcloud.new
221
- # search = gcloud.search
234
+ # gcloud = Gcloud.new
235
+ # search = gcloud.search
222
236
  #
223
- # index = search.index "products"
224
- # document = index.find "product-sku-000001"
225
- # document.add "description", "The best T-shirt ever.", type: :text, lang: "en"
226
- # document.add "description", "<p>The best T-shirt ever.</p>", type: :html, lang: "en"
227
- # document["description"].size #=> 2
237
+ # index = search.index "products"
238
+ # document = index.find "product-sku-000001"
239
+ # document.add "description", "The best T-shirt ever.", type: :text, lang: "en"
240
+ # document.add "description", "<p>The best T-shirt ever.</p>", type: :html, lang: "en"
241
+ # document["description"].size #=> 2
242
+ # ```
228
243
  #
229
- # == Searching
244
+ # ## Searching
230
245
  #
231
246
  # After populating an index with documents, you can request search results
232
247
  # with a query:
233
248
  #
234
- # require "gcloud"
249
+ # ```ruby
250
+ # require "gcloud"
235
251
  #
236
- # gcloud = Gcloud.new
237
- # search = gcloud.search
238
- # index = search.index "books"
252
+ # gcloud = Gcloud.new
253
+ # search = gcloud.search
254
+ # index = search.index "books"
239
255
  #
240
- # results = index.search "dark stormy"
241
- # results.each do |result|
242
- # puts result.doc_id
243
- # end
256
+ # results = index.search "dark stormy"
257
+ # results.each do |result|
258
+ # puts result.doc_id
259
+ # end
260
+ # ```
244
261
  #
245
262
  # By default, Result objects are sorted by document rank. For more information
246
- # see the {REST API documentation for Document.rank}[https://cloud.google.com/search/reference/rest/v1/projects/indexes/documents#resource_representation.google.cloudsearch.v1.Document.rank].
263
+ # see the [REST API documentation for Document.rank](https://cloud.google.com/search/reference/rest/v1/projects/indexes/documents#resource_representation.google.cloudsearch.v1.Document.rank).
247
264
  #
248
- # You can specify how to sort results with the +order+ option:
265
+ # You can specify how to sort results with the `order` option:
249
266
  #
250
- # require "gcloud"
267
+ # ```ruby
268
+ # require "gcloud"
251
269
  #
252
- # gcloud = Gcloud.new
253
- # search = gcloud.search
254
- # index = search.index "books"
270
+ # gcloud = Gcloud.new
271
+ # search = gcloud.search
272
+ # index = search.index "books"
255
273
  #
256
- # results = index.search "dark stormy", order: "published, avg_review desc"
257
- # documents = index.search query # API call
274
+ # results = index.search "dark stormy", order: "published, avg_review desc"
275
+ # documents = index.search query # API call
276
+ # ```
258
277
  #
259
- # You can add computed fields with the +expressions+ option, and specify the
260
- # fields that are returned with the +fields+ option. No document data will be
261
- # returned if you omit the +fields+ option, only `doc_id` references to any
278
+ # You can add computed fields with the `expressions` option, and specify the
279
+ # fields that are returned with the `fields` option. No document data will be
280
+ # returned if you omit the `fields` option, only `doc_id` references to any
262
281
  # matched documents.
263
282
  #
264
- # require "gcloud"
283
+ # ```ruby
284
+ # require "gcloud"
265
285
  #
266
- # gcloud = Gcloud.new
267
- # search = gcloud.search
268
- # index = search.index "products"
286
+ # gcloud = Gcloud.new
287
+ # search = gcloud.search
288
+ # index = search.index "products"
269
289
  #
270
- # results = index.search "cotton T-shirt",
271
- # expressions: { total_price: "(price + tax)" },
272
- # fields: ["name", "total_price", "highlight"]
290
+ # results = index.search "cotton T-shirt",
291
+ # expressions: { total_price: "(price + tax)" },
292
+ # fields: ["name", "total_price", "highlight"]
293
+ # ```
273
294
  #
274
295
  # Just as in documents, Result data is accessible via Fields methods:
275
296
  #
276
- # require "gcloud"
277
- #
278
- # gcloud = Gcloud.new
279
- # search = gcloud.search
280
- # index = search.index "products"
281
- # document = index.find "product-sku-000001"
282
- # results = index.search "cotton T-shirt"
283
- # values = results[0]["description"]
284
- #
285
- # values[0] #=> "100% organic cotton ruby gem T-shirt"
286
- # values[0].type #=> :text
287
- # values[0].lang #=> "en"
288
- # values[1] #=> "<p>100% organic cotton ruby gem T-shirt</p>"
289
- # values[1].type #=> :html
290
- # values[1].lang #=> "en"
297
+ # ```ruby
298
+ # require "gcloud"
299
+ #
300
+ # gcloud = Gcloud.new
301
+ # search = gcloud.search
302
+ # index = search.index "products"
303
+ # document = index.find "product-sku-000001"
304
+ # results = index.search "cotton T-shirt"
305
+ # values = results[0]["description"]
306
+ #
307
+ # values[0] #=> "100% organic cotton ruby gem T-shirt"
308
+ # values[0].type #=> :text
309
+ # values[0].lang #=> "en"
310
+ # values[1] #=> "<p>100% organic cotton ruby gem T-shirt</p>"
311
+ # values[1].type #=> :html
312
+ # values[1].lang #=> "en"
313
+ # ```
291
314
  #
292
315
  module Search
293
316
  end