google-cloud-datastore 1.4.1 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6677adc0fe54bae8453d609401a902aa2afc5e1231b5ee57a3b75c1d86cdda7e
4
- data.tar.gz: f8092af4287def66a0ff425150039e5e9a2dae3e38a2f1adcff037700f01c4c7
3
+ metadata.gz: ed948cf1137d8762a24cdace7370bd5a1609d5954e60efcec8a3a641ebac7c3c
4
+ data.tar.gz: cbbb8c6d267386d6906df1af8f5b45a75ec091a5f7dcb50136f7a1883da32aaa
5
5
  SHA512:
6
- metadata.gz: 9690a8f334e5b29a2d18e89420f0adb787b0b5a2b3f5b2c36e8bb7fb4087b566848ed2cb8fff800fe932e60b8225702fe469f6b99e8e1945614a7fbd175705c8
7
- data.tar.gz: 77b81d3cab09c0bfe41b2b644f8b7932835a6a0731c90d6f22127a99952703a0ab11b899e1e26ec26a6118ed15d9d8e42d33e2c7f5afef14b33e06927a9d973d
6
+ metadata.gz: 4ada6f3aedfec41a0ef6f63bb9729c77f5640766f6fcff3084a6036949046558a5dd428698e72ec921e53d8bb25f3ee8c9f616f9e4df69ae2b0bdc021e3899ed
7
+ data.tar.gz: b5b4ae1707fc512ac968d5871af9c4331af7a6700f7d048defce3bbe1fbe2fa62339410fd5632ce74fe5fe1f1f23c83b6311165f8ff2fe567d44f86695ae95cb
data/.yardopts CHANGED
@@ -3,7 +3,16 @@
3
3
  --exclude _pb\.rb$
4
4
  --markup markdown
5
5
  --markup-provider redcarpet
6
+ --main OVERVIEW.md
6
7
 
7
8
  ./lib/**/*.rb
8
9
  -
9
- README.md
10
+ OVERVIEW.md
11
+ AUTHENTICATION.md
12
+ EMULATOR.md
13
+ LOGGING.md
14
+ CONTRIBUTING.md
15
+ TROUBLESHOOTING.md
16
+ CHANGELOG.md
17
+ CODE_OF_CONDUCT.md
18
+ LICENSE
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  Follow the [activation instructions](https://cloud.google.com/datastore/docs/activate) to use the Google Cloud Datastore API with your project.
6
6
 
7
- - [google-cloud-datastore API documentation](http://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-datastore/latest)
7
+ - [google-cloud-datastore API documentation](http://googlecloudplatform.github.io/google-cloud-ruby/docs/google-cloud-datastore/latest)
8
8
  - [google-cloud-datastore on RubyGems](https://rubygems.org/gems/google-cloud-datastore)
9
9
  - [Google Cloud Datastore documentation](https://cloud.google.com/datastore/docs)
10
10
 
@@ -18,7 +18,7 @@ $ gem install google-cloud-datastore
18
18
 
19
19
  This library uses Service Account credentials to connect to Google Cloud services. When running on Compute Engine the credentials will be discovered automatically. When running on other environments the Service Account credentials can be specified by providing the path to the JSON file, or the JSON itself, in environment variables.
20
20
 
21
- Instructions and configuration options are covered in the [Authentication Guide](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-datastore/guides/authentication).
21
+ Instructions and configuration options are covered in the [Authentication Guide](https://googlecloudplatform.github.io/google-cloud-ruby/docs/google-cloud-datastore/latest/file.AUTHENTICATION).
22
22
 
23
23
  ## Example
24
24
 
@@ -49,7 +49,7 @@ tasks = datastore.run query
49
49
 
50
50
  ## Enabling Logging
51
51
 
52
- To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library. The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html) as shown below, or a [`Google::Cloud::Logging::Logger`](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-logging/latest/google/cloud/logging/logger) that will write logs to [Stackdriver Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb) and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
52
+ To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library. The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html) as shown below, or a [`Google::Cloud::Logging::Logger`](https://googlecloudplatform.github.io/google-cloud-ruby/docs/google-cloud-logging/latest/Google/Cloud/Logging/Logger) that will write logs to [Stackdriver Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb) and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
53
53
 
54
54
  Configuring a Ruby stdlib logger:
55
55
 
@@ -74,9 +74,9 @@ end
74
74
  This library is supported on Ruby 2.3+.
75
75
 
76
76
  Google provides official support for Ruby versions that are actively supported
77
- by Ruby Core—that is, Ruby versions that are either in normal maintenance or
78
- in security maintenance, and not end of life. Currently, this means Ruby 2.3
79
- and later. Older versions of Ruby _may_ still work, but are unsupported and not
77
+ by Ruby Core—that is, Ruby versions that are either in normal maintenance or in
78
+ security maintenance, and not end of life. Currently, this means Ruby 2.3 and
79
+ later. Older versions of Ruby _may_ still work, but are unsupported and not
80
80
  recommended. See https://www.ruby-lang.org/en/downloads/branches/ for details
81
81
  about the Ruby support schedule.
82
82
 
@@ -88,15 +88,24 @@ This library follows [Semantic Versioning](http://semver.org/).
88
88
 
89
89
  Contributions to this library are always welcome and highly encouraged.
90
90
 
91
- See the [Contributing Guide](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/guides/contributing) for more information on how to get started.
91
+ See the [Contributing
92
+ Guide](https://googlecloudplatform.github.io/google-cloud-ruby/docs/google-cloud-datastore/latest/file.CONTRIBUTING)
93
+ for more information on how to get started.
92
94
 
93
- Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms. See [Code of Conduct](../CODE_OF_CONDUCT.md) for more information.
95
+ Please note that this project is released with a Contributor Code of Conduct. By
96
+ participating in this project you agree to abide by its terms. See [Code of
97
+ Conduct](https://googlecloudplatform.github.io/google-cloud-ruby/docs/google-cloud-datastore/latest/file.CODE_OF_CONDUCT)
98
+ for more information.
94
99
 
95
100
  ## License
96
101
 
97
- This library is licensed under Apache 2.0. Full license text is available in [LICENSE](LICENSE).
102
+ This library is licensed under Apache 2.0. Full license text is available in
103
+ [LICENSE](https://googlecloudplatform.github.io/google-cloud-ruby/docs/google-cloud-datastore/latest/file.LICENSE).
98
104
 
99
105
  ## Support
100
106
 
101
- Please [report bugs at the project on Github](https://github.com/GoogleCloudPlatform/google-cloud-ruby/issues).
102
- Don't hesitate to [ask questions](http://stackoverflow.com/questions/tagged/google-cloud-platform+ruby) about the client or APIs on [StackOverflow](http://stackoverflow.com).
107
+ Please [report bugs at the project on
108
+ Github](https://github.com/GoogleCloudPlatform/google-cloud-ruby/issues). Don't
109
+ hesitate to [ask
110
+ questions](http://stackoverflow.com/questions/tagged/google-cloud-platform+ruby)
111
+ about the client or APIs on [StackOverflow](http://stackoverflow.com).
@@ -12,6 +12,7 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+
15
16
  ##
16
17
  # This file is here to be autorequired by bundler, so that the
17
18
  # Google::Cloud.datastore and Google::Cloud#datastore methods can be available,
@@ -29,8 +30,8 @@ module Google
29
30
  # Creates a new object for connecting to the Datastore service.
30
31
  # Each call creates a new connection.
31
32
  #
32
- # For more information on connecting to Google Cloud see the [Authentication
33
- # Guide](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/guides/authentication).
33
+ # For more information on connecting to Google Cloud see the
34
+ # {file:AUTHENTICATION.md Authentication Guide}.
34
35
  #
35
36
  # @param [String, Array<String>] scope The OAuth 2.0 scopes controlling the
36
37
  # set of resources and operations that the connection can access. See
@@ -78,8 +79,8 @@ module Google
78
79
  # Creates a new object for connecting to the Datastore service.
79
80
  # Each call creates a new connection.
80
81
  #
81
- # For more information on connecting to Google Cloud see the [Authentication
82
- # Guide](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/guides/authentication).
82
+ # For more information on connecting to Google Cloud see the
83
+ # {file:AUTHENTICATION.md Authentication Guide}.
83
84
  #
84
85
  # @param [String] project_id Identifier for a Datastore project. If not
85
86
  # present, the default project for the credentials is used.
@@ -31,581 +31,29 @@ module Google
31
31
  # relational databases, but there are some key differences to be aware of to
32
32
  # make the most of using Datastore.
33
33
  #
34
- # The goal of google-cloud is to provide an API that is comfortable to
35
- # Rubyists. Your authentication credentials are detected automatically in
36
- # Google Cloud Platform environments such as Google Compute Engine, Google
37
- # App Engine and Google Kubernetes Engine. In other environments you can
38
- # configure authentication easily, either directly in your code or via
39
- # environment variables. Read more about the options for connecting in the
40
- # [Authentication
41
- # Guide](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/guides/authentication).
34
+ # See {file:OVERVIEW.md Datastore Overview}.
42
35
  #
43
- # ```ruby
44
- # require "google/cloud/datastore"
36
+ # @example
37
+ # require "google/cloud/datastore"
45
38
  #
46
- # datastore = Google::Cloud::Datastore.new(
47
- # project_id: "my-todo-project",
48
- # credentials: "/path/to/keyfile.json"
49
- # )
39
+ # datastore = Google::Cloud::Datastore.new(
40
+ # project_id: "my-todo-project",
41
+ # credentials: "/path/to/keyfile.json"
42
+ # )
50
43
  #
51
- # task = datastore.find "Task", "sampleTask"
52
- # task["priority"] = 5
53
- # datastore.save task
54
- # ```
55
- #
56
- # You can learn more about various options for connection on the
57
- # [Authentication
58
- # Guide](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/guides/authentication).
59
- #
60
- # To learn more about Datastore, read the
61
- # [Google Cloud Datastore Concepts Overview
62
- # ](https://cloud.google.com/datastore/docs/concepts/overview).
63
- #
64
- # ## Enabling Logging
65
- #
66
- # To enable logging for this library, set the logger for the underlying
67
- # [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library. The
68
- # logger that you set may be a Ruby stdlib
69
- # [`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html)
70
- # as shown below, or a
71
- # [`Google::Cloud::Logging::Logger`](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-logging/latest/google/cloud/logging/logger)
72
- # that will write logs to [Stackdriver
73
- # Logging](https://cloud.google.com/logging/). See
74
- # [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
75
- # and the gRPC
76
- # [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb)
77
- # for additional information.
78
- #
79
- # Configuring a Ruby stdlib logger:
80
- #
81
- # ```ruby
82
- # require "logger"
83
- #
84
- # module MyLogger
85
- # LOGGER = Logger.new $stderr, level: Logger::WARN
86
- # def logger
87
- # LOGGER
88
- # end
89
- # end
90
- #
91
- # # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
92
- # module GRPC
93
- # extend MyLogger
94
- # end
95
- # ```
96
- #
97
- # ## Retrieving records
98
- #
99
- # Records, called "entities" in Datastore, are retrieved by using a key.
100
- # The key is more than a numeric identifier, it is a complex data structure
101
- # that can be used to model relationships. The simplest key has a string
102
- # <tt>kind</tt> value and either a numeric <tt>id</tt> value or a string
103
- # <tt>name</tt> value. A single record can be retrieved by calling
104
- # {Google::Cloud::Datastore::Dataset#find} and passing the parts of the key:
105
- #
106
- # ```ruby
107
- # require "google/cloud/datastore"
108
- #
109
- # datastore = Google::Cloud::Datastore.new
110
- #
111
- # task = datastore.find "Task", "sampleTask"
112
- # ```
113
- #
114
- # Optionally, {Google::Cloud::Datastore::Dataset#find} can be given a key
115
- # object:
116
- #
117
- # ```ruby
118
- # require "google/cloud/datastore"
119
- #
120
- # datastore = Google::Cloud::Datastore.new
121
- #
122
- # task_key = datastore.key "Task", 123456
123
- # task = datastore.find task_key
124
- # ```
125
- #
126
- # See {Google::Cloud::Datastore::Dataset#find}
127
- #
128
- # ## Querying records
129
- #
130
- # Multiple records can be found that match criteria.
131
- # (See {Google::Cloud::Datastore::Query#where})
132
- #
133
- # ```ruby
134
- # require "google/cloud/datastore"
135
- #
136
- # datastore = Google::Cloud::Datastore.new
137
- #
138
- # query = datastore.query("Task").
139
- # where("done", "=", false)
140
- #
141
- # tasks = datastore.run query
142
- # ```
143
- #
144
- # Records can also be ordered. (See {Google::Cloud::Datastore::Query#order})
145
- #
146
- # ```ruby
147
- # require "google/cloud/datastore"
148
- #
149
- # datastore = Google::Cloud::Datastore.new
150
- #
151
- # query = datastore.query("Task").
152
- # order("created")
153
- #
154
- # tasks = datastore.run query
155
- # ```
156
- #
157
- # The number of records returned can be specified.
158
- # (See {Google::Cloud::Datastore::Query#limit})
159
- #
160
- # ```ruby
161
- # require "google/cloud/datastore"
162
- #
163
- # datastore = Google::Cloud::Datastore.new
164
- #
165
- # query = datastore.query("Task").
166
- # limit(5)
167
- #
168
- # tasks = datastore.run query
169
- # ```
170
- #
171
- # When using Datastore in a multitenant application, a query may be run
172
- # within a namespace using the `namespace` option. (See
173
- # [Multitenancy](https://cloud.google.com/datastore/docs/concepts/multitenancy))
174
- #
175
- # ```ruby
176
- # require "google/cloud/datastore"
177
- #
178
- # datastore = Google::Cloud::Datastore.new
179
- #
180
- # query = datastore.query("Task").
181
- # where("done", "=", false)
182
- #
183
- # tasks = datastore.run query, namespace: "example-ns"
184
- # ```
185
- #
186
- # Records' key structures can also be queried.
187
- # (See {Google::Cloud::Datastore::Query#ancestor})
188
- #
189
- # ```ruby
190
- # require "google/cloud/datastore"
191
- #
192
- # datastore = Google::Cloud::Datastore.new
193
- #
194
- # task_list_key = datastore.key "TaskList", "default"
195
- #
196
- # query = datastore.query("Task").
197
- # ancestor(task_list_key)
198
- #
199
- # tasks = datastore.run query
200
- # ```
201
- #
202
- # See {Google::Cloud::Datastore::Query} and
203
- # {Google::Cloud::Datastore::Dataset#run}
204
- #
205
- # ### Paginating records
206
- #
207
- # All records may not return at once, but multiple calls can be made to
208
- # Datastore to return them all.
209
- #
210
- # ```ruby
211
- # require "google/cloud/datastore"
212
- #
213
- # datastore = Google::Cloud::Datastore.new
214
- #
215
- # query = datastore.query("Task")
216
- # tasks = datastore.run query
217
- # tasks.all do |t|
218
- # puts t["description"]
219
- # end
220
- # ```
221
- #
222
- # See {Google::Cloud::Datastore::Dataset::LookupResults} and
223
- # {Google::Cloud::Datastore::Dataset::QueryResults}
224
- #
225
- # ## Creating records
226
- #
227
- # New entities can be created and persisted buy calling
228
- # {Google::Cloud::Datastore::Dataset#save}. The entity must have a key to be
229
- # saved. If the key is incomplete then it will be completed when saved.
230
- #
231
- # ```ruby
232
- # require "google/cloud/datastore"
233
- #
234
- # datastore = Google::Cloud::Datastore.new
235
- #
236
- # task = datastore.entity "Task" do |t|
237
- # t["type"] = "Personal"
238
- # t["done"] = false
239
- # t["priority"] = 4
240
- # t["description"] = "Learn Cloud Datastore"
241
- # end
242
- # task.key.id #=> nil
243
- # datastore.save task
244
- # task.key.id #=> 123456
245
- # ```
246
- #
247
- # Multiple new entities may be created in a batch.
248
- #
249
- # ```ruby
250
- # require "google/cloud/datastore"
251
- #
252
- # datastore = Google::Cloud::Datastore.new
253
- #
254
- # task1 = datastore.entity "Task" do |t|
255
- # t["type"] = "Personal"
256
- # t["done"] = false
257
- # t["priority"] = 4
258
- # t["description"] = "Learn Cloud Datastore"
259
- # end
260
- #
261
- # task2 = datastore.entity "Task" do |t|
262
- # t["type"] = "Personal"
263
- # t["done"] = false
264
- # t["priority"] = 5
265
- # t["description"] = "Integrate Cloud Datastore"
266
- # end
267
- #
268
- # tasks = datastore.save(task1, task2)
269
- # task_key1 = tasks[0].key
270
- # task_key2 = tasks[1].key
271
- # ```
272
- #
273
- # Entities in Datastore form a hierarchically structured space similar to
274
- # the directory structure of a file system. When you create an entity, you
275
- # can optionally designate another entity as its parent; the new entity is a
276
- # child of the parent entity.
277
- #
278
- # ```ruby
279
- # require "google/cloud/datastore"
280
- #
281
- # datastore = Google::Cloud::Datastore.new
282
- #
283
- # task_key = datastore.key "Task", "sampleTask"
284
- # task_key.parent = datastore.key "TaskList", "default"
285
- #
286
- # task = datastore.entity task_key do |t|
287
- # t["type"] = "Personal"
288
- # t["done"] = false
289
- # t["priority"] = 5
290
- # t["description"] = "Integrate Cloud Datastore"
291
- # end
292
- # ```
293
- #
294
- # ## Setting properties
295
- #
296
- # Entities hold properties. A property has a name that is a string or
297
- # symbol, and a value that is an object. Most value objects are supported,
298
- # including `String`, `Integer`, `Date`, `Time`, and even other entity or
299
- # key objects. Changes to the entity's properties are persisted by calling
300
- # {Google::Cloud::Datastore::Dataset#save}.
301
- #
302
- # ```ruby
303
- # require "google/cloud/datastore"
304
- #
305
- # datastore = Google::Cloud::Datastore.new
306
- #
307
- # task = datastore.find "Task", "sampleTask"
308
- # # Read the priority property
309
- # task["priority"] #=> 4
310
- # # Write the priority property
311
- # task["priority"] = 5
312
- # # Persist the changes
313
- # datastore.save task
314
- # ```
315
- #
316
- # Array properties can be used to store more than one value.
317
- #
318
- # ```ruby
319
- # require "google/cloud/datastore"
320
- #
321
- # datastore = Google::Cloud::Datastore.new
322
- #
323
- # task = datastore.entity "Task", "sampleTask" do |t|
324
- # t["tags"] = ["fun", "programming"]
325
- # t["collaborators"] = ["alice", "bob"]
326
- # end
327
- # ```
328
- #
329
- # ## Deleting records
330
- #
331
- # Entities can be removed from Datastore by calling
332
- # {Google::Cloud::Datastore::Dataset#delete} and passing the entity object
333
- # or the entity's key object.
334
- #
335
- # ```ruby
336
- # require "google/cloud/datastore"
337
- #
338
- # datastore = Google::Cloud::Datastore.new
339
- #
340
- # task = datastore.find "Task", "sampleTask"
341
- # datastore.delete task
342
- # ```
343
- #
344
- # Multiple entities may be deleted in a batch.
345
- #
346
- # ```ruby
347
- # require "google/cloud/datastore"
348
- #
349
- # datastore = Google::Cloud::Datastore.new
350
- #
351
- # task_key1 = datastore.key "Task", "sampleTask1"
352
- # task_key2 = datastore.key "Task", "sampleTask2"
353
- # datastore.delete task_key1, task_key2
354
- # ```
355
- #
356
- # ## Transactions
357
- #
358
- # Complex logic can be wrapped in a transaction. All queries and updates
359
- # within the {Google::Cloud::Datastore::Dataset#transaction} block are run
360
- # within the transaction scope, and will be automatically committed when the
361
- # block completes.
362
- #
363
- # ```ruby
364
- # require "google/cloud/datastore"
365
- #
366
- # datastore = Google::Cloud::Datastore.new
367
- #
368
- # task_key = datastore.key "Task", "sampleTask"
369
- #
370
- # datastore.transaction do |tx|
371
- # if tx.find(task_key).nil?
372
- # task = datastore.entity task_key do |t|
373
- # t["type"] = "Personal"
374
- # t["done"] = false
375
- # t["priority"] = 4
376
- # t["description"] = "Learn Cloud Datastore"
377
- # end
378
- # tx.save task
379
- # end
380
- # end
381
- # ```
382
- #
383
- # Alternatively, if no block is given the transaction object is returned
384
- # allowing you to commit or rollback manually.
385
- #
386
- # ```ruby
387
- # require "google/cloud/datastore"
388
- #
389
- # datastore = Google::Cloud::Datastore.new
390
- #
391
- # task_key = datastore.key "Task", "sampleTask"
392
- #
393
- # tx = datastore.transaction
394
- # begin
395
- # if tx.find(task_key).nil?
396
- # task = datastore.entity task_key do |t|
397
- # t["type"] = "Personal"
398
- # t["done"] = false
399
- # t["priority"] = 4
400
- # t["description"] = "Learn Cloud Datastore"
401
- # end
402
- # tx.save task
403
- # end
404
- # tx.commit
405
- # rescue
406
- # tx.rollback
407
- # end
408
- # ```
409
- #
410
- # A read-only transaction cannot modify entities; in return they do not
411
- # contend with other read-write or read-only transactions. Using a read-only
412
- # transaction for transactions that only read data will potentially improve
413
- # throughput.
414
- #
415
- # ```ruby
416
- # require "google/cloud/datastore"
417
- #
418
- # datastore = Google::Cloud::Datastore.new
419
- #
420
- # task_list_key = datastore.key "TaskList", "default"
421
- # query = datastore.query("Task").
422
- # ancestor(task_list_key)
423
- #
424
- # tasks = nil
425
- #
426
- # datastore.transaction read_only: true do |tx|
427
- # task_list = tx.find task_list_key
428
- # if task_list
429
- # tasks = tx.run query
430
- # end
431
- # end
432
- # ```
433
- #
434
- # See {Google::Cloud::Datastore::Transaction} and
435
- # {Google::Cloud::Datastore::Dataset#transaction}
436
- #
437
- # ## Querying metadata
438
- #
439
- # Datastore provides programmatic access to some of its metadata to support
440
- # meta-programming, implementing backend administrative functions, simplify
441
- # consistent caching, and similar purposes. The metadata available includes
442
- # information about the entity groups, namespaces, entity kinds, and
443
- # properties your application uses, as well as the property representations
444
- # for each property.
445
- #
446
- # The special entity kind `__namespace__` can be used to find all the
447
- # namespaces used in your application entities.
448
- #
449
- # ```ruby
450
- # require "google/cloud/datastore"
451
- #
452
- # datastore = Google::Cloud::Datastore.new
453
- #
454
- # query = datastore.query("__namespace__").
455
- # select("__key__").
456
- # where("__key__", ">=", datastore.key("__namespace__", "g")).
457
- # where("__key__", "<", datastore.key("__namespace__", "h"))
458
- #
459
- # namespaces = datastore.run(query).map do |entity|
460
- # entity.key.name
461
- # end
462
- # ```
463
- #
464
- # The special entity kind `__kind__` can be used to return all the
465
- # kinds used in your application.
466
- #
467
- # ```ruby
468
- # require "google/cloud/datastore"
469
- #
470
- # datastore = Google::Cloud::Datastore.new
471
- #
472
- # query = datastore.query("__kind__").
473
- # select("__key__")
474
- #
475
- # kinds = datastore.run(query).map do |entity|
476
- # entity.key.name
477
- # end
478
- # ```
479
- #
480
- # Property queries return entities of kind `__property__` denoting the
481
- # indexed properties associated with an entity kind. (Unindexed properties
482
- # are not included.)
483
- #
484
- # ```ruby
485
- # require "google/cloud/datastore"
486
- #
487
- # datastore = Google::Cloud::Datastore.new
488
- #
489
- # query = datastore.query("__property__").
490
- # select("__key__")
491
- #
492
- # entities = datastore.run(query)
493
- # properties_by_kind = entities.each_with_object({}) do |entity, memo|
494
- # kind = entity.key.parent.name
495
- # prop = entity.key.name
496
- # memo[kind] ||= []
497
- # memo[kind] << prop
498
- # end
499
- # ```
500
- #
501
- # Property queries support ancestor filtering on a `__kind__` or
502
- # `__property__` key, to limit the query results to a single kind or
503
- # property. The `property_representation` property in the entity
504
- # representing property `p` of kind `k` is an array containing all
505
- # representations of `p`'s value in any entity of kind `k`.
506
- #
507
- # ```ruby
508
- # require "google/cloud/datastore"
509
- #
510
- # datastore = Google::Cloud::Datastore.new
511
- #
512
- # ancestor_key = datastore.key "__kind__", "Task"
513
- # query = datastore.query("__property__").
514
- # ancestor(ancestor_key)
515
- #
516
- # entities = datastore.run(query)
517
- # representations = entities.each_with_object({}) do |entity, memo|
518
- # property_name = entity.key.name
519
- # property_types = entity["property_representation"]
520
- # memo[property_name] = property_types
521
- # end
522
- # ```
523
- #
524
- # Property queries can also be filtered with a range over the
525
- # pseudo-property `__key__`, where the keys denote either `__kind__` or
526
- # `__property__` entities.
527
- #
528
- # ```ruby
529
- # require "google/cloud/datastore"
530
- #
531
- # datastore = Google::Cloud::Datastore.new
532
- #
533
- # start_key = datastore.key "__property__", "priority"
534
- # start_key.parent = datastore.key "__kind__", "Task"
535
- # query = datastore.query("__property__").
536
- # select("__key__").
537
- # where("__key__", ">=", start_key)
538
- #
539
- # entities = datastore.run(query)
540
- # properties_by_kind = entities.each_with_object({}) do |entity, memo|
541
- # kind = entity.key.parent.name
542
- # prop = entity.key.name
543
- # memo[kind] ||= []
544
- # memo[kind] << prop
545
- # end
546
- # ```
547
- #
548
- # ## Configuring timeout
549
- #
550
- # You can configure the request `timeout` value in seconds.
551
- #
552
- # ```ruby
553
- # require "google/cloud/datastore"
554
- #
555
- # datastore = Google::Cloud::Datastore.new timeout: 120
556
- # ```
557
- #
558
- # ## The Cloud Datastore Emulator
559
- #
560
- # As of this release, the Cloud Datastore emulator that is part of the
561
- # gcloud SDK is no longer compatible with google-cloud. This is because the
562
- # gcloud SDK's Cloud Datastore emulator does not yet support gRPC as a
563
- # transport layer.
564
- #
565
- # A gRPC-compatible emulator is available until the gcloud SDK Cloud
566
- # Datastore emulator supports gRPC. To use it you must [download the gRPC
567
- # emulator](https://storage.googleapis.com/gcd/tools/cloud-datastore-emulator-1.1.1.zip)
568
- # and use the `cloud_datastore_emulator` script.
569
- #
570
- # When you run the Cloud Datastore emulator you will see a message similar
571
- # to the following printed:
572
- #
573
- # ```
574
- # If you are using a library that supports the DATASTORE_EMULATOR_HOST
575
- # environment variable, run:
576
- #
577
- # export DATASTORE_EMULATOR_HOST=localhost:8978
578
- # ```
579
- #
580
- # Now you can connect to the emulator using the `DATASTORE_EMULATOR_HOST`
581
- # environment variable:
582
- #
583
- # ```ruby
584
- # require "google/cloud/datastore"
585
- #
586
- # # Make Datastore use the emulator
587
- # ENV["DATASTORE_EMULATOR_HOST"] = "localhost:8978"
588
- #
589
- # datastore = Google::Cloud::Datastore.new project: "emulator-project-id"
590
- #
591
- # task = datastore.entity "Task", "emulatorTask" do |t|
592
- # t["type"] = "Testing"
593
- # t["done"] = false
594
- # t["priority"] = 5
595
- # t["description"] = "Use Datastore Emulator"
596
- # end
597
- #
598
- # datastore.save task
599
- # ```
44
+ # task = datastore.find "Task", "sampleTask"
45
+ # task["priority"] = 5
46
+ # datastore.save task
600
47
  #
601
48
  module Datastore
49
+ # rubocop:disable Metrics/MethodLength
50
+
602
51
  ##
603
52
  # Creates a new object for connecting to the Datastore service.
604
53
  # Each call creates a new connection.
605
54
  #
606
55
  # For more information on connecting to Google Cloud see the
607
- # [Authentication
608
- # Guide](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/guides/authentication).
56
+ # {file:AUTHENTICATION.md Authentication Guide}.
609
57
  #
610
58
  # @param [String] project_id Identifier for a Datastore project. If not
611
59
  # present, the default project for the credentials is used.
@@ -663,7 +111,8 @@ module Google
663
111
  return Datastore::Dataset.new(
664
112
  Datastore::Service.new(
665
113
  project_id, :this_channel_is_insecure,
666
- host: emulator_host, client_config: client_config
114
+ host: emulator_host, timeout: timeout,
115
+ client_config: client_config
667
116
  )
668
117
  )
669
118
  end
@@ -681,6 +130,8 @@ module Google
681
130
  )
682
131
  end
683
132
 
133
+ # rubocop:enable Metrics/MethodLength
134
+
684
135
  ##
685
136
  # Configure the Google Cloud Datastore library.
686
137
  #
@@ -12,6 +12,7 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+
15
16
  require "googleauth"
16
17
 
17
18
  module Google
@@ -19,6 +19,7 @@
19
19
  # For the short term, the refresh process will only be runnable by Google
20
20
  # engineers.
21
21
 
22
+
22
23
  require "json"
23
24
  require "pathname"
24
25
 
@@ -41,6 +42,7 @@ module Google
41
42
  # @!attribute [r] datastore_stub
42
43
  # @return [Google::Datastore::V1::Datastore::Stub]
43
44
  class DatastoreClient
45
+ # @private
44
46
  attr_reader :datastore_stub
45
47
 
46
48
  # The default address of the service.
@@ -12,6 +12,7 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+
15
16
  module Google
16
17
  module Datastore
17
18
  module V1
@@ -12,6 +12,7 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+
15
16
  module Google
16
17
  module Datastore
17
18
  module V1
@@ -12,6 +12,7 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+
15
16
  module Google
16
17
  module Datastore
17
18
  module V1
@@ -12,6 +12,7 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+
15
16
  module Google
16
17
  module Protobuf
17
18
  # Wrapper message for +double+.
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Datastore
19
- VERSION = "1.4.1".freeze
19
+ VERSION = "1.4.2".freeze
20
20
  end
21
21
  end
22
22
  end
@@ -1,6 +1,7 @@
1
1
  # Generated by the protocol buffer compiler. DO NOT EDIT!
2
2
  # source: google/datastore/v1/datastore.proto
3
3
 
4
+
4
5
  require 'google/protobuf'
5
6
 
6
7
  require 'google/api/annotations_pb'
@@ -16,6 +16,7 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
+
19
20
  require 'grpc'
20
21
  require 'google/datastore/v1/datastore_pb'
21
22
 
@@ -1,6 +1,7 @@
1
1
  # Generated by the protocol buffer compiler. DO NOT EDIT!
2
2
  # source: google/datastore/v1/entity.proto
3
3
 
4
+
4
5
  require 'google/protobuf'
5
6
 
6
7
  require 'google/api/annotations_pb'
@@ -1,6 +1,7 @@
1
1
  # Generated by the protocol buffer compiler. DO NOT EDIT!
2
2
  # source: google/datastore/v1/query.proto
3
3
 
4
+
4
5
  require 'google/protobuf'
5
6
 
6
7
  require 'google/api/annotations_pb'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-cloud-datastore
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Moore
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-08-21 00:00:00.000000000 Z
12
+ date: 2018-09-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: google-cloud-core
@@ -183,16 +183,16 @@ dependencies:
183
183
  name: yard-doctest
184
184
  requirement: !ruby/object:Gem::Requirement
185
185
  requirements:
186
- - - "<="
186
+ - - "~>"
187
187
  - !ruby/object:Gem::Version
188
- version: 0.1.8
188
+ version: 0.1.13
189
189
  type: :development
190
190
  prerelease: false
191
191
  version_requirements: !ruby/object:Gem::Requirement
192
192
  requirements:
193
- - - "<="
193
+ - - "~>"
194
194
  - !ruby/object:Gem::Version
195
- version: 0.1.8
195
+ version: 0.1.13
196
196
  description: google-cloud-datastore is the official library for Google Cloud Datastore.
197
197
  email:
198
198
  - mike@blowmage.com