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 2014 Google Inc. All rights reserved.
3
2
  #
4
3
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,17 +12,20 @@
13
12
  # See the License for the specific language governing permissions and
14
13
  # limitations under the License.
15
14
 
15
+
16
16
  require "faraday"
17
17
 
18
18
  module Gcloud
19
19
  module Datastore
20
20
  ##
21
+ # @private
22
+ #
21
23
  # Represent the HTTP connection to the Datastore,
22
24
  # as well as the Datastore API calls.
23
25
  #
24
26
  # This class only deals with Protocol Buffer objects,
25
27
  # and is not part of the public API.
26
- class Connection #:nodoc:
28
+ class Connection
27
29
  API_VERSION = "v1beta2"
28
30
  API_URL = "https://www.googleapis.com"
29
31
 
@@ -33,13 +35,15 @@ module Gcloud
33
35
 
34
36
  ##
35
37
  # The Credentials object for signing HTTP requests.
36
- attr_accessor :credentials #:nodoc:
38
+ attr_accessor :credentials
37
39
 
38
40
  ##
39
41
  # Create a new Connection instance.
40
42
  #
43
+ # @example
41
44
  # conn = Gcloud::Datastore.Connection.new "my-todo-project",
42
45
  # Gcloud::Datastore::Credentials.new("/path/to/keyfile.json")
46
+ #
43
47
  def initialize dataset_id, credentials
44
48
  @dataset_id = dataset_id
45
49
  @credentials = credentials
@@ -114,24 +118,24 @@ module Gcloud
114
118
 
115
119
  ##
116
120
  # The default HTTP headers to be sent on all API calls.
117
- def default_http_headers #:nodoc:
121
+ def default_http_headers
118
122
  @default_http_headers ||= {
119
123
  "User-Agent" => "gcloud-node/#{Gcloud::VERSION}",
120
124
  "Content-Type" => "application/x-protobuf" }
121
125
  end
122
126
  ##
123
127
  # Update the default HTTP headers.
124
- attr_writer :default_http_headers #:nodoc:
128
+ attr_writer :default_http_headers
125
129
 
126
130
  ##
127
131
  # The HTTP object that makes calls to Datastore.
128
132
  # This must be a Faraday object.
129
- def http #:nodoc:
133
+ def http
130
134
  @http ||= Faraday.new url: http_host
131
135
  end
132
136
  ##
133
137
  # Update the HTTP object.
134
- attr_writer :http #:nodoc:
138
+ attr_writer :http
135
139
 
136
140
  ##
137
141
  # The Datastore API URL.
@@ -146,7 +150,7 @@ module Gcloud
146
150
  @http_host = new_http_host
147
151
  end
148
152
 
149
- def inspect #:nodoc:
153
+ def inspect
150
154
  "#{self.class}(#{@dataset_id})"
151
155
  end
152
156
 
@@ -1,4 +1,3 @@
1
- #--
2
1
  # Copyright 2014 Google Inc. All rights reserved.
3
2
  #
4
3
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,17 +12,20 @@
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 Datastore
20
20
  ##
21
+ # @private
22
+ #
21
23
  # Authentication credentials to Google Cloud.
22
24
  # The most common way to create this object is to provide the path
23
25
  # to the JSON keyfile downloaded from Google Cloud.
24
26
  #
25
- # https://developers.google.com/accounts/docs/application-default-credentials
26
- class Credentials < Gcloud::Credentials #:nodoc:
27
+ # @see https://developers.google.com/accounts/docs/application-default-credentials
28
+ class Credentials < Gcloud::Credentials
27
29
  SCOPE = ["https://www.googleapis.com/auth/datastore",
28
30
  "https://www.googleapis.com/auth/userinfo.email"]
29
31
  PATH_ENV_VARS = %w(DATASTORE_KEYFILE GCLOUD_KEYFILE GOOGLE_CLOUD_KEYFILE)
@@ -32,7 +34,7 @@ module Gcloud
32
34
 
33
35
  ##
34
36
  # Sign OAuth 2.0 API calls.
