google-cloud-datastore 0.24.2 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0d7ce2752911ea72c137a1552380d6b632a12b3b
4
- data.tar.gz: bdedcee6506cc84157a121a1c5ac6a6f3e030a10
3
+ metadata.gz: 559613c74ca35117a66212cce1a9ad90a1e5ccc2
4
+ data.tar.gz: 0c4f32aeeb33dfe3d9f3f180e259fb84b3064798
5
5
  SHA512:
6
- metadata.gz: e8c1641e321e73292306a5c697152cb2db76f81c09aefa47aece7935e7148ebcdf9366da58fab1706624b052add2ccdac859de50c475558013dbcd5233126e31
7
- data.tar.gz: 31699feb662ad45832583c3e443cd11650856cd86f5e4fbda97970dccbd7ec84dc3cdfedee827ad5cb73f3b2828becf3cbe0d8526bc40065a4170d9a3f2e0ee3
6
+ metadata.gz: eb046b91614d0fc04a8709684f1df2de02f573f6b5ddb9e275b2d9b705666c8ae55269d276dd3b650495315b57c6d1150ad46d9fbfd09ec3f641d9cbe5b110ba
7
+ data.tar.gz: 26a675b75579cf7edc42f0c4178fc821c865e567da3c279dbc95a0c42dc89c8f2885e7d28443f307150008b5f91b7a531d5ceed57508f94c0702c4df18891080
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/master/google/cloud/datastore)
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
 
@@ -61,7 +61,7 @@ module Google
61
61
  # Records, called "entities" in Datastore, are retrieved by using a key.
62
62
  # The key is more than a numeric identifier, it is a complex data structure
63
63
  # that can be used to model relationships. The simplest key has a string
64
- # <tt>kind</tt> value, and either a numeric <tt>id</tt> value, or a string
64
+ # <tt>kind</tt> value and either a numeric <tt>id</tt> value or a string
65
65
  # <tt>name</tt> value. A single record can be retrieved by calling
66
66
  # {Google::Cloud::Datastore::Dataset#find} and passing the parts of the key:
67
67
  #
@@ -130,6 +130,21 @@ module Google
130
130
  # tasks = datastore.run query
131
131
  # ```
132
132
  #
133
+ # When using Datastore in a multitenant application, a query may be run
134
+ # within a namespace using the `namespace` option. (See
135
+ # [Multitenancy](https://cloud.google.com/datastore/docs/concepts/multitenancy))
136
+ #
137
+ # ```ruby
138
+ # require "google/cloud/datastore"
139
+ #
140
+ # datastore = Google::Cloud::Datastore.new
141
+ #
142
+ # query = datastore.query("Task").
143
+ # where("done", "=", false)
144
+ #
145
+ # tasks = datastore.run query, namespace: "example-ns"
146
+ # ```
147
+ #
133
148
  # Records' key structures can also be queried.
134
149
  # (See {Google::Cloud::Datastore::Query#ancestor})
135
150
  #
@@ -161,7 +176,7 @@ module Google
161
176
  #
162
177
  # query = datastore.query("Task")
163
178
  # tasks = datastore.run query
164
- # tasks.all do |task|
179
+ # tasks.all do |t|
165
180
  # puts t["description"]
166
181
  # end
167
182
  # ```
@@ -242,8 +257,8 @@ module Google
242
257
  #
243
258
  # Entities hold properties. A property has a name that is a string or
244
259
  # symbol, and a value that is an object. Most value objects are supported,
245
- # including String, Integer, Date, Time, and even other entity or key
246
- # objects. Changes to the entity's properties are persisted by calling
260
+ # including `String`, `Integer`, `Date`, `Time`, and even other entity or
261
+ # key objects. Changes to the entity's properties are persisted by calling
247
262
  # {Google::Cloud::Datastore::Dataset#save}.
248
263
  #
249
264
  # ```ruby
@@ -302,7 +317,7 @@ module Google
302
317
  #
