Class DirectAccessServiceClient (0.2.0)

GitHub RepositoryProduct Reference

Service Description: A service for allocating Android devices and interacting with the live-allocated devices.

Each Session will wait for available capacity, at a higher priority over Test Execution. When allocated, the session will be exposed through a stream for integration.

DirectAccessService is currently available as a preview to select developers. You can register today on behalf of you and your team at https://developer.android.com/studio/preview/android-device-streaming

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 (DirectAccessServiceClient directAccessServiceClient = DirectAccessServiceClient.create()) {
   ProjectName parent = ProjectName.of("[PROJECT]");
   DeviceSession deviceSession = DeviceSession.newBuilder().build();
   String deviceSessionId = "deviceSessionId-544276325";
   DeviceSession response =
       directAccessServiceClient.createDeviceSession(parent, deviceSession, deviceSessionId);
 }
 

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

Methods
Method Description Method Variants

CreateDeviceSession

Creates a DeviceSession.

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

  • createDeviceSession(CreateDeviceSessionRequest request)

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

  • createDeviceSession(ProjectName parent, DeviceSession deviceSession, String deviceSessionId)

  • createDeviceSession(String parent, DeviceSession deviceSession, String deviceSessionId)

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

  • createDeviceSessionCallable()

ListDeviceSessions

Lists DeviceSessions owned by the project user.

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

  • listDeviceSessions(ListDeviceSessionsRequest request)

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

  • listDeviceSessions(ProjectName parent)

  • listDeviceSessions(String parent)

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

  • listDeviceSessionsPagedCallable()

  • listDeviceSessionsCallable()

GetDeviceSession

Gets a DeviceSession, which documents the allocation status and whether the device is allocated. Clients making requests from this API must poll GetDeviceSession.

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

  • getDeviceSession(GetDeviceSessionRequest request)

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

  • getDeviceSession(DeviceSessionName name)

  • getDeviceSession(String name)

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

  • getDeviceSessionCallable()

CancelDeviceSession

Cancel a DeviceSession. This RPC changes the DeviceSession to state FINISHED and terminates all connections. Canceled sessions are not deleted and can be retrieved or listed by the user until they expire based on the 28 day deletion policy.

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

  • cancelDeviceSession(CancelDeviceSessionRequest request)

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

  • cancelDeviceSessionCallable()

UpdateDeviceSession

Updates the current DeviceSession to the fields described by the update_mask.

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

  • updateDeviceSession(UpdateDeviceSessionRequest request)

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

  • updateDeviceSession(DeviceSession deviceSession, FieldMask updateMask)

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

  • updateDeviceSessionCallable()

AdbConnect

Exposes an ADB connection if the device supports ADB. gRPC headers are used to authenticate the Connect RPC, as well as associate to a particular DeviceSession. In particular, the user must specify the "X-Omnilab-Session-Name" header.

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

  • adbConnectCallable()

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 DirectAccessServiceSettings 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
 DirectAccessServiceSettings directAccessServiceSettings =
     DirectAccessServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 DirectAccessServiceClient directAccessServiceClient =
     DirectAccessServiceClient.create(directAccessServiceSettings);
 

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
 DirectAccessServiceSettings directAccessServiceSettings =
     DirectAccessServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
 DirectAccessServiceClient directAccessServiceClient =
     DirectAccessServiceClient.create(directAccessServiceSettings);
 

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
 DirectAccessServiceSettings directAccessServiceSettings =
     DirectAccessServiceSettings.newHttpJsonBuilder().build();
 DirectAccessServiceClient directAccessServiceClient =
     DirectAccessServiceClient.create(directAccessServiceSettings);
 

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

Inheritance

java.lang.Object > DirectAccessServiceClient

Static Methods

create()

public static final DirectAccessServiceClient create()

Constructs an instance of DirectAccessServiceClient with default settings.

Returns
Type Description
DirectAccessServiceClient
Exceptions
Type Description
IOException

create(DirectAccessServiceSettings settings)

public static final DirectAccessServiceClient create(DirectAccessServiceSettings settings)

Constructs an instance of DirectAccessServiceClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.

Parameter
Name Description
settings DirectAccessServiceSettings
Returns
Type Description
DirectAccessServiceClient
Exceptions
Type Description
IOException

