Device Streaming v1 API - Class DirectAccessServiceClient (1.0.0-beta01)

public abstract class DirectAccessServiceClient

Reference documentation and code samples for the Device Streaming v1 API class DirectAccessServiceClient.

DirectAccessService client wrapper, for convenient use.

Inheritance

object > DirectAccessServiceClient

Namespace

Google.Cloud.DeviceStreaming.V1

Assembly

Google.Cloud.DeviceStreaming.V1.dll

Remarks

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

Properties

DefaultEndpoint

public static string DefaultEndpoint { get; }

The default endpoint for the DirectAccessService service, which is a host of "devicestreaming.googleapis.com" and a port of 443.

Property Value
Type Description
string

DefaultScopes

public static IReadOnlyList<string> DefaultScopes { get; }

The default DirectAccessService scopes.

Property Value
Type Description
IReadOnlyListstring
Remarks

The default DirectAccessService scopes are:

GrpcClient

public virtual DirectAccessService.DirectAccessServiceClient GrpcClient { get; }

The underlying gRPC DirectAccessService client

Property Value
Type Description
DirectAccessServiceDirectAccessServiceClient

ServiceMetadata

public static ServiceMetadata ServiceMetadata { get; }

The service metadata associated with this client type.

Property Value
Type Description
ServiceMetadata

Methods

AdbConnect(CallSettings, BidirectionalStreamingSettings)

public virtual DirectAccessServiceClient.AdbConnectStream AdbConnect(CallSettings callSettings = null, BidirectionalStreamingSettings streamingSettings = null)

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.

Parameters
Name Description
callSettings CallSettings

If not null, applies overrides to this RPC call.

streamingSettings BidirectionalStreamingSettings

If not null, applies streaming overrides to this RPC call.

Returns
Type Description
DirectAccessServiceClientAdbConnectStream

The client-server stream.

Example
// Create client
DirectAccessServiceClient directAccessServiceClient = DirectAccessServiceClient.Create();
// Initialize streaming call, retrieving the stream object
using DirectAccessServiceClient.AdbConnectStream response = directAccessServiceClient.AdbConnect();

// Sending requests and retrieving responses can be arbitrarily interleaved
// Exact sequence will depend on client/server behavior

// Create task to do something with responses from server
Task responseHandlerTask = Task.Run(async () =>
{
    // Note that C# 8 code can use await foreach
    AsyncResponseStream<DeviceMessage> responseStream = response.GetResponseStream();
    while (await responseStream.MoveNextAsync())
    {
        DeviceMessage responseItem = responseStream.Current;
        // Do something with streamed response
    }
    // The response stream has completed
});

// Send requests to the server
bool done = false;
while (!done)
{
    // Initialize a request
    AdbMessage request = new AdbMessage { Open = new Open(), };
    // Stream a request to the server
    await response.WriteAsync(request);
    // Set "done" to true when sending requests is complete
}

// Complete writing requests to the stream
await response.WriteCompleteAsync();
// Await the response handler
// This will complete once all server responses have been processed
await responseHandlerTask;

CancelDeviceSession(CancelDeviceSessionRequest, CallSettings)

public virtual void CancelDeviceSession(CancelDeviceSessionRequest request, CallSettings callSettings = null)

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.

Parameters
Name Description
request CancelDeviceSessionRequest

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

callSettings CallSettings

If not null, applies overrides to this RPC call.

Example
// Create client
DirectAccessServiceClient directAccessServiceClient = DirectAccessServiceClient.Create();
// Initialize request argument(s)
CancelDeviceSessionRequest request = new CancelDeviceSessionRequest
{
    DeviceSessionName = DeviceSessionName.FromProjectDeviceSession("[PROJECT]", "[DEVICE_SESSION]"),
};
// Make the request
directAccessServiceClient.CancelDeviceSession(request);

CancelDeviceSessionAsync(CancelDeviceSessionRequest, CallSettings)

public virtual Task CancelDeviceSessionAsync(CancelDeviceSessionRequest request, CallSettings callSettings = null)

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.

Parameters
Name Description
request CancelDeviceSessionRequest

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

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Task

A Task containing the RPC response.

Example
// Create client
DirectAccessServiceClient directAccessServiceClient = await DirectAccessServiceClient.CreateAsync();
// Initialize request argument(s)
CancelDeviceSessionRequest request = new CancelDeviceSessionRequest
{
    DeviceSessionName = DeviceSessionName.FromProjectDeviceSession("[PROJECT]", "[DEVICE_SESSION]"),
};
// Make the request
await directAccessServiceClient.CancelDeviceSessionAsync(request);

CancelDeviceSessionAsync(CancelDeviceSessionRequest, CancellationToken)

public virtual Task CancelDeviceSessionAsync(CancelDeviceSessionRequest request, CancellationToken cancellationToken)

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.

Parameters
Name Description
request CancelDeviceSessionRequest

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

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
Task

A Task containing the RPC response.

Example
// Create client
DirectAccessServiceClient directAccessServiceClient = await DirectAccessServiceClient.CreateAsync();
// Initialize request argument(s)
CancelDeviceSessionRequest request = new CancelDeviceSessionRequest
{
    DeviceSessionName = DeviceSessionName.FromProjectDeviceSession("[PROJECT]", "[DEVICE_SESSION]"),
};
// Make the request
await directAccessServiceClient.CancelDeviceSessionAsync(request);

Create()

public static DirectAccessServiceClient Create()

Synchronously creates a DirectAccessServiceClient using the default credentials, endpoint and settings. To specify custom credentials or other settings, use DirectAccessServiceClientBuilder.

Returns
Type Description
DirectAccessServiceClient

The created DirectAccessServiceClient.

CreateAsync(CancellationToken)

public static Task<DirectAccessServiceClient> CreateAsync(CancellationToken cancellationToken = default)

Asynchronously creates a DirectAccessServiceClient using the default credentials, endpoint and settings. To specify custom credentials or other settings, use DirectAccessServiceClientBuilder.

Parameter
Name Description
cancellationToken CancellationToken

The CancellationToken to use while creating the client.

Returns
Type Description
TaskDirectAccessServiceClient

The task representing the created DirectAccessServiceClient.

CreateDeviceSession(ProjectName, DeviceSession, string, CallSettings)

public virtual DeviceSession CreateDeviceSession(ProjectName parent, DeviceSession deviceSession, string deviceSessionId, CallSettings callSettings = null)

Creates a DeviceSession.

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][0-9]-/.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
DeviceSession

The RPC response.

Example
// Create client
DirectAccessServiceClient directAccessServiceClient = DirectAccessServiceClient.Create();
// Initialize request argument(s)
ProjectName parent = ProjectName.FromProject("[PROJECT]");
DeviceSession deviceSession = new DeviceSession();
string deviceSessionId = "";
// Make the request
DeviceSession response = directAccessServiceClient.CreateDeviceSession(parent, deviceSession, deviceSessionId);

CreateDeviceSession(CreateDeviceSessionRequest, CallSettings)

public virtual DeviceSession CreateDeviceSession(CreateDeviceSessionRequest request, CallSettings callSettings = null)

Creates a DeviceSession.

Parameters
Name Description
request CreateDeviceSessionRequest

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

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
DeviceSession

The RPC response.

Example
// Create client
DirectAccessServiceClient directAccessServiceClient = DirectAccessServiceClient.Create();
// Initialize request argument(s)
CreateDeviceSessionRequest request = new CreateDeviceSessionRequest
{
    ParentAsProjectName = ProjectName.FromProject("[PROJECT]"),
    DeviceSession = new DeviceSession(),
    DeviceSessionId = "",
};
// Make the request
DeviceSession response = directAccessServiceClient.CreateDeviceSession(request);

CreateDeviceSession(string, DeviceSession, string, CallSettings)

public virtual DeviceSession CreateDeviceSession(string parent, DeviceSession deviceSession, string deviceSessionId, CallSettings callSettings = null)

Creates a DeviceSession.

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][0-9]-/.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
DeviceSession

The RPC response.