35
- def sign_http_request request #:nodoc:
37
+ def sign_http_request request
36
38
  if @client
37
39
  @client.fetch_access_token! if @client.expired?
38
40
  @client.generate_authenticated_request request: request
@@ -1,4 +1,3 @@
1
- #--
2
1
  # Copyright 2014 Google Inc. All rights reserved.
3
2
  #
4
3
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,6 +12,7 @@
13
12
  # See the License for the specific language governing permissions and
14
13
  # limitations under the License.
15
14
 
15
+
16
16
  require "gcloud/gce"
17
17
  require "gcloud/datastore/connection"
18
18
  require "gcloud/datastore/credentials"
@@ -25,15 +25,18 @@ require "gcloud/datastore/dataset/query_results"
25
25
  module Gcloud
26
26
  module Datastore
27
27
  ##
28
- # = Dataset
28
+ # # Dataset
29
29
  #
30
30
  # Dataset is the data saved in a project's Datastore.
31
31
  # Dataset is analogous to a database in relational database world.
32
32
  #
33
33
  # Gcloud::Datastore::Dataset is the main object for interacting with
34
- # Google Datastore. Gcloud::Datastore::Entity objects are created,
34
+ # Google Datastore. {Gcloud::Datastore::Entity} objects are created,
35
35
  # read, updated, and deleted by Gcloud::Datastore::Dataset.
36
36
  #
37
+ # See {Gcloud#datastore}
38
+ #
39
+ # @example
37
40
  # require "gcloud"
38
41
  #
39
42
  # gcloud = Gcloud.new
@@ -44,15 +47,15 @@ module Gcloud
44
47
  #
45
48
  # tasks = dataset.run query
46
49
  #
47
- # See Gcloud#datastore
48
50
  class Dataset
49
- attr_accessor :connection #:nodoc:
51
+ # @private
52
+ attr_accessor :connection
50
53
 
51
54
  ##
52
- # Creates a new Dataset instance.
55
+ # @private Creates a new Dataset instance.
53
56
  #
54
- # See Gcloud#datastore
55
- def initialize project, credentials #:nodoc:
57
+ # See {Gcloud#datastore}
58
+ def initialize project, credentials
56
59
  project = project.to_s # Always cast to a string
57
60
  fail ArgumentError, "project is missing" if project.empty?
58
61
  @connection = Connection.new project, credentials
@@ -61,8 +64,7 @@ module Gcloud
61
64
  ##
62
65
  # The Datastore project connected to.
63
66
  #
64
- # === Example
65
- #
67
+ # @example
66
68
  # require "gcloud"
67
69
  #
68
70
  # gcloud = Gcloud.new "my-todo-project",
@@ -76,8 +78,8 @@ module Gcloud
76
78
  end
77
79
 
78
80
  ##
79
- # Default project.
80
- def self.default_project #:nodoc:
81
+ # @private Default project.
82
+ def self.default_project
81
83
  ENV["DATASTORE_DATASET"] ||
82
84
  ENV["DATASTORE_PROJECT"] ||
83
85
  ENV["GCLOUD_PROJECT"] ||
@@ -88,19 +90,12 @@ module Gcloud
88
90
  ##
89
91
  # Generate IDs for a Key before creating an entity.
90
92
  #
91
- # === Parameters
92
- #
93
- # +incomplete_key+::
94
- # A Key without +id+ or +name+ set. (+Key+)
95
- # +count+::
96
- # The number of new key IDs to create. (+Integer+)
97
- #
98
- # === Returns
99
- #
100
- # Array of Gcloud::Datastore::Key
93
+ # @param [Key] incomplete_key A Key without `id` or `name` set.
94
+ # @param [String] count The number of new key IDs to create.
101
95
  #
102
- # === Example
96
+ # @return [Array<Gcloud::Datastore::Key>]
103
97
  #
98
+ # @example
104
99
  # empty_key = dataset.key "Task"
105
100
  # task_keys = dataset.allocate_ids empty_key, 5
106
101
  #
@@ -119,18 +114,12 @@ module Gcloud
119
114
  ##
