Class AgentsClient (4.6.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 for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (AgentsClient agentsClient = AgentsClient.create()) {
   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
   Agent response = agentsClient.getAgent(parent);
 }
 

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 for illustrative purposes only.
 // It may require modifications to work in your environment.
 AgentsSettings agentsSettings =
     AgentsSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 AgentsClient agentsClient = AgentsClient.create(agentsSettings);
 

To customize the endpoint:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 AgentsSettings agentsSettings = AgentsSettings.newBuilder().setEndpoint(myEndpoint).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
TypeDescription
AgentsClient
Exceptions
TypeDescription
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
NameDescription
settingsAgentsSettings
Returns
TypeDescription
AgentsClient
Exceptions
TypeDescription
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
NameDescription
stubAgentsStub
Returns
TypeDescription
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
NameDescription
settingsAgentsSettings

AgentsClient(AgentsStub stub)

protected AgentsClient(AgentsStub stub)
Parameter
NameDescription
stubAgentsStub

Methods

awaitTermination(long duration, TimeUnit unit)

public boolean awaitTermination(long duration, TimeUnit unit)
Parameters
NameDescription
durationlong
unitTimeUnit
Returns
TypeDescription
boolean
Exceptions
TypeDescription
InterruptedException

close()

public final void close()

deleteAgent(DeleteAgentRequest request)

public final void deleteAgent(DeleteAgentRequest request)

Deletes the specified agent.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (AgentsClient agentsClient = AgentsClient.create()) {
   DeleteAgentRequest request =
       DeleteAgentRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).build();
   agentsClient.deleteAgent(request);
 }
 
Parameter
NameDescription
requestDeleteAgentRequest

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

deleteAgent(LocationName parent)

public final void deleteAgent(LocationName parent)

Deletes the specified agent.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (AgentsClient agentsClient = AgentsClient.create()) {
   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
   agentsClient.deleteAgent(parent);
 }
 
Parameter
NameDescription
parentLocationName

Required. The project that the agent to delete is associated with. Format: projects/<Project ID>.

deleteAgent(ProjectName parent)

public final void deleteAgent(ProjectName parent)

Deletes the specified agent.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (AgentsClient agentsClient = AgentsClient.create()) {
   ProjectName parent = ProjectName.of("[PROJECT]");
   agentsClient.deleteAgent(parent);
 }
 
Parameter
NameDescription
parentProjectName

Required. The project that the agent to delete is associated with. Format: projects/<Project ID>.

deleteAgent(String parent)

public final void deleteAgent(String parent)

Deletes the specified agent.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (AgentsClient agentsClient = AgentsClient.create()) {
   String parent = ProjectName.of("[PROJECT]").toString();
   agentsClient.deleteAgent(parent);
 }
 
Parameter
NameDescription
parentString

Required. The project that the agent to delete is associated with. Format: projects/<Project ID>.

deleteAgentCallable()

public final UnaryCallable<DeleteAgentRequest,Empty> deleteAgentCallable()

Deletes the specified agent.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (AgentsClient agentsClient = AgentsClient.create()) {
   DeleteAgentRequest request =
       DeleteAgentRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).build();
   ApiFuture<Empty> future = agentsClient.deleteAgentCallable().futureCall(request);
   // Do something.
   future.get();
 }
 
Returns
TypeDescription
UnaryCallable<DeleteAgentRequest,Empty>

exportAgentAsync(ExportAgentRequest request)

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

Exports the specified agent to a ZIP 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 for illustrative purposes only.
    // It may require modifications to work in your environment.
    try (AgentsClient agentsClient = AgentsClient.create()) {
    ExportAgentRequest request =
        ExportAgentRequest.newBuilder()
            .setParent(ProjectName.of("[PROJECT]").toString())
            .setAgentUri("agentUri1469149223")
            .build();
    ExportAgentResponse response = agentsClient.exportAgentAsync(request).get();
    }
    
Parameter
NameDescription
requestExportAgentRequest

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

Returns
TypeDescription
OperationFuture<ExportAgentResponse,Struct>

exportAgentAsync(LocationName parent)

public final OperationFuture<ExportAgentResponse,Struct> exportAgentAsync(LocationName parent)

Exports the specified agent to a ZIP 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 for illustrative purposes only.
    // It may require modifications to work in your environment.
    try (AgentsClient agentsClient = AgentsClient.create()) {
    LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
    ExportAgentResponse response = agentsClient.exportAgentAsync(parent).get();
    }
    
Parameter
NameDescription
parentLocationName

Required. The project that the agent to export is associated with. Format: projects/<Project ID>.

Returns
TypeDescription
OperationFuture<ExportAgentResponse,Struct>

exportAgentAsync(ProjectName parent)

public final OperationFuture<ExportAgentResponse,Struct> exportAgentAsync(ProjectName parent)

Exports the specified agent to a ZIP 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 for illustrative purposes only.
    // It may require modifications to work in your environment.
    try (AgentsClient agentsClient = AgentsClient.create()) {
    ProjectName parent = ProjectName.of("[PROJECT]");
    ExportAgentResponse response = agentsClient.exportAgentAsync(parent).get();
    }
    
Parameter
NameDescription
parentProjectName

Required. The project that the agent to export is associated with. Format: projects/<Project ID>.

Returns
TypeDescription
OperationFuture<ExportAgentResponse,Struct>

exportAgentAsync(String parent)

public final OperationFuture<ExportAgentResponse,Struct> exportAgentAsync(String parent)

Exports the specified agent to a ZIP 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 for illustrative purposes only.
    // It may require modifications to work in your environment.
    try (AgentsClient agentsClient = AgentsClient.create()) {
    String parent = ProjectName.of("[PROJECT]").toString();
    ExportAgentResponse response = agentsClient.exportAgentAsync(parent).get();
    }
    
Parameter
NameDescription
parentString

Required. The project that the agent to export is associated with. Format: projects/<Project ID>.

Returns
TypeDescription
OperationFuture<ExportAgentResponse,Struct>

exportAgentCallable()

public final UnaryCallable<ExportAgentRequest,Operation> exportAgentCallable()

Exports the specified agent to a ZIP 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 for illustrative purposes only.
    // It may require modifications to work in your environment.
    try (AgentsClient agentsClient = AgentsClient.create()) {
    ExportAgentRequest request =
        ExportAgentRequest.newBuilder()
            .setParent(ProjectName.of("[PROJECT]").toString())
            .setAgentUri("agentUri1469149223")
            .build();
    ApiFuture<Operation> future = agentsClient.exportAgentCallable().futureCall(request);
    // Do something.
    Operation response = future.get();
    }
    
Returns
TypeDescription
UnaryCallable<ExportAgentRequest,Operation>

exportAgentOperationCallable()

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

Exports the specified agent to a ZIP 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 for illustrative purposes only.
    // It may require modifications to work in your environment.
    try (AgentsClient agentsClient = AgentsClient.create()) {
    ExportAgentRequest request =
        ExportAgentRequest.newBuilder()
            .setParent(ProjectName.of("[PROJECT]").toString())
            .setAgentUri("agentUri1469149223")
            .build();
    OperationFuture<ExportAgentResponse, Struct> future =
        agentsClient.exportAgentOperationCallable().futureCall(request);
    // Do something.
    ExportAgentResponse response = future.get();
    }
    
Returns
TypeDescription
OperationCallable<ExportAgentRequest,ExportAgentResponse,Struct>

getAgent(GetAgentRequest request)

public final Agent getAgent(GetAgentRequest request)

Retrieves the specified agent.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (AgentsClient agentsClient = AgentsClient.create()) {
   GetAgentRequest request =
       GetAgentRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).build();
   Agent response = agentsClient.getAgent(request);
 }
 
Parameter
NameDescription
requestGetAgentRequest

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

Returns
TypeDescription
Agent

getAgent(LocationName parent)

public final Agent getAgent(LocationName parent)

Retrieves the specified agent.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (AgentsClient agentsClient = AgentsClient.create()) {
   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
   Agent response = agentsClient.getAgent(parent);
 }
 
Parameter
NameDescription
parentLocationName

Required. The project that the agent to fetch is associated with. Format: projects/<Project ID>.

Returns
TypeDescription
Agent

getAgent(ProjectName parent)

public final Agent getAgent(ProjectName parent)

Retrieves the specified agent.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (AgentsClient agentsClient = AgentsClient.create()) {
   ProjectName parent = ProjectName.of("[PROJECT]");
   Agent response = agentsClient.getAgent(parent);
 }
 
Parameter
NameDescription
parentProjectName

Required. The project that the agent to fetch is associated with. Format: projects/<Project ID>.

Returns
TypeDescription
Agent

getAgent(String parent)

public final Agent getAgent(String parent)

Retrieves the specified agent.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (AgentsClient agentsClient = AgentsClient.create()) {
   String parent = ProjectName.of("[PROJECT]").toString();
   Agent response = agentsClient.getAgent(parent);
 }
 
Parameter
NameDescription
parentString

Required. The project that the agent to fetch is associated with. Format: projects/<Project ID>.

Returns
TypeDescription
Agent

getAgentCallable()

public final UnaryCallable<GetAgentRequest,Agent> getAgentCallable()

Retrieves the specified agent.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (AgentsClient agentsClient = AgentsClient.create()) {
   GetAgentRequest request =
       GetAgentRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).build();
   ApiFuture<Agent> future = agentsClient.getAgentCallable().futureCall(request);
   // Do something.
   Agent response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<GetAgentRequest,Agent>

getOperationsClient()

public final OperationsClient getOperationsClient()

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

Returns
TypeDescription
OperationsClient

getSettings()

public final AgentsSettings getSettings()
Returns
TypeDescription
AgentsSettings

getStub()

public AgentsStub getStub()
Returns
TypeDescription
AgentsStub

getValidationResult(GetValidationResultRequest request)

public final ValidationResult getValidationResult(GetValidationResultRequest request)

Gets agent validation result. Agent validation is performed during training time and is updated automatically when training is completed.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (AgentsClient agentsClient = AgentsClient.create()) {
   GetValidationResultRequest request =
       GetValidationResultRequest.newBuilder()
           .setParent(ProjectName.of("[PROJECT]").toString())
           .setLanguageCode("languageCode-2092349083")
           .build();
   ValidationResult response = agentsClient.getValidationResult(request);
 }
 
Parameter
NameDescription
requestGetValidationResultRequest

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

Returns
TypeDescription
ValidationResult

getValidationResultCallable()

public final UnaryCallable<GetValidationResultRequest,ValidationResult> getValidationResultCallable()

Gets agent validation result. Agent validation is performed during training time and is updated automatically when training is completed.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (AgentsClient agentsClient = AgentsClient.create()) {
   GetValidationResultRequest request =
       GetValidationResultRequest.newBuilder()
           .setParent(ProjectName.of("[PROJECT]").toString())
           .setLanguageCode("languageCode-2092349083")
           .build();
   ApiFuture<ValidationResult> future =
       agentsClient.getValidationResultCallable().futureCall(request);
   // Do something.
   ValidationResult response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<GetValidationResultRequest,ValidationResult>

importAgentAsync(ImportAgentRequest request)

public final OperationFuture<Empty,Struct> importAgentAsync(ImportAgentRequest request)

Imports the specified agent from a ZIP file.

Uploads new intents and entity types without deleting the existing ones. Intents and entity types with the same name are replaced with the new versions from ImportAgentRequest. After the import, the imported draft agent will be trained automatically (unless disabled in agent settings). However, once the import is done, training may not be completed yet. Please call TrainAgent and wait for the operation it returns in order to train explicitly.

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

    The operation only tracks when importing is complete, not when it is done training.

    Note: You should always train an agent prior to sending it queries. See the training documentation.

    Sample code:

    
    // This snippet has been automatically generated for illustrative purposes only.
    // It may require modifications to work in your environment.
    try (AgentsClient agentsClient = AgentsClient.create()) {
    ImportAgentRequest request =
        ImportAgentRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).build();
    agentsClient.importAgentAsync(request).get();
    }
    
Parameter
NameDescription
requestImportAgentRequest

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

Returns
TypeDescription
OperationFuture<Empty,Struct>

importAgentCallable()

public final UnaryCallable<ImportAgentRequest,Operation> importAgentCallable()

Imports the specified agent from a ZIP file.

Uploads new intents and entity types without deleting the existing ones. Intents and entity types with the same name are replaced with the new versions from ImportAgentRequest. After the import, the imported draft agent will be trained automatically (unless disabled in agent settings). However, once the import is done, training may not be completed yet. Please call TrainAgent and wait for the operation it returns in order to train explicitly.

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

    The operation only tracks when importing is complete, not when it is done training.

    Note: You should always train an agent prior to sending it queries. See the training documentation.

    Sample code:

    
    // This snippet has been automatically generated for illustrative purposes only.
    // It may require modifications to work in your environment.
    try (AgentsClient agentsClient = AgentsClient.create()) {
    ImportAgentRequest request =
        ImportAgentRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).build();
    ApiFuture<Operation> future = agentsClient.importAgentCallable().futureCall(request);
    // Do something.
    future.get();
    }
    
Returns
TypeDescription
UnaryCallable<ImportAgentRequest,Operation>

importAgentOperationCallable()

public final OperationCallable<ImportAgentRequest,Empty,Struct> importAgentOperationCallable()

Imports the specified agent from a ZIP file.

Uploads new intents and entity types without deleting the existing ones. Intents and entity types with the same name are replaced with the new versions from ImportAgentRequest. After the import, the imported draft agent will be trained automatically (unless disabled in agent settings). However, once the import is done, training may not be completed yet. Please call TrainAgent and wait for the operation it returns in order to train explicitly.

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

    The operation only tracks when importing is complete, not when it is done training.

    Note: You should always train an agent prior to sending it queries. See the training documentation.

    Sample code:

    
    // This snippet has been automatically generated for illustrative purposes only.
    // It may require modifications to work in your environment.
    try (AgentsClient agentsClient = AgentsClient.create()) {
    ImportAgentRequest request =
        ImportAgentRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).build();
    OperationFuture<Empty, Struct> future =
        agentsClient.importAgentOperationCallable().futureCall(request);
    // Do something.
    future.get();
    }
    
Returns
TypeDescription
OperationCallable<ImportAgentRequest,Empty,Struct>

isShutdown()

public boolean isShutdown()
Returns
TypeDescription
boolean

isTerminated()

public boolean isTerminated()
Returns
TypeDescription
boolean

restoreAgentAsync(RestoreAgentRequest request)

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

Restores the specified agent from a ZIP file.

Replaces the current agent version with a new one. All the intents and entity types in the older version are deleted. After the restore, the restored draft agent will be trained automatically (unless disabled in agent settings). However, once the restore is done, training may not be completed yet. Please call TrainAgent and wait for the operation it returns in order to train explicitly.

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

    The operation only tracks when restoring is complete, not when it is done training.

    Note: You should always train an agent prior to sending it queries. See the training documentation.

    Sample code:

    
    // This snippet has been automatically generated for illustrative purposes only.
    // It may require modifications to work in your environment.
    try (AgentsClient agentsClient = AgentsClient.create()) {
    RestoreAgentRequest request =
        RestoreAgentRequest.newBuilder()
            .setParent(ProjectName.of("[PROJECT]").toString())
            .build();
    agentsClient.restoreAgentAsync(request).get();
    }
    
Parameter
NameDescription
requestRestoreAgentRequest

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

Returns
TypeDescription
OperationFuture<Empty,Struct>

restoreAgentCallable()

public final UnaryCallable<RestoreAgentRequest,Operation> restoreAgentCallable()

Restores the specified agent from a ZIP file.

Replaces the current agent version with a new one. All the intents and entity types in the older version are deleted. After the restore, the restored draft agent will be trained automatically (unless disabled in agent settings). However, once the restore is done, training may not be completed yet. Please call TrainAgent and wait for the operation it returns in order to train explicitly.

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

    The operation only tracks when restoring is complete, not when it is done training.

    Note: You should always train an agent prior to sending it queries. See the training documentation.

    Sample code:

    
    // This snippet has been automatically generated for illustrative purposes only.
    // It may require modifications to work in your environment.
    try (AgentsClient agentsClient = AgentsClient.create()) {
    RestoreAgentRequest request =
        RestoreAgentRequest.newBuilder()
            .setParent(ProjectName.of("[PROJECT]").toString())
            .build();
    ApiFuture<Operation> future = agentsClient.restoreAgentCallable().futureCall(request);
    // Do something.
    future.get();
    }
    
Returns
TypeDescription
UnaryCallable<RestoreAgentRequest,Operation>

restoreAgentOperationCallable()

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

Restores the specified agent from a ZIP file.

Replaces the current agent version with a new one. All the intents and entity types in the older version are deleted. After the restore, the restored draft agent will be trained automatically (unless disabled in agent settings). However, once the restore is done, training may not be completed yet. Please call TrainAgent and wait for the operation it returns in order to train explicitly.

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

    The operation only tracks when restoring is complete, not when it is done training.

    Note: You should always train an agent prior to sending it queries. See the training documentation.

    Sample code:

    
    // This snippet has been automatically generated for illustrative purposes only.
    // It may require modifications to work in your environment.
    try (AgentsClient agentsClient = AgentsClient.create()) {
    RestoreAgentRequest request =
        RestoreAgentRequest.newBuilder()
            .setParent(ProjectName.of("[PROJECT]").toString())
            .build();
    OperationFuture<Empty, Struct> future =
        agentsClient.restoreAgentOperationCallable().futureCall(request);
    // Do something.
    future.get();
    }
    
Returns
TypeDescription
OperationCallable<RestoreAgentRequest,Empty,Struct>

searchAgents(LocationName parent)

public final AgentsClient.SearchAgentsPagedResponse searchAgents(LocationName parent)

Returns the list of agents.

