api

package
v0.0.0-...-6e3d6eb Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2017 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddRequestHeaders

func AddRequestHeaders(req *http.Request)

AddRequestHeaders add a few default headers to req. Currently added: User- Agent, X-Wercker-Version, X-Wercker-Git.

Types

type APIBuild

type APIBuild struct {
	ID         string  `json:"id"`
	URL        string  `json:"url"`
	Status     string  `json:"status"`
	Result     string  `json:"result"`
	CreatedAt  string  `json:"createdAt"`
	UpdatedAt  string  `json:"updatedAt"`
	FinishedAt string  `json:"finishedAt"`
	Progress   float64 `json:"progress"`
}

APIBuild represents a build from wercker api.

type APIClient

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

APIClient is a very dumb client for the wercker API

func NewAPIClient

func NewAPIClient(options *APIOptions) *APIClient

NewAPIClient returns our dumb client

func (*APIClient) Get

func (c *APIClient) Get(path string) (*http.Response, error)

Get will do a GET http request, it adds the wercker endpoint and will add some default headers.

func (*APIClient) GetBody

func (c *APIClient) GetBody(path string) ([]byte, error)

GetBody does a GET request. If the status code is 200, it will return the body.

func (*APIClient) GetBuilds

func (c *APIClient) GetBuilds(username, name string, options *GetBuildsOptions) ([]*APIBuild, error)

GetBuilds will fetch multiple builds for application username/name.

func (*APIClient) GetDockerRepository

func (c *APIClient) GetDockerRepository(buildID string) (*DockerRepository, error)

GetDockerRepository will retrieve a snappy-stream compressed tarball.

func (*APIClient) GetStepVersion

func (c *APIClient) GetStepVersion(owner, name, version string) (*APIStepVersion, error)

GetStepVersion grabs a step at a specific version

func (*APIClient) URL

func (c *APIClient) URL(path string) string

URL joins a path with the baseurl. If path doesn't have a leading slash, it will be added.

type APIError

type APIError struct {
	Message    string `json:"message"`
	StatusCode int    `json:"statusCode"`
}

APIError represents a wercker error.

func (*APIError) Error

func (e *APIError) Error() string

Error returns the message and status code.

type APIOptions

type APIOptions struct {
	BaseURL   string
	AuthToken string
}

type APIStepVersion

type APIStepVersion struct {
	TarballURL  string `json:"tarballUrl"`
	Version     string `json:"version"`
	Description string `json:"description"`
}

APIStepVersion is the data structure for the JSON returned by the wercker API.

type DockerRepository

type DockerRepository struct {
	// Content is the compressed tarball. It is the caller's responsibility to
	// close Content.
	Content io.ReadCloser

	// Sha256 checksum of the compressed tarball.
	Sha256 string

	// Size of the compressed tarball.
	Size int64
}

DockerRepository represents the meta information of a downloadable docker repository. This is a tarball compressed using snappy-stream.

type GetBuildsOptions

type GetBuildsOptions struct {
	Sort   string `qs:"sort"`
	Limit  int    `qs:"limit"`
	Skip   int    `qs:"skip"`
	Commit string `qs:"commit"`
	Branch string `qs:"branch"`
	Status string `qs:"status"`
	Result string `qs:"result"`
	Stack  int    `qs:"stack"`
}

GetBuildsOptions are the optional parameters associated with GetBuilds

Jump to

Keyboard shortcuts

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