@Generated(value="by gapic-generator-java") public class ConversationsClient extends Object implements BackgroundResource
This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ConversationsClient conversationsClient = ConversationsClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
Conversation conversation = Conversation.newBuilder().build();
Conversation response = conversationsClient.createConversation(parent, conversation);
}
Note: close() needs to be called on the ConversationsClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
The surface of this class includes several types of Java methods for each of the API's methods:
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 ConversationsSettings 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
ConversationsSettings conversationsSettings =
ConversationsSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
ConversationsClient conversationsClient = ConversationsClient.create(conversationsSettings);
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
ConversationsSettings conversationsSettings =
ConversationsSettings.newBuilder().setEndpoint(myEndpoint).build();
ConversationsClient conversationsClient = ConversationsClient.create(conversationsSettings);
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
ConversationsSettings conversationsSettings =
ConversationsSettings.newBuilder()
.setTransportChannelProvider(
ConversationsSettings.defaultHttpJsonTransportProviderBuilder().build())
.build();
ConversationsClient conversationsClient = ConversationsClient.create(conversationsSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
Modifier and Type | Class and Description |
---|---|
static class |
ConversationsClient.ListConversationsFixedSizeCollection |
static class |
ConversationsClient.ListConversationsPage |
static class |
ConversationsClient.ListConversationsPagedResponse |
static class |
ConversationsClient.ListLocationsFixedSizeCollection |
static class |
ConversationsClient.ListLocationsPage |
static class |
ConversationsClient.ListLocationsPagedResponse |
static class |
ConversationsClient.ListMessagesFixedSizeCollection |
static class |
ConversationsClient.ListMessagesPage |
static class |
ConversationsClient.ListMessagesPagedResponse |
Modifier | Constructor and Description |
---|---|
protected |
ConversationsClient(ConversationsSettings settings)
Constructs an instance of ConversationsClient, using the given settings.
|
protected |
ConversationsClient(ConversationsStub stub) |
Modifier and Type | Method and Description |
---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
Conversation |
completeConversation(CompleteConversationRequest request)
Completes the specified conversation.
|
Conversation |
completeConversation(ConversationName name)
Completes the specified conversation.
|
Conversation |
completeConversation(String name)
Completes the specified conversation.
|
UnaryCallable<CompleteConversationRequest,Conversation> |
completeConversationCallable()
Completes the specified conversation.
|
static ConversationsClient |
create()
Constructs an instance of ConversationsClient with default settings.
|
static ConversationsClient |
create(ConversationsSettings settings)
Constructs an instance of ConversationsClient, using the given settings.
|
static ConversationsClient |
create(ConversationsStub stub)
Constructs an instance of ConversationsClient, using the given stub for making calls.
|
Conversation |
createConversation(CreateConversationRequest request)
Creates a new conversation.
|
Conversation |
createConversation(LocationName parent,
Conversation conversation)
Creates a new conversation.
|
Conversation |
createConversation(ProjectName parent,
Conversation conversation)
Creates a new conversation.
|
Conversation |
createConversation(String parent,
Conversation conversation)
Creates a new conversation.
|
UnaryCallable<CreateConversationRequest,Conversation> |
createConversationCallable()
Creates a new conversation.
|
Conversation |
getConversation(ConversationName name)
Retrieves the specific conversation.
|
Conversation |
getConversation(GetConversationRequest request)
Retrieves the specific conversation.
|
Conversation |
getConversation(String name)
Retrieves the specific conversation.
|
UnaryCallable<GetConversationRequest,Conversation> |
getConversationCallable()
Retrieves the specific conversation.
|
com.google.cloud.location.Location |
getLocation(com.google.cloud.location.GetLocationRequest request)
Gets information about a location.
|
UnaryCallable<com.google.cloud.location.GetLocationRequest,com.google.cloud.location.Location> |
getLocationCallable()
Gets information about a location.
|
ConversationsSettings |
getSettings() |
ConversationsStub |
getStub() |
boolean |
isShutdown() |
boolean |
isTerminated() |
ConversationsClient.ListConversationsPagedResponse |
listConversations(ListConversationsRequest request)
Returns the list of all conversations in the specified project.
|
ConversationsClient.ListConversationsPagedResponse |
listConversations(LocationName parent)
Returns the list of all conversations in the specified project.
|
ConversationsClient.ListConversationsPagedResponse |
listConversations(ProjectName parent)
Returns the list of all conversations in the specified project.
|
ConversationsClient.ListConversationsPagedResponse |
listConversations(String parent)
Returns the list of all conversations in the specified project.
|
UnaryCallable<ListConversationsRequest,ListConversationsResponse> |
listConversationsCallable()
Returns the list of all conversations in the specified project.
|
UnaryCallable<ListConversationsRequest,ConversationsClient.ListConversationsPagedResponse> |
listConversationsPagedCallable()
Returns the list of all conversations in the specified project.
|
ConversationsClient.ListLocationsPagedResponse |
listLocations(com.google.cloud.location.ListLocationsRequest request)
Lists information about the supported locations for this service.
|
UnaryCallable<com.google.cloud.location.ListLocationsRequest,com.google.cloud.location.ListLocationsResponse> |
listLocationsCallable()
Lists information about the supported locations for this service.
|
UnaryCallable<com.google.cloud.location.ListLocationsRequest,ConversationsClient.ListLocationsPagedResponse> |
listLocationsPagedCallable()
Lists information about the supported locations for this service.
|
ConversationsClient.ListMessagesPagedResponse |
listMessages(ConversationName parent)
Lists messages that belong to a given conversation.
|
ConversationsClient.ListMessagesPagedResponse |
listMessages(ListMessagesRequest request)
Lists messages that belong to a given conversation.
|
ConversationsClient.ListMessagesPagedResponse |
listMessages(String parent)
Lists messages that belong to a given conversation.
|
UnaryCallable<ListMessagesRequest,ListMessagesResponse> |
listMessagesCallable()
Lists messages that belong to a given conversation.
|
UnaryCallable<ListMessagesRequest,ConversationsClient.ListMessagesPagedResponse> |
listMessagesPagedCallable()
Lists messages that belong to a given conversation.
|
void |
shutdown() |
void |
shutdownNow() |
protected ConversationsClient(ConversationsSettings settings) throws IOException
IOException
protected ConversationsClient(ConversationsStub stub)
public static final ConversationsClient create() throws IOException
IOException
public static final ConversationsClient create(ConversationsSettings settings) throws IOException
IOException
public static final ConversationsClient create(ConversationsStub stub)
public final ConversationsSettings getSettings()
public ConversationsStub getStub()
public final Conversation createConversation(LocationName parent, Conversation conversation)
Conversation Lifecycle: There are two stages during a conversation: Automated Agent Stage and Assist Stage.
For Automated Agent Stage, there will be a dialogflow agent responding to user queries.
For Assist Stage, there's no dialogflow agent responding to user queries. But we will provide suggestions which are generated from conversation.
If [Conversation.conversation_profile][google.cloud.dialogflow.v2.Conversation.conversation_profile] is configured for a dialogflow agent, conversation will start from `Automated Agent Stage`, otherwise, it will start from `Assist Stage`. And during `Automated Agent Stage`, once an [Intent][google.cloud.dialogflow.v2.Intent] with [Intent.live_agent_handoff][google.cloud.dialogflow.v2.Intent.live_agent_handoff] is triggered, conversation will transfer to Assist Stage.
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 (ConversationsClient conversationsClient = ConversationsClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
Conversation conversation = Conversation.newBuilder().build();
Conversation response = conversationsClient.createConversation(parent, conversation);
}
parent
- Required. Resource identifier of the project creating the conversation. Format:
`projects/<Project ID>/locations/<Location ID>`.conversation
- Required. The conversation to create.ApiException
- if the remote call failspublic final Conversation createConversation(ProjectName parent, Conversation conversation)
Conversation Lifecycle: There are two stages during a conversation: Automated Agent Stage and Assist Stage.
For Automated Agent Stage, there will be a dialogflow agent responding to user queries.
For Assist Stage, there's no dialogflow agent responding to user queries. But we will provide suggestions which are generated from conversation.
If [Conversation.conversation_profile][google.cloud.dialogflow.v2.Conversation.conversation_profile] is configured for a dialogflow agent, conversation will start from `Automated Agent Stage`, otherwise, it will start from `Assist Stage`. And during `Automated Agent Stage`, once an [Intent][google.cloud.dialogflow.v2.Intent] with [Intent.live_agent_handoff][google.cloud.dialogflow.v2.Intent.live_agent_handoff] is triggered, conversation will transfer to Assist Stage.
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 (ConversationsClient conversationsClient = ConversationsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
Conversation conversation = Conversation.newBuilder().build();
Conversation response = conversationsClient.createConversation(parent, conversation);
}
parent
- Required. Resource identifier of the project creating the conversation. Format:
`projects/<Project ID>/locations/<Location ID>`.conversation
- Required. The conversation to create.ApiException
- if the remote call failspublic final Conversation createConversation(String parent, Conversation conversation)
Conversation Lifecycle: There are two stages during a conversation: Automated Agent Stage and Assist Stage.
For Automated Agent Stage, there will be a dialogflow agent responding to user queries.
For Assist Stage, there's no dialogflow agent responding to user queries. But we will provide suggestions which are generated from conversation.
If [Conversation.conversation_profile][google.cloud.dialogflow.v2.Conversation.conversation_profile] is configured for a dialogflow agent, conversation will start from `Automated Agent Stage`, otherwise, it will start from `Assist Stage`. And during `Automated Agent Stage`, once an [Intent][google.cloud.dialogflow.v2.Intent] with [Intent.live_agent_handoff][google.cloud.dialogflow.v2.Intent.live_agent_handoff] is triggered, conversation will transfer to Assist Stage.
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 (ConversationsClient conversationsClient = ConversationsClient.create()) {
String parent = ProjectName.of("[PROJECT]").toString();
Conversation conversation = Conversation.newBuilder().build();
Conversation response = conversationsClient.createConversation(parent, conversation);
}
parent
- Required. Resource identifier of the project creating the conversation. Format:
`projects/<Project ID>/locations/<Location ID>`.conversation
- Required. The conversation to create.ApiException
- if the remote call failspublic final Conversation createConversation(CreateConversationRequest request)
Conversation Lifecycle: There are two stages during a conversation: Automated Agent Stage and Assist Stage.
For Automated Agent Stage, there will be a dialogflow agent responding to user queries.
For Assist Stage, there's no dialogflow agent responding to user queries. But we will provide suggestions which are generated from conversation.
If [Conversation.conversation_profile][google.cloud.dialogflow.v2.Conversation.conversation_profile] is configured for a dialogflow agent, conversation will start from `Automated Agent Stage`, otherwise, it will start from `Assist Stage`. And during `Automated Agent Stage`, once an [Intent][google.cloud.dialogflow.v2.Intent] with [Intent.live_agent_handoff][google.cloud.dialogflow.v2.Intent.live_agent_handoff] is triggered, conversation will transfer to Assist Stage.
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 (ConversationsClient conversationsClient = ConversationsClient.create()) {
CreateConversationRequest request =
CreateConversationRequest.newBuilder()
.setParent(ProjectName.of("[PROJECT]").toString())
.setConversation(Conversation.newBuilder().build())
.setConversationId("conversationId-1676095234")
.build();
Conversation response = conversationsClient.createConversation(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<CreateConversationRequest,Conversation> createConversationCallable()
Conversation Lifecycle: There are two stages during a conversation: Automated Agent Stage and Assist Stage.
For Automated Agent Stage, there will be a dialogflow agent responding to user queries.
For Assist Stage, there's no dialogflow agent responding to user queries. But we will provide suggestions which are generated from conversation.
If [Conversation.conversation_profile][google.cloud.dialogflow.v2.Conversation.conversation_profile] is configured for a dialogflow agent, conversation will start from `Automated Agent Stage`, otherwise, it will start from `Assist Stage`. And during `Automated Agent Stage`, once an [Intent][google.cloud.dialogflow.v2.Intent] with [Intent.live_agent_handoff][google.cloud.dialogflow.v2.Intent.live_agent_handoff] is triggered, conversation will transfer to Assist Stage.
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 (ConversationsClient conversationsClient = ConversationsClient.create()) {
CreateConversationRequest request =
CreateConversationRequest.newBuilder()
.setParent(ProjectName.of("[PROJECT]").toString())
.setConversation(Conversation.newBuilder().build())
.setConversationId("conversationId-1676095234")
.build();
ApiFuture<Conversation> future =
conversationsClient.createConversationCallable().futureCall(request);
// Do something.
Conversation response = future.get();
}
public final ConversationsClient.ListConversationsPagedResponse listConversations(LocationName parent)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ConversationsClient conversationsClient = ConversationsClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
for (Conversation element : conversationsClient.listConversations(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent
- Required. The project from which to list all conversation. Format:
`projects/<Project ID>/locations/<Location ID>`.ApiException
- if the remote call failspublic final ConversationsClient.ListConversationsPagedResponse listConversations(ProjectName 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 (ConversationsClient conversationsClient = ConversationsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
for (Conversation element : conversationsClient.listConversations(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent
- Required. The project from which to list all conversation. Format:
`projects/<Project ID>/locations/<Location ID>`.ApiException
- if the remote call failspublic final ConversationsClient.ListConversationsPagedResponse listConversations(String parent)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ConversationsClient conversationsClient = ConversationsClient.create()) {
String parent = ProjectName.of("[PROJECT]").toString();
for (Conversation element : conversationsClient.listConversations(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent
- Required. The project from which to list all conversation. Format:
`projects/<Project ID>/locations/<Location ID>`.ApiException
- if the remote call failspublic final ConversationsClient.ListConversationsPagedResponse listConversations(ListConversationsRequest request)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ConversationsClient conversationsClient = ConversationsClient.create()) {
ListConversationsRequest request =
ListConversationsRequest.newBuilder()
.setParent(ProjectName.of("[PROJECT]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.build();
for (Conversation element : conversationsClient.listConversations(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<ListConversationsRequest,ConversationsClient.ListConversationsPagedResponse> listConversationsPagedCallable()
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 (ConversationsClient conversationsClient = ConversationsClient.create()) {
ListConversationsRequest request =
ListConversationsRequest.newBuilder()
.setParent(ProjectName.of("[PROJECT]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.build();
ApiFuture<Conversation> future =
conversationsClient.listConversationsPagedCallable().futureCall(request);
// Do something.
for (Conversation element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final UnaryCallable<ListConversationsRequest,ListConversationsResponse> listConversationsCallable()
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 (ConversationsClient conversationsClient = ConversationsClient.create()) {
ListConversationsRequest request =
ListConversationsRequest.newBuilder()
.setParent(ProjectName.of("[PROJECT]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.build();
while (true) {
ListConversationsResponse response =
conversationsClient.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;
}
}
}
public final Conversation getConversation(ConversationName name)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ConversationsClient conversationsClient = ConversationsClient.create()) {
ConversationName name =
ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]");
Conversation response = conversationsClient.getConversation(name);
}
name
- Required. The name of the conversation. Format: `projects/<Project
ID>/locations/<Location ID>/conversations/<Conversation ID>`.ApiException
- if the remote call failspublic final Conversation getConversation(String name)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ConversationsClient conversationsClient = ConversationsClient.create()) {
String name =
ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]").toString();
Conversation response = conversationsClient.getConversation(name);
}
name
- Required. The name of the conversation. Format: `projects/<Project
ID>/locations/<Location ID>/conversations/<Conversation ID>`.ApiException
- if the remote call failspublic final Conversation getConversation(GetConversationRequest request)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ConversationsClient conversationsClient = ConversationsClient.create()) {
GetConversationRequest request =
GetConversationRequest.newBuilder()
.setName(
ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]")
.toString())
.build();
Conversation response = conversationsClient.getConversation(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<GetConversationRequest,Conversation> getConversationCallable()
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 (ConversationsClient conversationsClient = ConversationsClient.create()) {
GetConversationRequest request =
GetConversationRequest.newBuilder()
.setName(
ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]")
.toString())
.build();
ApiFuture<Conversation> future =
conversationsClient.getConversationCallable().futureCall(request);
// Do something.
Conversation response = future.get();
}
public final Conversation completeConversation(ConversationName name)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ConversationsClient conversationsClient = ConversationsClient.create()) {
ConversationName name =
ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]");
Conversation response = conversationsClient.completeConversation(name);
}
name
- Required. Resource identifier of the conversation to close. Format:
`projects/<Project ID>/locations/<Location ID>/conversations/<Conversation
ID>`.ApiException
- if the remote call failspublic final Conversation completeConversation(String name)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ConversationsClient conversationsClient = ConversationsClient.create()) {
String name =
ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]").toString();
Conversation response = conversationsClient.completeConversation(name);
}
name
- Required. Resource identifier of the conversation to close. Format:
`projects/<Project ID>/locations/<Location ID>/conversations/<Conversation
ID>`.ApiException
- if the remote call failspublic final Conversation completeConversation(CompleteConversationRequest request)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ConversationsClient conversationsClient = ConversationsClient.create()) {
CompleteConversationRequest request =
CompleteConversationRequest.newBuilder()
.setName(
ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]")
.toString())
.build();
Conversation response = conversationsClient.completeConversation(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<CompleteConversationRequest,Conversation> completeConversationCallable()
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 (ConversationsClient conversationsClient = ConversationsClient.create()) {
CompleteConversationRequest request =
CompleteConversationRequest.newBuilder()
.setName(
ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]")
.toString())
.build();
ApiFuture<Conversation> future =
conversationsClient.completeConversationCallable().futureCall(request);
// Do something.
Conversation response = future.get();
}
public final ConversationsClient.ListMessagesPagedResponse listMessages(ConversationName 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 (ConversationsClient conversationsClient = ConversationsClient.create()) {
ConversationName parent =
ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]");
for (Message element : conversationsClient.listMessages(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent
- Required. The name of the conversation to list messages for. Format:
`projects/<Project ID>/locations/<Location ID>/conversations/<Conversation
ID>`ApiException
- if the remote call failspublic final ConversationsClient.ListMessagesPagedResponse listMessages(String parent)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ConversationsClient conversationsClient = ConversationsClient.create()) {
String parent =
ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]").toString();
for (Message element : conversationsClient.listMessages(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent
- Required. The name of the conversation to list messages for. Format:
`projects/<Project ID>/locations/<Location ID>/conversations/<Conversation
ID>`ApiException
- if the remote call failspublic final ConversationsClient.ListMessagesPagedResponse listMessages(ListMessagesRequest request)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ConversationsClient conversationsClient = ConversationsClient.create()) {
ListMessagesRequest request =
ListMessagesRequest.newBuilder()
.setParent(
ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]")
.toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (Message element : conversationsClient.listMessages(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<ListMessagesRequest,ConversationsClient.ListMessagesPagedResponse> listMessagesPagedCallable()
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 (ConversationsClient conversationsClient = ConversationsClient.create()) {
ListMessagesRequest request =
ListMessagesRequest.newBuilder()
.setParent(
ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]")
.toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<Message> future =
conversationsClient.listMessagesPagedCallable().futureCall(request);
// Do something.
for (Message element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final UnaryCallable<ListMessagesRequest,ListMessagesResponse> listMessagesCallable()
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 (ConversationsClient conversationsClient = ConversationsClient.create()) {
ListMessagesRequest request =
ListMessagesRequest.newBuilder()
.setParent(
ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]")
.toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
ListMessagesResponse response = conversationsClient.listMessagesCallable().call(request);
for (Message element : response.getMessagesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final ConversationsClient.ListLocationsPagedResponse listLocations(com.google.cloud.location.ListLocationsRequest request)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ConversationsClient conversationsClient = ConversationsClient.create()) {
ListLocationsRequest request =
ListLocationsRequest.newBuilder()
.setName("name3373707")
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (Location element : conversationsClient.listLocations(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.location.ListLocationsRequest,ConversationsClient.ListLocationsPagedResponse> listLocationsPagedCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ConversationsClient conversationsClient = ConversationsClient.create()) {
ListLocationsRequest request =
ListLocationsRequest.newBuilder()
.setName("name3373707")
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<Location> future =
conversationsClient.listLocationsPagedCallable().futureCall(request);
// Do something.
for (Location element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final UnaryCallable<com.google.cloud.location.ListLocationsRequest,com.google.cloud.location.ListLocationsResponse> listLocationsCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ConversationsClient conversationsClient = ConversationsClient.create()) {
ListLocationsRequest request =
ListLocationsRequest.newBuilder()
.setName("name3373707")
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
ListLocationsResponse response = conversationsClient.listLocationsCallable().call(request);
for (Location element : response.getLocationsList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final com.google.cloud.location.Location getLocation(com.google.cloud.location.GetLocationRequest request)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ConversationsClient conversationsClient = ConversationsClient.create()) {
GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
Location response = conversationsClient.getLocation(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.location.GetLocationRequest,com.google.cloud.location.Location> getLocationCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ConversationsClient conversationsClient = ConversationsClient.create()) {
GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
ApiFuture<Location> future = conversationsClient.getLocationCallable().futureCall(request);
// Do something.
Location response = future.get();
}
public final void close()
close
in interface AutoCloseable
public void shutdown()
shutdown
in interface BackgroundResource
public boolean isShutdown()
isShutdown
in interface BackgroundResource
public boolean isTerminated()
isTerminated
in interface BackgroundResource
public void shutdownNow()
shutdownNow
in interface BackgroundResource
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
awaitTermination
in interface BackgroundResource
InterruptedException
Copyright © 2022 Google LLC. All rights reserved.