Since there is at most one conversational agent per project, this method is useful primarily for listing all agents across projects the caller has access to. One can achieve that with a wildcard project collection id "-". Refer to List Sub-Collections.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (AgentsClient agentsClient = AgentsClient.create()) {
   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
   for (Agent element : agentsClient.searchAgents(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
parentLocationName

Required. The project to list agents from. Format: projects/<Project ID or '-'>.

Returns
TypeDescription
AgentsClient.SearchAgentsPagedResponse

searchAgents(ProjectName parent)

public final AgentsClient.SearchAgentsPagedResponse searchAgents(ProjectName parent)

Returns the list of agents.

Since there is at most one conversational agent per project, this method is useful primarily for listing all agents across projects the caller has access to. One can achieve that with a wildcard project collection id "-". Refer to List Sub-Collections.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (AgentsClient agentsClient = AgentsClient.create()) {
   ProjectName parent = ProjectName.of("[PROJECT]");
   for (Agent element : agentsClient.searchAgents(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
parentProjectName

Required. The project to list agents from. Format: projects/<Project ID or '-'>.

Returns
TypeDescription
AgentsClient.SearchAgentsPagedResponse

searchAgents(SearchAgentsRequest request)

public final AgentsClient.SearchAgentsPagedResponse searchAgents(SearchAgentsRequest request)

Returns the list of agents.

Since there is at most one conversational agent per project, this method is useful primarily for listing all agents across projects the caller has access to. One can achieve that with a wildcard project collection id "-". Refer to List Sub-Collections.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (AgentsClient agentsClient = AgentsClient.create()) {
   SearchAgentsRequest request =
       SearchAgentsRequest.newBuilder()
           .setParent(ProjectName.of("[PROJECT]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   for (Agent element : agentsClient.searchAgents(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
requestSearchAgentsRequest

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

Returns
TypeDescription
AgentsClient.SearchAgentsPagedResponse

searchAgents(String parent)

public final AgentsClient.SearchAgentsPagedResponse searchAgents(String parent)

Returns the list of agents.

Since there is at most one conversational agent per project, this method is useful primarily for listing all agents across projects the caller has access to. One can achieve that with a wildcard project collection id "-". Refer to List Sub-Collections.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (AgentsClient agentsClient = AgentsClient.create()) {
   String parent = ProjectName.of("[PROJECT]").toString();
   for (Agent element : agentsClient.searchAgents(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
parentString

Required. The project to list agents from. Format: projects/<Project ID or '-'>.

Returns
TypeDescription
AgentsClient.SearchAgentsPagedResponse

searchAgentsCallable()

public final UnaryCallable<SearchAgentsRequest,SearchAgentsResponse> searchAgentsCallable()

Returns the list of agents.

Since there is at most one conversational agent per project, this method is useful primarily for listing all agents across projects the caller has access to. One can achieve that with a wildcard project collection id "-". Refer to List Sub-Collections.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (AgentsClient agentsClient = AgentsClient.create()) {
   SearchAgentsRequest request =
       SearchAgentsRequest.newBuilder()
           .setParent(ProjectName.of("[PROJECT]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   while (true) {
     SearchAgentsResponse response = agentsClient.searchAgentsCallable().call(request);
     for (Agent element : response.getResponsesList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
TypeDescription
UnaryCallable<SearchAgentsRequest,SearchAgentsResponse>

searchAgentsPagedCallable()

public final UnaryCallable<SearchAgentsRequest,AgentsClient.SearchAgentsPagedResponse> searchAgentsPagedCallable()

Returns the list of agents.

Since there is at most one conversational agent per project, this method is useful primarily for listing all agents across projects the caller has access to. One can achieve that with a wildcard project collection id "-". Refer to List Sub-Collections.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (AgentsClient agentsClient = AgentsClient.create()) {
   SearchAgentsRequest request =
       SearchAgentsRequest.newBuilder()
           .setParent(ProjectName.of("[PROJECT]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   ApiFuture<Agent> future = agentsClient.searchAgentsPagedCallable().futureCall(request);
   // Do something.
   for (Agent element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
TypeDescription
UnaryCallable<SearchAgentsRequest,SearchAgentsPagedResponse>

setAgent(Agent agent)

public final Agent setAgent(Agent agent)

Creates/updates the specified agent.

Note: You should always train an agent prior to sending it queries. See the training documentation.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (AgentsClient agentsClient = AgentsClient.create()) {
   Agent agent = Agent.newBuilder().build();
   Agent response = agentsClient.setAgent(agent);
 }
 
Parameter
NameDescription
agentAgent

Required. The agent to update.

Returns
TypeDescription
Agent

setAgent(SetAgentRequest request)

public final Agent setAgent(SetAgentRequest request)

Creates/updates the specified agent.

Note: You should always train an agent prior to sending it queries. See the training documentation.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (AgentsClient agentsClient = AgentsClient.create()) {
   SetAgentRequest request =
       SetAgentRequest.newBuilder()
           .setAgent(Agent.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   Agent response = agentsClient.setAgent(request);
 }
 
Parameter
NameDescription
requestSetAgentRequest

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

Returns
TypeDescription
Agent

setAgentCallable()

public final UnaryCallable<SetAgentRequest,Agent> setAgentCallable()

Creates/updates the specified agent.

Note: You should always train an agent prior to sending it queries. See the training documentation.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (AgentsClient agentsClient = AgentsClient.create()) {
   SetAgentRequest request =
       SetAgentRequest.newBuilder()
           .setAgent(Agent.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   ApiFuture<Agent> future = agentsClient.setAgentCallable().futureCall(request);
   // Do something.
   Agent response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<SetAgentRequest,Agent>

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()

trainAgentAsync(LocationName parent)

public final OperationFuture<Empty,Struct> trainAgentAsync(LocationName parent)

Trains the specified agent.

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 an agent prior to sending it queries. See the training documentation.

    Sample code:

    
    // This snippet has been automatically generated for illustrative purposes only.
    // It may require modifications to work in your environment.
    try (AgentsClient agentsClient = AgentsClient.create()) {
    LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
    agentsClient.trainAgentAsync(parent).get();
    }
    
Parameter
NameDescription
parentLocationName

Required. The project that the agent to train is associated with. Format: projects/<Project ID>.

Returns
TypeDescription
OperationFuture<Empty,Struct>

trainAgentAsync(ProjectName parent)

public final OperationFuture<Empty,Struct> trainAgentAsync(ProjectName parent)

Trains the specified agent.

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 an agent prior to sending it queries. See the training documentation.

    Sample code:

    
    // This snippet has been automatically generated for illustrative purposes only.
    // It may require modifications to work in your environment.
    try (AgentsClient agentsClient = AgentsClient.create()) {
    ProjectName parent = ProjectName.of("[PROJECT]");
    agentsClient.trainAgentAsync(parent).get();
    }
    
Parameter
NameDescription
parentProjectName

Required. The project that the agent to train is associated with. Format: projects/<Project ID>.

Returns
TypeDescription
OperationFuture<Empty,Struct>

trainAgentAsync(TrainAgentRequest request)

public final OperationFuture<Empty,Struct> trainAgentAsync(TrainAgentRequest request)

Trains the specified agent.

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 an agent prior to sending it queries. See the training documentation.

    Sample code:

    
    // This snippet has been automatically generated for illustrative purposes only.
    // It may require modifications to work in your environment.
    try (AgentsClient agentsClient = AgentsClient.create()) {
    TrainAgentRequest request =
        TrainAgentRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).build();
    agentsClient.trainAgentAsync(request).get();
    }
    
Parameter
NameDescription
requestTrainAgentRequest

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

Returns
TypeDescription
OperationFuture<Empty,Struct>

trainAgentAsync(String parent)

public final OperationFuture<Empty,Struct> trainAgentAsync(String parent)

Trains the specified agent.

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 an agent prior to sending it queries. See the training documentation.

    Sample code:

    
    // This snippet has been automatically generated for illustrative purposes only.
    // It may require modifications to work in your environment.
    try (AgentsClient agentsClient = AgentsClient.create()) {
    String parent = ProjectName.of("[PROJECT]").toString();
    agentsClient.trainAgentAsync(parent).get();
    }
    
Parameter
NameDescription
parentString

Required. The project that the agent to train is associated with. Format: projects/<Project ID>.

Returns
TypeDescription
OperationFuture<Empty,Struct>

trainAgentCallable()

public final UnaryCallable<TrainAgentRequest,Operation> trainAgentCallable()

Trains the specified agent.

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 an agent prior to sending it queries. See the training documentation.

    Sample code:

    
    // This snippet has been automatically generated for illustrative purposes only.
    // It may require modifications to work in your environment.
    try (AgentsClient agentsClient = AgentsClient.create()) {
    TrainAgentRequest request =
        TrainAgentRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).build();
    ApiFuture<Operation> future = agentsClient.trainAgentCallable().futureCall(request);
    // Do something.
    future.get();
    }
    
Returns
TypeDescription
UnaryCallable<TrainAgentRequest,Operation>

trainAgentOperationCallable()

public final OperationCallable<TrainAgentRequest,Empty,Struct> trainAgentOperationCallable()

Trains the specified agent.

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 an agent prior to sending it queries. See the training documentation.

    Sample code:

    
    // This snippet has been automatically generated for illustrative purposes only.
    // It may require modifications to work in your environment.
    try (AgentsClient agentsClient = AgentsClient.create()) {
    TrainAgentRequest request =
        TrainAgentRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).build();
    OperationFuture<Empty, Struct> future =
        agentsClient.trainAgentOperationCallable().futureCall(request);
    // Do something.
    future.get();
    }
    
Returns
TypeDescription
OperationCallable<TrainAgentRequest,Empty,Struct>