androidapi

package
v0.0.0-...-cd06882 Latest Latest
Warning

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

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

Documentation

Overview

Package androidapi provides library functions for interating with Android One platform APIs go/ants-api#one-platform

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FetchCredentials

func FetchCredentials(rt RunType) (*google.Credentials, error)

FetchCredentials fetches creds for authentication.

func GetAndroidOnePlatformClient

func GetAndroidOnePlatformClient(rt RunType) (*http.Client, error)

GetAndroidOnePlatformClient returns an HTTP client for making REST calls to Android One platform APIs. The rt parameter specifies the environment, determining whether the client is used on a bot with an attached Service Account (SA), within a container, or in a local environment.

func GetLatestGreenBuildNumber

func GetLatestGreenBuildNumber(rt RunType, buildsReq BuildGetRequest) (int, error)

GetLatestGreenBuildNumber calls the android one platform api to get latest build version

func NewWorkUnit

func NewWorkUnit(parentWUId, invocationID, name string, childRunNumber, childShardNumber, childAttemptNumber int) *atp.WorkUnit

NewWorkUnit is a helper function to generate a new WorkUnit.

Types

type AndroidBuildAPIOptions

type AndroidBuildAPIOptions struct {
	// The optional page token for the request.
	// If empty, the first page will be returned.
	PageToken string

	// The max results to be returned by the API.
	// If empty, the default max results will be used.
	MaxResults int64
}

AndroidBuildAPIOptions represents the common request options when communicating with android build API.

type BuildGetRequest

type BuildGetRequest struct {
	BuildType   string
	Branch      string
	MaxResults  string
	SortingType string
	Successful  string
	Board       string
}

BuildGetRequest defines get request params for builds endpoint

type ChildNodes

type ChildNodes []*WorkUnitNode

ChildNodes implements sort.Interface so that we can iterate according to the node's index.

func (ChildNodes) Len

func (c ChildNodes) Len() int

func (ChildNodes) Less

func (c ChildNodes) Less(i, j int) bool

func (ChildNodes) Swap

func (c ChildNodes) Swap(i, j int)

type InvocationService

type InvocationService interface {
	Get(ctx context.Context, resourceID string) (*atp.Invocation, error)
	Insert(invocation *atp.Invocation) (*atp.Invocation, error)
	Update(resourceID string, invocation *atp.Invocation) (*atp.Invocation, error)
	Patch(resourceID string, invocation *atp.Invocation) (*atp.Invocation, error)
	List(ctx context.Context, invocationID string, options AndroidBuildAPIOptions) (*atp.InvocationListResponse, error)
}

InvocationService handles API calls related to invocations.

type InvocationServiceImpl

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

InvocationServiceImpl is the RPC implementation of InvocationService.

func (*InvocationServiceImpl) Get

func (w *InvocationServiceImpl) Get(ctx context.Context, resourceID string) (*atp.Invocation, error)

Get implementation for invocations.

func (*InvocationServiceImpl) Insert

func (w *InvocationServiceImpl) Insert(invocation *atp.Invocation) (*atp.Invocation, error)

Insert implementation for invocations.

func (*InvocationServiceImpl) List

List implementation for invocations.

func (*InvocationServiceImpl) Patch

func (w *InvocationServiceImpl) Patch(resourceID string, invocation *atp.Invocation) (*atp.Invocation, error)

Patch implementation for invocations.

func (*InvocationServiceImpl) Update

func (w *InvocationServiceImpl) Update(resourceID string, invocation *atp.Invocation) (*atp.Invocation, error)

Update implementation for invocations.

type InvocationState

type InvocationState int
const (
	InvocationUnspecified InvocationState = iota
	InvocationQueued
	InvocationRunning
	InvocationError
	InvocationCompleted
	InvocationCancelled
	InvocationPending
	InvocationSkipped
)

func (InvocationState) String

func (w InvocationState) String() string

type RunType

type RunType int

RunType is enum defining where would client be executed

const (
	Local RunType = iota
	ContainerGce
	ContainerSatlab
	ServiceAccount
)

Define constants for RunType

func (RunType) String

func (rt RunType) String() string

String method to get a string representation of RunType

type Service

type Service struct {
	WorkUnitService      WorkUnitService
	InvocationService    InvocationService
	TestResultService    TestResultService
	TestArtifactsService TestArtifactsService
}

Service is used for accessing the android build api. It is broken into sub services similar to the underlying API. All sub services share the same client, so the caller needs to initialize it when the service is first used.

func NewAndroidBuildService

func NewAndroidBuildService(ctx context.Context, rt RunType, env common.Environment) (*Service, error)

NewAndroidBuildService returns a new service which is used to interact with the android build api. It initializes the build client depending on rt RunType(environment SA, container or local)

type TestArtifactsService

type TestArtifactsService interface {
	Get(resourceID string) (*atp.BuildArtifactMetadata, error)
	Update(resourceID string, reader io.Reader, metadata *atp.BuildArtifactMetadata) (*atp.BuildArtifactMetadata, error)
	List(ctx context.Context, invocationID string, options AndroidBuildAPIOptions) (*atp.TestArtifactListResponse, error)
}

TestArtifactsService handles API calls related to testResults.

type TestArtifactsServiceImpl

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

TestArtifactsServiceImpl is the RPC implementation of TestArtifactsService.

func (*TestArtifactsServiceImpl) Get

Get implmentation for test artifact metadata.

func (*TestArtifactsServiceImpl) List

List implmentation for test artifact.

func (*TestArtifactsServiceImpl) Update

func (w *TestArtifactsServiceImpl) Update(resourceID string, reader io.Reader, metadata *atp.BuildArtifactMetadata) (*atp.BuildArtifactMetadata, error)

Update implementation for test artifact metadata.

type TestResultService

type TestResultService interface {
	Get(resourceID int64) (*atp.TestResult, error)
	Insert(testResult *atp.TestResult) (*atp.TestResult, error)
	BatchInsert(ctx context.Context, invocationID string, request *atp.TestResultBatchInsertRequest) (*atp.TestResultBatchInsertResponse, error)
	Update(resourceID int64, testResult *atp.TestResult) (*atp.TestResult, error)
	List(ctx context.Context, invocationID string, options AndroidBuildAPIOptions) (*atp.TestResultListResponse, error)
}

TestResultService handles API calls related to testResults.

type TestResultServiceImpl

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

TestResultServiceImpl is the RPC implementation of TestResultService.

func (*TestResultServiceImpl) BatchInsert

BatchInsert implementation for testResults.

func (*TestResultServiceImpl) Get

func (w *TestResultServiceImpl) Get(resourceID int64) (*atp.TestResult, error)

Get implementation for testResults.

func (*TestResultServiceImpl) Insert

func (w *TestResultServiceImpl) Insert(testResult *atp.TestResult) (*atp.TestResult, error)

Insert implementation for testResults.

func (*TestResultServiceImpl) List

List implementation for testResults.

func (*TestResultServiceImpl) Update

func (w *TestResultServiceImpl) Update(resourceID int64, testResult *atp.TestResult) (*atp.TestResult, error)

Update implementation for testResults.

type WULayer

type WULayer int

WULayer is and enum signifying what WU layer type the node represents

const (
	WULayerUnknown WULayer = iota
	WULayerTestJob
	WULayerRun
	WULayerShard
	WULayerAttempt
	WULayerCTP
)

func (WULayer) String

func (w WULayer) String() string

type WorkUnitNode

type WorkUnitNode struct {
	Service WorkUnitService
	// contains filtered or unexported fields
}

WorkUnitNode encapsulates an ATP WorkUnit and associated metadata to keep the tree in memory in a sensible way. Struct fields are not exposed to keep access of the tree limited to the exposed functions.

func NewWorkUnitNode

func NewWorkUnitNode(ctx context.Context, parentWUId, invocationID string, nodeType WULayer, parent *WorkUnitNode, env common.Environment) (*WorkUnitNode, error)

