@BetaApi @Generated(value="by gapic-generator-java") public class AgentsClient extends Object implements com.google.api.gax.core.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:
// 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 (AgentsClient agentsClient = AgentsClient.create()) {
AgentName name = AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]");
Agent response = agentsClient.getAgent(name);
}
Note: close() needs to be called on the AgentsClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
| Method | Description | Method Variants |
|---|---|---|
ListAgents |
Returns the list of all agents in the specified location. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetAgent |
Retrieves the specified agent. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
CreateAgent |
Creates an agent in the specified location. Note: You should always train a flow prior to sending it queries. See the [training documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training). |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
UpdateAgent |
Updates the specified agent. Note: You should always train a flow prior to sending it queries. See the [training documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training). |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
DeleteAgent |
Deletes the specified agent. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ExportAgent |
Exports the specified agent to a binary file. This method is a [long-running operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The returned `Operation` type has the following method-specific fields: - `metadata`: An empty [Struct message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) - `response`: [ExportAgentResponse][google.cloud.dialogflow.cx.v3beta1.ExportAgentResponse] |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
RestoreAgent |
Restores the specified agent from a binary file. Replaces the current agent with a new one. Note that all existing resources in agent (e.g. intents, entity types, flows) will be removed. This method is a [long-running operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The returned `Operation` type has the following method-specific fields: - `metadata`: An empty [Struct message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) - `response`: An [Empty message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty) Note: You should always train a flow prior to sending it queries. See the [training documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training). |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ValidateAgent |
Validates the specified agent and creates or updates validation results. The agent in draft version is validated. Please call this API after the training is completed to get the complete validation results. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetAgentValidationResult |
Gets the latest agent validation result. Agent validation is performed when ValidateAgent is called. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetGenerativeSettings |
Gets the generative settings for the agent. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
UpdateGenerativeSettings |
Updates the generative settings for the agent. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ListLocations |
Lists information about the supported locations for this service. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetLocation |
Gets information about a location. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
See the individual methods for example code.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.
This class can be customized by passing in a custom instance of AgentsSettings 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
AgentsSettings agentsSettings =
AgentsSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
AgentsClient agentsClient = AgentsClient.create(agentsSettings);
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
AgentsSettings agentsSettings = AgentsSettings.newBuilder().setEndpoint(myEndpoint).build();
AgentsClient agentsClient = AgentsClient.create(agentsSettings);
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
AgentsSettings agentsSettings = AgentsSettings.newHttpJsonBuilder().build();
AgentsClient agentsClient = AgentsClient.create(agentsSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
| Modifier and Type | Class and Description |
|---|---|
static class |
AgentsClient.ListAgentsFixedSizeCollection |
static class |
AgentsClient.ListAgentsPage |
static class |
AgentsClient.ListAgentsPagedResponse |
static class |
AgentsClient.ListLocationsFixedSizeCollection |
static class |
AgentsClient.ListLocationsPage |
static class |
AgentsClient.ListLocationsPagedResponse |
| Modifier | Constructor and Description |
|---|---|
protected |
AgentsClient(AgentsSettings settings)
Constructs an instance of AgentsClient, using the given settings.
|
protected |
AgentsClient(AgentsStub stub) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static AgentsClient |
create()
Constructs an instance of AgentsClient with default settings.
|
static AgentsClient |
create(AgentsSettings settings)
Constructs an instance of AgentsClient, using the given settings.
|
static AgentsClient |
create(AgentsStub stub)
Constructs an instance of AgentsClient, using the given stub for making calls.
|
Agent |
createAgent(CreateAgentRequest request)
Creates an agent in the specified location.
|
Agent |
createAgent(LocationName parent,
Agent agent)
Creates an agent in the specified location.
|
Agent |
createAgent(String parent,
Agent agent)
Creates an agent in the specified location.
|
com.google.api.gax.rpc.UnaryCallable<CreateAgentRequest,Agent> |
createAgentCallable()
Creates an agent in the specified location.
|
void |
deleteAgent(AgentName name)
Deletes the specified agent.
|
void |
deleteAgent(DeleteAgentRequest request)
Deletes the specified agent.
|
void |
deleteAgent(String name)
Deletes the specified agent.
|
com.google.api.gax.rpc.UnaryCallable<DeleteAgentRequest,com.google.protobuf.Empty> |
deleteAgentCallable()
Deletes the specified agent.
|
com.google.api.gax.longrunning.OperationFuture<ExportAgentResponse,com.google.protobuf.Struct> |
exportAgentAsync(ExportAgentRequest request)
Exports the specified agent to a binary file.
|
com.google.api.gax.rpc.UnaryCallable<ExportAgentRequest,com.google.longrunning.Operation> |
exportAgentCallable()
Exports the specified agent to a binary file.
|
com.google.api.gax.rpc.OperationCallable<ExportAgentRequest,ExportAgentResponse,com.google.protobuf.Struct> |
exportAgentOperationCallable()
Exports the specified agent to a binary file.
|
Agent |
getAgent(AgentName name)
Retrieves the specified agent.
|
Agent |
getAgent(GetAgentRequest request)
Retrieves the specified agent.
|
Agent |
getAgent(String name)
Retrieves the specified agent.
|
com.google.api.gax.rpc.UnaryCallable<GetAgentRequest,Agent> |
getAgentCallable()
Retrieves the specified agent.
|
AgentValidationResult |
getAgentValidationResult(AgentValidationResultName name)
Gets the latest agent validation result.
|
AgentValidationResult |
getAgentValidationResult(GetAgentValidationResultRequest request)
Gets the latest agent validation result.
|
AgentValidationResult |
getAgentValidationResult(String name)
Gets the latest agent validation result.
|
com.google.api.gax.rpc.UnaryCallable<GetAgentValidationResultRequest,AgentValidationResult> |
getAgentValidationResultCallable()
Gets the latest agent validation result.
|
GenerativeSettings |
getGenerativeSettings(AgentGenerativeSettingsName name,
String languageCode)
Gets the generative settings for the agent.
|
GenerativeSettings |
getGenerativeSettings(GetGenerativeSettingsRequest request)
Gets the generative settings for the agent.
|
GenerativeSettings |
getGenerativeSettings(String name,
String languageCode)
Gets the generative settings for the agent.
|
com.google.api.gax.rpc.UnaryCallable<GetGenerativeSettingsRequest,GenerativeSettings> |
getGenerativeSettingsCallable()
Gets the generative settings for the agent.
|
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.
|
com.google.cloud.location.Location |
getLocation(com.google.cloud.location.GetLocationRequest request)
Gets information about a location.
|
com.google.api.gax.rpc.UnaryCallable<com.google.cloud.location.GetLocationRequest,com.google.cloud.location.Location> |
getLocationCallable()
Gets information about a location.
|
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.
|
AgentsSettings |
getSettings() |
AgentsStub |
getStub() |
boolean |
isShutdown() |
boolean |
isTerminated() |
AgentsClient.ListAgentsPagedResponse |
listAgents(ListAgentsRequest request)
Returns the list of all agents in the specified location.
|
AgentsClient.ListAgentsPagedResponse |
listAgents(LocationName parent)
Returns the list of all agents in the specified location.
|
AgentsClient.ListAgentsPagedResponse |
listAgents(String parent)
Returns the list of all agents in the specified location.
|
com.google.api.gax.rpc.UnaryCallable<ListAgentsRequest,ListAgentsResponse> |
listAgentsCallable()
Returns the list of all agents in the specified location.
|
com.google.api.gax.rpc.UnaryCallable<ListAgentsRequest,AgentsClient.ListAgentsPagedResponse> |
listAgentsPagedCallable()
Returns the list of all agents in the specified location.
|
AgentsClient.ListLocationsPagedResponse |
listLocations(com.google.cloud.location.ListLocationsRequest request)
Lists information about the supported locations for this service.
|
com.google.api.gax.rpc.UnaryCallable<com.google.cloud.location.ListLocationsRequest,com.google.cloud.location.ListLocationsResponse> |
listLocationsCallable()
Lists information about the supported locations for this service.
|
com.google.api.gax.rpc.UnaryCallable<com.google.cloud.location.ListLocationsRequest,AgentsClient.ListLocationsPagedResponse> |
listLocationsPagedCallable()
Lists information about the supported locations for this service.
|
com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,com.google.protobuf.Struct> |
restoreAgentAsync(RestoreAgentRequest request)
Restores the specified agent from a binary file.
|
com.google.api.gax.rpc.UnaryCallable<RestoreAgentRequest,com.google.longrunning.Operation> |
restoreAgentCallable()
Restores the specified agent from a binary file.
|
com.google.api.gax.rpc.OperationCallable<RestoreAgentRequest,com.google.protobuf.Empty,com.google.protobuf.Struct> |
restoreAgentOperationCallable()
Restores the specified agent from a binary file.
|
void |
shutdown() |
void |
shutdownNow() |
Agent |
updateAgent(Agent agent,
com.google.protobuf.FieldMask updateMask)
Updates the specified agent.
|
Agent |
updateAgent(UpdateAgentRequest request)
Updates the specified agent.
|
com.google.api.gax.rpc.UnaryCallable<UpdateAgentRequest,Agent> |
updateAgentCallable()
Updates the specified agent.
|
GenerativeSettings |
updateGenerativeSettings(GenerativeSettings generativeSettings,
com.google.protobuf.FieldMask updateMask)
Updates the generative settings for the agent.
|
GenerativeSettings |
updateGenerativeSettings(UpdateGenerativeSettingsRequest request)
Updates the generative settings for the agent.
|
com.google.api.gax.rpc.UnaryCallable<UpdateGenerativeSettingsRequest,GenerativeSettings> |
updateGenerativeSettingsCallable()
Updates the generative settings for the agent.
|
AgentValidationResult |
validateAgent(ValidateAgentRequest request)
Validates the specified agent and creates or updates validation results.
|
com.google.api.gax.rpc.UnaryCallable<ValidateAgentRequest,AgentValidationResult> |
validateAgentCallable()
Validates the specified agent and creates or updates validation results.
|
protected AgentsClient(AgentsSettings settings) throws IOException
IOExceptionprotected AgentsClient(AgentsStub stub)
public static final AgentsClient create() throws IOException
IOExceptionpublic static final AgentsClient create(AgentsSettings settings) throws IOException
IOExceptionpublic static final AgentsClient create(AgentsStub stub)
public final AgentsSettings getSettings()
public AgentsStub getStub()
public final com.google.longrunning.OperationsClient getOperationsClient()
@BetaApi public final com.google.api.gax.httpjson.longrunning.OperationsClient getHttpJsonOperationsClient()
public final AgentsClient.ListAgentsPagedResponse listAgents(LocationName parent)
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 (AgentsClient agentsClient = AgentsClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
for (Agent element : agentsClient.listAgents(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent - Required. The location to list all agents for. Format:
`projects/<ProjectID>/locations/<LocationID>`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final AgentsClient.ListAgentsPagedResponse listAgents(String parent)
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 (AgentsClient agentsClient = AgentsClient.create()) {
String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
for (Agent element : agentsClient.listAgents(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent - Required. The location to list all agents for. Format:
`projects/<ProjectID>/locations/<LocationID>`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final AgentsClient.ListAgentsPagedResponse listAgents(ListAgentsRequest 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 (AgentsClient agentsClient = AgentsClient.create()) {
ListAgentsRequest request =
ListAgentsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (Agent element : agentsClient.listAgents(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<ListAgentsRequest,AgentsClient.ListAgentsPagedResponse> listAgentsPagedCallable()
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 (AgentsClient agentsClient = AgentsClient.create()) {
ListAgentsRequest request =
ListAgentsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<Agent> future = agentsClient.listAgentsPagedCallable().futureCall(request);
// Do something.
for (Agent element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final com.google.api.gax.rpc.UnaryCallable<ListAgentsRequest,ListAgentsResponse> listAgentsCallable()
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 (AgentsClient agentsClient = AgentsClient.create()) {
ListAgentsRequest request =
ListAgentsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
ListAgentsResponse response = agentsClient.listAgentsCallable().call(request);
for (Agent element : response.getAgentsList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final Agent getAgent(AgentName name)
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 (AgentsClient agentsClient = AgentsClient.create()) {
AgentName name = AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]");
Agent response = agentsClient.getAgent(name);
}
name - Required. The name of the agent. Format:
`projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final Agent getAgent(String name)
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 (AgentsClient agentsClient = AgentsClient.create()) {
String name = AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString();
Agent response = agentsClient.getAgent(name);
}
name - Required. The name of the agent. Format:
`projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final Agent getAgent(GetAgentRequest 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 (AgentsClient agentsClient = AgentsClient.create()) {
GetAgentRequest request =
GetAgentRequest.newBuilder()
.setName(AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
.build();
Agent response = agentsClient.getAgent(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<GetAgentRequest,Agent> getAgentCallable()
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 (AgentsClient agentsClient = AgentsClient.create()) {
GetAgentRequest request =
GetAgentRequest.newBuilder()
.setName(AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
.build();
ApiFuture<Agent> future = agentsClient.getAgentCallable().futureCall(request);
// Do something.
Agent response = future.get();
}
public final Agent createAgent(LocationName parent, Agent agent)
Note: You should always train a flow prior to sending it queries. See the [training documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training).
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 (AgentsClient agentsClient = AgentsClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
Agent agent = Agent.newBuilder().build();
Agent response = agentsClient.createAgent(parent, agent);
}
parent - Required. The location to create a agent for. Format:
`projects/<ProjectID>/locations/<LocationID>`.agent - Required. The agent to create.com.google.api.gax.rpc.ApiException - if the remote call failspublic final Agent createAgent(String parent, Agent agent)
Note: You should always train a flow prior to sending it queries. See the [training documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training).
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 (AgentsClient agentsClient = AgentsClient.create()) {
String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
Agent agent = Agent.newBuilder().build();
Agent response = agentsClient.createAgent(parent, agent);
}
parent - Required. The location to create a agent for. Format:
`projects/<ProjectID>/locations/<LocationID>`.agent - Required. The agent to create.com.google.api.gax.rpc.ApiException - if the remote call failspublic final Agent createAgent(CreateAgentRequest request)
Note: You should always train a flow prior to sending it queries. See the [training documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training).
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 (AgentsClient agentsClient = AgentsClient.create()) {
CreateAgentRequest request =
CreateAgentRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setAgent(Agent.newBuilder().build())
.build();
Agent response = agentsClient.createAgent(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<CreateAgentRequest,Agent> createAgentCallable()
Note: You should always train a flow prior to sending it queries. See the [training documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training).
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 (AgentsClient agentsClient = AgentsClient.create()) {
CreateAgentRequest request =
CreateAgentRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setAgent(Agent.newBuilder().build())
.build();
ApiFuture<Agent> future = agentsClient.createAgentCallable().futureCall(request);
// Do something.
Agent response = future.get();
}
public final Agent updateAgent(Agent agent, com.google.protobuf.FieldMask updateMask)
Note: You should always train a flow prior to sending it queries. See the [training documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training).
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 (AgentsClient agentsClient = AgentsClient.create()) {
Agent agent = Agent.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
Agent response = agentsClient.updateAgent(agent, updateMask);
}
agent - Required. The agent to update.updateMask - The mask to control which fields get updated. If the mask is not present, all
fields will be updated.com.google.api.gax.rpc.ApiException - if the remote call failspublic final Agent updateAgent(UpdateAgentRequest request)
Note: You should always train a flow prior to sending it queries. See the [training documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training).
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 (AgentsClient agentsClient = AgentsClient.create()) {
UpdateAgentRequest request =
UpdateAgentRequest.newBuilder()
.setAgent(Agent.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
Agent response = agentsClient.updateAgent(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<UpdateAgentRequest,Agent> updateAgentCallable()
Note: You should always train a flow prior to sending it queries. See the [training documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training).
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 (AgentsClient agentsClient = AgentsClient.create()) {
UpdateAgentRequest request =
UpdateAgentRequest.newBuilder()
.setAgent(Agent.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
ApiFuture<Agent> future = agentsClient.updateAgentCallable().futureCall(request);
// Do something.
Agent response = future.get();
}
public final void deleteAgent(AgentName name)
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 (AgentsClient agentsClient = AgentsClient.create()) {
AgentName name = AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]");
agentsClient.deleteAgent(name);
}
name - Required. The name of the agent to delete. Format:
`projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final void deleteAgent(String name)
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 (AgentsClient agentsClient = AgentsClient.create()) {
String name = AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString();
agentsClient.deleteAgent(name);
}
name - Required. The name of the agent to delete. Format:
`projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final void deleteAgent(DeleteAgentRequest 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 (AgentsClient agentsClient = AgentsClient.create()) {
DeleteAgentRequest request =
DeleteAgentRequest.newBuilder()
.setName(AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
.build();
agentsClient.deleteAgent(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<DeleteAgentRequest,com.google.protobuf.Empty> deleteAgentCallable()
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 (AgentsClient agentsClient = AgentsClient.create()) {
DeleteAgentRequest request =
DeleteAgentRequest.newBuilder()
.setName(AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
.build();
ApiFuture<Empty> future = agentsClient.deleteAgentCallable().futureCall(request);
// Do something.
future.get();
}
public final com.google.api.gax.longrunning.OperationFuture<ExportAgentResponse,com.google.protobuf.Struct> exportAgentAsync(ExportAgentRequest request)
This method is a [long-running operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The returned `Operation` type has the following method-specific fields:
- `metadata`: An empty [Struct message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) - `response`: [ExportAgentResponse][google.cloud.dialogflow.cx.v3beta1.ExportAgentResponse]
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 (AgentsClient agentsClient = AgentsClient.create()) {
ExportAgentRequest request =
ExportAgentRequest.newBuilder()
.setName(AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
.setAgentUri("agentUri1469149223")
.setEnvironment(
EnvironmentName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENVIRONMENT]")
.toString())
.setGitDestination(ExportAgentRequest.GitDestination.newBuilder().build())
.setIncludeBigqueryExportSettings(true)
.build();
ExportAgentResponse response = agentsClient.exportAgentAsync(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<ExportAgentRequest,ExportAgentResponse,com.google.protobuf.Struct> exportAgentOperationCallable()
This method is a [long-running operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The returned `Operation` type has the following method-specific fields:
- `metadata`: An empty [Struct message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) - `response`: [ExportAgentResponse][google.cloud.dialogflow.cx.v3beta1.ExportAgentResponse]
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 (AgentsClient agentsClient = AgentsClient.create()) {
ExportAgentRequest request =
ExportAgentRequest.newBuilder()
.setName(AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
.setAgentUri("agentUri1469149223")
.setEnvironment(
EnvironmentName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENVIRONMENT]")
.toString())
.setGitDestination(ExportAgentRequest.GitDestination.newBuilder().build())
.setIncludeBigqueryExportSettings(true)
.build();
OperationFuture<ExportAgentResponse, Struct> future =
agentsClient.exportAgentOperationCallable().futureCall(request);
// Do something.
ExportAgentResponse response = future.get();
}
public final com.google.api.gax.rpc.UnaryCallable<ExportAgentRequest,com.google.longrunning.Operation> exportAgentCallable()
This method is a [long-running operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The returned `Operation` type has the following method-specific fields:
- `metadata`: An empty [Struct message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) - `response`: [ExportAgentResponse][google.cloud.dialogflow.cx.v3beta1.ExportAgentResponse]
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 (AgentsClient agentsClient = AgentsClient.create()) {
ExportAgentRequest request =
ExportAgentRequest.newBuilder()
.setName(AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
.setAgentUri("agentUri1469149223")
.setEnvironment(
EnvironmentName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENVIRONMENT]")
.toString())
.setGitDestination(ExportAgentRequest.GitDestination.newBuilder().build())
.setIncludeBigqueryExportSettings(true)
.build();
ApiFuture<Operation> future = agentsClient.exportAgentCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
public final com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,com.google.protobuf.Struct> restoreAgentAsync(RestoreAgentRequest request)
Replaces the current agent with a new one. Note that all existing resources in agent (e.g. intents, entity types, flows) will be removed.
This method is a [long-running operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The returned `Operation` type has the following method-specific fields:
- `metadata`: An empty [Struct message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) - `response`: An [Empty message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty)
Note: You should always train a flow prior to sending it queries. See the [training documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training).
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 (AgentsClient agentsClient = AgentsClient.create()) {
RestoreAgentRequest request =
RestoreAgentRequest.newBuilder()
.setName(AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
.build();
agentsClient.restoreAgentAsync(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<RestoreAgentRequest,com.google.protobuf.Empty,com.google.protobuf.Struct> restoreAgentOperationCallable()
Replaces the current agent with a new one. Note that all existing resources in agent (e.g. intents, entity types, flows) will be removed.
This method is a [long-running operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The returned `Operation` type has the following method-specific fields:
- `metadata`: An empty [Struct message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) - `response`: An [Empty message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty)
Note: You should always train a flow prior to sending it queries. See the [training documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training).
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 (AgentsClient agentsClient = AgentsClient.create()) {
RestoreAgentRequest request =
RestoreAgentRequest.newBuilder()
.setName(AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
.build();
OperationFuture<Empty, Struct> future =
agentsClient.restoreAgentOperationCallable().futureCall(request);
// Do something.
future.get();
}
public final com.google.api.gax.rpc.UnaryCallable<RestoreAgentRequest,com.google.longrunning.Operation> restoreAgentCallable()
Replaces the current agent with a new one. Note that all existing resources in agent (e.g. intents, entity types, flows) will be removed.
This method is a [long-running operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The returned `Operation` type has the following method-specific fields:
- `metadata`: An empty [Struct message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) - `response`: An [Empty message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty)
Note: You should always train a flow prior to sending it queries. See the [training documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training).
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 (AgentsClient agentsClient = AgentsClient.create()) {
RestoreAgentRequest request =
RestoreAgentRequest.newBuilder()
.setName(AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
.build();
ApiFuture<Operation> future = agentsClient.restoreAgentCallable().futureCall(request);
// Do something.
future.get();
}
public final AgentValidationResult validateAgent(ValidateAgentRequest 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 (AgentsClient agentsClient = AgentsClient.create()) {
ValidateAgentRequest request =
ValidateAgentRequest.newBuilder()
.setName(AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
.setLanguageCode("languageCode-2092349083")
.build();
AgentValidationResult response = agentsClient.validateAgent(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<ValidateAgentRequest,AgentValidationResult> validateAgentCallable()
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 (AgentsClient agentsClient = AgentsClient.create()) {
ValidateAgentRequest request =
ValidateAgentRequest.newBuilder()
.setName(AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
.setLanguageCode("languageCode-2092349083")
.build();
ApiFuture<AgentValidationResult> future =
agentsClient.validateAgentCallable().futureCall(request);
// Do something.
AgentValidationResult response = future.get();
}
public final AgentValidationResult getAgentValidationResult(AgentValidationResultName name)
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 (AgentsClient agentsClient = AgentsClient.create()) {
AgentValidationResultName name =
AgentValidationResultName.of("[PROJECT]", "[LOCATION]", "[AGENT]");
AgentValidationResult response = agentsClient.getAgentValidationResult(name);
}
name - Required. The agent name. Format:
`projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>/validationResult`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final AgentValidationResult getAgentValidationResult(String name)
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 (AgentsClient agentsClient = AgentsClient.create()) {
String name = AgentValidationResultName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString();
AgentValidationResult response = agentsClient.getAgentValidationResult(name);
}
name - Required. The agent name. Format:
`projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>/validationResult`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final AgentValidationResult getAgentValidationResult(GetAgentValidationResultRequest 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 (AgentsClient agentsClient = AgentsClient.create()) {
GetAgentValidationResultRequest request =
GetAgentValidationResultRequest.newBuilder()
.setName(
AgentValidationResultName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
.setLanguageCode("languageCode-2092349083")
.build();
AgentValidationResult response = agentsClient.getAgentValidationResult(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<GetAgentValidationResultRequest,AgentValidationResult> getAgentValidationResultCallable()
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 (AgentsClient agentsClient = AgentsClient.create()) {
GetAgentValidationResultRequest request =
GetAgentValidationResultRequest.newBuilder()
.setName(
AgentValidationResultName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
.setLanguageCode("languageCode-2092349083")
.build();
ApiFuture<AgentValidationResult> future =
agentsClient.getAgentValidationResultCallable().futureCall(request);
// Do something.
AgentValidationResult response = future.get();
}
public final GenerativeSettings getGenerativeSettings(AgentGenerativeSettingsName name, String languageCode)
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 (AgentsClient agentsClient = AgentsClient.create()) {
AgentGenerativeSettingsName name =
AgentGenerativeSettingsName.of("[PROJECT]", "[LOCATION]", "[AGENT]");
String languageCode = "languageCode-2092349083";
GenerativeSettings response = agentsClient.getGenerativeSettings(name, languageCode);
}
name - Required. Format:
`projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>/generativeSettings`.languageCode - Required. Language code of the generative settings.com.google.api.gax.rpc.ApiException - if the remote call failspublic final GenerativeSettings getGenerativeSettings(String name, String languageCode)
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 (AgentsClient agentsClient = AgentsClient.create()) {
String name = AgentGenerativeSettingsName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString();
String languageCode = "languageCode-2092349083";
GenerativeSettings response = agentsClient.getGenerativeSettings(name, languageCode);
}
name - Required. Format:
`projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>/generativeSettings`.languageCode - Required. Language code of the generative settings.com.google.api.gax.rpc.ApiException - if the remote call failspublic final GenerativeSettings getGenerativeSettings(GetGenerativeSettingsRequest 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 (AgentsClient agentsClient = AgentsClient.create()) {
GetGenerativeSettingsRequest request =
GetGenerativeSettingsRequest.newBuilder()
.setName(
AgentGenerativeSettingsName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
.setLanguageCode("languageCode-2092349083")
.build();
GenerativeSettings response = agentsClient.getGenerativeSettings(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<GetGenerativeSettingsRequest,GenerativeSettings> getGenerativeSettingsCallable()
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 (AgentsClient agentsClient = AgentsClient.create()) {
GetGenerativeSettingsRequest request =
GetGenerativeSettingsRequest.newBuilder()
.setName(
AgentGenerativeSettingsName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
.setLanguageCode("languageCode-2092349083")
.build();
ApiFuture<GenerativeSettings> future =
agentsClient.getGenerativeSettingsCallable().futureCall(request);
// Do something.
GenerativeSettings response = future.get();
}
public final GenerativeSettings updateGenerativeSettings(GenerativeSettings generativeSettings, com.google.protobuf.FieldMask updateMask)
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 (AgentsClient agentsClient = AgentsClient.create()) {
GenerativeSettings generativeSettings = GenerativeSettings.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
GenerativeSettings response =
agentsClient.updateGenerativeSettings(generativeSettings, updateMask);
}
generativeSettings - Required. Generative settings to update.updateMask - Optional. The mask to control which fields get updated. If the mask is not
present, all fields will be updated.com.google.api.gax.rpc.ApiException - if the remote call failspublic final GenerativeSettings updateGenerativeSettings(UpdateGenerativeSettingsRequest 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 (AgentsClient agentsClient = AgentsClient.create()) {
UpdateGenerativeSettingsRequest request =
UpdateGenerativeSettingsRequest.newBuilder()
.setGenerativeSettings(GenerativeSettings.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
GenerativeSettings response = agentsClient.updateGenerativeSettings(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<UpdateGenerativeSettingsRequest,GenerativeSettings> updateGenerativeSettingsCallable()
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 (AgentsClient agentsClient = AgentsClient.create()) {
UpdateGenerativeSettingsRequest request =
UpdateGenerativeSettingsRequest.newBuilder()
.setGenerativeSettings(GenerativeSettings.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
ApiFuture<GenerativeSettings> future =
agentsClient.updateGenerativeSettingsCallable().futureCall(request);
// Do something.
GenerativeSettings response = future.get();
}
public final AgentsClient.ListLocationsPagedResponse listLocations(com.google.cloud.location.ListLocationsRequest 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 (AgentsClient agentsClient = AgentsClient.create()) {
ListLocationsRequest request =
ListLocationsRequest.newBuilder()
.setName("name3373707")
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (Location element : agentsClient.listLocations(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<com.google.cloud.location.ListLocationsRequest,AgentsClient.ListLocationsPagedResponse> listLocationsPagedCallable()
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 (AgentsClient agentsClient = AgentsClient.create()) {
ListLocationsRequest request =
ListLocationsRequest.newBuilder()
.setName("name3373707")
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<Location> future = agentsClient.listLocationsPagedCallable().futureCall(request);
// Do something.
for (Location element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final com.google.api.gax.rpc.UnaryCallable<com.google.cloud.location.ListLocationsRequest,com.google.cloud.location.ListLocationsResponse> listLocationsCallable()
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 (AgentsClient agentsClient = AgentsClient.create()) {
ListLocationsRequest request =
ListLocationsRequest.newBuilder()
.setName("name3373707")
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
ListLocationsResponse response = agentsClient.listLocationsCallable().call(request);
for (Location element : response.getLocationsList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final com.google.cloud.location.Location getLocation(com.google.cloud.location.GetLocationRequest 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 (AgentsClient agentsClient = AgentsClient.create()) {
GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
Location response = agentsClient.getLocation(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<com.google.cloud.location.GetLocationRequest,com.google.cloud.location.Location> getLocationCallable()
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 (AgentsClient agentsClient = AgentsClient.create()) {
GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
ApiFuture<Location> future = agentsClient.getLocationCallable().futureCall(request);
// Do something.
Location response = future.get();
}
public final void close()
close in interface AutoCloseablepublic void shutdown()
shutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isShutdown()
isShutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isTerminated()
isTerminated in interface com.google.api.gax.core.BackgroundResourcepublic void shutdownNow()
shutdownNow in interface com.google.api.gax.core.BackgroundResourcepublic boolean awaitTermination(long duration,
TimeUnit unit)
throws InterruptedException
awaitTermination in interface com.google.api.gax.core.BackgroundResourceInterruptedExceptionCopyright © 2025 Google LLC. All rights reserved.