moblab

package
v0.0.0-...-9994f1b Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2025 License: BSD-3-Clause Imports: 22 Imported by: 0

Documentation

Overview

Copyright 2023 The Chromium Authors Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

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 BuildCallOptions

type BuildCallOptions struct {
	ListBuildTargets      []gax.CallOption
	ListModels            []gax.CallOption
	ListBuilds            []gax.CallOption
	CheckBuildStageStatus []gax.CallOption
	StageBuild            []gax.CallOption
	FindMostStableBuild   []gax.CallOption
}

BuildCallOptions contains the retry settings for each method of BuildClient.

type BuildClient

type BuildClient struct {

	// LROClient is used internally to handle longrunning operations.
	// It is exposed so that its CallOptions can be modified if required.
	// Users should not Close this client.
	LROClient *lroauto.OperationsClient

	// The call options for this service.
	CallOptions *BuildCallOptions
	// contains filtered or unexported fields
}

BuildClient is a client for interacting with .

Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.

func NewBuildClient

func NewBuildClient(ctx context.Context, opts ...option.ClientOption) (*BuildClient, error)

NewBuildClient creates a new build service client.

Manages Chrome OS build services.

Example
package main

import (
	"context"

	"go.chromium.org/infra/cros/satlab/common/google.golang.org/google/chromeos/moblab"
)

func main() {
	ctx := context.Background()
	c, err := moblab.NewBuildClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use client.
	_ = c
}
Output:

func (*BuildClient) CheckBuildStageStatus

CheckBuildStageStatus checks the stage status for a given build artifact in a partner Google Cloud Storage bucket.

Example
package main

import (
	"context"

	moblabpb "google.golang.org/genproto/googleapis/chromeos/moblab/v1beta1"

	"go.chromium.org/infra/cros/satlab/common/google.golang.org/google/chromeos/moblab"
)

func main() {
	// import moblabpb "google.golang.org/genproto/googleapis/chromeos/moblab/v1beta1"

	ctx := context.Background()
	c, err := moblab.NewBuildClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &moblabpb.CheckBuildStageStatusRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.CheckBuildStageStatus(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
Output:

func (*BuildClient) Close

func (c *BuildClient) Close() error

Close closes the connection to the API service. The user should invoke this when the client is no longer required.

func (*BuildClient) Connection

func (c *BuildClient) Connection() *grpc.ClientConn

Connection returns a connection to the API service.

Deprecated.

func (*BuildClient) FindMostStableBuild

FindMostStableBuild finds the most stable build for the given build target. The definition of the most stable build is determined by evaluating the following rules in order until one is true. If none are true, then there is no stable build and it will return an empty response.

Evaluation rules:

Stable channel build with label “Live”

Beta channel build with label “Live”

Dev channel build with label “Live”

Most recent stable channel build with build status Pass

Most recent beta channel build with build status Pass

Most recent dev channel build with build status Pass

Example
package main

import (
	"context"

	moblabpb "google.golang.org/genproto/googleapis/chromeos/moblab/v1beta1"

	"go.chromium.org/infra/cros/satlab/common/google.golang.org/google/chromeos/moblab"
)

func main() {
	// import moblabpb "google.golang.org/genproto/googleapis/chromeos/moblab/v1beta1"

	ctx := context.Background()
	c, err := moblab.NewBuildClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &moblabpb.FindMostStableBuildRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.FindMostStableBuild(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
Output:

func (*BuildClient) ListBuildTargets

ListBuildTargets lists all build targets that a user has access to.

Example
package main

import (
	"context"

	"google.golang.org/api/iterator"
	moblabpb "google.golang.org/genproto/googleapis/chromeos/moblab/v1beta1"

	"go.chromium.org/infra/cros/satlab/common/google.golang.org/google/chromeos/moblab"
)

func main() {
	// import moblabpb "google.golang.org/genproto/googleapis/chromeos/moblab/v1beta1"
	// import "google.golang.org/api/iterator"

	ctx := context.Background()
	c, err := moblab.NewBuildClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &moblabpb.ListBuildTargetsRequest{
		// TODO: Fill request struct fields.
	}
	it := c.ListBuildTargets(ctx, req)
	for {
		resp, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			// TODO: Handle error.
		}
		// TODO: Use resp.
		_ = resp
	}
}
Output:

func (*BuildClient) ListBuilds

func (c *BuildClient) ListBuilds(ctx context.Context, req *moblabpb.ListBuildsRequest, opts ...gax.CallOption) *BuildIterator

ListBuilds lists all builds for the given build target and model in descending order for the milestones and build versions.

Example
package main

import (
	"context"

	"google.golang.org/api/iterator"
	moblabpb "google.golang.org/genproto/googleapis/chromeos/moblab/v1beta1"

	"go.chromium.org/infra/cros/satlab/common/google.golang.org/google/chromeos/moblab"
)

func main() {
	// import moblabpb "google.golang.org/genproto/googleapis/chromeos/moblab/v1beta1"
	// import "google.golang.org/api/iterator"

	ctx := context.Background()
	c, err := moblab.NewBuildClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &moblabpb.ListBuildsRequest{
		// TODO: Fill request struct fields.
	}
	it := c.ListBuilds(ctx, req)
	for {
		resp, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			// TODO: Handle error.
		}
		// TODO: Use resp.
		_ = resp
	}
}
Output:

func (*BuildClient) ListModels

func (c *BuildClient) ListModels(ctx context.Context, req *moblabpb.ListModelsRequest, opts ...gax.CallOption) *ModelIterator

ListModels lists all models for the given build target.

Example
package main

import (
	"context"

	"google.golang.org/api/iterator"
	moblabpb "google.golang.org/genproto/googleapis/chromeos/moblab/v1beta1"

	"go.chromium.org/infra/cros/satlab/common/google.golang.org/google/chromeos/moblab"
)

func main() {
	// import moblabpb "google.golang.org/genproto/googleapis/chromeos/moblab/v1beta1"
	// import "google.golang.org/api/iterator"

	ctx := context.Background()
	c, err := moblab.NewBuildClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &moblabpb.ListModelsRequest{
		// TODO: Fill request struct fields.
	}
	it := c.ListModels(ctx, req)
	for {
		resp, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			// TODO: Handle error.
		}
		// TODO: Use resp.
		_ = resp
	}
}
Output:

func (*BuildClient) StageBuild

StageBuild stages a given build artifact from a internal Google Cloud Storage bucket to a partner Google Cloud Storage bucket. If any of objects has already been copied, it will overwrite the previous objects. Operation <response: StageBuildResponse, metadata: StageBuildMetadata>

Example
package main

import (
	"context"

	moblabpb "google.golang.org/genproto/googleapis/chromeos/moblab/v1beta1"

	"go.chromium.org/infra/cros/satlab/common/google.golang.org/google/chromeos/moblab"
)

func main() {
	// import moblabpb "google.golang.org/genproto/googleapis/chromeos/moblab/v1beta1"

	ctx := context.Background()
	c, err := moblab.NewBuildClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &moblabpb.StageBuildRequest{
		// TODO: Fill request struct fields.
	}
	op, err := c.StageBuild(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

	resp, err := op.Wait(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
Output:

func (*BuildClient) StageBuildOperation

func (c *BuildClient) StageBuildOperation(name string) *StageBuildOperation

StageBuildOperation returns a new StageBuildOperation from a given name. The name must be that of a previously created StageBuildOperation, possibly from a different process.

type BuildIterator

type BuildIterator 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 []*moblabpb.Build, nextPageToken string, err error)
	// contains filtered or unexported fields
}

BuildIterator manages a stream of *moblabpb.Build.

func (*BuildIterator) Next

func (it *BuildIterator) Next() (*moblabpb.Build, 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 (*BuildIterator) PageInfo

func (it *BuildIterator) PageInfo() *iterator.PageInfo

PageInfo supports pagination. See the google.golang.org/api/iterator package for details.

type BuildTargetIterator

type BuildTargetIterator 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 []*moblabpb.BuildTarget, nextPageToken string, err error)
	// contains filtered or unexported fields
}

BuildTargetIterator manages a stream of *moblabpb.BuildTarget.

func (*BuildTargetIterator) 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 (*BuildTargetIterator) PageInfo

func (it *BuildTargetIterator) PageInfo() *iterator.PageInfo

PageInfo supports pagination. See the google.golang.org/api/iterator package for details.

type ModelIterator

type ModelIterator 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 []*moblabpb.Model, nextPageToken string, err error)
	// contains filtered or unexported fields
}

ModelIterator manages a stream of *moblabpb.Model.

func (*ModelIterator) Next

func (it *ModelIterator) Next() (*moblabpb.Model, 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 (*ModelIterator) PageInfo

func (it *ModelIterator) PageInfo() *iterator.PageInfo

PageInfo supports pagination. See the google.golang.org/api/iterator package for details.

type StageBuildOperation

type StageBuildOperation struct {
	// contains filtered or unexported fields
}

StageBuildOperation manages a long-running operation from StageBuild.

func (*StageBuildOperation) Done

func (op *StageBuildOperation) Done() bool

Done reports whether the long-running operation has completed.

func (*StageBuildOperation) Metadata

Metadata returns metadata associated with the long-running operation. Metadata itself does not contact the server, but Poll does. To get the latest metadata, call this method after a successful call to Poll. If the metadata is not available, the returned metadata and error are both nil.

func (*StageBuildOperation) Name

func (op *StageBuildOperation) Name() string

Name returns the name of the long-running operation. The name is assigned by the server and is unique within the service from which the operation is created.

func (*StageBuildOperation) Poll

Poll fetches the latest state of the long-running operation.

Poll also fetches the latest metadata, which can be retrieved by Metadata.

If Poll fails, the error is returned and op is unmodified. If Poll succeeds and the operation has completed with failure, the error is returned and op.Done will return true. If Poll succeeds and the operation has completed successfully, op.Done will return true, and the response of the operation is returned. If Poll succeeds and the operation has not completed, the returned response and error are both nil.

func (*StageBuildOperation) Wait

Wait blocks until the long-running operation is completed, returning the response and any errors encountered.

See documentation of Poll for error-handling information.

Jump to

Keyboard shortcuts

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