- 3.56.0 (latest)
- 3.55.0
- 3.54.0
- 3.53.0
- 3.52.0
- 3.50.0
- 3.49.0
- 3.48.0
- 3.47.0
- 3.46.0
- 3.45.0
- 3.44.0
- 3.43.0
- 3.42.0
- 3.41.0
- 3.40.0
- 3.38.0
- 3.37.0
- 3.36.0
- 3.35.0
- 3.34.0
- 3.33.0
- 3.32.0
- 3.31.0
- 3.30.0
- 3.29.0
- 3.28.0
- 3.25.0
- 3.24.0
- 3.23.0
- 3.22.0
- 3.21.0
- 3.20.0
- 3.19.0
- 3.18.0
- 3.17.0
- 3.16.0
- 3.15.0
- 3.14.0
- 3.13.0
- 3.12.0
- 3.11.0
- 3.10.0
- 3.9.0
- 3.8.0
- 3.7.0
- 3.6.0
- 3.5.0
- 3.4.2
- 3.3.0
- 3.2.0
- 3.0.0
- 2.9.8
- 2.8.9
- 2.7.4
- 2.5.3
- 2.4.0
public class IndexServiceClient implements BackgroundResource
Service Description: A service for creating and managing Vertex AI's Index resources.
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:
try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) {
IndexName name = IndexName.of("[PROJECT]", "[LOCATION]", "[INDEX]");
Index response = indexServiceClient.getIndex(name);
}
Note: close() needs to be called on the IndexServiceClient 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:
- 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.
- 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.
- 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 IndexServiceSettings to create(). For example:
To customize credentials:
IndexServiceSettings indexServiceSettings =
IndexServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
IndexServiceClient indexServiceClient = IndexServiceClient.create(indexServiceSettings);
To customize the endpoint:
IndexServiceSettings indexServiceSettings =
IndexServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
IndexServiceClient indexServiceClient = IndexServiceClient.create(indexServiceSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
Implements
BackgroundResourceStatic Methods
create()
public static final IndexServiceClient create()
Constructs an instance of IndexServiceClient with default settings.
Type | Description |
IndexServiceClient |
Type | Description |
IOException |
create(IndexServiceSettings settings)
public static final IndexServiceClient create(IndexServiceSettings settings)
Constructs an instance of IndexServiceClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.
Name | Description |
settings | IndexServiceSettings |
Type | Description |
IndexServiceClient |
Type | Description |
IOException |
create(IndexServiceStub stub)
public static final IndexServiceClient create(IndexServiceStub stub)
Constructs an instance of IndexServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(IndexServiceSettings).
Name | Description |
stub | IndexServiceStub |
Type | Description |
IndexServiceClient |
Constructors
IndexServiceClient(IndexServiceSettings settings)
protected IndexServiceClient(IndexServiceSettings settings)
Constructs an instance of IndexServiceClient, 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.
Name | Description |
settings | IndexServiceSettings |
IndexServiceClient(IndexServiceStub stub)
protected IndexServiceClient(IndexServiceStub stub)
Name | Description |
stub | IndexServiceStub |
Methods
awaitTermination(long duration, TimeUnit unit)
public boolean awaitTermination(long duration, TimeUnit unit)
Name | Description |
duration | long |
unit | TimeUnit |
Type | Description |
boolean |
Type | Description |
InterruptedException |
close()
public final void close()
createIndexAsync(CreateIndexRequest request)
public final OperationFuture<Index,CreateIndexOperationMetadata> createIndexAsync(CreateIndexRequest request)
Creates an Index.
Sample code:
try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) {
CreateIndexRequest request =
CreateIndexRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setIndex(Index.newBuilder().build())
.build();
Index response = indexServiceClient.createIndexAsync(request).get();
}
Name | Description |
request | CreateIndexRequest The request object containing all of the parameters for the API call. |
Type | Description |
OperationFuture<Index,CreateIndexOperationMetadata> |
createIndexAsync(LocationName parent, Index index)
public final OperationFuture<Index,CreateIndexOperationMetadata> createIndexAsync(LocationName parent, Index index)
Creates an Index.
Sample code:
try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
Index index = Index.newBuilder().build();
Index response = indexServiceClient.createIndexAsync(parent, index).get();
}
Name | Description |
parent | LocationName Required. The resource name of the Location to create the Index in. Format:
|
index | Index Required. The Index to create. |
Type | Description |
OperationFuture<Index,CreateIndexOperationMetadata> |
createIndexAsync(String parent, Index index)
public final OperationFuture<Index,CreateIndexOperationMetadata> createIndexAsync(String parent, Index index)
Creates an Index.
Sample code:
try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) {
String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
Index index = Index.newBuilder().build();
Index response = indexServiceClient.createIndexAsync(parent, index).get();
}
Name | Description |
parent | String Required. The resource name of the Location to create the Index in. Format:
|
index | Index Required. The Index to create. |
Type | Description |
OperationFuture<Index,CreateIndexOperationMetadata> |
createIndexCallable()
public final UnaryCallable<CreateIndexRequest,Operation> createIndexCallable()
Creates an Index.
Sample code:
try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) {
CreateIndexRequest request =
CreateIndexRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setIndex(Index.newBuilder().build())
.build();
ApiFuture<Operation> future = indexServiceClient.createIndexCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
Type | Description |
UnaryCallable<CreateIndexRequest,Operation> |
createIndexOperationCallable()
public final OperationCallable<CreateIndexRequest,Index,CreateIndexOperationMetadata> createIndexOperationCallable()
Creates an Index.
Sample code:
try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) {
CreateIndexRequest request =
CreateIndexRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setIndex(Index.newBuilder().build())
.build();
OperationFuture<Index, CreateIndexOperationMetadata> future =
indexServiceClient.createIndexOperationCallable().futureCall(request);
// Do something.
Index response = future.get();
}
Type | Description |
OperationCallable<CreateIndexRequest,Index,CreateIndexOperationMetadata> |
deleteIndexAsync(DeleteIndexRequest request)
public final OperationFuture<Empty,DeleteOperationMetadata> deleteIndexAsync(DeleteIndexRequest request)
Deletes an Index. An Index can only be deleted when all its DeployedIndexes had been undeployed.
Sample code:
try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) {
DeleteIndexRequest request =
DeleteIndexRequest.newBuilder()
.setName(IndexName.of("[PROJECT]", "[LOCATION]", "[INDEX]").toString())
.build();
indexServiceClient.deleteIndexAsync(request).get();
}
Name | Description |
request | DeleteIndexRequest The request object containing all of the parameters for the API call. |
Type | Description |
OperationFuture<Empty,DeleteOperationMetadata> |
deleteIndexAsync(IndexName name)
public final OperationFuture<Empty,DeleteOperationMetadata> deleteIndexAsync(IndexName name)
Deletes an Index. An Index can only be deleted when all its DeployedIndexes had been undeployed.
Sample code:
try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) {
IndexName name = IndexName.of("[PROJECT]", "[LOCATION]", "[INDEX]");
indexServiceClient.deleteIndexAsync(name).get();
}
Name | Description |
name | IndexName Required. The name of the Index resource to be deleted. Format:
|
Type | Description |
OperationFuture<Empty,DeleteOperationMetadata> |
deleteIndexAsync(String name)
public final OperationFuture<Empty,DeleteOperationMetadata> deleteIndexAsync(String name)
Deletes an Index. An Index can only be deleted when all its DeployedIndexes had been undeployed.
Sample code:
try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) {
String name = IndexName.of("[PROJECT]", "[LOCATION]", "[INDEX]").toString();
indexServiceClient.deleteIndexAsync(name).get();
}
Name | Description |
name | String Required. The name of the Index resource to be deleted. Format:
|
Type | Description |
OperationFuture<Empty,DeleteOperationMetadata> |
deleteIndexCallable()
public final UnaryCallable<DeleteIndexRequest,Operation> deleteIndexCallable()
Deletes an Index. An Index can only be deleted when all its DeployedIndexes had been undeployed.
Sample code:
try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) {
DeleteIndexRequest request =
DeleteIndexRequest.newBuilder()
.setName(IndexName.of("[PROJECT]", "[LOCATION]", "[INDEX]").toString())
.build();
ApiFuture<Operation> future = indexServiceClient.deleteIndexCallable().futureCall(request);
// Do something.
future.get();
}
Type | Description |
UnaryCallable<DeleteIndexRequest,Operation> |
deleteIndexOperationCallable()
public final OperationCallable<DeleteIndexRequest,Empty,DeleteOperationMetadata> deleteIndexOperationCallable()
Deletes an Index. An Index can only be deleted when all its DeployedIndexes had been undeployed.
Sample code:
try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) {
DeleteIndexRequest request =
DeleteIndexRequest.newBuilder()
.setName(IndexName.of("[PROJECT]", "[LOCATION]", "[INDEX]").toString())
.build();
OperationFuture<Empty, DeleteOperationMetadata> future =
indexServiceClient.deleteIndexOperationCallable().futureCall(request);
// Do something.
future.get();
}
Type | Description |
OperationCallable<DeleteIndexRequest,Empty,DeleteOperationMetadata> |
getIndex(GetIndexRequest request)
public final Index getIndex(GetIndexRequest request)
Gets an Index.
Sample code:
try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) {
GetIndexRequest request =
GetIndexRequest.newBuilder()
.setName(IndexName.of("[PROJECT]", "[LOCATION]", "[INDEX]").toString())
.build();
Index response = indexServiceClient.getIndex(request);
}
Name | Description |
request | GetIndexRequest The request object containing all of the parameters for the API call. |
Type | Description |
Index |
getIndex(IndexName name)
public final Index getIndex(IndexName name)
Gets an Index.
Sample code:
try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) {
IndexName name = IndexName.of("[PROJECT]", "[LOCATION]", "[INDEX]");
Index response = indexServiceClient.getIndex(name);
}
Name | Description |
name | IndexName Required. The name of the Index resource. Format:
|
Type | Description |
Index |
getIndex(String name)
public final Index getIndex(String name)
Gets an Index.
Sample code:
try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) {
String name = IndexName.of("[PROJECT]", "[LOCATION]", "[INDEX]").toString();
Index response = indexServiceClient.getIndex(name);
}
Name | Description |
name | String Required. The name of the Index resource. Format:
|
Type | Description |
Index |
getIndexCallable()
public final UnaryCallable<GetIndexRequest,Index> getIndexCallable()
Gets an Index.
Sample code:
try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) {
GetIndexRequest request =
GetIndexRequest.newBuilder()
.setName(IndexName.of("[PROJECT]", "[LOCATION]", "[INDEX]").toString())
.build();
ApiFuture<Index> future = indexServiceClient.getIndexCallable().futureCall(request);
// Do something.
Index response = future.get();
}
Type | Description |
UnaryCallable<GetIndexRequest,Index> |
getOperationsClient()
public final OperationsClient getOperationsClient()
Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.
Type | Description |
OperationsClient |
getSettings()
public final IndexServiceSettings getSettings()
Type | Description |
IndexServiceSettings |
getStub()
public IndexServiceStub getStub()
Type | Description |
IndexServiceStub |
isShutdown()
public boolean isShutdown()
Type | Description |
boolean |
isTerminated()
public boolean isTerminated()
Type | Description |
boolean |
listIndexes(ListIndexesRequest request)
public final IndexServiceClient.ListIndexesPagedResponse listIndexes(ListIndexesRequest request)
Lists Indexes in a Location.
Sample code:
try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) {
ListIndexesRequest request =
ListIndexesRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setReadMask(FieldMask.newBuilder().build())
.build();
for (Index element : indexServiceClient.listIndexes(request).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
request | ListIndexesRequest The request object containing all of the parameters for the API call. |
Type | Description |
IndexServiceClient.ListIndexesPagedResponse |
listIndexes(LocationName parent)
public final IndexServiceClient.ListIndexesPagedResponse listIndexes(LocationName parent)
Lists Indexes in a Location.
Sample code:
try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
for (Index element : indexServiceClient.listIndexes(parent).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
parent | LocationName Required. The resource name of the Location from which to list the Indexes.
Format: |
Type | Description |
IndexServiceClient.ListIndexesPagedResponse |
listIndexes(String parent)
public final IndexServiceClient.ListIndexesPagedResponse listIndexes(String parent)
Lists Indexes in a Location.
Sample code:
try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) {
String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
for (Index element : indexServiceClient.listIndexes(parent).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
parent | String Required. The resource name of the Location from which to list the Indexes.
Format: |
Type | Description |
IndexServiceClient.ListIndexesPagedResponse |
listIndexesCallable()
public final UnaryCallable<ListIndexesRequest,ListIndexesResponse> listIndexesCallable()
Lists Indexes in a Location.
Sample code:
try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) {
ListIndexesRequest request =
ListIndexesRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setReadMask(FieldMask.newBuilder().build())
.build();
while (true) {
ListIndexesResponse response = indexServiceClient.listIndexesCallable().call(request);
for (Index element : response.getResponsesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
Type | Description |
UnaryCallable<ListIndexesRequest,ListIndexesResponse> |
listIndexesPagedCallable()
public final UnaryCallable<ListIndexesRequest,IndexServiceClient.ListIndexesPagedResponse> listIndexesPagedCallable()
Lists Indexes in a Location.
Sample code:
try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) {
ListIndexesRequest request =
ListIndexesRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setReadMask(FieldMask.newBuilder().build())
.build();
ApiFuture<Index> future = indexServiceClient.listIndexesPagedCallable().futureCall(request);
// Do something.
for (Index element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
Type | Description |
UnaryCallable<ListIndexesRequest,ListIndexesPagedResponse> |
shutdown()
public void shutdown()
shutdownNow()
public void shutdownNow()
updateIndexAsync(Index index, FieldMask updateMask)
public final OperationFuture<Index,UpdateIndexOperationMetadata> updateIndexAsync(Index index, FieldMask updateMask)
Updates an Index.
Sample code:
try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) {
Index index = Index.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
Index response = indexServiceClient.updateIndexAsync(index, updateMask).get();
}
Name | Description |
index | Index Required. The Index which updates the resource on the server. |
updateMask | FieldMask The update mask applies to the resource. For the |
Type | Description |
OperationFuture<Index,UpdateIndexOperationMetadata> |
updateIndexAsync(UpdateIndexRequest request)
public final OperationFuture<Index,UpdateIndexOperationMetadata> updateIndexAsync(UpdateIndexRequest request)
Updates an Index.
Sample code:
try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) {
UpdateIndexRequest request =
UpdateIndexRequest.newBuilder()
.setIndex(Index.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
Index response = indexServiceClient.updateIndexAsync(request).get();
}
Name | Description |
request | UpdateIndexRequest The request object containing all of the parameters for the API call. |
Type | Description |
OperationFuture<Index,UpdateIndexOperationMetadata> |
updateIndexCallable()
public final UnaryCallable<UpdateIndexRequest,Operation> updateIndexCallable()
Updates an Index.
Sample code:
try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) {
UpdateIndexRequest request =
UpdateIndexRequest.newBuilder()
.setIndex(Index.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
ApiFuture<Operation> future = indexServiceClient.updateIndexCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
Type | Description |
UnaryCallable<UpdateIndexRequest,Operation> |
updateIndexOperationCallable()
public final OperationCallable<UpdateIndexRequest,Index,UpdateIndexOperationMetadata> updateIndexOperationCallable()
Updates an Index.
Sample code:
try (IndexServiceClient indexServiceClient = IndexServiceClient.create()) {
UpdateIndexRequest request =
UpdateIndexRequest.newBuilder()
.setIndex(Index.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
OperationFuture<Index, UpdateIndexOperationMetadata> future =
indexServiceClient.updateIndexOperationCallable().futureCall(request);
// Do something.
Index response = future.get();
}
Type | Description |
OperationCallable<UpdateIndexRequest,Index,UpdateIndexOperationMetadata> |