Example
// Create client
DirectAccessServiceClient directAccessServiceClient = DirectAccessServiceClient.Create();
// Initialize request argument(s)
string parent = "projects/[PROJECT]";
DeviceSession deviceSession = new DeviceSession();
string deviceSessionId = "";
// Make the request
DeviceSession response = directAccessServiceClient.CreateDeviceSession(parent, deviceSession, deviceSessionId);

CreateDeviceSessionAsync(ProjectName, DeviceSession, string, CallSettings)

public virtual Task<DeviceSession> CreateDeviceSessionAsync(ProjectName parent, DeviceSession deviceSession, string deviceSessionId, CallSettings callSettings = null)

Creates a DeviceSession.

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][0-9]-/.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskDeviceSession

A Task containing the RPC response.

Example
// Create client
DirectAccessServiceClient directAccessServiceClient = await DirectAccessServiceClient.CreateAsync();
// Initialize request argument(s)
ProjectName parent = ProjectName.FromProject("[PROJECT]");
DeviceSession deviceSession = new DeviceSession();
string deviceSessionId = "";
// Make the request
DeviceSession response = await directAccessServiceClient.CreateDeviceSessionAsync(parent, deviceSession, deviceSessionId);

CreateDeviceSessionAsync(ProjectName, DeviceSession, string, CancellationToken)

public virtual Task<DeviceSession> CreateDeviceSessionAsync(ProjectName parent, DeviceSession deviceSession, string deviceSessionId, CancellationToken cancellationToken)

Creates a DeviceSession.

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][0-9]-/.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskDeviceSession

A Task containing the RPC response.

Example
// Create client
DirectAccessServiceClient directAccessServiceClient = await DirectAccessServiceClient.CreateAsync();
// Initialize request argument(s)
ProjectName parent = ProjectName.FromProject("[PROJECT]");
DeviceSession deviceSession = new DeviceSession();
string deviceSessionId = "";
// Make the request
DeviceSession response = await directAccessServiceClient.CreateDeviceSessionAsync(parent, deviceSession, deviceSessionId);

CreateDeviceSessionAsync(CreateDeviceSessionRequest, CallSettings)

public virtual Task<DeviceSession> CreateDeviceSessionAsync(CreateDeviceSessionRequest request, CallSettings callSettings = null)

Creates a DeviceSession.

Parameters
Name Description
request CreateDeviceSessionRequest

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

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskDeviceSession

A Task containing the RPC response.

Example
// Create client
DirectAccessServiceClient directAccessServiceClient = await DirectAccessServiceClient.CreateAsync();
// Initialize request argument(s)
CreateDeviceSessionRequest request = new CreateDeviceSessionRequest
{
    ParentAsProjectName = ProjectName.FromProject("[PROJECT]"),
    DeviceSession = new DeviceSession(),
    DeviceSessionId = "",
};
// Make the request
DeviceSession response = await directAccessServiceClient.CreateDeviceSessionAsync(request);

CreateDeviceSessionAsync(CreateDeviceSessionRequest, CancellationToken)

public virtual Task<DeviceSession> CreateDeviceSessionAsync(CreateDeviceSessionRequest request, CancellationToken cancellationToken)

Creates a DeviceSession.

Parameters
Name Description
request CreateDeviceSessionRequest

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

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskDeviceSession

A Task containing the RPC response.

Example
// Create client
DirectAccessServiceClient directAccessServiceClient = await DirectAccessServiceClient.CreateAsync();
// Initialize request argument(s)
CreateDeviceSessionRequest request = new CreateDeviceSessionRequest
{
    ParentAsProjectName = ProjectName.FromProject("[PROJECT]"),
    DeviceSession = new DeviceSession(),
    DeviceSessionId = "",
};
// Make the request
DeviceSession response = await directAccessServiceClient.CreateDeviceSessionAsync(request);

CreateDeviceSessionAsync(string, DeviceSession, string, CallSettings)

public virtual Task<DeviceSession> CreateDeviceSessionAsync(string parent, DeviceSession deviceSession, string deviceSessionId, CallSettings callSettings = null)

Creates a DeviceSession.

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][0-9]-/.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskDeviceSession

A Task containing the RPC response.

Example
// Create client
DirectAccessServiceClient directAccessServiceClient = await DirectAccessServiceClient.CreateAsync();
// Initialize request argument(s)
string parent = "projects/[PROJECT]";
DeviceSession deviceSession = new DeviceSession();
string deviceSessionId = "";
// Make the request
DeviceSession response = await directAccessServiceClient.CreateDeviceSessionAsync(parent, deviceSession, deviceSessionId);

CreateDeviceSessionAsync(string, DeviceSession, string, CancellationToken)

public virtual Task<DeviceSession> CreateDeviceSessionAsync(string parent, DeviceSession deviceSession, string deviceSessionId, CancellationToken cancellationToken)

Creates a DeviceSession.

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][0-9]-/.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskDeviceSession

A Task containing the RPC response.

Example
// Create client
DirectAccessServiceClient directAccessServiceClient = await DirectAccessServiceClient.CreateAsync();
// Initialize request argument(s)
string parent = "projects/[PROJECT]";
DeviceSession deviceSession = new DeviceSession();
string deviceSessionId = "";
// Make the request
DeviceSession response = await directAccessServiceClient.CreateDeviceSessionAsync(parent, deviceSession, deviceSessionId);

GetDeviceSession(DeviceSessionName, CallSettings)

public virtual DeviceSession GetDeviceSession(DeviceSessionName name, CallSettings callSettings = null)

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

Parameters
Name Description
name DeviceSessionName

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

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
DeviceSession

The RPC response.

Example
// Create client
DirectAccessServiceClient directAccessServiceClient = DirectAccessServiceClient.Create();
// Initialize request argument(s)
DeviceSessionName name = DeviceSessionName.FromProjectDeviceSession("[PROJECT]", "[DEVICE_SESSION]");
// Make the request
DeviceSession response = directAccessServiceClient.GetDeviceSession(name);

GetDeviceSession(GetDeviceSessionRequest, CallSettings)

public virtual DeviceSession GetDeviceSession(GetDeviceSessionRequest request, CallSettings callSettings = null)

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

Parameters
Name Description
request GetDeviceSessionRequest

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

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
DeviceSession

The RPC response.

Example
// Create client
DirectAccessServiceClient directAccessServiceClient = DirectAccessServiceClient.Create();
// Initialize request argument(s)
GetDeviceSessionRequest request = new GetDeviceSessionRequest
{
    DeviceSessionName = DeviceSessionName.FromProjectDeviceSession("[PROJECT]", "[DEVICE_SESSION]"),
};
// Make the request
DeviceSession response = directAccessServiceClient.GetDeviceSession(request);

GetDeviceSession(string, CallSettings)

public virtual DeviceSession GetDeviceSession(string name, CallSettings callSettings = null)

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

Parameters
Name Description
name string

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

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
DeviceSession

The RPC response.

Example
// Create client
DirectAccessServiceClient directAccessServiceClient = DirectAccessServiceClient.Create();
// Initialize request argument(s)
string name = "projects/[PROJECT]/deviceSessions/[DEVICE_SESSION]";
// Make the request
DeviceSession response = directAccessServiceClient.GetDeviceSession(name);

GetDeviceSessionAsync(DeviceSessionName, CallSettings)

public virtual Task<DeviceSession> GetDeviceSessionAsync(DeviceSessionName name, CallSettings callSettings = null)

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

Parameters
Name Description
name DeviceSessionName

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

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskDeviceSession

A Task containing the RPC response.

Example
// Create client
DirectAccessServiceClient directAccessServiceClient = await DirectAccessServiceClient.CreateAsync();
// Initialize request argument(s)
DeviceSessionName name = DeviceSessionName.FromProjectDeviceSession("[PROJECT]", "[DEVICE_SESSION]");
// Make the request
DeviceSession response = await directAccessServiceClient.GetDeviceSessionAsync(name);

GetDeviceSessionAsync(DeviceSessionName, CancellationToken)

public virtual Task<DeviceSession> GetDeviceSessionAsync(DeviceSessionName name, CancellationToken cancellationToken)

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

Parameters
Name Description
name DeviceSessionName

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

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskDeviceSession

A Task containing the RPC response.

