Class AgentsClient (0.29.0)

public class AgentsClient implements BackgroundResource

Service Description: Service for managing Agents.

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

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

  1. A "flattened" method. With this type of method, the fields of the request type have been converted into function parameters. It may be the case that not all fields are available as parameters, and not every API method will have a flattened method entry point.
  2. A "request object" method. This type of method only takes one parameter, a request object, which must be constructed before the call. Not every API method will have a request object method.
  3. A "callable" method. This type of method takes no parameters and returns an immutable API callable object, which can be used to initiate calls to the service.

See the individual methods for example code.

Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.

This class can be customized by passing in a custom instance of 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.

Inheritance

java.lang.Object > AgentsClient

Implements

BackgroundResource

Static Methods

create()

public static final AgentsClient create()

Constructs an instance of AgentsClient with default settings.

Returns
Type Description
AgentsClient
Exceptions
Type Description
IOException

create(AgentsSettings settings)

public static final AgentsClient create(AgentsSettings settings)

Constructs an instance of AgentsClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.

Parameter
Name Description
settings AgentsSettings
Returns
Type Description
AgentsClient
Exceptions
Type Description
IOException

create(AgentsStub stub)

public static final AgentsClient create(AgentsStub stub)

Constructs an instance of AgentsClient, using the given stub for making calls. This is for advanced usage - prefer using create(AgentsSettings).

Parameter
Name Description
stub AgentsStub
Returns
Type Description
AgentsClient

Constructors

AgentsClient(AgentsSettings settings)

protected AgentsClient(AgentsSettings settings)

Constructs an instance of AgentsClient, using the given settings. This is protected so that it is easy to make a subclass, but otherwise, the static factory methods should be preferred.

Parameter
Name Description
settings AgentsSettings

AgentsClient(AgentsStub stub)

protected AgentsClient(AgentsStub stub)
Parameter
Name Description
stub AgentsStub

Methods

awaitTermination(long duration, TimeUnit unit)

public boolean awaitTermination(long duration, TimeUnit unit)
Parameters
Name Description
duration long
unit TimeUnit
Returns
Type Description
boolean
Exceptions
Type Description
InterruptedException

close()

public final void close()

createAgent(CreateAgentRequest request)

public final Agent createAgent(CreateAgentRequest request)

Creates an agent in the specified location.

Note: You should always train flows prior to sending them queries. See the training documentation.

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);
 }
 
Parameter
Name Description
request CreateAgentRequest

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

Returns
Type Description
Agent

createAgent(LocationName parent, Agent agent)

public final Agent createAgent(LocationName parent, Agent agent)

Creates an agent in the specified location.

Note: You should always train flows prior to sending them queries. See the training documentation.

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);
 }
 
Parameters
Name Description
parent LocationName

Required. The location to create a agent for. Format: projects/<Project ID>/locations/<Location ID>.

agent Agent

Required. The agent to create.

Returns
Type Description
Agent

createAgent(String parent, Agent agent)

public final Agent createAgent(String parent, Agent agent)

Creates an agent in the specified location.

Note: You should always train flows prior to sending them queries. See the training documentation.

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);
 }
 
Parameters
Name Description
parent String

Required. The location to create a agent for. Format: projects/<Project ID>/locations/<Location ID>.

agent Agent

Required. The agent to create.

Returns
Type Description
Agent

createAgentCallable()

public final UnaryCallable<CreateAgentRequest,Agent> createAgentCallable()

Creates an agent in the specified location.

Note: You should always train flows prior to sending them queries. See the training documentation.

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();
 }
 
Returns
Type Description
UnaryCallable<CreateAgentRequest,Agent>

deleteAgent(AgentName name)

public final void deleteAgent(AgentName name)

Deletes the specified agent.

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);
 }
 
Parameter
Name Description
name AgentName

Required. The name of the agent to delete. Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>.

deleteAgent(DeleteAgentRequest request)

public final void deleteAgent(DeleteAgentRequest request)

Deletes the specified agent.

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);
 }
 
Parameter
Name Description
request DeleteAgentRequest

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

deleteAgent(String name)

public final void deleteAgent(String name)

Deletes the specified agent.

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);
 }
 
Parameter
Name Description
name String

Required. The name of the agent to delete. Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>.

deleteAgentCallable()

public final UnaryCallable<DeleteAgentRequest,Empty> deleteAgentCallable()

Deletes the specified agent.

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();
 }
 
Returns
Type Description
UnaryCallable<DeleteAgentRequest,Empty>

exportAgentAsync(ExportAgentRequest request)

public final OperationFuture<ExportAgentResponse,Struct> exportAgentAsync(ExportAgentRequest request)

Exports the specified agent to a binary file.

This method is a long-running operation. The returned Operation type has the following method-specific fields:

- metadata: An empty Struct message

  • response: 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())
            .build();
    ExportAgentResponse response = agentsClient.exportAgentAsync(request).get();
    }
    
Parameter
Name Description
request ExportAgentRequest

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

Returns
Type Description
OperationFuture<ExportAgentResponse,Struct>

exportAgentCallable()

