google-cloud-datastore-admin-v1 0.1.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.
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ # This gem does not autoload during Bundler.require. To load this gem,
20
+ # issue explicit require statements for the packages desired, e.g.:
21
+ # require "google/cloud/datastore/admin/v1"
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "google/cloud/datastore/admin/v1/datastore_admin"
20
+ require "google/cloud/datastore/admin/v1/version"
21
+
22
+ module Google
23
+ module Cloud
24
+ module Datastore
25
+ module Admin
26
+ ##
27
+ # To load this package, including all its services, and instantiate a client:
28
+ #
29
+ # require "google/cloud/datastore/admin/v1"
30
+ # client = ::Google::Cloud::Datastore::Admin::V1::DatastoreAdmin::Client.new
31
+ #
32
+ module V1
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,111 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "gapic/common"
20
+ require "gapic/config"
21
+ require "gapic/config/method"
22
+
23
+ require "google/cloud/datastore/admin/v1/version"
24
+
25
+ require "google/cloud/datastore/admin/v1/datastore_admin/credentials"
26
+ require "google/cloud/datastore/admin/v1/datastore_admin/operations"
27
+ require "google/cloud/datastore/admin/v1/datastore_admin/client"
28
+
29
+ module Google
30
+ module Cloud
31
+ module Datastore
32
+ module Admin
33
+ module V1
34
+ ##
35
+ # Google Cloud Datastore Admin API
36
+ #
37
+ #
38
+ # The Datastore Admin API provides several admin services for Cloud Datastore.
39
+ #
40
+ # -----------------------------------------------------------------------------
41
+ # ## Concepts
42
+ #
43
+ # Project, namespace, kind, and entity as defined in the Google Cloud Datastore
44
+ # API.
45
+ #
46
+ # Operation: An Operation represents work being performed in the background.
47
+ #
48
+ # EntityFilter: Allows specifying a subset of entities in a project. This is
49
+ # specified as a combination of kinds and namespaces (either or both of which
50
+ # may be all).
51
+ #
52
+ # -----------------------------------------------------------------------------
53
+ # ## Services
54
+ #
55
+ # # Export/Import
56
+ #
57
+ # The Export/Import service provides the ability to copy all or a subset of
58
+ # entities to/from Google Cloud Storage.
59
+ #
60
+ # Exported data may be imported into Cloud Datastore for any Google Cloud
61
+ # Platform project. It is not restricted to the export source project. It is
62
+ # possible to export from one project and then import into another.
63
+ #
64
+ # Exported data can also be loaded into Google BigQuery for analysis.
65
+ #
66
+ # Exports and imports are performed asynchronously. An Operation resource is
67
+ # created for each export/import. The state (including any errors encountered)
68
+ # of the export/import may be queried via the Operation resource.
69
+ #
70
+ # # Index
71
+ #
72
+ # The index service manages Cloud Datastore composite indexes.
73
+ #
74
+ # Index creation and deletion are performed asynchronously.
75
+ # An Operation resource is created for each such asynchronous operation.
76
+ # The state of the operation (including any errors encountered)
77
+ # may be queried via the Operation resource.
78
+ #
79
+ # # Operation
80
+ #
81
+ # The Operations collection provides a record of actions performed for the
82
+ # specified project (including any operations in progress). Operations are not
83
+ # created directly but through calls on other collections or resources.
84
+ #
85
+ # An operation that is not yet done may be cancelled. The request to cancel is
86
+ # asynchronous and the operation may continue to run for some time after the
87
+ # request to cancel is made.
88
+ #
89
+ # An operation that is done may be deleted so that it is no longer listed as
90
+ # part of the Operation collection.
91
+ #
92
+ # ListOperations returns all pending operations, but not completed operations.
93
+ #
94
+ # Operations are created by service DatastoreAdmin,
95
+ # but are accessed via service google.longrunning.Operations.
96
+ #
97
+ # To load this service and instantiate a client:
98
+ #
99
+ # require "google/cloud/datastore/admin/v1/datastore_admin"
100
+ # client = ::Google::Cloud::Datastore::Admin::V1::DatastoreAdmin::Client.new
101
+ #
102
+ module DatastoreAdmin
103
+ end
104
+ end
105
+ end
106
+ end
107
+ end
108
+ end
109
+
110
+ helper_path = ::File.join __dir__, "datastore_admin", "helpers.rb"
111
+ require "google/cloud/datastore/admin/v1/datastore_admin/helpers" if ::File.file? helper_path
@@ -0,0 +1,749 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "google/cloud/errors"
20
+ require "google/datastore/admin/v1/datastore_admin_pb"
21
+
22
+ module Google
23
+ module Cloud
24
+ module Datastore
25
+ module Admin
26
+ module V1
27
+ module DatastoreAdmin
28
+ ##
29
+ # Client for the DatastoreAdmin service.
30
+ #
31
+ # Google Cloud Datastore Admin API
32
+ #
33
+ #
34
+ # The Datastore Admin API provides several admin services for Cloud Datastore.
35
+ #
36
+ # -----------------------------------------------------------------------------
37
+ # ## Concepts
38
+ #
39
+ # Project, namespace, kind, and entity as defined in the Google Cloud Datastore
40
+ # API.
41
+ #
42
+ # Operation: An Operation represents work being performed in the background.
43
+ #
44
+ # EntityFilter: Allows specifying a subset of entities in a project. This is
45
+ # specified as a combination of kinds and namespaces (either or both of which
46
+ # may be all).
47
+ #
48
+ # -----------------------------------------------------------------------------
49
+ # ## Services
50
+ #
51
+ # # Export/Import
52
+ #
53
+ # The Export/Import service provides the ability to copy all or a subset of
54
+ # entities to/from Google Cloud Storage.
55
+ #
56
+ # Exported data may be imported into Cloud Datastore for any Google Cloud
57
+ # Platform project. It is not restricted to the export source project. It is
58
+ # possible to export from one project and then import into another.
59
+ #
60
+ # Exported data can also be loaded into Google BigQuery for analysis.
61
+ #
62
+ # Exports and imports are performed asynchronously. An Operation resource is
63
+ # created for each export/import. The state (including any errors encountered)
64
+ # of the export/import may be queried via the Operation resource.
65
+ #
66
+ # # Index
67
+ #
68
+ # The index service manages Cloud Datastore composite indexes.
69
+ #
70
+ # Index creation and deletion are performed asynchronously.
71
+ # An Operation resource is created for each such asynchronous operation.
72
+ # The state of the operation (including any errors encountered)
73
+ # may be queried via the Operation resource.
74
+ #
75
+ # # Operation
76
+ #
77
+ # The Operations collection provides a record of actions performed for the
78
+ # specified project (including any operations in progress). Operations are not
79
+ # created directly but through calls on other collections or resources.
80
+ #
81
+ # An operation that is not yet done may be cancelled. The request to cancel is
82
+ # asynchronous and the operation may continue to run for some time after the
83
+ # request to cancel is made.
84
+ #
85
+ # An operation that is done may be deleted so that it is no longer listed as
86
+ # part of the Operation collection.
87
+ #
88
+ # ListOperations returns all pending operations, but not completed operations.
89
+ #
90
+ # Operations are created by service DatastoreAdmin,
91
+ # but are accessed via service google.longrunning.Operations.
92
+ #
93
+ class Client
94
+ # @private
95
+ attr_reader :datastore_admin_stub
96
+
97
+ ##
98
+ # Configure the DatastoreAdmin Client class.
99
+ #
100
+ # See {::Google::Cloud::Datastore::Admin::V1::DatastoreAdmin::Client::Configuration}
101
+ # for a description of the configuration fields.
102
+ #
103
+ # ## Example
104
+ #
105
+ # To modify the configuration for all DatastoreAdmin clients:
106
+ #
107
+ # ::Google::Cloud::Datastore::Admin::V1::DatastoreAdmin::Client.configure do |config|
108
+ # config.timeout = 10.0
109
+ # end
110
+ #
111
+ # @yield [config] Configure the Client client.
112
+ # @yieldparam config [Client::Configuration]
113
+ #
114
+ # @return [Client::Configuration]
115
+ #
116
+ def self.configure
117
+ @configure ||= begin
118
+ namespace = ["Google", "Cloud", "Datastore", "Admin", "V1"]
119
+ parent_config = while namespace.any?
120
+ parent_name = namespace.join "::"
121
+ parent_const = const_get parent_name
122
+ break parent_const.configure if parent_const&.respond_to? :configure
123
+ namespace.pop
124
+ end
125
+ default_config = Client::Configuration.new parent_config
126
+
127
+ default_config.rpcs.export_entities.timeout = 60.0
128
+
129
+ default_config.rpcs.import_entities.timeout = 60.0
130
+
131
+ default_config.rpcs.get_index.timeout = 60.0
132
+ default_config.rpcs.get_index.retry_policy = {
133
+ initial_delay: 0.1,
134
+ max_delay: 60.0,
135
+ multiplier: 1.3,
136
+ retry_codes: [14, 4]
137
+ }
138
+
139
+ default_config.rpcs.list_indexes.timeout = 60.0
140
+ default_config.rpcs.list_indexes.retry_policy = {
141
+ initial_delay: 0.1,
142
+ max_delay: 60.0,
143
+ multiplier: 1.3,
144
+ retry_codes: [14, 4]
145
+ }
146
+
147
+ default_config
148
+ end
149
+ yield @configure if block_given?
150
+ @configure
151
+ end
152
+
153
+ ##
154
+ # Configure the DatastoreAdmin Client instance.
155
+ #
156
+ # The configuration is set to the derived mode, meaning that values can be changed,
157
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
158
+ # should be made on {Client.configure}.
159
+ #
160
+ # See {::Google::Cloud::Datastore::Admin::V1::DatastoreAdmin::Client::Configuration}
161
+ # for a description of the configuration fields.
162
+ #
163
+ # @yield [config] Configure the Client client.
164
+ # @yieldparam config [Client::Configuration]
165
+ #
166
+ # @return [Client::Configuration]
167
+ #
168
+ def configure
169
+ yield @config if block_given?
170
+ @config
171
+ end
172
+
173
+ ##
174
+ # Create a new DatastoreAdmin client object.
175
+ #
176
+ # ## Examples
177
+ #
178
+ # To create a new DatastoreAdmin client with the default
179
+ # configuration:
180
+ #
181
+ # client = ::Google::Cloud::Datastore::Admin::V1::DatastoreAdmin::Client.new
182
+ #
183
+ # To create a new DatastoreAdmin client with a custom
184
+ # configuration:
185
+ #
186
+ # client = ::Google::Cloud::Datastore::Admin::V1::DatastoreAdmin::Client.new do |config|
187
+ # config.timeout = 10.0
188
+ # end
189
+ #
190
+ # @yield [config] Configure the DatastoreAdmin client.
191
+ # @yieldparam config [Client::Configuration]
192
+ #
193
+ def initialize
194
+ # These require statements are intentionally placed here to initialize
195
+ # the gRPC module only when it's required.
196
+ # See https://github.com/googleapis/toolkit/issues/446
197
+ require "gapic/grpc"
198
+ require "google/datastore/admin/v1/datastore_admin_services_pb"
199
+
200
+ # Create the configuration object
201
+ @config = Configuration.new Client.configure
202
+
203
+ # Yield the configuration if needed
204
+ yield @config if block_given?
205
+
206
+ # Create credentials
207
+ credentials = @config.credentials
208
+ credentials ||= Credentials.default scope: @config.scope
209
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
210
+ credentials = Credentials.new credentials, scope: @config.scope
211
+ end
212
+ @quota_project_id = @config.quota_project
213
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
214
+
215
+ @operations_client = Operations.new do |config|
216
+ config.credentials = credentials
217
+ config.endpoint = @config.endpoint
218
+ end
219
+
220
+ @datastore_admin_stub = ::Gapic::ServiceStub.new(
221
+ ::Google::Cloud::Datastore::Admin::V1::DatastoreAdmin::Stub,
222
+ credentials: credentials,
223
+ endpoint: @config.endpoint,
224
+ channel_args: @config.channel_args,
225
+ interceptors: @config.interceptors
226
+ )
227
+ end
228
+
229
+ ##
230
+ # Get the associated client for long-running operations.
231
+ #
232
+ # @return [::Google::Cloud::Datastore::Admin::V1::DatastoreAdmin::Operations]
233
+ #
234
+ attr_reader :operations_client
235
+
236
+ # Service calls
237
+
238
+ ##
239
+ # Exports a copy of all or a subset of entities from Google Cloud Datastore
240
+ # to another storage system, such as Google Cloud Storage. Recent updates to
241
+ # entities may not be reflected in the export. The export occurs in the
242
+ # background and its progress can be monitored and managed via the
243
+ # Operation resource that is created. The output of an export may only be
244
+ # used once the associated operation is done. If an export operation is
245
+ # cancelled before completion it may leave partial data behind in Google
246
+ # Cloud Storage.
247
+ #
248
+ # @overload export_entities(request, options = nil)
249
+ # Pass arguments to `export_entities` via a request object, either of type
250
+ # {::Google::Cloud::Datastore::Admin::V1::ExportEntitiesRequest} or an equivalent Hash.
251
+ #
252
+ # @param request [::Google::Cloud::Datastore::Admin::V1::ExportEntitiesRequest, ::Hash]
253
+ # A request object representing the call parameters. Required. To specify no
254
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
255
+ # @param options [::Gapic::CallOptions, ::Hash]
256
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
257
+ #
258
+ # @overload export_entities(project_id: nil, labels: nil, entity_filter: nil, output_url_prefix: nil)
259
+ # Pass arguments to `export_entities` via keyword arguments. Note that at
260
+ # least one keyword argument is required. To specify no parameters, or to keep all
261
+ # the default parameter values, pass an empty Hash as a request object (see above).
262
+ #
263
+ # @param project_id [::String]
264
+ # Required. Project ID against which to make the request.
265
+ # @param labels [::Hash{::String => ::String}]
266
+ # Client-assigned labels.
267
+ # @param entity_filter [::Google::Cloud::Datastore::Admin::V1::EntityFilter, ::Hash]
268
+ # Description of what data from the project is included in the export.
269
+ # @param output_url_prefix [::String]
270
+ # Required. Location for the export metadata and data files.
271
+ #
272
+ # The full resource URL of the external storage location. Currently, only
273
+ # Google Cloud Storage is supported. So output_url_prefix should be of the
274
+ # form: `gs://BUCKET_NAME[/NAMESPACE_PATH]`, where `BUCKET_NAME` is the
275
+ # name of the Cloud Storage bucket and `NAMESPACE_PATH` is an optional Cloud
276
+ # Storage namespace path (this is not a Cloud Datastore namespace). For more
277
+ # information about Cloud Storage namespace paths, see
278
+ # [Object name
279
+ # considerations](https://cloud.google.com/storage/docs/naming#object-considerations).
280
+ #
281
+ # The resulting files will be nested deeper than the specified URL prefix.
282
+ # The final output URL will be provided in the
283
+ # {::Google::Cloud::Datastore::Admin::V1::ExportEntitiesResponse#output_url google.datastore.admin.v1.ExportEntitiesResponse.output_url} field. That
284
+ # value should be used for subsequent ImportEntities operations.
285
+ #
286
+ # By nesting the data files deeper, the same Cloud Storage bucket can be used
287
+ # in multiple ExportEntities operations without conflict.
288
+ #
289
+ # @yield [response, operation] Access the result along with the RPC operation
290
+ # @yieldparam response [::Gapic::Operation]
291
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
292
+ #
293
+ # @return [::Gapic::Operation]
294
+ #
295
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
296
+ #
297
+ def export_entities request, options = nil
298
+ raise ::ArgumentError, "request must be provided" if request.nil?
299
+
300
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Datastore::Admin::V1::ExportEntitiesRequest
301
+
302
+ # Converts hash and nil to an options object
303
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
304
+
305
+ # Customize the options with defaults
306
+ metadata = @config.rpcs.export_entities.metadata.to_h
307
+
308
+ # Set x-goog-api-client and x-goog-user-project headers
309
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
310
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
311
+ gapic_version: ::Google::Cloud::Datastore::Admin::V1::VERSION
312
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
313
+
314
+ header_params = {
315
+ "project_id" => request.project_id
316
+ }
317
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
318
+ metadata[:"x-goog-request-params"] ||= request_params_header
319
+
320
+ options.apply_defaults timeout: @config.rpcs.export_entities.timeout,
321
+ metadata: metadata,
322
+ retry_policy: @config.rpcs.export_entities.retry_policy
323
+ options.apply_defaults metadata: @config.metadata,
324
+ retry_policy: @config.retry_policy
325
+
326
+ @datastore_admin_stub.call_rpc :export_entities, request, options: options do |response, operation|
327
+ response = ::Gapic::Operation.new response, @operations_client, options: options
328
+ yield response, operation if block_given?
329
+ return response
330
+ end
331
+ rescue ::GRPC::BadStatus => e
332
+ raise ::Google::Cloud::Error.from_error(e)
333
+ end
334
+
335
+ ##
336
+ # Imports entities into Google Cloud Datastore. Existing entities with the
337
+ # same key are overwritten. The import occurs in the background and its
338
+ # progress can be monitored and managed via the Operation resource that is
339
+ # created. If an ImportEntities operation is cancelled, it is possible
340
+ # that a subset of the data has already been imported to Cloud Datastore.
341
+ #
342
+ # @overload import_entities(request, options = nil)
343
+ # Pass arguments to `import_entities` via a request object, either of type
344
+ # {::Google::Cloud::Datastore::Admin::V1::ImportEntitiesRequest} or an equivalent Hash.
345
+ #
346
+ # @param request [::Google::Cloud::Datastore::Admin::V1::ImportEntitiesRequest, ::Hash]
347
+ # A request object representing the call parameters. Required. To specify no
348
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
349
+ # @param options [::Gapic::CallOptions, ::Hash]
350
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
351
+ #
352
+ # @overload import_entities(project_id: nil, labels: nil, input_url: nil, entity_filter: nil)
353
+ # Pass arguments to `import_entities` via keyword arguments. Note that at
354
+ # least one keyword argument is required. To specify no parameters, or to keep all
355
+ # the default parameter values, pass an empty Hash as a request object (see above).
356
+ #
357
+ # @param project_id [::String]
358
+ # Required. Project ID against which to make the request.
359
+ # @param labels [::Hash{::String => ::String}]
360
+ # Client-assigned labels.
361
+ # @param input_url [::String]
362
+ # Required. The full resource URL of the external storage location. Currently, only
363
+ # Google Cloud Storage is supported. So input_url should be of the form:
364
+ # `gs://BUCKET_NAME[/NAMESPACE_PATH]/OVERALL_EXPORT_METADATA_FILE`, where
365
+ # `BUCKET_NAME` is the name of the Cloud Storage bucket, `NAMESPACE_PATH` is
366
+ # an optional Cloud Storage namespace path (this is not a Cloud Datastore
367
+ # namespace), and `OVERALL_EXPORT_METADATA_FILE` is the metadata file written
368
+ # by the ExportEntities operation. For more information about Cloud Storage
369
+ # namespace paths, see
370
+ # [Object name
371
+ # considerations](https://cloud.google.com/storage/docs/naming#object-considerations).
372
+ #
373
+ # For more information, see
374
+ # {::Google::Cloud::Datastore::Admin::V1::ExportEntitiesResponse#output_url google.datastore.admin.v1.ExportEntitiesResponse.output_url}.
375
+ # @param entity_filter [::Google::Cloud::Datastore::Admin::V1::EntityFilter, ::Hash]
376
+ # Optionally specify which kinds/namespaces are to be imported. If provided,
377
+ # the list must be a subset of the EntityFilter used in creating the export,
378
+ # otherwise a FAILED_PRECONDITION error will be returned. If no filter is
379
+ # specified then all entities from the export are imported.
380
+ #
381
+ # @yield [response, operation] Access the result along with the RPC operation
382
+ # @yieldparam response [::Gapic::Operation]
383
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
384
+ #
385
+ # @return [::Gapic::Operation]
386
+ #
387
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
388
+ #
389
+ def import_entities request, options = nil
390
+ raise ::ArgumentError, "request must be provided" if request.nil?
391
+
392
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Datastore::Admin::V1::ImportEntitiesRequest
393
+
394
+ # Converts hash and nil to an options object
395
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
396
+
397
+ # Customize the options with defaults
398
+ metadata = @config.rpcs.import_entities.metadata.to_h
399
+
400
+ # Set x-goog-api-client and x-goog-user-project headers
401
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
402
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
403
+ gapic_version: ::Google::Cloud::Datastore::Admin::V1::VERSION
404
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
405
+
406
+ header_params = {
407
+ "project_id" => request.project_id
408
+ }
409
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
410
+ metadata[:"x-goog-request-params"] ||= request_params_header
411
+
412
+ options.apply_defaults timeout: @config.rpcs.import_entities.timeout,
413
+ metadata: metadata,
414
+ retry_policy: @config.rpcs.import_entities.retry_policy
415
+ options.apply_defaults metadata: @config.metadata,
416
+ retry_policy: @config.retry_policy
417
+
418
+ @datastore_admin_stub.call_rpc :import_entities, request, options: options do |response, operation|
419
+ response = ::Gapic::Operation.new response, @operations_client, options: options
420
+ yield response, operation if block_given?
421
+ return response
422
+ end
423
+ rescue ::GRPC::BadStatus => e
424
+ raise ::Google::Cloud::Error.from_error(e)
425
+ end
426
+
427
+ ##
428
+ # Gets an index.
429
+ #
430
+ # @overload get_index(request, options = nil)
431
+ # Pass arguments to `get_index` via a request object, either of type
432
+ # {::Google::Cloud::Datastore::Admin::V1::GetIndexRequest} or an equivalent Hash.
433
+ #
434
+ # @param request [::Google::Cloud::Datastore::Admin::V1::GetIndexRequest, ::Hash]
435
+ # A request object representing the call parameters. Required. To specify no
436
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
437
+ # @param options [::Gapic::CallOptions, ::Hash]
438
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
439
+ #
440
+ # @overload get_index(project_id: nil, index_id: nil)
441
+ # Pass arguments to `get_index` via keyword arguments. Note that at
442
+ # least one keyword argument is required. To specify no parameters, or to keep all
443
+ # the default parameter values, pass an empty Hash as a request object (see above).
444
+ #
445
+ # @param project_id [::String]
446
+ # Project ID against which to make the request.
447
+ # @param index_id [::String]
448
+ # The resource ID of the index to get.
449
+ #
450
+ # @yield [response, operation] Access the result along with the RPC operation
451
+ # @yieldparam response [::Google::Cloud::Datastore::Admin::V1::Index]
452
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
453
+ #
454
+ # @return [::Google::Cloud::Datastore::Admin::V1::Index]
455
+ #
456
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
457
+ #
458
+ def get_index request, options = nil
459
+ raise ::ArgumentError, "request must be provided" if request.nil?
460
+
461
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Datastore::Admin::V1::GetIndexRequest
462
+
463
+ # Converts hash and nil to an options object
464
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
465
+
466
+ # Customize the options with defaults
467
+ metadata = @config.rpcs.get_index.metadata.to_h
468
+
469
+ # Set x-goog-api-client and x-goog-user-project headers
470
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
471
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
472
+ gapic_version: ::Google::Cloud::Datastore::Admin::V1::VERSION
473
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
474
+
475
+ header_params = {
476
+ "project_id" => request.project_id,
477
+ "index_id" => request.index_id
478
+ }
479
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
480
+ metadata[:"x-goog-request-params"] ||= request_params_header
481
+
482
+ options.apply_defaults timeout: @config.rpcs.get_index.timeout,
483
+ metadata: metadata,
484
+ retry_policy: @config.rpcs.get_index.retry_policy
485
+ options.apply_defaults metadata: @config.metadata,
486
+ retry_policy: @config.retry_policy
487
+
488
+ @datastore_admin_stub.call_rpc :get_index, request, options: options do |response, operation|
489
+ yield response, operation if block_given?
490
+ return response
491
+ end
492
+ rescue ::GRPC::BadStatus => e
493
+ raise ::Google::Cloud::Error.from_error(e)
494
+ end
495
+
496
+ ##
497
+ # Lists the indexes that match the specified filters. Datastore uses an
498
+ # eventually consistent query to fetch the list of indexes and may
499
+ # occasionally return stale results.
500
+ #
501
+ # @overload list_indexes(request, options = nil)
502
+ # Pass arguments to `list_indexes` via a request object, either of type
503
+ # {::Google::Cloud::Datastore::Admin::V1::ListIndexesRequest} or an equivalent Hash.
504
+ #
505
+ # @param request [::Google::Cloud::Datastore::Admin::V1::ListIndexesRequest, ::Hash]
506
+ # A request object representing the call parameters. Required. To specify no
507
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
508
+ # @param options [::Gapic::CallOptions, ::Hash]
509
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
510
+ #
511
+ # @overload list_indexes(project_id: nil, filter: nil, page_size: nil, page_token: nil)
512
+ # Pass arguments to `list_indexes` via keyword arguments. Note that at
513
+ # least one keyword argument is required. To specify no parameters, or to keep all
514
+ # the default parameter values, pass an empty Hash as a request object (see above).
515
+ #
516
+ # @param project_id [::String]
517
+ # Project ID against which to make the request.
518
+ # @param filter [::String]
519
+ # @param page_size [::Integer]
520
+ # The maximum number of items to return. If zero, then all results will be
521
+ # returned.
522
+ # @param page_token [::String]
523
+ # The next_page_token value returned from a previous List request, if any.
524
+ #
525
+ # @yield [response, operation] Access the result along with the RPC operation
526
+ # @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::Datastore::Admin::V1::Index>]
527
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
528
+ #
529
+ # @return [::Gapic::PagedEnumerable<::Google::Cloud::Datastore::Admin::V1::Index>]
530
+ #
531
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
532
+ #
533
+ def list_indexes request, options = nil
534
+ raise ::ArgumentError, "request must be provided" if request.nil?
535
+
536
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Datastore::Admin::V1::ListIndexesRequest
537
+
538
+ # Converts hash and nil to an options object
539
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
540
+
541
+ # Customize the options with defaults
542
+ metadata = @config.rpcs.list_indexes.metadata.to_h
543
+
544
+ # Set x-goog-api-client and x-goog-user-project headers
545
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
546
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
547
+ gapic_version: ::Google::Cloud::Datastore::Admin::V1::VERSION
548
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
549
+
550
+ header_params = {
551
+ "project_id" => request.project_id
552
+ }
553
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
554
+ metadata[:"x-goog-request-params"] ||= request_params_header
555
+
556
+ options.apply_defaults timeout: @config.rpcs.list_indexes.timeout,
557
+ metadata: metadata,
558
+ retry_policy: @config.rpcs.list_indexes.retry_policy
559
+ options.apply_defaults metadata: @config.metadata,
560
+ retry_policy: @config.retry_policy
561
+
562
+ @datastore_admin_stub.call_rpc :list_indexes, request, options: options do |response, operation|
563
+ response = ::Gapic::PagedEnumerable.new @datastore_admin_stub, :list_indexes, request, response, operation, options
564
+ yield response, operation if block_given?
565
+ return response
566
+ end
567
+ rescue ::GRPC::BadStatus => e
568
+ raise ::Google::Cloud::Error.from_error(e)
569
+ end
570
+
571
+ ##
572
+ # Configuration class for the DatastoreAdmin API.
573
+ #
574
+ # This class represents the configuration for DatastoreAdmin,
575
+ # providing control over timeouts, retry behavior, logging, transport
576
+ # parameters, and other low-level controls. Certain parameters can also be
577
+ # applied individually to specific RPCs. See
578
+ # {::Google::Cloud::Datastore::Admin::V1::DatastoreAdmin::Client::Configuration::Rpcs}
579
+ # for a list of RPCs that can be configured independently.
580
+ #
581
+ # Configuration can be applied globally to all clients, or to a single client
582
+ # on construction.
583
+ #
584
+ # # Examples
585
+ #
586
+ # To modify the global config, setting the timeout for export_entities
587
+ # to 20 seconds, and all remaining timeouts to 10 seconds:
588
+ #
589
+ # ::Google::Cloud::Datastore::Admin::V1::DatastoreAdmin::Client.configure do |config|
590
+ # config.timeout = 10.0
591
+ # config.rpcs.export_entities.timeout = 20.0
592
+ # end
593
+ #
594
+ # To apply the above configuration only to a new client:
595
+ #
596
+ # client = ::Google::Cloud::Datastore::Admin::V1::DatastoreAdmin::Client.new do |config|
597
+ # config.timeout = 10.0
598
+ # config.rpcs.export_entities.timeout = 20.0
599
+ # end
600
+ #
601
+ # @!attribute [rw] endpoint
602
+ # The hostname or hostname:port of the service endpoint.
603
+ # Defaults to `"datastore.googleapis.com"`.
604
+ # @return [::String]
605
+ # @!attribute [rw] credentials
606
+ # Credentials to send with calls. You may provide any of the following types:
607
+ # * (`String`) The path to a service account key file in JSON format
608
+ # * (`Hash`) A service account key as a Hash
609
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
610
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
611
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
612
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
613
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
614
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
615
+ # * (`nil`) indicating no credentials
616
+ # @return [::Object]
617
+ # @!attribute [rw] scope
618
+ # The OAuth scopes
619
+ # @return [::Array<::String>]
620
+ # @!attribute [rw] lib_name
621
+ # The library name as recorded in instrumentation and logging
622
+ # @return [::String]
623
+ # @!attribute [rw] lib_version
624
+ # The library version as recorded in instrumentation and logging
625
+ # @return [::String]
626
+ # @!attribute [rw] channel_args
627
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
628
+ # `GRPC::Core::Channel` object is provided as the credential.
629
+ # @return [::Hash]
630
+ # @!attribute [rw] interceptors
631
+ # An array of interceptors that are run before calls are executed.
632
+ # @return [::Array<::GRPC::ClientInterceptor>]
633
+ # @!attribute [rw] timeout
634
+ # The call timeout in seconds.
635
+ # @return [::Numeric]
636
+ # @!attribute [rw] metadata
637
+ # Additional gRPC headers to be sent with the call.
638
+ # @return [::Hash{::Symbol=>::String}]
639
+ # @!attribute [rw] retry_policy
640
+ # The retry policy. The value is a hash with the following keys:
641
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
642
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
643
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
644
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
645
+ # trigger a retry.
646
+ # @return [::Hash]
647
+ # @!attribute [rw] quota_project
648
+ # A separate project against which to charge quota.
649
+ # @return [::String]
650
+ #
651
+ class Configuration
652
+ extend ::Gapic::Config
653
+
654
+ config_attr :endpoint, "datastore.googleapis.com", ::String
655
+ config_attr :credentials, nil do |value|
656
+ allowed = [::String, ::Hash, ::Proc, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
657
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
658
+ allowed.any? { |klass| klass === value }
659
+ end
660
+ config_attr :scope, nil, ::String, ::Array, nil
661
+ config_attr :lib_name, nil, ::String, nil
662
+ config_attr :lib_version, nil, ::String, nil
663
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, ::Hash, nil)
664
+ config_attr :interceptors, nil, ::Array, nil
665
+ config_attr :timeout, nil, ::Numeric, nil
666
+ config_attr :metadata, nil, ::Hash, nil
667
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
668
+ config_attr :quota_project, nil, ::String, nil
669
+
670
+ # @private
671
+ def initialize parent_config = nil
672
+ @parent_config = parent_config unless parent_config.nil?
673
+
674
+ yield self if block_given?
675
+ end
676
+
677
+ ##
678
+ # Configurations for individual RPCs
679
+ # @return [Rpcs]
680
+ #
681
+ def rpcs
682
+ @rpcs ||= begin
683
+ parent_rpcs = nil
684
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config&.respond_to?(:rpcs)
685
+ Rpcs.new parent_rpcs
686
+ end
687
+ end
688
+
689
+ ##
690
+ # Configuration RPC class for the DatastoreAdmin API.
691
+ #
692
+ # Includes fields providing the configuration for each RPC in this service.
693
+ # Each configuration object is of type `Gapic::Config::Method` and includes
694
+ # the following configuration fields:
695
+ #
696
+ # * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
697
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
698
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
699
+ # include the following keys:
700
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
701
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
702
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
703
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
704
+ # trigger a retry.
705
+ #
706
+ class Rpcs
707
+ ##
708
+ # RPC-specific configuration for `export_entities`
709
+ # @return [::Gapic::Config::Method]
710
+ #
711
+ attr_reader :export_entities
712
+ ##
713
+ # RPC-specific configuration for `import_entities`
714
+ # @return [::Gapic::Config::Method]
715
+ #
716
+ attr_reader :import_entities
717
+ ##
718
+ # RPC-specific configuration for `get_index`
719
+ # @return [::Gapic::Config::Method]
720
+ #
721
+ attr_reader :get_index
722
+ ##
723
+ # RPC-specific configuration for `list_indexes`
724
+ # @return [::Gapic::Config::Method]
725
+ #
726
+ attr_reader :list_indexes
727
+
728
+ # @private
729
+ def initialize parent_rpcs = nil
730
+ export_entities_config = parent_rpcs&.export_entities if parent_rpcs&.respond_to? :export_entities
731
+ @export_entities = ::Gapic::Config::Method.new export_entities_config
732
+ import_entities_config = parent_rpcs&.import_entities if parent_rpcs&.respond_to? :import_entities
733
+ @import_entities = ::Gapic::Config::Method.new import_entities_config
734
+ get_index_config = parent_rpcs&.get_index if parent_rpcs&.respond_to? :get_index
735
+ @get_index = ::Gapic::Config::Method.new get_index_config
736
+ list_indexes_config = parent_rpcs&.list_indexes if parent_rpcs&.respond_to? :list_indexes
737
+ @list_indexes = ::Gapic::Config::Method.new list_indexes_config
738
+
739
+ yield self if block_given?
740
+ end
741
+ end
742
+ end
743
+ end
744
+ end
745
+ end
746
+ end
747
+ end
748
+ end
749
+ end