303
318
  # ## Transactions
304
319
  #
305
- # Complex logic can be wrapped in a Transaction. All queries and updates
320
+ # Complex logic can be wrapped in a transaction. All queries and updates
306
321
  # within the {Google::Cloud::Datastore::Dataset#transaction} block are run
307
322
  # within the transaction scope, and will be automatically committed when the
308
323
  # block completes.
@@ -13,7 +13,7 @@
13
13
  # limitations under the License.
14
14
 
15
15
 
16
- require "google/cloud/core/environment"
16
+ require "google/cloud/env"
17
17
  require "google/cloud/datastore/convert"
18
18
  require "google/cloud/datastore/credentials"
19
19
  require "google/cloud/datastore/service"
@@ -35,10 +35,9 @@ module Google
35
35
  # Dataset is the data saved in a project's Datastore.
36
36
  # Dataset is analogous to a database in relational database world.
37
37
  #
38
- # Google::Cloud::Datastore::Dataset is the main object for interacting
39
- # with Google Datastore. {Google::Cloud::Datastore::Entity} objects are
40
- # created, read, updated, and deleted by
41
- # Google::Cloud::Datastore::Dataset.
38
+ # Dataset is the main object for interacting with Google Datastore.
39
+ # {Google::Cloud::Datastore::Entity} objects are created, read, updated,
40
+ # and deleted by Dataset.
42
41
  #
43
42
  # See {Google::Cloud#datastore}
44
43
  #
@@ -89,7 +88,7 @@ module Google
89
88
  ENV["DATASTORE_PROJECT"] ||
90
89
  ENV["GOOGLE_CLOUD_PROJECT"] ||
91
90
  ENV["GCLOUD_PROJECT"] ||
92
- Google::Cloud::Core::Environment.project_id
91
+ Google::Cloud.env.project_id
93
92
  end
94
93
 
95
94
  ##
@@ -430,7 +429,7 @@ module Google
430
429
  #
431
430
  # query = datastore.query("Task").
432
431
  # where("done", "=", false)
433
- # tasks = datastore.run query, namespace: "ns~todo-project"
432
+ # tasks = datastore.run query, namespace: "example-ns"
434
433
  #
435
434
  # @example Run the query with a GQL string.
436
435
  # require "google/cloud/datastore"
@@ -448,7 +447,7 @@ module Google
448
447
  #
449
448
  # gql_query = datastore.gql "SELECT * FROM Task WHERE done = @done",
450
449
  # done: false
451
- # tasks = datastore.run gql_query, namespace: "ns~todo-project"
450
+ # tasks = datastore.run gql_query, namespace: "example-ns"
452
451
  #
453
452
  def run query, namespace: nil, consistency: nil
454
453
  ensure_service!
@@ -676,10 +675,10 @@ module Google
676
675
  #
677
676
  # key = datastore.key ["TaskList", "default"], ["Task", "sampleTask"],
678
677
  # project: "my-todo-project",
679
- # namespace: "ns~todo-project"
678
+ # namespace: "example-ns"
680
679
  # key.path #=> [["TaskList", "default"], ["Task", "sampleTask"]]
681
680
  # key.project #=> "my-todo-project"
682
- # key.namespace #=> "ns~todo-project"
681
+ # key.namespace #=> "example-ns"
683
682
  #
684
683
  def key *path, project: nil, namespace: nil
685
684
  path = path.flatten.each_slice(2).to_a # group in pairs
@@ -47,7 +47,7 @@ module Google
47
47
  # tasks.size #=> 3
48
48
  # tasks.deferred #=> []
49
49
  # tasks.missing #=> []
50
- # descriptions = tasks.map { |task| task["description"] }
50
+ # descriptions = tasks.map { |t| t["description"] }
51
51
  # descriptions.size #=> 3
52
52
  # descriptions.deferred #=> raise NoMethodError
53
53
  # descriptions.missing #=> raise NoMethodError
