Class DirectAccessServiceClient

java.lang.Object
com.google.cloud.devicestreaming.v1.DirectAccessServiceClient
All Implemented Interfaces:
BackgroundResource, AutoCloseable

@Generated("by gapic-generator-java") public class DirectAccessServiceClient extends Object implements BackgroundResource
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.

  • Constructor Details

    • DirectAccessServiceClient

      protected DirectAccessServiceClient(DirectAccessServiceSettings settings) throws IOException
      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.
      Throws:
      IOException
    • DirectAccessServiceClient

      protected DirectAccessServiceClient(DirectAccessServiceStub stub)
  • Method Details

    • create

      public static final DirectAccessServiceClient create() throws IOException
      Constructs an instance of DirectAccessServiceClient with default settings.
      Throws:
      IOException
    • create

      public static final DirectAccessServiceClient create(DirectAccessServiceSettings settings) throws IOException
      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.
      Throws:
      IOException
    • create

      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).
    • getSettings

      public final DirectAccessServiceSettings getSettings()
    • getStub

      public DirectAccessServiceStub getStub()
    • createDeviceSession

      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:
      parent - Required. The Compute Engine project under which this device will be allocated. "projects/{project_id}"
      deviceSession - Required. A DeviceSession to create.
      deviceSessionId - 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][0-9]-/.

      Throws:
      ApiException - if the remote call fails
    • createDeviceSession

      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:
      parent - Required. The Compute Engine project under which this device will be allocated. "projects/{project_id}"
      deviceSession - Required. A DeviceSession to create.
      deviceSessionId - 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][0-9]-/.

      Throws:
      ApiException - if the remote call fails
    • createDeviceSession

      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);
       }
       
      Parameters:
      request - The request object containing all of the parameters for the API call.
      Throws:
      ApiException - if the remote call fails
    • 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();
       }
       
    • listDeviceSessions

      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);
         }
       }
       
      Parameters:
      parent - Required. The name of the parent to request, e.g. "projects/{project_id}"
      Throws:
      ApiException - if the remote call fails
    • listDeviceSessions

      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);
         }
       }
       
      Parameters:
      parent - Required. The name of the parent to request, e.g. "projects/{project_id}"
      Throws:
      ApiException - if the remote call fails
    • listDeviceSessions

      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);
         }
       }
       
      Parameters:
      request - The request object containing all of the parameters for the API call.
      Throws:
      ApiException - if the remote call fails
    • 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);
         }
       }
       
    • 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;
           }
         }
       }
       
    • getDeviceSession

      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);
       }
       
      Parameters:
      name - Required. Name of the DeviceSession, e.g. "projects/{project_id}/deviceSessions/{session_id}"
      Throws:
      ApiException - if the remote call fails
    • getDeviceSession

      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);
       }
       
      Parameters:
      name - Required. Name of the DeviceSession, e.g. "projects/{project_id}/deviceSessions/{session_id}"
      Throws:
      ApiException - if the remote call fails
    • getDeviceSession

      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);
       }
       
      Parameters:
      request - The request object containing all of the parameters for the API call.
      Throws:
      ApiException - if the remote call fails
    • 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();
       }
       
    • cancelDeviceSession

      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);
       }
       
      Parameters:
      request - The request object containing all of the parameters for the API call.
      Throws:
      ApiException - if the remote call fails
    • cancelDeviceSessionCallable

      public final UnaryCallable<CancelDeviceSessionRequest,com.google.protobuf.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();
       }
       
    • updateDeviceSession

      public final DeviceSession updateDeviceSession(DeviceSession deviceSession, com.google.protobuf.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:
      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 - Optional. The list of fields to update.
      Throws:
      ApiException - if the remote call fails
    • updateDeviceSession

      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);
       }
       
      Parameters:
      request - The request object containing all of the parameters for the API call.
      Throws:
      ApiException - if the remote call fails
    • 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();
       }
       
    • 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.
         }
       }
       
    • close

      public final void close()
      Specified by:
      close in interface AutoCloseable
    • shutdown

      public void shutdown()
      Specified by:
      shutdown in interface BackgroundResource
    • isShutdown

      public boolean isShutdown()
      Specified by:
      isShutdown in interface BackgroundResource
    • isTerminated

      public boolean isTerminated()
      Specified by:
      isTerminated in interface BackgroundResource
    • shutdownNow

      public void shutdownNow()
      Specified by:
      shutdownNow in interface BackgroundResource
    • awaitTermination

      public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
      Specified by:
      awaitTermination in interface BackgroundResource
      Throws:
      InterruptedException