azuredevops

package
v0.0.0-...-370a180 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent struct {
	Definition
	Version           string `json:"version"`
	OSDescription     string `json:"osDescription"`
	Enabled           bool   `json:"enabled"`
	Status            string `json:"status"`
	ProvisioningState string `json:"provisioningState"`
	AccessPoint       string `json:"accessPoint"`
}

Agent is the the agent object returned in AgentRequest.ReservedAgent. It is also the base struct for AgentDetails.

type AgentDetails

type AgentDetails struct {
	Agent
	SystemCapabilities   map[string]string `json:"systemCapabilities"`
	MaxParallelism       int               `json:"maxParallelism"`
	CreatedOn            string            `json:"createdOn"`
	AssignedRequest      *JobRequest       `json:"assignedRequest"`
	LastCompletedRequest *JobRequest       `json:"lastCompletedRequest"`
}

AgentDetails is the response received when retrieving an individual agent. curl -u user:token https://dev.azure.com/organization/_apis/distributedtask/pools/9/agents/8?includeCapabilities=true&includeAssignedRequest=true&includeLastCompletedRequest=true'

type Client

type Client interface {
	ListPools() ([]PoolDetails, error)
	ListPoolsByName(poolName string) ([]PoolDetails, error)
	ListPoolAgents(poolID int) ([]AgentDetails, error)
	ListJobRequests(poolID int) ([]JobRequest, error)
}

Client is used to call Azure Devops

type ClientAsync

type ClientAsync interface {
	ListPoolsAsync(channel chan<- PoolDetailsResponse)
	ListPoolsByNameAsync(channel chan<- PoolDetailsResponse, poolName string)
	ListPoolAgentsAsync(channel chan<- PoolAgentsResponse, poolID int)
	ListJobRequestsAsync(channel chan<- JobRequestsResponse, poolID int)
}

ClientAsync is an async version of Client

func MakeClient

func MakeClient(baseURL string, token string) ClientAsync

MakeClient creates a new Azure Devops client

type ClientAsyncImpl

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

ClientAsyncImpl is the async interface implementation that calls Azure Devops

func (ClientAsyncImpl) ListJobRequestsAsync

func (c ClientAsyncImpl) ListJobRequestsAsync(channel chan<- JobRequestsResponse, poolID int)

ListJobRequestsAsync retrieves the job requests for a pool

func (ClientAsyncImpl) ListPoolAgentsAsync

func (c ClientAsyncImpl) ListPoolAgentsAsync(channel chan<- PoolAgentsResponse, poolID int)

ListPoolAgentsAsync retrieves all of the agents in a pool

func (ClientAsyncImpl) ListPoolsAsync

func (c ClientAsyncImpl) ListPoolsAsync(channel chan<- PoolDetailsResponse)

ListPoolsAsync retrieves a list of agent pools

func (ClientAsyncImpl) ListPoolsByNameAsync

func (c ClientAsyncImpl) ListPoolsByNameAsync(channel chan<- PoolDetailsResponse, poolName string)

ListPoolsByNameAsync retrieves a list of agent pools with the given name

type ClientImpl

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

ClientImpl is the interface implementation that calls Azure Devops

func (ClientImpl) ListJobRequests

func (c ClientImpl) ListJobRequests(poolID int) ([]JobRequest, error)

ListJobRequests retrieves the job requests for a pool

func (ClientImpl) ListPoolAgents

func (c ClientImpl) ListPoolAgents(poolID int) ([]AgentDetails, error)

ListPoolAgents retrieves all of the agents in a pool

func (ClientImpl) ListPools

func (c ClientImpl) ListPools() ([]PoolDetails, error)

ListPools retrieves a list of agent pools

func (ClientImpl) ListPoolsByName

func (c ClientImpl) ListPoolsByName(poolName string) ([]PoolDetails, error)

ListPoolsByName retrieves a list of agent pools with the given name

type Definition

type Definition struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
}

Definition is the base type for Azure Devops responses

type Error

type Error struct {
	//ID             string `json:"$id"`
	//InnerException Error  `json:"innerException"`
	Message   string `json:"message"`
	TypeName  string `json:"typeName"`
	TypeKey   string `json:"typeKey"`
	ErrorCode int    `json:"errorCode"`
	EventID   int    `json:"eventId"`
}

Error is returned when an error occurs in the API, such as an invalid ID being used.

type HTTPError

type HTTPError struct {
	StatusCode int

	Endpoint string

	RetryAfter *time.Duration
}

HTTPError is returned when an HTTP response does not return 200

