0.34.0 (latest) 0.33.0 0.31.0 0.28.0 0.27.0 0.25.0 0.23.0 0.22.0 0.21.0 0.20.0 0.18.0 0.16.0 0.15.0 0.14.0 0.13.0 0.12.0 0.10.0 0.8.0 0.7.0 0.4.0 0.3.0 0.2.0

|---|---|
| [GitHub Repository](https://github.com/googleapis/google-cloud-java/tree/main/java-devicestreaming/google-cloud-devicestreaming/src/main/java/com/google/cloud/devicestreaming/v1/DirectAccessServiceClient.java) | [Product Reference](https://cloud.google.com/device-streaming/docs) |

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().

| 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() |
[Methods]

See the individual methods for example code.

Many parameters require resource names to be formatted in a particular way. To assist with
these names, this class includes a format method for each type of name, and additionally a parse
method to extract the individual identifiers contained within names that are returned.

This class can be customized by passing in a custom instance of 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](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \> DirectAccessServiceClient

## Static Methods

### create()

    public static final DirectAccessServiceClient create()

Constructs an instance of DirectAccessServiceClient with default settings.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-devicestreaming/latest/com.google.cloud.devicestreaming.v1.DirectAccessServiceClient` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |

### 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` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-devicestreaming/latest/com.google.cloud.devicestreaming.v1.DirectAccessServiceSettings` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-devicestreaming/latest/com.google.cloud.devicestreaming.v1.DirectAccessServiceClient` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |

### 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` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-devicestreaming/latest/com.google.cloud.devicestreaming.v1.stub.DirectAccessServiceStub` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-devicestreaming/latest/com.google.cloud.devicestreaming.v1.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` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-devicestreaming/latest/com.google.cloud.devicestreaming.v1.DirectAccessServiceSettings` |

### DirectAccessServiceClient(DirectAccessServiceStub stub)

    protected DirectAccessServiceClient(DirectAccessServiceStub stub)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `stub` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-devicestreaming/latest/com.google.cloud.devicestreaming.v1.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** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.BidiStreamingCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-devicestreaming/latest/com.google.cloud.devicestreaming.v1.AdbMessage,https://docs.cloud.google.com/java/docs/reference/google-cloud-devicestreaming/latest/com.google.cloud.devicestreaming.v1.DeviceMessage>` |   |

### awaitTermination(long duration, TimeUnit unit)

    public boolean awaitTermination(long duration, TimeUnit unit)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `duration` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |
| `unit` | `https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/TimeUnit.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/InterruptedException.html` |   |

### 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` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-devicestreaming/latest/com.google.cloud.devicestreaming.v1.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** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-devicestreaming/latest/com.google.cloud.devicestreaming.v1.CancelDeviceSessionRequest,https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Empty.html>` |   |

### 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` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-devicestreaming/latest/com.google.cloud.devicestreaming.v1.CreateDeviceSessionRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-devicestreaming/latest/com.google.cloud.devicestreaming.v1.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` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-devicestreaming/latest/com.google.cloud.devicestreaming.v1.ProjectName` Required. The Compute Engine project under which this device will be allocated. "projects/{project_id}" |
| `deviceSession` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-devicestreaming/latest/com.google.cloud.devicestreaming.v1.DeviceSession` Required. A DeviceSession to create. |
| `deviceSessionId` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` 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** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-devicestreaming/latest/com.google.cloud.devicestreaming.v1.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` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. The Compute Engine project under which this device will be allocated. "projects/{project_id}" |
| `deviceSession` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-devicestreaming/latest/com.google.cloud.devicestreaming.v1.DeviceSession` Required. A DeviceSession to create. |
| `deviceSessionId` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` 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** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-devicestreaming/latest/com.google.cloud.devicestreaming.v1.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** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-devicestreaming/latest/com.google.cloud.devicestreaming.v1.CreateDeviceSessionRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-devicestreaming/latest/com.google.cloud.devicestreaming.v1.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` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-devicestreaming/latest/com.google.cloud.devicestreaming.v1.DeviceSessionName` Required. Name of the DeviceSession, e.g. "projects/{project_id}/deviceSessions/{session_id}" |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-devicestreaming/latest/com.google.cloud.devicestreaming.v1.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` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-devicestreaming/latest/com.google.cloud.devicestreaming.v1.GetDeviceSessionRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-devicestreaming/latest/com.google.cloud.devicestreaming.v1.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` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. Name of the DeviceSession, e.g. "projects/{project_id}/deviceSessions/{session_id}" |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-devicestreaming/latest/com.google.cloud.devicestreaming.v1.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** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-devicestreaming/latest/com.google.cloud.devicestreaming.v1.GetDeviceSessionRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-devicestreaming/latest/com.google.cloud.devicestreaming.v1.DeviceSession>` |   |

### getSettings()

    public final DirectAccessServiceSettings getSettings()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-devicestreaming/latest/com.google.cloud.devicestreaming.v1.DirectAccessServiceSettings` |   |

### getStub()

    public DirectAccessServiceStub getStub()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-devicestreaming/latest/com.google.cloud.devicestreaming.v1.stub.DirectAccessServiceStub` |   |

### isShutdown()

    public boolean isShutdown()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

### isTerminated()

    public boolean isTerminated()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

### 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` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-devicestreaming/latest/com.google.cloud.devicestreaming.v1.ListDeviceSessionsRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-devicestreaming/latest/com.google.cloud.devicestreaming.v1.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` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-devicestreaming/latest/com.google.cloud.devicestreaming.v1.ProjectName` Required. The name of the parent to request, e.g. "projects/{project_id}" |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-devicestreaming/latest/com.google.cloud.devicestreaming.v1.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` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. The name of the parent to request, e.g. "projects/{project_id}" |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-devicestreaming/latest/com.google.cloud.devicestreaming.v1.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** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-devicestreaming/latest/com.google.cloud.devicestreaming.v1.ListDeviceSessionsRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-devicestreaming/latest/com.google.cloud.devicestreaming.v1.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** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-devicestreaming/latest/com.google.cloud.devicestreaming.v1.ListDeviceSessionsRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-devicestreaming/latest/com.google.cloud.devicestreaming.v1.DirectAccessServiceClient.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` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-devicestreaming/latest/com.google.cloud.devicestreaming.v1.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` | `https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.FieldMask.html` Optional. The list of fields to update. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-devicestreaming/latest/com.google.cloud.devicestreaming.v1.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` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-devicestreaming/latest/com.google.cloud.devicestreaming.v1.UpdateDeviceSessionRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-devicestreaming/latest/com.google.cloud.devicestreaming.v1.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** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-devicestreaming/latest/com.google.cloud.devicestreaming.v1.UpdateDeviceSessionRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-devicestreaming/latest/com.google.cloud.devicestreaming.v1.DeviceSession>` |   |