Class DatastoreAdminClient (2.24.3)
Stay organized with collections
Save and categorize content based on your preferences.
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(DatastoreAdminClientdatastoreAdminClient=DatastoreAdminClient.create()){
GetIndexRequestrequest=
GetIndexRequest.newBuilder()
.setProjectId("projectId-894832108")
.setIndexId("indexId1943291277")
.build();
Indexresponse=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
DatastoreAdminSettingsdatastoreAdminSettings=
DatastoreAdminSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
DatastoreAdminClientdatastoreAdminClient=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
DatastoreAdminSettingsdatastoreAdminSettings=
DatastoreAdminSettings.newBuilder().setEndpoint(myEndpoint).build();
DatastoreAdminClientdatastoreAdminClient=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
DatastoreAdminSettingsdatastoreAdminSettings=
DatastoreAdminSettings.newHttpJsonBuilder().build();
DatastoreAdminClientdatastoreAdminClient=DatastoreAdminClient.create(datastoreAdminSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
Static Methods
create()
publicstaticfinalDatastoreAdminClientcreate()Constructs an instance of DatastoreAdminClient with default settings.
| Returns | |
|---|---|
| Type | Description |
DatastoreAdminClient |
|
| Exceptions | |
|---|---|
| Type | Description |
IOException |
|
create(DatastoreAdminSettings settings)
publicstaticfinalDatastoreAdminClientcreate(DatastoreAdminSettingssettings)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)
publicstaticfinalDatastoreAdminClientcreate(DatastoreAdminStubstub)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)
protectedDatastoreAdminClient(DatastoreAdminSettingssettings)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)
protectedDatastoreAdminClient(DatastoreAdminStubstub)| Parameter | |
|---|---|
| Name | Description |
stub |
DatastoreAdminStub |
Methods
awaitTermination(long duration, TimeUnit unit)
publicbooleanawaitTermination(longduration,TimeUnitunit)| Parameters | |
|---|---|
| Name | Description |
duration |
long |
unit |
TimeUnit |
| Returns | |
|---|---|
| Type | Description |
boolean |
|
| Exceptions | |
|---|---|
| Type | Description |
InterruptedException |
|
close()
publicfinalvoidclose()createIndexAsync(CreateIndexRequest request)
publicfinalOperationFuture<Index,IndexOperationMetadata>createIndexAsync(CreateIndexRequestrequest)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(DatastoreAdminClientdatastoreAdminClient=DatastoreAdminClient.create()){
CreateIndexRequestrequest=
CreateIndexRequest.newBuilder()
.setProjectId("projectId-894832108")
.setIndex(Index.newBuilder().build())
.build();
Indexresponse=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()
publicfinalUnaryCallable<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(DatastoreAdminClientdatastoreAdminClient=DatastoreAdminClient.create()){
CreateIndexRequestrequest=
CreateIndexRequest.newBuilder()
.setProjectId("projectId-894832108")
.setIndex(Index.newBuilder().build())
.build();
ApiFuture<Operation>future=datastoreAdminClient.createIndexCallable().futureCall(request);
// Do something.
Operationresponse=future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<CreateIndexRequest,Operation> |
|
createIndexOperationCallable()
publicfinalOperationCallable<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(DatastoreAdminClientdatastoreAdminClient=DatastoreAdminClient.create()){
CreateIndexRequestrequest=
CreateIndexRequest.newBuilder()
.setProjectId("projectId-894832108")
.setIndex(Index.newBuilder().build())
.build();
OperationFuture<Index,IndexOperationMetadata>future=
datastoreAdminClient.createIndexOperationCallable().futureCall(request);
// Do something.
Indexresponse=future.get();
}
| Returns | |
|---|---|
| Type | Description |
OperationCallable<CreateIndexRequest,Index,IndexOperationMetadata> |
|
deleteIndexAsync(DeleteIndexRequest request)
publicfinalOperationFuture<Index,IndexOperationMetadata>deleteIndexAsync(DeleteIndexRequestrequest)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(DatastoreAdminClientdatastoreAdminClient=DatastoreAdminClient.create()){
DeleteIndexRequestrequest=
DeleteIndexRequest.newBuilder()
.setProjectId("projectId-894832108")
.setIndexId("indexId1943291277")
.build();
Indexresponse=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()
publicfinalUnaryCallable<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(DatastoreAdminClientdatastoreAdminClient=DatastoreAdminClient.create()){
DeleteIndexRequestrequest=
DeleteIndexRequest.newBuilder()
.setProjectId("projectId-894832108")
.setIndexId("indexId1943291277")
.build();
ApiFuture<Operation>future=datastoreAdminClient.deleteIndexCallable().futureCall(request);
// Do something.
Operationresponse=future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<DeleteIndexRequest,Operation> |
|
deleteIndexOperationCallable()
publicfinalOperationCallable<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(DatastoreAdminClientdatastoreAdminClient=DatastoreAdminClient.create()){
DeleteIndexRequestrequest=
DeleteIndexRequest.newBuilder()
.setProjectId("projectId-894832108")
.setIndexId("indexId1943291277")
.build();
OperationFuture<Index,IndexOperationMetadata>future=
datastoreAdminClient.deleteIndexOperationCallable().futureCall(request);
// Do something.
Indexresponse=future.get();
}
| Returns | |
|---|---|
| Type | Description |
OperationCallable<DeleteIndexRequest,Index,IndexOperationMetadata> |
|
exportEntitiesAsync(ExportEntitiesRequest request)
publicfinalOperationFuture<ExportEntitiesResponse,ExportEntitiesMetadata>exportEntitiesAsync(ExportEntitiesRequestrequest)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(DatastoreAdminClientdatastoreAdminClient=DatastoreAdminClient.create()){
ExportEntitiesRequestrequest=
ExportEntitiesRequest.newBuilder()
.setProjectId("projectId-894832108")
.putAllLabels(newHashMap<String,String>())
.setEntityFilter(EntityFilter.newBuilder().build())
.setOutputUrlPrefix("outputUrlPrefix-1132598048")
.build();
ExportEntitiesResponseresponse=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)
publicfinalOperationFuture<ExportEntitiesResponse,ExportEntitiesMetadata>exportEntitiesAsync(StringprojectId,Map<String,String>labels,EntityFilterentityFilter,StringoutputUrlPrefix)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(DatastoreAdminClientdatastoreAdminClient=DatastoreAdminClient.create()){
StringprojectId="projectId-894832108";
Map<String,String>labels=newHashMap<>();
EntityFilterentityFilter=EntityFilter.newBuilder().build();
StringoutputUrlPrefix="outputUrlPrefix-1132598048";
ExportEntitiesResponseresponse=
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()
publicfinalUnaryCallable<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(DatastoreAdminClientdatastoreAdminClient=DatastoreAdminClient.create()){
ExportEntitiesRequestrequest=
ExportEntitiesRequest.newBuilder()
.setProjectId("projectId-894832108")
.putAllLabels(newHashMap<String,String>())
.setEntityFilter(EntityFilter.newBuilder().build())
.setOutputUrlPrefix("outputUrlPrefix-1132598048")
.build();
ApiFuture<Operation>future=
datastoreAdminClient.exportEntitiesCallable().futureCall(request);
// Do something.
Operationresponse=future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<ExportEntitiesRequest,Operation> |
|
exportEntitiesOperationCallable()
publicfinalOperationCallable<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(DatastoreAdminClientdatastoreAdminClient=DatastoreAdminClient.create()){
ExportEntitiesRequestrequest=
ExportEntitiesRequest.newBuilder()
.setProjectId("projectId-894832108")
.putAllLabels(newHashMap<String,String>())
.setEntityFilter(EntityFilter.newBuilder().build())
.setOutputUrlPrefix("outputUrlPrefix-1132598048")
.build();
OperationFuture<ExportEntitiesResponse,ExportEntitiesMetadata>future=
datastoreAdminClient.exportEntitiesOperationCallable().futureCall(request);
// Do something.
ExportEntitiesResponseresponse=future.get();
}
| Returns | |
|---|---|
| Type | Description |
OperationCallable<ExportEntitiesRequest,ExportEntitiesResponse,ExportEntitiesMetadata> |
|
getHttpJsonOperationsClient()
publicfinalOperationsClientgetHttpJsonOperationsClient()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)
publicfinalIndexgetIndex(GetIndexRequestrequest)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(DatastoreAdminClientdatastoreAdminClient=DatastoreAdminClient.create()){
GetIndexRequestrequest=
GetIndexRequest.newBuilder()
.setProjectId("projectId-894832108")
.setIndexId("indexId1943291277")
.build();
Indexresponse=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()
publicfinalUnaryCallable<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(DatastoreAdminClientdatastoreAdminClient=DatastoreAdminClient.create()){
GetIndexRequestrequest=
GetIndexRequest.newBuilder()
.setProjectId("projectId-894832108")
.setIndexId("indexId1943291277")
.build();
ApiFuture<Index>future=datastoreAdminClient.getIndexCallable().futureCall(request);
// Do something.
Indexresponse=future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<GetIndexRequest,Index> |
|
getOperationsClient()
publicfinalOperationsClientgetOperationsClient()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()
publicfinalDatastoreAdminSettingsgetSettings()| Returns | |
|---|---|
| Type | Description |
DatastoreAdminSettings |
|
getStub()
publicDatastoreAdminStubgetStub()| Returns | |
|---|---|
| Type | Description |
DatastoreAdminStub |
|
importEntitiesAsync(ImportEntitiesRequest request)
publicfinalOperationFuture<Empty,ImportEntitiesMetadata>importEntitiesAsync(ImportEntitiesRequestrequest)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(DatastoreAdminClientdatastoreAdminClient=DatastoreAdminClient.create()){
ImportEntitiesRequestrequest=
ImportEntitiesRequest.newBuilder()
.setProjectId("projectId-894832108")
.putAllLabels(newHashMap<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)
publicfinalOperationFuture<Empty,ImportEntitiesMetadata>importEntitiesAsync(StringprojectId,Map<String,String>labels,StringinputUrl,EntityFilterentityFilter)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(DatastoreAdminClientdatastoreAdminClient=DatastoreAdminClient.create()){
StringprojectId="projectId-894832108";
Map<String,String>labels=newHashMap<>();
StringinputUrl="inputUrl470706501";
EntityFilterentityFilter=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()
publicfinalUnaryCallable<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(DatastoreAdminClientdatastoreAdminClient=DatastoreAdminClient.create()){
ImportEntitiesRequestrequest=
ImportEntitiesRequest.newBuilder()
.setProjectId("projectId-894832108")
.putAllLabels(newHashMap<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()
publicfinalOperationCallable<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(DatastoreAdminClientdatastoreAdminClient=DatastoreAdminClient.create()){
ImportEntitiesRequestrequest=
ImportEntitiesRequest.newBuilder()
.setProjectId("projectId-894832108")
.putAllLabels(newHashMap<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()
publicbooleanisShutdown()| Returns | |
|---|---|
| Type | Description |
boolean |
|
isTerminated()
publicbooleanisTerminated()| Returns | |
|---|---|
| Type | Description |
boolean |
|
listIndexes(ListIndexesRequest request)
publicfinalDatastoreAdminClient.ListIndexesPagedResponselistIndexes(ListIndexesRequestrequest)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(DatastoreAdminClientdatastoreAdminClient=DatastoreAdminClient.create()){
ListIndexesRequestrequest=
ListIndexesRequest.newBuilder()
.setProjectId("projectId-894832108")
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for(Indexelement: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()
publicfinalUnaryCallable<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(DatastoreAdminClientdatastoreAdminClient=DatastoreAdminClient.create()){
ListIndexesRequestrequest=
ListIndexesRequest.newBuilder()
.setProjectId("projectId-894832108")
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while(true){
ListIndexesResponseresponse=datastoreAdminClient.listIndexesCallable().call(request);
for(Indexelement:response.getIndexesList()){
// doThingsWith(element);
}
StringnextPageToken=response.getNextPageToken();
if(!Strings.isNullOrEmpty(nextPageToken)){
request=request.toBuilder().setPageToken(nextPageToken).build();
}else{
break;
}
}
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<ListIndexesRequest,ListIndexesResponse> |
|
listIndexesPagedCallable()
publicfinalUnaryCallable<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(DatastoreAdminClientdatastoreAdminClient=DatastoreAdminClient.create()){
ListIndexesRequestrequest=
ListIndexesRequest.newBuilder()
.setProjectId("projectId-894832108")
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<Index>future=datastoreAdminClient.listIndexesPagedCallable().futureCall(request);
// Do something.
for(Indexelement:future.get().iterateAll()){
// doThingsWith(element);
}
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<ListIndexesRequest,ListIndexesPagedResponse> |
|
shutdown()
publicvoidshutdown()shutdownNow()
publicvoidshutdownNow()