Example
// Create client
DirectAccessServiceClient directAccessServiceClient = await DirectAccessServiceClient.CreateAsync();
// Initialize request argument(s)
DeviceSessionName name = DeviceSessionName.FromProjectDeviceSession("[PROJECT]", "[DEVICE_SESSION]");
// Make the request
DeviceSession response = await directAccessServiceClient.GetDeviceSessionAsync(name);

GetDeviceSessionAsync(GetDeviceSessionRequest, CallSettings)

public virtual Task<DeviceSession> GetDeviceSessionAsync(GetDeviceSessionRequest request, CallSettings callSettings = null)

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

Parameters
Name Description
request GetDeviceSessionRequest

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

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskDeviceSession

A Task containing the RPC response.

Example
// Create client
DirectAccessServiceClient directAccessServiceClient = await DirectAccessServiceClient.CreateAsync();
// Initialize request argument(s)
GetDeviceSessionRequest request = new GetDeviceSessionRequest
{
    DeviceSessionName = DeviceSessionName.FromProjectDeviceSession("[PROJECT]", "[DEVICE_SESSION]"),
};
// Make the request
DeviceSession response = await directAccessServiceClient.GetDeviceSessionAsync(request);

GetDeviceSessionAsync(GetDeviceSessionRequest, CancellationToken)

public virtual Task<DeviceSession> GetDeviceSessionAsync(GetDeviceSessionRequest request, CancellationToken cancellationToken)

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

Parameters
Name Description
request GetDeviceSessionRequest

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

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskDeviceSession

A Task containing the RPC response.

Example
// Create client
DirectAccessServiceClient directAccessServiceClient = await DirectAccessServiceClient.CreateAsync();
// Initialize request argument(s)
GetDeviceSessionRequest request = new GetDeviceSessionRequest
{
    DeviceSessionName = DeviceSessionName.FromProjectDeviceSession("[PROJECT]", "[DEVICE_SESSION]"),
};
// Make the request
DeviceSession response = await directAccessServiceClient.GetDeviceSessionAsync(request);

GetDeviceSessionAsync(string, CallSettings)

public virtual Task<DeviceSession> GetDeviceSessionAsync(string name, CallSettings callSettings = null)

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

Parameters
Name Description
name string

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

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskDeviceSession

A Task containing the RPC response.

Example
// Create client
DirectAccessServiceClient directAccessServiceClient = await DirectAccessServiceClient.CreateAsync();
// Initialize request argument(s)
string name = "projects/[PROJECT]/deviceSessions/[DEVICE_SESSION]";
// Make the request
DeviceSession response = await directAccessServiceClient.GetDeviceSessionAsync(name);

GetDeviceSessionAsync(string, CancellationToken)

public virtual Task<DeviceSession> GetDeviceSessionAsync(string name, CancellationToken cancellationToken)

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

Parameters
Name Description
name string

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

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskDeviceSession

A Task containing the RPC response.

Example
// Create client
DirectAccessServiceClient directAccessServiceClient = await DirectAccessServiceClient.CreateAsync();
// Initialize request argument(s)
string name = "projects/[PROJECT]/deviceSessions/[DEVICE_SESSION]";
// Make the request
DeviceSession response = await directAccessServiceClient.GetDeviceSessionAsync(name);

ListDeviceSessions(ProjectName, string, int?, CallSettings)

public virtual PagedEnumerable<ListDeviceSessionsResponse, DeviceSession> ListDeviceSessions(ProjectName parent, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

Lists DeviceSessions owned by the project user.

Parameters
Name Description
parent ProjectName

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

pageToken string

The token returned from the previous request. A value of null or an empty string retrieves the first page.

pageSize int

The size of page to request. The response will not be larger than this, but may be smaller. A value of null or 0 uses a server-defined page size.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PagedEnumerableListDeviceSessionsResponseDeviceSession

A pageable sequence of DeviceSession resources.

Example
// Create client
DirectAccessServiceClient directAccessServiceClient = DirectAccessServiceClient.Create();
// Initialize request argument(s)
ProjectName parent = ProjectName.FromProject("[PROJECT]");
// Make the request
PagedEnumerable<ListDeviceSessionsResponse, DeviceSession> response = directAccessServiceClient.ListDeviceSessions(parent);

// Iterate over all response items, lazily performing RPCs as required
foreach (DeviceSession item in response)
{
    // Do something with each item
    Console.WriteLine(item);
}

// Or iterate over pages (of server-defined size), performing one RPC per page
foreach (ListDeviceSessionsResponse page in response.AsRawResponses())
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (DeviceSession item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
}

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<DeviceSession> singlePage = response.ReadPage(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (DeviceSession item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

ListDeviceSessions(ListDeviceSessionsRequest, CallSettings)

public virtual PagedEnumerable<ListDeviceSessionsResponse, DeviceSession> ListDeviceSessions(ListDeviceSessionsRequest request, CallSettings callSettings = null)

Lists DeviceSessions owned by the project user.

Parameters
Name Description
request ListDeviceSessionsRequest

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

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PagedEnumerableListDeviceSessionsResponseDeviceSession

A pageable sequence of DeviceSession resources.

Example
// Create client
DirectAccessServiceClient directAccessServiceClient = DirectAccessServiceClient.Create();
// Initialize request argument(s)
ListDeviceSessionsRequest request = new ListDeviceSessionsRequest
{
    Filter = "",
    ParentAsProjectName = ProjectName.FromProject("[PROJECT]"),
};
// Make the request
PagedEnumerable<ListDeviceSessionsResponse, DeviceSession> response = directAccessServiceClient.ListDeviceSessions(request);

// Iterate over all response items, lazily performing RPCs as required
foreach (DeviceSession item in response)
{
    // Do something with each item
    Console.WriteLine(item);
}

// Or iterate over pages (of server-defined size), performing one RPC per page
foreach (ListDeviceSessionsResponse page in response.AsRawResponses())
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (DeviceSession item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
}

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<DeviceSession> singlePage = response.ReadPage(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (DeviceSession item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

ListDeviceSessions(string, string, int?, CallSettings)

public virtual PagedEnumerable<ListDeviceSessionsResponse, DeviceSession> ListDeviceSessions(string parent, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

Lists DeviceSessions owned by the project user.

Parameters
Name Description
parent string

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

pageToken string

The token returned from the previous request. A value of null or an empty string retrieves the first page.

pageSize int

The size of page to request. The response will not be larger than this, but may be smaller. A value of null or 0 uses a server-defined page size.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PagedEnumerableListDeviceSessionsResponseDeviceSession

A pageable sequence of DeviceSession resources.

Example
// Create client
DirectAccessServiceClient directAccessServiceClient = DirectAccessServiceClient.Create();
// Initialize request argument(s)
string parent = "projects/[PROJECT]";
// Make the request
PagedEnumerable<ListDeviceSessionsResponse, DeviceSession> response = directAccessServiceClient.ListDeviceSessions(parent);

// Iterate over all response items, lazily performing RPCs as required
foreach (DeviceSession item in response)
{
    // Do something with each item
    Console.WriteLine(item);
}

// Or iterate over pages (of server-defined size), performing one RPC per page
foreach (ListDeviceSessionsResponse page in response.AsRawResponses())
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (DeviceSession item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
}

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<DeviceSession> singlePage = response.ReadPage(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (DeviceSession item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

ListDeviceSessionsAsync(ProjectName, string, int?, CallSettings)

public virtual PagedAsyncEnumerable<ListDeviceSessionsResponse, DeviceSession> ListDeviceSessionsAsync(ProjectName parent, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

Lists DeviceSessions owned by the project user.

Parameters
Name Description
parent ProjectName

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

pageToken string

The token returned from the previous request. A value of null or an empty string retrieves the first page.

pageSize int

The size of page to request. The response will not be larger than this, but may be smaller. A value of null or 0 uses a server-defined page size.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PagedAsyncEnumerableListDeviceSessionsResponseDeviceSession

A pageable asynchronous sequence of DeviceSession resources.

Example
// Create client
DirectAccessServiceClient directAccessServiceClient = await DirectAccessServiceClient.CreateAsync();
// Initialize request argument(s)
ProjectName parent = ProjectName.FromProject("[PROJECT]");
// Make the request
PagedAsyncEnumerable<ListDeviceSessionsResponse, DeviceSession> response = directAccessServiceClient.ListDeviceSessionsAsync(parent);

// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((DeviceSession item) =>
{
    // Do something with each item
    Console.WriteLine(item);
});

// Or iterate over pages (of server-defined size), performing one RPC per page
await response.AsRawResponses().ForEachAsync((ListDeviceSessionsResponse page) =>
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (DeviceSession item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
});

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<DeviceSession> singlePage = await response.ReadPageAsync(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (DeviceSession item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

ListDeviceSessionsAsync(ListDeviceSessionsRequest, CallSettings)

public virtual PagedAsyncEnumerable<ListDeviceSessionsResponse, DeviceSession> ListDeviceSessionsAsync(ListDeviceSessionsRequest request, CallSettings callSettings = null)

Lists DeviceSessions owned by the project user.

Parameters
Name Description
request ListDeviceSessionsRequest

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

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PagedAsyncEnumerableListDeviceSessionsResponseDeviceSession

A pageable asynchronous sequence of DeviceSession resources.

Example
// Create client
DirectAccessServiceClient directAccessServiceClient = await DirectAccessServiceClient.CreateAsync();
// Initialize request argument(s)
ListDeviceSessionsRequest request = new ListDeviceSessionsRequest
{
    Filter = "",
    ParentAsProjectName = ProjectName.FromProject("[PROJECT]"),
};
// Make the request
PagedAsyncEnumerable<ListDeviceSessionsResponse, DeviceSession> response = directAccessServiceClient.ListDeviceSessionsAsync(request);

// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((DeviceSession item) =>
{
    // Do something with each item
    Console.WriteLine(item);
});

// Or iterate over pages (of server-defined size), performing one RPC per page
await response.AsRawResponses().ForEachAsync((ListDeviceSessionsResponse page) =>
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (DeviceSession item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
});

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<DeviceSession> singlePage = await response.ReadPageAsync(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (DeviceSession item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

ListDeviceSessionsAsync(string, string, int?, CallSettings)

public virtual PagedAsyncEnumerable<ListDeviceSessionsResponse, DeviceSession> ListDeviceSessionsAsync(string parent, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

Lists DeviceSessions owned by the project user.

Parameters
Name Description
parent string

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

pageToken string

The token returned from the previous request. A value of null or an empty string retrieves the first page.

pageSize int

The size of page to request. The response will not be larger than this, but may be smaller. A value of null or 0 uses a server-defined page size.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PagedAsyncEnumerableListDeviceSessionsResponseDeviceSession

A pageable asynchronous sequence of DeviceSession resources.

Example
// Create client
DirectAccessServiceClient directAccessServiceClient = await DirectAccessServiceClient.CreateAsync();
// Initialize request argument(s)
string parent = "projects/[PROJECT]";
// Make the request
PagedAsyncEnumerable<ListDeviceSessionsResponse, DeviceSession> response = directAccessServiceClient.ListDeviceSessionsAsync(parent);

// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((DeviceSession item) =>
{
    // Do something with each item
    Console.WriteLine(item);
});

// Or iterate over pages (of server-defined size), performing one RPC per page
await response.AsRawResponses().ForEachAsync((ListDeviceSessionsResponse page) =>
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (DeviceSession item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
});

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<DeviceSession> singlePage = await response.ReadPageAsync(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (DeviceSession item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

ShutdownDefaultChannelsAsync()

public static Task ShutdownDefaultChannelsAsync()

Shuts down any channels automatically created by Create() and CreateAsync(CancellationToken). Channels which weren't automatically created are not affected.

Returns
Type Description
Task

A task representing the asynchronous shutdown operation.

Remarks

After calling this method, further calls to Create() and CreateAsync(CancellationToken) will create new channels, which could in turn be shut down by another call to this method.

UpdateDeviceSession(DeviceSession, FieldMask, CallSettings)

public virtual DeviceSession UpdateDeviceSession(DeviceSession deviceSession, FieldMask updateMask, CallSettings callSettings = null)

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

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.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
DeviceSession

The RPC response.

Example
// Create client
DirectAccessServiceClient directAccessServiceClient = DirectAccessServiceClient.Create();
// Initialize request argument(s)
DeviceSession deviceSession = new DeviceSession();
FieldMask updateMask = new FieldMask();
// Make the request
DeviceSession response = directAccessServiceClient.UpdateDeviceSession(deviceSession, updateMask);

UpdateDeviceSession(UpdateDeviceSessionRequest, CallSettings)

public virtual DeviceSession UpdateDeviceSession(UpdateDeviceSessionRequest request, CallSettings callSettings = null)

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

Parameters
Name Description
request UpdateDeviceSessionRequest

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

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
DeviceSession

The RPC response.

Example
// Create client
DirectAccessServiceClient directAccessServiceClient = DirectAccessServiceClient.Create();
// Initialize request argument(s)
UpdateDeviceSessionRequest request = new UpdateDeviceSessionRequest
{
    DeviceSession = new DeviceSession(),
    UpdateMask = new FieldMask(),
};
// Make the request
DeviceSession response = directAccessServiceClient.UpdateDeviceSession(request);

UpdateDeviceSessionAsync(DeviceSession, FieldMask, CallSettings)

public virtual Task<DeviceSession> UpdateDeviceSessionAsync(DeviceSession deviceSession, FieldMask updateMask, CallSettings callSettings = null)

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

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.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskDeviceSession

A Task containing the RPC response.

Example
// Create client
DirectAccessServiceClient directAccessServiceClient = await DirectAccessServiceClient.CreateAsync();
// Initialize request argument(s)
DeviceSession deviceSession = new DeviceSession();
FieldMask updateMask = new FieldMask();
// Make the request
DeviceSession response = await directAccessServiceClient.UpdateDeviceSessionAsync(deviceSession, updateMask);

UpdateDeviceSessionAsync(DeviceSession, FieldMask, CancellationToken)

public virtual Task<DeviceSession> UpdateDeviceSessionAsync(DeviceSession deviceSession, FieldMask updateMask, CancellationToken cancellationToken)

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

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.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskDeviceSession

A Task containing the RPC response.

Example
// Create client
DirectAccessServiceClient directAccessServiceClient = await DirectAccessServiceClient.CreateAsync();
// Initialize request argument(s)
DeviceSession deviceSession = new DeviceSession();
FieldMask updateMask = new FieldMask();
// Make the request
DeviceSession response = await directAccessServiceClient.UpdateDeviceSessionAsync(deviceSession, updateMask);

UpdateDeviceSessionAsync(UpdateDeviceSessionRequest, CallSettings)

public virtual Task<DeviceSession> UpdateDeviceSessionAsync(UpdateDeviceSessionRequest request, CallSettings callSettings = null)

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

Parameters
Name Description
request UpdateDeviceSessionRequest

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

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskDeviceSession

A Task containing the RPC response.

Example
// Create client
DirectAccessServiceClient directAccessServiceClient = await DirectAccessServiceClient.CreateAsync();
// Initialize request argument(s)
UpdateDeviceSessionRequest request = new UpdateDeviceSessionRequest
{
    DeviceSession = new DeviceSession(),
    UpdateMask = new FieldMask(),
};
// Make the request
DeviceSession response = await directAccessServiceClient.UpdateDeviceSessionAsync(request);

UpdateDeviceSessionAsync(UpdateDeviceSessionRequest, CancellationToken)

public virtual Task<DeviceSession> UpdateDeviceSessionAsync(UpdateDeviceSessionRequest request, CancellationToken cancellationToken)

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

Parameters
Name Description
request UpdateDeviceSessionRequest

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

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskDeviceSession

A Task containing the RPC response.

Example
// Create client
DirectAccessServiceClient directAccessServiceClient = await DirectAccessServiceClient.CreateAsync();
// Initialize request argument(s)
UpdateDeviceSessionRequest request = new UpdateDeviceSessionRequest
{
    DeviceSession = new DeviceSession(),
    UpdateMask = new FieldMask(),
};
// Make the request
DeviceSession response = await directAccessServiceClient.UpdateDeviceSessionAsync(request);