v1

package
Version: v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package v1 Access to the API v1 of SemaphoreCI.

Reference: https://semaphoreci.com/docs/branches-and-builds-api.html

Index

Constants

View Source
const (
	Passed  = "passed"
	Failed  = "failed"
	Stopped = "stopped"
	Pending = "pending"
)

Build status

View Source
const (
	PostBuild  = "post_build"
	PostDeploy = "post_deploy"
	All        = "all"
)

hook type

Variables

This section is empty.

Functions

This section is empty.

Types

type Branch

type Branch struct {
	ID        int    `json:"id"`
	Name      string `json:"name"`
	BranchURL string `json:"branch_url"`
}

Branch a branch

type BranchHistory

type BranchHistory struct {
	BranchName       string  `json:"branch_name"`
	BranchURL        string  `json:"branch_url"`
	BranchStatusURL  string  `json:"branch_status_url"`
	BranchHistoryURL string  `json:"branch_history_url"`
	ProjectName      string  `json:"project_name"`
	Builds           []Build `json:"builds"`
}

BranchHistory a branch history

type BranchHistoryOptions

type BranchHistoryOptions struct {
	Page int
}

BranchHistoryOptions the branch history pagination options

type BranchStatus

type BranchStatus struct {
	BranchName       string     `json:"branch_name"`
	BranchURL        string     `json:"branch_url"`
	BranchStatusURL  string     `json:"branch_status_url"`
	BranchHistoryURL string     `json:"branch_history_url"`
	ProjectName      string     `json:"project_name"`
	BuildURL         string     `json:"build_url"`
	BuildInfoURL     string     `json:"build_info_url"`
	BuildNumber      int        `json:"build_number,omitempty"`
	Result           string     `json:"result"`
	StartedAt        *time.Time `json:"started_at"`
	FinishedAt       *time.Time `json:"finished_at"`
	Commit           Commit     `json:"commit"`
}

BranchStatus a branch status

type BranchesService

type BranchesService service

BranchesService https://semaphoreci.com/docs/branches-and-builds-api.html

func (*BranchesService) GetByProject

func (c *BranchesService) GetByProject(projectHashID string) ([]Branch, *Response, error)

GetByProject https://semaphoreci.com/docs/branches-and-builds-api.html#project_branches

func (*BranchesService) GetHistory

func (c *BranchesService) GetHistory(projectHashID string, branchID int, opts *BranchHistoryOptions) (*BranchHistory, *Response, error)

GetHistory https://semaphoreci.com/docs/branches-and-builds-api.html#branch_history

func (*BranchesService) GetStatus

func (c *BranchesService) GetStatus(projectHashID string, branchID int) (*BranchStatus, error)

GetStatus https://semaphoreci.com/docs/branches-and-builds-api.html#branch_status

type Build

type Build struct {
	BuildURL     string     `json:"build_url"`
	BuildInfoURL string     `json:"build_info_url"`
	BuildNumber  int        `json:"build_number"`
	Result       string     `json:"result"`
	StartedAt    *time.Time `json:"started_at"`
	FinishedAt   *time.Time `json:"finished_at"`
	Commit       Commit     `json:"commit"`
}

Build a build

type BuildInformation

type BuildInformation struct {
	Commits      []Commit   `json:"commits"`
	ProjectName  string     `json:"project_name"`
	BranchName   string     `json:"branch_name"`
	Number       int        `json:"number,omitempty"`
	Result       string     `json:"result"`
	CreatedAt    *time.Time `json:"created_at"`
	UpdatedAt    *time.Time `json:"updated_at"`
	StartedAt    *time.Time `json:"started_at"`
	FinishedAt   *time.Time `json:"finished_at"`
	HTMLURL      string     `json:"html_url"`
	BuildLogURL  string     `json:"build_log_url"`
	BuildInfoURL string     `json:"build_info_url"`
}

BuildInformation information about the build

type BuildLog

type BuildLog struct {
	Threads      []Thread `json:"threads"`
	BuildInfoURL string   `json:"build_info_url"`
}

BuildLog a build log

type BuildsService

type BuildsService service

BuildsService https://semaphoreci.com/docs/branches-and-builds-api.html

func (*BuildsService) DeployFromBuild

func (c *BuildsService) DeployFromBuild(projectHashID string, branchID int, number int, serverID int) (*ServerStatus, error)

DeployFromBuild https://semaphoreci.com/docs/branches-and-builds-api.html#deploy

func (*BuildsService) GetInformation

func (c *BuildsService) GetInformation(projectHashID string, branchID int, number int) (*BuildInformation, error)

GetInformation https://semaphoreci.com/docs/branches-and-builds-api.html#build_information

func (*BuildsService) GetLog

func (c *BuildsService) GetLog(projectHashID string, branchID int, number int) (*BuildLog, error)

GetLog https://semaphoreci.com/docs/branches-and-builds-api.html#build_log

func (*BuildsService) Launch added in v1.2.0

func (c *BuildsService) Launch(projectHashID string, branchID int, commitSHA string) (*BuildInformation, error)

Launch https://semaphoreci.com/docs/branches-and-builds-api.html#launch_build

func (*BuildsService) RebuildLastRevision

func (c *BuildsService) RebuildLastRevision(projectHashID string, branchID int) (*BuildInformation, error)

RebuildLastRevision https://semaphoreci.com/docs/branches-and-builds-api.html#rebuild

func (*BuildsService) Stop

func (c *BuildsService) Stop(projectHashID string, branchID int, number int) (*BuildInformation, error)

Stop https://semaphoreci.com/docs/branches-and-builds-api.html#stop

type Client

type Client struct {
	BaseURL   *url.URL
	UserAgent string

	Branch   *BranchesService
	Builds   *BuildsService
	Projects *ProjectsService
	Servers  *ServersService
	Deploys  *DeploysService
	WebHooks *WebHooksService
	// contains filtered or unexported fields
}

Client API v1 client

func NewClient

func NewClient(httpClient *http.Client) *Client

NewClient create a new API v1 client

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}) (*Response, error)

Do execute a request

func (*Client) NewRequest

func (c *Client) NewRequest(method, urlStr string, body io.Reader) (*http.Request, error)

NewRequest creates a request

type Command

type Command struct {
	Name       string     `json:"name"`
	Result     string     `json:"result"`
	Output     string     `json:"output"`
	StartTime  *time.Time `json:"start_time"`
	FinishTime *time.Time `json:"finish_time"`
	Duration   string     `json:"duration"`
}

Command a command

type Commit

type Commit struct {
	ID          string     `json:"id"`
	URL         string     `json:"url"`
	AuthorName  string     `json:"author_name"`
	AuthorEmail string     `json:"author_email"`
	Message     string     `json:"message"`
	Timestamp   *time.Time `json:"timestamp" `
}

Commit a commit

type Deploy

type Deploy struct {
	ProjectName  string     `json:"project_name"`
	ServerName   string     `json:"server_name"`
	Number       int        `json:"number"`
	Result       string     `json:"result"`
	CreatedAt    *time.Time `json:"created_at"`
	UpdatedAt    *time.Time `json:"updated_at"`
	StartedAt    *time.Time `json:"started_at"`
	FinishedAt   *time.Time `json:"finished_at"`
	HTMLURL      string     `json:"html_url"`
	DeployURL    string     `json:"deploy_url"`
	DeployLogURL string     `json:"deploy_log_url"`
	BuildURL     string     `json:"build_url"`
	BuildHTMLURL string     `json:"build_html_url"`
	Commit       *Commit    `json:"commit"`
}

Deploy a deploy

type DeployLog added in v1.2.0

type DeployLog struct {
	Threads       []Thread `json:"threads"`
	DeployInfoURL string   `json:"deploy_info_url"`
}

DeployLog a deploy log

type DeploysService added in v1.2.0

type DeploysService service

