Class DataChatServiceClient
- All Implemented Interfaces:
BackgroundResource,AutoCloseable
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 (DataChatServiceClient dataChatServiceClient = DataChatServiceClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
Conversation conversation = Conversation.newBuilder().build();
String conversationId = "conversationId-1676095234";
Conversation response =
dataChatServiceClient.createConversation(parent, conversation, conversationId);
}
Note: close() needs to be called on the DataChatServiceClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
| Method | Description | Method Variants |
|---|---|---|
Chat |
Answers a data question by generating a stream of [Message][google.cloud.geminidataanalytics.v1alpha.Message] objects. |
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
CreateConversation |
Creates a new conversation to persist the conversation history. Each conversation will have multiple messages associated with it. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
DeleteConversation |
Deletes a conversation. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetConversation |
Gets details of a single conversation by using conversation id and parent. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ListConversations |
Lists all conversations for a given parent. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ListMessages |
Lists all messages for a given conversation. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
QueryData |
Queries data from a natural language user query. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ListLocations |
Lists information about the supported locations for this service.This method can be called in two ways: * **List all public locations:** Use the path `GET /v1/locations`.* **List project-visible locations:** Use the path`GET /v1/projects/{project_id}/locations`. This may include publiclocations as well as private or other locations specifically visibleto the project. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetLocation |
Gets information about a location. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
See the individual methods for example code.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.
This class can be customized by passing in a custom instance of DataChatServiceSettings 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
DataChatServiceSettings dataChatServiceSettings =
DataChatServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
DataChatServiceClient dataChatServiceClient =
DataChatServiceClient.create(dataChatServiceSettings);
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
DataChatServiceSettings dataChatServiceSettings =
DataChatServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
DataChatServiceClient dataChatServiceClient =
DataChatServiceClient.create(dataChatServiceSettings);
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
DataChatServiceSettings dataChatServiceSettings =
DataChatServiceSettings.newHttpJsonBuilder().build();
DataChatServiceClient dataChatServiceClient =
DataChatServiceClient.create(dataChatServiceSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic class -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDataChatServiceClient(DataChatServiceSettings settings) Constructs an instance of DataChatServiceClient, using the given settings.protected -
Method Summary
Modifier and TypeMethodDescriptionbooleanawaitTermination(long duration, TimeUnit unit) Answers a data question by generating a stream of [Message][google.cloud.geminidataanalytics.v1alpha.Message] objects.final voidclose()static final DataChatServiceClientcreate()Constructs an instance of DataChatServiceClient with default settings.static final DataChatServiceClientcreate(DataChatServiceSettings settings) Constructs an instance of DataChatServiceClient, using the given settings.static final DataChatServiceClientcreate(DataChatServiceStub stub) Constructs an instance of DataChatServiceClient, using the given stub for making calls.final ConversationCreates a new conversation to persist the conversation history.final ConversationcreateConversation(LocationName parent, Conversation conversation, String conversationId) Creates a new conversation to persist the conversation history.final ConversationcreateConversation(String parent, Conversation conversation, String conversationId) Creates a new conversation to persist the conversation history.Creates a new conversation to persist the conversation history.final voidDeletes a conversation.final voidDeletes a conversation.final voiddeleteConversation(String name) Deletes a conversation.final UnaryCallable<DeleteConversationRequest,com.google.protobuf.Empty> Deletes a conversation.final ConversationGets details of a single conversation by using conversation id and parent.final ConversationgetConversation(GetConversationRequest request) Gets details of a single conversation by using conversation id and parent.final ConversationgetConversation(String name) Gets details of a single conversation by using conversation id and parent.Gets details of a single conversation by using conversation id and parent.final LocationgetLocation(GetLocationRequest request) Gets information about a location.Gets information about a location.final DataChatServiceSettingsgetStub()booleanbooleanLists all conversations for a given parent.listConversations(LocationName parent) Lists all conversations for a given parent.listConversations(String parent) Lists all conversations for a given parent.Lists all conversations for a given parent.Lists all conversations for a given parent.listLocations(ListLocationsRequest request) Lists information about the supported locations for this service.This method can be called in two ways:Lists information about the supported locations for this service.This method can be called in two ways:Lists information about the supported locations for this service.This method can be called in two ways:listMessages(ConversationName parent) Lists all messages for a given conversation.listMessages(ListMessagesRequest request) Lists all messages for a given conversation.listMessages(String parent) Lists all messages for a given conversation.Lists all messages for a given conversation.Lists all messages for a given conversation.final QueryDataResponsequeryData(QueryDataRequest request) Queries data from a natural language user query.Queries data from a natural language user query.voidshutdown()void
-
Constructor Details
-
DataChatServiceClient
Constructs an instance of DataChatServiceClient, 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.- Throws:
IOException
-
DataChatServiceClient
-
-
Method Details
-
create
Constructs an instance of DataChatServiceClient with default settings.- Throws:
IOException
-
create
public static final DataChatServiceClient create(DataChatServiceSettings settings) throws IOException Constructs an instance of DataChatServiceClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.- Throws:
IOException
-
create
Constructs an instance of DataChatServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(DataChatServiceSettings). -
getSettings
-
getStub
-
chatCallable
Answers a data question by generating a stream of [Message][google.cloud.geminidataanalytics.v1alpha.Message] objects.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 (DataChatServiceClient dataChatServiceClient = DataChatServiceClient.create()) { ChatRequest request = ChatRequest.newBuilder() .setProject(ProjectName.of("[PROJECT]").toString()) .setParent("parent-995424086") .addAllMessages(new ArrayList<Message>()) .build(); ServerStream<Message> stream = dataChatServiceClient.chatCallable().call(request); for (Message response : stream) { // Do something when a response is received. } } -
createConversation
public final Conversation createConversation(LocationName parent, Conversation conversation, String conversationId) Creates a new conversation to persist the conversation history. Each conversation will have multiple messages associated with it.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 (DataChatServiceClient dataChatServiceClient = DataChatServiceClient.create()) { LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); Conversation conversation = Conversation.newBuilder().build(); String conversationId = "conversationId-1676095234"; Conversation response = dataChatServiceClient.createConversation(parent, conversation, conversationId); }- Parameters:
parent- Required. Parent value for CreateConversationRequest. Format: `projects/{project}/locations/{location}`conversation- Required. The conversation to create.conversationId- Optional. The conversation id of the conversation to create. Must be unique within the parent. The allowed format is: `^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$`. If not provided, the server will auto-generate a value for the id.- Throws:
ApiException- if the remote call fails
-
createConversation
public final Conversation createConversation(String parent, Conversation conversation, String conversationId) Creates a new conversation to persist the conversation history. Each conversation will have multiple messages associated with it.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 (DataChatServiceClient dataChatServiceClient = DataChatServiceClient.create()) { String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); Conversation conversation = Conversation.newBuilder().build(); String conversationId = "conversationId-1676095234"; Conversation response = dataChatServiceClient.createConversation(parent, conversation, conversationId); }- Parameters:
parent- Required. Parent value for CreateConversationRequest. Format: `projects/{project}/locations/{location}`conversation- Required. The conversation to create.conversationId- Optional. The conversation id of the conversation to create. Must be unique within the parent. The allowed format is: `^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$`. If not provided, the server will auto-generate a value for the id.- Throws:
ApiException- if the remote call fails
-
createConversation
Creates a new conversation to persist the conversation history. Each conversation will have multiple messages associated with it.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 (DataChatServiceClient dataChatServiceClient = DataChatServiceClient.create()) { CreateConversationRequest request = CreateConversationRequest.newBuilder() .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) .setConversationId("conversationId-1676095234") .setConversation(Conversation.newBuilder().build()) .setRequestId("requestId693933066") .build(); Conversation response = dataChatServiceClient.createConversation(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
createConversationCallable
Creates a new conversation to persist the conversation history. Each conversation will have multiple messages associated with it.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 (DataChatServiceClient dataChatServiceClient = DataChatServiceClient.create()) { CreateConversationRequest request = CreateConversationRequest.newBuilder() .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) .setConversationId("conversationId-1676095234") .setConversation(Conversation.newBuilder().build()) .setRequestId("requestId693933066") .build(); ApiFuture<Conversation> future = dataChatServiceClient.createConversationCallable().futureCall(request); // Do something. Conversation response = future.get(); } -
deleteConversation
Deletes a conversation.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 (DataChatServiceClient dataChatServiceClient = DataChatServiceClient.create()) { ConversationName name = ConversationName.of("[PROJECT]", "[LOCATION]", "[CONVERSATION]"); dataChatServiceClient.deleteConversation(name); }- Parameters:
name- Required. Name of the resource. Format: `projects/{project}/locations/{location}/conversations/{conversation}`- Throws:
ApiException- if the remote call fails
-
deleteConversation
Deletes a conversation.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 (DataChatServiceClient dataChatServiceClient = DataChatServiceClient.create()) { String name = ConversationName.of("[PROJECT]", "[LOCATION]", "[CONVERSATION]").toString(); dataChatServiceClient.deleteConversation(name); }- Parameters:
name- Required. Name of the resource. Format: `projects/{project}/locations/{location}/conversations/{conversation}`- Throws:
ApiException- if the remote call fails
-
deleteConversation
Deletes a conversation.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 (DataChatServiceClient dataChatServiceClient = DataChatServiceClient.create()) { DeleteConversationRequest request = DeleteConversationRequest.newBuilder() .setName(ConversationName.of("[PROJECT]", "[LOCATION]", "[CONVERSATION]").toString()) .build(); dataChatServiceClient.deleteConversation(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
deleteConversationCallable
public final UnaryCallable<DeleteConversationRequest,com.google.protobuf.Empty> deleteConversationCallable()Deletes a conversation.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 (DataChatServiceClient dataChatServiceClient = DataChatServiceClient.create()) { DeleteConversationRequest request = DeleteConversationRequest.newBuilder() .setName(ConversationName.of("[PROJECT]", "[LOCATION]", "[CONVERSATION]").toString()) .build(); ApiFuture<Empty> future = dataChatServiceClient.deleteConversationCallable().futureCall(request); // Do something. future.get(); } -
getConversation
Gets details of a single conversation by using conversation id and parent.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DataChatServiceClient dataChatServiceClient = DataChatServiceClient.create()) { ConversationName name = ConversationName.of("[PROJECT]", "[LOCATION]", "[CONVERSATION]"); Conversation response = dataChatServiceClient.getConversation(name); }- Parameters:
name- Required. Name of the resource. Format: `projects/{project}/locations/{location}/conversations/{conversation}`- Throws:
ApiException- if the remote call fails
-
getConversation
Gets details of a single conversation by using conversation id and parent.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DataChatServiceClient dataChatServiceClient = DataChatServiceClient.create()) { String name = ConversationName.of("[PROJECT]", "[LOCATION]", "[CONVERSATION]").toString(); Conversation response = dataChatServiceClient.getConversation(name); }- Parameters:
name- Required. Name of the resource. Format: `projects/{project}/locations/{location}/conversations/{conversation}`- Throws:
ApiException- if the remote call fails
-
getConversation
Gets details of a single conversation by using conversation id and parent.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DataChatServiceClient dataChatServiceClient = DataChatServiceClient.create()) { GetConversationRequest request = GetConversationRequest.newBuilder() .setName(ConversationName.of("[PROJECT]", "[LOCATION]", "[CONVERSATION]").toString()) .build(); Conversation response = dataChatServiceClient.getConversation(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
getConversationCallable
Gets details of a single conversation by using conversation id and parent.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DataChatServiceClient dataChatServiceClient = DataChatServiceClient.create()) { GetConversationRequest request = GetConversationRequest.newBuilder() .setName(ConversationName.of("[PROJECT]", "[LOCATION]", "[CONVERSATION]").toString()) .build(); ApiFuture<Conversation> future = dataChatServiceClient.getConversationCallable().futureCall(request); // Do something. Conversation response = future.get(); } -
listConversations
public final DataChatServiceClient.ListConversationsPagedResponse listConversations(LocationName parent) Lists all conversations for a given parent.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DataChatServiceClient dataChatServiceClient = DataChatServiceClient.create()) { LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); for (Conversation element : dataChatServiceClient.listConversations(parent).iterateAll()) { // doThingsWith(element); } }- Parameters:
parent- Required. Parent value for ListConversationsRequest. Format: `projects/{project}/locations/{location}`- Throws:
ApiException- if the remote call fails
-
listConversations
Lists all conversations for a given parent.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DataChatServiceClient dataChatServiceClient = DataChatServiceClient.create()) { String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); for (Conversation element : dataChatServiceClient.listConversations(parent).iterateAll()) { // doThingsWith(element); } }- Parameters:
parent- Required. Parent value for ListConversationsRequest. Format: `projects/{project}/locations/{location}`- Throws:
ApiException- if the remote call fails
-
listConversations
public final DataChatServiceClient.ListConversationsPagedResponse listConversations(ListConversationsRequest request) Lists all conversations for a given parent.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DataChatServiceClient dataChatServiceClient = DataChatServiceClient.create()) { ListConversationsRequest request = ListConversationsRequest.newBuilder() .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) .setPageSize(883849137) .setPageToken("pageToken873572522") .setFilter("filter-1274492040") .build(); for (Conversation element : dataChatServiceClient.listConversations(request).iterateAll()) { // doThingsWith(element); } }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
listConversationsPagedCallable
public final UnaryCallable<ListConversationsRequest,DataChatServiceClient.ListConversationsPagedResponse> listConversationsPagedCallable()Lists all conversations for a given parent.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DataChatServiceClient dataChatServiceClient = DataChatServiceClient.create()) { ListConversationsRequest request = ListConversationsRequest.newBuilder() .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) .setPageSize(883849137) .setPageToken("pageToken873572522") .setFilter("filter-1274492040") .build(); ApiFuture<Conversation> future = dataChatServiceClient.listConversationsPagedCallable().futureCall(request); // Do something. for (Conversation element : future.get().iterateAll()) { // doThingsWith(element); } } -
listConversationsCallable
public final UnaryCallable<ListConversationsRequest,ListConversationsResponse> listConversationsCallable()Lists all conversations for a given parent.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (DataChatServiceClient dataChatServiceClient = DataChatServiceClient.create()) { ListConversationsRequest request = ListConversationsRequest.newBuilder() .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) .setPageSize(883849137) .setPageToken("pageToken873572522") .setFilter("filter-1274492040") .build(); while (true) { ListConversationsResponse response = dataChatServiceClient.listConversationsCallable().call(request); for (Conversation element : response.getConversationsList()) { // doThingsWith(element); } String nextPageToken = response.getNextPageToken(); if (!Strings.isNullOrEmpty(nextPageToken)) { request = request.toBuilder().setPageToken(nextPageToken).build(); } else { break; } } } -
listMessages
Lists all messages for a given conversation.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 (DataChatServiceClient dataChatServiceClient = DataChatServiceClient.create()) { ConversationName parent = ConversationName.of("[PROJECT]", "[LOCATION]", "[CONVERSATION]"); for (StorageMessage element : dataChatServiceClient.listMessages(parent).iterateAll()) { // doThingsWith(element); } }- Parameters:
parent- Required. The conversation to list messages under. Format: `projects/{project}/locations/{location}/conversations/{conversation_id}`- Throws:
ApiException- if the remote call fails
-
listMessages
Lists all messages for a given conversation.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 (DataChatServiceClient dataChatServiceClient = DataChatServiceClient.create()) { String parent = ConversationName.of("[PROJECT]", "[LOCATION]", "[CONVERSATION]").toString(); for (StorageMessage element : dataChatServiceClient.listMessages(parent).iterateAll()) { // doThingsWith(element); } }- Parameters:
parent- Required. The conversation to list messages under. Format: `projects/{project}/locations/{location}/conversations/{conversation_id}`- Throws:
ApiException- if the remote call fails
-
listMessages
public final DataChatServiceClient.ListMessagesPagedResponse listMessages(ListMessagesRequest request) Lists all messages for a given conversation.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 (DataChatServiceClient dataChatServiceClient = DataChatServiceClient.create()) { ListMessagesRequest request = ListMessagesRequest.newBuilder() .setParent( ConversationName.of("[PROJECT]", "[LOCATION]", "[CONVERSATION]").toString()) .setPageSize(883849137) .setPageToken("pageToken873572522") .setFilter("filter-1274492040") .build(); for (StorageMessage element : dataChatServiceClient.listMessages(request).iterateAll()) { // doThingsWith(element); } }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
listMessagesPagedCallable
public final UnaryCallable<ListMessagesRequest,DataChatServiceClient.ListMessagesPagedResponse> listMessagesPagedCallable()Lists all messages for a given conversation.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 (DataChatServiceClient dataChatServiceClient = DataChatServiceClient.create()) { ListMessagesRequest request = ListMessagesRequest.newBuilder() .setParent( ConversationName.of("[PROJECT]", "[LOCATION]", "[CONVERSATION]").toString()) .setPageSize(883849137) .setPageToken("pageToken873572522") .setFilter("filter-1274492040") .build(); ApiFuture<StorageMessage> future = dataChatServiceClient.listMessagesPagedCallable().futureCall(request); // Do something. for (StorageMessage element : future.get().iterateAll()) { // doThingsWith(element); } } -
listMessagesCallable
Lists all messages for a given conversation.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 (DataChatServiceClient dataChatServiceClient = DataChatServiceClient.create()) { ListMessagesRequest request = ListMessagesRequest.newBuilder() .setParent( ConversationName.of("[PROJECT]", "[LOCATION]", "[CONVERSATION]").toString()) .setPageSize(883849137) .setPageToken("pageToken873572522") .setFilter("filter-1274492040") .build(); while (true) { ListMessagesResponse response = dataChatServiceClient.listMessagesCallable().call(request); for (StorageMessage element : response.getMessagesList()) { // doThingsWith(element); } String nextPageToken = response.getNextPageToken(); if (!Strings.isNullOrEmpty(nextPageToken)) { request = request.toBuilder().setPageToken(nextPageToken).build(); } else { break; } } } -
queryData
Queries data from a natural language user query.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 (DataChatServiceClient dataChatServiceClient = DataChatServiceClient.create()) { QueryDataRequest request = QueryDataRequest.newBuilder() .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) .setPrompt("prompt-979805852") .setContext(QueryDataContext.newBuilder().build()) .setGenerationOptions(GenerationOptions.newBuilder().build()) .build(); QueryDataResponse response = dataChatServiceClient.queryData(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
queryDataCallable
Queries data from a natural language user query.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 (DataChatServiceClient dataChatServiceClient = DataChatServiceClient.create()) { QueryDataRequest request = QueryDataRequest.newBuilder() .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) .setPrompt("prompt-979805852") .setContext(QueryDataContext.newBuilder().build()) .setGenerationOptions(GenerationOptions.newBuilder().build()) .build(); ApiFuture<QueryDataResponse> future = dataChatServiceClient.queryDataCallable().futureCall(request); // Do something. QueryDataResponse response = future.get(); } -
listLocations
public final DataChatServiceClient.ListLocationsPagedResponse listLocations(ListLocationsRequest request) Lists information about the supported locations for this service.This method can be called in two ways:* **List all public locations:** Use the path `GET /v1/locations`.* **List project-visible locations:** Use the path`GET /v1/projects/{project_id}/locations`. This may include publiclocations as well as private or other locations specifically visibleto the project.
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 (DataChatServiceClient dataChatServiceClient = DataChatServiceClient.create()) { ListLocationsRequest request = ListLocationsRequest.newBuilder() .setName("name3373707") .setFilter("filter-1274492040") .setPageSize(883849137) .setPageToken("pageToken873572522") .build(); for (Location element : dataChatServiceClient.listLocations(request).iterateAll()) { // doThingsWith(element); } }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
listLocationsPagedCallable
public final UnaryCallable<ListLocationsRequest,DataChatServiceClient.ListLocationsPagedResponse> listLocationsPagedCallable()Lists information about the supported locations for this service.This method can be called in two ways:* **List all public locations:** Use the path `GET /v1/locations`.* **List project-visible locations:** Use the path`GET /v1/projects/{project_id}/locations`. This may include publiclocations as well as private or other locations specifically visibleto the project.
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 (DataChatServiceClient dataChatServiceClient = DataChatServiceClient.create()) { ListLocationsRequest request = ListLocationsRequest.newBuilder() .setName("name3373707") .setFilter("filter-1274492040") .setPageSize(883849137) .setPageToken("pageToken873572522") .build(); ApiFuture<Location> future = dataChatServiceClient.listLocationsPagedCallable().futureCall(request); // Do something. for (Location element : future.get().iterateAll()) { // doThingsWith(element); } } -
listLocationsCallable
Lists information about the supported locations for this service.This method can be called in two ways:* **List all public locations:** Use the path `GET /v1/locations`.* **List project-visible locations:** Use the path`GET /v1/projects/{project_id}/locations`. This may include publiclocations as well as private or other locations specifically visibleto the project.
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 (DataChatServiceClient dataChatServiceClient = DataChatServiceClient.create()) { ListLocationsRequest request = ListLocationsRequest.newBuilder() .setName("name3373707") .setFilter("filter-1274492040") .setPageSize(883849137) .setPageToken("pageToken873572522") .build(); while (true) { ListLocationsResponse response = dataChatServiceClient.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; } } } -
getLocation
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 (DataChatServiceClient dataChatServiceClient = DataChatServiceClient.create()) { GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build(); Location response = dataChatServiceClient.getLocation(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
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 (DataChatServiceClient dataChatServiceClient = DataChatServiceClient.create()) { GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build(); ApiFuture<Location> future = dataChatServiceClient.getLocationCallable().futureCall(request); // Do something. Location response = future.get(); } -
close
public final void close()- Specified by:
closein interfaceAutoCloseable
-
shutdown
public void shutdown()- Specified by:
shutdownin interfaceBackgroundResource
-
isShutdown
public boolean isShutdown()- Specified by:
isShutdownin interfaceBackgroundResource
-
isTerminated
public boolean isTerminated()- Specified by:
isTerminatedin interfaceBackgroundResource
-
shutdownNow
public void shutdownNow()- Specified by:
shutdownNowin interfaceBackgroundResource
-
awaitTermination
- Specified by:
awaitTerminationin interfaceBackgroundResource- Throws:
InterruptedException
-