120
115
  # Persist one or more entities to the Datastore.
121
116
  #
122
- # === Parameters
117
+ # @param [Entity] entities One or more entity objects to be saved without
118
+ # `id` or `name` set.
123
119
  #
124
- # +entities+::
125
- # One or more entity objects to be saved without +id+ or +name+ set.
126
- # (+Entity+)
127
- #
128
- # === Returns
129
- #
130
- # Array of Gcloud::Datastore::Entity
131
- #
132
- # === Example
120
+ # @return [Array<Gcloud::Datastore::Entity>]
133
121
  #
122
+ # @example
134
123
  # dataset.save task1, task2
135
124
  #
136
125
  def save *entities
@@ -144,27 +133,17 @@ module Gcloud
144
133
  ##
145
134
  # Retrieve an entity by providing key information.
146
135
  #
147
- # === Parameters
148
- #
149
- # +key_or_kind+::
150
- # A Key object or +kind+ string value. (+Key+ or +String+)
151
- # +id_or_name+::
152
- # The Key's +id+ or +name+ value if a +kind+ was provided in the first
153
- # parameter. (+Integer+ or +String+ or +nil+)
154
- #
155
- # === Returns
136
+ # @param [Key, String] key_or_kind A Key object or `kind` string value.
137
+ # @param [Integer, String, nil] id_or_name The Key's `id` or `name` value
138
+ # if a `kind` was provided in the first parameter.
156
139
  #
157
- # Gcloud::Datastore::Entity or +nil+
158
- #
159
- # === Example
160
- #
161
- # Finding an entity with a key:
140
+ # @return [Gcloud::Datastore::Entity, nil]
162
141
  #
142
+ # @example Finding an entity with a key:
163
143
  # key = dataset.key "Task", 123456
164
144
  # task = dataset.find key
165
145
  #
166
- # Finding an entity with a +kind+ and +id+/+name+:
167
- #
146
+ # @example Finding an entity with a `kind` and `id`/`name`:
168
147
  # task = dataset.find "Task", 123456
169
148
  #
170
149
  def find key_or_kind, id_or_name = nil
@@ -179,17 +158,11 @@ module Gcloud
179
158
  ##
180
159
  # Retrieve the entities for the provided keys.
181
160
  #
182
- # === Parameters
183
- #
184
- # +keys+::
185
- # One or more Key objects to find records for. (+Key+)
186
- #
187
- # === Returns
188
- #
189
- # Gcloud::Datastore::Dataset::LookupResults
161
+ # @param [Key] keys One or more Key objects to find records for.
190
162
  #
191
- # === Example
163
+ # @return [Gcloud::Datastore::Dataset::LookupResults]
192
164
  #
165
+ # @example
193
166
  # gcloud = Gcloud.new
194
167
  # dataset = gcloud.datastore
195
168
  # key1 = dataset.key "Task", 123456
@@ -208,17 +181,12 @@ module Gcloud
208
181
  ##
209
182
  # Remove entities from the Datastore.
210
183
  #
211
- # === Parameters
184
+ # @param [Entity, Key] entities_or_keys One or more Entity or Key objects
185
+ # to remove.
212
186
  #
213
- # +entities_or_keys+::
214
- # One or more Entity or Key objects to remove. (+Entity+ or +Key+)
215
- #
216
- # === Returns
217
- #
218
- # +true+ if successful
219
- #
220
- # === Example
187
+ # @return [Boolean] Returns `true` if successful
221
188
  #
189
+ # @example
222
190
  # gcloud = Gcloud.new
223
191
  # dataset = gcloud.datastore
224
192
  # dataset.delete entity1, entity2
@@ -237,26 +205,17 @@ module Gcloud
237
205
  ##
238
206
  # Retrieve entities specified by a Query.
239
207
  #
240
- # === Parameters
241
- #
242
- # +query+::
243
- # The Query object with the search criteria. (+Query+)
244
- # +namespace+::
245
- # The namespace the query is to run within. (+String+)
246
- #
247
- # === Returns
208
+ # @param [Query] query The Query object with the search criteria.
209
+ # @param [String] namespace The namespace the query is to run within.
248
210
  #
249
- # Gcloud::Datastore::Dataset::QueryResults
250
- #
251
- # === Examples
211
+ # @return [Gcloud::Datastore::Dataset::QueryResults]
252
212
  #
213
+ # @example
253
214
  # query = dataset.query("Task").
254
215
  # where("completed", "=", true)
255
216
  # tasks = dataset.run query
256
217
  #
257
- # The query can optionally run within namespace when the +namespace+
258
- # option is provided:
259
- #
218
+ # @example Run the query within a namespace with the `namespace` option:
260
219
  # query = Gcloud::Datastore::Query.new.kind("Task").
261
220
  # where("completed", "=", true)
262
221
  # tasks = dataset.run query, namespace: "ns~todo-project"
@@ -274,10 +233,10 @@ module Gcloud
274
233
  ##
275
234
  # Creates a Datastore Transaction.
276
235
  #
277
- # === Example
278
- #
279
- # Runs the given block in a database transaction:
236
+ # @yield [tx] a block yielding a new transaction
237
+ # @yieldparam [Transaction] tx the transaction object
280
238
  #
239
+ # @example Runs the given block in a database transaction:
281
240
  # require "gcloud"
282
241
  #
283
242
  # gcloud = Gcloud.new
@@ -294,8 +253,7 @@ module Gcloud
294
253
  # end
295
254
  # end
296
255
  #
297
- # Alternatively, if no block is given a Transaction object is returned:
298
- #
256
+ # @example If no block is given, a Transaction object is returned:
299
257
  # require "gcloud"
300
258
  #
301
259
  # gcloud = Gcloud.new
@@ -333,23 +291,16 @@ module Gcloud
333
291
  # Create a new Query instance. This is a convenience method to make the
334
292
  # creation of Query objects easier.
335
293
  #
336
- # === Parameters
337
- #
338
- # +kinds+::
339
- # The kind of entities to query. This is optional. (+String+)
340
- #
341
- # === Returns
294
+ # @param [String] kinds The kind of entities to query. This is optional.
342
295
  #
343
- # Gcloud::Datastore::Query
344
- #
345
- # === Example
296
+ # @return [Gcloud::Datastore::Query]
346
297
  #
298
+ # @example
347
299
  # query = dataset.query("Task").
348
300
  # where("completed", "=", true)
349
301
  # tasks = dataset.run query
350
302
  #
351
- # This code is equivalent to the following:
352
- #
303
+ # @example The previous example is equivalent to:
353
304
  # query = Gcloud::Datastore::Query.new.
354
305
  # kind("Task").
355
306
  # where("completed", "=", true)
@@ -365,23 +316,16 @@ module Gcloud
365
316
  # Create a new Key instance. This is a convenience method to make the
366
317
  # creation of Key objects easier.
367
318
  #
368
- # === Parameters
369
- #
370
- # +kind+::
371
- # The kind of the Key. This is optional. (+String+)
372
- # +id_or_name+::
373
- # The id or name of the Key. This is optional. (+Integer+ or +String+)
374
- #
375
- # === Returns
376
- #
377
- # Gcloud::Datastore::Key
319
+ # @param [String] kind The kind of the Key. This is optional.
320
+ # @param [Integer, String] id_or_name The id or name of the Key. This is
321
+ # optional.
378
322
  #
379
- # === Example
323
+ # @return [Gcloud::Datastore::Key]
380
324
  #
325
+ # @example
381
326
  # key = dataset.key "User", "heidi@example.com"
382
327
  #
383
- # This code is equivalent to the following:
384
- #
328
+ # @example The previous example is equivalent to:
385
329
  # key = Gcloud::Datastore::Key.new "User", "heidi@example.com"
386
330
  #
387
331
  def key kind = nil, id_or_name = nil
@@ -392,50 +336,39 @@ module Gcloud
392
336
  # Create a new empty Entity instance. This is a convenience method to make
