google-cloud-datastore 1.8.2 → 2.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.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/AUTHENTICATION.md +2 -1
  3. data/CHANGELOG.md +23 -0
  4. data/lib/google-cloud-datastore.rb +12 -18
  5. data/lib/google/cloud/datastore.rb +12 -11
  6. data/lib/google/cloud/datastore/commit.rb +4 -4
  7. data/lib/google/cloud/datastore/convert.rb +4 -4
  8. data/lib/google/cloud/datastore/credentials.rb +2 -2
  9. data/lib/google/cloud/datastore/entity.rb +3 -3
  10. data/lib/google/cloud/datastore/gql_query.rb +5 -5
  11. data/lib/google/cloud/datastore/key.rb +5 -5
  12. data/lib/google/cloud/datastore/properties.rb +1 -1
  13. data/lib/google/cloud/datastore/query.rb +12 -12
  14. data/lib/google/cloud/datastore/service.rb +31 -86
  15. data/lib/google/cloud/datastore/version.rb +1 -1
  16. metadata +8 -63
  17. data/lib/google/cloud/datastore/v1.rb +0 -16
  18. data/lib/google/cloud/datastore/v1/credentials.rb +0 -39
  19. data/lib/google/cloud/datastore/v1/datastore_client.rb +0 -577
  20. data/lib/google/cloud/datastore/v1/datastore_client_config.json +0 -61
  21. data/lib/google/cloud/datastore/v1/doc/google/datastore/v1/datastore.rb +0 -283
  22. data/lib/google/cloud/datastore/v1/doc/google/datastore/v1/entity.rb +0 -189
  23. data/lib/google/cloud/datastore/v1/doc/google/datastore/v1/query.rb +0 -297
  24. data/lib/google/cloud/datastore/v1/doc/google/protobuf/struct.rb +0 -74
  25. data/lib/google/cloud/datastore/v1/doc/google/protobuf/timestamp.rb +0 -109
  26. data/lib/google/cloud/datastore/v1/doc/google/protobuf/wrappers.rb +0 -26
  27. data/lib/google/cloud/datastore/v1/doc/google/type/latlng.rb +0 -65
  28. data/lib/google/datastore/v1/datastore_pb.rb +0 -147
  29. data/lib/google/datastore/v1/datastore_services_pb.rb +0 -65
  30. data/lib/google/datastore/v1/entity_pb.rb +0 -64
  31. data/lib/google/datastore/v1/query_pb.rb +0 -132
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Datastore
19
- VERSION = "1.8.2".freeze
19
+ VERSION = "2.0.0".freeze
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: 1.8.2
4
+ version: 2.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: 2020-05-28 00:00:00.000000000 Z
12
+ date: 2020-08-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: google-cloud-core
@@ -17,68 +17,28 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: '1.2'
20
+ version: '1.5'
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: '1.2'
27
+ version: '1.5'
28
28
  - !ruby/object:Gem::Dependency
29
- name: google-gax
29
+ name: google-cloud-datastore-v1
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '1.8'
34
+ version: '0.0'
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: '1.8'
42
- - !ruby/object:Gem::Dependency
43
- name: googleapis-common-protos
44
- requirement: !ruby/object:Gem::Requirement
45
- requirements:
46
- - - ">="
47
- - !ruby/object:Gem::Version
48
- version: 1.3.9
49
- - - "<"
50
- - !ruby/object:Gem::Version
51
- version: '2.0'
52
- type: :runtime
53
- prerelease: false
54
- version_requirements: !ruby/object:Gem::Requirement
55
- requirements:
56
- - - ">="
57
- - !ruby/object:Gem::Version
58
- version: 1.3.9
59
- - - "<"
60
- - !ruby/object:Gem::Version
61
- version: '2.0'
62
- - !ruby/object:Gem::Dependency
63
- name: googleapis-common-protos-types
64
- requirement: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: 1.0.4
69
- - - "<"
70
- - !ruby/object:Gem::Version
71
- version: '2.0'
72
- type: :runtime
73
- prerelease: false
74
- version_requirements: !ruby/object:Gem::Requirement
75
- requirements:
76
- - - ">="
77
- - !ruby/object:Gem::Version
78
- version: 1.0.4
79
- - - "<"
80
- - !ruby/object:Gem::Version
81
- version: '2.0'
41
+ version: '0.0'
82
42
  - !ruby/object:Gem::Dependency
