Class DatastoreAdminClient
- All Implemented Interfaces:
com.google.api.gax.core.BackgroundResource
,AutoCloseable
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.
This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:
// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.create()) {
GetIndexRequest request =
GetIndexRequest.newBuilder()
.setProjectId("projectId-894832108")
.setIndexId("indexId1943291277")
.build();
Index response = datastoreAdminClient.getIndex(request);
}
Note: close() needs to be called on the DatastoreAdminClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
Method | Description | Method Variants |
---|---|---|
ExportEntities |
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. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ImportEntities |
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. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
CreateIndex |
Creates the specified index. A newly created index's initial state is `CREATING`. On completion of the returned [google.longrunning.Operation][google.longrunning.Operation], 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 [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex], then re-creating the index with [create] [google.datastore.admin.v1.DatastoreAdmin.CreateIndex]. Indexes with a single property cannot be created. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
DeleteIndex |
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` [state][google.datastore.admin.v1.Index.State]. And on completion of the returned [google.longrunning.Operation][google.longrunning.Operation], 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 [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex] again. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetIndex |
Gets an index. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ListIndexes |
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. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
See the individual methods for example code.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.
This class can be customized by passing in a custom instance of DatastoreAdminSettings to create(). For example:
To customize credentials:
// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
DatastoreAdminSettings datastoreAdminSettings =
DatastoreAdminSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.create(datastoreAdminSettings);
To customize the endpoint:
// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
DatastoreAdminSettings datastoreAdminSettings =
DatastoreAdminSettings.newBuilder().setEndpoint(myEndpoint).build();
DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.create(datastoreAdminSettings);
To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over the wire:
// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
DatastoreAdminSettings datastoreAdminSettings =
DatastoreAdminSettings.newHttpJsonBuilder().build();
DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.create(datastoreAdminSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static class
static class
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
DatastoreAdminClient
(DatastoreAdminSettings settings) Constructs an instance of DatastoreAdminClient, using the given settings.protected
-
Method Summary
Modifier and TypeMethodDescriptionboolean
awaitTermination
(long duration, TimeUnit unit) final void
close()
static final DatastoreAdminClient
create()
Constructs an instance of DatastoreAdminClient with default settings.static final DatastoreAdminClient
create
(DatastoreAdminSettings settings) Constructs an instance of DatastoreAdminClient, using the given settings.static final DatastoreAdminClient
create
(DatastoreAdminStub stub) Constructs an instance of DatastoreAdminClient, using the given stub for making calls.final com.google.api.gax.longrunning.OperationFuture<Index,
IndexOperationMetadata> createIndexAsync
(CreateIndexRequest request) Creates the specified index.final com.google.api.gax.rpc.UnaryCallable<CreateIndexRequest,
com.google.longrunning.Operation> Creates the specified index.final com.google.api.gax.rpc.OperationCallable<CreateIndexRequest,
Index, IndexOperationMetadata> Creates the specified index.final com.google.api.gax.longrunning.OperationFuture<Index,
IndexOperationMetadata> deleteIndexAsync
(DeleteIndexRequest request) Deletes an existing index.final com.google.api.gax.rpc.UnaryCallable<DeleteIndexRequest,
com.google.longrunning.Operation> Deletes an existing index.final com.google.api.gax.rpc.OperationCallable<DeleteIndexRequest,
Index, IndexOperationMetadata> Deletes an existing index.final com.google.api.gax.longrunning.OperationFuture<ExportEntitiesResponse,
ExportEntitiesMetadata> exportEntitiesAsync
(ExportEntitiesRequest request) Exports a copy of all or a subset of entities from Google Cloud Datastore to another storage system, such as Google Cloud Storage.final com.google.api.gax.longrunning.OperationFuture<ExportEntitiesResponse,
ExportEntitiesMetadata> exportEntitiesAsync
(String projectId, Map<String, String> labels, EntityFilter entityFilter, String outputUrlPrefix) Exports a copy of all or a subset of entities from Google Cloud Datastore to another storage system, such as Google Cloud Storage.final com.google.api.gax.rpc.UnaryCallable<ExportEntitiesRequest,
com.google.longrunning.Operation> Exports a copy of all or a subset of entities from Google Cloud Datastore to another storage system, such as Google Cloud Storage.final com.google.api.gax.rpc.OperationCallable<ExportEntitiesRequest,
ExportEntitiesResponse, ExportEntitiesMetadata> Exports a copy of all or a subset of entities from Google Cloud Datastore to another storage system, such as Google Cloud Storage.final com.google.api.gax.httpjson.longrunning.OperationsClient
Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.final Index
getIndex
(GetIndexRequest request) Gets an index.final com.google.api.gax.rpc.UnaryCallable<GetIndexRequest,
Index> Gets an index.final com.google.longrunning.OperationsClient
Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.final DatastoreAdminSettings
getStub()
final com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,
ImportEntitiesMetadata> importEntitiesAsync
(ImportEntitiesRequest request) Imports entities into Google Cloud Datastore.final com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,
ImportEntitiesMetadata> importEntitiesAsync
(String projectId, Map<String, String> labels, String inputUrl, EntityFilter entityFilter) Imports entities into Google Cloud Datastore.final com.google.api.gax.rpc.UnaryCallable<ImportEntitiesRequest,
com.google.longrunning.Operation> Imports entities into Google Cloud Datastore.final com.google.api.gax.rpc.OperationCallable<ImportEntitiesRequest,
com.google.protobuf.Empty, ImportEntitiesMetadata> Imports entities into Google Cloud Datastore.boolean
boolean
listIndexes
(ListIndexesRequest request) Lists the indexes that match the specified filters.final com.google.api.gax.rpc.UnaryCallable<ListIndexesRequest,
ListIndexesResponse> Lists the indexes that match the specified filters.final com.google.api.gax.rpc.UnaryCallable<ListIndexesRequest,
DatastoreAdminClient.ListIndexesPagedResponse> Lists the indexes that match the specified filters.void
shutdown()
void
-
Constructor Details
-
DatastoreAdminClient
Constructs an instance of DatastoreAdminClient, using the given settings. This is protected so that it is easy to make a subclass, but otherwise, the static factory methods should be preferred.- Throws:
IOException
-
DatastoreAdminClient
-
-
Method Details
-
create
Constructs an instance of DatastoreAdminClient with default settings.- Throws:
IOException
-
create
Constructs an instance of DatastoreAdminClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.- Throws:
IOException
-
create
Constructs an instance of DatastoreAdminClient, using the given stub for making calls. This is for advanced usage - prefer using create(DatastoreAdminSettings). -
getSettings
-
getStub
-
getOperationsClient
public final com.google.longrunning.OperationsClient getOperationsClient()Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call. -
getHttpJsonOperationsClient
@BetaApi public final com.google.api.gax.httpjson.longrunning.OperationsClient getHttpJsonOperationsClient()Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call. -
exportEntitiesAsync
public final com.google.api.gax.longrunning.OperationFuture<ExportEntitiesResponse,ExportEntitiesMetadata> exportEntitiesAsync(String projectId, Map<String, String> labels, EntityFilter entityFilter, String outputUrlPrefix) 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.Sample code:
// 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. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.create()) { String projectId = "projectId-894832108"; Map<String, String> labels = new HashMap<>(); EntityFilter entityFilter = EntityFilter.newBuilder().build(); String outputUrlPrefix = "outputUrlPrefix-1132598048"; ExportEntitiesResponse response = datastoreAdminClient .exportEntitiesAsync(projectId, labels, entityFilter, outputUrlPrefix) .get(); }
- Parameters:
projectId
- Required. Project ID against which to make the request.labels
- Client-assigned labels.entityFilter
- Description of what data from the project is included in the export.outputUrlPrefix
- 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.
- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
exportEntitiesAsync
public final com.google.api.gax.longrunning.OperationFuture<ExportEntitiesResponse,ExportEntitiesMetadata> exportEntitiesAsync(ExportEntitiesRequest request) 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.Sample code:
// 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. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.create()) { ExportEntitiesRequest request = ExportEntitiesRequest.newBuilder() .setProjectId("projectId-894832108") .putAllLabels(new HashMap<String, String>()) .setEntityFilter(EntityFilter.newBuilder().build()) .setOutputUrlPrefix("outputUrlPrefix-1132598048") .build(); ExportEntitiesResponse response = datastoreAdminClient.exportEntitiesAsync(request).get(); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
exportEntitiesOperationCallable
public final com.google.api.gax.rpc.OperationCallable<ExportEntitiesRequest,ExportEntitiesResponse, exportEntitiesOperationCallable()ExportEntitiesMetadata> 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.Sample code:
// 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. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.create()) { ExportEntitiesRequest request = ExportEntitiesRequest.newBuilder() .setProjectId("projectId-894832108") .putAllLabels(new HashMap<String, String>()) .setEntityFilter(EntityFilter.newBuilder().build()) .setOutputUrlPrefix("outputUrlPrefix-1132598048") .build(); OperationFuture<ExportEntitiesResponse, ExportEntitiesMetadata> future = datastoreAdminClient.exportEntitiesOperationCallable().futureCall(request); // Do something. ExportEntitiesResponse response = future.get(); }
-
exportEntitiesCallable
public final com.google.api.gax.rpc.UnaryCallable<ExportEntitiesRequest,com.google.longrunning.Operation> exportEntitiesCallable()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.Sample code:
// 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. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.create()) { ExportEntitiesRequest request = ExportEntitiesRequest.newBuilder() .setProjectId("projectId-894832108") .putAllLabels(new HashMap<String, String>()) .setEntityFilter(EntityFilter.newBuilder().build()) .setOutputUrlPrefix("outputUrlPrefix-1132598048") .build(); ApiFuture<Operation> future = datastoreAdminClient.exportEntitiesCallable().futureCall(request); // Do something. Operation response = future.get(); }
-
importEntitiesAsync
public final com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,ImportEntitiesMetadata> importEntitiesAsync(String projectId, Map<String, String> labels, String inputUrl, EntityFilter entityFilter) 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.Sample code:
// 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. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.create()) { String projectId = "projectId-894832108"; Map<String, String> labels = new HashMap<>(); String inputUrl = "inputUrl470706501"; EntityFilter entityFilter = EntityFilter.newBuilder().build(); datastoreAdminClient.importEntitiesAsync(projectId, labels, inputUrl, entityFilter).get(); }
- Parameters:
projectId
- Required. Project ID against which to make the request.labels
- Client-assigned labels.inputUrl
- 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].
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.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
importEntitiesAsync
public final com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,ImportEntitiesMetadata> importEntitiesAsync(ImportEntitiesRequest request) 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.Sample code:
// 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. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.create()) { ImportEntitiesRequest request = ImportEntitiesRequest.newBuilder() .setProjectId("projectId-894832108") .putAllLabels(new HashMap<String, String>()) .setInputUrl("inputUrl470706501") .setEntityFilter(EntityFilter.newBuilder().build()) .build(); datastoreAdminClient.importEntitiesAsync(request).get(); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
importEntitiesOperationCallable
public final com.google.api.gax.rpc.OperationCallable<ImportEntitiesRequest,com.google.protobuf.Empty, importEntitiesOperationCallable()ImportEntitiesMetadata> 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.Sample code:
// 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. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.create()) { ImportEntitiesRequest request = ImportEntitiesRequest.newBuilder() .setProjectId("projectId-894832108") .putAllLabels(new HashMap<String, String>()) .setInputUrl("inputUrl470706501") .setEntityFilter(EntityFilter.newBuilder().build()) .build(); OperationFuture<Empty, ImportEntitiesMetadata> future = datastoreAdminClient.importEntitiesOperationCallable().futureCall(request); // Do something. future.get(); }
-
importEntitiesCallable
public final com.google.api.gax.rpc.UnaryCallable<ImportEntitiesRequest,com.google.longrunning.Operation> importEntitiesCallable()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.Sample code:
// 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. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.create()) { ImportEntitiesRequest request = ImportEntitiesRequest.newBuilder() .setProjectId("projectId-894832108") .putAllLabels(new HashMap<String, String>()) .setInputUrl("inputUrl470706501") .setEntityFilter(EntityFilter.newBuilder().build()) .build(); ApiFuture<Operation> future = datastoreAdminClient.importEntitiesCallable().futureCall(request); // Do something. future.get(); }
-
createIndexAsync
public final com.google.api.gax.longrunning.OperationFuture<Index,IndexOperationMetadata> createIndexAsync(CreateIndexRequest request) Creates the specified index. A newly created index's initial state is `CREATING`. On completion of the returned [google.longrunning.Operation][google.longrunning.Operation], 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 [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex], then re-creating the index with [create] [google.datastore.admin.v1.DatastoreAdmin.CreateIndex].
Indexes with a single property cannot be created.
Sample code:
// 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. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.create()) { CreateIndexRequest request = CreateIndexRequest.newBuilder() .setProjectId("projectId-894832108") .setIndex(Index.newBuilder().build()) .build(); Index response = datastoreAdminClient.createIndexAsync(request).get(); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
createIndexOperationCallable
public final com.google.api.gax.rpc.OperationCallable<CreateIndexRequest,Index, createIndexOperationCallable()IndexOperationMetadata> Creates the specified index. A newly created index's initial state is `CREATING`. On completion of the returned [google.longrunning.Operation][google.longrunning.Operation], 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 [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex], then re-creating the index with [create] [google.datastore.admin.v1.DatastoreAdmin.CreateIndex].
Indexes with a single property cannot be created.
Sample code:
// 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. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.create()) { CreateIndexRequest request = CreateIndexRequest.newBuilder() .setProjectId("projectId-894832108") .setIndex(Index.newBuilder().build()) .build(); OperationFuture<Index, IndexOperationMetadata> future = datastoreAdminClient.createIndexOperationCallable().futureCall(request); // Do something. Index response = future.get(); }
-
createIndexCallable
public final com.google.api.gax.rpc.UnaryCallable<CreateIndexRequest,com.google.longrunning.Operation> createIndexCallable()Creates the specified index. A newly created index's initial state is `CREATING`. On completion of the returned [google.longrunning.Operation][google.longrunning.Operation], 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 [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex], then re-creating the index with [create] [google.datastore.admin.v1.DatastoreAdmin.CreateIndex].
Indexes with a single property cannot be created.
Sample code:
// 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. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.create()) { CreateIndexRequest request = CreateIndexRequest.newBuilder() .setProjectId("projectId-894832108") .setIndex(Index.newBuilder().build()) .build(); ApiFuture<Operation> future = datastoreAdminClient.createIndexCallable().futureCall(request); // Do something. Operation response = future.get(); }
-
deleteIndexAsync
public final com.google.api.gax.longrunning.OperationFuture<Index,IndexOperationMetadata> deleteIndexAsync(DeleteIndexRequest request) 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` [state][google.datastore.admin.v1.Index.State]. And on completion of the returned [google.longrunning.Operation][google.longrunning.Operation], 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 [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex] again.
Sample code:
// 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. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.create()) { DeleteIndexRequest request = DeleteIndexRequest.newBuilder() .setProjectId("projectId-894832108") .setIndexId("indexId1943291277") .build(); Index response = datastoreAdminClient.deleteIndexAsync(request).get(); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
deleteIndexOperationCallable
public final com.google.api.gax.rpc.OperationCallable<DeleteIndexRequest,Index, deleteIndexOperationCallable()IndexOperationMetadata> 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` [state][google.datastore.admin.v1.Index.State]. And on completion of the returned [google.longrunning.Operation][google.longrunning.Operation], 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 [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex] again.
Sample code:
// 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. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.create()) { DeleteIndexRequest request = DeleteIndexRequest.newBuilder() .setProjectId("projectId-894832108") .setIndexId("indexId1943291277") .build(); OperationFuture<Index, IndexOperationMetadata> future = datastoreAdminClient.deleteIndexOperationCallable().futureCall(request); // Do something. Index response = future.get(); }
-
deleteIndexCallable
public final com.google.api.gax.rpc.UnaryCallable<DeleteIndexRequest,com.google.longrunning.Operation> deleteIndexCallable()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` [state][google.datastore.admin.v1.Index.State]. And on completion of the returned [google.longrunning.Operation][google.longrunning.Operation], 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 [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex] again.
Sample code:
// 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. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.create()) { DeleteIndexRequest request = DeleteIndexRequest.newBuilder() .setProjectId("projectId-894832108") .setIndexId("indexId1943291277") .build(); ApiFuture<Operation> future = datastoreAdminClient.deleteIndexCallable().futureCall(request); // Do something. Operation response = future.get(); }
-
getIndex
Gets an index.Sample code:
// 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. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.create()) { GetIndexRequest request = GetIndexRequest.newBuilder() .setProjectId("projectId-894832108") .setIndexId("indexId1943291277") .build(); Index response = datastoreAdminClient.getIndex(request); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
getIndexCallable
Gets an index.Sample code:
// 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. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.create()) { GetIndexRequest request = GetIndexRequest.newBuilder() .setProjectId("projectId-894832108") .setIndexId("indexId1943291277") .build(); ApiFuture<Index> future = datastoreAdminClient.getIndexCallable().futureCall(request); // Do something. Index response = future.get(); }
-
listIndexes
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.Sample code:
// 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. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.create()) { ListIndexesRequest request = ListIndexesRequest.newBuilder() .setProjectId("projectId-894832108") .setFilter("filter-1274492040") .setPageSize(883849137) .setPageToken("pageToken873572522") .build(); for (Index element : datastoreAdminClient.listIndexes(request).iterateAll()) { // doThingsWith(element); } }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
listIndexesPagedCallable
public final com.google.api.gax.rpc.UnaryCallable<ListIndexesRequest,DatastoreAdminClient.ListIndexesPagedResponse> listIndexesPagedCallable()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.Sample code:
// 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. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.create()) { ListIndexesRequest request = ListIndexesRequest.newBuilder() .setProjectId("projectId-894832108") .setFilter("filter-1274492040") .setPageSize(883849137) .setPageToken("pageToken873572522") .build(); ApiFuture<Index> future = datastoreAdminClient.listIndexesPagedCallable().futureCall(request); // Do something. for (Index element : future.get().iterateAll()) { // doThingsWith(element); } }
-
listIndexesCallable
public final com.google.api.gax.rpc.UnaryCallable<ListIndexesRequest,ListIndexesResponse> listIndexesCallable()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.Sample code:
// 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. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.create()) { ListIndexesRequest request = ListIndexesRequest.newBuilder() .setProjectId("projectId-894832108") .setFilter("filter-1274492040") .setPageSize(883849137) .setPageToken("pageToken873572522") .build(); while (true) { ListIndexesResponse response = datastoreAdminClient.listIndexesCallable().call(request); for (Index element : response.getIndexesList()) { // doThingsWith(element); } String nextPageToken = response.getNextPageToken(); if (!Strings.isNullOrEmpty(nextPageToken)) { request = request.toBuilder().setPageToken(nextPageToken).build(); } else { break; } } }
-
close
public final void close()- Specified by:
close
in interfaceAutoCloseable
-
shutdown
public void shutdown()- Specified by:
shutdown
in interfacecom.google.api.gax.core.BackgroundResource
-
isShutdown
public boolean isShutdown()- Specified by:
isShutdown
in interfacecom.google.api.gax.core.BackgroundResource
-
isTerminated
public boolean isTerminated()- Specified by:
isTerminated
in interfacecom.google.api.gax.core.BackgroundResource
-
shutdownNow
public void shutdownNow()- Specified by:
shutdownNow
in interfacecom.google.api.gax.core.BackgroundResource
-
awaitTermination
- Specified by:
awaitTermination
in interfacecom.google.api.gax.core.BackgroundResource
- Throws:
InterruptedException
-