wharfapi

package
v2.2.1 Latest Latest
Warning

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

Go to latest
Published: May 10, 2022 License: MIT Imports: 30 Imported by: 2

Documentation

Overview

Package wharfapi has a list of type-safe functions used to access Wharf's main API (wharf-api).

Index

Constants

View Source
const (
	// BuildScheduling means that the build has not started execution yet.
	BuildScheduling = BuildStatus(iota)
	// BuildRunning means that the build is currently executing code.
	BuildRunning
	// BuildCompleted means that the build ran successfully to completetion.
	BuildCompleted
	// BuildFailed means that the build ran unsuccessfully.
	BuildFailed
)

Variables

View Source
var (
	// ErrOutdatedServer is returned from an endpoint method when the
	// Client.ErrIfOutdatedServer flag is enabled and the server is of a lower
	// version than when the endpoint was first introduced to the wharf-api.
	ErrOutdatedServer = errors.New("outdated server")
	// ErrOutdatedClient is returned from an endpoint method when the
	// Client.ErrIfOutdatedClient flag is enabled and the client is of a too
	// low version than when the server.
	ErrOutdatedClient = errors.New("outdated client")
)
View Source
var HighestSupportedVersion = semver.MustParse("5.1.0")

HighestSupportedVersion is the highest version that the wharf-api-client-go is known to work for. It is used when checking if the client is outdated, given the Client.ErrIfOutdatedClient is enabled.

Functions

This section is empty.

Types

type ArtifactSearch

type ArtifactSearch struct {
	BuildID       *uint    `url:"buildId,omitempty"`
	Limit         *int     `url:"limit,omitempty"`
	Offset        *int     `url:"offset,omitempty"`
	OrderBy       []string `url:"orderby,omitempty"`
	Name          *string  `url:"name,omitempty"`
	FileName      *string  `url:"fileName,omitempty"`
	NameMatch     *string  `url:"nameMatch,omitempty"`
	FileNameMatch *string  `url:"fileNameMatch,omitempty"`
	Match         *string  `url:"match,omitempty"`
}

ArtifactSearch is used when getting artifacts without using an artifact ID through the HTTP request:

GET /api/build/{buildId}/artifact

type AuthError

type AuthError struct {
	Realm string
}

AuthError is returned on authentication/authorization errors issued when trying to communicate with the Wharf API.

This could be because of missing, invalid, or outdated authentication header provided to the client.

func (*AuthError) Error

func (e *AuthError) Error() string

type BuildSearch

type BuildSearch struct {
	Limit     *int     `url:"limit,omitempty"`
	Offset    *int     `url:"offset,omitempty"`
	OrderBy   []string `url:"orderby,omitempty"`
	ProjectID *uint    `url:"projectId,omitempty"`

	ScheduledAfter  *time.Time `url:"scheduledAfter,omitempty"`
	ScheduledBefore *time.Time `url:"scheduledBefore,omitempty"`
	FinishedAfter   *time.Time `url:"finishedAfter,omitempty"`
	FinishedBefore  *time.Time `url:"finishedBefore,omitempty"`

	IsInvalid *bool    `url:"isInvalid,omitempty"`
	Status    []string `url:"status,omitempty"`
	StatusID  []int    `url:"statusId,omitempty"`

	Environment *string `url:"environment,omitempty"`
	GitBranch   *string `url:"gitBranch,omitempty"`
	Stage       *string `url:"stage,omitempty"`

	EnvironmentMatch *string `url:"environmentMatch,omitempty"`
	GitBranchMatch   *string `url:"gitBranchMatch,omitempty"`
	StageMatch       *string `url:"stageMatch,omitempty"`
	Match            *string `url:"match,omitempty"`
}

BuildSearch is used when getting builds without using a build ID through the HTTP request:

GET /api/build

type BuildStatus

type BuildStatus int

BuildStatus is the state of a build.

The flow of the build status goes like this:

          Scheduling
              |
              V
           Running
             / \
Completed <-/   \-> Failed

func (BuildStatus) String

func (bs BuildStatus) String() string

type Client

type Client struct {
	AuthHeader string
	APIURL     string

	// ErrIfOutdatedClient will error if the client is outdated. Wharf aims
	// for a backward compatability of 1 major version back, so the client will
	// only prematurely error before making a request if the client is 2 major
	// versions behind or more. Example:
	//
	//   Server version        Client supports        Client outdated?
	//   v5.0.0                v5.0.0                 No
	//   v5.1.0                v5.0.0                 No
	//   v6.0.0                v5.0.0                 No
	//   v6.12.5               v5.0.0                 No
	//   v7.0.0                v5.0.0                 Yes
	ErrIfOutdatedClient bool

	// ErrIfOutdatedServer will error if the remote API version is too low for
	// each endpoint before even making the web request.
	ErrIfOutdatedServer bool

	// DisableOutdatedLogging will disable the logging to console if there are
	// unattended issues regarding version mismatch between the client and the
	// server.
	DisableOutdatedLogging bool
	// contains filtered or unexported fields
}

Client contains authentication and API URLs used to access the Wharf main API.

func (Client) CreateBuildArtifact added in v2.1.0

func (c Client) CreateBuildArtifact(buildID uint, fileName string, artifact io.Reader) error

CreateBuildArtifact uploads an artifact by invoking the HTTP request:

POST /api/build/{buildId}/artifact

Added in wharf-api v0.4.9.

func (*Client) CreateBuildLog

func (c *Client) CreateBuildLog(buildID uint, buildLog request.LogOrStatusUpdate) error

CreateBuildLog adds a new log to a build by invoking the HTTP request:

POST /api/build/{buildId}/log

Added in wharf-api v0.1.0.

func (*Client) CreateBuildLogStream added in v2.1.0

func (c *Client) CreateBuildLogStream(ctx context.Context) (CreateBuildLogStream, error)

CreateBuildLogStream creates a log creation stream used to sending log creation requests in a streamed fashion by reusing the same TCP connection for higher throughput during log injection.

Added in wharf-api v5.1.0.

func (*Client) CreateBuildTestResult added in v2.1.0

func (c *Client) CreateBuildTestResult(buildID uint, fileName string, testResult io.Reader) ([]response.ArtifactMetadata, error)

CreateBuildTestResult uploads a test result file (eg: "tests.trx") by invoking the HTTP request:

POST /api/build/{buildId}/test-result

Added in wharf-api v5.0.0.

func (*Client) CreateProject

func (c *Client) CreateProject(project request.Project) (response.Project, error)

CreateProject adds a new project to the database by invoking the HTTP request:

POST /api/project

Added in wharf-api v0.1.10.

func (*Client) CreateProjectBranch

func (c *Client) CreateProjectBranch(projectID uint, branch request.Branch) (response.Branch, error)

CreateProjectBranch adds a branch to the project with the matching project ID by invoking the HTTP request:

POST /api/project/{projectId}/branch

Added in wharf-api v5.0.0.

func (*Client) CreateProvider

func (c *Client) CreateProvider(provider request.Provider) (response.Provider, error)

CreateProvider creates a new provider by invoking the HTTP request:

POST /api/provider

Added in wharf-api v0.3.9.

func (*Client) CreateToken

func (c *Client) CreateToken(token request.Token) (response.Token, error)

CreateToken adds a new a token by invoking the HTTP request:

POST /api/token

Added in wharf-api v0.2.0.

func (*Client) DeleteProject added in v2.1.0

func (c *Client) DeleteProject(projectID uint) error

DeleteProject deletes a project by ID by invoking the HTTP request:

DELETE /api/project/{projectID}/override

This will also delete all associated artifacts, builds, and logs. This is an irreversable action.

Added in wharf-api v0.2.8.

func (*Client) DeleteProjectOverrides added in v2.1.0

func (c *Client) DeleteProjectOverrides(projectID uint) error

DeleteProjectOverrides clears a project's overrides by project ID by invoking the HTTP request:

DELETE /api/project/{projectID}/override

