wercker

package module
v0.0.0-...-1d6befb Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2018 License: MIT Imports: 12 Imported by: 0

README

wercker api client

wercker status

go-wercker-api is the official wercker client for the wercker API.

Caution: Both the API and this client are under active development. This client may introduce breaking changes, so be sure to vendor in this client.

Usage

To start using this client, import this package and create a new client:

import "github.com/wercker/go-wercker-api"

client := wercker.NewClient(nil)

This will create a new client with the default config. If you want to override the default config, then you need to create a wercker.Config object and pass this wercker.NewClient:

import "github.com/wercker/go-wercker-api"

options := &wercker.Config{}
client := wercker.NewClient(options)

Authentication

The client uses a Provider to get the credentials for the user. By default it uses the following strategy:

  • Retrieve the token from the environment variable$WERCKER_TOKEN
  • Retrieve the token from file ~/.wercker/credentials
  • Fallback to anonymous user

If you retrieved your wercker token through other means, then you can use the credentials.Token method to create a static Provider:

import "github.com/wercker/go-wercker-api"
import "github.com/wercker/go-wercker-api/credentials"

token := "... your token ..."
options := &wercker.Config{Credentials: credentials.Token(token)}
client := wercker.NewClient(options)

More information

FAQ

...

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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 Application

type Application struct {
	ID        string       `json:"id"`
	URL       string       `json:"url"`
	Name      string       `json:"name"`
	Owner     *UnifiedUser `json:"owner"`
	Builds    string       `json:"builds"`
	Deploys   string       `json:"deploys"`
	SCM       *SCM         `json:"scm"`
	CreatedAt time.Time    `json:"createdAt"`
	UpdatedAt time.Time    `json:"updatedAt"`
	Privacy   string       `json:"privacy"`
	Stack     int          `json:"stack"`
}

Application is a detailed api representation

type ApplicationSummary

type ApplicationSummary struct {
	ID        string       `json:"id"`
	URL       string       `json:"url"`
	Name      string       `json:"name"`
	Owner     *UnifiedUser `json:"owner"`
	CreatedAt time.Time    `json:"createdAt"`
	UpdatedAt time.Time    `json:"updatedAt"`
	Privacy   string       `json:"privacy"`
	Stack     int          `json:"stack"`
}

ApplicationSummary is a summary api representation

type Build

type Build struct {
	ID          string              `json:"id"`
	URL         string              `json:"url"`
	Application *ApplicationSummary `json:"application"`
	Branch      string              `json:"branch"`
	CommitHash  string              `json:"commitHash"`
	CreatedAt   time.Time           `json:"createdAt"`
	EnvVars     []EnvVar            `json:"envVars"`
	FinishedAt  time.Time           `json:"finishedAt"`
	Message     string              `json:"message"`
	Progress    int                 `json:"progress"`
	Result      string              `json:"result"`
	StartedAt   time.Time           `json:"startedAt"`
	Status      string              `json:"status"`
}

Build is a detailed api representation

type BuildSummary

type BuildSummary struct {
	ID         string    `json:"id"`
	URL        string    `json:"url"`
	Branch     string    `json:"branch"`
	CommitHash string    `json:"commitHash"`
	CreatedAt  time.Time `json:"createdAt"`
	FinishedAt time.Time `json:"finishedAt"`
	Message    string    `json:"message"`
	Progress   int       `json:"progress"`
	Result     string    `json:"result"`
	StartedAt  time.Time `json:"startedAt"`
	Status     string    `json:"status"`
}

BuildSummary is a summary api representation

type Client

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

Client is the wercker api client.

func NewClient

func NewClient(config *Config) *Client

NewClient creates a new Client. It merges the default Config together with config.

func (*Client) CreateBuild

func (c *Client) CreateBuild(options *CreateBuildOptions) (*Build, error)

CreateBuild will trigger a new build.

func (*Client) CreateToken

func (c *Client) CreateToken(options *CreateTokenOptions) (*Token, error)

CreateToken creates a new Token.

func (*Client) DeleteToken

func (c *Client) DeleteToken(options *DeleteTokenOptions) error

DeleteToken deletes a token

func (*Client) Do

func (c *Client) Do(method string, urlTemplate *uritemplates.UriTemplate, urlModel interface{}, payload interface{}, result interface{}) error

Do makes a request to the wercker api servers.

func (*Client) GetApplication

func (c *Client) GetApplication(options *GetApplicationOptions) (*Application, error)

GetApplication will retrieve a single Application

func (*Client) GetApplications

func (c *Client) GetApplications(options *GetApplicationsOptions) ([]Application, error)

GetApplications will retrieve a list of Applications

func (*Client) GetBuild

func (c *Client) GetBuild(options *GetBuildOptions) (*Build, error)

GetBuild will retrieve a single Build

func (*Client) GetBuilds

func (c *Client) GetBuilds(options *GetBuildsOptions) ([]*BuildSummary, error)

GetBuilds fetches all builds for a certain application and optional filters.

func (*Client) GetDeploy

func (c *Client) GetDeploy(options *GetDeployOptions) (*Deploy, error)

GetDeploy will retrieve a single Deploy

func (*Client) GetDeploys

func (c *Client) GetDeploys(options *GetDeploysOptions) ([]*DeploySummary, error)

GetDeploys fetches all deploys for a certain application and optional filters.

func (*Client) GetToken

func (c *Client) GetToken(options *GetTokenOptions) (*Token, error)

GetToken retrieves a single Token.

func (*Client) GetTokens

func (c *Client) GetTokens(options *GetTokensOptions) ([]*TokenSummary, error)

GetTokens gets all tokens for the current user.

func (*Client) UpdateToken

func (c *Client) UpdateToken(options *UpdateTokenOptions) (*Token, error)

UpdateToken updates a Token.

type Config

type Config struct {
	Credentials credentials.Provider
	Endpoint    string
	HTTPClient  *http.Client
}

Config contains all configurable settings which will be used when making requests

func (*Config) Copy

func (o *Config) Copy() *Config

Copy will create a shallow copy of the Copy object

func (*Config) Merge

func (o *Config) Merge(config *Config) *Config

Merge creates a new shallow copy of o, and copies all non empty values from config to the copy. If config is nil, than o will be returned.

type CreateBuildOptions

type CreateBuildOptions struct {
	// Required
	ApplicationID string `json:"applicationId,omitempty"`

	// Optional
	Branch     string   `json:"branch,omitempty"`
	CommitHash string   `json:"commitHash,omitempty"`
	Message    string   `json:"message,omitempty"`
	EnvVars    []EnvVar `json:"envVars,omitempty"`
}

CreateBuildOptions are the options associated with Client.CreateBuild.

type CreateTokenOptions

type CreateTokenOptions struct {
	Name string `json:"name"`
}

CreateTokenOptions are the options associated with Client.CreateToken

type DeleteTokenOptions

type DeleteTokenOptions struct {
	TokenID string `map:"tokenId"`
}

DeleteTokenOptions are the options associated with Client.DeleteToken

type Deploy

type Deploy struct {
	ID          string              `json:"id"`
	URL         string              `json:"url"`
	Status      string              `json:"status"`
	Result      string              `json:"result"`
	CreatedAt   time.Time           `json:"createdAt"`
	FinishedAt  time.Time           `json:"finishedAt"`
	Progress    int                 `json:"progress"`
	Application *ApplicationSummary `json:"application"`
	Build       *BuildSummary       `json:"build"`
}

Deploy is a detailed api representation

type DeploySummary

type DeploySummary struct {
	ID         string    `json:"id"`
	URL        string    `json:"url"`
	Status     string    `json:"status"`
	Result     string    `json:"result"`
	CreatedAt  time.Time `json:"createdAt"`
	FinishedAt time.Time `json:"finishedAt"`
	Progress   int       `json:"progress"`
}

DeploySummary is a summary api representation

type EnvVar

type EnvVar struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

EnvVar represents a environment variable key value pair

type ErrResponse

type ErrResponse struct {
	StatusCode    int    `json:"statusCode"`
	StatusMessage string `json:"error"`
	Message       string `json:"message"`
}

ErrResponse is a generic error object using wercker api conventions.

func (*ErrResponse) Error

func (e *ErrResponse) Error() string

Error returns the wercker error message

type GetApplicationOptions

type GetApplicationOptions struct {
	// Required
	Owner string `map:"owner"`
	Name  string `map:"name"`
}

GetApplicationOptions are the options associated with Client.GetApplication

type GetApplicationsOptions

type GetApplicationsOptions struct {
	Limit string `map:"limit,omitempty"`
	Skip  int    `map:"skip,omitempty"`
	Sort  int    `map:"sort,omitempty"`
	Stack string `map:"stack,omitempty"`
}

GetApplicationsOptions are the options associated with Client.GetApplications

type GetBuildOptions

type GetBuildOptions struct {
	BuildID string `map:"buildId"`
}

GetBuildOptions are the options associated with Client.GetBuild

type GetBuildsOptions

type GetBuildsOptions struct {
	// Required
	Owner string `map:"owner"`
	Name  string `map:"name"`

	// Optional
	Branch string `map:"branch,omitempty"`
	Commit string `map:"commit,omitempty"`
	Limit  int    `map:"limit,omitempty"`
	Result string `map:"result,omitempty"`
	Skip   int    `map:"skip,omitempty"`
	Sort   string `map:"sort,omitempty"`
	Stack  string `map:"stack,omitempty"`
	Status string `map:"status,omitempty"`
}

GetBuildsOptions are the options associated with Client.GetBuilds.

type GetDeployOptions

type GetDeployOptions struct {
	DeployID string `map:"deployId"`
}

GetDeployOptions are the options associated with Client.GetDeploy

type GetDeploysOptions

type GetDeploysOptions struct {
	// Required
	Owner string `map:"owner"`
	Name  string `map:"name"`

	// Optional
	BuildID string `map:"buildId,omitempty"`
	Limit   int    `map:"limit,omitempty"`
	Result  string `map:"result,omitempty"`
	Skip    int    `map:"skip,omitempty"`
	Sort    string `map:"sort,omitempty"`
	Stack   string `map:"stack,omitempty"`
	Status  string `map:"status,omitempty"`
}

GetDeploysOptions are the options associated with Client.GetDeploys.

type GetTokenOptions

type GetTokenOptions struct {
	TokenID string `map:"tokenId"`
}

GetTokenOptions are the options associated with Client.GetToken

type GetTokensOptions

type GetTokensOptions struct {
}

GetTokensOptions are the options associated with Client.GetTokens

type SCM

type SCM struct {
	Type       string `json:"type"`
	Owner      string `json:"owner"`
	Repository string `json:"repository"`
}

SCM is a detailed source control manager api representation

type Token

type Token struct {
	ID             string     `json:"id"`
	URL            string     `json:"url"`
	Name           string     `json:"name"`
	Token          string     `json:"token"`
	HashedToken    string     `json:"hashedToken"`
	LastCharacters string     `json:"lastCharacters"`
	CreatedAt      *time.Time `json:"createdAt"`
	LastUsedAt     *time.Time `json:"lastUsedAt"`
}

Token is a detailed api representation

type TokenSummary

type TokenSummary struct {
	ID             string     `json:"id"`
	URL            string     `json:"url"`
	Name           string     `json:"name"`
	HashedToken    string     `json:"hashedToken"`
	LastCharacters string     `json:"lastCharacters"`
	CreatedAt      *time.Time `json:"createdAt"`
	LastUsedAt     *time.Time `json:"lastUsedAt"`
}

TokenSummary is a summary api representation

type UnifiedUser

type UnifiedUser struct {
	Type   string             `json:"type"`
	Name   string             `json:"name"`
	Avatar *UnifiedUserAvatar `json:"avatar"`
	UserID string             `json:"userId"`
	Meta   *UnifiedUserMeta   `json:"meta"`
}

UnifiedUser is a flexible user representation. Not all fields have to be set

type UnifiedUserAvatar

type UnifiedUserAvatar struct {
	Gravatar string `json:"gravatar"`
}

UnifiedUserAvatar is the avatar property of the UnifiedUser

type UnifiedUserMeta

type UnifiedUserMeta struct {
	Username        string `json:"username"`
	WerckerEmployee bool   `json:"werckerEmployee"`
}

UnifiedUserMeta is the meta property of the UnifiedUser

type UpdateTokenOptions

type UpdateTokenOptions struct {
	// Required
	TokenID string `map:"tokenId"`

	// Optional
	Name string `json:"name,omitempty"`
}

UpdateTokenOptions are the options associated with Client.UpdateToken

Directories

Path Synopsis
cmd
explorer command

Jump to

Keyboard shortcuts

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