travis

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

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

Go to latest
Published: Jan 18, 2019 License: BSD-3-Clause Imports: 13 Imported by: 8

README

This Repository is Unmaintained

This repository is currently unmaintained, please do not use it for new projects. You may be interested in @shuheiktgw's fork, which has been updated to use the Travis v3 API. It is available here: https://github.com/shuheiktgw/go-travis.

go-travis

go-travis is a Go client library for accessing the Travis CI API.

Documentation: GoDoc

go-travis requires Go version 1.1 or greater.

Dive

import (
    "log"
    travis "github.com/Ableton/go-travis"
)

client := travis.NewDefaultClient("")
builds, _, _, resp, err := client.Builds.ListFromRepository("Ableton/go-travis", nil)
if err != nil {
    log.Fatal(err)
}

// Now do something with the builds

Installation

$ go get github.com/Ableton/go-travis

Usage

Interaction with the Travis CI API is done through a Client instance.

import travis "github.com/Ableton/go-travis"

client := travis.NewClient(travis.TRAVIS_API_DEFAULT_URL, "asuperdupertoken")

Constructing it with the NewClient helper requires two arguments:

  • The Travis CI API URL you wish to communicate with. Different Travis CI plans are accessed through different URLs. go-travis exposes constants for these URLs:
    • TRAVIS_API_DEFAULT_URL: default api.travis-ci.org endpoint for the free Travis "Open Source" plan.
    • TRAVIS_API_PRO_URL: the api.travis-ci.com endpoint for the paid Travis pro plans.
  • A Travis CI token with which to authenticate. If you wish to run requests unauthenticated, pass an empty string. It is possible at any time to authenticate the Client instance with a Travis token or a Github token. For more information see Authentication.
Services oriented design

The Client instance's Service attributes provide access to Travis CI API resources.

opt := &travis.BuildListOptions{EventType: "pull request"}
builds, response, err := client.Builds.ListFromRepository("mygithubuser/mygithubrepo", opt)
if err != nil {
        log.Fatal(err)
}

Non exhaustive list of implemented services:

  • Authentication
  • Branches
  • Builds
  • Commits
  • Jobs
  • Logs
  • Repositories
  • Requests
  • Users

(For an up to date exhaustive list, please check out the documentation)

Nota: Service methods will often take an Option (sub-)type instance as input. These types, like BuildListOptions allow narrowing and filtering your requests.

Authentication

The Client instance supports both authenticated and unauthenticated interaction with the Travis CI API. Note that both Pro and Enterprise plans will require almost all API calls to be authenticated.

Unuathenticated

It is possible to use the client unauthenticated. However some resources won't be accesible.

unauthClient := travis.NewClient(travis.TRAVIS_API_DEFAULT_URL, "")
builds, _, _, resp, err := unauthClient.Builds.ListFromRepository("mygithubuser/myopensourceproject", nil)
// Do something with your builds

_, err := unauthClient.Jobs.Cancel(12345)
if err != nil {
        // This operation is unavailable in unauthenticated mode and will
        // throw an error.
}
Authenticated

The Client instance supports authentication with both Travis token and Github token.

authClient := travis.NewClient(travis.TRAVIS_API_DEFAULT_URL, "mytravistoken")
builds, _, _, resp, err := authClient.Builds.ListFromRepository("mygithubuser/myopensourceproject",
nil)
// Do something with your builds

_, err := unauthClient.Jobs.Cancel(12345)
// Your job is succesfully canceled

However, authentication with a Github token will require and extra step (and request).

authWithGithubClient := travis.NewClient(travis.TRAVIS_API_DEFAULT_URL, "")
// authWithGithubClient.IsAuthenticated() will return false

err := authWithGithubClient.Authentication.UsingGithubToken("mygithubtoken")
if err != nil {
        log.Fatal(err)
}
// authWithGithubClient.IsAuthenticated()  will return true

builds, _, _, resp, err := authClient.Builds.ListFromRepository("mygithubuser/myopensourceproject",
nil)
// Do something with your builds
Pagination

The services support resource pagination through the ListOption type. Every services Option type implements the ListOption type.

client := travis.NewClient(travis.TRAVIS_API_DEFAULT_URL, "mysuperdupertoken")
opt := &travis.BuildListOptions{}

for {
        travisBuilds, _, _, _, err := tc.Builds.ListFromRepository(target, opt)
        if err != nil {
                log.Fatal(err)
        }

        // Do something with the builds

        opt.GetNextPage(travisBuilds)
        if opt.AfterNumber <= 1 {  // Travis CI resources are one-indexed (not zero-indexed)
                break
        }
}

Disclaimer

This library design is heavily inspired from the amazing Google's go-github library. Some pieces of code have been directly extracted from there too. Therefore any obvious similarities would not be adventitious.

License

This library is distributed under the BSD-style license found in the LICENSE file.

Documentation

Overview

go-travis is a Go client library for accessing the Travis CI API.

Installation

go-travis requires Go version 1.1 or greater.

$ go get github.com/Ableton/go-travis

Usage

Interaction with the Travis CI API is done through a Client instance.

import travis "github.com/AbletonAppDev/go-travis"
client := travis.NewClient(travis.TRAVIS_API_DEFAULT_URL, "AQFvXR7r88s2Db5-dMYo3g")

Constructing it with the NewClient helper requires two arguments:

First, the Travis CI API URL you wish to communicate with. Different Travis CI plans are accessed through different URLs. go-travis exposes constants for these URLs:

TRAVIS_API_DEFAULT_URL -> default api.travis-ci.org endpoint for the free Travis "Open Source" plan.
TRAVIS_API_PRO_URL -> the api.travis-ci.com endpoint for the paid Travis pro plans.

Second, a Travis CI token with which to authenticate. If you wish to run requests unauthenticated, pass an empty string. It is possible at any time to authenticate the Client instance with a Travis token or a Github token. For more information see [Authentication]().

Services

The Client instance's Service attributes provide access to Travis CI API resources.

opt := &travis.BuildListOptions{EventType: "pull request"}
builds, response, err := client.Builds.ListFromRepository("mygithubuser/mygithubrepo", opt)
if err != nil {
            log.Fatal(err)
}

Service methods will often take an Option (sub-)type instance as input. These types, like BuildListOptions allow narrowing and filtering your requests.

Authentication

The Client instance supports both authenticated and unauthenticated interactions with the Travis CI API. Note that both Pro and Enterprise will require almost all API calls to be authenticated.

It is possible to use the client unauthenticated. However some resources won't be accesible.

unauthClient := travis.NewClient(travis.TRAVIS_API_DEFAULT_URL, "")
builds, _, _, resp, err :=
unauthClient.Builds.ListFromRepository("mygithubuser/myopensourceproject", nil)
// Do something with your builds

_, err := unauthClient.Jobs.Cancel(12345)
if err != nil {
            // This operation is unavailable in unauthenticated mode and will
                    // throw an error at you.
}

The Client instance supports authentication with both Travis token and Github token.

authClient := travis.NewClient(travis.TRAVIS_API_DEFAULT_URL, "mytravistoken")
builds, _, _, resp, err := authClient.Builds.ListFromRepository("mygithubuser/myopensourceproject",
nil)
// Do something with your builds

_, err := unauthClient.Jobs.Cancel(12345)
// Your job is succesfully canceled

However, authentication with a Github token will require and extra step (and request).

authWithGithubClient := travis.NewClient(travis.TRAVIS_API_DEFAULT_URL, "")
// authWithGithubClient.IsAuthenticated() will return false

err := authWithGithubClient.Authentication.UsingGithubToken("mygithubtoken")
if err != nil {
            log.Fatal(err)
}
// authWithGithubClient.IsAuthenticated()  will return true

builds, _, _, resp, err := authClient.Builds.ListFromRepository("mygithubuser/myopensourceproject",
nil)
// Do something with your builds

Pagination

The services support resource pagination through the ListOption type. Every services `Option` type implements the ListOption type.