public final UnaryCallable<ExportAgentRequest,Operation> exportAgentCallable()

Exports the specified agent to a binary file.

This method is a long-running operation. The returned Operation type has the following method-specific fields:

- metadata: An empty Struct message

  • response: 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())
            .build();
    ApiFuture<Operation> future = agentsClient.exportAgentCallable().futureCall(request);
    // Do something.
    Operation response = future.get();
    }
    
Returns
Type Description
UnaryCallable<ExportAgentRequest,Operation>

exportAgentOperationCallable()

public final OperationCallable<ExportAgentRequest,ExportAgentResponse,Struct> exportAgentOperationCallable()

Exports the specified agent to a binary file.

This method is a long-running operation. The returned Operation type has the following method-specific fields:

- metadata: An empty Struct message

  • response: 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())
            .build();
    OperationFuture<ExportAgentResponse, Struct> future =
        agentsClient.exportAgentOperationCallable().futureCall(request);
    // Do something.
    ExportAgentResponse response = future.get();
    }
    
Returns
Type Description
OperationCallable<ExportAgentRequest,ExportAgentResponse,Struct>

getAgent(AgentName name)

public final Agent getAgent(AgentName name)

Retrieves the specified agent.

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);
 }
 
Parameter
Name Description
name AgentName

Required. The name of the agent. Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>.

Returns
Type Description
Agent

getAgent(GetAgentRequest request)

public final Agent getAgent(GetAgentRequest request)

Retrieves the specified agent.

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);
 }
 
Parameter
Name Description
request GetAgentRequest

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

Returns
Type Description
Agent

getAgent(String name)

public final Agent getAgent(String name)

Retrieves the specified agent.

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);
 }
 
Parameter
Name Description
name String

Required. The name of the agent. Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>.

Returns
Type Description
Agent

getAgentCallable()

public final UnaryCallable<GetAgentRequest,Agent> getAgentCallable()

Retrieves the specified agent.

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();
 }
 
Returns
Type Description
UnaryCallable<GetAgentRequest,Agent>

getAgentValidationResult(AgentValidationResultName name)

public final AgentValidationResult getAgentValidationResult(AgentValidationResultName name)

Gets the latest agent validation result. Agent validation is performed when ValidateAgent is called.

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);
 }
 
Parameter
Name Description
name AgentValidationResultName

Required. The agent name. Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/validationResult.

Returns
Type Description
AgentValidationResult

getAgentValidationResult(GetAgentValidationResultRequest request)

public final AgentValidationResult getAgentValidationResult(GetAgentValidationResultRequest request)

Gets the latest agent validation result. Agent validation is performed when ValidateAgent is called.

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);
 }
 
Parameter
Name Description
request GetAgentValidationResultRequest

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

Returns
Type Description
AgentValidationResult

getAgentValidationResult(String name)

public final AgentValidationResult getAgentValidationResult(String name)

Gets the latest agent validation result. Agent validation is performed when ValidateAgent is called.

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);
 }
 
Parameter
Name Description
name String

Required. The agent name. Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/validationResult.

Returns
Type Description
AgentValidationResult

getAgentValidationResultCallable()

public final UnaryCallable<GetAgentValidationResultRequest,AgentValidationResult> getAgentValidationResultCallable()

Gets the latest agent validation result. Agent validation is performed when ValidateAgent is called.

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();
 }
 
Returns
Type Description
UnaryCallable<GetAgentValidationResultRequest,AgentValidationResult>

getHttpJsonOperationsClient()

public final OperationsClient getHttpJsonOperationsClient()

Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.

Returns
Type Description
OperationsClient

getLocation(GetLocationRequest request)

public final Location getLocation(GetLocationRequest request)

Gets information about a location.

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);
 }
 
Parameter
Name Description
request com.google.cloud.location.GetLocationRequest

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

Returns
Type Description
com.google.cloud.location.Location

getLocationCallable()

public final UnaryCallable<GetLocationRequest,Location> getLocationCallable()

Gets information about a location.

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();
 }
 
Returns
Type Description
UnaryCallable<com.google.cloud.location.GetLocationRequest,com.google.cloud.location.Location>

getOperationsClient()

public final OperationsClient getOperationsClient()

Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.

Returns
Type Description
OperationsClient

getSettings()

public final AgentsSettings getSettings()
Returns
Type Description
AgentsSettings

getStub()

public AgentsStub getStub()
Returns
Type Description
AgentsStub

isShutdown()

public boolean isShutdown()
Returns
Type Description
boolean

isTerminated()

public boolean isTerminated()
Returns
Type Description
boolean

listAgents(ListAgentsRequest request)

public final AgentsClient.ListAgentsPagedResponse listAgents(ListAgentsRequest request)

Returns the list of all agents in the specified location.

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);
   }
 }
 
Parameter
Name Description
request ListAgentsRequest

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

Returns
Type Description
AgentsClient.ListAgentsPagedResponse

listAgents(LocationName parent)

public final AgentsClient.ListAgentsPagedResponse listAgents(LocationName parent)

Returns the list of all agents in the specified location.

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);
   }
 }
 
Parameter
Name Description
parent LocationName

