@Generated(value="by gapic-generator-java") public class SessionServiceClient extends Object implements com.google.api.gax.core.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 (SessionServiceClient sessionServiceClient = SessionServiceClient.create()) {
DataStoreName parent =
DataStoreName.ofProjectLocationDataStoreName("[PROJECT]", "[LOCATION]", "[DATA_STORE]");
Session session = Session.newBuilder().build();
Session response = sessionServiceClient.createSession(parent, session);
}
Note: close() needs to be called on the SessionServiceClient 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 |
|---|---|---|
CreateSession |
Creates a Session. If the [Session][google.cloud.discoveryengine.v1.Session] to create already exists, an ALREADY_EXISTS error is returned. |
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.
|
DeleteSession |
Deletes a Session. If the [Session][google.cloud.discoveryengine.v1.Session] to delete does not exist, a NOT_FOUND error is returned. |
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.
|
UpdateSession |
Updates a Session. [Session][google.cloud.discoveryengine.v1.Session] action type cannot be changed. If the [Session][google.cloud.discoveryengine.v1.Session] to update does not exist, a NOT_FOUND error is returned. |
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.
|
GetSession |
Gets a Session. |
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.
|
ListSessions |
Lists all Sessions by their parent [DataStore][google.cloud.discoveryengine.v1.DataStore]. |
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.
|
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 SessionServiceSettings 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
SessionServiceSettings sessionServiceSettings =
SessionServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
SessionServiceClient sessionServiceClient = SessionServiceClient.create(sessionServiceSettings);
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
SessionServiceSettings sessionServiceSettings =
SessionServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
SessionServiceClient sessionServiceClient = SessionServiceClient.create(sessionServiceSettings);
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
SessionServiceSettings sessionServiceSettings =
SessionServiceSettings.newHttpJsonBuilder().build();
SessionServiceClient sessionServiceClient = SessionServiceClient.create(sessionServiceSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
| Modifier and Type | Class and Description |
|---|---|
static class |
SessionServiceClient.ListSessionsFixedSizeCollection |
static class |
SessionServiceClient.ListSessionsPage |
static class |
SessionServiceClient.ListSessionsPagedResponse |
| Modifier | Constructor and Description |
|---|---|
protected |
SessionServiceClient(SessionServiceSettings settings)
Constructs an instance of SessionServiceClient, using the given settings.
|
protected |
SessionServiceClient(SessionServiceStub stub) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static SessionServiceClient |
create()
Constructs an instance of SessionServiceClient with default settings.
|
static SessionServiceClient |
create(SessionServiceSettings settings)
Constructs an instance of SessionServiceClient, using the given settings.
|
static SessionServiceClient |
create(SessionServiceStub stub)
Constructs an instance of SessionServiceClient, using the given stub for making calls.
|
Session |
createSession(CreateSessionRequest request)
Creates a Session.
|
Session |
createSession(DataStoreName parent,
Session session)
Creates a Session.
|
Session |
createSession(String parent,
Session session)
Creates a Session.
|
com.google.api.gax.rpc.UnaryCallable<CreateSessionRequest,Session> |
createSessionCallable()
Creates a Session.
|
void |
deleteSession(DeleteSessionRequest request)
Deletes a Session.
|
void |
deleteSession(SessionName name)
Deletes a Session.
|
void |
deleteSession(String name)
Deletes a Session.
|
com.google.api.gax.rpc.UnaryCallable<DeleteSessionRequest,com.google.protobuf.Empty> |
deleteSessionCallable()
Deletes a Session.
|
Session |
getSession(GetSessionRequest request)
Gets a Session.
|
Session |
getSession(SessionName name)
Gets a Session.
|
Session |
getSession(String name)
Gets a Session.
|
com.google.api.gax.rpc.UnaryCallable<GetSessionRequest,Session> |
getSessionCallable()
Gets a Session.
|
SessionServiceSettings |
getSettings() |
SessionServiceStub |
getStub() |
boolean |
isShutdown() |
boolean |
isTerminated() |
SessionServiceClient.ListSessionsPagedResponse |
listSessions(DataStoreName parent)
Lists all Sessions by their parent [DataStore][google.cloud.discoveryengine.v1.DataStore].
|
SessionServiceClient.ListSessionsPagedResponse |
listSessions(ListSessionsRequest request)
Lists all Sessions by their parent [DataStore][google.cloud.discoveryengine.v1.DataStore].
|
SessionServiceClient.ListSessionsPagedResponse |
listSessions(String parent)
Lists all Sessions by their parent [DataStore][google.cloud.discoveryengine.v1.DataStore].
|
com.google.api.gax.rpc.UnaryCallable<ListSessionsRequest,ListSessionsResponse> |
listSessionsCallable()
Lists all Sessions by their parent [DataStore][google.cloud.discoveryengine.v1.DataStore].
|
com.google.api.gax.rpc.UnaryCallable<ListSessionsRequest,SessionServiceClient.ListSessionsPagedResponse> |
listSessionsPagedCallable()
Lists all Sessions by their parent [DataStore][google.cloud.discoveryengine.v1.DataStore].
|
void |
shutdown() |
void |
shutdownNow() |
Session |
updateSession(Session session,
com.google.protobuf.FieldMask updateMask)
Updates a Session.
|
Session |
updateSession(UpdateSessionRequest request)
Updates a Session.
|
com.google.api.gax.rpc.UnaryCallable<UpdateSessionRequest,Session> |
updateSessionCallable()
Updates a Session.
|
protected SessionServiceClient(SessionServiceSettings settings) throws IOException
IOExceptionprotected SessionServiceClient(SessionServiceStub stub)
public static final SessionServiceClient create() throws IOException
IOExceptionpublic static final SessionServiceClient create(SessionServiceSettings settings) throws IOException
IOExceptionpublic static final SessionServiceClient create(SessionServiceStub stub)
public final SessionServiceSettings getSettings()
public SessionServiceStub getStub()
public final Session createSession(DataStoreName parent, Session session)
If the [Session][google.cloud.discoveryengine.v1.Session] to create already exists, an ALREADY_EXISTS error is returned.
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 (SessionServiceClient sessionServiceClient = SessionServiceClient.create()) {
DataStoreName parent =
DataStoreName.ofProjectLocationDataStoreName("[PROJECT]", "[LOCATION]", "[DATA_STORE]");
Session session = Session.newBuilder().build();
Session response = sessionServiceClient.createSession(parent, session);
}
parent - Required. Full resource name of parent data store. Format:
`projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store_id}`session - Required. The session to create.com.google.api.gax.rpc.ApiException - if the remote call failspublic final Session createSession(String parent, Session session)
If the [Session][google.cloud.discoveryengine.v1.Session] to create already exists, an ALREADY_EXISTS error is returned.
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 (SessionServiceClient sessionServiceClient = SessionServiceClient.create()) {
String parent =
DataStoreName.ofProjectLocationDataStoreName("[PROJECT]", "[LOCATION]", "[DATA_STORE]")
.toString();
Session session = Session.newBuilder().build();
Session response = sessionServiceClient.createSession(parent, session);
}
parent - Required. Full resource name of parent data store. Format:
`projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store_id}`session - Required. The session to create.com.google.api.gax.rpc.ApiException - if the remote call failspublic final Session createSession(CreateSessionRequest request)
If the [Session][google.cloud.discoveryengine.v1.Session] to create already exists, an ALREADY_EXISTS error is returned.
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 (SessionServiceClient sessionServiceClient = SessionServiceClient.create()) {
CreateSessionRequest request =
CreateSessionRequest.newBuilder()
.setParent(
DataStoreName.ofProjectLocationDataStoreName(
"[PROJECT]", "[LOCATION]", "[DATA_STORE]")
.toString())
.setSession(Session.newBuilder().build())
.build();
Session response = sessionServiceClient.createSession(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<CreateSessionRequest,Session> createSessionCallable()
If the [Session][google.cloud.discoveryengine.v1.Session] to create already exists, an ALREADY_EXISTS error is returned.
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 (SessionServiceClient sessionServiceClient = SessionServiceClient.create()) {
CreateSessionRequest request =
CreateSessionRequest.newBuilder()
.setParent(
DataStoreName.ofProjectLocationDataStoreName(
"[PROJECT]", "[LOCATION]", "[DATA_STORE]")
.toString())
.setSession(Session.newBuilder().build())
.build();
ApiFuture<Session> future = sessionServiceClient.createSessionCallable().futureCall(request);
// Do something.
Session response = future.get();
}
public final void deleteSession(SessionName name)
If the [Session][google.cloud.discoveryengine.v1.Session] to delete does not exist, a NOT_FOUND error is returned.
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 (SessionServiceClient sessionServiceClient = SessionServiceClient.create()) {
SessionName name =
SessionName.ofProjectLocationDataStoreSessionName(
"[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[SESSION]");
sessionServiceClient.deleteSession(name);
}
name - Required. The resource name of the Session to delete. Format:
`projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store_id}/sessions/{session_id}`com.google.api.gax.rpc.ApiException - if the remote call failspublic final void deleteSession(String name)
If the [Session][google.cloud.discoveryengine.v1.Session] to delete does not exist, a NOT_FOUND error is returned.
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 (SessionServiceClient sessionServiceClient = SessionServiceClient.create()) {
String name =
SessionName.ofProjectLocationDataStoreSessionName(
"[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[SESSION]")
.toString();
sessionServiceClient.deleteSession(name);
}
name - Required. The resource name of the Session to delete. Format:
`projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store_id}/sessions/{session_id}`com.google.api.gax.rpc.ApiException - if the remote call failspublic final void deleteSession(DeleteSessionRequest request)
If the [Session][google.cloud.discoveryengine.v1.Session] to delete does not exist, a NOT_FOUND error is returned.
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 (SessionServiceClient sessionServiceClient = SessionServiceClient.create()) {
DeleteSessionRequest request =
DeleteSessionRequest.newBuilder()
.setName(
SessionName.ofProjectLocationDataStoreSessionName(
"[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[SESSION]")
.toString())
.build();
sessionServiceClient.deleteSession(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<DeleteSessionRequest,com.google.protobuf.Empty> deleteSessionCallable()
If the [Session][google.cloud.discoveryengine.v1.Session] to delete does not exist, a NOT_FOUND error is returned.
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 (SessionServiceClient sessionServiceClient = SessionServiceClient.create()) {
DeleteSessionRequest request =
DeleteSessionRequest.newBuilder()
.setName(
SessionName.ofProjectLocationDataStoreSessionName(
"[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[SESSION]")
.toString())
.build();
ApiFuture<Empty> future = sessionServiceClient.deleteSessionCallable().futureCall(request);
// Do something.
future.get();
}
public final Session updateSession(Session session, com.google.protobuf.FieldMask updateMask)
[Session][google.cloud.discoveryengine.v1.Session] action type cannot be changed. If the [Session][google.cloud.discoveryengine.v1.Session] to update does not exist, a NOT_FOUND error is returned.
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 (SessionServiceClient sessionServiceClient = SessionServiceClient.create()) {
Session session = Session.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
Session response = sessionServiceClient.updateSession(session, updateMask);
}
session - Required. The Session to update.updateMask - Indicates which fields in the provided
[Session][google.cloud.discoveryengine.v1.Session] to update. The following are NOT
supported:
If not set or empty, all supported fields are updated.
com.google.api.gax.rpc.ApiException - if the remote call failspublic final Session updateSession(UpdateSessionRequest request)
[Session][google.cloud.discoveryengine.v1.Session] action type cannot be changed. If the [Session][google.cloud.discoveryengine.v1.Session] to update does not exist, a NOT_FOUND error is returned.
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 (SessionServiceClient sessionServiceClient = SessionServiceClient.create()) {
UpdateSessionRequest request =
UpdateSessionRequest.newBuilder()
.setSession(Session.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
Session response = sessionServiceClient.updateSession(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<UpdateSessionRequest,Session> updateSessionCallable()
[Session][google.cloud.discoveryengine.v1.Session] action type cannot be changed. If the [Session][google.cloud.discoveryengine.v1.Session] to update does not exist, a NOT_FOUND error is returned.
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 (SessionServiceClient sessionServiceClient = SessionServiceClient.create()) {
UpdateSessionRequest request =
UpdateSessionRequest.newBuilder()
.setSession(Session.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
ApiFuture<Session> future = sessionServiceClient.updateSessionCallable().futureCall(request);
// Do something.
Session response = future.get();
}
public final Session getSession(SessionName 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 (SessionServiceClient sessionServiceClient = SessionServiceClient.create()) {
SessionName name =
SessionName.ofProjectLocationDataStoreSessionName(
"[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[SESSION]");
Session response = sessionServiceClient.getSession(name);
}
name - Required. The resource name of the Session to get. Format:
`projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store_id}/sessions/{session_id}`com.google.api.gax.rpc.ApiException - if the remote call failspublic final Session getSession(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 (SessionServiceClient sessionServiceClient = SessionServiceClient.create()) {
String name =
SessionName.ofProjectLocationDataStoreSessionName(
"[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[SESSION]")
.toString();
Session response = sessionServiceClient.getSession(name);
}
name - Required. The resource name of the Session to get. Format:
`projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store_id}/sessions/{session_id}`com.google.api.gax.rpc.ApiException - if the remote call failspublic final Session getSession(GetSessionRequest 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 (SessionServiceClient sessionServiceClient = SessionServiceClient.create()) {
GetSessionRequest request =
GetSessionRequest.newBuilder()
.setName(
SessionName.ofProjectLocationDataStoreSessionName(
"[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[SESSION]")
.toString())
.setIncludeAnswerDetails(true)
.build();
Session response = sessionServiceClient.getSession(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<GetSessionRequest,Session> getSessionCallable()
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 (SessionServiceClient sessionServiceClient = SessionServiceClient.create()) {
GetSessionRequest request =
GetSessionRequest.newBuilder()
.setName(
SessionName.ofProjectLocationDataStoreSessionName(
"[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[SESSION]")
.toString())
.setIncludeAnswerDetails(true)
.build();
ApiFuture<Session> future = sessionServiceClient.getSessionCallable().futureCall(request);
// Do something.
Session response = future.get();
}
public final SessionServiceClient.ListSessionsPagedResponse listSessions(DataStoreName 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 (SessionServiceClient sessionServiceClient = SessionServiceClient.create()) {
DataStoreName parent =
DataStoreName.ofProjectLocationDataStoreName("[PROJECT]", "[LOCATION]", "[DATA_STORE]");
for (Session element : sessionServiceClient.listSessions(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent - Required. The data store resource name. Format:
`projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store_id}`com.google.api.gax.rpc.ApiException - if the remote call failspublic final SessionServiceClient.ListSessionsPagedResponse listSessions(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 (SessionServiceClient sessionServiceClient = SessionServiceClient.create()) {
String parent =
DataStoreName.ofProjectLocationDataStoreName("[PROJECT]", "[LOCATION]", "[DATA_STORE]")
.toString();
for (Session element : sessionServiceClient.listSessions(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent - Required. The data store resource name. Format:
`projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store_id}`com.google.api.gax.rpc.ApiException - if the remote call failspublic final SessionServiceClient.ListSessionsPagedResponse listSessions(ListSessionsRequest 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 (SessionServiceClient sessionServiceClient = SessionServiceClient.create()) {
ListSessionsRequest request =
ListSessionsRequest.newBuilder()
.setParent(
DataStoreName.ofProjectLocationDataStoreName(
"[PROJECT]", "[LOCATION]", "[DATA_STORE]")
.toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.setOrderBy("orderBy-1207110587")
.build();
for (Session element : sessionServiceClient.listSessions(request).iterateAll()) {
// doThingsWith(element);
}
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<ListSessionsRequest,SessionServiceClient.ListSessionsPagedResponse> listSessionsPagedCallable()
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 (SessionServiceClient sessionServiceClient = SessionServiceClient.create()) {
ListSessionsRequest request =
ListSessionsRequest.newBuilder()
.setParent(
DataStoreName.ofProjectLocationDataStoreName(
"[PROJECT]", "[LOCATION]", "[DATA_STORE]")
.toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.setOrderBy("orderBy-1207110587")
.build();
ApiFuture<Session> future =
sessionServiceClient.listSessionsPagedCallable().futureCall(request);
// Do something.
for (Session element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final com.google.api.gax.rpc.UnaryCallable<ListSessionsRequest,ListSessionsResponse> listSessionsCallable()
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 (SessionServiceClient sessionServiceClient = SessionServiceClient.create()) {
ListSessionsRequest request =
ListSessionsRequest.newBuilder()
.setParent(
DataStoreName.ofProjectLocationDataStoreName(
"[PROJECT]", "[LOCATION]", "[DATA_STORE]")
.toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.setOrderBy("orderBy-1207110587")
.build();
while (true) {
ListSessionsResponse response = sessionServiceClient.listSessionsCallable().call(request);
for (Session element : response.getSessionsList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final void close()
close in interface AutoCloseablepublic void shutdown()
shutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isShutdown()
isShutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isTerminated()
isTerminated in interface com.google.api.gax.core.BackgroundResourcepublic void shutdownNow()
shutdownNow in interface com.google.api.gax.core.BackgroundResourcepublic boolean awaitTermination(long duration,
TimeUnit unit)
throws InterruptedException
awaitTermination in interface com.google.api.gax.core.BackgroundResourceInterruptedExceptionCopyright © 2026 Google LLC. All rights reserved.