client := travis.NewClient(travis.TRAVIS_API_DEFAULT_URL, "mysuperdupertoken")
opt := &travis.BuildListOptions{}

for {
        travisBuilds, _, _, _, err := tc.Builds.ListFromRepository(target, opt)
        if err != nil {
                log.Fatal(err)
        }

        // Do something with the builds

        opt.GetNextPage(travisBuilds)
        if opt.AfterNumber <= 1 {  // Travis CI resources are one-indexed (not zero-indexed)
                break
        }
}

Index

Constants

View Source
const (
	TRAVIS_USER_AGENT string = "go-travis/1.0.0"

	TRAVIS_REQUEST_ACCEPT_HEADER string = "application/vnd.travis-ci.2+json"
	TRAVIS_REQUEST_CONTENT_TYPE  string = "application/json"

	TRAVIS_API_DEFAULT_URL string = "https://api.travis-ci.org/"
	TRAVIS_API_PRO_URL     string = "https://api.travis-ci.com/"

	TRAVIS_RESPONSE_PER_PAGE uint64 = 25
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessToken

type AccessToken string

type AuthenticationService

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

BuildsService handles communication with the builds related methods of the Travis CI API.

func (*AuthenticationService) UsingGithubToken

func (as *AuthenticationService) UsingGithubToken(githubToken string) (AccessToken, *http.Response, error)

UsingGithubToken will generate a Travis CI API authentication token and call the UsingTravisToken method with it, leaving your client authenticated and ready to use.

func (*AuthenticationService) UsingTravisToken

func (as *AuthenticationService) UsingTravisToken(travisToken string) error

UsingTravisToken will format and write provided travisToken in the AuthenticationService client's headers.

type Branch

type Branch struct {
	Id           uint   `json:"id,omitempty"`
	RepositoryId uint   `json:"repository_id,omitempty"`
	CommitId     uint   `json:"commit_id,omitempty"`
	Number       string `json:"number,omitempty"`
	// Config       Config `json:"config,omitempty"`
	State       string `json:"state,omitempty"`
	StartedAt   string `json:"started_at,omitempty"`
	FinishedAt  string `json:"finished_at,omitempty"`
	Duration    uint   `json:"duration,omitempty"`
	JobIds      []uint `json:"job_ids,omitempty"`
	PullRequest bool   `json:"pull_request,omitempty"`
}

Branch represents a Travis CI build

type BranchesService

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

BranchesService handles communication with the branches related methods of the Travis CI API.

func (*BranchesService) Get

func (bs *BranchesService) Get(repoSlug string, branchId uint) (*Branch, *http.Response, error)

Get fetches a branch based on the provided repository slug and it's id.

Travis CI API docs: http://docs.travis-ci.com/api/#builds

func (*BranchesService) GetFromSlug

func (bs *BranchesService) GetFromSlug(repoSlug string, branchSlug string) (*Branch, *http.Response, error)

Get fetches a branch based on the provided repository slug and its name.

Travis CI API docs: http://docs.travis-ci.com/api/#builds

func (*BranchesService) ListFromRepository

func (bs *BranchesService) ListFromRepository(slug string) ([]Branch, *http.Response, error)

List the branches of a given repository.

Travis CI API docs: http://docs.travis-ci.com/api/#builds

type Build

type Build struct {
	Id           uint   `json:"id,omitempty"`
	RepositoryId uint   `json:"repository_id,omitempty"`
	Slug         string `json:"slug,omitempty"`
	CommitId     uint   `json:"commit_id,omitempty"`
	Number       string `json:"number,omitempty"`
	// Config            Config `json:"config,omitempty"`
	PullRequest       bool   `json:"pull_request,omitempty"`
	PullRequestTitle  string `json:"pull_request_title,omitempty"`
	PullRequestNumber uint   `json:"pull_request_number,omitempty"`
	State             string `json:"state,omitempty"`
	StartedAt         string `json:"started_at,omitempty"`
	FinishedAt        string `json:"finished_at,omitempty"`
	Duration          uint   `json:"duration,omitempty"`
	JobIds            []uint `json:"job_ids,omitempty"`
	AfterNumber       uint   `json:"after_number,omitempty"`
	EventType         string `json:"event_type,omitempty"`
}

Build represents a Travis CI build

type BuildListOptions

type BuildListOptions struct {
	ListOptions

	Ids          []uint `url:"ids,omitempty"`
	RepositoryId uint   `url:"repository_id,omitempty"`
	Slug         string `url:"slug,omitempty"`
	Number       string `url:"number,omitempty"`
	EventType    string `url:"event_type,omitempty"`
}

BuildListOptions specifies the optional parameters to the BuildsService.List method.

type BuildsService

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

BuildsService handles communication with the builds related methods of the Travis CI API.

func (*BuildsService) Cancel

func (bs *BuildsService) Cancel(id uint) (*http.Response, error)

Cancel build with the provided id.

Travis CI API docs: http://docs.travis-ci.com/api/#builds

func (*BuildsService) Get

func (bs *BuildsService) Get(id uint) (*Build, []Job, *Commit, *http.Response, error)

Get fetches a build based on the provided id.

Travis CI API docs: http://docs.travis-ci.com/api/#builds

func (*BuildsService) List

func (bs *BuildsService) List(opt *BuildListOptions) ([]Build, []Job, []Commit, *http.Response, error)

List the builds for the authenticated user.

Travis CI API docs: http://docs.travis-ci.com/api/#builds

func (*BuildsService) ListFromRepository

func (bs *BuildsService) ListFromRepository(slug string, opt *BuildListOptions) ([]Build, []Job, []Commit, *http.Response, error)

List a repository builds based on it's provided slug.

Travis CI API docs: http://docs.travis-ci.com/api/#builds

func (*BuildsService) Restart

func (bs *BuildsService) Restart(id uint) (*http.Response, error)

Restart build with the provided id.

Travis CI API docs: http://docs.travis-ci.com/api/#builds

type Client

type Client struct {

	// Headers to attach to every requests made with the client.
	// As a default, Headers will be used to provide Travis API authentication
	// token and other necessary headers.
	// However these could be updated per-request through a parameters.
	Headers map[string]string

	// Base URL for api requests. Defaults to the public Travis API, but
	// can be set to an alternative endpoint to use with Travis Pro or Enterprise.
	// BaseURL should alway be terminated by a slash.
	BaseURL *url.URL

	// User agent used when communicating with the Travis API
	UserAgent string

	// Services used to manipulate API entities
	Authentication *AuthenticationService
	Repositories   *RepositoriesService
	Builds         *BuildsService
	Jobs           *JobsService
	Branches       *BranchesService
	Logs           *LogsService
	Commits        *CommitsService
	Requests       *RequestsService
	Users          *UsersService
	// contains filtered or unexported fields
}

A Client manages communication with the Travis CI API.

func NewClient

func NewClient(baseUrl string, travisToken string) *Client

NewClient returns a new Travis API client. If travisToken is not provided, the client can be authenticated at any time, using it's Authentication exposed service.

func NewDefaultClient

func NewDefaultClient(travisToken string) *Client

NewDefaultClient returns a new Travis API client bound to the public travis API. If travisToken is not provided, the client can be authenticated at any time, using it's Authentication exposed service.

func (*Client) Do

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

Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response body will be written to v, without attempting to first decode it.

func (*Client) IsAuthenticated

func (c *Client) IsAuthenticated() bool

IsAuthenticated indicates if Authorization headers were found in Client.Headers mapping.

func (*Client) NewRequest

func (c *Client) NewRequest(method, urlStr string, body interface{}, headers map[string]string) (*http.Request, error)

NewRequest creates an API request. A relative URL can be provided in urlStr, in which case it is resolved relative to the BaseURL of the Client. Relative URLs should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included as the request body. If specified, the map provided by headers will be used to udate request headers.

type Commit

type Commit struct {
	Id             uint   `json:"id,omitempty"`
	Sha            string `json:"sha,omitempty"`
	Branch         string `json:"branch,omitempty"`
	Message        string `json:"message,omitempty"`
	CommittedAt    string `json:"committed_at,omitempty"`
	AuthorName     string `json:"author_name,omitempty"`
	AuthorEmail    string `json:"author_email,omitempty"`
	CommitterName  string `json:"committer_name,omitempty"`
	CommitterEmail string `json:"committer_email,omitempty"`
	CompareUrl     string `json:"compare_url,omitempty"`
}

Commit represents a VCS commit as seen by Travis CI

type CommitsService

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

CommitsService handles communication with the commits related parts of the Travis CI API. As commits are not directly exposed as an endpoint, most of this service methods will fetch commits through the builds or jobs endpoint.

func (*CommitsService) GetFromBuild

func (cs *CommitsService) GetFromBuild(buildId uint) (*Commit, *http.Response, error)

Get fetches the commit that triggered a build based on the build id.

Travis CI API docs: http://docs.travis-ci.com/api/#builds

func (*CommitsService) ListFromRepository

func (cs *CommitsService) ListFromRepository(repositorySlug string) ([]Commit, *http.Response, error)

List last commits attached to a repository builds.

Travis CI API docs: http://docs.travis-ci.com/api/#builds

type Config

type Config struct {
	Os            string              `json:"os,omitempty"`
	Language      string              `json:"language,omitempty"`
	Branches      map[string][]string `json:"branches,omitemtpy"`
	BeforeScript  []string            `json:"before_script,omitempty"`
	Script        []string            `json:"script,omitempty"`
	AfterScript   []string            `json:"after_script,omitempty"`
	BeforeInstall []string            `json:"before_install,omitempty"`
	Install       []string            `json:"install,omitempty"`
	AfterSuccess  []string            `json:"after_success,omitempty"`
	AfterFailure  []string            `json:"after_failure,omitempty"`
	Addons        map[string]string   `json:"addons,omitempty"`
	Notifications NotificationMap     `json:"notifications,omitempty"`
}

Config represents a Travis CI build config

As the endpoints responses fields can change types according to the request, it is not possible to represent them easily in a statically language like go. Therefore Its implementation is purposedly left in an incomplete and very limited state.

type ErrorResponse

type ErrorResponse struct {
	// HTTP response that caused this error
	Response *http.Response

	// Error message produced by Travis API
	Message string `json:"error"`
}

ErrorResponse reports an error caused by an API request. ErrorResponse implemented the Error interface.

func (*ErrorResponse) Error

func (er *ErrorResponse) Error() string

type Job

type Job struct {
	Id           uint   `json:"id,omitempty"`
	BuildId      uint   `json:"build_id,omitempty"`
	RepositoryId uint   `json:"repository_id,omitempty"`
	CommitId     uint   `json:"commit_id,omitempty"`
	LogId        uint   `json:"log_id,omitempty"`
	Number       string `json:"number,omitempty"`
	// Config        Config `json:"config,omitempty"`
	State         string `json:"state,omitempty"`
	StartedAt     string `json:"started_at,omitempty"`
	FinishedAt    string `json:"finished_at,omitempty"`
	Duration      uint   `json:"duration,omitempty"`
	Queue         string `json:"queue,omitempty"`
	AllowFailure  bool   `json:"allow_failure,omitempty"`
	AnnotationIds []uint `json:"annotation_ids,omitempty"`
}

Job represents a Travis CI job

type JobFindOptions

type JobFindOptions struct {
	ListOptions

	// List of job ids
	Ids []uint `url:"ids,omitempty"`

	// Job state to filter by
	State string `url:"state,omitempty"`

	// Job queue to filter by
	Queue string `url:"queue,omitempty"`
}

JobListOptions specifies the optional parameters to the JobsService.List method. You need to provide exactly one of the below attribute. If you provide State or Queue, a maximum of 250 jobs will be returned.

func (*JobFindOptions) IsValid

func (jfo *JobFindOptions) IsValid() bool

IsValid asserts the JobFindOptions instance has one and only one value set to a non-zero value.

This method is particularly useful to check a JobFindOptions instance before passing it to JobsService.Find method.

type JobsService

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

JobsService handles communication with the jobs related methods of the Travis CI API.

func (*JobsService) Cancel

func (js *JobsService) Cancel(id uint) (*http.Response, error)

Cancel job with the provided id.

Travis CI API docs: http://docs.travis-ci.com/api/#jobs

func (*JobsService) Find

func (js *JobsService) Find(opt *JobFindOptions) ([]Job, *http.Response, error)

Find jobs using the provided options. You need to provide exactly one of the opt fields value. If you provide State or Queue, a maximum of 250 jobs will be returned.

Travis CI API docs: http://docs.travis-ci.com/api/#jobs

func (*JobsService) Get

func (js *JobsService) Get(id uint) (*Job, *http.Response, error)

Get fetches job with the provided id.

Travis CI API docs: http://docs.travis-ci.com/api/#jobs

func (*JobsService) ListFromBuild

func (js *JobsService) ListFromBuild(buildId uint) ([]Job, *http.Response, error)

ListByBuild retrieve a build jobs from its provided id.

Travis CI API docs: http://docs.travis-ci.com/api/#jobs

func (*JobsService) Restart

func (js *JobsService) Restart(id uint) (*http.Response, error)

Restart job with the provided id.

Travis CI API docs: http://docs.travis-ci.com/api/#jobs

type ListOptions

type ListOptions struct {
	AfterNumber uint `url:"after_number,omitempty"`
}

func (*ListOptions) GetNextPage

func (into *ListOptions) GetNextPage(from interface{}) error

GetNextPage provided a collection of resources (Builds or Jobs), will update the ListOptions to fetch the next resource page on next call.

type Log

type Log struct {
	Id    uint   `json:"id,omitempty"`
	JobId uint   `json:"job_id,omitempty"`
	Type  string `json:"type,omitempty"`
	Body  string `json:"body,omitempty"`
}

Log represents a Travis CI job log

type LogsService

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

LogssService handles communication with the logs related methods of the Travis CI API.

func (*LogsService) Get

func (ls *LogsService) Get(logId uint) (*Log, *http.Response, error)

Get fetches a log based on the provided id.

Travis CI API docs: http://docs.travis-ci.com/api/#logs

func (*LogsService) GetByJob

func (ls *LogsService) GetByJob(jobId uint) (*Log, *http.Response, error)

Get a job's log based on it's provided id.

Travis CI API docs: http://docs.travis-ci.com/api/#logs

type NotificationMap

type NotificationMap map[string]map[string]string

type Paginator

type Paginator interface {
	GetNextPage(interface{}) error
}

type RepositoriesService

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

RepositoriesService handles communication with the builds related methods of the Travis CI API.

func (*RepositoriesService) Find

Find repositories using the provided options. If no options are provided, a list of repositories with recent activity for the authenticated user is returned.

Travis CI API docs: http://docs.travis-ci.com/api/#repositories

func (*RepositoriesService) Get

Get fetches a repository based on the provided id.

Travis CI API docs: http://docs.travis-ci.com/api/#repositories

func (*RepositoriesService) GetFromSlug

func (rs *RepositoriesService) GetFromSlug(slug string) (*Repository, *http.Response, error)

GetBySlug fetches a repository based on the provided slug.

Travis CI API docs: http://docs.travis-ci.com/api/#repositories

type Repository

type Repository struct {
	Id                  uint   `json:"id"`
	Slug                string `json:"slug"`
	Description         string `json:"description"`
	LastBuildId         uint   `json:"last_build_id"`
	LastBuildNumber     string `json:"last_build_number"`
	LastBuildState      string `json:"last_build_state"`
	LastBuildDuration   uint   `json:"last_build_duration"`
	LastBuildStartedAt  string `json:"last_build_started_at"`
	LastBuildFinishedAt string `json:"last_build_finished_at"`
	GithubLanguage      string `json:"github_language"`
}

Repository represents a Travis CI repository

type RepositoryListOptions

type RepositoryListOptions struct {
	// list of repository ids to fetch, cannot be combined with other parameters
	Ids []uint `url:"ids,omitempty"`

	// filter by user that has access to it (github login)
	Member string `url:"member,omitempty"`

	// filter by owner name (first segment of slug)
	OwnerName string `url:"owner_name,omitempty"`

	// filter by slug
	Slug string `url:"slug,omitempty"`

	// filter by search term
	Search string `url:"search,omitempty"`

	// if true, will only return repositories that are enabled
	Active bool `url:"active,omitempty"`
}

RepositoryListOptions specifies the optional parameters to the RepositoriesService.Findmethod.

type Request

type Request struct {
	Id           uint   `json:"id,omitempty"`
	RepositoryId uint   `json:"repository_id,omitempty"`
	CommitId     uint   `json:"commit_id,omitempty"`
	CreatedAt    string `json:"created_at,omitempty"`
	OwnerId      uint   `json:"owner_id"`
	OwnerType    string `json:"owner_type,omitempty"`
	EventType    string `json:"event_type,omitempty"`
	Result       string `json:"result,omitempty"`
	PullRequest  bool   `json:"pull_request,omitempty"`
	Branch       string `json:"branch,omitempty"`
}

Request represents a Travis CI request. They can be used to see if and why a GitHub even has or has not triggered a new build.

type RequestsListOptions

type RequestsListOptions struct {
	// repository id the requests belong to
	RepositoryId uint `url:"repository_id,omitempty"`

	// repository slug the requests belong to
	Slug string `url:"slug,omitempty"`

	// maximum number of requests to return (cannot be larger than 100)
	Limit uint `url:"limit,omitempty"`

	// list requests before older_than (with older_than being a request id)
	OlderThan uint `url:"older_than,omitempty"`
}

RequestsListOptions specifies the optional parameters to the RequestsService.List method.

You have to either provide RepositoryId or Slug

type RequestsService

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

RequestsService handles communication with the requests related methods of the Travis CI API.

func (*RequestsService) Get

func (rs *RequestsService) Get(requestId uint) (*Request, *Commit, *http.Response, error)

Get fetches the request with the provided id from the Travis CI API.

Travis CI API docs: http://docs.travis-ci.com/api/#builds

func (*RequestsService) ListFromRepository

func (rs *RequestsService) ListFromRepository(slug string, opt *RequestsListOptions) ([]Request, []Commit, *http.Response, error)

List requests triggered (or not) by a repository's builds.

Travis CI API docs: http://docs.travis-ci.com/api/#builds

type User

type User struct {
	Id            uint   `json:"id,omitempty"`
	Name          string `json:"name,omitempty"`
	Login         string `json:"commit_id,omitempty"`
	Email         string `json:"email,omitempty"`
	GravatarId    string `json:"gravatar_id,omitempty"`
	IsSyncing     bool   `json:"is_syncing,omitempty"`
	SyncedAt      string `json:"synced_at,omitempty"`
	CorrectScopes bool   `json:"correct_scopes,omitempty"`
	CreatedAt     string `json:"created_at,omitempty"`
}

User represents a Travis CI user.

type UsersService

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

UsersService handles communication with the users related methods of the Travis CI API.

func (*UsersService) Get

func (us *UsersService) Get(userId uint) (*User, *http.Response, error)

Get fetches the user with the provided id from the Travis CI API.

Travis CI API docs: http://docs.travis-ci.com/api/#users

func (*UsersService) GetAuthenticated

func (us *UsersService) GetAuthenticated() (*User, *http.Response, error)

GetAuthenticated fetches the currently authenticated user from Travis CI API. This request always needs to be authenticated.

Travis CI API docs: http://docs.travis-ci.com/api/#users

func (*UsersService) Sync

func (us *UsersService) Sync() (*http.Response, error)

Sync triggers a new sync with GitHub. Might return status 409 if the user is currently syncing. This request always needs to be authenticated.

Travis CI API docs: http://docs.travis-ci.com/api/#users

Jump to

Keyboard shortcuts

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