Device Streaming API v1 - Package cloud.google.com/go/devicestreaming/apiv1 (v0.1.1) Stay organized with collections Save and categorize content based on your preferences.
Beta
This library is covered by thePre-GA Offerings Terms of the Terms of Service. Pre-GA libraries might have limited support, and changes to pre-GA libraries might not be compatible with other pre-GA versions. For more information, see thelaunch stage descriptions.
Note: To get more information about this package, such as access to older versions, viewthis package on pkg.go.dev.Package devicestreaming is an auto-generated package for theDevice Streaming API.
The Cloud API for device streaming usage.
NOTE:Thispackageisinbeta.Itisnotstable,andmaybesubjecttochanges.
General documentation
For information that is relevant for all client libraries please referencehttps://pkg.go.dev/cloud.google.com/go#pkg-overview. Some information on thispage includes:
- Authentication and Authorization
- Timeouts and Cancellation
- Testing against Client Libraries
- Debugging Client Libraries
- Inspecting errors
Example usage
To get started with this package, create a client.
// go get cloud.google.com/go/devicestreaming/apiv1@latestctx:=context.Background()// 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://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=devicestreaming.NewDirectAccessClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()
The client will use your default application credentials. Clients should be reused instead of created as needed.The methods of Client are safe for concurrent use by multiple goroutines.The returned client must be Closed when it is done being used.
Using the Client
The following is an example of making an API call with the newly created client, mentioned above.
stream,err:=c.AdbConnect(ctx)iferr!=nil{// TODO: Handle error.}gofunc(){reqs:=[]*devicestreamingpb.AdbMessage{// TODO: Create requests.}for_,req:=rangereqs{iferr:=stream.Send(req);err!=nil{// TODO: Handle error.}}stream.CloseSend()}()for{resp,err:=stream.Recv()iferr==io.EOF{break}iferr!=nil{// TODO: handle error.}// TODO: Use resp._=resp}
Use of Context
The ctx passed to NewDirectAccessClient is used for authentication requests andfor creating the underlying connection, but is not used for subsequent calls.Individual methods on the client use the ctx given to them.
To close the open connection, use the Close() method.
Functions
func DefaultAuthScopes
funcDefaultAuthScopes()[]stringDefaultAuthScopes reports the default set of authentication scopes to use with this package.
DeviceSessionIterator
typeDeviceSessionIteratorstruct{// Response is the raw response for the current page.// It must be cast to the RPC response type.// Calling Next() or InternalFetch() updates this value.Responseinterface{}// InternalFetch is for use by the Google Cloud Libraries only.// It is not part of the stable interface of this package.//// InternalFetch returns results from a single call to the underlying RPC.// The number of results is no greater than pageSize.// If there are no more results, nextPageToken is empty and err is nil.InternalFetchfunc(pageSizeint,pageTokenstring)(results[]*devicestreamingpb.DeviceSession,nextPageTokenstring,errerror)// contains filtered or unexported fields}DeviceSessionIterator manages a stream of *devicestreamingpb.DeviceSession.
func (*DeviceSessionIterator) All
func(it*DeviceSessionIterator)All()iter.Seq2[*devicestreamingpb.DeviceSession,error]All returns an iterator. If an error is returned by the iterator, theiterator will stop after that iteration.
func (*DeviceSessionIterator) Next
func(it*DeviceSessionIterator)Next()(*devicestreamingpb.DeviceSession,error)Next returns the next result. Its second return value is iterator.Done if there are no moreresults. Once Next returns Done, all subsequent calls will return Done.
func (*DeviceSessionIterator) PageInfo
func(it*DeviceSessionIterator)PageInfo()*iterator.PageInfoPageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
DirectAccessCallOptions
typeDirectAccessCallOptionsstruct{CreateDeviceSession[]gax.CallOptionListDeviceSessions[]gax.CallOptionGetDeviceSession[]gax.CallOptionCancelDeviceSession[]gax.CallOptionUpdateDeviceSession[]gax.CallOptionAdbConnect[]gax.CallOption}DirectAccessCallOptions contains the retry settings for each method of DirectAccessClient.
DirectAccessClient
typeDirectAccessClientstruct{// The call options for this service.CallOptions*DirectAccessCallOptions// contains filtered or unexported fields}DirectAccessClient is a client for interacting with Device Streaming API.Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
A service for allocating Android devices and interacting with thelive-allocated devices.
Each Session will wait for available capacity, at a higherpriority over Test Execution. When allocated, the session will be exposedthrough 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 athttps://developer.android.com/studio/preview/android-device-streaming (athttps://developer.android.com/studio/preview/android-device-streaming)
func NewDirectAccessClient
funcNewDirectAccessClient(ctxcontext.Context,opts...option.ClientOption)(*DirectAccessClient,error)NewDirectAccessClient creates a new direct access service client based on gRPC.The returned client must be Closed when it is done being used to clean up its underlying connections.
A service for allocating Android devices and interacting with thelive-allocated devices.
Each Session will wait for available capacity, at a higherpriority over Test Execution. When allocated, the session will be exposedthrough 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 athttps://developer.android.com/studio/preview/android-device-streaming (athttps://developer.android.com/studio/preview/android-device-streaming)
Example
packagemainimport("context"devicestreaming"cloud.google.com/go/devicestreaming/apiv1")funcmain(){ctx:=context.Background()// 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://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=devicestreaming.NewDirectAccessClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()// TODO: Use client._=c}func NewDirectAccessRESTClient
funcNewDirectAccessRESTClient(ctxcontext.Context,opts...option.ClientOption)(*DirectAccessClient,error)NewDirectAccessRESTClient creates a new direct access service rest client.
A service for allocating Android devices and interacting with thelive-allocated devices.
Each Session will wait for available capacity, at a higherpriority over Test Execution. When allocated, the session will be exposedthrough 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 athttps://developer.android.com/studio/preview/android-device-streaming (athttps://developer.android.com/studio/preview/android-device-streaming)
Example
packagemainimport("context"devicestreaming"cloud.google.com/go/devicestreaming/apiv1")funcmain(){ctx:=context.Background()// 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://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=devicestreaming.NewDirectAccessRESTClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()// TODO: Use client._=c}func (*DirectAccessClient) AdbConnect
func(c*DirectAccessClient)AdbConnect(ctxcontext.Context,opts...gax.CallOption)(devicestreamingpb.DirectAccessService_AdbConnectClient,error)AdbConnect exposes an ADB connection if the device supports ADB.gRPC headers are used to authenticate the Connect RPC, as well asassociate to a particular DeviceSession.In particular, the user must specify the “X-Omnilab-Session-Name” header.
This method is not supported for the REST transport.
Example
packagemainimport("context""io"devicestreaming"cloud.google.com/go/devicestreaming/apiv1"devicestreamingpb"cloud.google.com/go/devicestreaming/apiv1/devicestreamingpb")funcmain(){ctx:=context.Background()// 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://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=devicestreaming.NewDirectAccessClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()stream,err:=c.AdbConnect(ctx)iferr!=nil{// TODO: Handle error.}gofunc(){reqs:=[]*devicestreamingpb.AdbMessage{// TODO: Create requests.}for_,req:=rangereqs{iferr:=stream.Send(req);err!=nil{// TODO: Handle error.}}stream.CloseSend()}()for{resp,err:=stream.Recv()iferr==io.EOF{break}iferr!=nil{// TODO: handle error.}// TODO: Use resp._=resp}}func (*DirectAccessClient) CancelDeviceSession
func(c*DirectAccessClient)CancelDeviceSession(ctxcontext.Context,req*devicestreamingpb.CancelDeviceSessionRequest,opts...gax.CallOption)errorCancelDeviceSession cancel a DeviceSession.This RPC changes the DeviceSession to state FINISHED and terminates allconnections.Canceled sessions are not deleted and can be retrieved orlisted by the user until they expire based on the 28 day deletion policy.
Example
packagemainimport("context"devicestreaming"cloud.google.com/go/devicestreaming/apiv1"devicestreamingpb"cloud.google.com/go/devicestreaming/apiv1/devicestreamingpb")funcmain(){ctx:=context.Background()// 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://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=devicestreaming.NewDirectAccessClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&devicestreamingpb.CancelDeviceSessionRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/devicestreaming/apiv1/devicestreamingpb#CancelDeviceSessionRequest.}err=c.CancelDeviceSession(ctx,req)iferr!=nil{// TODO: Handle error.}}func (*DirectAccessClient) Close
func(c*DirectAccessClient)Close()errorClose closes the connection to the API service. The user should invoke this whenthe client is no longer required.
func (*DirectAccessClient) Connection (deprecated)
func(c*DirectAccessClient)Connection()*grpc.ClientConnConnection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not alwaysreturn the same resource.
func (*DirectAccessClient) CreateDeviceSession
func(c*DirectAccessClient)CreateDeviceSession(ctxcontext.Context,req*devicestreamingpb.CreateDeviceSessionRequest,opts...gax.CallOption)(*devicestreamingpb.DeviceSession,error)CreateDeviceSession creates a DeviceSession.
Example
packagemainimport("context"devicestreaming"cloud.google.com/go/devicestreaming/apiv1"devicestreamingpb"cloud.google.com/go/devicestreaming/apiv1/devicestreamingpb")funcmain(){ctx:=context.Background()// 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://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=devicestreaming.NewDirectAccessClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&devicestreamingpb.CreateDeviceSessionRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/devicestreaming/apiv1/devicestreamingpb#CreateDeviceSessionRequest.}resp,err:=c.CreateDeviceSession(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*DirectAccessClient) GetDeviceSession
func(c*DirectAccessClient)GetDeviceSession(ctxcontext.Context,req*devicestreamingpb.GetDeviceSessionRequest,opts...gax.CallOption)(*devicestreamingpb.DeviceSession,error)GetDeviceSession gets a DeviceSession, which documents the allocation status andwhether the device is allocated. Clients making requests from this APImust poll GetDeviceSession.
Example
packagemainimport("context"devicestreaming"cloud.google.com/go/devicestreaming/apiv1"devicestreamingpb"cloud.google.com/go/devicestreaming/apiv1/devicestreamingpb")funcmain(){ctx:=context.Background()// 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://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=devicestreaming.NewDirectAccessClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&devicestreamingpb.GetDeviceSessionRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/devicestreaming/apiv1/devicestreamingpb#GetDeviceSessionRequest.}resp,err:=c.GetDeviceSession(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*DirectAccessClient) ListDeviceSessions
func(c*DirectAccessClient)ListDeviceSessions(ctxcontext.Context,req*devicestreamingpb.ListDeviceSessionsRequest,opts...gax.CallOption)*DeviceSessionIteratorListDeviceSessions lists DeviceSessions owned by the project user.
Examples
packagemainimport("context"devicestreaming"cloud.google.com/go/devicestreaming/apiv1"devicestreamingpb"cloud.google.com/go/devicestreaming/apiv1/devicestreamingpb""google.golang.org/api/iterator")funcmain(){ctx:=context.Background()// 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://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=devicestreaming.NewDirectAccessClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&devicestreamingpb.ListDeviceSessionsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/devicestreaming/apiv1/devicestreamingpb#ListDeviceSessionsRequest.}it:=c.ListDeviceSessions(ctx,req)for{resp,err:=it.Next()iferr==iterator.Done{break}iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp// If you need to access the underlying RPC response,// you can do so by casting the `Response` as below.// Otherwise, remove this line. Only populated after// first call to Next(). Not safe for concurrent access._=it.Response.(*devicestreamingpb.ListDeviceSessionsResponse)}}all
packagemainimport("context"devicestreaming"cloud.google.com/go/devicestreaming/apiv1"devicestreamingpb"cloud.google.com/go/devicestreaming/apiv1/devicestreamingpb")funcmain(){ctx:=context.Background()// 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://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=devicestreaming.NewDirectAccessClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&devicestreamingpb.ListDeviceSessionsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/devicestreaming/apiv1/devicestreamingpb#ListDeviceSessionsRequest.}forresp,err:=rangec.ListDeviceSessions(ctx,req).All(){iferr!=nil{// TODO: Handle error and break/return/continue. Iteration will stop after any error.}// TODO: Use resp._=resp}}func (*DirectAccessClient) UpdateDeviceSession
func(c*DirectAccessClient)UpdateDeviceSession(ctxcontext.Context,req*devicestreamingpb.UpdateDeviceSessionRequest,opts...gax.CallOption)(*devicestreamingpb.DeviceSession,error)UpdateDeviceSession updates the current DeviceSession to the fields described by theupdate_mask.
Example
packagemainimport("context"devicestreaming"cloud.google.com/go/devicestreaming/apiv1"devicestreamingpb"cloud.google.com/go/devicestreaming/apiv1/devicestreamingpb")funcmain(){ctx:=context.Background()// 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://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=devicestreaming.NewDirectAccessClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&devicestreamingpb.UpdateDeviceSessionRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/devicestreaming/apiv1/devicestreamingpb#UpdateDeviceSessionRequest.}resp,err:=c.UpdateDeviceSession(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-10-30 UTC.