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.
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,19 +12,19 @@
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 "signet/oauth_2/client"
18
18
  require "forwardable"
19
19
  require "googleauth"
20
20
 
21
- #--
22
- # Google Cloud Credentials
23
21
  module Gcloud
24
22
  ##
23
+ # @private
25
24
  # Represents the OAuth 2.0 signing logic.
26
25
  # This class is intended to be inherited by API-specific classes
27
26
  # which overrides the SCOPE constant.
28
- class Credentials #:nodoc:
27
+ class Credentials
29
28
  TOKEN_CREDENTIAL_URI = "https://accounts.google.com/o/oauth2/token"
30
29
  AUDIENCE = "https://accounts.google.com/o/oauth2/token"
31
30
  SCOPE = []
@@ -59,9 +58,6 @@ module Gcloud
59
58
  @client.fetch_access_token!
60
59
  end
61
60
 
62
- # rubocop:disable all
63
- # Disabled rubocop because this is intentionally complex.
64
-
65
61
  ##
66
62
  # Returns the default credentials.
67
63
  #
@@ -88,8 +84,6 @@ module Gcloud
88
84
  new client
89
85
  end
90
86
 
91
- # rubocop:enable all
92
-
93
87
  protected
94
88
 
95
89
  ##
@@ -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,43 +12,38 @@
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"
17
17
  require "gcloud/datastore/errors"
18
18
  require "gcloud/datastore/dataset"
19
19
  require "gcloud/datastore/transaction"
20
20
  require "gcloud/datastore/credentials"
21
21
 
22
- #--
23
- # Google Cloud Datastore
24
22
  module Gcloud
25
23
  ##
26
24
  # Creates a new object for connecting to the Datastore service.
27
25
  # Each call creates a new connection.
28
26
  #
29
- # === Parameters
27
+ # For more information on connecting to Google Cloud see the [Authentication
28
+ # Guide](https://googlecloudplatform.github.io/gcloud-ruby/#/docs/guides/authentication).
30
29
  #
31
- # +project+::
32
- # Dataset identifier for the Datastore you are connecting to. (+String+)
33
- # +keyfile+::
34
- # Keyfile downloaded from Google Cloud. If file path the file must be
35
- # readable. (+String+ or +Hash+)
36
- # +scope+::
37
- # The OAuth 2.0 scopes controlling the set of resources and operations that
38
- # the connection can access. See {Using OAuth 2.0 to Access Google
39
- # APIs}[https://developers.google.com/identity/protocols/OAuth2]. (+String+
40
- # or +Array+)
30
+ # @param [String] project Dataset identifier for the Datastore you are
31
+ # connecting to.
32
+ # @param [String, Hash] keyfile Keyfile downloaded from Google Cloud. If file
33
+ # path the file must be readable.
34
+ # @param [String, Array<String>] scope The OAuth 2.0 scopes controlling the
35
+ # set of resources and operations that the connection can access. See [Using
36
+ # OAuth 2.0 to Access Google
37
+ # APIs](https://developers.google.com/identity/protocols/OAuth2).
41
38
  #
42
39
  # The default scopes are:
43
40
  #
44
- # * +https://www.googleapis.com/auth/datastore+
45
- # * +https://www.googleapis.com/auth/userinfo.email+
46
- #
47
- # === Returns
41
+ # * `https://www.googleapis.com/auth/datastore`
42
+ # * `https://www.googleapis.com/auth/userinfo.email`
48
43
  #
49
- # Gcloud::Datastore::Dataset
50
- #
51
- # === Example
44
+ # @return [Gcloud::Datastore::Dataset]
52
45
  #
46
+ # @example
53
47
  # require "gcloud/datastore"
54
48
  #
55
49
  # dataset = Gcloud.datastore "my-todo-project",
@@ -73,7 +67,7 @@ module Gcloud
73
67
  end
74
68
 
75
69
  ##
76
- # = Google Cloud Datastore
70
+ # # Google Cloud Datastore
77
71
  #
78
72
  # Google Cloud Datastore is a fully managed, schemaless database for storing
79
73
  # non-relational data. You should feel at home if you are familiar with
@@ -81,235 +75,265 @@ module Gcloud
81
75
  # make the most of using Datastore.
82
76
  #
83
77
  # Gcloud's goal is to provide a API that is familiar and comfortable to
84
- # Rubyists. Authentication is handled by Gcloud#datastore. You can provide
78
+ # Rubyists. Authentication is handled by {Gcloud#datastore}. You can provide
85
79
  # the project and credential information to connect to the Datastore service,
86
80
  # or if you are running on Google Compute Engine this configuration is taken
87
81
  # care of for you.
88
82
  #
89
- # require "gcloud"
83
+ # ```ruby
84
+ # require "gcloud"
90
85
  #
91
- # gcloud = Gcloud.new "my-todo-project",
92
- # "/path/to/keyfile.json"
93
- # dataset = gcloud.datastore
94
- # entity = dataset.find "Task", "start"
95
- # entity["completed"] = true
96
- # dataset.save entity
86
+ # gcloud = Gcloud.new "my-todo-project",
87
+ # "/path/to/keyfile.json"
88
+ # dataset = gcloud.datastore
89
+ # entity = dataset.find "Task", "start"
90
+ # entity["completed"] = true
91
+ # dataset.save entity
92
+ # ```
97
93
  #
98
94
  # You can learn more about various options for connection on the
99
- # {Authentication Guide}[link:AUTHENTICATION.md].
95
+ # [Authentication
96
+ # Guide](https://googlecloudplatform.github.io/gcloud-ruby/#/docs/guides/authentication).
100
97
  #
101
98
  # To learn more about Datastore, read the
102
- # {Google Cloud Datastore Concepts Overview
103
- # }[https://cloud.google.com/datastore/docs/concepts/overview].
99
+ # [Google Cloud Datastore Concepts Overview
100
+ # ](https://cloud.google.com/datastore/docs/concepts/overview).
104
101
  #
105
- # == Retrieving Records
102
+ # ## Retrieving Records
106
103
  #
107
104
  # Records, called "entities" in Datastore, are retrieved by using a Key.
108
105
  # The Key is more than a numeric identifier, it is a complex data structure
109
106
  # that can be used to model relationships. The simplest Key has a string
110
107
  # <tt>kind</tt> value, and either a numeric <tt>id</tt> value, or a string
111
108
  # <tt>name</tt> value. A single record can be retrieved by calling
112
- # Gcloud::Datastore::Dataset#find and passing the parts of the key:
109
+ # {Gcloud::Datastore::Dataset#find} and passing the parts of the key:
113
110
  #
114
- # require "gcloud"
111
+ # ```ruby
112
+ # require "gcloud"
115
113
  #
116
- # gcloud = Gcloud.new
117
- # dataset = gcloud.datastore
118
- # entity = dataset.find "Task", "start"
114
+ # gcloud = Gcloud.new
115
+ # dataset = gcloud.datastore
116
+ # entity = dataset.find "Task", "start"
117
+ # ```
119
118
  #
120
- # Optionally, Gcloud::Datastore::Dataset#find can be given a Key object:
119
+ # Optionally, {Gcloud::Datastore::Dataset#find} can be given a Key object:
121
120
  #
122
- # require "gcloud"
121
+ # ```ruby
122
+ # require "gcloud"
123
123
  #
124
- # gcloud = Gcloud.new
125
- # dataset = gcloud.datastore
126
- # key = dataset.key "Task", 12345
127
- # entity = dataset.find key
124
+ # gcloud = Gcloud.new
125
+ # dataset = gcloud.datastore
126
+ # key = dataset.key "Task", 12345
127
+ # entity = dataset.find key
128
+ # ```
128
129
  #
129
- # See Gcloud::Datastore::Dataset#find
130
+ # See {Gcloud::Datastore::Dataset#find}
130
131
  #
131
- # == Querying Records
132
+ # ## Querying Records
132
133
  #
133
134
  # Multiple records can be found that match criteria.
134
- # (See Gcloud::Datastore::Query#where)
135
+ # (See {Gcloud::Datastore::Query#where})
135
136
  #
136
- # require "gcloud"
137
+ # ```ruby
138
+ # require "gcloud"
137
139
  #
138
- # gcloud = Gcloud.new
139
- # dataset = gcloud.datastore
140
- # query = dataset.query("List").
141
- # where("active", "=", true)
142
- # active_lists = dataset.run query
140
+ # gcloud = Gcloud.new
141
+ # dataset = gcloud.datastore
142
+ # query = dataset.query("List").
143
+ # where("active", "=", true)
144
+ # active_lists = dataset.run query
145
+ # ```
143
146
  #
144
- # Records can also be ordered. (See Gcloud::Datastore::Query#order)
147
+ # Records can also be ordered. (See {Gcloud::Datastore::Query#order})
145
148
  #
146
- # require "gcloud"
149
+ # ```ruby
150
+ # require "gcloud"
147
151
  #
148
- # gcloud = Gcloud.new
149
- # dataset = gcloud.datastore
150
- # query = dataset.query("List").
151
- # where("active", "=", true).
152
- # order("name")
153
- # active_lists = dataset.run query
152
+ # gcloud = Gcloud.new
153
+ # dataset = gcloud.datastore
154
+ # query = dataset.query("List").
155
+ # where("active", "=", true).
156
+ # order("name")
157
+ # active_lists = dataset.run query
158
+ # ```
154
159
  #
155
160
  # The number of records returned can be specified.
156
- # (See Gcloud::Datastore::Query#limit)
161
+ # (See {Gcloud::Datastore::Query#limit})
157
162
  #
158
- # require "gcloud"
163
+ # ```ruby
164
+ # require "gcloud"
159
165
  #
160
- # gcloud = Gcloud.new
161
- # dataset = gcloud.datastore
162
- # query = dataset.query("List").
163
- # where("active", "=", true).
164
- # order("name").
165
- # limit(5)
166
- # active_lists = dataset.run query
166
+ # gcloud = Gcloud.new
167
+ # dataset = gcloud.datastore
168
+ # query = dataset.query("List").
169
+ # where("active", "=", true).
170
+ # order("name").
171
+ # limit(5)
172
+ # active_lists = dataset.run query
173
+ # ```
167
174
  #
168
175
  # Records' Key structures can also be queried.
169
- # (See Gcloud::Datastore::Query#ancestor)
176
+ # (See {Gcloud::Datastore::Query#ancestor})
170
177
  #
171
- # require "gcloud"
178
+ # ```ruby
179
+ # require "gcloud"
172
180
  #
173
- # gcloud = Gcloud.new
174
- # dataset = gcloud.datastore
181
+ # gcloud = Gcloud.new
182
+ # dataset = gcloud.datastore
175
183
  #
176
- # list = dataset.find "List", "todos"
177
- # query = dataset.query("Task").
178
- # ancestor(list.key)
179
- # items = dataset.run query
184
+ # list = dataset.find "List", "todos"
185
+ # query = dataset.query("Task").
186
+ # ancestor(list.key)
187
+ # items = dataset.run query
188
+ # ```
180
189
  #
181
- # See Gcloud::Datastore::Query and Gcloud::Datastore::Dataset#run
190
+ # See {Gcloud::Datastore::Query} and {Gcloud::Datastore::Dataset#run}
182
191
  #
183
- # == Paginating Records
192
+ # ## Paginating Records
184
193
  #
185
194
  # All Records may not return at once, requiring multiple calls to Datastore
186
195
  # to return them all. The returned records will have a <tt>cursor</tt> if
187
196
  # there are more available.
188
197
  #
189
- # require "gcloud"
198
+ # ```ruby
199
+ # require "gcloud"
190
200
  #
191
- # gcloud = Gcloud.new
192
- # dataset = gcloud.datastore
201
+ # gcloud = Gcloud.new
202
+ # dataset = gcloud.datastore
193
203
  #
