Documentation
¶
Overview ¶
Package devicestreaming is an auto-generated package for the Device Streaming API.
The Cloud API for device streaming usage.
NOTE: This package is in beta. It is not stable, and may be subject to changes.
General documentation ¶
For information that is relevant for all client libraries please reference https://pkg.go.dev/cloud.google.com/go#pkg-overview. Some information on this page 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@latest 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_Options c, err := devicestreaming.NewDirectAccessClient(ctx) if err != nil { // TODO: Handle error. } defer c.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) if err != nil { // TODO: Handle error. } go func() { reqs := []*devicestreamingpb.AdbMessage{ // TODO: Create requests. } for _, req := range reqs { if err := stream.Send(req); err != nil { // TODO: Handle error. } } stream.CloseSend() }() for { resp, err := stream.Recv() if err == io.EOF { break } if err != nil { // TODO: handle error. } // TODO: Use resp. _ = resp }
Use of Context ¶
The ctx passed to NewDirectAccessClient is used for authentication requests and for 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.
Index ¶
- func DefaultAuthScopes() []string
- type DeviceSessionIterator
- type DirectAccessCallOptions
- type DirectAccessClient
- func (c *DirectAccessClient) AdbConnect(ctx context.Context, opts ...gax.CallOption) (devicestreamingpb.DirectAccessService_AdbConnectClient, error)
- func (c *DirectAccessClient) CancelDeviceSession(ctx context.Context, req *devicestreamingpb.CancelDeviceSessionRequest, ...) error
- func (c *DirectAccessClient) Close() error
- func (c *DirectAccessClient) Connection() *grpc.ClientConndeprecated
- func (c *DirectAccessClient) CreateDeviceSession(ctx context.Context, req *devicestreamingpb.CreateDeviceSessionRequest, ...) (*devicestreamingpb.DeviceSession, error)
- func (c *DirectAccessClient) GetDeviceSession(ctx context.Context, req *devicestreamingpb.GetDeviceSessionRequest, ...) (*devicestreamingpb.DeviceSession, error)
- func (c *DirectAccessClient) ListDeviceSessions(ctx context.Context, req *devicestreamingpb.ListDeviceSessionsRequest, ...) *DeviceSessionIterator
- func (c *DirectAccessClient) UpdateDeviceSession(ctx context.Context, req *devicestreamingpb.UpdateDeviceSessionRequest, ...) (*devicestreamingpb.DeviceSession, error)
Examples ¶
- DirectAccessClient.AdbConnect
- DirectAccessClient.CancelDeviceSession
- DirectAccessClient.CreateDeviceSession
- DirectAccessClient.GetDeviceSession
- DirectAccessClient.ListDeviceSessions
- DirectAccessClient.ListDeviceSessions (All)
- DirectAccessClient.UpdateDeviceSession
- NewDirectAccessClient
- NewDirectAccessRESTClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultAuthScopes ¶
func DefaultAuthScopes() []string
DefaultAuthScopes reports the default set of authentication scopes to use with this package.
Types ¶
type DeviceSessionIterator ¶
type DeviceSessionIterator struct { // 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. Response interface{} // 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. InternalFetch func(pageSize int, pageToken string) (results []*devicestreamingpb.DeviceSession, nextPageToken string, err error) // 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, the iterator 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 more results. Once Next returns Done, all subsequent calls will return Done.
func (*DeviceSessionIterator) PageInfo ¶
func (it *DeviceSessionIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
type DirectAccessCallOptions ¶
type DirectAccessCallOptions struct { CreateDeviceSession []gax.CallOption ListDeviceSessions []gax.CallOption GetDeviceSession []gax.CallOption CancelDeviceSession []gax.CallOption UpdateDeviceSession []gax.CallOption AdbConnect []gax.CallOption }
DirectAccessCallOptions contains the retry settings for each method of DirectAccessClient.
type DirectAccessClient ¶
type DirectAccessClient struct { // 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 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 (at https://developer.android.com/studio/preview/android-device-streaming)
func NewDirectAccessClient ¶
func NewDirectAccessClient(ctx context.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 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 (at https://developer.android.com/studio/preview/android-device-streaming)
Example ¶
package main import ( "context" devicestreaming "cloud.google.com/go/devicestreaming/apiv1" ) func main() { 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_Options c, err := devicestreaming.NewDirectAccessClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() // TODO: Use client. _ = c }
func NewDirectAccessRESTClient ¶
func NewDirectAccessRESTClient(ctx context.Context, opts ...option.ClientOption) (*DirectAccessClient, error)
NewDirectAccessRESTClient creates a new direct access service rest client.
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 (at https://developer.android.com/studio/preview/android-device-streaming)
Example ¶
package main import ( "context" devicestreaming "cloud.google.com/go/devicestreaming/apiv1" ) func main() { 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_Options c, err := devicestreaming.NewDirectAccessRESTClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() // TODO: Use client. _ = c }
func (*DirectAccessClient) AdbConnect ¶
func (c *DirectAccessClient) AdbConnect(ctx context.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 as associate 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 ¶
package main import ( "context" "io" devicestreaming "cloud.google.com/go/devicestreaming/apiv1" devicestreamingpb "cloud.google.com/go/devicestreaming/apiv1/devicestreamingpb" ) func main() { 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_Options c, err := devicestreaming.NewDirectAccessClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() stream, err := c.AdbConnect(ctx) if err != nil { // TODO: Handle error. } go func() { reqs := []*devicestreamingpb.AdbMessage{ // TODO: Create requests. } for _, req := range reqs { if err := stream.Send(req); err != nil { // TODO: Handle error. } } stream.CloseSend() }() for { resp, err := stream.Recv() if err == io.EOF { break } if err != nil { // TODO: handle error. } // TODO: Use resp. _ = resp } }
func (*DirectAccessClient) CancelDeviceSession ¶
func (c *DirectAccessClient) CancelDeviceSession(ctx context.Context, req *devicestreamingpb.CancelDeviceSessionRequest, opts ...gax.CallOption) error
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.
Example ¶
package main import ( "context" devicestreaming "cloud.google.com/go/devicestreaming/apiv1" devicestreamingpb "cloud.google.com/go/devicestreaming/apiv1/devicestreamingpb" ) func main() { 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_Options c, err := devicestreaming.NewDirectAccessClient(ctx) if err != nil { // TODO: Handle error. } defer c.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) if err != nil { // TODO: Handle error. } }
func (*DirectAccessClient) Close ¶
func (c *DirectAccessClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*DirectAccessClient) Connection
deprecated
func (c *DirectAccessClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*DirectAccessClient) CreateDeviceSession ¶
func (c *DirectAccessClient) CreateDeviceSession(ctx context.Context, req *devicestreamingpb.CreateDeviceSessionRequest, opts ...gax.CallOption) (*devicestreamingpb.DeviceSession, error)
CreateDeviceSession creates a DeviceSession.
Example ¶
package main import ( "context" devicestreaming "cloud.google.com/go/devicestreaming/apiv1" devicestreamingpb "cloud.google.com/go/devicestreaming/apiv1/devicestreamingpb" ) func main() { 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_Options c, err := devicestreaming.NewDirectAccessClient(ctx) if err != nil { // TODO: Handle error. } defer c.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) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
func (*DirectAccessClient) GetDeviceSession ¶
func (c *DirectAccessClient) GetDeviceSession(ctx context.Context, req *devicestreamingpb.GetDeviceSessionRequest, opts ...gax.CallOption) (*devicestreamingpb.DeviceSession, error)
GetDeviceSession gets a DeviceSession, which documents the allocation status and whether the device is allocated. Clients making requests from this API must poll GetDeviceSession.
Example ¶
package main import ( "context" devicestreaming "cloud.google.com/go/devicestreaming/apiv1" devicestreamingpb "cloud.google.com/go/devicestreaming/apiv1/devicestreamingpb" ) func main() { 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_Options c, err := devicestreaming.NewDirectAccessClient(ctx) if err != nil { // TODO: Handle error. } defer c.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) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
func (*DirectAccessClient) ListDeviceSessions ¶
func (c *DirectAccessClient) ListDeviceSessions(ctx context.Context, req *devicestreamingpb.ListDeviceSessionsRequest, opts ...gax.CallOption) *DeviceSessionIterator
ListDeviceSessions lists DeviceSessions owned by the project user.
Example ¶
package main import ( "context" devicestreaming "cloud.google.com/go/devicestreaming/apiv1" devicestreamingpb "cloud.google.com/go/devicestreaming/apiv1/devicestreamingpb" "google.golang.org/api/iterator" ) func main() { 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_Options c, err := devicestreaming.NewDirectAccessClient(ctx) if err != nil { // TODO: Handle error. } defer c.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() if err == iterator.Done { break } if err != 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) } }
Example (All) ¶
package main import ( "context" devicestreaming "cloud.google.com/go/devicestreaming/apiv1" devicestreamingpb "cloud.google.com/go/devicestreaming/apiv1/devicestreamingpb" ) func main() { 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_Options c, err := devicestreaming.NewDirectAccessClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &devicestreamingpb.ListDeviceSessionsRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/devicestreaming/apiv1/devicestreamingpb#ListDeviceSessionsRequest. } for resp, err := range c.ListDeviceSessions(ctx, req).All() { if err != 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(ctx context.Context, req *devicestreamingpb.UpdateDeviceSessionRequest, opts ...gax.CallOption) (*devicestreamingpb.DeviceSession, error)
UpdateDeviceSession updates the current DeviceSession to the fields described by the update_mask.
Example ¶
package main import ( "context" devicestreaming "cloud.google.com/go/devicestreaming/apiv1" devicestreamingpb "cloud.google.com/go/devicestreaming/apiv1/devicestreamingpb" ) func main() { 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_Options c, err := devicestreaming.NewDirectAccessClient(ctx) if err != nil { // TODO: Handle error. } defer c.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) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }