DatastoreAdminClient

DatastoreAdminClient

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).


Services

Export/Import

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

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

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.

Constructor

new DatastoreAdminClient(optionsopt)

Construct an instance of DatastoreAdminClient.

Parameters:
Name Type Attributes Description
options object <optional>

The configuration object. See the subsequent parameters for more details.

Properties
Name Type Attributes Description
credentials object <optional>

Credentials object.

Properties
Name Type Attributes Description
client_email string <optional>
private_key string <optional>
email string <optional>

Account email address. Required when using a .pem or .p12 keyFilename.

keyFilename string <optional>

Full path to the a .json, .pem, or .p12 key downloaded from the Google Developers Console. If you provide a path to a JSON file, the projectId option below is not necessary. NOTE: .pem and .p12 require you to specify options.email as well.

port number <optional>

The port on which to connect to the remote host.

projectId string <optional>

The project ID from the Google Developer's Console, e.g. 'grape-spaceship-123'. We will also check the environment variable GCLOUD_PROJECT for your project ID. If your app is running in an environment which supports Application Default Credentials, your project ID will be detected automatically.

apiEndpoint string <optional>

The domain name of the API remote host.

Members

(static) apiEndpoint

The DNS address for this API service - same as servicePath(), exists for compatibility reasons.

(static) port

The port for this API service.

(static) scopes

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

(static) servicePath

The DNS address for this API service.

Methods

(async) checkExportEntitiesProgress(name) → {Promise}

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

Parameters:
Name Type Description
name String

The operation name that will be passed.

(async) checkImportEntitiesProgress(name) → {Promise}

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

Parameters:
Name Type Description
name String

The operation name that will be passed.

close()

Terminate the GRPC channel and close the client.

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

exportEntities(request, optionsopt) → {Promise}

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:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
projectId string

Required. Project ID against which to make the request.

labels Array.<number>

Client-assigned labels.

entityFilter google.datastore.admin.v1.EntityFilter

Description of what data from the project is included in the export.

outputUrlPrefix string

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.

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 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.

options object <optional>

Call options. See CallOptions for more details.

getIndex(request, optionsopt) → {Promise}

Gets an index.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
projectId string

Project ID against which to make the request.

indexId string

The resource ID of the index to get.

options object <optional>

Call options. See CallOptions for more details.

getProjectId(callback)

Return the project ID used by this class.

Parameters:
Name Type Description
callback function

the callback to be called with the current project Id.

importEntities(request, optionsopt) → {Promise}

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:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
projectId string

Required. Project ID against which to make the request.

labels Array.<number>

Client-assigned labels.

inputUrl string

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.

For more information, see google.datastore.admin.v1.ExportEntitiesResponse.output_url.

entityFilter google.datastore.admin.v1.EntityFilter

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.

options object <optional>

Call options. See CallOptions for more details.

initialize() → {Promise}

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.

listIndexes(request, optionsopt) → {Promise}

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:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
projectId string

Project ID against which to make the request.

filter string
pageSize number

The maximum number of items to return. If zero, then all results will be returned.

pageToken string

The next_page_token value returned from a previous List request, if any.

options object <optional>

Call options. See CallOptions for more details.

listIndexesAsync(request, optionsopt) → {Object}

Equivalent to listIndexes, but returns an iterable object.

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

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
projectId string

Project ID against which to make the request.

filter string
pageSize number

The maximum number of items to return. If zero, then all results will be returned.

pageToken string

The next_page_token value returned from a previous List request, if any.

options object <optional>

Call options. See CallOptions for more details.

listIndexesStream(request, optionsopt) → {Stream}

Equivalent to listIndexes, but returns a NodeJS Stream object.

This fetches the paged responses for listIndexes continuously and invokes the callback registered for 'data' event for each element in the responses.

The returned object has 'end' method when no more elements are required.

autoPaginate option will be ignored.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
projectId string

Project ID against which to make the request.

filter string
pageSize number

The maximum number of items to return. If zero, then all results will be returned.

pageToken string

The next_page_token value returned from a previous List request, if any.

options object <optional>

Call options. See CallOptions for more details.

See: