Class AssistantServiceClient (0.19.0)

GitHub RepositoryProduct ReferenceRPC Documentation

Service Description: The service that manages assistant-related resources in Customer Engagement Suite (CES). The assistant, Arc, is a conversational agent embedded in CES applications to help users with building their 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 (AssistantServiceClient assistantServiceClient = AssistantServiceClient.create()) {
   AssistantSessionName name =
       AssistantSessionName.of("[PROJECT]", "[LOCATION]", "[APP]", "[ASSISTANT_SESSION]");
   AssistantSession response = assistantServiceClient.getAssistantSession(name);
 }
 

Note: close() needs to be called on the AssistantServiceClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().

Methods
Method Description Method Variants

ListAssistantSessions

Lists all assistant sessions in the given app.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • listAssistantSessions(ListAssistantSessionsRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • listAssistantSessions(AppName parent)

  • listAssistantSessions(String parent)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listAssistantSessionsPagedCallable()

  • listAssistantSessionsCallable()

GetAssistantSession

Gets details of the specified assistant session.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getAssistantSession(GetAssistantSessionRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • getAssistantSession(AssistantSessionName name)

  • getAssistantSession(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getAssistantSessionCallable()

CreateAssistantSession

Creates a new assistant session in the given app.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • createAssistantSession(CreateAssistantSessionRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • createAssistantSession(AppName parent, String assistantSessionId)

  • createAssistantSession(String parent, String assistantSessionId)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • createAssistantSessionCallable()

DeleteAssistantSession

Deletes the specified assistant session.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • deleteAssistantSession(DeleteAssistantSessionRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • deleteAssistantSession(AssistantSessionName name)

  • deleteAssistantSession(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • deleteAssistantSessionCallable()

RunAssistant

Runs the assistant agent for the specified assistant session.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • runAssistant(RunAssistantRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • runAssistantCallable()

ChatAiAssistant

Runs Arc, the AI assistant, for the specified assistant session.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • chatAiAssistant(ChatAiAssistantRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • chatAiAssistantCallable()

ListLocations

Lists information about the supported locations for this service.

This method lists locations based on the resource scope provided inthe ListLocationsRequest.name field: ***Global locations**: If name is empty, the method lists thepublic locations available to all projects. * **Project-specificlocations**: If name follows the formatprojects/{project}, the method lists locations visible to thatspecific project. This includes public, private, or otherproject-specific locations enabled for the project.

For gRPC and client library implementations, the resource name ispassed as the name field. For direct service calls, the resourcename isincorporated into the request path based on the specific serviceimplementation and version.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • listLocations(ListLocationsRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listLocationsPagedCallable()

  • listLocationsCallable()

GetLocation

Gets information about a location.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getLocation(GetLocationRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getLocationCallable()

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 AssistantServiceSettings 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
 AssistantServiceSettings assistantServiceSettings =
     AssistantServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 AssistantServiceClient assistantServiceClient =
     AssistantServiceClient.create(assistantServiceSettings);
 

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
 AssistantServiceSettings assistantServiceSettings =
     AssistantServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
 AssistantServiceClient assistantServiceClient =
     AssistantServiceClient.create(assistantServiceSettings);
 

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
 AssistantServiceSettings assistantServiceSettings =
     AssistantServiceSettings.newHttpJsonBuilder().build();
 AssistantServiceClient assistantServiceClient =
     AssistantServiceClient.create(assistantServiceSettings);
 

Please refer to the GitHub repository's samples for more quickstart code snippets.

Inheritance

java.lang.Object > AssistantServiceClient

Static Methods

create()

public static final AssistantServiceClient create()

Constructs an instance of AssistantServiceClient with default settings.

Returns
Type Description
AssistantServiceClient
Exceptions
Type Description
IOException

create(AssistantServiceSettings settings)

public static final AssistantServiceClient create(AssistantServiceSettings settings)

Constructs an instance of AssistantServiceClient, 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 AssistantServiceSettings
Returns
Type Description
AssistantServiceClient
Exceptions
Type Description
IOException

create(AssistantServiceStub stub)

public static final AssistantServiceClient create(AssistantServiceStub stub)

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

Parameter
Name Description
stub AssistantServiceStub
Returns
Type Description
AssistantServiceClient

Constructors

AssistantServiceClient(AssistantServiceSettings settings)

protected AssistantServiceClient(AssistantServiceSettings settings)

Constructs an instance of AssistantServiceClient, 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 AssistantServiceSettings

AssistantServiceClient(AssistantServiceStub stub)

protected AssistantServiceClient(AssistantServiceStub stub)
Parameter
Name Description
stub AssistantServiceStub

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

chatAiAssistant(ChatAiAssistantRequest request)

public final ChatAiAssistantResponse chatAiAssistant(ChatAiAssistantRequest request)

Runs Arc, the AI assistant, for the specified assistant session.

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 (AssistantServiceClient assistantServiceClient = AssistantServiceClient.create()) {
   ChatAiAssistantRequest request =
       ChatAiAssistantRequest.newBuilder()
           .setApp(AppName.of("[PROJECT]", "[LOCATION]", "[APP]").toString())
           .setAssistantSession(
               AssistantSessionName.of("[PROJECT]", "[LOCATION]", "[APP]", "[ASSISTANT_SESSION]")
                   .toString())
           .setMessage("message954925063")
           .addAllAttachedGcsUris(new ArrayList<String>())
           .setContextToken("contextToken1106626954")
           .build();
   ChatAiAssistantResponse response = assistantServiceClient.chatAiAssistant(request);
 }
 
Parameter
Name Description
request ChatAiAssistantRequest

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

Returns
Type Description
ChatAiAssistantResponse

chatAiAssistantCallable()

public final UnaryCallable<ChatAiAssistantRequest,ChatAiAssistantResponse> chatAiAssistantCallable()

Runs Arc, the AI assistant, for the specified assistant session.

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 (AssistantServiceClient assistantServiceClient = AssistantServiceClient.create()) {
   ChatAiAssistantRequest request =
       ChatAiAssistantRequest.newBuilder()
           .setApp(AppName.of("[PROJECT]", "[LOCATION]", "[APP]").toString())
           .setAssistantSession(
               AssistantSessionName.of("[PROJECT]", "[LOCATION]", "[APP]", "[ASSISTANT_SESSION]")
                   .toString())
           .setMessage("message954925063")
           .addAllAttachedGcsUris(new ArrayList<String>())
           .setContextToken("contextToken1106626954")
           .build();
   ApiFuture<ChatAiAssistantResponse> future =
       assistantServiceClient.chatAiAssistantCallable().futureCall(request);
   // Do something.
   ChatAiAssistantResponse response = future.get();
 }
 
Returns
Type Description
UnaryCallable<ChatAiAssistantRequest,ChatAiAssistantResponse>

close()

public final void close()

createAssistantSession(@Nullable AppName parent, String assistantSessionId)

public final AssistantSession createAssistantSession(@Nullable AppName parent, String assistantSessionId)

Creates a new assistant session in the given app.

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 (AssistantServiceClient assistantServiceClient = AssistantServiceClient.create()) {
   AppName parent = AppName.of("[PROJECT]", "[LOCATION]", "[APP]");
   String assistantSessionId = "assistantSessionId-1566358253";
   AssistantSession response =
       assistantServiceClient.createAssistantSession(parent, assistantSessionId);
 }
 
Parameters
Name Description
parent @org.jspecify.annotations.Nullable com.google.cloud.ces.v1beta.AppName

Required. The app to create the assistant session in Format: projects/{project}/locations/{location}/apps/{app}

assistantSessionId String

Optional. The ID to use for the assistant session, which will become the final component of the assistant session's resource name. If not provided, a unique ID will be automatically assigned for the assistant session.

Returns
Type Description
AssistantSession

createAssistantSession(CreateAssistantSessionRequest request)

public final AssistantSession createAssistantSession(CreateAssistantSessionRequest request)

Creates a new assistant session in the given app.

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 (AssistantServiceClient assistantServiceClient = AssistantServiceClient.create()) {
   CreateAssistantSessionRequest request =
       CreateAssistantSessionRequest.newBuilder()
           .setParent(AppName.of("[PROJECT]", "[LOCATION]", "[APP]").toString())
           .setAssistantSessionId("assistantSessionId-1566358253")
           .addAllAssistantSessionMessages(new ArrayList<AssistantMessage>())
           .build();
   AssistantSession response = assistantServiceClient.createAssistantSession(request);
 }
 
Parameter
Name Description
request CreateAssistantSessionRequest

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

Returns
Type Description
AssistantSession

createAssistantSession(String parent, String assistantSessionId)

public final AssistantSession createAssistantSession(String parent, String assistantSessionId)

Creates a new assistant session in the given app.

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 (AssistantServiceClient assistantServiceClient = AssistantServiceClient.create()) {
   String parent = AppName.of("[PROJECT]", "[LOCATION]", "[APP]").toString();
   String assistantSessionId = "assistantSessionId-1566358253";
   AssistantSession response =
       assistantServiceClient.createAssistantSession(parent, assistantSessionId);
 }
 
Parameters
Name Description
parent String

Required. The app to create the assistant session in Format: projects/{project}/locations/{location}/apps/{app}

assistantSessionId String

Optional. The ID to use for the assistant session, which will become the final component of the assistant session's resource name. If not provided, a unique ID will be automatically assigned for the assistant session.

Returns
Type Description
AssistantSession

createAssistantSessionCallable()

public final UnaryCallable<CreateAssistantSessionRequest,AssistantSession> createAssistantSessionCallable()

Creates a new assistant session in the given app.

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 (AssistantServiceClient assistantServiceClient = AssistantServiceClient.create()) {
   CreateAssistantSessionRequest request =
       CreateAssistantSessionRequest.newBuilder()
           .setParent(AppName.of("[PROJECT]", "[LOCATION]", "[APP]").toString())
           .setAssistantSessionId("assistantSessionId-1566358253")
           .addAllAssistantSessionMessages(new ArrayList<AssistantMessage>())
           .build();
   ApiFuture<AssistantSession> future =
       assistantServiceClient.createAssistantSessionCallable().futureCall(request);
   // Do something.
   AssistantSession response = future.get();
 }
 
Returns
Type Description
UnaryCallable<CreateAssistantSessionRequest,AssistantSession>

deleteAssistantSession(@Nullable AssistantSessionName name)

public final void deleteAssistantSession(@Nullable AssistantSessionName name)

Deletes the specified assistant session.

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 (AssistantServiceClient assistantServiceClient = AssistantServiceClient.create()) {
   AssistantSessionName name =
       AssistantSessionName.of("[PROJECT]", "[LOCATION]", "[APP]", "[ASSISTANT_SESSION]");
   assistantServiceClient.deleteAssistantSession(name);
 }
 
Parameter
Name Description
name @org.jspecify.annotations.Nullable com.google.cloud.ces.v1beta.AssistantSessionName

Required. The name of the assistant session to delete. Format: projects/{project}/locations/{location}/apps/{app}/assistantSessions/{assistant_session}

deleteAssistantSession(DeleteAssistantSessionRequest request)

public final void deleteAssistantSession(DeleteAssistantSessionRequest request)

Deletes the specified assistant session.

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 (AssistantServiceClient assistantServiceClient = AssistantServiceClient.create()) {
   DeleteAssistantSessionRequest request =
       DeleteAssistantSessionRequest.newBuilder()
           .setName(
               AssistantSessionName.of("[PROJECT]", "[LOCATION]", "[APP]", "[ASSISTANT_SESSION]")
                   .toString())
           .build();
   assistantServiceClient.deleteAssistantSession(request);
 }
 
Parameter
Name Description
request DeleteAssistantSessionRequest

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

deleteAssistantSession(String name)

public final void deleteAssistantSession(String name)

Deletes the specified assistant session.

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 (AssistantServiceClient assistantServiceClient = AssistantServiceClient.create()) {
   String name =
       AssistantSessionName.of("[PROJECT]", "[LOCATION]", "[APP]", "[ASSISTANT_SESSION]")
           .toString();
   assistantServiceClient.deleteAssistantSession(name);
 }
 
Parameter
Name Description
name String

Required. The name of the assistant session to delete. Format: projects/{project}/locations/{location}/apps/{app}/assistantSessions/{assistant_session}

deleteAssistantSessionCallable()

public final UnaryCallable<DeleteAssistantSessionRequest,Empty> deleteAssistantSessionCallable()

Deletes the specified assistant session.

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 (AssistantServiceClient assistantServiceClient = AssistantServiceClient.create()) {
   DeleteAssistantSessionRequest request =
       DeleteAssistantSessionRequest.newBuilder()
           .setName(
               AssistantSessionName.of("[PROJECT]", "[LOCATION]", "[APP]", "[ASSISTANT_SESSION]")
                   .toString())
           .build();
   ApiFuture<Empty> future =
       assistantServiceClient.deleteAssistantSessionCallable().futureCall(request);
   // Do something.
   future.get();
 }
 
Returns
Type Description
UnaryCallable<DeleteAssistantSessionRequest,Empty>

getAssistantSession(@Nullable AssistantSessionName name)

public final AssistantSession getAssistantSession(@Nullable AssistantSessionName name)

Gets details of the specified assistant session.

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 (AssistantServiceClient assistantServiceClient = AssistantServiceClient.create()) {
   AssistantSessionName name =
       AssistantSessionName.of("[PROJECT]", "[LOCATION]", "[APP]", "[ASSISTANT_SESSION]");
   AssistantSession response = assistantServiceClient.getAssistantSession(name);
 }
 
Parameter
Name Description
name @org.jspecify.annotations.Nullable com.google.cloud.ces.v1beta.AssistantSessionName

Required. The name of the assistant session to retrieve. Format: projects/{project}/locations/{location}/apps/{app}/assistantSessions/{assistant_session}

Returns
Type Description
AssistantSession

getAssistantSession(GetAssistantSessionRequest request)

public final AssistantSession getAssistantSession(GetAssistantSessionRequest request)

Gets details of the specified assistant session.

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 (AssistantServiceClient assistantServiceClient = AssistantServiceClient.create()) {
   GetAssistantSessionRequest request =
       GetAssistantSessionRequest.newBuilder()
           .setName(
               AssistantSessionName.of("[PROJECT]", "[LOCATION]", "[APP]", "[ASSISTANT_SESSION]")
                   .toString())
           .build();
   AssistantSession response = assistantServiceClient.getAssistantSession(request);
 }
 
Parameter
Name Description
request GetAssistantSessionRequest

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

Returns
Type Description
AssistantSession

getAssistantSession(String name)

public final AssistantSession getAssistantSession(String name)

Gets details of the specified assistant session.

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 (AssistantServiceClient assistantServiceClient = AssistantServiceClient.create()) {
   String name =
       AssistantSessionName.of("[PROJECT]", "[LOCATION]", "[APP]", "[ASSISTANT_SESSION]")
           .toString();
   AssistantSession response = assistantServiceClient.getAssistantSession(name);
 }
 
Parameter
Name Description
name String

Required. The name of the assistant session to retrieve. Format: projects/{project}/locations/{location}/apps/{app}/assistantSessions/{assistant_session}

Returns
Type Description
AssistantSession

getAssistantSessionCallable()

public final UnaryCallable<GetAssistantSessionRequest,AssistantSession> getAssistantSessionCallable()

Gets details of the specified assistant session.

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 (AssistantServiceClient assistantServiceClient = AssistantServiceClient.create()) {
   GetAssistantSessionRequest request =
       GetAssistantSessionRequest.newBuilder()
           .setName(
               AssistantSessionName.of("[PROJECT]", "[LOCATION]", "[APP]", "[ASSISTANT_SESSION]")
                   .toString())
           .build();
   ApiFuture<AssistantSession> future =
       assistantServiceClient.getAssistantSessionCallable().futureCall(request);
   // Do something.
   AssistantSession response = future.get();
 }
 
Returns
Type Description
UnaryCallable<GetAssistantSessionRequest,AssistantSession>

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 (AssistantServiceClient assistantServiceClient = AssistantServiceClient.create()) {
   GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
   Location response = assistantServiceClient.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 (AssistantServiceClient assistantServiceClient = AssistantServiceClient.create()) {
   GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
   ApiFuture<Location> future = assistantServiceClient.getLocationCallable().futureCall(request);
   // Do something.
   Location response = future.get();
 }
 
Returns
Type Description
UnaryCallable<com.google.cloud.location.GetLocationRequest,com.google.cloud.location.Location>

getSettings()

public final @Nullable AssistantServiceSettings getSettings()
Returns
Type Description
@org.jspecify.annotations.Nullable com.google.cloud.ces.v1beta.AssistantServiceSettings

getStub()

public AssistantServiceStub getStub()
Returns
Type Description
AssistantServiceStub

isShutdown()

public boolean isShutdown()
Returns
Type Description
boolean

isTerminated()

public boolean isTerminated()
Returns
Type Description
boolean

listAssistantSessions(@Nullable AppName parent)

public final AssistantServiceClient.ListAssistantSessionsPagedResponse listAssistantSessions(@Nullable AppName parent)

Lists all assistant sessions in the given app.

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 (AssistantServiceClient assistantServiceClient = AssistantServiceClient.create()) {
   AppName parent = AppName.of("[PROJECT]", "[LOCATION]", "[APP]");
   for (AssistantSession element :
       assistantServiceClient.listAssistantSessions(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent @org.jspecify.annotations.Nullable com.google.cloud.ces.v1beta.AppName

Required. The app to list assistant sessions from. Format: projects/{project}/locations/{location}/apps/{app}

Returns
Type Description
AssistantServiceClient.ListAssistantSessionsPagedResponse

listAssistantSessions(ListAssistantSessionsRequest request)

public final AssistantServiceClient.ListAssistantSessionsPagedResponse listAssistantSessions(ListAssistantSessionsRequest request)

Lists all assistant sessions in the given app.

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 (AssistantServiceClient assistantServiceClient = AssistantServiceClient.create()) {
   ListAssistantSessionsRequest request =
       ListAssistantSessionsRequest.newBuilder()
           .setParent(AppName.of("[PROJECT]", "[LOCATION]", "[APP]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .build();
   for (AssistantSession element :
       assistantServiceClient.listAssistantSessions(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
request ListAssistantSessionsRequest

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

Returns
Type Description
AssistantServiceClient.ListAssistantSessionsPagedResponse

listAssistantSessions(String parent)

public final AssistantServiceClient.ListAssistantSessionsPagedResponse listAssistantSessions(String parent)

Lists all assistant sessions in the given app.

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 (AssistantServiceClient assistantServiceClient = AssistantServiceClient.create()) {
   String parent = AppName.of("[PROJECT]", "[LOCATION]", "[APP]").toString();
   for (AssistantSession element :
       assistantServiceClient.listAssistantSessions(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent String

Required. The app to list assistant sessions from. Format: projects/{project}/locations/{location}/apps/{app}

Returns
Type Description
AssistantServiceClient.ListAssistantSessionsPagedResponse

listAssistantSessionsCallable()

public final UnaryCallable<ListAssistantSessionsRequest,ListAssistantSessionsResponse> listAssistantSessionsCallable()

Lists all assistant sessions in the given app.

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 (AssistantServiceClient assistantServiceClient = AssistantServiceClient.create()) {
   ListAssistantSessionsRequest request =
       ListAssistantSessionsRequest.newBuilder()
           .setParent(AppName.of("[PROJECT]", "[LOCATION]", "[APP]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .build();
   while (true) {
     ListAssistantSessionsResponse response =
         assistantServiceClient.listAssistantSessionsCallable().call(request);
     for (AssistantSession element : response.getAssistantSessionsList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
Type Description
UnaryCallable<ListAssistantSessionsRequest,ListAssistantSessionsResponse>

listAssistantSessionsPagedCallable()

public final UnaryCallable<ListAssistantSessionsRequest,AssistantServiceClient.ListAssistantSessionsPagedResponse> listAssistantSessionsPagedCallable()

Lists all assistant sessions in the given app.

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 (AssistantServiceClient assistantServiceClient = AssistantServiceClient.create()) {
   ListAssistantSessionsRequest request =
       ListAssistantSessionsRequest.newBuilder()
           .setParent(AppName.of("[PROJECT]", "[LOCATION]", "[APP]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .build();
   ApiFuture<AssistantSession> future =
       assistantServiceClient.listAssistantSessionsPagedCallable().futureCall(request);
   // Do something.
   for (AssistantSession element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
Type Description
UnaryCallable<ListAssistantSessionsRequest,ListAssistantSessionsPagedResponse>

listLocations(ListLocationsRequest request)

public final AssistantServiceClient.ListLocationsPagedResponse listLocations(ListLocationsRequest request)

Lists information about the supported locations for this service.

This method lists locations based on the resource scope provided inthe ListLocationsRequest.name field: ***Global locations**: If name is empty, the method lists thepublic locations available to all projects. * **Project-specificlocations**: If name follows the formatprojects/{project}, the method lists locations visible to thatspecific project. This includes public, private, or otherproject-specific locations enabled for the project.

For gRPC and client library implementations, the resource name ispassed as the name field. For direct service calls, the resourcename isincorporated into the request path based on the specific serviceimplementation and version.

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 (AssistantServiceClient assistantServiceClient = AssistantServiceClient.create()) {
   ListLocationsRequest request =
       ListLocationsRequest.newBuilder()
           .setName("name3373707")
           .setFilter("filter-1274492040")
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   for (Location element : assistantServiceClient.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
AssistantServiceClient.ListLocationsPagedResponse

listLocationsCallable()

public final UnaryCallable<ListLocationsRequest,ListLocationsResponse> listLocationsCallable()

Lists information about the supported locations for this service.

This method lists locations based on the resource scope provided inthe ListLocationsRequest.name field: ***Global locations**: If name is empty, the method lists thepublic locations available to all projects. * **Project-specificlocations**: If name follows the formatprojects/{project}, the method lists locations visible to thatspecific project. This includes public, private, or otherproject-specific locations enabled for the project.

For gRPC and client library implementations, the resource name ispassed as the name field. For direct service calls, the resourcename isincorporated into the request path based on the specific serviceimplementation and version.

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 (AssistantServiceClient assistantServiceClient = AssistantServiceClient.create()) {
   ListLocationsRequest request =
       ListLocationsRequest.newBuilder()
           .setName("name3373707")
           .setFilter("filter-1274492040")
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   while (true) {
     ListLocationsResponse response =
         assistantServiceClient.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,AssistantServiceClient.ListLocationsPagedResponse> listLocationsPagedCallable()

Lists information about the supported locations for this service.

This method lists locations based on the resource scope provided inthe ListLocationsRequest.name field: ***Global locations**: If name is empty, the method lists thepublic locations available to all projects. * **Project-specificlocations**: If name follows the formatprojects/{project}, the method lists locations visible to thatspecific project. This includes public, private, or otherproject-specific locations enabled for the project.

For gRPC and client library implementations, the resource name ispassed as the name field. For direct service calls, the resourcename isincorporated into the request path based on the specific serviceimplementation and version.

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 (AssistantServiceClient assistantServiceClient = AssistantServiceClient.create()) {
   ListLocationsRequest request =
       ListLocationsRequest.newBuilder()
           .setName("name3373707")
           .setFilter("filter-1274492040")
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   ApiFuture<Location> future =
       assistantServiceClient.listLocationsPagedCallable().futureCall(request);
   // Do something.
   for (Location element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
Type Description
UnaryCallable<com.google.cloud.location.ListLocationsRequest,ListLocationsPagedResponse>

runAssistant(RunAssistantRequest request)

public final RunAssistantResponse runAssistant(RunAssistantRequest request)

Runs the assistant agent for the specified assistant session.

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 (AssistantServiceClient assistantServiceClient = AssistantServiceClient.create()) {
   RunAssistantRequest request =
       RunAssistantRequest.newBuilder()
           .setApp(AppName.of("[PROJECT]", "[LOCATION]", "[APP]").toString())
           .setAssistantSession(
               AssistantSessionName.of("[PROJECT]", "[LOCATION]", "[APP]", "[ASSISTANT_SESSION]")
                   .toString())
           .setMessage(AssistantMessage.newBuilder().build())
           .build();
   RunAssistantResponse response = assistantServiceClient.runAssistant(request);
 }
 
Parameter
Name Description
request RunAssistantRequest

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

Returns
Type Description
RunAssistantResponse

runAssistantCallable()

public final UnaryCallable<RunAssistantRequest,RunAssistantResponse> runAssistantCallable()

Runs the assistant agent for the specified assistant session.

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 (AssistantServiceClient assistantServiceClient = AssistantServiceClient.create()) {
   RunAssistantRequest request =
       RunAssistantRequest.newBuilder()
           .setApp(AppName.of("[PROJECT]", "[LOCATION]", "[APP]").toString())
           .setAssistantSession(
               AssistantSessionName.of("[PROJECT]", "[LOCATION]", "[APP]", "[ASSISTANT_SESSION]")
                   .toString())
           .setMessage(AssistantMessage.newBuilder().build())
           .build();
   ApiFuture<RunAssistantResponse> future =
       assistantServiceClient.runAssistantCallable().futureCall(request);
   // Do something.
   RunAssistantResponse response = future.get();
 }
 
Returns
Type Description
UnaryCallable<RunAssistantRequest,RunAssistantResponse>

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()