194
- # list = dataset.find "List", "todos"
195
- # query = dataset.query("Task").
196
- # ancestor(list.key)
197
- # all_tasks = []
198
- # tmp_tasks = dataset.run query
199
- # while tmp_tasks.any? do
200
- # tmp_tasks.each do |task|
201
- # all_tasks << task
202
- # end
203
- # # break loop if no more tasks available
204
- # break if tmp_tasks.cursor.nil?
205
- # # set cursor on the query
206
- # query = query.cursor tmp_tasks.cursor
207
- # # query for more records
208
- # tmp_tasks = dataset.run query
204
+ # list = dataset.find "List", "todos"
205
+ # query = dataset.query("Task").
206
+ # ancestor(list.key)
207
+ # all_tasks = []
208
+ # tmp_tasks = dataset.run query
209
+ # while tmp_tasks.any? do
210
+ # tmp_tasks.each do |task|
211
+ # all_tasks << task
209
212
  # end
213
+ # # break loop if no more tasks available
214
+ # break if tmp_tasks.cursor.nil?
215
+ # # set cursor on the query
216
+ # query = query.cursor tmp_tasks.cursor
217
+ # # query for more records
218
+ # tmp_tasks = dataset.run query
219
+ # end
220
+ # ```
210
221
  #
211
- # See Gcloud::Datastore::Dataset::LookupResults and
212
- # Gcloud::Datastore::Dataset::QueryResults
222
+ # See {Gcloud::Datastore::Dataset::LookupResults} and
223
+ # {Gcloud::Datastore::Dataset::QueryResults}
213
224
  #
214
- # == Creating Records
225
+ # ## Creating Records
215
226
  #
216
- # New entities can be created and persisted buy calling Dataset#save.
217
- # The entity must have a Key to be saved. If the Key is incomplete then
218
- # it will be completed when saved.
227
+ # New entities can be created and persisted buy calling
228
+ # {Gcloud::Datastore::Dataset#save}. The entity must have a Key to be saved.
229
+ # If the Key is incomplete then it will be completed when saved.
219
230
  #
220
- # require "gcloud"
231
+ # ```ruby
232
+ # require "gcloud"
221
233
  #
222
- # gcloud = Gcloud.new
223
- # dataset = gcloud.datastore
224
- # entity = dataset.entity "User" do |e|
225
- # e["name"] = "Heidi Henderson"
226
- # end
227
- # entity.key.id #=> nil
228
- # dataset.save entity
229
- # entity.key.id #=> 123456789
234
+ # gcloud = Gcloud.new
235
+ # dataset = gcloud.datastore
236
+ # entity = dataset.entity "User" do |e|
237
+ # e["name"] = "Heidi Henderson"
238
+ # end
239
+ # entity.key.id #=> nil
240
+ # dataset.save entity
241
+ # entity.key.id #=> 123456789
242
+ # ```
230
243
  #
231
- # == Updating Records
244
+ # ## Updating Records
232
245
  #
233
246
  # Entities hold properties. A property has a name that is a string or symbol,
234
247
  # and a value that is an object. Most value objects are supported, including
235
248
  # String, Integer, Date, Time, and even other Entity or Key objects. Changes
236
- # to the Entity's properties are persisted by calling Dataset#save.
237
- #
238
- # require "gcloud"
239
- #
240
- # gcloud = Gcloud.new
241
- # dataset = gcloud.datastore
242
- # entity = dataset.find "User", "heidi"
243
- # # Read the status property
244
- # entity["status"] #=> "inactive"
245
- # # Write the status property
246
- # entity["status"] = "active"
247
- # # Persist the changes
248
- # dataset.save entity
249
+ # to the Entity's properties are persisted by calling
250
+ # {Gcloud::Datastore::Dataset#save}.
251
+ #
252
+ # ```ruby
253
+ # require "gcloud"
254
+ #
255
+ # gcloud = Gcloud.new
256
+ # dataset = gcloud.datastore
257
+ # entity = dataset.find "User", "heidi"
258
+ # # Read the status property
259
+ # entity["status"] #=> "inactive"
260
+ # # Write the status property
261
+ # entity["status"] = "active"
262
+ # # Persist the changes
263
+ # dataset.save entity
264
+ # ```
249
265
  #
250
- # == Deleting Records
266
+ # ## Deleting Records
251
267
  #