NewWorkUnitNode Creates and registers a Work Unit using the ATP API and inserts it into the local Work Unit tree.

func (*WorkUnitNode) AddChild

func (w *WorkUnitNode) AddChild(node *WorkUnitNode) error

func (*WorkUnitNode) FetchAttemptLayer

func (w *WorkUnitNode) FetchAttemptLayer() ([][]*WorkUnitNode, error)

func (*WorkUnitNode) FetchHead

func (w *WorkUnitNode) FetchHead() (*WorkUnitNode, error)

func (*WorkUnitNode) FetchRunLayer

func (w *WorkUnitNode) FetchRunLayer() ([]*WorkUnitNode, error)

func (*WorkUnitNode) FetchShardLayer

func (w *WorkUnitNode) FetchShardLayer() ([][]*WorkUnitNode, error)

func (*WorkUnitNode) GetChildren

func (w *WorkUnitNode) GetChildren() ChildNodes

GetChildren returns the sorted list of children.

func (*WorkUnitNode) GetIndex

func (w *WorkUnitNode) GetIndex() int

func (*WorkUnitNode) GetLayer

func (w *WorkUnitNode) GetLayer() WULayer

func (*WorkUnitNode) GetParent

func (w *WorkUnitNode) GetParent() *WorkUnitNode

func (*WorkUnitNode) GetWorkUnit

func (w *WorkUnitNode) GetWorkUnit() *atp.WorkUnit

func (*WorkUnitNode) SetWorkUnit

func (w *WorkUnitNode) SetWorkUnit(newWU *atp.WorkUnit)

type WorkUnitService

type WorkUnitService interface {
	Get(resourceID string) (*atp.WorkUnit, error)
	Insert(workunit *atp.WorkUnit) (*atp.WorkUnit, error)
	Update(resourceID string, workunit *atp.WorkUnit) (*atp.WorkUnit, error)
	Patch(resourceID string, workunit *atp.WorkUnit) (*atp.WorkUnit, error)
	List(ctx context.Context, invocationID string, options AndroidBuildAPIOptions) (*atp.WorkUnitListResponse, error)
}

WorkUnitService handles API calls related to workunits.

type WorkUnitServiceImpl

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

WorkUnitServiceImpl is the RPC implementation of WorkUnitService.

func (*WorkUnitServiceImpl) Get

func (w *WorkUnitServiceImpl) Get(resourceID string) (*atp.WorkUnit, error)

Get implementation for workunits.

func (*WorkUnitServiceImpl) Insert

func (w *WorkUnitServiceImpl) Insert(workunit *atp.WorkUnit) (*atp.WorkUnit, error)

Insert implementation for workunits.

func (*WorkUnitServiceImpl) List

List implementation for workunits.

func (*WorkUnitServiceImpl) Patch

func (w *WorkUnitServiceImpl) Patch(resourceID string, workunit *atp.WorkUnit) (*atp.WorkUnit, error)

Patch implementation for workunits.

func (*WorkUnitServiceImpl) Update

func (w *WorkUnitServiceImpl) Update(resourceID string, workunit *atp.WorkUnit) (*atp.WorkUnit, error)

Update implementation for workunits.

type WorkUnitState

type WorkUnitState int
const (
	WorkUnitUnspecified WorkUnitState = iota
	WorkUnitQueued
	WorkUnitRunning
	WorkUnitError
	WorkUnitCompleted
	WorkUnitCancelled
	WorkUnitPending
	WorkUnitSkipped
)

func (WorkUnitState) String

func (w WorkUnitState) String() string

type WorkUnitTree

type WorkUnitTree struct {
	Head *WorkUnitNode

	// ShardsByKey will be used to map shard nodes by the BuildsMap keys. This
	// will allow us to remove the requirement of including the shards as
	// arguments to scheduleAndMonitor().
	ShardsByKey map[string]*WorkUnitNode
}

Directories

Path Synopsis
Package mock_androidapi is a generated GoMock package.
Package mock_androidapi is a generated GoMock package.

Jump to

Keyboard shortcuts

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