@google-cloud/datastore-api 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.
Files changed (30) hide show
  1. package/README.md +111 -0
  2. package/build/protos/google/datastore/admin/v1/datastore_admin.proto +506 -0
  3. package/build/protos/google/datastore/admin/v1/index.proto +122 -0
  4. package/build/protos/google/datastore/admin/v1/migration.proto +124 -0
  5. package/build/protos/google/datastore/v1/aggregation_result.proto +62 -0
  6. package/build/protos/google/datastore/v1/datastore.proto +851 -0
  7. package/build/protos/google/datastore/v1/entity.proto +217 -0
  8. package/build/protos/google/datastore/v1/query.proto +622 -0
  9. package/build/protos/google/datastore/v1/query_profile.proto +91 -0
  10. package/build/protos/protos.d.ts +18507 -0
  11. package/build/protos/protos.js +1 -0
  12. package/build/protos/protos.json +1 -0
  13. package/build/src/index.d.ts +14 -0
  14. package/build/src/index.js +30 -0
  15. package/build/src/index.js.map +1 -0
  16. package/build/src/v1/datastore_admin_client.d.ts +631 -0
  17. package/build/src/v1/datastore_admin_client.js +954 -0
  18. package/build/src/v1/datastore_admin_client.js.map +1 -0
  19. package/build/src/v1/datastore_admin_client_config.json +56 -0
  20. package/build/src/v1/datastore_admin_proto_list.json +5 -0
  21. package/build/src/v1/datastore_client.d.ts +451 -0
  22. package/build/src/v1/datastore_client.js +806 -0
  23. package/build/src/v1/datastore_client.js.map +1 -0
  24. package/build/src/v1/datastore_client_config.json +66 -0
  25. package/build/src/v1/datastore_proto_list.json +7 -0
  26. package/build/src/v1/gapic_metadata.json +87 -0
  27. package/build/src/v1/index.d.ts +2 -0
  28. package/build/src/v1/index.js +25 -0
  29. package/build/src/v1/index.js.map +1 -0
  30. package/package.json +65 -0
@@ -0,0 +1,954 @@
1
+ "use strict";
2
+ // Copyright 2026 Google LLC
3
+ //
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // you may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ //
8
+ // https://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+ //
16
+ // ** This file is automatically generated by gapic-generator-typescript. **
17
+ // ** https://github.com/googleapis/gapic-generator-typescript **
18
+ // ** All changes to this file may be overwritten. **
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.DatastoreAdminClient = void 0;
21
+ const jsonProtos = require("../../protos/protos.json");
22
+ const google_gax_1 = require("google-gax");
23
+ /**
24
+ * Client JSON configuration object, loaded from
25
+ * `src/v1/datastore_admin_client_config.json`.
26
+ * This file defines retry strategy and timeouts for all API methods in this library.
27
+ */
28
+ const gapicConfig = require("./datastore_admin_client_config.json");
29
+ const version = require('../../../package.json').version;
30
+ /**
31
+ * Google Cloud Datastore Admin API
32
+ *
33
+ * The Datastore Admin API provides several admin services for Cloud Datastore.
34
+ *
35
+ * Concepts: Project, namespace, kind, and entity as defined in the Google Cloud
36
+ * Datastore API.
37
+ *
38
+ * Operation: An Operation represents work being performed in the background.
39
+ *
40
+ * EntityFilter: Allows specifying a subset of entities in a project. This is
41
+ * specified as a combination of kinds and namespaces (either or both of which
42
+ * may be all).
43
+ *
44
+ * Export/Import Service:
45
+ *
46
+ * - The Export/Import service provides the ability to copy all or a subset of
47
+ * entities to/from Google Cloud Storage.
48
+ * - Exported data may be imported into Cloud Datastore for any Google Cloud
49
+ * Platform project. It is not restricted to the export source project. It is
50
+ * possible to export from one project and then import into another.
51
+ * - Exported data can also be loaded into Google BigQuery for analysis.
52
+ * - Exports and imports are performed asynchronously. An Operation resource is
53
+ * created for each export/import. The state (including any errors encountered)
54
+ * of the export/import may be queried via the Operation resource.
55
+ *
56
+ * Index Service:
57
+ *
58
+ * - The index service manages Cloud Datastore composite indexes.
59
+ * - Index creation and deletion are performed asynchronously.
60
+ * An Operation resource is created for each such asynchronous operation.
61
+ * The state of the operation (including any errors encountered)
62
+ * may be queried via the Operation resource.
63
+ *
64
+ * Operation Service:
65
+ *
66
+ * - The Operations collection provides a record of actions performed for the
67
+ * specified project (including any operations in progress). Operations are not
68
+ * created directly but through calls on other collections or resources.
69
+ * - An operation that is not yet done may be cancelled. The request to cancel
70
+ * is asynchronous and the operation may continue to run for some time after the
71
+ * request to cancel is made.
72
+ * - An operation that is done may be deleted so that it is no longer listed as
73
+ * part of the Operation collection.
74
+ * - ListOperations returns all pending operations, but not completed
75
+ * operations.
76
+ * - Operations are created by service DatastoreAdmin, but are accessed via
77
+ * service google.longrunning.Operations.
78
+ * @class
79
+ * @memberof v1
80
+ */
81
+ class DatastoreAdminClient {
82
+ _terminated = false;
83
+ _opts;
84
+ _providedCustomServicePath;
85
+ _gaxModule;
86
+ _gaxGrpc;
87
+ _protos;
88
+ _defaults;
89
+ _universeDomain;
90
+ _servicePath;
91
+ _log = google_gax_1.loggingUtils.log('datastore-api');
92
+ auth;
93
+ descriptors = {
94
+ page: {},
95
+ stream: {},
96
+ longrunning: {},
97
+ batching: {},
98
+ };
99
+ warn;
100
+ innerApiCalls;
101
+ operationsClient;
102
+ datastoreAdminStub;
103
+ /**
104
+ * Construct an instance of DatastoreAdminClient.
105
+ *
106
+ * @param {object} [options] - The configuration object.
107
+ * The options accepted by the constructor are described in detail
108
+ * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance).
109
+ * The common options are:
110
+ * @param {object} [options.credentials] - Credentials object.
111
+ * @param {string} [options.credentials.client_email]
112
+ * @param {string} [options.credentials.private_key]
113
+ * @param {string} [options.email] - Account email address. Required when
114
+ * using a .pem or .p12 keyFilename.
115
+ * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or
116
+ * .p12 key downloaded from the Google Developers Console. If you provide
117
+ * a path to a JSON file, the projectId option below is not necessary.
118
+ * NOTE: .pem and .p12 require you to specify options.email as well.
119
+ * @param {number} [options.port] - The port on which to connect to
120
+ * the remote host.
121
+ * @param {string} [options.projectId] - The project ID from the Google
122
+ * Developer's Console, e.g. 'grape-spaceship-123'. We will also check
123
+ * the environment variable GCLOUD_PROJECT for your project ID. If your
124
+ * app is running in an environment which supports
125
+ * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials},
126
+ * your project ID will be detected automatically.
127
+ * @param {string} [options.apiEndpoint] - The domain name of the
128
+ * API remote host.
129
+ * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
130
+ * Follows the structure of {@link gapicConfig}.
131
+ * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode.
132
+ * For more information, please check the
133
+ * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
134
+ * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you
135
+ * need to avoid loading the default gRPC version and want to use the fallback
136
+ * HTTP implementation. Load only fallback version and pass it to the constructor:
137
+ * ```
138
+ * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC
139
+ * const client = new DatastoreAdminClient({fallback: true}, gax);
140
+ * ```
141
+ */
142
+ constructor(opts, gaxInstance) {
143
+ // Ensure that options include all the required fields.
144
+ const staticMembers = this.constructor;
145
+ if (opts?.universe_domain &&
146
+ opts?.universeDomain &&
147
+ opts?.universe_domain !== opts?.universeDomain) {
148
+ throw new Error('Please set either universe_domain or universeDomain, but not both.');
149
+ }
150
+ const universeDomainEnvVar = typeof process === 'object' && typeof process.env === 'object'
151
+ ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']
152
+ : undefined;
153
+ this._universeDomain =
154
+ opts?.universeDomain ??
155
+ opts?.universe_domain ??
156
+ universeDomainEnvVar ??
157
+ 'googleapis.com';
158
+ this._servicePath = 'datastore.' + this._universeDomain;
159
+ const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath;
160
+ this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint);
161
+ const port = opts?.port || staticMembers.port;
162
+ const clientConfig = opts?.clientConfig ?? {};
163
+ const fallback = opts?.fallback ??
164
+ (typeof window !== 'undefined' && typeof window?.fetch === 'function');
165
+ opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts);
166
+ // Request numeric enum values if REST transport is used.
167
+ opts.numericEnums = true;
168
+ // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case.
169
+ if (servicePath !== this._servicePath && !('scopes' in opts)) {
170
+ opts['scopes'] = staticMembers.scopes;
171
+ }
172
+ // Load google-gax module synchronously if needed
173
+ if (!gaxInstance) {
174
+ gaxInstance = require('google-gax');
175
+ }
176
+ // Choose either gRPC or proto-over-HTTP implementation of google-gax.
177
+ this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance;
178
+ // Create a `gaxGrpc` object, with any grpc-specific options sent to the client.
179
+ this._gaxGrpc = new this._gaxModule.GrpcClient(opts);
180
+ // Save options to use in initialize() method.
181
+ this._opts = opts;
182
+ // Save the auth object to the client, for use by other methods.
183
+ this.auth = this._gaxGrpc.auth;
184
+ // Set useJWTAccessWithScope on the auth object.
185
+ this.auth.useJWTAccessWithScope = true;
186
+ // Set defaultServicePath on the auth object.
187
+ this.auth.defaultServicePath = this._servicePath;
188
+ // Set the default scopes in auth client if needed.
189
+ if (servicePath === this._servicePath) {
190
+ this.auth.defaultScopes = staticMembers.scopes;
191
+ }
192
+ // Determine the client header string.
193
+ const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`];
194
+ if (typeof process === 'object' && 'versions' in process) {
195
+ clientHeader.push(`gl-node/${process.versions.node}`);
196
+ }
197
+ else {
198
+ clientHeader.push(`gl-web/${this._gaxModule.version}`);
199
+ }
200
+ if (!opts.fallback) {
201
+ clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`);
202
+ }
203
+ else {
204
+ clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`);
205
+ }
206
+ if (opts.libName && opts.libVersion) {
207
+ clientHeader.push(`${opts.libName}/${opts.libVersion}`);
208
+ }
209
+ // Load the applicable protos.
210
+ this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);
211
+ // Some of the methods on this service return "paged" results,
212
+ // (e.g. 50 results at a time, with tokens to get subsequent
213
+ // pages). Denote the keys used for pagination and results.
214
+ this.descriptors.page = {
215
+ listIndexes: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'indexes'),
216
+ };
217
+ const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos);
218
+ // This API contains "long-running operations", which return a
219
+ // an Operation object that allows for tracking of the operation,
220
+ // rather than holding a request open.
221
+ const lroOptions = {
222
+ auth: this.auth,
223
+ grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
224
+ };
225
+ if (opts.fallback) {
226
+ lroOptions.protoJson = protoFilesRoot;
227
+ lroOptions.httpRules = [
228
+ {
229
+ selector: 'google.longrunning.Operations.CancelOperation',
230
+ post: '/v1/{name=projects/*/operations/*}:cancel',
231
+ },
232
+ {
233
+ selector: 'google.longrunning.Operations.DeleteOperation',
234
+ delete: '/v1/{name=projects/*/operations/*}',
235
+ },
236
+ {
237
+ selector: 'google.longrunning.Operations.GetOperation',
238
+ get: '/v1/{name=projects/*/operations/*}',
239
+ },
240
+ {
241
+ selector: 'google.longrunning.Operations.ListOperations',
242
+ get: '/v1/{name=projects/*}/operations',
243
+ },
244
+ ];
245
+ }
246
+ this.operationsClient = this._gaxModule
247
+ .lro(lroOptions)
248
+ .operationsClient(opts);
249
+ const exportEntitiesResponse = protoFilesRoot.lookup('.google.datastore.admin.v1.ExportEntitiesResponse');
250
+ const exportEntitiesMetadata = protoFilesRoot.lookup('.google.datastore.admin.v1.ExportEntitiesMetadata');
251
+ const importEntitiesResponse = protoFilesRoot.lookup('.google.protobuf.Empty');
252
+ const importEntitiesMetadata = protoFilesRoot.lookup('.google.datastore.admin.v1.ImportEntitiesMetadata');
253
+ const createIndexResponse = protoFilesRoot.lookup('.google.datastore.admin.v1.Index');
254
+ const createIndexMetadata = protoFilesRoot.lookup('.google.datastore.admin.v1.IndexOperationMetadata');
255
+ const deleteIndexResponse = protoFilesRoot.lookup('.google.datastore.admin.v1.Index');
256
+ const deleteIndexMetadata = protoFilesRoot.lookup('.google.datastore.admin.v1.IndexOperationMetadata');
257
+ this.descriptors.longrunning = {
258
+ exportEntities: new this._gaxModule.LongrunningDescriptor(this.operationsClient, exportEntitiesResponse.decode.bind(exportEntitiesResponse), exportEntitiesMetadata.decode.bind(exportEntitiesMetadata)),
259
+ importEntities: new this._gaxModule.LongrunningDescriptor(this.operationsClient, importEntitiesResponse.decode.bind(importEntitiesResponse), importEntitiesMetadata.decode.bind(importEntitiesMetadata)),
260
+ createIndex: new this._gaxModule.LongrunningDescriptor(this.operationsClient, createIndexResponse.decode.bind(createIndexResponse), createIndexMetadata.decode.bind(createIndexMetadata)),
261
+ deleteIndex: new this._gaxModule.LongrunningDescriptor(this.operationsClient, deleteIndexResponse.decode.bind(deleteIndexResponse), deleteIndexMetadata.decode.bind(deleteIndexMetadata)),
262
+ };
263
+ // Put together the default options sent with requests.
264
+ this._defaults = this._gaxGrpc.constructSettings('google.datastore.admin.v1.DatastoreAdmin', gapicConfig, opts.clientConfig || {}, { 'x-goog-api-client': clientHeader.join(' ') });
265
+ // Set up a dictionary of "inner API calls"; the core implementation
266
+ // of calling the API is handled in `google-gax`, with this code
267
+ // merely providing the destination and request information.
268
+ this.innerApiCalls = {};
269
+ // Add a warn function to the client constructor so it can be easily tested.
270
+ this.warn = this._gaxModule.warn;
271
+ }
272
+ /**
273
+ * Initialize the client.
274
+ * Performs asynchronous operations (such as authentication) and prepares the client.
275
+ * This function will be called automatically when any class method is called for the
276
+ * first time, but if you need to initialize it before calling an actual method,
277
+ * feel free to call initialize() directly.
278
+ *
279
+ * You can await on this method if you want to make sure the client is initialized.
280
+ *
281
+ * @returns {Promise} A promise that resolves to an authenticated service stub.
282
+ */
283
+ initialize() {
284
+ // If the client stub promise is already initialized, return immediately.
285
+ if (this.datastoreAdminStub) {
286
+ return this.datastoreAdminStub;
287
+ }
288
+ // Put together the "service stub" for
289
+ // google.datastore.admin.v1.DatastoreAdmin.
290
+ this.datastoreAdminStub = this._gaxGrpc.createStub(this._opts.fallback
291
+ ? this._protos.lookupService('google.datastore.admin.v1.DatastoreAdmin')
292
+ : // eslint-disable-next-line @typescript-eslint/no-explicit-any
293
+ this._protos.google.datastore.admin.v1.DatastoreAdmin, this._opts, this._providedCustomServicePath);
294
+ // Iterate over each of the methods that the service provides
295
+ // and create an API call method for each.
296
+ const datastoreAdminStubMethods = [
297
+ 'exportEntities',
298
+ 'importEntities',
299
+ 'createIndex',
300
+ 'deleteIndex',
301
+ 'getIndex',
302
+ 'listIndexes',
303
+ ];
304
+ for (const methodName of datastoreAdminStubMethods) {
305
+ const callPromise = this.datastoreAdminStub.then((stub) => (...args) => {
306
+ if (this._terminated) {
307
+ return Promise.reject('The client has already been closed.');
308
+ }
309
+ const func = stub[methodName];
310
+ return func.apply(stub, args);
311
+ }, (err) => () => {
312
+ throw err;
313
+ });
314
+ const descriptor = this.descriptors.page[methodName] ||
315
+ this.descriptors.longrunning[methodName] ||
316
+ undefined;
317
+ const apiCall = this._gaxModule.createApiCall(callPromise, this._defaults[methodName], descriptor, this._opts.fallback);
318
+ this.innerApiCalls[methodName] = apiCall;
319
+ }
320
+ return this.datastoreAdminStub;
321
+ }
322
+ /**
323
+ * The DNS address for this API service.
324
+ * @deprecated Use the apiEndpoint method of the client instance.
325
+ * @returns {string} The DNS address for this service.
326
+ */
327
+ static get servicePath() {
328
+ if (typeof process === 'object' &&
329
+ typeof process.emitWarning === 'function') {
330
+ process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning');
331
+ }
332
+ return 'datastore.googleapis.com';
333
+ }
334
+ /**
335
+ * The DNS address for this API service - same as servicePath.
336
+ * @deprecated Use the apiEndpoint method of the client instance.
337
+ * @returns {string} The DNS address for this service.
338
+ */
339
+ static get apiEndpoint() {
340
+ if (typeof process === 'object' &&
341
+ typeof process.emitWarning === 'function') {
342
+ process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning');
343
+ }
344
+ return 'datastore.googleapis.com';
345
+ }
346
+ /**
347
+ * The DNS address for this API service.
348
+ * @returns {string} The DNS address for this service.
349
+ */
350
+ get apiEndpoint() {
351
+ return this._servicePath;
352
+ }
353
+ get universeDomain() {
354
+ return this._universeDomain;
355
+ }
356
+ /**
357
+ * The port for this API service.
358
+ * @returns {number} The default port for this service.
359
+ */
360
+ static get port() {
361
+ return 443;
362
+ }
363
+ /**
364
+ * The scopes needed to make gRPC calls for every method defined
365
+ * in this service.
366
+ * @returns {string[]} List of default scopes.
367
+ */
368
+ static get scopes() {
369
+ return [
370
+ 'https://www.googleapis.com/auth/cloud-platform',
371
+ 'https://www.googleapis.com/auth/datastore',
372
+ ];
373
+ }
374
+ /**
375
+ * Return the project ID used by this class.
376
+ * @returns {Promise} A promise that resolves to string containing the project ID.
377
+ */
378
+ getProjectId(callback) {
379
+ if (callback) {
380
+ this.auth.getProjectId(callback);
381
+ return;
382
+ }
383
+ return this.auth.getProjectId();
384
+ }
385
+ getIndex(request, optionsOrCallback, callback) {
386
+ request = request || {};
387
+ let options;
388
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
389
+ callback = optionsOrCallback;
390
+ options = {};
391
+ }
392
+ else {
393
+ options = optionsOrCallback;
394
+ }
395
+ options = options || {};
396
+ options.otherArgs = options.otherArgs || {};
397
+ options.otherArgs.headers = options.otherArgs.headers || {};
398
+ options.otherArgs.headers['x-goog-request-params'] =
399
+ this._gaxModule.routingHeader.fromParams({
400
+ project_id: request.projectId?.toString() ?? '',
401
+ index_id: request.indexId?.toString() ?? '',
402
+ });
403
+ this.initialize().catch((err) => {
404
+ throw err;
405
+ });
406
+ this._log.info('getIndex request %j', request);
407
+ const wrappedCallback = callback
408
+ ? (error, response, options, rawResponse) => {
409
+ this._log.info('getIndex response %j', response);
410
+ callback(error, response, options, rawResponse); // We verified callback above.
411
+ }
412
+ : undefined;
413
+ return this.innerApiCalls
414
+ .getIndex(request, options, wrappedCallback)
415
+ ?.then(([response, options, rawResponse]) => {
416
+ this._log.info('getIndex response %j', response);
417
+ return [response, options, rawResponse];
418
+ })
419
+ .catch((error) => {
420
+ if (error &&
421
+ 'statusDetails' in error &&
422
+ error.statusDetails instanceof Array) {
423
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
424
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
425
+ }
426
+ throw error;
427
+ });
428
+ }
429
+ exportEntities(request, optionsOrCallback, callback) {
430
+ request = request || {};
431
+ let options;
432
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
433
+ callback = optionsOrCallback;
434
+ options = {};
435
+ }
436
+ else {
437
+ options = optionsOrCallback;
438
+ }
439
+ options = options || {};
440
+ options.otherArgs = options.otherArgs || {};
441
+ options.otherArgs.headers = options.otherArgs.headers || {};
442
+ options.otherArgs.headers['x-goog-request-params'] =
443
+ this._gaxModule.routingHeader.fromParams({
444
+ project_id: request.projectId?.toString() ?? '',
445
+ });
446
+ this.initialize().catch((err) => {
447
+ throw err;
448
+ });
449
+ const wrappedCallback = callback
450
+ ? (error, response, rawResponse, _) => {
451
+ this._log.info('exportEntities response %j', rawResponse);
452
+ callback(error, response, rawResponse, _); // We verified callback above.
453
+ }
454
+ : undefined;
455
+ this._log.info('exportEntities request %j', request);
456
+ return this.innerApiCalls
457
+ .exportEntities(request, options, wrappedCallback)
458
+ ?.then(([response, rawResponse, _]) => {
459
+ this._log.info('exportEntities response %j', rawResponse);
460
+ return [response, rawResponse, _];
461
+ });
462
+ }
463
+ /**
464
+ * Check the status of the long running operation returned by `exportEntities()`.
465
+ * @param {String} name
466
+ * The operation name that will be passed.
467
+ * @returns {Promise} - The promise which resolves to an object.
468
+ * The decoded operation object has result and metadata field to get information from.
469
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation }
470
+ * for more details and examples.
471
+ * @example <caption>include:samples/generated/v1/datastore_admin.export_entities.js</caption>
472
+ * region_tag:datastore_v1_generated_DatastoreAdmin_ExportEntities_async
473
+ */
474
+ async checkExportEntitiesProgress(name) {
475
+ this._log.info('exportEntities long-running');
476
+ const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({ name });
477
+ const [operation] = await this.operationsClient.getOperation(request);
478
+ const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.exportEntities, this._gaxModule.createDefaultBackoffSettings());
479
+ return decodeOperation;
480
+ }
481
+ importEntities(request, optionsOrCallback, callback) {
482
+ request = request || {};
483
+ let options;
484
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
485
+ callback = optionsOrCallback;
486
+ options = {};
487
+ }
488
+ else {
489
+ options = optionsOrCallback;
490
+ }
491
+ options = options || {};
492
+ options.otherArgs = options.otherArgs || {};
493
+ options.otherArgs.headers = options.otherArgs.headers || {};
494
+ options.otherArgs.headers['x-goog-request-params'] =
495
+ this._gaxModule.routingHeader.fromParams({
496
+ project_id: request.projectId?.toString() ?? '',
497
+ });
498
+ this.initialize().catch((err) => {
499
+ throw err;
500
+ });
501
+ const wrappedCallback = callback
502
+ ? (error, response, rawResponse, _) => {
503
+ this._log.info('importEntities response %j', rawResponse);
504
+ callback(error, response, rawResponse, _); // We verified callback above.
505
+ }
506
+ : undefined;
507
+ this._log.info('importEntities request %j', request);
508
+ return this.innerApiCalls
509
+ .importEntities(request, options, wrappedCallback)
510
+ ?.then(([response, rawResponse, _]) => {
511
+ this._log.info('importEntities response %j', rawResponse);
512
+ return [response, rawResponse, _];
513
+ });
514
+ }
515
+ /**
516
+ * Check the status of the long running operation returned by `importEntities()`.
517
+ * @param {String} name
518
+ * The operation name that will be passed.
519
+ * @returns {Promise} - The promise which resolves to an object.
520
+ * The decoded operation object has result and metadata field to get information from.
521
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation }
522
+ * for more details and examples.
523
+ * @example <caption>include:samples/generated/v1/datastore_admin.import_entities.js</caption>
524
+ * region_tag:datastore_v1_generated_DatastoreAdmin_ImportEntities_async
525
+ */
526
+ async checkImportEntitiesProgress(name) {
527
+ this._log.info('importEntities long-running');
528
+ const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({ name });
529
+ const [operation] = await this.operationsClient.getOperation(request);
530
+ const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.importEntities, this._gaxModule.createDefaultBackoffSettings());
531
+ return decodeOperation;
532
+ }
533
+ createIndex(request, optionsOrCallback, callback) {
534
+ request = request || {};
535
+ let options;
536
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
537
+ callback = optionsOrCallback;
538
+ options = {};
539
+ }
540
+ else {
541
+ options = optionsOrCallback;
542
+ }
543
+ options = options || {};
544
+ options.otherArgs = options.otherArgs || {};
545
+ options.otherArgs.headers = options.otherArgs.headers || {};
546
+ options.otherArgs.headers['x-goog-request-params'] =
547
+ this._gaxModule.routingHeader.fromParams({
548
+ project_id: request.projectId?.toString() ?? '',
549
+ });
550
+ this.initialize().catch((err) => {
551
+ throw err;
552
+ });
553
+ const wrappedCallback = callback
554
+ ? (error, response, rawResponse, _) => {
555
+ this._log.info('createIndex response %j', rawResponse);
556
+ callback(error, response, rawResponse, _); // We verified callback above.
557
+ }
558
+ : undefined;
559
+ this._log.info('createIndex request %j', request);
560
+ return this.innerApiCalls
561
+ .createIndex(request, options, wrappedCallback)
562
+ ?.then(([response, rawResponse, _]) => {
563
+ this._log.info('createIndex response %j', rawResponse);
564
+ return [response, rawResponse, _];
565
+ });
566
+ }
567
+ /**
568
+ * Check the status of the long running operation returned by `createIndex()`.
569
+ * @param {String} name
570
+ * The operation name that will be passed.
571
+ * @returns {Promise} - The promise which resolves to an object.
572
+ * The decoded operation object has result and metadata field to get information from.
573
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation }
574
+ * for more details and examples.
575
+ * @example <caption>include:samples/generated/v1/datastore_admin.create_index.js</caption>
576
+ * region_tag:datastore_v1_generated_DatastoreAdmin_CreateIndex_async
577
+ */
578
+ async checkCreateIndexProgress(name) {
579
+ this._log.info('createIndex long-running');
580
+ const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({ name });
581
+ const [operation] = await this.operationsClient.getOperation(request);
582
+ const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createIndex, this._gaxModule.createDefaultBackoffSettings());
583
+ return decodeOperation;
584
+ }
585
+ deleteIndex(request, optionsOrCallback, callback) {
586
+ request = request || {};
587
+ let options;
588
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
589
+ callback = optionsOrCallback;
590
+ options = {};
591
+ }
592
+ else {
593
+ options = optionsOrCallback;
594
+ }
595
+ options = options || {};
596
+ options.otherArgs = options.otherArgs || {};
597
+ options.otherArgs.headers = options.otherArgs.headers || {};
598
+ options.otherArgs.headers['x-goog-request-params'] =
599
+ this._gaxModule.routingHeader.fromParams({
600
+ project_id: request.projectId?.toString() ?? '',
601
+ index_id: request.indexId?.toString() ?? '',
602
+ });
603
+ this.initialize().catch((err) => {
604
+ throw err;
605
+ });
606
+ const wrappedCallback = callback
607
+ ? (error, response, rawResponse, _) => {
608
+ this._log.info('deleteIndex response %j', rawResponse);
609
+ callback(error, response, rawResponse, _); // We verified callback above.
610
+ }
611
+ : undefined;
612
+ this._log.info('deleteIndex request %j', request);
613
+ return this.innerApiCalls
614
+ .deleteIndex(request, options, wrappedCallback)
615
+ ?.then(([response, rawResponse, _]) => {
616
+ this._log.info('deleteIndex response %j', rawResponse);
617
+ return [response, rawResponse, _];
618
+ });
619
+ }
620
+ /**
621
+ * Check the status of the long running operation returned by `deleteIndex()`.
622
+ * @param {String} name
623
+ * The operation name that will be passed.
624
+ * @returns {Promise} - The promise which resolves to an object.
625
+ * The decoded operation object has result and metadata field to get information from.
626
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation }
627
+ * for more details and examples.
628
+ * @example <caption>include:samples/generated/v1/datastore_admin.delete_index.js</caption>
629
+ * region_tag:datastore_v1_generated_DatastoreAdmin_DeleteIndex_async
630
+ */
631
+ async checkDeleteIndexProgress(name) {
632
+ this._log.info('deleteIndex long-running');
633
+ const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({ name });
634
+ const [operation] = await this.operationsClient.getOperation(request);
635
+ const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteIndex, this._gaxModule.createDefaultBackoffSettings());
636
+ return decodeOperation;
637
+ }
638
+ listIndexes(request, optionsOrCallback, callback) {
639
+ request = request || {};
640
+ let options;
641
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
642
+ callback = optionsOrCallback;
643
+ options = {};
644
+ }
645
+ else {
646
+ options = optionsOrCallback;
647
+ }
648
+ options = options || {};
649
+ options.otherArgs = options.otherArgs || {};
650
+ options.otherArgs.headers = options.otherArgs.headers || {};
651
+ options.otherArgs.headers['x-goog-request-params'] =
652
+ this._gaxModule.routingHeader.fromParams({
653
+ project_id: request.projectId?.toString() ?? '',
654
+ });
655
+ this.initialize().catch((err) => {
656
+ throw err;
657
+ });
658
+ const wrappedCallback = callback
659
+ ? (error, values, nextPageRequest, rawResponse) => {
660
+ this._log.info('listIndexes values %j', values);
661
+ callback(error, values, nextPageRequest, rawResponse); // We verified callback above.
662
+ }
663
+ : undefined;
664
+ this._log.info('listIndexes request %j', request);
665
+ return this.innerApiCalls
666
+ .listIndexes(request, options, wrappedCallback)
667
+ ?.then(([response, input, output]) => {
668
+ this._log.info('listIndexes values %j', response);
669
+ return [response, input, output];
670
+ });
671
+ }
672
+ /**
673
+ * Equivalent to `listIndexes`, but returns a NodeJS Stream object.
674
+ * @param {Object} request
675
+ * The request object that will be sent.
676
+ * @param {string} request.projectId
677
+ * Project ID against which to make the request.
678
+ * @param {string} request.filter
679
+ * @param {number} request.pageSize
680
+ * The maximum number of items to return. If zero, then all results will be
681
+ * returned.
682
+ * @param {string} request.pageToken
683
+ * The next_page_token value returned from a previous List request, if any.
684
+ * @param {object} [options]
685
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
686
+ * @returns {Stream}
687
+ * An object stream which emits an object representing {@link protos.google.datastore.admin.v1.Index|Index} on 'data' event.
688
+ * The client library will perform auto-pagination by default: it will call the API as many
689
+ * times as needed. Note that it can affect your quota.
690
+ * We recommend using `listIndexesAsync()`
691
+ * method described below for async iteration which you can stop as needed.
692
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
693
+ * for more details and examples.
694
+ */
695
+ listIndexesStream(request, options) {
696
+ request = request || {};
697
+ options = options || {};
698
+ options.otherArgs = options.otherArgs || {};
699
+ options.otherArgs.headers = options.otherArgs.headers || {};
700
+ options.otherArgs.headers['x-goog-request-params'] =
701
+ this._gaxModule.routingHeader.fromParams({
702
+ project_id: request.projectId?.toString() ?? '',
703
+ });
704
+ const defaultCallSettings = this._defaults['listIndexes'];
705
+ const callSettings = defaultCallSettings.merge(options);
706
+ this.initialize().catch((err) => {
707
+ throw err;
708
+ });
709
+ this._log.info('listIndexes stream %j', request);
710
+ return this.descriptors.page.listIndexes.createStream(this.innerApiCalls.listIndexes, request, callSettings);
711
+ }
712
+ /**
713
+ * Equivalent to `listIndexes`, but returns an iterable object.
714
+ *
715
+ * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand.
716
+ * @param {Object} request
717
+ * The request object that will be sent.
718
+ * @param {string} request.projectId
719
+ * Project ID against which to make the request.
720
+ * @param {string} request.filter
721
+ * @param {number} request.pageSize
722
+ * The maximum number of items to return. If zero, then all results will be
723
+ * returned.
724
+ * @param {string} request.pageToken
725
+ * The next_page_token value returned from a previous List request, if any.
726
+ * @param {object} [options]
727
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
728
+ * @returns {Object}
729
+ * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }.
730
+ * When you iterate the returned iterable, each element will be an object representing
731
+ * {@link protos.google.datastore.admin.v1.Index|Index}. The API will be called under the hood as needed, once per the page,
732
+ * so you can stop the iteration when you don't need more results.
733
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
734
+ * for more details and examples.
735
+ * @example <caption>include:samples/generated/v1/datastore_admin.list_indexes.js</caption>
736
+ * region_tag:datastore_v1_generated_DatastoreAdmin_ListIndexes_async
737
+ */
738
+ listIndexesAsync(request, options) {
739
+ request = request || {};
740
+ options = options || {};
741
+ options.otherArgs = options.otherArgs || {};
742
+ options.otherArgs.headers = options.otherArgs.headers || {};
743
+ options.otherArgs.headers['x-goog-request-params'] =
744
+ this._gaxModule.routingHeader.fromParams({
745
+ project_id: request.projectId?.toString() ?? '',
746
+ });
747
+ const defaultCallSettings = this._defaults['listIndexes'];
748
+ const callSettings = defaultCallSettings.merge(options);
749
+ this.initialize().catch((err) => {
750
+ throw err;
751
+ });
752
+ this._log.info('listIndexes iterate %j', request);
753
+ return this.descriptors.page.listIndexes.asyncIterate(this.innerApiCalls['listIndexes'], request, callSettings);
754
+ }
755
+ /**
756
+ * Gets the latest state of a long-running operation. Clients can use this
757
+ * method to poll the operation result at intervals as recommended by the API
758
+ * service.
759
+ *
760
+ * @param {Object} request - The request object that will be sent.
761
+ * @param {string} request.name - The name of the operation resource.
762
+ * @param {Object=} options
763
+ * Optional parameters. You can override the default settings for this call,
764
+ * e.g, timeout, retries, paginations, etc. See {@link
765
+ * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions}
766
+ * for the details.
767
+ * @param {function(?Error, ?Object)=} callback
768
+ * The function which will be called with the result of the API call.
769
+ *
770
+ * The second parameter to the callback is an object representing
771
+ * {@link google.longrunning.Operation | google.longrunning.Operation}.
772
+ * @return {Promise} - The promise which resolves to an array.
773
+ * The first element of the array is an object representing
774
+ * {@link google.longrunning.Operation | google.longrunning.Operation}.
775
+ * The promise has a method named "cancel" which cancels the ongoing API call.
776
+ *
777
+ * @example
778
+ * ```
779
+ * const client = longrunning.operationsClient();
780
+ * const name = '';
781
+ * const [response] = await client.getOperation({name});
782
+ * // doThingsWith(response)
783
+ * ```
784
+ */
785
+ getOperation(request, optionsOrCallback, callback) {
786
+ let options;
787
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
788
+ callback = optionsOrCallback;
789
+ options = {};
790
+ }
791
+ else {
792
+ options = optionsOrCallback;
793
+ }
794
+ options = options || {};
795
+ options.otherArgs = options.otherArgs || {};
796
+ options.otherArgs.headers = options.otherArgs.headers || {};
797
+ options.otherArgs.headers['x-goog-request-params'] =
798
+ this._gaxModule.routingHeader.fromParams({
799
+ name: request.name ?? '',
800
+ });
801
+ return this.operationsClient.getOperation(request, options, callback);
802
+ }
803
+ /**
804
+ * Lists operations that match the specified filter in the request. If the
805
+ * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object.
806
+ *
807
+ * For-await-of syntax is used with the iterable to recursively get response element on-demand.
808
+ *
809
+ * @param {Object} request - The request object that will be sent.
810
+ * @param {string} request.name - The name of the operation collection.
811
+ * @param {string} request.filter - The standard list filter.
812
+ * @param {number=} request.pageSize -
813
+ * The maximum number of resources contained in the underlying API
814
+ * response. If page streaming is performed per-resource, this
815
+ * parameter does not affect the return value. If page streaming is
816
+ * performed per-page, this determines the maximum number of
817
+ * resources in a page.
818
+ * @param {Object=} options
819
+ * Optional parameters. You can override the default settings for this call,
820
+ * e.g, timeout, retries, paginations, etc. See {@link
821
+ * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the
822
+ * details.
823
+ * @returns {Object}
824
+ * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}.
825
+ *
826
+ * @example
827
+ * ```
828
+ * const client = longrunning.operationsClient();
829
+ * for await (const response of client.listOperationsAsync(request));
830
+ * // doThingsWith(response)
831
+ * ```
832
+ */
833
+ listOperationsAsync(request, options) {
834
+ options = options || {};
835
+ options.otherArgs = options.otherArgs || {};
836
+ options.otherArgs.headers = options.otherArgs.headers || {};
837
+ options.otherArgs.headers['x-goog-request-params'] =
838
+ this._gaxModule.routingHeader.fromParams({
839
+ name: request.name ?? '',
840
+ });
841
+ return this.operationsClient.listOperationsAsync(request, options);
842
+ }
843
+ /**
844
+ * Starts asynchronous cancellation on a long-running operation. The server
845
+ * makes a best effort to cancel the operation, but success is not
846
+ * guaranteed. If the server doesn't support this method, it returns
847
+ * `google.rpc.Code.UNIMPLEMENTED`. Clients can use
848
+ * {@link Operations.GetOperation} or
849
+ * other methods to check whether the cancellation succeeded or whether the
850
+ * operation completed despite cancellation. On successful cancellation,
851
+ * the operation is not deleted; instead, it becomes an operation with
852
+ * an {@link Operation.error} value with a {@link google.rpc.Status.code} of
853
+ * 1, corresponding to `Code.CANCELLED`.
854
+ *
855
+ * @param {Object} request - The request object that will be sent.
856
+ * @param {string} request.name - The name of the operation resource to be cancelled.
857
+ * @param {Object=} options
858
+ * Optional parameters. You can override the default settings for this call,
859
+ * e.g, timeout, retries, paginations, etc. See {@link
860
+ * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the
861
+ * details.
862
+ * @param {function(?Error)=} callback
863
+ * The function which will be called with the result of the API call.
864
+ * @return {Promise} - The promise which resolves when API call finishes.
865
+ * The promise has a method named "cancel" which cancels the ongoing API
866
+ * call.
867
+ *
868
+ * @example
869
+ * ```
870
+ * const client = longrunning.operationsClient();
871
+ * await client.cancelOperation({name: ''});
872
+ * ```
873
+ */
874
+ cancelOperation(request, optionsOrCallback, callback) {
875
+ let options;
876
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
877
+ callback = optionsOrCallback;
878
+ options = {};
879
+ }
880
+ else {
881
+ options = optionsOrCallback;
882
+ }
883
+ options = options || {};
884
+ options.otherArgs = options.otherArgs || {};
885
+ options.otherArgs.headers = options.otherArgs.headers || {};
886
+ options.otherArgs.headers['x-goog-request-params'] =
887
+ this._gaxModule.routingHeader.fromParams({
888
+ name: request.name ?? '',
889
+ });
890
+ return this.operationsClient.cancelOperation(request, options, callback);
891
+ }
892
+ /**
893
+ * Deletes a long-running operation. This method indicates that the client is
894
+ * no longer interested in the operation result. It does not cancel the
895
+ * operation. If the server doesn't support this method, it returns
896
+ * `google.rpc.Code.UNIMPLEMENTED`.
897
+ *
898
+ * @param {Object} request - The request object that will be sent.
899
+ * @param {string} request.name - The name of the operation resource to be deleted.
900
+ * @param {Object=} options
901
+ * Optional parameters. You can override the default settings for this call,
902
+ * e.g, timeout, retries, paginations, etc. See {@link
903
+ * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions}
904
+ * for the details.
905
+ * @param {function(?Error)=} callback
906
+ * The function which will be called with the result of the API call.
907
+ * @return {Promise} - The promise which resolves when API call finishes.
908
+ * The promise has a method named "cancel" which cancels the ongoing API
909
+ * call.
910
+ *
911
+ * @example
912
+ * ```
913
+ * const client = longrunning.operationsClient();
914
+ * await client.deleteOperation({name: ''});
915
+ * ```
916
+ */
917
+ deleteOperation(request, optionsOrCallback, callback) {
918
+ let options;
919
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
920
+ callback = optionsOrCallback;
921
+ options = {};
922
+ }
923
+ else {
924
+ options = optionsOrCallback;
925
+ }
926
+ options = options || {};
927
+ options.otherArgs = options.otherArgs || {};
928
+ options.otherArgs.headers = options.otherArgs.headers || {};
929
+ options.otherArgs.headers['x-goog-request-params'] =
930
+ this._gaxModule.routingHeader.fromParams({
931
+ name: request.name ?? '',
932
+ });
933
+ return this.operationsClient.deleteOperation(request, options, callback);
934
+ }
935
+ /**
936
+ * Terminate the gRPC channel and close the client.
937
+ *
938
+ * The client will no longer be usable and all future behavior is undefined.
939
+ * @returns {Promise} A promise that resolves when the client is closed.
940
+ */
941
+ close() {
942
+ if (this.datastoreAdminStub && !this._terminated) {
943
+ return this.datastoreAdminStub.then((stub) => {
944
+ this._log.info('ending gRPC channel');
945
+ this._terminated = true;
946
+ stub.close();
947
+ void this.operationsClient.close();
948
+ });
949
+ }
950
+ return Promise.resolve();
951
+ }
952
+ }
953
+ exports.DatastoreAdminClient = DatastoreAdminClient;
954
+ //# sourceMappingURL=datastore_admin_client.js.map