google-cloud-datastore 1.4.0 → 1.4.1
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 +4 -4
- data/.yardopts +2 -1
- data/README.md +30 -1
- data/lib/google/cloud/datastore.rb +33 -0
- data/lib/google/cloud/datastore/credentials.rb +2 -14
- data/lib/google/cloud/datastore/v1/credentials.rb +38 -0
- data/lib/google/cloud/datastore/v1/datastore_client.rb +124 -60
- data/lib/google/cloud/datastore/v1/doc/google/datastore/v1/datastore.rb +1 -12
- data/lib/google/cloud/datastore/v1/doc/google/datastore/v1/entity.rb +1 -1
- data/lib/google/cloud/datastore/v1/doc/google/datastore/v1/query.rb +1 -1
- data/lib/google/cloud/datastore/v1/doc/google/protobuf/wrappers.rb +1 -1
- data/lib/google/cloud/datastore/version.rb +1 -1
- data/lib/google/datastore/v1/datastore_services_pb.rb +2 -2
- metadata +18 -4
- data/lib/google/cloud/datastore/v1/doc/overview.rb +0 -54
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6677adc0fe54bae8453d609401a902aa2afc5e1231b5ee57a3b75c1d86cdda7e
|
4
|
+
data.tar.gz: f8092af4287def66a0ff425150039e5e9a2dae3e38a2f1adcff037700f01c4c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9690a8f334e5b29a2d18e89420f0adb787b0b5a2b3f5b2c36e8bb7fb4087b566848ed2cb8fff800fe932e60b8225702fe469f6b99e8e1945614a7fbd175705c8
|
7
|
+
data.tar.gz: 77b81d3cab09c0bfe41b2b644f8b7932835a6a0731c90d6f22127a99952703a0ab11b899e1e26ec26a6118ed15d9d8e42d33e2c7f5afef14b33e06927a9d973d
|
data/.yardopts
CHANGED
data/README.md
CHANGED
@@ -47,9 +47,38 @@ query = datastore.query("Task").
|
|
47
47
|
tasks = datastore.run query
|
48
48
|
```
|
49
49
|
|
50
|
+
## Enabling Logging
|
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.
|
53
|
+
|
54
|
+
Configuring a Ruby stdlib logger:
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
require "logger"
|
58
|
+
|
59
|
+
module MyLogger
|
60
|
+
LOGGER = Logger.new $stderr, level: Logger::WARN
|
61
|
+
def logger
|
62
|
+
LOGGER
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# Define a gRPC module-level logger method before grpc/logconfig.rb loads.
|
67
|
+
module GRPC
|
68
|
+
extend MyLogger
|
69
|
+
end
|
70
|
+
```
|
71
|
+
|
50
72
|
## Supported Ruby Versions
|
51
73
|
|
52
|
-
This library is supported on Ruby 2.
|
74
|
+
This library is supported on Ruby 2.3+.
|
75
|
+
|
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
|
80
|
+
recommended. See https://www.ruby-lang.org/en/downloads/branches/ for details
|
81
|
+
about the Ruby support schedule.
|
53
82
|
|
54
83
|
## Versioning
|
55
84
|
|
@@ -61,6 +61,39 @@ module Google
|
|
61
61
|
# [Google Cloud Datastore Concepts Overview
|
62
62
|
# ](https://cloud.google.com/datastore/docs/concepts/overview).
|
63
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
|
+
#
|
64
97
|
# ## Retrieving records
|
65
98
|
#
|
66
99
|
# Records, called "entities" in Datastore, are retrieved by using a key.
|
@@ -14,6 +14,7 @@
|
|
14
14
|
|
15
15
|
|
16
16
|
require "googleauth"
|
17
|
+
require "google/cloud/datastore/v1/credentials"
|
17
18
|
|
18
19
|
module Google
|
19
20
|
module Cloud
|
@@ -37,20 +38,7 @@ module Google
|
|
37
38
|
#
|
38
39
|
# datastore.project_id #=> "my-todo-project"
|
39
40
|
#
|
40
|
-
class Credentials < Google::
|
41
|
-
SCOPE = ["https://www.googleapis.com/auth/datastore"].freeze
|
42
|
-
PATH_ENV_VARS = %w[DATASTORE_CREDENTIALS
|
43
|
-
DATASTORE_KEYFILE
|
44
|
-
GOOGLE_CLOUD_CREDENTIALS
|
45
|
-
GOOGLE_CLOUD_KEYFILE
|
46
|
-
GCLOUD_KEYFILE].freeze
|
47
|
-
JSON_ENV_VARS = %w[DATASTORE_CREDENTIALS_JSON
|
48
|
-
DATASTORE_KEYFILE_JSON
|
49
|
-
GOOGLE_CLOUD_CREDENTIALS_JSON
|
50
|
-
GOOGLE_CLOUD_KEYFILE_JSON
|
51
|
-
GCLOUD_KEYFILE_JSON].freeze
|
52
|
-
DEFAULT_PATHS = \
|
53
|
-
["~/.config/gcloud/application_default_credentials.json"].freeze
|
41
|
+
class Credentials < Google::Cloud::Datastore::V1::Credentials
|
54
42
|
end
|
55
43
|
end
|
56
44
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# Copyright 2018 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
|
+
require "googleauth"
|
16
|
+
|
17
|
+
module Google
|
18
|
+
module Cloud
|
19
|
+
module Datastore
|
20
|
+
module V1
|
21
|
+
class Credentials < Google::Auth::Credentials
|
22
|
+
SCOPE = ["https://www.googleapis.com/auth/datastore"].freeze
|
23
|
+
PATH_ENV_VARS = %w(DATASTORE_CREDENTIALS
|
24
|
+
DATASTORE_KEYFILE
|
25
|
+
GOOGLE_CLOUD_CREDENTIALS
|
26
|
+
GOOGLE_CLOUD_KEYFILE
|
27
|
+
GCLOUD_KEYFILE)
|
28
|
+
JSON_ENV_VARS = %w(DATASTORE_CREDENTIALS_JSON
|
29
|
+
DATASTORE_KEYFILE_JSON
|
30
|
+
GOOGLE_CLOUD_CREDENTIALS_JSON
|
31
|
+
GOOGLE_CLOUD_KEYFILE_JSON
|
32
|
+
GCLOUD_KEYFILE_JSON)
|
33
|
+
DEFAULT_PATHS = ["~/.config/gcloud/application_default_credentials.json"]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2018 Google LLC
|
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.
|
@@ -18,9 +18,6 @@
|
|
18
18
|
# and updates to that file get reflected here through a refresh process.
|
19
19
|
# For the short term, the refresh process will only be runnable by Google
|
20
20
|
# engineers.
|
21
|
-
#
|
22
|
-
# The only allowed edits are to method and file documentation. A 3-way
|
23
|
-
# merge preserves those additions if the generated source changes.
|
24
21
|
|
25
22
|
require "json"
|
26
23
|
require "pathname"
|
@@ -28,7 +25,7 @@ require "pathname"
|
|
28
25
|
require "google/gax"
|
29
26
|
|
30
27
|
require "google/datastore/v1/datastore_pb"
|
31
|
-
require "google/cloud/datastore/credentials"
|
28
|
+
require "google/cloud/datastore/v1/credentials"
|
32
29
|
|
33
30
|
module Google
|
34
31
|
module Cloud
|
@@ -52,6 +49,9 @@ module Google
|
|
52
49
|
# The default port of the service.
|
53
50
|
DEFAULT_SERVICE_PORT = 443
|
54
51
|
|
52
|
+
# The default set of gRPC interceptors.
|
53
|
+
GRPC_INTERCEPTORS = []
|
54
|
+
|
55
55
|
DEFAULT_TIMEOUT = 30
|
56
56
|
|
57
57
|
# The scopes needed to make gRPC calls to all of the methods defined in
|
@@ -61,6 +61,7 @@ module Google
|
|
61
61
|
"https://www.googleapis.com/auth/datastore"
|
62
62
|
].freeze
|
63
63
|
|
64
|
+
|
64
65
|
# @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
|
65
66
|
# Provides the means for authenticating requests made by the client. This parameter can
|
66
67
|
# be many types.
|
@@ -85,16 +86,18 @@ module Google
|
|
85
86
|
# or the specified config is missing data points.
|
86
87
|
# @param timeout [Numeric]
|
87
88
|
# The default timeout, in seconds, for calls made through this client.
|
89
|
+
# @param metadata [Hash]
|
90
|
+
# Default metadata to be sent with each request. This can be overridden on a per call basis.
|
91
|
+
# @param exception_transformer [Proc]
|
92
|
+
# An optional proc that intercepts any exceptions raised during an API call to inject
|
93
|
+
# custom error handling.
|
88
94
|
def initialize \
|
89
|
-
service_path: SERVICE_ADDRESS,
|
90
|
-
port: DEFAULT_SERVICE_PORT,
|
91
|
-
channel: nil,
|
92
|
-
chan_creds: nil,
|
93
|
-
updater_proc: nil,
|
94
95
|
credentials: nil,
|
95
96
|
scopes: ALL_SCOPES,
|
96
97
|
client_config: {},
|
97
98
|
timeout: DEFAULT_TIMEOUT,
|
99
|
+
metadata: nil,
|
100
|
+
exception_transformer: nil,
|
98
101
|
lib_name: nil,
|
99
102
|
lib_version: ""
|
100
103
|
# These require statements are intentionally placed here to initialize
|
@@ -103,21 +106,10 @@ module Google
|
|
103
106
|
require "google/gax/grpc"
|
104
107
|
require "google/datastore/v1/datastore_services_pb"
|
105
108
|
|
106
|
-
|
107
|
-
warn "The `channel`, `chan_creds`, and `updater_proc` parameters will be removed " \
|
108
|
-
"on 2017/09/08"
|
109
|
-
credentials ||= channel
|
110
|
-
credentials ||= chan_creds
|
111
|
-
credentials ||= updater_proc
|
112
|
-
end
|
113
|
-
if service_path != SERVICE_ADDRESS || port != DEFAULT_SERVICE_PORT
|
114
|
-
warn "`service_path` and `port` parameters are deprecated and will be removed"
|
115
|
-
end
|
116
|
-
|
117
|
-
credentials ||= Google::Cloud::Datastore::Credentials.default
|
109
|
+
credentials ||= Google::Cloud::Datastore::V1::Credentials.default
|
118
110
|
|
119
111
|
if credentials.is_a?(String) || credentials.is_a?(Hash)
|
120
|
-
updater_proc = Google::Cloud::Datastore::Credentials.new(credentials).updater_proc
|
112
|
+
updater_proc = Google::Cloud::Datastore::V1::Credentials.new(credentials).updater_proc
|
121
113
|
end
|
122
114
|
if credentials.is_a?(GRPC::Core::Channel)
|
123
115
|
channel = credentials
|
@@ -132,13 +124,16 @@ module Google
|
|
132
124
|
updater_proc = credentials.updater_proc
|
133
125
|
end
|
134
126
|
|
127
|
+
package_version = Gem.loaded_specs['google-cloud-datastore'].version.version
|
128
|
+
|
135
129
|
google_api_client = "gl-ruby/#{RUBY_VERSION}"
|
136
130
|
google_api_client << " #{lib_name}/#{lib_version}" if lib_name
|
137
|
-
google_api_client << " gapic
|
131
|
+
google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
|
138
132
|
google_api_client << " grpc/#{GRPC::VERSION}"
|
139
133
|
google_api_client.freeze
|
140
134
|
|
141
135
|
headers = { :"x-goog-api-client" => google_api_client }
|
136
|
+
headers.merge!(metadata) unless metadata.nil?
|
142
137
|
client_config_file = Pathname.new(__dir__).join(
|
143
138
|
"datastore_client_config.json"
|
144
139
|
)
|
@@ -150,9 +145,14 @@ module Google
|
|
150
145
|
Google::Gax::Grpc::STATUS_CODE_NAMES,
|
151
146
|
timeout,
|
152
147
|
errors: Google::Gax::Grpc::API_ERRORS,
|
153
|
-
|
148
|
+
metadata: headers
|
154
149
|
)
|
155
150
|
end
|
151
|
+
|
152
|
+
# Allow overriding the service path/port in subclasses.
|
153
|
+
service_path = self.class::SERVICE_ADDRESS
|
154
|
+
port = self.class::DEFAULT_SERVICE_PORT
|
155
|
+
interceptors = self.class::GRPC_INTERCEPTORS
|
156
156
|
@datastore_stub = Google::Gax::Grpc.create_stub(
|
157
157
|
service_path,
|
158
158
|
port,
|
@@ -160,36 +160,44 @@ module Google
|
|
160
160
|
channel: channel,
|
161
161
|
updater_proc: updater_proc,
|
162
162
|
scopes: scopes,
|
163
|
+
interceptors: interceptors,
|
163
164
|
&Google::Datastore::V1::Datastore::Stub.method(:new)
|
164
165
|
)
|
165
166
|
|
166
167
|
@lookup = Google::Gax.create_api_call(
|
167
168
|
@datastore_stub.method(:lookup),
|
168
|
-
defaults["lookup"]
|
169
|
+
defaults["lookup"],
|
170
|
+
exception_transformer: exception_transformer
|
169
171
|
)
|
170
172
|
@run_query = Google::Gax.create_api_call(
|
171
173
|
@datastore_stub.method(:run_query),
|
172
|
-
defaults["run_query"]
|
174
|
+
defaults["run_query"],
|
175
|
+
exception_transformer: exception_transformer
|
173
176
|
)
|
174
177
|
@begin_transaction = Google::Gax.create_api_call(
|
175
178
|
@datastore_stub.method(:begin_transaction),
|
176
|
-
defaults["begin_transaction"]
|
179
|
+
defaults["begin_transaction"],
|
180
|
+
exception_transformer: exception_transformer
|
177
181
|
)
|
178
182
|
@commit = Google::Gax.create_api_call(
|
179
183
|
@datastore_stub.method(:commit),
|
180
|
-
defaults["commit"]
|
184
|
+
defaults["commit"],
|
185
|
+
exception_transformer: exception_transformer
|
181
186
|
)
|
182
187
|
@rollback = Google::Gax.create_api_call(
|
183
188
|
@datastore_stub.method(:rollback),
|
184
|
-
defaults["rollback"]
|
189
|
+
defaults["rollback"],
|
190
|
+
exception_transformer: exception_transformer
|
185
191
|
)
|
186
192
|
@allocate_ids = Google::Gax.create_api_call(
|
187
193
|
@datastore_stub.method(:allocate_ids),
|
188
|
-
defaults["allocate_ids"]
|
194
|
+
defaults["allocate_ids"],
|
195
|
+
exception_transformer: exception_transformer
|
189
196
|
)
|
190
197
|
@reserve_ids = Google::Gax.create_api_call(
|
191
198
|
@datastore_stub.method(:reserve_ids),
|
192
|
-
defaults["reserve_ids"]
|
199
|
+
defaults["reserve_ids"],
|
200
|
+
exception_transformer: exception_transformer
|
193
201
|
)
|
194
202
|
end
|
195
203
|
|
@@ -210,13 +218,20 @@ module Google
|
|
210
218
|
# @param options [Google::Gax::CallOptions]
|
211
219
|
# Overrides the default settings for this call, e.g, timeout,
|
212
220
|
# retries, etc.
|
221
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
222
|
+
# @yieldparam result [Google::Datastore::V1::LookupResponse]
|
223
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
213
224
|
# @return [Google::Datastore::V1::LookupResponse]
|
214
225
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
215
226
|
# @example
|
216
|
-
# require "google/cloud/datastore
|
227
|
+
# require "google/cloud/datastore"
|
228
|
+
#
|
229
|
+
# datastore_client = Google::Cloud::Datastore.new(version: :v1)
|
217
230
|
#
|
218
|
-
#
|
231
|
+
# # TODO: Initialize +project_id+:
|
219
232
|
# project_id = ''
|
233
|
+
#
|
234
|
+
# # TODO: Initialize +keys+:
|
220
235
|
# keys = []
|
221
236
|
# response = datastore_client.lookup(project_id, keys)
|
222
237
|
|
@@ -224,14 +239,15 @@ module Google
|
|
224
239
|
project_id,
|
225
240
|
keys,
|
226
241
|
read_options: nil,
|
227
|
-
options: nil
|
242
|
+
options: nil,
|
243
|
+
&block
|
228
244
|
req = {
|
229
245
|
project_id: project_id,
|
230
246
|
keys: keys,
|
231
247
|
read_options: read_options
|
232
248
|
}.delete_if { |_, v| v.nil? }
|
233
249
|
req = Google::Gax::to_proto(req, Google::Datastore::V1::LookupRequest)
|
234
|
-
@lookup.call(req, options)
|
250
|
+
@lookup.call(req, options, &block)
|
235
251
|
end
|
236
252
|
|
237
253
|
# Queries for entities.
|
@@ -260,13 +276,20 @@ module Google
|
|
260
276
|
# @param options [Google::Gax::CallOptions]
|
261
277
|
# Overrides the default settings for this call, e.g, timeout,
|
262
278
|
# retries, etc.
|
279
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
280
|
+
# @yieldparam result [Google::Datastore::V1::RunQueryResponse]
|
281
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
263
282
|
# @return [Google::Datastore::V1::RunQueryResponse]
|
264
283
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
265
284
|
# @example
|
266
|
-
# require "google/cloud/datastore
|
285
|
+
# require "google/cloud/datastore"
|
286
|
+
#
|
287
|
+
# datastore_client = Google::Cloud::Datastore.new(version: :v1)
|
267
288
|
#
|
268
|
-
#
|
289
|
+
# # TODO: Initialize +project_id+:
|
269
290
|
# project_id = ''
|
291
|
+
#
|
292
|
+
# # TODO: Initialize +partition_id+:
|
270
293
|
# partition_id = {}
|
271
294
|
# response = datastore_client.run_query(project_id, partition_id)
|
272
295
|
|
@@ -276,7 +299,8 @@ module Google
|
|
276
299
|
read_options: nil,
|
277
300
|
query: nil,
|
278
301
|
gql_query: nil,
|
279
|
-
options: nil
|
302
|
+
options: nil,
|
303
|
+
&block
|
280
304
|
req = {
|
281
305
|
project_id: project_id,
|
282
306
|
partition_id: partition_id,
|
@@ -285,7 +309,7 @@ module Google
|
|
285
309
|
gql_query: gql_query
|
286
310
|
}.delete_if { |_, v| v.nil? }
|
287
311
|
req = Google::Gax::to_proto(req, Google::Datastore::V1::RunQueryRequest)
|
288
|
-
@run_query.call(req, options)
|
312
|
+
@run_query.call(req, options, &block)
|
289
313
|
end
|
290
314
|
|
291
315
|
# Begins a new transaction.
|
@@ -299,25 +323,31 @@ module Google
|
|
299
323
|
# @param options [Google::Gax::CallOptions]
|
300
324
|
# Overrides the default settings for this call, e.g, timeout,
|
301
325
|
# retries, etc.
|
326
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
327
|
+
# @yieldparam result [Google::Datastore::V1::BeginTransactionResponse]
|
328
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
302
329
|
# @return [Google::Datastore::V1::BeginTransactionResponse]
|
303
330
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
304
331
|
# @example
|
305
|
-
# require "google/cloud/datastore
|
332
|
+
# require "google/cloud/datastore"
|
333
|
+
#
|
334
|
+
# datastore_client = Google::Cloud::Datastore.new(version: :v1)
|
306
335
|
#
|
307
|
-
#
|
336
|
+
# # TODO: Initialize +project_id+:
|
308
337
|
# project_id = ''
|
309
338
|
# response = datastore_client.begin_transaction(project_id)
|
310
339
|
|
311
340
|
def begin_transaction \
|
312
341
|
project_id,
|
313
342
|
transaction_options: nil,
|
314
|
-
options: nil
|
343
|
+
options: nil,
|
344
|
+
&block
|
315
345
|
req = {
|
316
346
|
project_id: project_id,
|
317
347
|
transaction_options: transaction_options
|
318
348
|
}.delete_if { |_, v| v.nil? }
|
319
349
|
req = Google::Gax::to_proto(req, Google::Datastore::V1::BeginTransactionRequest)
|
320
|
-
@begin_transaction.call(req, options)
|
350
|
+
@begin_transaction.call(req, options, &block)
|
321
351
|
end
|
322
352
|
|
323
353
|
# Commits a transaction, optionally creating, deleting or modifying some
|
@@ -350,14 +380,23 @@ module Google
|
|
350
380
|
# @param options [Google::Gax::CallOptions]
|
351
381
|
# Overrides the default settings for this call, e.g, timeout,
|
352
382
|
# retries, etc.
|
383
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
384
|
+
# @yieldparam result [Google::Datastore::V1::CommitResponse]
|
385
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
353
386
|
# @return [Google::Datastore::V1::CommitResponse]
|
354
387
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
355
388
|
# @example
|
356
|
-
# require "google/cloud/datastore
|
389
|
+
# require "google/cloud/datastore"
|
390
|
+
#
|
391
|
+
# datastore_client = Google::Cloud::Datastore.new(version: :v1)
|
357
392
|
#
|
358
|
-
#
|
393
|
+
# # TODO: Initialize +project_id+:
|
359
394
|
# project_id = ''
|
395
|
+
#
|
396
|
+
# # TODO: Initialize +mode+:
|
360
397
|
# mode = :MODE_UNSPECIFIED
|
398
|
+
#
|
399
|
+
# # TODO: Initialize +mutations+:
|
361
400
|
# mutations = []
|
362
401
|
# response = datastore_client.commit(project_id, mode, mutations)
|
363
402
|
|
@@ -366,7 +405,8 @@ module Google
|
|
366
405
|
mode,
|
367
406
|
mutations,
|
368
407
|
transaction: nil,
|
369
|
-
options: nil
|
408
|
+
options: nil,
|
409
|
+
&block
|
370
410
|
req = {
|
371
411
|
project_id: project_id,
|
372
412
|
mode: mode,
|
@@ -374,7 +414,7 @@ module Google
|
|
374
414
|
transaction: transaction
|
375
415
|
}.delete_if { |_, v| v.nil? }
|
376
416
|
req = Google::Gax::to_proto(req, Google::Datastore::V1::CommitRequest)
|
377
|
-
@commit.call(req, options)
|
417
|
+
@commit.call(req, options, &block)
|
378
418
|
end
|
379
419
|
|
380
420
|
# Rolls back a transaction.
|
@@ -387,26 +427,34 @@ module Google
|
|
387
427
|
# @param options [Google::Gax::CallOptions]
|
388
428
|
# Overrides the default settings for this call, e.g, timeout,
|
389
429
|
# retries, etc.
|
430
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
431
|
+
# @yieldparam result [Google::Datastore::V1::RollbackResponse]
|
432
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
390
433
|
# @return [Google::Datastore::V1::RollbackResponse]
|
391
434
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
392
435
|
# @example
|
393
|
-
# require "google/cloud/datastore
|
436
|
+
# require "google/cloud/datastore"
|
437
|
+
#
|
438
|
+
# datastore_client = Google::Cloud::Datastore.new(version: :v1)
|
394
439
|
#
|
395
|
-
#
|
440
|
+
# # TODO: Initialize +project_id+:
|
396
441
|
# project_id = ''
|
442
|
+
#
|
443
|
+
# # TODO: Initialize +transaction+:
|
397
444
|
# transaction = ''
|
398
445
|
# response = datastore_client.rollback(project_id, transaction)
|
399
446
|
|
400
447
|
def rollback \
|
401
448
|
project_id,
|
402
449
|
transaction,
|
403
|
-
options: nil
|
450
|
+
options: nil,
|
451
|
+
&block
|
404
452
|
req = {
|
405
453
|
project_id: project_id,
|
406
454
|
transaction: transaction
|
407
455
|
}.delete_if { |_, v| v.nil? }
|
408
456
|
req = Google::Gax::to_proto(req, Google::Datastore::V1::RollbackRequest)
|
409
|
-
@rollback.call(req, options)
|
457
|
+
@rollback.call(req, options, &block)
|
410
458
|
end
|
411
459
|
|
412
460
|
# Allocates IDs for the given keys, which is useful for referencing an entity
|
@@ -422,26 +470,34 @@ module Google
|
|
422
470
|
# @param options [Google::Gax::CallOptions]
|
423
471
|
# Overrides the default settings for this call, e.g, timeout,
|
424
472
|
# retries, etc.
|
473
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
474
|
+
# @yieldparam result [Google::Datastore::V1::AllocateIdsResponse]
|
475
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
425
476
|
# @return [Google::Datastore::V1::AllocateIdsResponse]
|
426
477
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
427
478
|
# @example
|
428
|
-
# require "google/cloud/datastore
|
479
|
+
# require "google/cloud/datastore"
|
480
|
+
#
|
481
|
+
# datastore_client = Google::Cloud::Datastore.new(version: :v1)
|
429
482
|
#
|
430
|
-
#
|
483
|
+
# # TODO: Initialize +project_id+:
|
431
484
|
# project_id = ''
|
485
|
+
#
|
486
|
+
# # TODO: Initialize +keys+:
|
432
487
|
# keys = []
|
433
488
|
# response = datastore_client.allocate_ids(project_id, keys)
|
434
489
|
|
435
490
|
def allocate_ids \
|
436
491
|
project_id,
|
437
492
|
keys,
|
438
|
-
options: nil
|
493
|
+
options: nil,
|
494
|
+
&block
|
439
495
|
req = {
|
440
496
|
project_id: project_id,
|
441
497
|
keys: keys
|
442
498
|
}.delete_if { |_, v| v.nil? }
|
443
499
|
req = Google::Gax::to_proto(req, Google::Datastore::V1::AllocateIdsRequest)
|
444
|
-
@allocate_ids.call(req, options)
|
500
|
+
@allocate_ids.call(req, options, &block)
|
445
501
|
end
|
446
502
|
|
447
503
|
# Prevents the supplied keys' IDs from being auto-allocated by Cloud
|
@@ -459,13 +515,20 @@ module Google
|
|
459
515
|
# @param options [Google::Gax::CallOptions]
|
460
516
|
# Overrides the default settings for this call, e.g, timeout,
|
461
517
|
# retries, etc.
|
518
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
519
|
+
# @yieldparam result [Google::Datastore::V1::ReserveIdsResponse]
|
520
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
462
521
|
# @return [Google::Datastore::V1::ReserveIdsResponse]
|
463
522
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
464
523
|
# @example
|
465
|
-
# require "google/cloud/datastore
|
524
|
+
# require "google/cloud/datastore"
|
466
525
|
#
|
467
|
-
# datastore_client = Google::Cloud::Datastore
|
526
|
+
# datastore_client = Google::Cloud::Datastore.new(version: :v1)
|
527
|
+
#
|
528
|
+
# # TODO: Initialize +project_id+:
|
468
529
|
# project_id = ''
|
530
|
+
#
|
531
|
+
# # TODO: Initialize +keys+:
|
469
532
|
# keys = []
|
470
533
|
# response = datastore_client.reserve_ids(project_id, keys)
|
471
534
|
|
@@ -473,14 +536,15 @@ module Google
|
|
473
536
|
project_id,
|
474
537
|
keys,
|
475
538
|
database_id: nil,
|
476
|
-
options: nil
|
539
|
+
options: nil,
|
540
|
+
&block
|
477
541
|
req = {
|
478
542
|
project_id: project_id,
|
479
543
|
keys: keys,
|
480
544
|
database_id: database_id
|
481
545
|
}.delete_if { |_, v| v.nil? }
|
482
546
|
req = Google::Gax::to_proto(req, Google::Datastore::V1::ReserveIdsRequest)
|
483
|
-
@reserve_ids.call(req, options)
|
547
|
+
@reserve_ids.call(req, options, &block)
|
484
548
|
end
|
485
549
|
end
|
486
550
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2018 Google LLC
|
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.
|
@@ -14,17 +14,6 @@
|
|
14
14
|
|
15
15
|
module Google
|
16
16
|
module Datastore
|
17
|
-
##
|
18
|
-
# # Google Cloud Datastore API Contents
|
19
|
-
#
|
20
|
-
# | Class | Description |
|
21
|
-
# | ----- | ----------- |
|
22
|
-
# | [DatastoreClient][] | Accesses the schemaless NoSQL database to provide fully managed, robust, scalable storage for your application. |
|
23
|
-
# | [Data Types][] | Data types for Google::Cloud::Datastore::V1 |
|
24
|
-
#
|
25
|
-
# [DatastoreClient]: https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-datastore/latest/google/datastore/v1/datastoreclient
|
26
|
-
# [Data Types]: https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-datastore/latest/google/datastore/v1/datatypes
|
27
|
-
#
|
28
17
|
module V1
|
29
18
|
# The request for {Google::Datastore::V1::Datastore::Lookup Datastore::Lookup}.
|
30
19
|
# @!attribute [rw] project_id
|
@@ -1,13 +1,13 @@
|
|
1
1
|
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
2
|
# Source: google/datastore/v1/datastore.proto for package 'google.datastore.v1'
|
3
3
|
# Original file comments:
|
4
|
-
# Copyright
|
4
|
+
# Copyright 2018 Google Inc.
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
7
|
# you may not use this file except in compliance with the License.
|
8
8
|
# You may obtain a copy of the License at
|
9
9
|
#
|
10
|
-
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
11
|
#
|
12
12
|
# Unless required by applicable law or agreed to in writing, software
|
13
13
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
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.
|
4
|
+
version: 1.4.1
|
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-
|
12
|
+
date: 2018-08-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: google-cloud-core
|
@@ -123,6 +123,20 @@ dependencies:
|
|
123
123
|
- - "~>"
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: '1.1'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: redcarpet
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - "~>"
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '3.0'
|
133
|
+
type: :development
|
134
|
+
prerelease: false
|
135
|
+
version_requirements: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - "~>"
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '3.0'
|
126
140
|
- !ruby/object:Gem::Dependency
|
127
141
|
name: rubocop
|
128
142
|
requirement: !ruby/object:Gem::Requirement
|
@@ -209,13 +223,13 @@ files:
|
|
209
223
|
- lib/google/cloud/datastore/service.rb
|
210
224
|
- lib/google/cloud/datastore/transaction.rb
|
211
225
|
- lib/google/cloud/datastore/v1.rb
|
226
|
+
- lib/google/cloud/datastore/v1/credentials.rb
|
212
227
|
- lib/google/cloud/datastore/v1/datastore_client.rb
|
213
228
|
- lib/google/cloud/datastore/v1/datastore_client_config.json
|
214
229
|
- lib/google/cloud/datastore/v1/doc/google/datastore/v1/datastore.rb
|
215
230
|
- lib/google/cloud/datastore/v1/doc/google/datastore/v1/entity.rb
|
216
231
|
- lib/google/cloud/datastore/v1/doc/google/datastore/v1/query.rb
|
217
232
|
- lib/google/cloud/datastore/v1/doc/google/protobuf/wrappers.rb
|
218
|
-
- lib/google/cloud/datastore/v1/doc/overview.rb
|
219
233
|
- lib/google/cloud/datastore/version.rb
|
220
234
|
- lib/google/datastore/v1/datastore_pb.rb
|
221
235
|
- lib/google/datastore/v1/datastore_services_pb.rb
|
@@ -241,7 +255,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
241
255
|
version: '0'
|
242
256
|
requirements: []
|
243
257
|
rubyforge_project:
|
244
|
-
rubygems_version: 2.7.
|
258
|
+
rubygems_version: 2.7.7
|
245
259
|
signing_key:
|
246
260
|
specification_version: 4
|
247
261
|
summary: API Client library for Google Cloud Datastore
|
@@ -1,54 +0,0 @@
|
|
1
|
-
# Copyright 2017 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
|
-
module Google
|
16
|
-
module Cloud
|
17
|
-
# rubocop:disable LineLength
|
18
|
-
|
19
|
-
##
|
20
|
-
# # Ruby Client for Google Cloud Datastore API ([Alpha](https://github.com/GoogleCloudPlatform/google-cloud-ruby#versioning))
|
21
|
-
#
|
22
|
-
# [Google Cloud Datastore API][Product Documentation]:
|
23
|
-
# Accesses the schemaless NoSQL database to provide fully managed, robust,
|
24
|
-
# scalable storage for your application.
|
25
|
-
# - [Product Documentation][]
|
26
|
-
#
|
27
|
-
# ## Quick Start
|
28
|
-
# In order to use this library, you first need to go through the following
|
29
|
-
# steps:
|
30
|
-
#
|
31
|
-
# 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
|
32
|
-
# 2. [Enable the Google Cloud Datastore API.](https://console.cloud.google.com/apis/api/datastore)
|
33
|
-
# 3. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication)
|
34
|
-
#
|
35
|
-
# ### Installation
|
36
|
-
# ```
|
37
|
-
# $ gem install google-cloud-datastore
|
38
|
-
# ```
|
39
|
-
#
|
40
|
-
# ### Next Steps
|
41
|
-
# - Read the [Google Cloud Datastore API Product documentation][Product Documentation]
|
42
|
-
# to learn more about the product and see How-to Guides.
|
43
|
-
# - View this [repository's main README](https://github.com/GoogleCloudPlatform/google-cloud-ruby/blob/master/README.md)
|
44
|
-
# to see the full list of Cloud APIs that we cover.
|
45
|
-
#
|
46
|
-
# [Product Documentation]: https://cloud.google.com/datastore
|
47
|
-
#
|
48
|
-
#
|
49
|
-
module Datastore
|
50
|
-
module V1
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|