DeploysService https://semaphoreci.com/docs/servers-and-deploys-api.html

func (*DeploysService) GetInformation added in v1.2.0

func (c *DeploysService) GetInformation(projectHashID string, serverID int, number int) (*Deploy, *Response, error)

GetInformation https://semaphoreci.com/docs/servers-and-deploys-api.html#deploy_information

func (*DeploysService) GetLog added in v1.2.0

func (c *DeploysService) GetLog(projectHashID string, serverID int, number int) (*DeployLog, error)

GetLog https://semaphoreci.com/docs/servers-and-deploys-api.html#deploy_log

func (*DeploysService) Stop added in v1.2.0

func (c *DeploysService) Stop(projectHashID string, serverID int, number int) (*Deploy, *Response, error)

Stop https://semaphoreci.com/docs/servers-and-deploys-api.html#stop

type ErrorResponse

type ErrorResponse struct {
	Response *http.Response `json:"-"`     // HTTP response that caused this error
	Message  string         `json:"error"` // error message
}

ErrorResponse API error response

func (*ErrorResponse) Error

func (e *ErrorResponse) Error() string

type Pagination

type Pagination struct {
	TotalEntries int  `json:"total_entries,omitempty"`
	TotalPages   int  `json:"total_pages,omitempty"`
	PerPage      int  `json:"per_page,omitempty"`
	CurrentPage  int  `json:"current_page,omitempty"`
	FirstPage    bool `json:"first_page"`
	LastPage     bool `json:"last_page"`
	NextPage     int  `json:"next_page,omitempty"`
	PreviousPage int  `json:"previous_page,omitempty"`
}

Pagination Pagination headers

type Project

type Project struct {
	ID        int             `json:"id"`
	HashID    string          `json:"hash_id"`
	Name      string          `json:"name"`
	Owner     string          `json:"owner"`
	HTMLURL   string          `json:"html_url"`
	CreatedAt *time.Time      `json:"created_at"`
	UpdatedAt *time.Time      `json:"updated_at"`
	Branches  []ProjectBranch `json:"branches"`
	Servers   []ServerStatus  `json:"servers"`
}

Project a project

type ProjectBranch added in v1.1.1

type ProjectBranch struct {
	Name         string     `json:"branch_name"`
	URL          string     `json:"branch_url"`
	StatusURL    string     `json:"branch_status_url"`
	HistoryURL   string     `json:"branch_history_url"`
	ProjectName  string     `json:"project_name"`
	BuildURL     string     `json:"build_url"`
	BuildInfoURL string     `json:"build_info_url"`
	BuildNumber  int        `json:"build_number"`
	Result       string     `json:"result"`
	StartedAt    *time.Time `json:"started_at"`
	FinishedAt   *time.Time `json:"finished_at"`
}

ProjectBranch a branch in project

type ProjectsService

type ProjectsService service

ProjectsService https://semaphoreci.com/docs/projects-api.html

func (*ProjectsService) Get

func (c *ProjectsService) Get() ([]Project, *Response, error)

Get https://semaphoreci.com/docs/projects-api.html#

type Response

type Response struct {
	*http.Response
	*Pagination
}

Response API response

type Server

type Server struct {
	ID        int    `json:"id"`
	Name      string `json:"name"`
	ServerURL string `json:"server_url"`
}

Server a server

type ServerDeploy

type ServerDeploy struct {
	ServerName       string   `json:"server_name"`
	ServerURL        string   `json:"server_url"`
	ServerStatusURL  string   `json:"server_status_url"`
	ServerHistoryURL string   `json:"server_history_url"`
	DeploymentMethod string   `json:"deployment_method"`
	Strategy         string   `json:"strategy"`
	BranchName       string   `json:"branch_name"`
	ProjectName      string   `json:"project_name"`
	Deploys          []Deploy `json:"deploys"`
}

ServerDeploy a server deploy

type ServerHistoryOptions added in v1.2.0

type ServerHistoryOptions struct {
	Page int
}