Added in wharf-api v5.0.0.

func (*Client) GetBuild

func (c *Client) GetBuild(buildID uint) (response.Build, error)

GetBuild gets a build by invoking the HTTP request:

GET /api/build/{buildId}

Added in wharf-api v0.3.5.

func (*Client) GetBuildAllTestResultDetailList

func (c *Client) GetBuildAllTestResultDetailList(buildID uint) (response.PaginatedTestResultDetails, error)

GetBuildAllTestResultDetailList fetches all the test result details for the specified build by invoking the HTTP request:

GET /api/build/{buildId}/test-result/detail

Added in wharf-api v5.0.0.

func (*Client) GetBuildAllTestResultListSummary

func (c *Client) GetBuildAllTestResultListSummary(buildID uint) (response.TestResultListSummary, error)

GetBuildAllTestResultListSummary fetches the test result list summary of all tests for the specified build.

GET /api/build/{buildId}/test-result/list-summary

Added in wharf-api v5.0.0.

func (*Client) GetBuildAllTestResultSummaryList

func (c *Client) GetBuildAllTestResultSummaryList(buildID uint) (response.PaginatedTestResultSummaries, error)

GetBuildAllTestResultSummaryList fetches all the test result summaries for the specified build by invoking the HTTP request:

GET /api/build/{buildId}/test-result/summary

Added in wharf-api v5.0.0.

func (*Client) GetBuildArtifact

func (c *Client) GetBuildArtifact(buildID, artifactID uint) (io.ReadCloser, error)

GetBuildArtifact gets an artifact by invoking the HTTP request:

GET /api/build/{buildId}/artifact/{artifactId}

Added in wharf-api v0.7.1.

func (*Client) GetBuildArtifactList

func (c *Client) GetBuildArtifactList(params ArtifactSearch, buildID uint) (response.PaginatedArtifacts, error)

GetBuildArtifactList filters artifacts based on the parameters by invoking the HTTP request:

GET /api/build/{buildId}/artifact

Added in wharf-api v5.0.0.

func (*Client) GetBuildList

func (c *Client) GetBuildList(params BuildSearch) (response.PaginatedBuilds, error)

GetBuildList filters builds based on the parameters by invoking the HTTP request:

GET /api/build

Added in wharf-api v5.0.0.

func (*Client) GetBuildLogList

func (c *Client) GetBuildLogList(buildID uint) ([]response.Log, error)

GetBuildLogList gets the logs for a build by invoking the HTTP request:

GET /api/build/{buildId}/log

Added in wharf-api v0.3.8.

func (*Client) GetBuildTestResultDetailList

func (c *Client) GetBuildTestResultDetailList(buildID, artifactID uint) (response.PaginatedTestResultDetails, error)

GetBuildTestResultDetailList fetches all test result details for the specified test result summary by invoking the HTTP request:

GET /api/build/{buildId}/test-result/summary/{artifactId}/detail

Added in wharf-api v5.0.0.

func (*Client) GetBuildTestResultSummary

func (c *Client) GetBuildTestResultSummary(buildID, artifactID uint) (response.TestResultSummary, error)

GetBuildTestResultSummary fetches a test result summary by ID by invoking the HTTP request:

GET /api/build/{buildId}/test-result/summary/{artifactId}

Added in wharf-api v5.0.0.

func (*Client) GetEngineList added in v2.2.0

func (c *Client) GetEngineList() (response.EngineList, error)

GetEngineList filters builds based on the parameters by invoking the HTTP request:

GET /api/build

Added in wharf-api v5.1.0.

func (*Client) GetHealth added in v2.1.0

func (c *Client) GetHealth() (response.HealthStatus, error)

GetHealth gets the health of the API by invoking the HTTP request:

GET /api/health

Added in wharf-api v0.7.1.

func (*Client) GetProject

func (c *Client) GetProject(projectID uint) (response.Project, error)

GetProject fetches a project by ID by invoking the HTTP request:

GET /api/project/{projectID}

Added in wharf-api v0.1.10.