252
- # Entities can be removed from Datastore by calling Dataset#delete and passing
253
- # the Entity object or the entity's Key object.
268
+ # Entities can be removed from Datastore by calling
269
+ # {Gcloud::Datastore::Dataset#delete} and passing the Entity object or the
270
+ # entity's Key object.
254
271
  #
255
- # require "gcloud"
272
+ # ```ruby
273
+ # require "gcloud"
256
274
  #
257
- # gcloud = Gcloud.new
258
- # dataset = gcloud.datastore
259
- # entity = dataset.find "User", "heidi"
260
- # dataset.delete entity
275
+ # gcloud = Gcloud.new
276
+ # dataset = gcloud.datastore
277
+ # entity = dataset.find "User", "heidi"
278
+ # dataset.delete entity
279
+ # ```
261
280
  #
262
- # == Transactions
281
+ # ## Transactions
263
282
  #
264
283
  # Complex logic can be wrapped in a Transaction. All queries and updates
265
- # within the Dataset#transaction block are run within the transaction scope,
266
- # and will be automatically committed when the block completes.
284
+ # within the {Gcloud::Datastore::Dataset#transaction} block are run within the
285
+ # transaction scope, and will be automatically committed when the block
286
+ # completes.
267
287
  #
268
- # require "gcloud"
288
+ # ```ruby
289
+ # require "gcloud"
269
290
  #
270
- # gcloud = Gcloud.new
271
- # dataset = gcloud.datastore
291
+ # gcloud = Gcloud.new
292
+ # dataset = gcloud.datastore
272
293
  #
273
- # key = dataset.key "User", "heidi"
294
+ # key = dataset.key "User", "heidi"
274
295
  #
275
- # user = dataset.entity key do |u|
276
- # u["name"] = "Heidi Henderson"
277
- # u["email"] = "heidi@example.net"
278
- # end
296
+ # user = dataset.entity key do |u|
297
+ # u["name"] = "Heidi Henderson"
298
+ # u["email"] = "heidi@example.net"
299
+ # end
279
300
  #
280
- # dataset.transaction do |tx|
281
- # if tx.find(user.key).nil?
282
- # tx.save user
283
- # end
301
+ # dataset.transaction do |tx|
302
+ # if tx.find(user.key).nil?
303
+ # tx.save user
284
304
  # end
305
+ # end
306
+ # ```
285
307
  #
286
308
  # Alternatively, if no block is given the transaction object is returned
287
309
  # allowing you to commit or rollback manually.
288
310
  #
289
- # require "gcloud"
311
+ # ```ruby
312
+ # require "gcloud"
290
313
  #
291
- # gcloud = Gcloud.new
292
- # dataset = gcloud.datastore
314
+ # gcloud = Gcloud.new
315
+ # dataset = gcloud.datastore
293
316
  #
294
- # key = dataset.key "User", "heidi"
317
+ # key = dataset.key "User", "heidi"
295
318
  #
296
- # user = dataset.entity key do |u|
297
- # u["name"] = "Heidi Henderson"
298
- # u["email"] = "heidi@example.net"
299
- # end
319
+ # user = dataset.entity key do |u|
320
+ # u["name"] = "Heidi Henderson"
321
+ # u["email"] = "heidi@example.net"
322
+ # end
300
323
  #
301
- # tx = dataset.transaction
302
- # begin
303
- # if tx.find(user.key).nil?
304
- # tx.save user
305
- # end
306
- # tx.commit
307
- # rescue
308
- # tx.rollback
324
+ # tx = dataset.transaction
325
+ # begin
326
+ # if tx.find(user.key).nil?
327
+ # tx.save user
309
328
  # end
310
- #
311
- # See Gcloud::Datastore::Transaction and
312
- # Gcloud::Datastore::Dataset#transaction
329
+ # tx.commit
330
+ # rescue
331
+ # tx.rollback
332
+ # end
333
+ # ```
334
+ #
335
+ # See {Gcloud::Datastore::Transaction} and
336
+ # {Gcloud::Datastore::Dataset#transaction}
313
337
  module Datastore
314
338
  end
315
339
  end