create(DirectAccessServiceStub stub)

public static final DirectAccessServiceClient create(DirectAccessServiceStub stub)

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

Parameter
Name Description
stub DirectAccessServiceStub
Returns
Type Description
DirectAccessServiceClient

Constructors

DirectAccessServiceClient(DirectAccessServiceSettings settings)

protected DirectAccessServiceClient(DirectAccessServiceSettings settings)

Constructs an instance of DirectAccessServiceClient, using the given settings. This is protected so that it is easy to make a subclass, but otherwise, the static factory methods should be preferred.

Parameter
Name Description
settings DirectAccessServiceSettings

DirectAccessServiceClient(DirectAccessServiceStub stub)

protected DirectAccessServiceClient(DirectAccessServiceStub stub)
Parameter
Name Description
stub DirectAccessServiceStub

Methods

adbConnectCallable()

public final BidiStreamingCallable<AdbMessage,DeviceMessage> adbConnectCallable()

Exposes an ADB connection if the device supports ADB. gRPC headers are used to authenticate the Connect RPC, as well as associate to a particular DeviceSession. In particular, the user must specify the "X-Omnilab-Session-Name" header.

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 (DirectAccessServiceClient directAccessServiceClient = DirectAccessServiceClient.create()) {
   BidiStream<AdbMessage, DeviceMessage> bidiStream =
       directAccessServiceClient.adbConnectCallable().call();
   AdbMessage request = AdbMessage.newBuilder().build();
   bidiStream.send(request);
   for (DeviceMessage response : bidiStream) {
     // Do something when a response is received.
   }
 }
 
Returns
Type Description
BidiStreamingCallable<AdbMessage,DeviceMessage>

awaitTermination(long duration, TimeUnit unit)

public boolean awaitTermination(long duration, TimeUnit unit)
Parameters
Name Description
duration long
unit TimeUnit
Returns
Type Description
boolean
Exceptions
Type Description
InterruptedException

cancelDeviceSession(CancelDeviceSessionRequest request)

public final void cancelDeviceSession(CancelDeviceSessionRequest request)

Cancel a DeviceSession. This RPC changes the DeviceSession to state FINISHED and terminates all connections. Canceled sessions are not deleted and can be retrieved or listed by the user until they expire based on the 28 day deletion policy.

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 (DirectAccessServiceClient directAccessServiceClient = DirectAccessServiceClient.create()) {
   CancelDeviceSessionRequest request =
       CancelDeviceSessionRequest.newBuilder()
           .setName(DeviceSessionName.of("[PROJECT]", "[DEVICE_SESSION]").toString())
           .build();
   directAccessServiceClient.cancelDeviceSession(request);
 }
 
Parameter
Name Description
request CancelDeviceSessionRequest

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

cancelDeviceSessionCallable()

public final UnaryCallable<CancelDeviceSessionRequest,Empty> cancelDeviceSessionCallable()

Cancel a DeviceSession. This RPC changes the DeviceSession to state FINISHED and terminates all connections. Canceled sessions are not deleted and can be retrieved or listed by the user until they expire based on the 28 day deletion policy.

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 (DirectAccessServiceClient directAccessServiceClient = DirectAccessServiceClient.create()) {
   CancelDeviceSessionRequest request =
       CancelDeviceSessionRequest.newBuilder()
           .setName(DeviceSessionName.of("[PROJECT]", "[DEVICE_SESSION]").toString())
           .build();
   ApiFuture<Empty> future =
       directAccessServiceClient.cancelDeviceSessionCallable().futureCall(request);
   // Do something.
   future.get();
 }
 
Returns
Type Description
UnaryCallable<CancelDeviceSessionRequest,Empty>

close()

public final void close()

createDeviceSession(CreateDeviceSessionRequest request)

public final DeviceSession createDeviceSession(CreateDeviceSessionRequest request)

Creates a DeviceSession.

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 (DirectAccessServiceClient directAccessServiceClient = DirectAccessServiceClient.create()) {
   CreateDeviceSessionRequest request =
       CreateDeviceSessionRequest.newBuilder()
           .setParent(ProjectName.of("[PROJECT]").toString())
           .setDeviceSession(DeviceSession.newBuilder().build())
           .setDeviceSessionId("deviceSessionId-544276325")
           .build();
   DeviceSession response = directAccessServiceClient.createDeviceSession(request);
 }
 
Parameter
Name Description
request CreateDeviceSessionRequest

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

Returns
Type Description
DeviceSession

createDeviceSession(ProjectName parent, DeviceSession deviceSession, String deviceSessionId)

public final DeviceSession createDeviceSession(ProjectName parent, DeviceSession deviceSession, String deviceSessionId)

Creates a DeviceSession.

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 (DirectAccessServiceClient directAccessServiceClient = DirectAccessServiceClient.create()) {
   ProjectName parent = ProjectName.of("[PROJECT]");
   DeviceSession deviceSession = DeviceSession.newBuilder().build();
   String deviceSessionId = "deviceSessionId-544276325";
   DeviceSession response =
       directAccessServiceClient.createDeviceSession(parent, deviceSession, deviceSessionId);
 }
 
Parameters
Name Description
parent ProjectName

Required. The Compute Engine project under which this device will be allocated. "projects/{project_id}"

deviceSession DeviceSession

Required. A DeviceSession to create.

deviceSessionId String

Optional. The ID to use for the DeviceSession, which will become the final component of the DeviceSession's resource name.

This value should be 4-63 characters, and valid characters are /a-z-/.

Returns
Type Description
DeviceSession

createDeviceSession(String parent, DeviceSession deviceSession, String deviceSessionId)

public final DeviceSession createDeviceSession(String parent, DeviceSession deviceSession, String deviceSessionId)

Creates a DeviceSession.

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 (DirectAccessServiceClient directAccessServiceClient = DirectAccessServiceClient.create()) {
   String parent = ProjectName.of("[PROJECT]").toString();
   DeviceSession deviceSession = DeviceSession.newBuilder().build();
   String deviceSessionId = "deviceSessionId-544276325";
   DeviceSession response =
       directAccessServiceClient.createDeviceSession(parent, deviceSession, deviceSessionId);
 }
 
Parameters
Name Description
parent String

Required. The Compute Engine project under which this device will be allocated. "projects/{project_id}"

deviceSession DeviceSession

Required. A DeviceSession to create.

deviceSessionId String

Optional. The ID to use for the DeviceSession, which will become the final component of the DeviceSession's resource name.

This value should be 4-63 characters, and valid characters are /a-z-/.

Returns
Type Description
DeviceSession

createDeviceSessionCallable()

public final UnaryCallable<CreateDeviceSessionRequest,DeviceSession> createDeviceSessionCallable()

Creates a DeviceSession.

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 (DirectAccessServiceClient directAccessServiceClient = DirectAccessServiceClient.create()) {
   CreateDeviceSessionRequest request =
       CreateDeviceSessionRequest.newBuilder()
           .setParent(ProjectName.of("[PROJECT]").toString())
           .setDeviceSession(DeviceSession.newBuilder().build())
           .setDeviceSessionId("deviceSessionId-544276325")
           .build();
   ApiFuture<DeviceSession> future =
       directAccessServiceClient.createDeviceSessionCallable().futureCall(request);
   // Do something.
   DeviceSession response = future.get();
 }
 
Returns
Type Description
UnaryCallable<CreateDeviceSessionRequest,DeviceSession>

getDeviceSession(DeviceSessionName name)

public final DeviceSession getDeviceSession(DeviceSessionName name)

Gets a DeviceSession, which documents the allocation status and whether the device is allocated. Clients making requests from this API must poll GetDeviceSession.

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 (DirectAccessServiceClient directAccessServiceClient = DirectAccessServiceClient.create()) {
   DeviceSessionName name = DeviceSessionName.of("[PROJECT]", "[DEVICE_SESSION]");
   DeviceSession response = directAccessServiceClient.getDeviceSession(name);
 }
 
Parameter
Name Description
name DeviceSessionName

Required. Name of the DeviceSession, e.g. "projects/{project_id}/deviceSessions/{session_id}"

Returns
Type Description
DeviceSession

getDeviceSession(GetDeviceSessionRequest request)

public final DeviceSession getDeviceSession(GetDeviceSessionRequest request)