func (*Client) GetProjectBranchList

func (c *Client) GetProjectBranchList(projectID uint) ([]response.Branch, error)

GetProjectBranchList gets the branches for a project by invoking the HTTP request:

GET /api/project/{projectId}/branch

Added in wharf-api v5.0.0.

func (*Client) GetProjectList

func (c *Client) GetProjectList(params ProjectSearch) (response.PaginatedProjects, error)

GetProjectList filters projects based on the parameters by invoking the HTTP request:

GET /api/project

Added in wharf-api v5.0.0.

func (*Client) GetProjectOverrides added in v2.1.0

func (c *Client) GetProjectOverrides(projectID uint) (response.ProjectOverrides, error)

GetProjectOverrides fetches a project's overrides by project ID by invoking the HTTP request:

GET /api/project/{projectID}/override

Added in wharf-api v5.0.0.

func (*Client) GetProvider

func (c *Client) GetProvider(providerID uint) (response.Provider, error)

GetProvider fetches a provider by ID by invoking the HTTP request:

GET /api/provider/{providerID}

Added in wharf-api v0.3.9.

func (*Client) GetProviderList

func (c *Client) GetProviderList(params ProviderSearch) (response.PaginatedProviders, error)

GetProviderList filters providers based on the parameters by invoking the HTTP request:

GET /api/provider

Added in wharf-api v5.0.0.

func (*Client) GetToken

func (c *Client) GetToken(tokenID uint) (response.Token, error)

GetToken fetches a token by ID by invoking the HTTP request:

GET /api/token/{tokenID}

Added in wharf-api v0.2.2.

func (*Client) GetTokenList

func (c *Client) GetTokenList(params TokenSearch) (response.PaginatedTokens, error)

GetTokenList filters tokens based on the parameters by invoking the HTTP request:

GET /api/token

Added in wharf-api v5.0.0.

func (*Client) GetVersion added in v2.1.0

func (c *Client) GetVersion() (app.Version, error)

GetVersion gets the version of the API by invoking the HTTP request:

GET /api/version

Added in wharf-api v4.0.0.

func (*Client) Ping added in v2.1.0

func (c *Client) Ping() (response.Ping, error)

Ping pings, and hopefully you get a pong in return, by invoking the HTTP request:

GET /api/ping

Added in wharf-api v4.2.0.

func (*Client) ResetCachedVersion added in v2.1.0

func (c *Client) ResetCachedVersion()

ResetCachedVersion will reset the version that the wharf-api client thinks the remote API has, and will then check for a fresh value on the next request.

func (*Client) SetCachedVersion added in v2.1.0

func (c *Client) SetCachedVersion(major, minor, patch uint64)

SetCachedVersion will override the version that the wharf-api-client-go thinks the remote API has when validating the Client.ErrIfOutdatedServer.

func (*Client) StartProjectBuild

func (c *Client) StartProjectBuild(projectID uint, params ProjectStartBuild, inputs request.BuildInputs) (response.BuildReferenceWrapper, error)

StartProjectBuild starts a new build by invoking the HTTP request:

POST /api/project/{projectID}/build

Added in wharf-api v5.0.0.

func (*Client) UpdateBuildStatus

func (c *Client) UpdateBuildStatus(buildID uint, status request.LogOrStatusUpdate) (response.Build, error)

UpdateBuildStatus updates a build by invoking the HTTP request:

PUT /api/build/{buildId}/status

Added in wharf-api v5.0.0.

func (*Client) UpdateProject

func (c *Client) UpdateProject(projectID uint, project request.ProjectUpdate) (response.Project, error)

UpdateProject updates a project by ID by invoking the HTTP request:

PUT /api/project/{projectID}

Added in wharf-api v5.0.0.

func (*Client) UpdateProjectBranchList

func (c *Client) UpdateProjectBranchList(projectID uint, branches []request.Branch) ([]response.Branch, error)

UpdateProjectBranchList resets the default branch and list of branches for a project using the project ID from the first branch in the provided list by invoking the HTTP request:

