@Generated(value="by gapic-generator-java") public class DatastoreAdminClient extends Object implements com.google.api.gax.core.BackgroundResource
The Datastore Admin API provides several admin services for Cloud Datastore.
----------------------------------------------------------------------------- ## Concepts
Project, namespace, kind, and entity as defined in the Google Cloud Datastore API.
Operation: An Operation represents work being performed in the background.
EntityFilter: Allows specifying a subset of entities in a project. This is specified as a combination of kinds and namespaces (either or both of which may be all).
----------------------------------------------------------------------------- ## Services
# Export/Import
The Export/Import service provides the ability to copy all or a subset of entities to/from Google Cloud Storage.
Exported data may be imported into Cloud Datastore for any Google Cloud Platform project. It is not restricted to the export source project. It is possible to export from one project and then import into another.
Exported data can also be loaded into Google BigQuery for analysis.
Exports and imports are performed asynchronously. An Operation resource is created for each export/import. The state (including any errors encountered) of the export/import may be queried via the Operation resource.
# Index
The index service manages Cloud Datastore composite indexes.
Index creation and deletion are performed asynchronously. An Operation resource is created for each such asynchronous operation. The state of the operation (including any errors encountered) may be queried via the Operation resource.
# Operation
The Operations collection provides a record of actions performed for the specified project (including any operations in progress). Operations are not created directly but through calls on other collections or resources.
An operation that is not yet done may be cancelled. The request to cancel is asynchronous and the operation may continue to run for some time after the request to cancel is made.
An operation that is done may be deleted so that it is no longer listed as part of the Operation collection.
ListOperations returns all pending operations, but not completed operations.
Operations are created by service DatastoreAdmin, but are accessed via service google.longrunning.Operations.
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().
The surface of this class includes several types of Java methods for each of the API's methods:
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.
Modifier and Type | Class and Description |
---|---|
static class |
DatastoreAdminClient.ListIndexesFixedSizeCollection |
static class |
DatastoreAdminClient.ListIndexesPage |
static class |
DatastoreAdminClient.ListIndexesPagedResponse |
Modifier | Constructor and Description |
---|---|
protected |
DatastoreAdminClient(DatastoreAdminSettings settings)
Constructs an instance of DatastoreAdminClient, using the given settings.
|
protected |
DatastoreAdminClient(DatastoreAdminStub stub) |
Modifier and Type | Method and Description |
---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static DatastoreAdminClient |
create()
Constructs an instance of DatastoreAdminClient with default settings.
|
static DatastoreAdminClient |
create(DatastoreAdminSettings settings)
Constructs an instance of DatastoreAdminClient, using the given settings.
|
static DatastoreAdminClient |
create(DatastoreAdminStub stub)
Constructs an instance of DatastoreAdminClient, using the given stub for making calls.
|
com.google.api.gax.longrunning.OperationFuture<Index,IndexOperationMetadata> |
createIndexAsync(CreateIndexRequest request)
Creates the specified index.
|
com.google.api.gax.rpc.UnaryCallable<CreateIndexRequest,com.google.longrunning.Operation> |
createIndexCallable()
Creates the specified index.
|
com.google.api.gax.rpc.OperationCallable<CreateIndexRequest,Index,IndexOperationMetadata> |
createIndexOperationCallable()
Creates the specified index.
|
com.google.api.gax.longrunning.OperationFuture<Index,IndexOperationMetadata> |
deleteIndexAsync(DeleteIndexRequest request)
Deletes an existing index.
|
com.google.api.gax.rpc.UnaryCallable<DeleteIndexRequest,com.google.longrunning.Operation> |
deleteIndexCallable()
Deletes an existing index.
|
com.google.api.gax.rpc.OperationCallable<DeleteIndexRequest,Index,IndexOperationMetadata> |
deleteIndexOperationCallable()
Deletes an existing index.
|
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.
|
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.
|
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.
|
com.google.api.gax.rpc.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.
|
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.
|
Index |
getIndex(GetIndexRequest request)
Gets an index.
|
com.google.api.gax.rpc.UnaryCallable<GetIndexRequest,Index> |
getIndexCallable()
Gets an index.
|
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.
|
DatastoreAdminSettings |
getSettings() |
DatastoreAdminStub |
getStub() |
com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,ImportEntitiesMetadata> |
importEntitiesAsync(ImportEntitiesRequest request)
Imports entities into Google Cloud Datastore.
|
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.
|
com.google.api.gax.rpc.UnaryCallable<ImportEntitiesRequest,com.google.longrunning.Operation> |
importEntitiesCallable()
Imports entities into Google Cloud Datastore.
|
com.google.api.gax.rpc.OperationCallable<ImportEntitiesRequest,com.google.protobuf.Empty,ImportEntitiesMetadata> |
importEntitiesOperationCallable()
Imports entities into Google Cloud Datastore.
|
boolean |
isShutdown() |
boolean |
isTerminated() |
DatastoreAdminClient.ListIndexesPagedResponse |
listIndexes(ListIndexesRequest request)
Lists the indexes that match the specified filters.
|
com.google.api.gax.rpc.UnaryCallable<ListIndexesRequest,ListIndexesResponse> |
listIndexesCallable()
Lists the indexes that match the specified filters.
|
com.google.api.gax.rpc.UnaryCallable<ListIndexesRequest,DatastoreAdminClient.ListIndexesPagedResponse> |
listIndexesPagedCallable()
Lists the indexes that match the specified filters.
|
void |
shutdown() |
void |
shutdownNow() |
protected DatastoreAdminClient(DatastoreAdminSettings settings) throws IOException
IOException
protected DatastoreAdminClient(DatastoreAdminStub stub)
public static final DatastoreAdminClient create() throws IOException
IOException
public static final DatastoreAdminClient create(DatastoreAdminSettings settings) throws IOException
IOException
public static final DatastoreAdminClient create(DatastoreAdminStub stub)
public final DatastoreAdminSettings getSettings()
public DatastoreAdminStub getStub()
public final com.google.longrunning.OperationsClient getOperationsClient()
@BetaApi public final com.google.api.gax.httpjson.longrunning.OperationsClient getHttpJsonOperationsClient()
public final com.google.api.gax.longrunning.OperationFuture<ExportEntitiesResponse,ExportEntitiesMetadata> exportEntitiesAsync(String projectId, Map<String,String> labels, EntityFilter entityFilter, String outputUrlPrefix)
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();
}
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.
com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<ExportEntitiesResponse,ExportEntitiesMetadata> exportEntitiesAsync(ExportEntitiesRequest request)
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();
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.OperationCallable<ExportEntitiesRequest,ExportEntitiesResponse,ExportEntitiesMetadata> exportEntitiesOperationCallable()
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();
}
public final com.google.api.gax.rpc.UnaryCallable<ExportEntitiesRequest,com.google.longrunning.Operation> exportEntitiesCallable()
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();
}
public final com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,ImportEntitiesMetadata> importEntitiesAsync(String projectId, Map<String,String> labels, String inputUrl, EntityFilter entityFilter)
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();
}
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.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,ImportEntitiesMetadata> importEntitiesAsync(ImportEntitiesRequest request)
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();
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.OperationCallable<ImportEntitiesRequest,com.google.protobuf.Empty,ImportEntitiesMetadata> importEntitiesOperationCallable()
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();
}
public final com.google.api.gax.rpc.UnaryCallable<ImportEntitiesRequest,com.google.longrunning.Operation> importEntitiesCallable()
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();
}
public final com.google.api.gax.longrunning.OperationFuture<Index,IndexOperationMetadata> createIndexAsync(CreateIndexRequest request)
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();
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.OperationCallable<CreateIndexRequest,Index,IndexOperationMetadata> createIndexOperationCallable()
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();
}
public final com.google.api.gax.rpc.UnaryCallable<CreateIndexRequest,com.google.longrunning.Operation> createIndexCallable()
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();
}
public final com.google.api.gax.longrunning.OperationFuture<Index,IndexOperationMetadata> deleteIndexAsync(DeleteIndexRequest request)
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();
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.OperationCallable<DeleteIndexRequest,Index,IndexOperationMetadata> deleteIndexOperationCallable()
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();
}
public final com.google.api.gax.rpc.UnaryCallable<DeleteIndexRequest,com.google.longrunning.Operation> deleteIndexCallable()
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();
}
public final Index getIndex(GetIndexRequest request)
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);
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<GetIndexRequest,Index> getIndexCallable()
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();
}
public final DatastoreAdminClient.ListIndexesPagedResponse listIndexes(ListIndexesRequest request)
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);
}
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<ListIndexesRequest,DatastoreAdminClient.ListIndexesPagedResponse> listIndexesPagedCallable()
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);
}
}
public final com.google.api.gax.rpc.UnaryCallable<ListIndexesRequest,ListIndexesResponse> listIndexesCallable()
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;
}
}
}
public final void close()
close
in interface AutoCloseable
public void shutdown()
shutdown
in interface com.google.api.gax.core.BackgroundResource
public boolean isShutdown()
isShutdown
in interface com.google.api.gax.core.BackgroundResource
public boolean isTerminated()
isTerminated
in interface com.google.api.gax.core.BackgroundResource
public void shutdownNow()
shutdownNow
in interface com.google.api.gax.core.BackgroundResource
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
awaitTermination
in interface com.google.api.gax.core.BackgroundResource
InterruptedException
Copyright © 2023 Google LLC. All rights reserved.