Class DatastoreAdminClient (2.17.6)

public class DatastoreAdminClient implements BackgroundResource

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

The surface of this class includes several types of Java methods for each of the API's methods:

  1. A "flattened" method. With this type of method, the fields of the request type have been converted into function parameters. It may be the case that not all fields are available as parameters, and not every API method will have a flattened method entry point.
  2. A "request object" method. This type of method only takes one parameter, a request object, which must be constructed before the call. Not every API method will have a request object method.
  3. A "callable" method. This type of method takes no parameters and returns 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.

Inheritance

java.lang.Object > DatastoreAdminClient

Implements

BackgroundResource

Static Methods

create()

public static final DatastoreAdminClient create()

Constructs an instance of DatastoreAdminClient with default settings.

Returns
TypeDescription
DatastoreAdminClient
Exceptions
TypeDescription
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
NameDescription
settingsDatastoreAdminSettings
Returns
TypeDescription
DatastoreAdminClient
Exceptions
TypeDescription
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
NameDescription
stubDatastoreAdminStub
Returns
TypeDescription
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
NameDescription
settingsDatastoreAdminSettings

DatastoreAdminClient(DatastoreAdminStub stub)

protected DatastoreAdminClient(DatastoreAdminStub stub)
Parameter
NameDescription
stubDatastoreAdminStub

Methods

awaitTermination(long duration, TimeUnit unit)

public boolean awaitTermination(long duration, TimeUnit unit)
Parameters
NameDescription
durationlong
unitTimeUnit
Returns
TypeDescription
boolean
Exceptions
TypeDescription
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
NameDescription
requestCreateIndexRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
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
TypeDescription
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
TypeDescription
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
NameDescription
requestDeleteIndexRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
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
TypeDescription
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
TypeDescription
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
NameDescription
requestExportEntitiesRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
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
NameDescription
projectIdString

Required. Project ID against which to make the request.

labelsMap<String,String>

Client-assigned labels.

entityFilterEntityFilter

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

outputUrlPrefixString

Required. Location for the export metadata and data files.

The full resource URL of the external storage location. Currently, only Google Cloud Storage is supported. So output_url_prefix should be of the form: gs://BUCKET_NAME[/NAMESPACE_PATH], where BUCKET_NAME is the name of the Cloud Storage bucket and NAMESPACE_PATH is an optional Cloud Storage namespace path (this is not a Cloud Datastore namespace). For more information about Cloud Storage namespace paths, see Object name considerations.

The resulting files will be nested deeper than the specified URL prefix. The final output URL will be provided in the google.datastore.admin.v1.ExportEntitiesResponse.output_url field. That value should be used for subsequent ImportEntities operations.

By nesting the data files deeper, the same Cloud Storage bucket can be used in multiple ExportEntities operations without conflict.

Returns
TypeDescription
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
TypeDescription
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
TypeDescription
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
TypeDescription
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
NameDescription
requestGetIndexRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
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
TypeDescription
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
TypeDescription
OperationsClient

getSettings()

public final DatastoreAdminSettings getSettings()
Returns
TypeDescription
DatastoreAdminSettings

getStub()

public DatastoreAdminStub getStub()
Returns
TypeDescription
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
NameDescription
requestImportEntitiesRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
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
NameDescription
projectIdString

Required. Project ID against which to make the request.

labelsMap<String,String>

Client-assigned labels.

inputUrlString

Required. The full resource URL of the external storage location. Currently, only Google Cloud Storage is supported. So input_url should be of the form: gs://BUCKET_NAME[/NAMESPACE_PATH]/OVERALL_EXPORT_METADATA_FILE, where BUCKET_NAME is the name of the Cloud Storage bucket, NAMESPACE_PATH is an optional Cloud Storage namespace path (this is not a Cloud Datastore namespace), and OVERALL_EXPORT_METADATA_FILE is the metadata file written by the ExportEntities operation. For more information about Cloud Storage namespace paths, see Object name considerations.

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

entityFilterEntityFilter

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
TypeDescription
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
TypeDescription
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
TypeDescription
OperationCallable<ImportEntitiesRequest,Empty,ImportEntitiesMetadata>

isShutdown()

public boolean isShutdown()
Returns
TypeDescription
boolean

isTerminated()

public boolean isTerminated()
Returns
TypeDescription
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
NameDescription
requestListIndexesRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
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
TypeDescription
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
TypeDescription
UnaryCallable<ListIndexesRequest,ListIndexesPagedResponse>

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()