83
43
  name: google-style
84
44
  requirement: !ruby/object:Gem::Requirement
@@ -255,22 +215,7 @@ files:
255
215
  - lib/google/cloud/datastore/read_only_transaction.rb
256
216
  - lib/google/cloud/datastore/service.rb
257
217
  - lib/google/cloud/datastore/transaction.rb
258
- - lib/google/cloud/datastore/v1.rb
259
- - lib/google/cloud/datastore/v1/credentials.rb
260
- - lib/google/cloud/datastore/v1/datastore_client.rb
261
- - lib/google/cloud/datastore/v1/datastore_client_config.json
262
- - lib/google/cloud/datastore/v1/doc/google/datastore/v1/datastore.rb
263
- - lib/google/cloud/datastore/v1/doc/google/datastore/v1/entity.rb
264
- - lib/google/cloud/datastore/v1/doc/google/datastore/v1/query.rb
265
- - lib/google/cloud/datastore/v1/doc/google/protobuf/struct.rb
266
- - lib/google/cloud/datastore/v1/doc/google/protobuf/timestamp.rb
267
- - lib/google/cloud/datastore/v1/doc/google/protobuf/wrappers.rb
268
- - lib/google/cloud/datastore/v1/doc/google/type/latlng.rb
269
218
  - lib/google/cloud/datastore/version.rb
270
- - lib/google/datastore/v1/datastore_pb.rb
271
- - lib/google/datastore/v1/datastore_services_pb.rb
272
- - lib/google/datastore/v1/entity_pb.rb
273
- - lib/google/datastore/v1/query_pb.rb
274
219
  homepage: https://github.com/googleapis/google-cloud-ruby/tree/master/google-cloud-datastore
275
220
  licenses:
276
221
  - Apache-2.0
@@ -290,7 +235,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
290
235
  - !ruby/object:Gem::Version
291
236
  version: '0'
292
237
  requirements: []
293
- rubygems_version: 3.0.6
238
+ rubygems_version: 3.1.3
294
239
  signing_key:
295
240
  specification_version: 4
296
241
  summary: API Client library for Google Cloud Datastore
@@ -1,16 +0,0 @@
1
- # Copyright 2016 Google LLC
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
-
16
- require "google/cloud/datastore/v1/datastore_client"
@@ -1,39 +0,0 @@
1
- # Copyright 2020 Google LLC
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
-
16
- require "googleauth"
17
-
18
- module Google
19
- module Cloud
20
- module Datastore
21
- module V1
22
- class Credentials < Google::Auth::Credentials
23
- SCOPE = ["https://www.googleapis.com/auth/datastore"].freeze
24
- PATH_ENV_VARS = %w(DATASTORE_CREDENTIALS
25
- DATASTORE_KEYFILE
26
- GOOGLE_CLOUD_CREDENTIALS
27
- GOOGLE_CLOUD_KEYFILE
28
- GCLOUD_KEYFILE)
29
- JSON_ENV_VARS = %w(DATASTORE_CREDENTIALS_JSON
30
- DATASTORE_KEYFILE_JSON
31
- GOOGLE_CLOUD_CREDENTIALS_JSON
32
- GOOGLE_CLOUD_KEYFILE_JSON
33
- GCLOUD_KEYFILE_JSON)
34
- DEFAULT_PATHS = ["~/.config/gcloud/application_default_credentials.json"]
35
- end
36
- end
37
- end
38
- end
39
- end
@@ -1,577 +0,0 @@
1
- # Copyright 2020 Google LLC
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
- #
15
- # EDITING INSTRUCTIONS
16
- # This file was generated from the file
17
- # https://github.com/googleapis/googleapis/blob/master/google/datastore/v1/datastore.proto,
18
- # and updates to that file get reflected here through a refresh process.
19
- # For the short term, the refresh process will only be runnable by Google
20
- # engineers.
21
-
22
-
23
- require "json"
24
- require "pathname"
25
-
26
- require "google/gax"
27
-
28
- require "google/datastore/v1/datastore_pb"
29
- require "google/cloud/datastore/v1/credentials"
30
- require "google/cloud/datastore/version"
31
-
32
- module Google
33
- module Cloud
34
- module Datastore
35
- module V1
36
- # Each RPC normalizes the partition IDs of the keys in its input entities,
37
- # and always returns entities with keys with normalized partition IDs.
38
- # This applies to all keys and entities, including those in values, except keys
39
- # with both an empty path and an empty or unset partition ID. Normalization of
40
- # input keys sets the project ID (if not already set) to the project ID from
41
- # the request.
42
- #
43
- # @!attribute [r] datastore_stub
44
- # @return [Google::Datastore::V1::Datastore::Stub]
45
- class DatastoreClient
46
- # @private
47
- attr_reader :datastore_stub
48
-
49
- # The default address of the service.
50
- SERVICE_ADDRESS = "datastore.googleapis.com".freeze
51
-
52
- # The default port of the service.
53
- DEFAULT_SERVICE_PORT = 443
54
-
55
- # The default set of gRPC interceptors.
56
- GRPC_INTERCEPTORS = []
57
-
58
- DEFAULT_TIMEOUT = 30
59
-
60
- # The scopes needed to make gRPC calls to all of the methods defined in
61
- # this service.
62
- ALL_SCOPES = [
63
- "https://www.googleapis.com/auth/cloud-platform",
64
- "https://www.googleapis.com/auth/datastore"
65
- ].freeze
66
-
67
-
68
- # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
69
- # Provides the means for authenticating requests made by the client. This parameter can
70
- # be many types.
71
- # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
72
- # authenticating requests made by this client.
73
- # A `String` will be treated as the path to the keyfile to be used for the construction of
74
- # credentials for this client.
75
- # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
76
- # credentials for this client.
77
- # A `GRPC::Core::Channel` will be used to make calls through.
78
- # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
79
- # should already be composed with a `GRPC::Core::CallCredentials` object.
80
- # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
81
- # metadata for requests, generally, to give OAuth credentials.
82
- # @param scopes [Array<String>]
83
- # The OAuth scopes for this service. This parameter is ignored if
84
- # an updater_proc is supplied.
85
- # @param client_config [Hash]
86
- # A Hash for call options for each method. See
87
- # Google::Gax#construct_settings for the structure of
88
- # this data. Falls back to the default config if not specified
89
- # or the specified config is missing data points.
90
- # @param timeout [Numeric]
91
- # The default timeout, in seconds, for calls made through this client.
92
- # @param metadata [Hash]
93
- # Default metadata to be sent with each request. This can be overridden on a per call basis.
94
- # @param service_address [String]
95
- # Override for the service hostname, or `nil` to leave as the default.
96
- # @param service_port [Integer]
97
- # Override for the service port, or `nil` to leave as the default.
98
- # @param exception_transformer [Proc]
99
- # An optional proc that intercepts any exceptions raised during an API call to inject
100
- # custom error handling.
101
- def initialize \
102
- credentials: nil,
103
- scopes: ALL_SCOPES,
104
- client_config: {},
105
- timeout: DEFAULT_TIMEOUT,
106
- metadata: nil,
107
- service_address: nil,
108
- service_port: nil,
109
- exception_transformer: nil,
110
- lib_name: nil,
111
- lib_version: ""
112
- # These require statements are intentionally placed here to initialize
113
- # the gRPC module only when it's required.
114
- # See https://github.com/googleapis/toolkit/issues/446
115
- require "google/gax/grpc"
116
- require "google/datastore/v1/datastore_services_pb"
117
-
118
- credentials ||= Google::Cloud::Datastore::V1::Credentials.default
119
-
120
- if credentials.is_a?(String) || credentials.is_a?(Hash)
121
- updater_proc = Google::Cloud::Datastore::V1::Credentials.new(credentials).updater_proc
122
- end
123
- if credentials.is_a?(GRPC::Core::Channel)
124
- channel = credentials
125
- end
126
- if credentials.is_a?(GRPC::Core::ChannelCredentials)
127
- chan_creds = credentials
128
- end
129
- if credentials.is_a?(Proc)
130
- updater_proc = credentials
131
- end
132
- if credentials.is_a?(Google::Auth::Credentials)
133
- updater_proc = credentials.updater_proc
134
- end
135
-
136
- package_version = Google::Cloud::Datastore::VERSION
137
-
138
- google_api_client = "gl-ruby/#{RUBY_VERSION}"
139
- google_api_client << " #{lib_name}/#{lib_version}" if lib_name
140
- google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
141
- google_api_client << " grpc/#{GRPC::VERSION}"
142
- google_api_client.freeze
143
-
144
- headers = { :"x-goog-api-client" => google_api_client }
145
- if credentials.respond_to?(:quota_project_id) && credentials.quota_project_id
146
- headers[:"x-goog-user-project"] = credentials.quota_project_id
147
- end
148
- headers.merge!(metadata) unless metadata.nil?
149
- client_config_file = Pathname.new(__dir__).join(
150
- "datastore_client_config.json"
151
- )
152
- defaults = client_config_file.open do |f|
153
- Google::Gax.construct_settings(
154
- "google.datastore.v1.Datastore",
155
- JSON.parse(f.read),
156
- client_config,
157
- Google::Gax::Grpc::STATUS_CODE_NAMES,
158
- timeout,
159
- errors: Google::Gax::Grpc::API_ERRORS,
160
- metadata: headers
161
- )
162
- end
163
-
164
- # Allow overriding the service path/port in subclasses.
165
- service_path = service_address || self.class::SERVICE_ADDRESS
166
- port = service_port || self.class::DEFAULT_SERVICE_PORT
167
- interceptors = self.class::GRPC_INTERCEPTORS
168
- @datastore_stub = Google::Gax::Grpc.create_stub(
169
- service_path,
170
- port,
171
- chan_creds: chan_creds,
172
- channel: channel,
173
- updater_proc: updater_proc,
174
- scopes: scopes,
175
- interceptors: interceptors,
176
- &Google::Datastore::V1::Datastore::Stub.method(:new)
177
- )
178
-
179
- @lookup = Google::Gax.create_api_call(
180
- @datastore_stub.method(:lookup),
181
- defaults["lookup"],
182
- exception_transformer: exception_transformer,
183
- params_extractor: proc do |request|
184
- {'project_id' => request.project_id}
185
- end
186
- )
187
- @run_query = Google::Gax.create_api_call(
188
- @datastore_stub.method(:run_query),
189
- defaults["run_query"],
190
- exception_transformer: exception_transformer,
191
- params_extractor: proc do |request|
192
- {'project_id' => request.project_id}
193
- end
194
- )
195
- @reserve_ids = Google::Gax.create_api_call(
196
- @datastore_stub.method(:reserve_ids),
197
- defaults["reserve_ids"],
198
- exception_transformer: exception_transformer,
199
- params_extractor: proc do |request|
200
- {'project_id' => request.project_id}
201
- end
202
- )
203
- @begin_transaction = Google::Gax.create_api_call(
204
- @datastore_stub.method(:begin_transaction),
205
- defaults["begin_transaction"],
206
- exception_transformer: exception_transformer,
207
- params_extractor: proc do |request|
208
- {'project_id' => request.project_id}
209
- end
210
- )
211
- @commit = Google::Gax.create_api_call(
212
- @datastore_stub.method(:commit),
213
- defaults["commit"],
214
- exception_transformer: exception_transformer,
215
- params_extractor: proc do |request|
216
- {'project_id' => request.project_id}
217
- end
218
- )
219
- @rollback = Google::Gax.create_api_call(
220
- @datastore_stub.method(:rollback),
221
- defaults["rollback"],
222
- exception_transformer: exception_transformer,
223
- params_extractor: proc do |request|
224
- {'project_id' => request.project_id}
225
- end
226
- )
227
- @allocate_ids = Google::Gax.create_api_call(
228
- @datastore_stub.method(:allocate_ids),
229
- defaults["allocate_ids"],
230
- exception_transformer: exception_transformer,
231
- params_extractor: proc do |request|
232
- {'project_id' => request.project_id}
233
- end
234
- )
235
- end
236
-
237
- # Service calls
238
-
239
- # Looks up entities by key.
240
- #
241
- # @param project_id [String]
242
- # Required. The ID of the project against which to make the request.
243
- # @param keys [Array<Google::Datastore::V1::Key | Hash>]
244
- # Required. Keys of entities to look up.
245
- # A hash of the same form as `Google::Datastore::V1::Key`
246
- # can also be provided.
247
- # @param read_options [Google::Datastore::V1::ReadOptions | Hash]
248
- # The options for this lookup request.
249
- # A hash of the same form as `Google::Datastore::V1::ReadOptions`
250
- # can also be provided.
251
- # @param options [Google::Gax::CallOptions]
252
- # Overrides the default settings for this call, e.g, timeout,
253
- # retries, etc.
254
- # @yield [result, operation] Access the result along with the RPC operation
255
- # @yieldparam result [Google::Datastore::V1::LookupResponse]
256
- # @yieldparam operation [GRPC::ActiveCall::Operation]
257
- # @return [Google::Datastore::V1::LookupResponse]
258
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
259
- # @example
260
- # require "google/cloud/datastore"
261
- #
262
- # datastore_client = Google::Cloud::Datastore.new(version: :v1)
263
- #
264
- # # TODO: Initialize `project_id`:
265
- # project_id = ''
266
- #
267
- # # TODO: Initialize `keys`:
268
- # keys = []
269
- # response = datastore_client.lookup(project_id, keys)
270
-
271
- def lookup \
272
- project_id,
273
- keys,
274
- read_options: nil,
275
- options: nil,
276
- &block
277
- req = {
278
- project_id: project_id,
279
- keys: keys,
280
- read_options: read_options
281
- }.delete_if { |_, v| v.nil? }
282
- req = Google::Gax::to_proto(req, Google::Datastore::V1::LookupRequest)
283
- @lookup.call(req, options, &block)
284
- end
285
-
286
- # Queries for entities.
287
- #
288
- # @param project_id [String]
289
- # Required. The ID of the project against which to make the request.
290
- # @param partition_id [Google::Datastore::V1::PartitionId | Hash]
291
- # Entities are partitioned into subsets, identified by a partition ID.
292
- # Queries are scoped to a single partition.
293
- # This partition ID is normalized with the standard default context
294
- # partition ID.
295
- # A hash of the same form as `Google::Datastore::V1::PartitionId`
296
- # can also be provided.
297
- # @param read_options [Google::Datastore::V1::ReadOptions | Hash]
298
- # The options for this query.
299
- # A hash of the same form as `Google::Datastore::V1::ReadOptions`
300
- # can also be provided.
301
- # @param query [Google::Datastore::V1::Query | Hash]
302
- # The query to run.
303
- # A hash of the same form as `Google::Datastore::V1::Query`
304
- # can also be provided.
305
- # @param gql_query [Google::Datastore::V1::GqlQuery | Hash]
306
- # The GQL query to run.
307
- # A hash of the same form as `Google::Datastore::V1::GqlQuery`
308
- # can also be provided.
309
- # @param options [Google::Gax::CallOptions]
310
- # Overrides the default settings for this call, e.g, timeout,
311
- # retries, etc.
312
- # @yield [result, operation] Access the result along with the RPC operation
313
- # @yieldparam result [Google::Datastore::V1::RunQueryResponse]
314
- # @yieldparam operation [GRPC::ActiveCall::Operation]
315
- # @return [Google::Datastore::V1::RunQueryResponse]
316
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
317
- # @example
318
- # require "google/cloud/datastore"
319
- #
320
- # datastore_client = Google::Cloud::Datastore.new(version: :v1)
321
- #
322
- # # TODO: Initialize `project_id`:
323
- # project_id = ''
324
- # response = datastore_client.run_query(project_id)
325
-
326
- def run_query \
327
- project_id,
328
- partition_id: nil,
329
- read_options: nil,
330
- query: nil,
331
- gql_query: nil,
332
- options: nil,
333
- &block
334
- req = {
335
- project_id: project_id,
336
- partition_id: partition_id,
337
- read_options: read_options,
338
- query: query,
339
- gql_query: gql_query
340
- }.delete_if { |_, v| v.nil? }
341
- req = Google::Gax::to_proto(req, Google::Datastore::V1::RunQueryRequest)
342
- @run_query.call(req, options, &block)
343
- end
344
-
345
- # Prevents the supplied keys' IDs from being auto-allocated by Cloud
346
- # Datastore.
347
- #
348
- # @param project_id [String]
349
- # Required. The ID of the project against which to make the request.
350
- # @param keys [Array<Google::Datastore::V1::Key | Hash>]
351
- # Required. A list of keys with complete key paths whose numeric IDs should not be
352
- # auto-allocated.
353
- # A hash of the same form as `Google::Datastore::V1::Key`
354
- # can also be provided.
355
- # @param database_id [String]
356
- # If not empty, the ID of the database against which to make the request.
357
- # @param options [Google::Gax::CallOptions]
358
- # Overrides the default settings for this call, e.g, timeout,
359
- # retries, etc.
360
- # @yield [result, operation] Access the result along with the RPC operation
361
- # @yieldparam result [Google::Datastore::V1::ReserveIdsResponse]
362
- # @yieldparam operation [GRPC::ActiveCall::Operation]
363
- # @return [Google::Datastore::V1::ReserveIdsResponse]
364
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
365
- # @example
366
- # require "google/cloud/datastore"
367
- #
368
- # datastore_client = Google::Cloud::Datastore.new(version: :v1)
369
- #
370
- # # TODO: Initialize `project_id`:
371
- # project_id = ''
372
- #
373
- # # TODO: Initialize `keys`:
374
- # keys = []
375
- # response = datastore_client.reserve_ids(project_id, keys)
376
-
377
- def reserve_ids \
378
- project_id,
379
- keys,
380
- database_id: nil,
381
- options: nil,
382
- &block
383
- req = {
384
- project_id: project_id,
385
- keys: keys,
386
- database_id: database_id
387
- }.delete_if { |_, v| v.nil? }
388
- req = Google::Gax::to_proto(req, Google::Datastore::V1::ReserveIdsRequest)
389
- @reserve_ids.call(req, options, &block)
390
- end
391
-
392
- # Begins a new transaction.
393
- #
394
- # @param project_id [String]
395
- # Required. The ID of the project against which to make the request.
396
- # @param transaction_options [Google::Datastore::V1::TransactionOptions | Hash]
397
- # Options for a new transaction.
398
- # A hash of the same form as `Google::Datastore::V1::TransactionOptions`
399
- # can also be provided.
400
- # @param options [Google::Gax::CallOptions]
401
- # Overrides the default settings for this call, e.g, timeout,
402
- # retries, etc.
403
- # @yield [result, operation] Access the result along with the RPC operation
404
- # @yieldparam result [Google::Datastore::V1::BeginTransactionResponse]
405
- # @yieldparam operation [GRPC::ActiveCall::Operation]
406
- # @return [Google::Datastore::V1::BeginTransactionResponse]
407
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
408
- # @example
409
- # require "google/cloud/datastore"
410
- #
411
- # datastore_client = Google::Cloud::Datastore.new(version: :v1)
412
- #
413
- # # TODO: Initialize `project_id`:
414
- # project_id = ''
415
- # response = datastore_client.begin_transaction(project_id)
416
-
417
- def begin_transaction \
418
- project_id,
419
- transaction_options: nil,
420
- options: nil,
421
- &block
422
- req = {
423
- project_id: project_id,
424
- transaction_options: transaction_options
425
- }.delete_if { |_, v| v.nil? }
426
- req = Google::Gax::to_proto(req, Google::Datastore::V1::BeginTransactionRequest)
427
- @begin_transaction.call(req, options, &block)
428
- end
429
-
430
- # Commits a transaction, optionally creating, deleting or modifying some
431
- # entities.
432
- #
433
- # @param project_id [String]
434
- # Required. The ID of the project against which to make the request.
435
- # @param mode [Google::Datastore::V1::CommitRequest::Mode]
436
- # The type of commit to perform. Defaults to `TRANSACTIONAL`.
437
- # @param transaction [String]
438
- # The identifier of the transaction associated with the commit. A
439
- # transaction identifier is returned by a call to
440
- # {Google::Datastore::V1::Datastore::BeginTransaction Datastore::BeginTransaction}.
441
- # @param mutations [Array<Google::Datastore::V1::Mutation | Hash>]
442
- # The mutations to perform.
443
- #
444
- # When mode is `TRANSACTIONAL`, mutations affecting a single entity are
445
- # applied in order. The following sequences of mutations affecting a single
446
- # entity are not permitted in a single `Commit` request:
447
- #
448
- # * `insert` followed by `insert`
449
- # * `update` followed by `insert`
450
- # * `upsert` followed by `insert`
451
- # * `delete` followed by `update`
452
- #
453
- # When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single
454
- # entity.
455
- # A hash of the same form as `Google::Datastore::V1::Mutation`
456
- # can also be provided.
457
- # @param options [Google::Gax::CallOptions]
458
- # Overrides the default settings for this call, e.g, timeout,
459
- # retries, etc.
460
- # @yield [result, operation] Access the result along with the RPC operation
461
- # @yieldparam result [Google::Datastore::V1::CommitResponse]
462
- # @yieldparam operation [GRPC::ActiveCall::Operation]
463
- # @return [Google::Datastore::V1::CommitResponse]
464
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
465
- # @example
466
- # require "google/cloud/datastore"
467
- #
468
- # datastore_client = Google::Cloud::Datastore.new(version: :v1)
469
- #
470
- # # TODO: Initialize `project_id`:
471
- # project_id = ''
472
- # response = datastore_client.commit(project_id)
473
-
474
- def commit \
475
- project_id,
476
- mode: nil,
477
- transaction: nil,
478
- mutations: nil,
479
- options: nil,
480
- &block
481
- req = {
482
- project_id: project_id,
483
- mode: mode,
484
- transaction: transaction,
485
- mutations: mutations
486
- }.delete_if { |_, v| v.nil? }
487
- req = Google::Gax::to_proto(req, Google::Datastore::V1::CommitRequest)
488
- @commit.call(req, options, &block)
489
- end
490
-
491
- # Rolls back a transaction.
492
- #
493
- # @param project_id [String]
494
- # Required. The ID of the project against which to make the request.
495
- # @param transaction [String]
496
- # Required. The transaction identifier, returned by a call to
497
- # {Google::Datastore::V1::Datastore::BeginTransaction Datastore::BeginTransaction}.
498
- # @param options [Google::Gax::CallOptions]
499
- # Overrides the default settings for this call, e.g, timeout,
500
- # retries, etc.
501
- # @yield [result, operation] Access the result along with the RPC operation
502
- # @yieldparam result [Google::Datastore::V1::RollbackResponse]
503
- # @yieldparam operation [GRPC::ActiveCall::Operation]
504
- # @return [Google::Datastore::V1::RollbackResponse]
505
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
506
- # @example
507
- # require "google/cloud/datastore"
508
- #
509
- # datastore_client = Google::Cloud::Datastore.new(version: :v1)
510
- #
511
- # # TODO: Initialize `project_id`:
512
- # project_id = ''
513
- #
514
- # # TODO: Initialize `transaction`:
515
- # transaction = ''
516
- # response = datastore_client.rollback(project_id, transaction)
517
-
518
- def rollback \
519
- project_id,
520
- transaction,
521
- options: nil,
522
- &block
523
- req = {
524
- project_id: project_id,
525
- transaction: transaction
526
- }.delete_if { |_, v| v.nil? }
527
- req = Google::Gax::to_proto(req, Google::Datastore::V1::RollbackRequest)
528
- @rollback.call(req, options, &block)
529
- end
530
-
531
- # Allocates IDs for the given keys, which is useful for referencing an entity
532
- # before it is inserted.
533
- #
534
- # @param project_id [String]
535
- # Required. The ID of the project against which to make the request.
536
- # @param keys [Array<Google::Datastore::V1::Key | Hash>]
537
- # Required. A list of keys with incomplete key paths for which to allocate IDs.
538
- # No key may be reserved/read-only.
539
- # A hash of the same form as `Google::Datastore::V1::Key`
540
- # can also be provided.
541
- # @param options [Google::Gax::CallOptions]
542
- # Overrides the default settings for this call, e.g, timeout,
543
- # retries, etc.
544
- # @yield [result, operation] Access the result along with the RPC operation
545
- # @yieldparam result [Google::Datastore::V1::AllocateIdsResponse]
546
- # @yieldparam operation [GRPC::ActiveCall::Operation]
547
- # @return [Google::Datastore::V1::AllocateIdsResponse]
548
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
549
- # @example
550
- # require "google/cloud/datastore"
551
- #
552
- # datastore_client = Google::Cloud::Datastore.new(version: :v1)
553
- #
554
- # # TODO: Initialize `project_id`:
555
- # project_id = ''
556
- #
557
- # # TODO: Initialize `keys`:
558
- # keys = []
559
- # response = datastore_client.allocate_ids(project_id, keys)
560
-
561
- def allocate_ids \
562
- project_id,
563
- keys,
564
- options: nil,
565
- &block
566
- req = {
567
- project_id: project_id,
568
- keys: keys
569
- }.delete_if { |_, v| v.nil? }
570
- req = Google::Gax::to_proto(req, Google::Datastore::V1::AllocateIdsRequest)
571
- @allocate_ids.call(req, options, &block)
572
- end
573
- end
574
- end
575
- end
576
- end
577
- end