393
337
  # the creation of Entity objects easier.
394
338
  #
395
- # === Parameters
396
- #
397
- # +key_or_kind+::
398
- # A Key object or +kind+ string value. This is optional. (+Key+ or
399
- # +String+ or +nil+)
400
- # +id_or_name+::
401
- # The Key's +id+ or +name+ value if a +kind+ was provided in the first
402
- # parameter. (+Integer+ or +String+ or +nil+)
403
- #
404
- # === Returns
339
+ # @param [Key, String, nil] key_or_kind A Key object or `kind` string
340
+ # value. This is optional.
341
+ # @param [Integer, String, nil] id_or_name The Key's `id` or `name` value
342
+ # if a `kind` was provided in the first parameter.
343
+ # @yield [entity] a block yielding a new entity
344
+ # @yieldparam [Entity] entity the newly created entity object
405
345
  #
406
- # Gcloud::Datastore::Entity
407
- #
408
- # === Examples
346
+ # @return [Gcloud::Datastore::Entity]
409
347
  #
348
+ # @example
410
349
  # entity = dataset.entity
411
350
  #
412
- # This code is equivalent to the following:
413
- #
351
+ # @example The previous example is equivalent to:
414
352
  # entity = Gcloud::Datastore::Entity.new
415
353
  #
416
- # The key can also be passed in as an object:
417
- #
354
+ # @example The key can also be passed in as an object:
418
355
  # key = dataset.key "User", "heidi@example.com"
419
356
  # entity = dataset.entity key
420
357
  #
421
- # Or the key values can be passed in as parameters:
422
- #
358
+ # @example Or the key values can be passed in as parameters:
423
359
  # entity = dataset.entity "User", "heidi@example.com"
424
360
  #
425
- # This code is equivalent to the following:
426
- #
361
+ # @example The previous example is equivalent to:
427
362
  # key = Gcloud::Datastore::Key.new "User", "heidi@example.com"
428
363
  # entity = Gcloud::Datastore::Entity.new
429
364
  # entity.key = key
430
365
  #
431
- # The newly created entity object can also be configured using a block:
432
- #
366
+ # @example The newly created entity can also be configured using a block:
433
367
  # user = dataset.entity "User", "heidi@example.com" do |u|
434
368
  # u["name"] = "Heidi Henderson"
435
369
  # end
436
370
  #
437
- # This code is equivalent to the following:
438
- #
371
+ # @example The previous example is equivalent to:
439
372
  # key = Gcloud::Datastore::Key.new "User", "heidi@example.com"
440
373
  # entity = Gcloud::Datastore::Entity.new
441
374
  # entity.key = key
@@ -477,15 +410,15 @@ module Gcloud
477
410
  end
478
411
 
479
412
  ##
480
- # Save a key to be given an ID when comitted.
481
- def auto_id_register entity #:nodoc:
413
+ # @private Save a key to be given an ID when comitted.
414
+ def auto_id_register entity
482
415
  @_auto_id_entities ||= []
483
416
  @_auto_id_entities << entity
484
417
  end
485
418
 
486
419
  ##
487
- # Update saved keys with new IDs post-commit.
488
- def auto_id_assign_ids auto_ids #:nodoc:
420
+ # @private Update saved keys with new IDs post-commit.
421
+ def auto_id_assign_ids auto_ids
489
422
  @_auto_id_entities ||= []
490
423
  Array(auto_ids).each_with_index do |key, index|
491
424
  entity = @_auto_id_entities[index]
@@ -495,9 +428,9 @@ module Gcloud
495
428
  end
496
429
 
497
430
  ##
498
- # Add entities to a Mutation, and register they key to be
431
+ # @private Add entities to a Mutation, and register they key to be
499
432
  # updated with an auto ID if needed.
500
- def save_entities_to_mutation entities, mutation #:nodoc:
433
+ def save_entities_to_mutation entities, mutation
501
434
  entities.each do |entity|
502
435
  if entity.key.id.nil? && entity.key.name.nil?
503
436
  mutation.insert_auto_id << entity.to_proto