func NewHTTPError

func NewHTTPError(response *http.Response) *HTTPError

NewHTTPError returns an HTTPError

func (HTTPError) Error

func (err HTTPError) Error() string

type JobRequest

type JobRequest struct {
	RequestID              int               `json:"requestId"`
	QueueTime              string            `json:"queueTime"`
	AssignTime             string            `json:"assignTime"`
	ReceiveTime            string            `json:"receiveTime"`
	FinishTime             string            `json:"finishTime"`
	Result                 string            `json:"result"`
	ServiceOwner           string            `json:"serviceOwner"`
	HostID                 string            `json:"hostId"`
	ScopeID                string            `json:"scopeId"`
	PlanType               string            `json:"planType"`
	PlanID                 string            `json:"planId"`
	JobID                  string            `json:"jobId"`
	Demands                []string          `json:"demands"`
	MatchedAgents          []Agent           `json:"matchedAgents"`
	ReservedAgent          *Agent            `json:"reservedAgent"`
	Data                   map[string]string `json:"data"`
	PoolID                 int               `json:"poolId"`
	OrchestrationID        string            `json:"orchestrationId"`
	MatchesAllAgentsInPool bool              `json:"matchesAllAgentsInPool"`
	Definition             *Definition       `json:"definition"`
	Owner                  *Definition       `json:"definition"`
}

JobRequest represents a requested job

func (*JobRequest) IsQueuedOrRunning

func (j *JobRequest) IsQueuedOrRunning() bool

IsQueuedOrRunning determines if a job is currently queued or running

type JobRequests

type JobRequests struct {
	Count int          `json:"count"`
	Value []JobRequest `json:"value"`
}

JobRequests is the response received when retrieving a pool's jobs. curl -u user:token https://dev.azure.com/organization/_apis/distributedtask/pools/9/jobrequests'

type JobRequestsResponse

type JobRequestsResponse struct {
	Jobs []JobRequest
	Err  error
}

JobRequestsResponse is a wrapper for JobRequests to allow also returning an error in channels

type JobResult

type JobResult string

JobResult is the Result field of JobRequest Running or queued jobs don't have a result

const (
	// JobResultFailed is the result for failed jobs
	JobResultFailed JobResult = "failed"
	// JobResultCanceled is the result for canceled jobs
	JobResultCanceled JobResult = "canceled"
	// JobResultSucceeded is the result for succeeded jobs
	JobResultSucceeded JobResult = "succeeded"
)

type Pool

type Pool struct {
	Count int            `json:"count"`
	Value []AgentDetails `json:"value"`
}

Pool is the response received when retrieving an individual pool. curl -u user:token https://dev.azure.com/organization/_apis/distributedtask/pools/9/agents?includeCapabilities=true&includeAssignedRequest=true&includeLastCompletedRequest=true'

type PoolAgentsResponse

type PoolAgentsResponse struct {
	Agents []AgentDetails
	Err    error
}

PoolAgentsResponse is a wrapper for []AgentDetails to allow also returning an error in channels

type PoolDetails

type PoolDetails struct {
	Definition
	CreatedOn     string `json:"createdOn"`
	AutoProvision bool   `json:"autoProvision"`
	AutoSize      bool   `json:"autoSize"`
	TargetSize    int    `json:"targetSize"`
	AgentCloudID  int    `json:"agentCloudId"`
	CreatedBy     *User  `json:"createdBy"`
	Owner         *User  `json:"owner"`
	Scope         string `json:"scope"`
	IsHosted      bool   `json:"isHosted"`
	PoolType      string `json:"poolType"`
	Size          int    `json:"size"`
	IsLegacy      bool   `json:"isLegacy"`
}

PoolDetails is returned when listing agent pools.

type PoolDetailsResponse

type PoolDetailsResponse struct {
	Pools []PoolDetails
	Err   error
}

PoolDetailsResponse is a wrapper for []PoolDetails to allow also returning an error in channels

type PoolList

type PoolList struct {
	Count int           `json:"count"`
	Value []PoolDetails `json:"value"`
}

PoolList is the response received when listing pools. curl -u user:token https://dev.azure.com/organization/_apis/distributedtask/pools?api-version=5.0-preview.1

type User

type User struct {
	DisplayName string `json:"displayName"`
	URL         string `json:"url"`
	ID          string `json:"id"`
	UniqueName  string `json:"uniqueName"`
	ImageURL    string `json:"imageUrl"`
	Descriptor  string `json:"descriptor"`
}

User fields in the Azure Devops API

Jump to

Keyboard shortcuts

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