Class DatastoreAdminClient (8.7.0)

Google Cloud Datastore Admin API

The Datastore Admin API provides several admin services for Cloud Datastore.

Concepts: Project, namespace, kind, and entity as defined in the Google Cloud Datastore API.

Operation: An Operation represents work being performed in the background.

EntityFilter: Allows specifying a subset of entities in a project. This is specified as a combination of kinds and namespaces (either or both of which may be all).

Export/Import Service:

  • The Export/Import service provides the ability to copy all or a subset of entities to/from Google Cloud Storage. - Exported data may be imported into Cloud Datastore for any Google Cloud Platform project. It is not restricted to the export source project. It is possible to export from one project and then import into another. - Exported data can also be loaded into Google BigQuery for analysis. - Exports and imports are performed asynchronously. An Operation resource is created for each export/import. The state (including any errors encountered) of the export/import may be queried via the Operation resource.

Index Service:

  • The index service manages Cloud Datastore composite indexes. - Index creation and deletion are performed asynchronously. An Operation resource is created for each such asynchronous operation. The state of the operation (including any errors encountered) may be queried via the Operation resource.

Operation Service:

  • The Operations collection provides a record of actions performed for the specified project (including any operations in progress). Operations are not created directly but through calls on other collections or resources. - An operation that is not yet done may be cancelled. The request to cancel is asynchronous and the operation may continue to run for some time after the request to cancel is made. - An operation that is done may be deleted so that it is no longer listed as part of the Operation collection. - ListOperations returns all pending operations, but not completed operations. - Operations are created by service DatastoreAdmin, but are accessed via service google.longrunning.Operations. v1

Package

@google-cloud/datastore

Constructors

(constructor)(opts, gaxInstance)

constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback);

Construct an instance of DatastoreAdminClient.

Parameters
NameDescription
opts ClientOptions
gaxInstance typeof gax | typeof fallback

: loaded instance of google-gax. Useful if you need to avoid loading the default gRPC version and want to use the fallback HTTP implementation. Load only fallback version and pass it to the constructor: ``` const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC const client = new DatastoreAdminClient({fallback: true}, gax); ```

Properties

apiEndpoint

get apiEndpoint(): string;

The DNS address for this API service.

apiEndpoint

static get apiEndpoint(): string;

The DNS address for this API service - same as servicePath.

auth

auth: gax.GoogleAuth;

datastoreAdminStub

datastoreAdminStub?: Promise<{
        [name: string]: Function;
    }>;

descriptors

descriptors: Descriptors;

innerApiCalls

innerApiCalls: {
        [name: string]: Function;
    };

operationsClient

operationsClient: gax.OperationsClient;

port

static get port(): number;

The port for this API service.

scopes

static get scopes(): string[];

The scopes needed to make gRPC calls for every method defined in this service.

servicePath

static get servicePath(): string;

The DNS address for this API service.

universeDomain

get universeDomain(): string;

warn

warn: (code: string, message: string, warnType?: string) => void;

Methods

cancelOperation(request, options, callback)

cancelOperation(request: protos.google.longrunning.CancelOperationRequest, options?: gax.CallOptions | Callback<protos.google.protobuf.Empty, protos.google.longrunning.CancelOperationRequest, {} | undefined | null>, callback?: Callback<protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null>): Promise<protos.google.protobuf.Empty>;

Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns google.rpc.Code.UNIMPLEMENTED. Clients can use or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an value with a of 1, corresponding to Code.CANCELLED.

Parameters
NameDescription
request protos.google.longrunning.CancelOperationRequest

The request object that will be sent.

options CallOptions | Callback<google.protobuf.Empty, google.longrunning.CancelOperationRequest, {} | undefined | null>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback Callback<google.longrunning.CancelOperationRequest, google.protobuf.Empty, {} | undefined | null>

The function which will be called with the result of the API call. {Promise} - The promise which resolves when API call finishes. The promise has a method named "cancel" which cancels the ongoing API call.

Returns
TypeDescription
Promise<google.protobuf.Empty>
Example

const client = longrunning.operationsClient();
await client.cancelOperation({name: ''});

checkCreateIndexProgress(name)

checkCreateIndexProgress(name: string): Promise<LROperation<protos.google.datastore.admin.v1.Index, protos.google.datastore.admin.v1.IndexOperationMetadata>>;

Check the status of the long running operation returned by createIndex().

Parameter
NameDescription
name string

The operation name that will be passed.

Returns
TypeDescription
Promise<LROperation<google.datastore.admin.v1.Index, google.datastore.admin.v1.IndexOperationMetadata>>

{Promise} - The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Project ID against which to make the request.
   */
  // const projectId = 'abc123'
  /**
   *  The index to create. The name and state fields are output only and will be
   *  ignored. Single property indexes cannot be created or deleted.
   */
  // const index = {}

  // Imports the Admin library
  const {DatastoreAdminClient} = require('@google-cloud/datastore-admin').v1;

  // Instantiates a client
  const adminClient = new DatastoreAdminClient();

  async function callCreateIndex() {
    // Construct request
    const request = {
    };

    // Run request
    const [operation] = await adminClient.createIndex(request);
    const [response] = await operation.promise();
    console.log(response);
  }

  callCreateIndex();

checkDeleteIndexProgress(name)

checkDeleteIndexProgress(name: string): Promise<LROperation<protos.google.datastore.admin.v1.Index, protos.google.datastore.admin.v1.IndexOperationMetadata>>;

Check the status of the long running operation returned by deleteIndex().

Parameter
NameDescription
name string

The operation name that will be passed.

Returns
TypeDescription
Promise<LROperation<google.datastore.admin.v1.Index, google.datastore.admin.v1.IndexOperationMetadata>>

{Promise} - The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Project ID against which to make the request.
   */
  // const projectId = 'abc123'
  /**
   *  The resource ID of the index to delete.
   */
  // const indexId = 'abc123'

  // Imports the Admin library
  const {DatastoreAdminClient} = require('@google-cloud/datastore-admin').v1;

  // Instantiates a client
  const adminClient = new DatastoreAdminClient();

  async function callDeleteIndex() {
    // Construct request
    const request = {
    };

    // Run request
    const [operation] = await adminClient.deleteIndex(request);
    const [response] = await operation.promise();
    console.log(response);
  }

  callDeleteIndex();

checkExportEntitiesProgress(name)

checkExportEntitiesProgress(name: string): Promise<LROperation<protos.google.datastore.admin.v1.ExportEntitiesResponse, protos.google.datastore.admin.v1.ExportEntitiesMetadata>>;

Check the status of the long running operation returned by exportEntities().

Parameter
NameDescription
name string

The operation name that will be passed.

Returns
TypeDescription
Promise<LROperation<google.datastore.admin.v1.ExportEntitiesResponse, google.datastore.admin.v1.ExportEntitiesMetadata>>

{Promise} - The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. Project ID against which to make the request.
   */
  // const projectId = 'abc123'
  /**
   *  Client-assigned labels.
   */
  // const labels = [1,2,3,4]
  /**
   *  Description of what data from the project is included in the export.
   */
  // const entityFilter = {}
  /**
   *  Required. Location for the export metadata and data files.
   *  The full resource URL of the external storage location. Currently, only
   *  Google Cloud Storage is supported. So output_url_prefix should be of the
   *  form: `gs://BUCKET_NAME/NAMESPACE_PATH`, where `BUCKET_NAME` is the
   *  name of the Cloud Storage bucket and `NAMESPACE_PATH` is an optional Cloud
   *  Storage namespace path (this is not a Cloud Datastore namespace). For more
   *  information about Cloud Storage namespace paths, see
   *  Object name
   *  considerations (https://cloud.google.com/storage/docs/naming#object-considerations).
   *  The resulting files will be nested deeper than the specified URL prefix.
   *  The final output URL will be provided in the
   *  google.datastore.admin.v1.ExportEntitiesResponse.output_url google.datastore.admin.v1.ExportEntitiesResponse.output_url 
   *  field. That value should be used for subsequent ImportEntities operations.
   *  By nesting the data files deeper, the same Cloud Storage bucket can be used
   *  in multiple ExportEntities operations without conflict.
   */
  // const outputUrlPrefix = 'abc123'

  // Imports the Admin library
  const {DatastoreAdminClient} = require('@google-cloud/datastore-admin').v1;

  // Instantiates a client
  const adminClient = new DatastoreAdminClient();

  async function callExportEntities() {
    // Construct request
    const request = {
      projectId,
      outputUrlPrefix,
    };

    // Run request
    const [operation] = await adminClient.exportEntities(request);
    const [response] = await operation.promise();
    console.log(response);
  }

  callExportEntities();

checkImportEntitiesProgress(name)

checkImportEntitiesProgress(name: string): Promise<LROperation<protos.google.protobuf.Empty, protos.google.datastore.admin.v1.ImportEntitiesMetadata>>;

Check the status of the long running operation returned by importEntities().

Parameter
NameDescription
name string

The operation name that will be passed.

Returns
TypeDescription
Promise<LROperation<google.protobuf.Empty, google.datastore.admin.v1.ImportEntitiesMetadata>>

{Promise} - The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. Project ID against which to make the request.
   */
  // const projectId = 'abc123'
  /**
   *  Client-assigned labels.
   */
  // const labels = [1,2,3,4]
  /**
   *  Required. The full resource URL of the external storage location.
   *  Currently, only Google Cloud Storage is supported. So input_url should be
   *  of the form:
   *  `gs://BUCKET_NAME[/NAMESPACE_PATH]/OVERALL_EXPORT_METADATA_FILE`, where
   *  `BUCKET_NAME` is the name of the Cloud Storage bucket, `NAMESPACE_PATH` is
   *  an optional Cloud Storage namespace path (this is not a Cloud Datastore
   *  namespace), and `OVERALL_EXPORT_METADATA_FILE` is the metadata file written
   *  by the ExportEntities operation. For more information about Cloud Storage
   *  namespace paths, see
   *  Object name
   *  considerations (https://cloud.google.com/storage/docs/naming#object-considerations).
   *  For more information, see
   *  google.datastore.admin.v1.ExportEntitiesResponse.output_url google.datastore.admin.v1.ExportEntitiesResponse.output_url.
   */
  // const inputUrl = 'abc123'
  /**
   *  Optionally specify which kinds/namespaces are to be imported. If provided,
   *  the list must be a subset of the EntityFilter used in creating the export,
   *  otherwise a FAILED_PRECONDITION error will be returned. If no filter is
   *  specified then all entities from the export are imported.
   */
  // const entityFilter = {}

  // Imports the Admin library
  const {DatastoreAdminClient} = require('@google-cloud/datastore-admin').v1;

  // Instantiates a client
  const adminClient = new DatastoreAdminClient();

  async function callImportEntities() {
    // Construct request
    const request = {
      projectId,
      inputUrl,
    };

    // Run request
    const [operation] = await adminClient.importEntities(request);
    const [response] = await operation.promise();
    console.log(response);
  }

  callImportEntities();

close()

close(): Promise<void>;

Terminate the gRPC channel and close the client.

The client will no longer be usable and all future behavior is undefined.

Returns
TypeDescription
Promise<void>

{Promise} A promise that resolves when the client is closed.

createIndex(request, options)

createIndex(request?: protos.google.datastore.admin.v1.ICreateIndexRequest, options?: CallOptions): Promise<[
        LROperation<protos.google.datastore.admin.v1.IIndex, protos.google.datastore.admin.v1.IIndexOperationMetadata>,
        protos.google.longrunning.IOperation | undefined,
        {} | undefined
    ]>;

Creates the specified index. A newly created index's initial state is CREATING. On completion of the returned , the state will be READY. If the index already exists, the call will return an ALREADY_EXISTS status.

During index creation, the process could result in an error, in which case the index will move to the ERROR state. The process can be recovered by fixing the data that caused the error, removing the index with , then re-creating the index with [create] [google.datastore.admin.v1.DatastoreAdmin.CreateIndex].

Indexes with a single property cannot be created.

Parameters
NameDescription
request protos.google.datastore.admin.v1.ICreateIndexRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ LROperation<google.datastore.admin.v1.IIndex, google.datastore.admin.v1.IIndexOperationMetadata>, google.longrunning.IOperation | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing a long running operation. Its promise() method returns a promise you can await for. Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Project ID against which to make the request.
   */
  // const projectId = 'abc123'
  /**
   *  The index to create. The name and state fields are output only and will be
   *  ignored. Single property indexes cannot be created or deleted.
   */
  // const index = {}

  // Imports the Admin library
  const {DatastoreAdminClient} = require('@google-cloud/datastore-admin').v1;

  // Instantiates a client
  const adminClient = new DatastoreAdminClient();

  async function callCreateIndex() {
    // Construct request
    const request = {
    };

    // Run request
    const [operation] = await adminClient.createIndex(request);
    const [response] = await operation.promise();
    console.log(response);
  }

  callCreateIndex();

createIndex(request, options, callback)

createIndex(request: protos.google.datastore.admin.v1.ICreateIndexRequest, options: CallOptions, callback: Callback<LROperation<protos.google.datastore.admin.v1.IIndex, protos.google.datastore.admin.v1.IIndexOperationMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.datastore.admin.v1.ICreateIndexRequest
options CallOptions
callback Callback<LROperation<google.datastore.admin.v1.IIndex, google.datastore.admin.v1.IIndexOperationMetadata>, google.longrunning.IOperation | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

createIndex(request, callback)

createIndex(request: protos.google.datastore.admin.v1.ICreateIndexRequest, callback: Callback<LROperation<protos.google.datastore.admin.v1.IIndex, protos.google.datastore.admin.v1.IIndexOperationMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.datastore.admin.v1.ICreateIndexRequest
callback Callback<LROperation<google.datastore.admin.v1.IIndex, google.datastore.admin.v1.IIndexOperationMetadata>, google.longrunning.IOperation | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

deleteIndex(request, options)

deleteIndex(request?: protos.google.datastore.admin.v1.IDeleteIndexRequest, options?: CallOptions): Promise<[
        LROperation<protos.google.datastore.admin.v1.IIndex, protos.google.datastore.admin.v1.IIndexOperationMetadata>,
        protos.google.longrunning.IOperation | undefined,
        {} | undefined
    ]>;

Deletes an existing index. An index can only be deleted if it is in a READY or ERROR state. On successful execution of the request, the index will be in a DELETING . And on completion of the returned , the index will be removed.

During index deletion, the process could result in an error, in which case the index will move to the ERROR state. The process can be recovered by fixing the data that caused the error, followed by calling again.

Parameters
NameDescription
request protos.google.datastore.admin.v1.IDeleteIndexRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ LROperation<google.datastore.admin.v1.IIndex, google.datastore.admin.v1.IIndexOperationMetadata>, google.longrunning.IOperation | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing a long running operation. Its promise() method returns a promise you can await for. Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Project ID against which to make the request.
   */
  // const projectId = 'abc123'
  /**
   *  The resource ID of the index to delete.
   */
  // const indexId = 'abc123'

  // Imports the Admin library
  const {DatastoreAdminClient} = require('@google-cloud/datastore-admin').v1;

  // Instantiates a client
  const adminClient = new DatastoreAdminClient();

  async function callDeleteIndex() {
    // Construct request
    const request = {
    };

    // Run request
    const [operation] = await adminClient.deleteIndex(request);
    const [response] = await operation.promise();
    console.log(response);
  }

  callDeleteIndex();

deleteIndex(request, options, callback)

deleteIndex(request: protos.google.datastore.admin.v1.IDeleteIndexRequest, options: CallOptions, callback: Callback<LROperation<protos.google.datastore.admin.v1.IIndex, protos.google.datastore.admin.v1.IIndexOperationMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.datastore.admin.v1.IDeleteIndexRequest
options CallOptions
callback Callback<LROperation<google.datastore.admin.v1.IIndex, google.datastore.admin.v1.IIndexOperationMetadata>, google.longrunning.IOperation | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

deleteIndex(request, callback)

deleteIndex(request: protos.google.datastore.admin.v1.IDeleteIndexRequest, callback: Callback<LROperation<protos.google.datastore.admin.v1.IIndex, protos.google.datastore.admin.v1.IIndexOperationMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.datastore.admin.v1.IDeleteIndexRequest
callback Callback<LROperation<google.datastore.admin.v1.IIndex, google.datastore.admin.v1.IIndexOperationMetadata>, google.longrunning.IOperation | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

deleteOperation(request, options, callback)

deleteOperation(request: protos.google.longrunning.DeleteOperationRequest, options?: gax.CallOptions | Callback<protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined>, callback?: Callback<protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined>): Promise<protos.google.protobuf.Empty>;

Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns google.rpc.Code.UNIMPLEMENTED.

Parameters
NameDescription
request protos.google.longrunning.DeleteOperationRequest

The request object that will be sent.

options CallOptions | Callback<google.protobuf.Empty, google.longrunning.DeleteOperationRequest, {} | null | undefined>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback Callback<google.protobuf.Empty, google.longrunning.DeleteOperationRequest, {} | null | undefined>

The function which will be called with the result of the API call. {Promise} - The promise which resolves when API call finishes. The promise has a method named "cancel" which cancels the ongoing API call.

Returns
TypeDescription
Promise<google.protobuf.Empty>
Example

const client = longrunning.operationsClient();
await client.deleteOperation({name: ''});

exportEntities(request, options)

exportEntities(request?: protos.google.datastore.admin.v1.IExportEntitiesRequest, options?: CallOptions): Promise<[
        LROperation<protos.google.datastore.admin.v1.IExportEntitiesResponse, protos.google.datastore.admin.v1.IExportEntitiesMetadata>,
        protos.google.longrunning.IOperation | undefined,
        {} | undefined
    ]>;

Exports a copy of all or a subset of entities from Google Cloud Datastore to another storage system, such as Google Cloud Storage. Recent updates to entities may not be reflected in the export. The export occurs in the background and its progress can be monitored and managed via the Operation resource that is created. The output of an export may only be used once the associated operation is done. If an export operation is cancelled before completion it may leave partial data behind in Google Cloud Storage.

Parameters
NameDescription
request protos.google.datastore.admin.v1.IExportEntitiesRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ LROperation<google.datastore.admin.v1.IExportEntitiesResponse, google.datastore.admin.v1.IExportEntitiesMetadata>, google.longrunning.IOperation | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing a long running operation. Its promise() method returns a promise you can await for. Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. Project ID against which to make the request.
   */
  // const projectId = 'abc123'
  /**
   *  Client-assigned labels.
   */
  // const labels = [1,2,3,4]
  /**
   *  Description of what data from the project is included in the export.
   */
  // const entityFilter = {}
  /**
   *  Required. Location for the export metadata and data files.
   *  The full resource URL of the external storage location. Currently, only
   *  Google Cloud Storage is supported. So output_url_prefix should be of the
   *  form: `gs://BUCKET_NAME/NAMESPACE_PATH`, where `BUCKET_NAME` is the
   *  name of the Cloud Storage bucket and `NAMESPACE_PATH` is an optional Cloud
   *  Storage namespace path (this is not a Cloud Datastore namespace). For more
   *  information about Cloud Storage namespace paths, see
   *  Object name
   *  considerations (https://cloud.google.com/storage/docs/naming#object-considerations).
   *  The resulting files will be nested deeper than the specified URL prefix.
   *  The final output URL will be provided in the
   *  google.datastore.admin.v1.ExportEntitiesResponse.output_url google.datastore.admin.v1.ExportEntitiesResponse.output_url 
   *  field. That value should be used for subsequent ImportEntities operations.
   *  By nesting the data files deeper, the same Cloud Storage bucket can be used
   *  in multiple ExportEntities operations without conflict.
   */
  // const outputUrlPrefix = 'abc123'

  // Imports the Admin library
  const {DatastoreAdminClient} = require('@google-cloud/datastore-admin').v1;

  // Instantiates a client
  const adminClient = new DatastoreAdminClient();

  async function callExportEntities() {
    // Construct request
    const request = {
      projectId,
      outputUrlPrefix,
    };

    // Run request
    const [operation] = await adminClient.exportEntities(request);
    const [response] = await operation.promise();
    console.log(response);
  }

  callExportEntities();

exportEntities(request, options, callback)

exportEntities(request: protos.google.datastore.admin.v1.IExportEntitiesRequest, options: CallOptions, callback: Callback<LROperation<protos.google.datastore.admin.v1.IExportEntitiesResponse, protos.google.datastore.admin.v1.IExportEntitiesMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.datastore.admin.v1.IExportEntitiesRequest
options CallOptions
callback Callback<LROperation<google.datastore.admin.v1.IExportEntitiesResponse, google.datastore.admin.v1.IExportEntitiesMetadata>, google.longrunning.IOperation | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

exportEntities(request, callback)

exportEntities(request: protos.google.datastore.admin.v1.IExportEntitiesRequest, callback: Callback<LROperation<protos.google.datastore.admin.v1.IExportEntitiesResponse, protos.google.datastore.admin.v1.IExportEntitiesMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.datastore.admin.v1.IExportEntitiesRequest
callback Callback<LROperation<google.datastore.admin.v1.IExportEntitiesResponse, google.datastore.admin.v1.IExportEntitiesMetadata>, google.longrunning.IOperation | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getIndex(request, options)

getIndex(request?: protos.google.datastore.admin.v1.IGetIndexRequest, options?: CallOptions): Promise<[
        protos.google.datastore.admin.v1.IIndex,
        protos.google.datastore.admin.v1.IGetIndexRequest | undefined,
        {} | undefined
    ]>;

Gets an index.

Parameters
NameDescription
request protos.google.datastore.admin.v1.IGetIndexRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ google.datastore.admin.v1.IIndex, google.datastore.admin.v1.IGetIndexRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Project ID against which to make the request.
   */
  // const projectId = 'abc123'
  /**
   *  The resource ID of the index to get.
   */
  // const indexId = 'abc123'

  // Imports the Admin library
  const {DatastoreAdminClient} = require('@google-cloud/datastore-admin').v1;

  // Instantiates a client
  const adminClient = new DatastoreAdminClient();

  async function callGetIndex() {
    // Construct request
    const request = {
    };

    // Run request
    const response = await adminClient.getIndex(request);
    console.log(response);
  }

  callGetIndex();

getIndex(request, options, callback)

getIndex(request: protos.google.datastore.admin.v1.IGetIndexRequest, options: CallOptions, callback: Callback<protos.google.datastore.admin.v1.IIndex, protos.google.datastore.admin.v1.IGetIndexRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.datastore.admin.v1.IGetIndexRequest
options CallOptions
callback Callback<google.datastore.admin.v1.IIndex, google.datastore.admin.v1.IGetIndexRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getIndex(request, callback)

getIndex(request: protos.google.datastore.admin.v1.IGetIndexRequest, callback: Callback<protos.google.datastore.admin.v1.IIndex, protos.google.datastore.admin.v1.IGetIndexRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.datastore.admin.v1.IGetIndexRequest
callback Callback<google.datastore.admin.v1.IIndex, google.datastore.admin.v1.IGetIndexRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getOperation(request, options, callback)

getOperation(request: protos.google.longrunning.GetOperationRequest, options?: gax.CallOptions | Callback<protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined>, callback?: Callback<protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined>): Promise<[protos.google.longrunning.Operation]>;

Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.

Parameters
NameDescription
request protos.google.longrunning.GetOperationRequest

The request object that will be sent.

options CallOptions | Callback<google.longrunning.Operation, google.longrunning.GetOperationRequest, {} | null | undefined>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback Callback<google.longrunning.Operation, google.longrunning.GetOperationRequest, {} | null | undefined>

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing . {Promise} - The promise which resolves to an array. The first element of the array is an object representing . The promise has a method named "cancel" which cancels the ongoing API call.

Returns
TypeDescription
Promise<[google.longrunning.Operation]>
Example

const client = longrunning.operationsClient();
const name = '';
const [response] = await client.getOperation({name});
// doThingsWith(response)

getProjectId()

getProjectId(): Promise<string>;
Returns
TypeDescription
Promise<string>

getProjectId(callback)

getProjectId(callback: Callback<string, undefined, undefined>): void;
Parameter
NameDescription
callback Callback<string, undefined, undefined>
Returns
TypeDescription
void

importEntities(request, options)

importEntities(request?: protos.google.datastore.admin.v1.IImportEntitiesRequest, options?: CallOptions): Promise<[
        LROperation<protos.google.protobuf.IEmpty, protos.google.datastore.admin.v1.IImportEntitiesMetadata>,
        protos.google.longrunning.IOperation | undefined,
        {} | undefined
    ]>;

Imports entities into Google Cloud Datastore. Existing entities with the same key are overwritten. The import occurs in the background and its progress can be monitored and managed via the Operation resource that is created. If an ImportEntities operation is cancelled, it is possible that a subset of the data has already been imported to Cloud Datastore.

Parameters
NameDescription
request protos.google.datastore.admin.v1.IImportEntitiesRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ LROperation<google.protobuf.IEmpty, google.datastore.admin.v1.IImportEntitiesMetadata>, google.longrunning.IOperation | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing a long running operation. Its promise() method returns a promise you can await for. Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. Project ID against which to make the request.
   */
  // const projectId = 'abc123'
  /**
   *  Client-assigned labels.
   */
  // const labels = [1,2,3,4]
  /**
   *  Required. The full resource URL of the external storage location.
   *  Currently, only Google Cloud Storage is supported. So input_url should be
   *  of the form:
   *  `gs://BUCKET_NAME[/NAMESPACE_PATH]/OVERALL_EXPORT_METADATA_FILE`, where
   *  `BUCKET_NAME` is the name of the Cloud Storage bucket, `NAMESPACE_PATH` is
   *  an optional Cloud Storage namespace path (this is not a Cloud Datastore
   *  namespace), and `OVERALL_EXPORT_METADATA_FILE` is the metadata file written
   *  by the ExportEntities operation. For more information about Cloud Storage
   *  namespace paths, see
   *  Object name
   *  considerations (https://cloud.google.com/storage/docs/naming#object-considerations).
   *  For more information, see
   *  google.datastore.admin.v1.ExportEntitiesResponse.output_url google.datastore.admin.v1.ExportEntitiesResponse.output_url.
   */
  // const inputUrl = 'abc123'
  /**
   *  Optionally specify which kinds/namespaces are to be imported. If provided,
   *  the list must be a subset of the EntityFilter used in creating the export,
   *  otherwise a FAILED_PRECONDITION error will be returned. If no filter is
   *  specified then all entities from the export are imported.
   */
  // const entityFilter = {}

  // Imports the Admin library
  const {DatastoreAdminClient} = require('@google-cloud/datastore-admin').v1;

  // Instantiates a client
  const adminClient = new DatastoreAdminClient();

  async function callImportEntities() {
    // Construct request
    const request = {
      projectId,
      inputUrl,
    };

    // Run request
    const [operation] = await adminClient.importEntities(request);
    const [response] = await operation.promise();
    console.log(response);
  }

  callImportEntities();

importEntities(request, options, callback)

importEntities(request: protos.google.datastore.admin.v1.IImportEntitiesRequest, options: CallOptions, callback: Callback<LROperation<protos.google.protobuf.IEmpty, protos.google.datastore.admin.v1.IImportEntitiesMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.datastore.admin.v1.IImportEntitiesRequest
options CallOptions
callback Callback<LROperation<google.protobuf.IEmpty, google.datastore.admin.v1.IImportEntitiesMetadata>, google.longrunning.IOperation | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

importEntities(request, callback)

importEntities(request: protos.google.datastore.admin.v1.IImportEntitiesRequest, callback: Callback<LROperation<protos.google.protobuf.IEmpty, protos.google.datastore.admin.v1.IImportEntitiesMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.datastore.admin.v1.IImportEntitiesRequest
callback Callback<LROperation<google.protobuf.IEmpty, google.datastore.admin.v1.IImportEntitiesMetadata>, google.longrunning.IOperation | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

initialize()

initialize(): Promise<{
        [name: string]: Function;
    }>;

Initialize the client. Performs asynchronous operations (such as authentication) and prepares the client. This function will be called automatically when any class method is called for the first time, but if you need to initialize it before calling an actual method, feel free to call initialize() directly.

You can await on this method if you want to make sure the client is initialized.

Returns
TypeDescription
Promise<{ [name: string]: Function; }>

{Promise} A promise that resolves to an authenticated service stub.

listIndexes(request, options)

listIndexes(request?: protos.google.datastore.admin.v1.IListIndexesRequest, options?: CallOptions): Promise<[
        protos.google.datastore.admin.v1.IIndex[],
        protos.google.datastore.admin.v1.IListIndexesRequest | null,
        protos.google.datastore.admin.v1.IListIndexesResponse
    ]>;

Lists the indexes that match the specified filters. Datastore uses an eventually consistent query to fetch the list of indexes and may occasionally return stale results.

Parameters
NameDescription
request protos.google.datastore.admin.v1.IListIndexesRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ google.datastore.admin.v1.IIndex[], google.datastore.admin.v1.IListIndexesRequest | null, google.datastore.admin.v1.IListIndexesResponse ]>

{Promise} - The promise which resolves to an array. The first element of the array is Array of . The client library will perform auto-pagination by default: it will call the API as many times as needed and will merge results from all the pages into this array. Note that it can affect your quota. We recommend using listIndexesAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listIndexes(request, options, callback)

listIndexes(request: protos.google.datastore.admin.v1.IListIndexesRequest, options: CallOptions, callback: PaginationCallback<protos.google.datastore.admin.v1.IListIndexesRequest, protos.google.datastore.admin.v1.IListIndexesResponse | null | undefined, protos.google.datastore.admin.v1.IIndex>): void;
Parameters
NameDescription
request protos.google.datastore.admin.v1.IListIndexesRequest
options CallOptions
callback PaginationCallback<google.datastore.admin.v1.IListIndexesRequest, google.datastore.admin.v1.IListIndexesResponse | null | undefined, google.datastore.admin.v1.IIndex>
Returns
TypeDescription
void

listIndexes(request, callback)

listIndexes(request: protos.google.datastore.admin.v1.IListIndexesRequest, callback: PaginationCallback<protos.google.datastore.admin.v1.IListIndexesRequest, protos.google.datastore.admin.v1.IListIndexesResponse | null | undefined, protos.google.datastore.admin.v1.IIndex>): void;
Parameters
NameDescription
request protos.google.datastore.admin.v1.IListIndexesRequest
callback PaginationCallback<google.datastore.admin.v1.IListIndexesRequest, google.datastore.admin.v1.IListIndexesResponse | null | undefined, google.datastore.admin.v1.IIndex>
Returns
TypeDescription
void

listIndexesAsync(request, options)

listIndexesAsync(request?: protos.google.datastore.admin.v1.IListIndexesRequest, options?: CallOptions): AsyncIterable<protos.google.datastore.admin.v1.IIndex>;

Equivalent to listIndexes, but returns an iterable object.

for-await-of syntax is used with the iterable to get response elements on-demand.

Parameters
NameDescription
request protos.google.datastore.admin.v1.IListIndexesRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
AsyncIterable<google.datastore.admin.v1.IIndex>

{Object} An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing . The API will be called under the hood as needed, once per the page, so you can stop the iteration when you don't need more results. Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Project ID against which to make the request.
   */
  // const projectId = 'abc123'
  /**
   */
  // const filter = 'abc123'
  /**
   *  The maximum number of items to return.  If zero, then all results will be
   *  returned.
   */
  // const pageSize = 1234
  /**
   *  The next_page_token value returned from a previous List request, if any.
   */
  // const pageToken = 'abc123'

  // Imports the Admin library
  const {DatastoreAdminClient} = require('@google-cloud/datastore-admin').v1;

  // Instantiates a client
  const adminClient = new DatastoreAdminClient();

  async function callListIndexes() {
    // Construct request
    const request = {
    };

    // Run request
    const iterable = adminClient.listIndexesAsync(request);
    for await (const response of iterable) {
        console.log(response);
    }
  }

  callListIndexes();

listIndexesStream(request, options)

listIndexesStream(request?: protos.google.datastore.admin.v1.IListIndexesRequest, options?: CallOptions): Transform;

Equivalent to method.name.toCamelCase(), but returns a NodeJS Stream object.

Parameters
NameDescription
request protos.google.datastore.admin.v1.IListIndexesRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Transform

{Stream} An object stream which emits an object representing on 'data' event. The client library will perform auto-pagination by default: it will call the API as many times as needed. Note that it can affect your quota. We recommend using listIndexesAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listOperationsAsync(request, options)

listOperationsAsync(request: protos.google.longrunning.ListOperationsRequest, options?: gax.CallOptions): AsyncIterable<protos.google.longrunning.ListOperationsResponse>;

Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns UNIMPLEMENTED. Returns an iterable object.

For-await-of syntax is used with the iterable to recursively get response element on-demand.

Parameters
NameDescription
request protos.google.longrunning.ListOperationsRequest

The request object that will be sent.

options CallOptions

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

Returns
TypeDescription
AsyncIterable<google.longrunning.ListOperationsResponse>

{Object} An iterable Object that conforms to iteration protocols.

Example

const client = longrunning.operationsClient();
for await (const response of client.listOperationsAsync(request));
// doThingsWith(response)