Required. The location to list all agents for. Format: projects/<Project ID>/locations/<Location ID>.

Returns
Type Description
AgentsClient.ListAgentsPagedResponse

listAgents(String parent)

public final AgentsClient.ListAgentsPagedResponse listAgents(String parent)

Returns the list of all agents in the specified location.

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);
   }
 }
 
Parameter
Name Description
parent String

Required. The location to list all agents for. Format: projects/<Project ID>/locations/<Location ID>.

Returns
Type Description
AgentsClient.ListAgentsPagedResponse

listAgentsCallable()

public final UnaryCallable<ListAgentsRequest,ListAgentsResponse> listAgentsCallable()

Returns the list of all agents in the specified location.

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;
     }
   }
 }
 
Returns
Type Description
UnaryCallable<ListAgentsRequest,ListAgentsResponse>

listAgentsPagedCallable()

public final UnaryCallable<ListAgentsRequest,AgentsClient.ListAgentsPagedResponse> listAgentsPagedCallable()

Returns the list of all agents in the specified location.

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);
   }
 }
 
Returns
Type Description
UnaryCallable<ListAgentsRequest,ListAgentsPagedResponse>

listLocations(ListLocationsRequest request)

public final AgentsClient.ListLocationsPagedResponse listLocations(ListLocationsRequest request)

Lists information about the supported locations for this service.

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);
   }
 }
 
Parameter
Name Description
request com.google.cloud.location.ListLocationsRequest

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

Returns
Type Description
AgentsClient.ListLocationsPagedResponse

listLocationsCallable()

public final UnaryCallable<ListLocationsRequest,ListLocationsResponse> listLocationsCallable()

Lists information about the supported locations for this service.

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;
     }
   }
 }
 
Returns
Type Description
UnaryCallable<com.google.cloud.location.ListLocationsRequest,com.google.cloud.location.ListLocationsResponse>

listLocationsPagedCallable()

public final UnaryCallable<ListLocationsRequest,AgentsClient.ListLocationsPagedResponse> listLocationsPagedCallable()

Lists information about the supported locations for this service.

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);
   }
 }
 
Returns
Type Description
UnaryCallable<com.google.cloud.location.ListLocationsRequest,ListLocationsPagedResponse>

restoreAgentAsync(RestoreAgentRequest request)

public final OperationFuture<Empty,Struct> restoreAgentAsync(RestoreAgentRequest request)

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. The returned Operation type has the following method-specific fields:

- metadata: An empty Struct message

  • response: An Empty message

    Note: You should always train flows prior to sending them queries. See the training documentation.

    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();
    }
    
Parameter
Name Description
request RestoreAgentRequest

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

Returns
Type Description
OperationFuture<Empty,Struct>

restoreAgentCallable()

public final UnaryCallable<RestoreAgentRequest,Operation> restoreAgentCallable()

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. The returned Operation type has the following method-specific fields:

- metadata: An empty Struct message

  • response: An Empty message

    Note: You should always train flows prior to sending them queries. See the training documentation.

    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();
    }
    
Returns
Type Description
UnaryCallable<RestoreAgentRequest,Operation>

restoreAgentOperationCallable()

public final OperationCallable<RestoreAgentRequest,Empty,Struct> restoreAgentOperationCallable()

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. The returned Operation type has the following method-specific fields:

- metadata: An empty Struct message

  • response: An Empty message

    Note: You should always train flows prior to sending them queries. See the training documentation.

    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();
    }
    
Returns
Type Description
OperationCallable<RestoreAgentRequest,Empty,Struct>

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()

updateAgent(Agent agent, FieldMask updateMask)

public final Agent updateAgent(Agent agent, FieldMask updateMask)

Updates the specified agent.

Note: You should always train flows prior to sending them queries. See the training documentation.

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);
 }
 
Parameters
Name Description
agent Agent

Required. The agent to update.

updateMask FieldMask

The mask to control which fields get updated. If the mask is not present, all fields will be updated.

Returns
Type Description
Agent

updateAgent(UpdateAgentRequest request)

public final Agent updateAgent(UpdateAgentRequest request)

Updates the specified agent.

Note: You should always train flows prior to sending them queries. See the training documentation.

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);
 }
 
Parameter
Name Description
request UpdateAgentRequest

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

Returns
Type Description
Agent

updateAgentCallable()

public final UnaryCallable<UpdateAgentRequest,Agent> updateAgentCallable()

Updates the specified agent.

Note: You should always train flows prior to sending them queries. See the training documentation.

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();
 }
 
Returns
Type Description
UnaryCallable<UpdateAgentRequest,Agent>

validateAgent(ValidateAgentRequest request)

public final AgentValidationResult validateAgent(ValidateAgentRequest request)

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.

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);
 }
 
Parameter
Name Description
request ValidateAgentRequest

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

Returns
Type Description
AgentValidationResult

validateAgentCallable()

public final UnaryCallable<ValidateAgentRequest,AgentValidationResult> validateAgentCallable()

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.

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();
 }
 
Returns
Type Description
UnaryCallable<ValidateAgentRequest,AgentValidationResult>