google-cloud-datastore 1.8.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/AUTHENTICATION.md +2 -1
  3. data/CHANGELOG.md +47 -0
  4. data/CONTRIBUTING.md +2 -2
  5. data/LOGGING.md +1 -1
  6. data/TROUBLESHOOTING.md +2 -8
  7. data/lib/google-cloud-datastore.rb +13 -18
  8. data/lib/google/cloud/datastore.rb +12 -11
  9. data/lib/google/cloud/datastore/commit.rb +4 -4
  10. data/lib/google/cloud/datastore/convert.rb +4 -4
  11. data/lib/google/cloud/datastore/credentials.rb +2 -2
  12. data/lib/google/cloud/datastore/dataset.rb +3 -3
  13. data/lib/google/cloud/datastore/dataset/lookup_results.rb +5 -5
  14. data/lib/google/cloud/datastore/dataset/query_results.rb +6 -6
  15. data/lib/google/cloud/datastore/entity.rb +4 -4
  16. data/lib/google/cloud/datastore/gql_query.rb +19 -23
  17. data/lib/google/cloud/datastore/key.rb +9 -8
  18. data/lib/google/cloud/datastore/properties.rb +1 -1
  19. data/lib/google/cloud/datastore/query.rb +15 -14
  20. data/lib/google/cloud/datastore/service.rb +34 -86
  21. data/lib/google/cloud/datastore/transaction.rb +1 -1
  22. data/lib/google/cloud/datastore/version.rb +1 -1
  23. metadata +13 -68
  24. data/lib/google/cloud/datastore/v1.rb +0 -16
  25. data/lib/google/cloud/datastore/v1/credentials.rb +0 -39
  26. data/lib/google/cloud/datastore/v1/datastore_client.rb +0 -577
  27. data/lib/google/cloud/datastore/v1/datastore_client_config.json +0 -61
  28. data/lib/google/cloud/datastore/v1/doc/google/datastore/v1/datastore.rb +0 -283
  29. data/lib/google/cloud/datastore/v1/doc/google/datastore/v1/entity.rb +0 -189
  30. data/lib/google/cloud/datastore/v1/doc/google/datastore/v1/query.rb +0 -297
  31. data/lib/google/cloud/datastore/v1/doc/google/protobuf/struct.rb +0 -74
  32. data/lib/google/cloud/datastore/v1/doc/google/protobuf/timestamp.rb +0 -109
  33. data/lib/google/cloud/datastore/v1/doc/google/protobuf/wrappers.rb +0 -26
  34. data/lib/google/cloud/datastore/v1/doc/google/type/latlng.rb +0 -65
  35. data/lib/google/datastore/v1/datastore_pb.rb +0 -147
  36. data/lib/google/datastore/v1/datastore_services_pb.rb +0 -65
  37. data/lib/google/datastore/v1/entity_pb.rb +0 -64
  38. data/lib/google/datastore/v1/query_pb.rb +0 -132
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 24443175e79fea809e939ff9a0270b29267fc9adaffb9ed0aae19728fd296904
4
- data.tar.gz: 04cad098d4bc8d86d4d95ca8aeef0eab46f57491fc4c0b5dd32640587d383604
3
+ metadata.gz: 5cc84b3b7cf1ffd53fb9014894883cf4a6245a105365c97c5a4665abd2241ff0
4
+ data.tar.gz: 9b7acbddf571fd3b5c02b926fc676cfa0ed20bcda6eebaf02b7162c819585ae4
5
5
  SHA512:
6
- metadata.gz: 0423c4729d6962cf87e42641a838554521e22f4390146480d3e296c3e3f2d9a385958113c223b3d080bc4ef5311359c56ce6967011deaf8672d4521261aee24d
7
- data.tar.gz: 3fbfeb296dcfd2d59779e2c971bae80e149804242a9962cc877bef8c79580700846f07f21cec5fefd96a6fd722c040632acdbf89d3a2fc629bbf476188d8fadd
6
+ metadata.gz: cd15c934e7ca1296df239924f55a02b2c105756cdbd60ffb538371bef4ff94176a04969678ed51e9337ad4b94d6d7faeb3e2366ac5c968225b7ddc9d4da1d86b
7
+ data.tar.gz: 31e397c409100133092611020ca472c671e8be85d1932be97cb3399c4ee576654f8a4018f98c9f6119be3881893d614b622a2243d13298b856ea359a83a58351
data/AUTHENTICATION.md CHANGED
@@ -76,7 +76,8 @@ The environment variables that google-cloud-datastore checks for project ID are:
76
76
  1. `DATASTORE_PROJECT`
77
77
  2. `GOOGLE_CLOUD_PROJECT`
78
78
 
79
- The environment variables that google-cloud-datastore checks for credentials are configured on {Google::Cloud::Datastore::V1::Credentials}:
79
+ The environment variables that google-cloud-datastore checks for credentials are configured on
80
+ {Google::Cloud::Datastore::Credentials}:
80
81
 
81
82
  1. `DATASTORE_CREDENTIALS` - Path to JSON file, or JSON contents
82
83
  2. `DATASTORE_KEYFILE` - Path to JSON file, or JSON contents
data/CHANGELOG.md CHANGED
@@ -1,5 +1,52 @@
1
1
  # Release History
2
2
 
3
+ ### 2.2.0 / 2021-03-10
4
+
5
+ #### Features
6
+
7
+ * Drop support for Ruby 2.4 and add support for Ruby 3.0
8
+
9
+ ### 2.1.0 / 2020-09-17
10
+
11
+ #### Features
12
+
13
+ * quota_project can be set via library configuration ([#7630](https://www.github.com/googleapis/google-cloud-ruby/issues/7630))
14
+
15
+ ### 2.0.0 / 2020-08-06
16
+
17
+ This is a major update that removes the "low-level" client interface code, and
18
+ instead adds the new `google-cloud-datastore-v1` gem as a dependency.
19
+ The new dependency is a rewritten low-level client, produced by a next-
20
+ generation client code generator, with improved performance and stability.
21
+
22
+ This change should have no effect on the high-level interface that most users
23
+ will use. The one exception is that the (mostly undocumented) `client_config`
24
+ argument, for adjusting low-level parameters such as RPC retry settings on
25
+ client objects, has been removed. If you need to adjust these parameters, use
26
+ the configuration interface in `google-cloud-datastore-v1`.
27
+
28
+ Substantial changes have been made in the low-level interfaces, however. If you
29
+ are using the low-level classes under the `Google::Cloud::Datastore::V1` module,
30
+ please review the docs for the new `google-cloud-datastore-v1` gem. In
31
+ particular:
32
+
33
+ * Some classes have been renamed, notably the client class itself.
34
+ * The client constructor takes a configuration block instead of configuration
35
+ keyword arguments.
36
+ * All RPC method arguments are now keyword arguments.
37
+
38
+ ### 1.8.2 / 2020-05-28
39
+
40
+ #### Documentation
41
+
42
+ * Fix a few broken links
43
+
44
+ ### 1.8.1 / 2020-05-19
45
+
46
+ #### Bug Fixes
47
+
48
+ * Adjusted some default timeout and retry settings
49
+
3
50
  ### 1.8.0 / 2020-03-11
4
51
 
5
52
  #### Features
data/CONTRIBUTING.md CHANGED
@@ -24,7 +24,7 @@ be able to accept your pull requests.
24
24
  In order to use the google-cloud-datastore console and run the project's tests,
25
25
  there is a small amount of setup:
26
26
 
27
- 1. Install Ruby. google-cloud-datastore requires Ruby 2.4+. You may choose to
27
+ 1. Install Ruby. google-cloud-datastore requires Ruby 2.5+. You may choose to
28
28
  manage your Ruby and gem installations with [RVM](https://rvm.io/),
29
29
  [rbenv](https://github.com/rbenv/rbenv), or
30
30
  [chruby](https://github.com/postmodern/chruby).
@@ -45,7 +45,7 @@ there is a small amount of setup:
45
45
 
46
46
  ```sh
47
47
  $ cd google-cloud-datastore/
48
- $ bundle exec rake bundleupdate
48
+ $ bundle install
49
49
  ```
50
50
 
51
51
  ## Console
data/LOGGING.md CHANGED
@@ -3,7 +3,7 @@
3
3
  To enable logging for this library, set the logger for the underlying
4
4
  [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library. The logger
5
5
  that you set may be a Ruby stdlib
6
- [`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html) as
6
+ [`Logger`](https://ruby-doc.org/stdlib/libdoc/logger/rdoc/Logger.html) as
7
7
  shown below, or a
8
8
  [`Google::Cloud::Logging::Logger`](https://googleapis.dev/ruby/google-cloud-logging/latest)
9
9
  that will write logs to [Stackdriver
data/TROUBLESHOOTING.md CHANGED
@@ -24,14 +24,8 @@ improved, *please* create a new issue on GitHub so we can talk about it.
24
24
 
25
25
  - [New issue][gh-ruby]
26
26
 
27
- Or, you can ask questions on the [Google Cloud Platform Slack][slack-ruby]. You
28
- can use the "ruby" channel for general Ruby questions, or use the
29
- "google-cloud-ruby" channel if you have questions about this gem in particular.
30
-
31
27
  [so-ruby]: http://stackoverflow.com/questions/tagged/google-cloud-platform+ruby+datastore
32
28
 
33
- [gh-search-ruby]: https://github.com/googlecloudplatform/google-cloud-ruby/issues?q=label%3A%22api%3A+datastore%22
34
-
35
- [gh-ruby]: https://github.com/googlecloudplatform/google-cloud-ruby/issues/new
29
+ [gh-search-ruby]: https://github.com/googleapis/google-cloud-ruby/issues?q=label%3A%22api%3A+datastore%22
36
30
 
37
- [slack-ruby]: https://gcp-slack.appspot.com/
31
+ [gh-ruby]: https://github.com/googleapis/google-cloud-ruby/issues/new
@@ -42,8 +42,6 @@ module Google
42
42
  #
43
43
  # * `https://www.googleapis.com/auth/datastore`
44
44
  # @param [Integer] timeout Default timeout to use in requests. Optional.
45
- # @param [Hash] client_config A hash of values to override the default
46
- # behavior of the API client. See Google::Gax::CallSettings. Optional.
47
45
  #
48
46
  # @return [Google::Cloud::Datastore::Dataset]
49
47
  #
@@ -69,10 +67,9 @@ module Google
69
67
  # platform_scope = "https://www.googleapis.com/auth/cloud-platform"
70
68
  # datastore = gcloud.datastore scope: platform_scope
71
69
  #
72
- def datastore scope: nil, timeout: nil, client_config: nil
70
+ def datastore scope: nil, timeout: nil
73
71
  Google::Cloud.datastore @project, @keyfile,
74
- scope: scope, timeout: (timeout || @timeout),
75
- client_config: client_config
72
+ scope: scope, timeout: (timeout || @timeout)
76
73
  end
77
74
 
78
75
  ##
@@ -96,8 +93,6 @@ module Google
96
93
  #
97
94
  # * `https://www.googleapis.com/auth/datastore`
98
95
  # @param [Integer] timeout Default timeout to use in requests. Optional.
99
- # @param [Hash] client_config A hash of values to override the default
100
- # behavior of the API client. See Google::Gax::CallSettings. Optional.
101
96
  #
102
97
  # @return [Google::Cloud::Datastore::Dataset]
103
98
  #
@@ -117,12 +112,11 @@ module Google
117
112
  # datastore.save task
118
113
  #
119
114
  def self.datastore project_id = nil, credentials = nil, scope: nil,
120
- timeout: nil, client_config: nil
115
+ timeout: nil
121
116
  require "google/cloud/datastore"
122
117
  Google::Cloud::Datastore.new project_id: project_id,
123
118
  credentials: credentials,
124
- scope: scope, timeout: timeout,
125
- client_config: client_config
119
+ scope: scope, timeout: timeout
126
120
  end
127
121
  end
128
122
  end
@@ -141,17 +135,18 @@ Google::Cloud.configure.add_config! :datastore do |config|
141
135
  default_emulator = Google::Cloud::Config.deferred do
142
136
  ENV["DATASTORE_EMULATOR_HOST"]
143
137
  end
138
+ default_scopes = [
139
+ "https://www.googleapis.com/auth/cloud-platform",
140
+ "https://www.googleapis.com/auth/datastore"
141
+ ]
144
142
 
145
143
  config.add_field! :project_id, default_project, match: String, allow_nil: true
146
144
  config.add_alias! :project, :project_id
147
- config.add_field! :credentials, default_creds,
148
- match: [String, Hash, Google::Auth::Credentials],
149
- allow_nil: true
145
+ config.add_field! :credentials, default_creds, match: [String, Hash, Google::Auth::Credentials], allow_nil: true
150
146
  config.add_alias! :keyfile, :credentials
151
- config.add_field! :scope, nil, match: [String, Array]
147
+ config.add_field! :scope, default_scopes, match: [String, Array]
148
+ config.add_field! :quota_project, nil, match: String
152
149
  config.add_field! :timeout, nil, match: Integer
153
- config.add_field! :client_config, nil, match: Hash
154
- config.add_field! :emulator_host, default_emulator,
155
- match: String, allow_nil: true
156
- config.add_field! :endpoint, nil, match: String
150
+ config.add_field! :emulator_host, default_emulator, match: String, allow_nil: true
151
+ config.add_field! :endpoint, "datastore.googleapis.com", match: String
157
152
  end
@@ -70,8 +70,6 @@ module Google
70
70
  #
71
71
  # * `https://www.googleapis.com/auth/datastore`
72
72
  # @param [Integer] timeout Default timeout to use in requests. Optional.
73
- # @param [Hash] client_config A hash of values to override the default
74
- # behavior of the API client. See Google::Gax::CallSettings. Optional.
75
73
  # @param [String] endpoint Override of the endpoint host name. Optional.
76
74
  # If the param is nil, uses the default endpoint.
77
75
  # @param [String] emulator_host Datastore emulator host. Optional.
@@ -99,13 +97,17 @@ module Google
99
97
  #
100
98
  # datastore.save task
101
99
  #
102
- def self.new project_id: nil, credentials: nil, scope: nil, timeout: nil,
103
- client_config: nil, endpoint: nil, emulator_host: nil,
104
- project: nil, keyfile: nil
100
+ def self.new project_id: nil,
101
+ credentials: nil,
102
+ scope: nil,
103
+ timeout: nil,
104
+ endpoint: nil,
105
+ emulator_host: nil,
106
+ project: nil,
107
+ keyfile: nil
105
108
  project_id ||= (project || default_project_id)
106
109
  scope ||= configure.scope
107
110
  timeout ||= configure.timeout
108
- client_config ||= configure.client_config
109
111
  endpoint ||= configure.endpoint
110
112
  emulator_host ||= configure.emulator_host
111
113
 
@@ -116,8 +118,7 @@ module Google
116
118
  return Datastore::Dataset.new(
117
119
  Datastore::Service.new(
118
120
  project_id, :this_channel_is_insecure,
119
- host: emulator_host, timeout: timeout,
120
- client_config: client_config
121
+ host: emulator_host, timeout: timeout
121
122
  )
122
123
  )
123
124
  end
@@ -136,7 +137,7 @@ module Google
136
137
  Datastore::Dataset.new(
137
138
  Datastore::Service.new(
138
139
  project_id, credentials,
139
- host: endpoint, timeout: timeout, client_config: client_config
140
+ host: endpoint, timeout: timeout
140
141
  )
141
142
  )
142
143
  end
@@ -158,8 +159,6 @@ module Google
158
159
  # * `scope` - (String, Array<String>) The OAuth 2.0 scopes controlling
159
160
  # the set of resources and operations that the connection can access.
160
161
  # * `timeout` - (Integer) Default timeout to use in requests.
161
- # * `client_config` - (Hash) A hash of values to override the default
162
- # behavior of the API client.
163
162
  # * `endpoint` - (String) Override of the endpoint host name, or `nil`
164
163
  # to use the default endpoint.
165
164
  # * `emulator_host` - (String) Host name of the emulator. Defaults to
@@ -191,4 +190,6 @@ module Google
191
190
  end
192
191
  end
193
192
  end
193
+ ## Legacy generated client namespace
194
+ Datastore = Cloud::Datastore unless const_defined? :Datastore
194
195
  end
@@ -136,16 +136,16 @@ module Google
136
136
  def mutations
137
137
  mutations = []
138
138
  mutations += @shared_upserts.map do |entity|
139
- Google::Datastore::V1::Mutation.new upsert: entity.to_grpc
139
+ Google::Cloud::Datastore::V1::Mutation.new upsert: entity.to_grpc
140
140
  end
141
141
  mutations += @shared_inserts.map do |entity|
142
- Google::Datastore::V1::Mutation.new insert: entity.to_grpc
142
+ Google::Cloud::Datastore::V1::Mutation.new insert: entity.to_grpc
143
143
  end
144
144
  mutations += @shared_updates.map do |entity|
145
- Google::Datastore::V1::Mutation.new update: entity.to_grpc
145
+ Google::Cloud::Datastore::V1::Mutation.new update: entity.to_grpc
146
146
  end
147
147
  mutations += @shared_deletes.map do |key|
148
- Google::Datastore::V1::Mutation.new delete: key.to_grpc
148
+ Google::Cloud::Datastore::V1::Mutation.new delete: key.to_grpc
149
149
  end
150
150
  mutations
151
151
  end
@@ -77,7 +77,7 @@ module Google
77
77
  end
78
78
 
79
79
  ##
80
- # Gets an object from a Google::Datastore::V1::Value.
80
+ # Gets an object from a Google::Cloud::Datastore::V1::Value.
81
81
  def self.from_value grpc_value
82
82
  if grpc_value.value_type == :null_value
83
83
  return nil
@@ -110,9 +110,9 @@ module Google
110
110
  end
111
111
 
112
112
  ##
113
- # Stores an object into a Google::Datastore::V1::Value.
113
+ # Stores an object into a Google::Cloud::Datastore::V1::Value.
114
114
  def self.to_value value
115
- v = Google::Datastore::V1::Value.new
115
+ v = Google::Cloud::Datastore::V1::Value.new
116
116
  if NilClass === value
117
117
  v.null_value = :NULL_VALUE
118
118
  elsif TrueClass === value
@@ -133,7 +133,7 @@ module Google
133
133
  elsif String === value
134
134
  v.string_value = value
135
135
  elsif Array === value
136
- v.array_value = Google::Datastore::V1::ArrayValue.new(
136
+ v.array_value = Google::Cloud::Datastore::V1::ArrayValue.new(
137
137
  values: value.map { |val| to_value val }
138
138
  )
139
139
  elsif value.respond_to? :to_time
@@ -14,7 +14,7 @@
14
14
 
15
15
 
16
16
  require "googleauth"
17
- require "google/cloud/datastore/v1/credentials"
17
+ require "google/cloud/datastore/v1/datastore/credentials"
18
18
 
19
19
  module Google
20
20
  module Cloud
@@ -38,7 +38,7 @@ module Google
38
38
  #
39
39
  # datastore.project_id #=> "my-todo-project"
40
40
  #
41
- class Credentials < Google::Cloud::Datastore::V1::Credentials
41
+ class Credentials < Google::Cloud::Datastore::V1::Datastore::Credentials
42
42
  end
43
43
  end
44
44
  end
@@ -535,9 +535,9 @@ module Google
535
535
  begin
536
536
  yield tx
537
537
  tx.commit
538
- rescue Google::Cloud::UnavailableError => err
538
+ rescue Google::Cloud::UnavailableError => e
539
539
  # Re-raise if deadline has passed
540
- raise err if Time.now - start_time > deadline
540
+ raise e if Time.now - start_time > deadline
541
541
 
542
542
  # Sleep with incremental backoff
543
543
  sleep backoff *= 1.3
@@ -878,7 +878,7 @@ module Google
878
878
 
879
879
  def validate_deadline deadline
880
880
  return 60 unless deadline.is_a? Numeric
881
- return 60 if deadline < 0
881
+ return 60 if deadline.negative?
882
882
  deadline
883
883
  end
884
884
 
@@ -167,17 +167,17 @@ module Google
167
167
  # puts "Task #{t.key.id} (#cursor)"
168
168
  # end
169
169
  #
170
- def all request_limit: nil
170
+ def all request_limit: nil, &block
171
171
  request_limit = request_limit.to_i if request_limit
172
172
  unless block_given?
173
173
  return enum_for :all, request_limit: request_limit
174
174
  end
175
175
  results = self
176
176
  loop do
177
- results.each { |r| yield r }
177
+ results.each(&block)
178
178
  if request_limit
179
179
  request_limit -= 1
180
- break if request_limit < 0
180
+ break if request_limit.negative?
181
181
  end
182
182
  break unless results.next?
183
183
  results = results.next
@@ -187,14 +187,14 @@ module Google
187
187
  ##
188
188
  # @private New Dataset::LookupResults from a
189
189
  # Google::Dataset::V1::LookupResponse object.
190
- def self.from_grpc lookup_res, service, consistency = nil, tx = nil
190
+ def self.from_grpc lookup_res, service, consistency = nil, transaction = nil
191
191
  entities = to_gcloud_entities lookup_res.found
192
192
  deferred = to_gcloud_keys lookup_res.deferred
193
193
  missing = to_gcloud_entities lookup_res.missing
194
194
  new(entities).tap do |lr|
195
195
  lr.instance_variable_set :@service, service
196
196
  lr.instance_variable_set :@consistency, consistency
197
- lr.instance_variable_set :@transaction, tx
197
+ lr.instance_variable_set :@transaction, transaction
198
198
  lr.instance_variable_set :@deferred, deferred
199
199
  lr.instance_variable_set :@missing, missing
200
200
  end
@@ -266,17 +266,17 @@ module Google
266
266
  # puts "Task #{t.key.id} (#cursor)"
267
267
  # end
268
268
  #
269
- def all request_limit: nil
269
+ def all request_limit: nil, &block
270
270
  request_limit = request_limit.to_i if request_limit
271
271
  unless block_given?
272
272
  return enum_for :all, request_limit: request_limit
273
273
  end
274
274
  results = self
275
275
  loop do
276
- results.each { |r| yield r }
276
+ results.each(&block)
277
277
  if request_limit
278
278
  request_limit -= 1
279
- break if request_limit < 0
279
+ break if request_limit.negative?
280
280
  end
281
281
  break unless results.next?
282
282
  results = results.next
@@ -335,7 +335,7 @@ module Google
335
335
  # puts "Task #{task.key.id} (#cursor)"
336
336
  # end
337
337
  #
338
- def all_with_cursor request_limit: nil
338
+ def all_with_cursor request_limit: nil, &block
339
339
  request_limit = request_limit.to_i if request_limit
340
340
  unless block_given?
341
341
  return enum_for :all_with_cursor, request_limit: request_limit
@@ -343,10 +343,10 @@ module Google
343
343
  results = self
344
344
 
345
345
  loop do
346
- results.zip(results.cursors).each { |r, c| yield r, c }
346
+ results.zip(results.cursors).each(&block)
347
347
  if request_limit
348
348
  request_limit -= 1
349
- break if request_limit < 0
349
+ break if request_limit.negative?
350
350
  end
351
351
  break unless results.next?
352
352
  results = results.next
@@ -293,7 +293,7 @@ module Google
293
293
  # task.persisted? #=> true
294
294
  #
295
295
  def persisted?
296
- @key && @key.frozen?
296
+ @key&.frozen?
297
297
  end
298
298
 
299
299
  ##
@@ -427,10 +427,10 @@ module Google
427
427
  end
428
428
 
429
429
  ##
430
- # @private Convert the Entity to a Google::Datastore::V1::Entity
430
+ # @private Convert the Entity to a Google::Cloud::Datastore::V1::Entity
431
431
  # object.
432
432
  def to_grpc
433
- grpc = Google::Datastore::V1::Entity.new(
433
+ grpc = Google::Cloud::Datastore::V1::Entity.new(
434
434
  properties: @properties.to_grpc
435
435
  )
436
436
  grpc.key = @key.to_grpc unless @key.nil?
@@ -439,7 +439,7 @@ module Google
439
439
  end
440
440
 
441
441
  ##
442
- # @private Create a new Entity from a Google::Datastore::V1::Key
442
+ # @private Create a new Entity from a Google::Cloud::Datastore::V1::Key
443
443
  # object.
444
444
  def self.from_grpc grpc
445
445
  entity = Entity.new