PUT /api/project/{projectId}/branch

Added in wharf-api v5.0.0.

func (*Client) UpdateProjectOverrides added in v2.1.0

func (c *Client) UpdateProjectOverrides(projectID uint, overrides request.ProjectOverridesUpdate) (response.ProjectOverrides, error)

UpdateProjectOverrides updates a project's overrides by project ID by invoking the HTTP request:

PUT /api/project/{projectID}/override

Added in wharf-api v5.0.0.

func (*Client) UpdateProvider

func (c *Client) UpdateProvider(providerID uint, provider request.ProviderUpdate) (response.Provider, error)

UpdateProvider updates the provider with the specified ID by invoking the HTTP request:

PUT /api/provider/{providerID}

Added in wharf-api v5.0.0.

func (*Client) UpdateToken

func (c *Client) UpdateToken(tokenID uint, token request.TokenUpdate) (response.Token, error)

UpdateToken updates the token with the specified ID by invoking the HTTP request:

PUT /api/token/{tokenID}

Added in wharf-api v5.0.0.

type CreateBuildLogStream added in v2.1.0

type CreateBuildLogStream interface {
	Send(request.Log) error
	CloseAndRecv() (response.CreatedLogsSummary, error)
}

CreateBuildLogStream contains methods for sending log creation requests in a streamed fashion.

type ProjectSearch

type ProjectSearch struct {
	OrderBy          []string `url:"orderby,omitempty"`
	Limit            *int     `url:"limit,omitempty"`
	Offset           *int     `url:"offset,omitempty"`
	Name             *string  `url:"name,omitempty"`
	GroupName        *string  `url:"groupName,omitempty"`
	Description      *string  `url:"description,omitempty"`
	TokenID          *uint    `url:"tokenId,omitempty"`
	ProviderID       *uint    `url:"providerId,omitempty"`
	GitURL           *string  `url:"gitUrl,omitempty"`
	NameMatch        *string  `url:"nameMatch,omitempty"`
	GroupNameMatch   *string  `url:"groupNameMatch,omitempty"`
	DescriptionMatch *string  `url:"descriptionMatch,omitempty"`
	GitURLMatch      *string  `url:"gitUrlMatch,omitempty"`
	Match            *string  `url:"match,omitempty"`
}

ProjectSearch is used when getting projects without using a project ID through the HTTP request:

GET /api/project

type ProjectStartBuild

type ProjectStartBuild struct {
	Stage       string `url:"stage"`
	Branch      string `url:"branch,omitempty"`
	Environment string `url:"environment,omitempty"`
	Engine      string `url:"engine,omitempty"`
}

ProjectStartBuild is a range of options you start a build with. The ProjectID and Stage fields are required when starting a build.

type ProviderSearch

type ProviderSearch struct {
	Limit     *int     `url:"limit,omitempty"`
	Offset    *int     `url:"offset,omitempty"`
	OrderBy   []string `url:"orderby,omitempty"`
	Name      *string  `url:"name,omitempty"`
	URL       *string  `url:"url,omitempty"`
	NameMatch *string  `url:"nameMatch,omitempty"`
	URLMatch  *string  `url:"urlMatch,omitempty"`
	Match     *string  `url:"match,omitempty"`
}

ProviderSearch is used when getting providers without using a provider ID through the HTTP request:

GET /api/provider

type TokenSearch

type TokenSearch struct {
	Limit         *int     `url:"limit,omitempty"`
	Offset        *int     `url:"offset,omitempty"`
	OrderBy       []string `url:"orderby,omitempty"`
	UserName      *string  `url:"userName,omitempty"`
	UserNameMatch *string  `url:"userNameMatch,omitempty"`
}

TokenSearch is used when getting tokens without using a token ID through the HTTP request:

GET /api/token

type WharfClient deprecated

type WharfClient Client

WharfClient contains authentication and API URLs used to access the Wharf main API.

Deprecated: This type has been renamed to Client and may be removed in a future release.

Jump to

Keyboard shortcuts

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