GitHub Repository | Product Reference |
Service Description: 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.
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
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
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 During index creation, the process could result in an error, in which case the index will move to the 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 During index deletion, the process could result in an error, in which case the index will move to the |
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.
Static Methods
create()
public static final DatastoreAdminClient create()
Constructs an instance of DatastoreAdminClient with default settings.
Returns | |
---|---|
Type | Description |
DatastoreAdminClient |
Exceptions | |
---|---|
Type | Description |
IOException |
create(DatastoreAdminSettings settings)
public static final DatastoreAdminClient create(DatastoreAdminSettings settings)
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.
Parameter | |
---|---|
Name | Description |
settings |
DatastoreAdminSettings |
Returns | |
---|---|
Type | Description |
DatastoreAdminClient |
Exceptions | |
---|---|
Type | Description |
IOException |
create(DatastoreAdminStub stub)
public static final DatastoreAdminClient create(DatastoreAdminStub stub)
Constructs an instance of DatastoreAdminClient, using the given stub for making calls. This is for advanced usage - prefer using create(DatastoreAdminSettings).
Parameter | |
---|---|
Name | Description |
stub |
DatastoreAdminStub |
Returns | |
---|---|
Type | Description |
DatastoreAdminClient |
Constructors
DatastoreAdminClient(DatastoreAdminSettings settings)
protected DatastoreAdminClient(DatastoreAdminSettings settings)
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.
Parameter | |
---|---|
Name | Description |
settings |
DatastoreAdminSettings |
DatastoreAdminClient(DatastoreAdminStub stub)
protected DatastoreAdminClient(DatastoreAdminStub stub)
Parameter | |
---|---|
Name | Description |
stub |
DatastoreAdminStub |
Methods
awaitTermination(long duration, TimeUnit unit)
public boolean awaitTermination(long duration, TimeUnit unit)
Parameters | |
---|---|
Name | Description |
duration |
long |
unit |
TimeUnit |
Returns | |
---|---|
Type | Description |
boolean |
Exceptions | |
---|---|
Type | Description |
InterruptedException |
close()
public final void close()
createIndexAsync(CreateIndexRequest request)
public final 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, 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,
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();
}
Parameter | |
---|---|
Name | Description |
request |
CreateIndexRequest The request object containing all of the parameters for the API call. |
Returns | |
---|---|
Type | Description |
OperationFuture<Index,IndexOperationMetadata> |
createIndexCallable()
public final UnaryCallable<CreateIndexRequest,Operation> createIndexCallable()
Creates the specified index. A newly created index's initial state is CREATING
. On completion
of the returned 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,
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();
}
Returns | |
---|---|
Type | Description |
UnaryCallable<CreateIndexRequest,Operation> |
createIndexOperationCallable()
public final OperationCallable<CreateIndexRequest,Index,IndexOperationMetadata> createIndexOperationCallable()
Creates the specified index. A newly created index's initial state is CREATING
. On completion
of the returned 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,
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();
}
Returns | |
---|---|
Type | Description |
OperationCallable<CreateIndexRequest,Index,IndexOperationMetadata> |
deleteIndexAsync(DeleteIndexRequest request)
public final 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. And on completion of the returned
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
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();
}
Parameter | |
---|---|
Name | Description |
request |
DeleteIndexRequest The request object containing all of the parameters for the API call. |
Returns | |
---|---|
Type | Description |
OperationFuture<Index,IndexOperationMetadata> |
deleteIndexCallable()
public final UnaryCallable<DeleteIndexRequest,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. And on completion of the returned
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
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();
}
Returns | |
---|---|
Type | Description |
UnaryCallable<DeleteIndexRequest,Operation> |
deleteIndexOperationCallable()
public final OperationCallable<DeleteIndexRequest,Index,IndexOperationMetadata> deleteIndexOperationCallable()
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. And on completion of the returned
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
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();
}
Returns | |
---|---|
Type | Description |
OperationCallable<DeleteIndexRequest,Index,IndexOperationMetadata> |
exportEntitiesAsync(ExportEntitiesRequest request)
public final 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();
}
Parameter | |
---|---|
Name | Description |
request |
ExportEntitiesRequest The request object containing all of the parameters for the API call. |
Returns | |
---|---|
Type | Description |
OperationFuture<ExportEntitiesResponse,ExportEntitiesMetadata> |
exportEntitiesAsync(String projectId, Map<String,String> labels, EntityFilter entityFilter, String outputUrlPrefix)
public final 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 | |
---|---|
Name | Description |
projectId |
String Required. Project ID against which to make the request. |
labels |
Map<String,String> Client-assigned labels. |
entityFilter |
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:
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. |
Returns | |
---|---|
Type | Description |
OperationFuture<ExportEntitiesResponse,ExportEntitiesMetadata> |
exportEntitiesCallable()
public final UnaryCallable<ExportEntitiesRequest,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();
}
Returns | |
---|---|
Type | Description |
UnaryCallable<ExportEntitiesRequest,Operation> |
exportEntitiesOperationCallable()
public final OperationCallable<ExportEntitiesRequest,ExportEntitiesResponse,ExportEntitiesMetadata> exportEntitiesOperationCallable()
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();
}
Returns | |
---|---|
Type | Description |
OperationCallable<ExportEntitiesRequest,ExportEntitiesResponse,ExportEntitiesMetadata> |
getHttpJsonOperationsClient()
public final OperationsClient getHttpJsonOperationsClient()
Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.
Returns | |
---|---|
Type | Description |
OperationsClient |
getIndex(GetIndexRequest request)
public final Index getIndex(GetIndexRequest request)
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);
}
Parameter | |
---|---|
Name | Description |
request |
GetIndexRequest The request object containing all of the parameters for the API call. |
Returns | |
---|---|
Type | Description |
Index |
getIndexCallable()
public final UnaryCallable<GetIndexRequest,Index> 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();
}
Returns | |
---|---|
Type | Description |
UnaryCallable<GetIndexRequest,Index> |
getOperationsClient()
public final OperationsClient getOperationsClient()
Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.
Returns | |
---|---|
Type | Description |
OperationsClient |
getSettings()
public final DatastoreAdminSettings getSettings()
Returns | |
---|---|
Type | Description |
DatastoreAdminSettings |
getStub()
public DatastoreAdminStub getStub()
Returns | |
---|---|
Type | Description |
DatastoreAdminStub |
importEntitiesAsync(ImportEntitiesRequest request)
public final OperationFuture<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();
}
Parameter | |
---|---|
Name | Description |
request |
ImportEntitiesRequest The request object containing all of the parameters for the API call. |
Returns | |
---|---|
Type | Description |
OperationFuture<Empty,ImportEntitiesMetadata> |
importEntitiesAsync(String projectId, Map<String,String> labels, String inputUrl, EntityFilter entityFilter)
public final OperationFuture<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 | |
---|---|
Name | Description |
projectId |
String Required. Project ID against which to make the request. |
labels |
Map<String,String> 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:
For more information, see google.datastore.admin.v1.ExportEntitiesResponse.output_url. |
entityFilter |
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. |
Returns | |
---|---|
Type | Description |
OperationFuture<Empty,ImportEntitiesMetadata> |
importEntitiesCallable()
public final UnaryCallable<ImportEntitiesRequest,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();
}
Returns | |
---|---|
Type | Description |
UnaryCallable<ImportEntitiesRequest,Operation> |
importEntitiesOperationCallable()
public final OperationCallable<ImportEntitiesRequest,Empty,ImportEntitiesMetadata> importEntitiesOperationCallable()
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();
}
Returns | |
---|---|
Type | Description |
OperationCallable<ImportEntitiesRequest,Empty,ImportEntitiesMetadata> |
isShutdown()
public boolean isShutdown()
Returns | |
---|---|
Type | Description |
boolean |
isTerminated()
public boolean isTerminated()
Returns | |
---|---|
Type | Description |
boolean |
listIndexes(ListIndexesRequest request)
public final DatastoreAdminClient.ListIndexesPagedResponse listIndexes(ListIndexesRequest request)
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);
}
}
Parameter | |
---|---|
Name | Description |
request |
ListIndexesRequest The request object containing all of the parameters for the API call. |
Returns | |
---|---|
Type | Description |
DatastoreAdminClient.ListIndexesPagedResponse |
listIndexesCallable()
public final 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;
}
}
}
Returns | |
---|---|
Type | Description |
UnaryCallable<ListIndexesRequest,ListIndexesResponse> |
listIndexesPagedCallable()
public final 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);
}
}
Returns | |
---|---|
Type | Description |
UnaryCallable<ListIndexesRequest,ListIndexesPagedResponse> |
shutdown()
public void shutdown()
shutdownNow()
public void shutdownNow()