@@ -140,8 +140,8 @@ module Google
140
140
  # task_key1 = datastore.key "Task", "sampleTask1"
141
141
  # task_key2 = datastore.key "Task", "sampleTask2"
142
142
  # tasks = datastore.find_all task_key1, task_key2
143
- # tasks.all do |task|
144
- # puts "Task #{task.key.id} (#cursor)"
143
+ # tasks.all do |t|
144
+ # puts "Task #{t.key.id} (#cursor)"
145
145
  # end
146
146
  #
147
147
  # @example Using the enumerator by not passing a block:
@@ -162,8 +162,8 @@ module Google
162
162
  # task_key1 = datastore.key "Task", "sampleTask1"
163
163
  # task_key2 = datastore.key "Task", "sampleTask2"
164
164
  # tasks = datastore.find_all task_key1, task_key2
165
- # tasks.all(request_limit: 10) do |task|
166
- # puts "Task #{task.key.id} (#cursor)"
165
+ # tasks.all(request_limit: 10) do |t|
166
+ # puts "Task #{t.key.id} (#cursor)"
167
167
  # end
168
168
  #
169
169
  def all request_limit: nil
@@ -49,7 +49,7 @@ module Google
49
49
  #
50
50
  # tasks.size #=> 3
51
51
  # tasks.cursor.to_s #=> "c2Vjb25kLXBhZ2UtY3Vyc29y"
52
- # descriptions = tasks.map { |task| task["description"] }
52
+ # descriptions = tasks.map { |t| t["description"] }
53
53
  # descriptions.size #=> 3
54
54
  # descriptions.cursor #=> raise NoMethodError
55
55
  #
@@ -239,8 +239,8 @@ module Google
239
239
  #
240
240
  # query = datastore.query "Task"
241
241
  # tasks = datastore.run query
242
- # tasks.all do |task|
243
- # puts "Task #{task.key.id} (#cursor)"
242
+ # tasks.all do |t|
243
+ # puts "Task #{t.key.id} (#cursor)"
244
244
  # end
245
245
  #
246
246
  # @example Using the enumerator by not passing a block:
@@ -261,8 +261,8 @@ module Google
261
261
  #
262
262
  # query = datastore.query "Task"
263
263
  # tasks = datastore.run query
264
- # tasks.all(request_limit: 10) do |task|
265
- # puts "Task #{task.key.id} (#cursor)"
264
+ # tasks.all(request_limit: 10) do |t|
265
+ # puts "Task #{t.key.id} (#cursor)"
266
266
  # end
267
267
  #
268
268
  def all request_limit: nil
@@ -24,6 +24,9 @@ module Google
24
24
  # either a key name string, assigned explicitly by the application, or an
25
25
  # integer numeric ID, assigned automatically by Datastore.
26
26
  #
27
+ # @see https://cloud.google.com/datastore/docs/concepts/entities Entities,
28
+ # Properties, and Keys
29
+ #
27
30
  # @example
28
31
  # require "google/cloud/datastore"
29
32
  #
@@ -78,7 +81,7 @@ module Google
78
81
  # )
79
82
  #
80
83
  # task = datastore.find "Task", "sampleTask"
81
- # task.key.namespace #=> "ns~todo-project"
84
+ # task.key.namespace #=> "example-ns"
82
85
  #
83
86
  attr_accessor :namespace
84
87
 
@@ -42,6 +42,15 @@ module Google
42
42
  #
43
43
  # tasks = datastore.run query
44
44
  #
45
+ # @example Run the query within a namespace with the `namespace` option:
46
+ # require "google/cloud/datastore"
47
+ #
48
+ # datastore = Google::Cloud::Datastore.new
49
+ #
50
+ # query = datastore.query("Task").
51
+ # where("done", "=", false)
52
+ # tasks = datastore.run query, namespace: "example-ns"
53
+ #
45
54
  class Query
46
55
  ##
47
56
  # Returns a new query object.
@@ -354,9 +363,9 @@ module Google
354
363
  #
355
364
  # priorities = []
356
365
  # percent_completes = []
357
- # datastore.run(query).each do |task|
358
- # priorities << task["priority"]
359
- # percent_completes << task["percent_complete"]
366
+ # datastore.run(query).each do |t|
367
+ # priorities << t["priority"]
368
+ # percent_completes << t["percent_complete"]
360
369
  # end
361
370
  #
362
371
  # @example A keys-only query using the special property `__key__`:
@@ -258,7 +258,7 @@ module Google
258
258
  # query = Google::Cloud::Datastore::Query.new.kind("Task").
259
259
  # where("done", "=", false)
260
260
  # datastore.transaction do |tx|
261
- # tasks = tx.run query, namespace: "ns~todo-project"
261
+ # tasks = tx.run query, namespace: "example-ns"
262
262
  # end
263
263
  #
264
264
  def run query, namespace: nil
@@ -1,10 +1,10 @@
1
- # Copyright 2016 Google Inc. All rights reserved.
1
+ # Copyright 2017, Google Inc. All rights reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
5
5
  # You may obtain a copy of the License at
6
6
  #
7
- # http://www.apache.org/licenses/LICENSE-2.0
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
8
  #
9
9
  # Unless required by applicable law or agreed to in writing, software
10
10
  # distributed under the License is distributed on an "AS IS" BASIS,
@@ -26,6 +26,7 @@ require "json"
26
26
  require "pathname"
27
27
 
28
28
  require "google/gax"
29
+
29
30
  require "google/datastore/v1/datastore_pb"
30
31
 
31
32
  module Google
@@ -277,10 +278,6 @@ module Google
277
278
  # The ID of the project against which to make the request.
278
279
  # @param mode [Google::Datastore::V1::CommitRequest::Mode]
279
280
  # The type of commit to perform. Defaults to +TRANSACTIONAL+.
280
- # @param transaction [String]
281
- # The identifier of the transaction associated with the commit. A
282
- # transaction identifier is returned by a call to
283
- # Datastore::BeginTransaction.
284
281
  # @param mutations [Array<Google::Datastore::V1::Mutation>]
285
282
  # The mutations to perform.
286
283
  #
@@ -295,6 +292,10 @@ module Google
295
292
  #
296
293
  # When mode is +NON_TRANSACTIONAL+, no two mutations may affect a single
297
294
  # entity.
295
+ # @param transaction [String]
296
+ # The identifier of the transaction associated with the commit. A
297
+ # transaction identifier is returned by a call to
298
+ # Datastore::BeginTransaction.
298
299
  # @param options [Google::Gax::CallOptions]
299
300
  # Overrides the default settings for this call, e.g, timeout,
300
301
  # retries, etc.
@@ -6,7 +6,9 @@
6
6
  "DEADLINE_EXCEEDED",
7
7
  "UNAVAILABLE"
8
8
  ],
9
- "non_idempotent": []
9
+ "non_idempotent": [
10
+ "UNAVAILABLE"
11
+ ]
10
12
  },
11
13
  "retry_params": {
12
14
  "default": {
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Datastore
19
- VERSION = "0.24.2"
19
+ VERSION = "1.0.0"
20
20
  end
21
21
  end
22
22
  end
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: 0.24.2
4
+ version: 1.0.0
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: 2017-03-04 00:00:00.000000000 Z
12
+ date: 2017-04-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: google-cloud-core
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: 0.21.0
20
+ version: '1.0'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: 0.21.0
27
+ version: '1.0'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: google-gax
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -225,7 +225,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
225
225
  version: '0'
226
226
  requirements: []
227
227
  rubyforge_project:
228
- rubygems_version: 2.6.10
228
+ rubygems_version: 2.6.11
229
229
  signing_key:
230
230
  specification_version: 4
231
231
  summary: API Client library for Google Cloud Datastore