ServerHistoryOptions the server history pagination options

type ServerStatus

type ServerStatus struct {
	ServerName       string     `json:"server_name"`
	ServerURL        string     `json:"server_url"`
	ServerStatusURL  string     `json:"server_status_url"`
	ServerHistoryURL string     `json:"server_history_url"`
	DeploymentMethod string     `json:"deployment_method"`
	Strategy         string     `json:"strategy"`
	BranchName       string     `json:"branch_name"`
	ProjectName      string     `json:"project_name"`
	Number           int        `json:"number"`
	Result           string     `json:"result"`
	CreatedAt        *time.Time `json:"created_at"`
	UpdatedAt        *time.Time `json:"updated_at"`
	StartedAt        *time.Time `json:"started_at"`
	FinishedAt       *time.Time `json:"finished_at"`
	HTMLURL          string     `json:"html_url"`
	DeployURL        string     `json:"deploy_url"`
	DeployLogURL     string     `json:"deploy_log_url"`
	BuildURL         string     `json:"build_url"`
	BuildHTMLURL     string     `json:"build_html_url"`
	Commit           *Commit    `json:"commit"`
}

ServerStatus a server

type ServersService

type ServersService service

ServersService https://semaphoreci.com/docs/servers-and-deploys-api.html

func (*ServersService) GetByProject

func (c *ServersService) GetByProject(projectHashID string) ([]Server, *Response, error)

GetByProject https://semaphoreci.com/docs/servers-and-deploys-api.html#project_servers

func (*ServersService) GetHistory

func (c *ServersService) GetHistory(projectHashID string, serverID int, opts *ServerHistoryOptions) (*ServerDeploy, *Response, error)

GetHistory https://semaphoreci.com/docs/servers-and-deploys-api.html#server_history

func (*ServersService) GetStatus

func (c *ServersService) GetStatus(projectHashID string, serverID int) (*ServerStatus, error)

GetStatus https://semaphoreci.com/docs/servers-and-deploys-api.html#server_status

type Thread

type Thread struct {
	Number   int       `json:"number"`
	Commands []Command `json:"commands"`
}

Thread a thread

type TokenTransport added in v1.1.0

type TokenTransport struct {
	Token string

	// Transport is the underlying HTTP transport to use when making requests.
	// It will default to http.DefaultTransport if nil.
	Transport http.RoundTripper
}

TokenTransport HTTP transport for API authentication

func (*TokenTransport) Client added in v1.1.0

func (t *TokenTransport) Client() *http.Client

Client Creates a new HTTP client

func (*TokenTransport) RoundTrip added in v1.1.0

func (t *TokenTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip executes a single HTTP transaction

type WebHook added in v1.2.0

type WebHook struct {
	ID       int    `json:"id,omitempty"`
	URL      string `json:"url"`
	HookType string `json:"hook_type"`
}

WebHook a WebHook

type WebHooksService added in v1.2.0

type WebHooksService service

WebHooksService https://semaphoreci.com/docs/webhooks-api.html

func (*WebHooksService) Create added in v1.2.0

func (c *WebHooksService) Create(projectHashID string, hook WebHook) (*WebHook, *Response, error)

Create https://semaphoreci.com/docs/webhooks-api.html#create_hook

func (*WebHooksService) Delete added in v1.2.0

func (c *WebHooksService) Delete(projectHashID string, webHookID int) (*Response, error)

Delete https://semaphoreci.com/docs/webhooks-api.html#delete_hook

func (*WebHooksService) GetByProject added in v1.2.0

func (c *WebHooksService) GetByProject(projectHashID string) ([]WebHook, *Response, error)

GetByProject https://semaphoreci.com/docs/webhooks-api.html#list_hooks

func (*WebHooksService) Update added in v1.2.0

func (c *WebHooksService) Update(projectHashID string, webHookID int, hook WebHook) (*WebHook, *Response, error)

Update https://semaphoreci.com/docs/webhooks-api.html#update_hook

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL