devicestreaming

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 15, 2025 License: Apache-2.0 Imports: 27 Imported by: 0

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:

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

Examples

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

All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.

func (*DeviceSessionIterator) Next

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

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

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

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

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

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

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
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL