@BetaApi @Generated(value="by gapic-generator-java") public class EntityTypesClient extends Object implements BackgroundResource
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 (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
EntityTypeName name =
EntityTypeName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENTITY_TYPE]");
EntityType response = entityTypesClient.getEntityType(name);
}
Note: close() needs to be called on the EntityTypesClient 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 EntityTypesSettings to create(). For example:
To customize credentials:
EntityTypesSettings entityTypesSettings =
EntityTypesSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
EntityTypesClient entityTypesClient = EntityTypesClient.create(entityTypesSettings);
To customize the endpoint:
EntityTypesSettings entityTypesSettings =
EntityTypesSettings.newBuilder().setEndpoint(myEndpoint).build();
EntityTypesClient entityTypesClient = EntityTypesClient.create(entityTypesSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
Modifier and Type | Class and Description |
---|---|
static class |
EntityTypesClient.ListEntityTypesFixedSizeCollection |
static class |
EntityTypesClient.ListEntityTypesPage |
static class |
EntityTypesClient.ListEntityTypesPagedResponse |
Modifier | Constructor and Description |
---|---|
protected |
EntityTypesClient(EntityTypesSettings settings)
Constructs an instance of EntityTypesClient, using the given settings.
|
protected |
EntityTypesClient(EntityTypesStub stub) |
Modifier and Type | Method and Description |
---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static EntityTypesClient |
create()
Constructs an instance of EntityTypesClient with default settings.
|
static EntityTypesClient |
create(EntityTypesSettings settings)
Constructs an instance of EntityTypesClient, using the given settings.
|
static EntityTypesClient |
create(EntityTypesStub stub)
Constructs an instance of EntityTypesClient, using the given stub for making calls.
|
EntityType |
createEntityType(AgentName parent,
EntityType entityType)
Creates an entity type in the specified agent.
|
EntityType |
createEntityType(CreateEntityTypeRequest request)
Creates an entity type in the specified agent.
|
EntityType |
createEntityType(String parent,
EntityType entityType)
Creates an entity type in the specified agent.
|
UnaryCallable<CreateEntityTypeRequest,EntityType> |
createEntityTypeCallable()
Creates an entity type in the specified agent.
|
void |
deleteEntityType(DeleteEntityTypeRequest request)
Deletes the specified entity type.
|
void |
deleteEntityType(EntityTypeName name)
Deletes the specified entity type.
|
void |
deleteEntityType(String name)
Deletes the specified entity type.
|
UnaryCallable<DeleteEntityTypeRequest,Empty> |
deleteEntityTypeCallable()
Deletes the specified entity type.
|
EntityType |
getEntityType(EntityTypeName name)
Retrieves the specified entity type.
|
EntityType |
getEntityType(GetEntityTypeRequest request)
Retrieves the specified entity type.
|
EntityType |
getEntityType(String name)
Retrieves the specified entity type.
|
UnaryCallable<GetEntityTypeRequest,EntityType> |
getEntityTypeCallable()
Retrieves the specified entity type.
|
EntityTypesSettings |
getSettings() |
EntityTypesStub |
getStub() |
boolean |
isShutdown() |
boolean |
isTerminated() |
EntityTypesClient.ListEntityTypesPagedResponse |
listEntityTypes(AgentName parent)
Returns the list of all entity types in the specified agent.
|
EntityTypesClient.ListEntityTypesPagedResponse |
listEntityTypes(ListEntityTypesRequest request)
Returns the list of all entity types in the specified agent.
|
EntityTypesClient.ListEntityTypesPagedResponse |
listEntityTypes(String parent)
Returns the list of all entity types in the specified agent.
|
UnaryCallable<ListEntityTypesRequest,ListEntityTypesResponse> |
listEntityTypesCallable()
Returns the list of all entity types in the specified agent.
|
UnaryCallable<ListEntityTypesRequest,EntityTypesClient.ListEntityTypesPagedResponse> |
listEntityTypesPagedCallable()
Returns the list of all entity types in the specified agent.
|
void |
shutdown() |
void |
shutdownNow() |
EntityType |
updateEntityType(EntityType entityType,
FieldMask updateMask)
Updates the specified entity type.
|
EntityType |
updateEntityType(UpdateEntityTypeRequest request)
Updates the specified entity type.
|
UnaryCallable<UpdateEntityTypeRequest,EntityType> |
updateEntityTypeCallable()
Updates the specified entity type.
|
protected EntityTypesClient(EntityTypesSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected EntityTypesClient(EntityTypesStub stub)
public static final EntityTypesClient create() throws IOException
IOException
public static final EntityTypesClient create(EntityTypesSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final EntityTypesClient create(EntityTypesStub stub)
public final EntityTypesSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public EntityTypesStub getStub()
public final EntityTypesClient.ListEntityTypesPagedResponse listEntityTypes(AgentName parent)
Sample code:
try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
AgentName parent = AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]");
for (EntityType element : entityTypesClient.listEntityTypes(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent
- Required. The agent to list all entity types for. Format: `projects/<Project
ID>/locations/<Location ID>/agents/<Agent ID>`.ApiException
- if the remote call failspublic final EntityTypesClient.ListEntityTypesPagedResponse listEntityTypes(String parent)
Sample code:
try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
String parent =
EntityTypeName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENTITY_TYPE]").toString();
for (EntityType element : entityTypesClient.listEntityTypes(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent
- Required. The agent to list all entity types for. Format: `projects/<Project
ID>/locations/<Location ID>/agents/<Agent ID>`.ApiException
- if the remote call failspublic final EntityTypesClient.ListEntityTypesPagedResponse listEntityTypes(ListEntityTypesRequest request)
Sample code:
try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
ListEntityTypesRequest request =
ListEntityTypesRequest.newBuilder()
.setParent(
EntityTypeName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENTITY_TYPE]")
.toString())
.setLanguageCode("languageCode-2092349083")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (EntityType element : entityTypesClient.listEntityTypes(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<ListEntityTypesRequest,EntityTypesClient.ListEntityTypesPagedResponse> listEntityTypesPagedCallable()
Sample code:
try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
ListEntityTypesRequest request =
ListEntityTypesRequest.newBuilder()
.setParent(
EntityTypeName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENTITY_TYPE]")
.toString())
.setLanguageCode("languageCode-2092349083")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<EntityType> future =
entityTypesClient.listEntityTypesPagedCallable().futureCall(request);
// Do something.
for (EntityType element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final UnaryCallable<ListEntityTypesRequest,ListEntityTypesResponse> listEntityTypesCallable()
Sample code:
try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
while (true) {
ListEntityTypesResponse response =
entityTypesClient.listEntityTypesCallable().call(request);
for (EntityType element : response.getResponsesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final EntityType getEntityType(EntityTypeName name)
Sample code:
try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
EntityTypeName name =
EntityTypeName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENTITY_TYPE]");
EntityType response = entityTypesClient.getEntityType(name);
}
name
- Required. The name of the entity type. Format: `projects/<Project
ID>/locations/<Location ID>/agents/<Agent ID>/entityTypes/<Entity Type
ID>`.ApiException
- if the remote call failspublic final EntityType getEntityType(String name)
Sample code:
try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
String name =
EntityTypeName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENTITY_TYPE]").toString();
EntityType response = entityTypesClient.getEntityType(name);
}
name
- Required. The name of the entity type. Format: `projects/<Project
ID>/locations/<Location ID>/agents/<Agent ID>/entityTypes/<Entity Type
ID>`.ApiException
- if the remote call failspublic final EntityType getEntityType(GetEntityTypeRequest request)
Sample code:
try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
GetEntityTypeRequest request =
GetEntityTypeRequest.newBuilder()
.setName(
EntityTypeName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENTITY_TYPE]")
.toString())
.setLanguageCode("languageCode-2092349083")
.build();
EntityType response = entityTypesClient.getEntityType(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<GetEntityTypeRequest,EntityType> getEntityTypeCallable()
Sample code:
try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
GetEntityTypeRequest request =
GetEntityTypeRequest.newBuilder()
.setName(
EntityTypeName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENTITY_TYPE]")
.toString())
.setLanguageCode("languageCode-2092349083")
.build();
ApiFuture<EntityType> future = entityTypesClient.getEntityTypeCallable().futureCall(request);
// Do something.
EntityType response = future.get();
}
public final EntityType createEntityType(AgentName parent, EntityType entityType)
Sample code:
try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
AgentName parent = AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]");
EntityType entityType = EntityType.newBuilder().build();
EntityType response = entityTypesClient.createEntityType(parent, entityType);
}
parent
- Required. The agent to create a entity type for. Format: `projects/<Project
ID>/locations/<Location ID>/agents/<Agent ID>`.entityType
- Required. The entity type to create.ApiException
- if the remote call failspublic final EntityType createEntityType(String parent, EntityType entityType)
Sample code:
try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
String parent =
EntityTypeName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENTITY_TYPE]").toString();
EntityType entityType = EntityType.newBuilder().build();
EntityType response = entityTypesClient.createEntityType(parent, entityType);
}
parent
- Required. The agent to create a entity type for. Format: `projects/<Project
ID>/locations/<Location ID>/agents/<Agent ID>`.entityType
- Required. The entity type to create.ApiException
- if the remote call failspublic final EntityType createEntityType(CreateEntityTypeRequest request)
Sample code:
try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
CreateEntityTypeRequest request =
CreateEntityTypeRequest.newBuilder()
.setParent(
EntityTypeName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENTITY_TYPE]")
.toString())
.setEntityType(EntityType.newBuilder().build())
.setLanguageCode("languageCode-2092349083")
.build();
EntityType response = entityTypesClient.createEntityType(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<CreateEntityTypeRequest,EntityType> createEntityTypeCallable()
Sample code:
try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
CreateEntityTypeRequest request =
CreateEntityTypeRequest.newBuilder()
.setParent(
EntityTypeName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENTITY_TYPE]")
.toString())
.setEntityType(EntityType.newBuilder().build())
.setLanguageCode("languageCode-2092349083")
.build();
ApiFuture<EntityType> future =
entityTypesClient.createEntityTypeCallable().futureCall(request);
// Do something.
EntityType response = future.get();
}
public final EntityType updateEntityType(EntityType entityType, FieldMask updateMask)
Sample code:
try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
EntityType entityType = EntityType.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
EntityType response = entityTypesClient.updateEntityType(entityType, updateMask);
}
entityType
- Required. The entity type to update.updateMask
- The mask to control which fields get updated.ApiException
- if the remote call failspublic final EntityType updateEntityType(UpdateEntityTypeRequest request)
Sample code:
try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
UpdateEntityTypeRequest request =
UpdateEntityTypeRequest.newBuilder()
.setEntityType(EntityType.newBuilder().build())
.setLanguageCode("languageCode-2092349083")
.setUpdateMask(FieldMask.newBuilder().build())
.build();
EntityType response = entityTypesClient.updateEntityType(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<UpdateEntityTypeRequest,EntityType> updateEntityTypeCallable()
Sample code:
try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
UpdateEntityTypeRequest request =
UpdateEntityTypeRequest.newBuilder()
.setEntityType(EntityType.newBuilder().build())
.setLanguageCode("languageCode-2092349083")
.setUpdateMask(FieldMask.newBuilder().build())
.build();
ApiFuture<EntityType> future =
entityTypesClient.updateEntityTypeCallable().futureCall(request);
// Do something.
EntityType response = future.get();
}
public final void deleteEntityType(EntityTypeName name)
Sample code:
try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
EntityTypeName name =
EntityTypeName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENTITY_TYPE]");
entityTypesClient.deleteEntityType(name);
}
name
- Required. The name of the entity type to delete. Format: `projects/<Project
ID>/locations/<Location ID>/agents/<Agent ID>/entityTypes/<Entity Type
ID>`.ApiException
- if the remote call failspublic final void deleteEntityType(String name)
Sample code:
try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
String name =
EntityTypeName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENTITY_TYPE]").toString();
entityTypesClient.deleteEntityType(name);
}
name
- Required. The name of the entity type to delete. Format: `projects/<Project
ID>/locations/<Location ID>/agents/<Agent ID>/entityTypes/<Entity Type
ID>`.ApiException
- if the remote call failspublic final void deleteEntityType(DeleteEntityTypeRequest request)
Sample code:
try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
DeleteEntityTypeRequest request =
DeleteEntityTypeRequest.newBuilder()
.setName(
EntityTypeName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENTITY_TYPE]")
.toString())
.setForce(true)
.build();
entityTypesClient.deleteEntityType(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<DeleteEntityTypeRequest,Empty> deleteEntityTypeCallable()
Sample code:
try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
DeleteEntityTypeRequest request =
DeleteEntityTypeRequest.newBuilder()
.setName(
EntityTypeName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENTITY_TYPE]")
.toString())
.setForce(true)
.build();
ApiFuture<Empty> future = entityTypesClient.deleteEntityTypeCallable().futureCall(request);
// Do something.
future.get();
}
public final void close()
close
in interface AutoCloseable
public void shutdown()
shutdown
in interface BackgroundResource
public boolean isShutdown()
isShutdown
in interface BackgroundResource
public boolean isTerminated()
isTerminated
in interface BackgroundResource
public void shutdownNow()
shutdownNow
in interface BackgroundResource
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
awaitTermination
in interface BackgroundResource
InterruptedException
Copyright © 2021 Google LLC. All rights reserved.