Gets a DeviceSession, which documents the allocation status and whether the device is allocated. Clients making requests from this API must poll GetDeviceSession.

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 (DirectAccessServiceClient directAccessServiceClient = DirectAccessServiceClient.create()) {
   GetDeviceSessionRequest request =
       GetDeviceSessionRequest.newBuilder()
           .setName(DeviceSessionName.of("[PROJECT]", "[DEVICE_SESSION]").toString())
           .build();
   DeviceSession response = directAccessServiceClient.getDeviceSession(request);
 }
 
Parameter
Name Description
request GetDeviceSessionRequest

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

Returns
Type Description
DeviceSession

getDeviceSession(String name)

public final DeviceSession getDeviceSession(String name)

Gets a DeviceSession, which documents the allocation status and whether the device is allocated. Clients making requests from this API must poll GetDeviceSession.

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 (DirectAccessServiceClient directAccessServiceClient = DirectAccessServiceClient.create()) {
   String name = DeviceSessionName.of("[PROJECT]", "[DEVICE_SESSION]").toString();
   DeviceSession response = directAccessServiceClient.getDeviceSession(name);
 }
 
Parameter
Name Description
name String

Required. Name of the DeviceSession, e.g. "projects/{project_id}/deviceSessions/{session_id}"

Returns
Type Description
DeviceSession

getDeviceSessionCallable()

public final UnaryCallable<GetDeviceSessionRequest,DeviceSession> getDeviceSessionCallable()

Gets a DeviceSession, which documents the allocation status and whether the device is allocated. Clients making requests from this API must poll GetDeviceSession.

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 (DirectAccessServiceClient directAccessServiceClient = DirectAccessServiceClient.create()) {
   GetDeviceSessionRequest request =
       GetDeviceSessionRequest.newBuilder()
           .setName(DeviceSessionName.of("[PROJECT]", "[DEVICE_SESSION]").toString())
           .build();
   ApiFuture<DeviceSession> future =
       directAccessServiceClient.getDeviceSessionCallable().futureCall(request);
   // Do something.
   DeviceSession response = future.get();
 }
 
Returns
Type Description
UnaryCallable<GetDeviceSessionRequest,DeviceSession>

getSettings()

public final DirectAccessServiceSettings getSettings()
Returns
Type Description
DirectAccessServiceSettings

getStub()

public DirectAccessServiceStub getStub()
Returns
Type Description
DirectAccessServiceStub

isShutdown()

public boolean isShutdown()
Returns
Type Description
boolean

isTerminated()

public boolean isTerminated()
Returns
Type Description
boolean

listDeviceSessions(ListDeviceSessionsRequest request)

public final DirectAccessServiceClient.ListDeviceSessionsPagedResponse listDeviceSessions(ListDeviceSessionsRequest request)

Lists DeviceSessions owned by the project user.

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 (DirectAccessServiceClient directAccessServiceClient = DirectAccessServiceClient.create()) {
   ListDeviceSessionsRequest request =
       ListDeviceSessionsRequest.newBuilder()
           .setParent(ProjectName.of("[PROJECT]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .build();
   for (DeviceSession element :
       directAccessServiceClient.listDeviceSessions(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
request ListDeviceSessionsRequest

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

Returns
Type Description
DirectAccessServiceClient.ListDeviceSessionsPagedResponse

listDeviceSessions(ProjectName parent)

public final DirectAccessServiceClient.ListDeviceSessionsPagedResponse listDeviceSessions(ProjectName parent)

Lists DeviceSessions owned by the project user.

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 (DirectAccessServiceClient directAccessServiceClient = DirectAccessServiceClient.create()) {
   ProjectName parent = ProjectName.of("[PROJECT]");
   for (DeviceSession element :
       directAccessServiceClient.listDeviceSessions(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent ProjectName

Required. The name of the parent to request, e.g. "projects/{project_id}"

Returns
Type Description
DirectAccessServiceClient.ListDeviceSessionsPagedResponse

listDeviceSessions(String parent)

public final DirectAccessServiceClient.ListDeviceSessionsPagedResponse listDeviceSessions(String parent)

Lists DeviceSessions owned by the project user.

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 (DirectAccessServiceClient directAccessServiceClient = DirectAccessServiceClient.create()) {
   String parent = ProjectName.of("[PROJECT]").toString();
   for (DeviceSession element :
       directAccessServiceClient.listDeviceSessions(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent String

Required. The name of the parent to request, e.g. "projects/{project_id}"

Returns
Type Description
DirectAccessServiceClient.ListDeviceSessionsPagedResponse

listDeviceSessionsCallable()

public final UnaryCallable<ListDeviceSessionsRequest,ListDeviceSessionsResponse> listDeviceSessionsCallable()

Lists DeviceSessions owned by the project user.

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 (DirectAccessServiceClient directAccessServiceClient = DirectAccessServiceClient.create()) {
   ListDeviceSessionsRequest request =
       ListDeviceSessionsRequest.newBuilder()
           .setParent(ProjectName.of("[PROJECT]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .build();
   while (true) {
     ListDeviceSessionsResponse response =
         directAccessServiceClient.listDeviceSessionsCallable().call(request);
     for (DeviceSession element : response.getDeviceSessionsList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
Type Description
UnaryCallable<ListDeviceSessionsRequest,ListDeviceSessionsResponse>

listDeviceSessionsPagedCallable()

public final UnaryCallable<ListDeviceSessionsRequest,DirectAccessServiceClient.ListDeviceSessionsPagedResponse> listDeviceSessionsPagedCallable()

Lists DeviceSessions owned by the project user.

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 (DirectAccessServiceClient directAccessServiceClient = DirectAccessServiceClient.create()) {
   ListDeviceSessionsRequest request =
       ListDeviceSessionsRequest.newBuilder()
           .setParent(ProjectName.of("[PROJECT]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .build();
   ApiFuture<DeviceSession> future =
       directAccessServiceClient.listDeviceSessionsPagedCallable().futureCall(request);
   // Do something.
   for (DeviceSession element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
Type Description
UnaryCallable<ListDeviceSessionsRequest,ListDeviceSessionsPagedResponse>

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()

updateDeviceSession(DeviceSession deviceSession, FieldMask updateMask)

public final DeviceSession updateDeviceSession(DeviceSession deviceSession, FieldMask updateMask)

Updates the current DeviceSession to the fields described by the update_mask.

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 (DirectAccessServiceClient directAccessServiceClient = DirectAccessServiceClient.create()) {
   DeviceSession deviceSession = DeviceSession.newBuilder().build();
   FieldMask updateMask = FieldMask.newBuilder().build();
   DeviceSession response =
       directAccessServiceClient.updateDeviceSession(deviceSession, updateMask);
 }
 
Parameters
Name Description
deviceSession DeviceSession

Required. DeviceSession to update. The DeviceSession's name field is used to identify the session to update "projects/{project_id}/deviceSessions/{session_id}"

updateMask FieldMask

Optional. The list of fields to update.

Returns
Type Description
DeviceSession

updateDeviceSession(UpdateDeviceSessionRequest request)

public final DeviceSession updateDeviceSession(UpdateDeviceSessionRequest request)

Updates the current DeviceSession to the fields described by the update_mask.

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 (DirectAccessServiceClient directAccessServiceClient = DirectAccessServiceClient.create()) {
   UpdateDeviceSessionRequest request =
       UpdateDeviceSessionRequest.newBuilder()
           .setDeviceSession(DeviceSession.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   DeviceSession response = directAccessServiceClient.updateDeviceSession(request);
 }
 
Parameter
Name Description
request UpdateDeviceSessionRequest

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

Returns
Type Description
DeviceSession

updateDeviceSessionCallable()

public final UnaryCallable<UpdateDeviceSessionRequest,DeviceSession> updateDeviceSessionCallable()

Updates the current DeviceSession to the fields described by the update_mask.

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 (DirectAccessServiceClient directAccessServiceClient = DirectAccessServiceClient.create()) {
   UpdateDeviceSessionRequest request =
       UpdateDeviceSessionRequest.newBuilder()
           .setDeviceSession(DeviceSession.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   ApiFuture<DeviceSession> future =
       directAccessServiceClient.updateDeviceSessionCallable().futureCall(request);
   // Do something.
   DeviceSession response = future.get();
 }
 
Returns
Type Description
UnaryCallable<UpdateDeviceSessionRequest,DeviceSession>