google-cloud-datastore-admin-v1 0.7.1 → 0.8.0

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