Categorygithub.com/robbybbb/go-travis
modulepackage
0.1.18
Repository: https://github.com/robbybbb/go-travis.git
Documentation: pkg.go.dev

# README

go-travis

GitHub release Actions Status License GoDoc

go-travis is a Go client library to interact with the Travis CI API V3.

Installation

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

Usage

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

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

client := travis.NewClient(travis.ApiOrgUrl, "TravisApiToken")

// List all the builds which belongs to the current user
builds, res, err := client.Builds.List(context.Background(), nil)

URL

Currently, there are two possible options for Travis CI API URL.

  • https://api.travis-ci.org/
  • https://api.travis-ci.com/

You should know which URL your project belongs to, and hand it in to NewClient method as an argument. We provide two constants, ApiOrgUrl for https://api.travis-ci.org/ and ApiComUrl for https://api.travis-ci.com/, so please choose one of them.

Travis CI is migrating projects in https://api.travis-ci.org/ to https://api.travis-ci.com/, and please visit their documentation page for more information on the migration.

Authentication

client := travis.NewClient(travis.ApiOrgUrl, "TravisApiToken")

// Jobs.Cancel will success
_, _, err := client.Jobs.Cancel(context.Background(), 12345)

You can issue Travis API token and hand it in to NewClient method directly. You can issue your token by visiting your Travis CI Profile page or using Travis CI command line tool.

For more information on how to issue Travis CI API token, please visit their documentation.

Unauthenticated client

It is possible to interact with the API without authentication. However, most resources are not accessible.

client := travis.NewClient(travis.ApiOrgUrl, "")

// Builds.ListByRepoSlug is available without authentication
builds, resp, err := client.Builds.ListByRepoSlug(context.Background(), "shuheiktgw/go-travis", nil)

// Jobs.Cancel is unavailable without authentication
_, _, err = client.Jobs.Cancel(context.Background(), 12345)

Standard Representation / Minimal Representation

Travis CI API V3 provides two types of resource representations, standard and minimal. The API returns the resource you request in a standard representation and the resources related to the original resource in a minimal representation.

If you want the related resources in a standard representation, you need to eager load them by specifying include option.

For example, to eager load repository and commits when fetching a build, one can specify Include in BuildOption:

opt := BuildOption{Include: []string{"build.repository", "build.commits"}}
build, _, err := client.Builds.Find(context.Background(), 123, &opt)

Contribution

Contributions are of course always welcome!

  1. Fork shuheiktgw/go-travis (https://github.com/shuheiktgw/go-travis/fork)
  2. Run make install to install dependencies
  3. Create a feature branch
  4. Commit your changes
  5. Run test using make test
  6. Create a Pull Request

See CONTRIBUTING.md for details.

Acknowledgements

This library is originally forked from Ableton/go-travis and most of the credits of this library is attributed to them.

# Functions

Bool is a helper routine that allocates a new bool value to store v and returns a pointer to it.
Int64 is a helper routine that allocates a new Int64 value to store v and returns a pointer to it.
NewClient returns a new Travis API client.
NewDefaultClient returns a new Travis API client bound to the public travis API.
String is a helper routine that allocates a new string value to store v and returns a pointer to it.
Uint is a helper routine that allocates a new Uint value to store v and returns a pointer to it.

# Constants

No description provided by the author
No description provided by the author
AutoCancelPullRequestsSetting is a setting name for auto_cancel_pull_requests.
AutoCancelPushesSetting is a setting name for auto_cancel_pushes.
BuildEventTypePullRequest represents the build event type `pull_request`.
BuildEventTypePush represents the build event type `push`.
BuildPullRequestsSetting is a setting name for build_pull_requests.
BuildPushesSetting is a setting name for build_pushes.
BuildsOnlyWithTravisYmlSetting is a setting name for builds_only_with_travis_yml.
BuildStateCanceled represents the build state `canceled`.
BuildStateCreated represents the build state `created`.
BuildStateErrored represents the build state `errored`.
BuildStateFailed represents the build state `failed`.
BuildStatePassed represents the build state `passed`.
BuildStateReceived represents the build state `received`.
BuildStateStarted represents the build state `started`.
No description provided by the author
No description provided by the author
No description provided by the author
JobStatusCanceled represents the job state `canceled`.
JobStatusCreated represents the job state `created`.
JobStatusPassed represents the job state `passed`.
JobStatusQueued represents the job state `queued`.
JobStatusReceived represents the job state `received`.
JobStatusStarted represents the job state `started`.
MaximumNumberOfBuildsSetting is a setting name for maximum_number_of_builds.

# Structs

ActiveOption specifies the optional parameters for active endpoint.
ActiveService handles communication with the active endpoints of Travis CI API.
BetaFeature is a standard representation of an individual beta feature Travis CI API docs: https://developer.travis-ci.com/resource/beta_feature#attributes.
BetaFeaturesService handles communication with the beta feature related methods of the Travis CI API.
BetaMigrationRequest is a standard representation of an individual beta migration request Travis CI API docs: https://developer.travis-ci.com/resource/beta_migration_request#attributes.
BetaMigrationRequestBody specifies body for creating a beta migration request.
BetaMigrationRequestOption specifies options for finding a beta migration requests.
BetaMigrationRequestsService handles communication with the beta migration requests related methods of the Travis CI API.
Branch represents a branch of a GitHub repository Travis CI API docs: https://developer.travis-ci.com/resource/branch#standard-representation.
BranchesOption specifies the optional parameters for branches endpoint.
BranchesService handles communication with the branch related methods of the Travis CI API.
BranchOption specifies the optional parameters for branch endpoint.
Broadcast is a standard representation of an individual broadcast Travis CI API docs: https://developer.travis-ci.com/resource/broadcast#standard-representation.
BroadcastsOption specifies the optional parameters for broadcasts endpoint.
BroadcastsService handles communication with the broadcasts related methods of the Travis CI API.
Build represents a Travis CI build Travis CI API docs: https://developer.travis-ci.com/resource/build#standard-representation.
BuildOption specifies the optional parameters for build endpoint.
BuildsByRepoOption specifies the optional parameters for builds endpoint.
BuildsOption specifies the optional parameters for builds endpoint.
BuildsService handles communication with the builds related methods of the Travis CI API.
Cache is a standard representation of a cache on Travis CI Travis CI API docs: https://developer.travis-ci.com/resource/caches#attributes.
CachesService handles communication with the caches endpoints of Travis CI API.
A Client manages communication with the Travis CI API.
Commit is a standard representation of a GitHub commit as seen by Travis CI Travis CI API docs: https://developer.travis-ci.com/resource/commit#standard-representation.
Committer is a committer of the commit.
Config represents Travis CI job's configuration.
Cron is a standard representation of an individual cron Travis CI API docs: https://developer.travis-ci.com/resource/cron#standard-representation.
CronBody specifies body for creating cron.
CronOption specifies options for fetching cron.
CronsOption specifies options for fetching crons.
CronsService handles communication with the crons related methods of the Travis CI API.
EmailSubscriptionService handles communication with the email subscription related methods of the Travis CI API.
EnvVar is a standard representation of a environment variable on Travis CI Travis CI API docs: https://developer.travis-ci.com/resource/env_var#standard-representation.
EnvVarBody specifies options for creating and updating env var.
EnvVarsService handles communication with the env vars endpoints of Travis CI API.
ErrorResponse reports an error caused by an API request.
GeneratedKeyPairService handles communication with the key pair (generated) endpoints of Travis CI API.
Installation represents a GitHub App installation Travis CI API docs: https://developer.travis-ci.com/resource/installation#standard-representation.
InstallationOption is query parameters to one can specify to find installation.
InstallationsService handles communication with the installation related methods of the Travis CI API.
Job represents a Travis CI job Travis CI API docs: https://developer.travis-ci.com/resource/job#standard-representation.
JobOption is query parameters to one can specify to find job.
JobsOption is query parameters to one can specify to find jobs.
JobsService handles communication with the jobs related methods of the Travis CI API.
KeyPair is a standard representation of a public/private RSA key pair on Travis CI Travis CI API docs: https://developer.travis-ci.com/resource/key_pair#standard-representation.
KeyPairBody specifies options for creating and updating key pair.
KeyPairService handles communication with the key pair endpoints of Travis CI API.
LintService handles communication with the lint endpoint of Travis CI API.
Log represents a Travis CI job log.
LogPart is parts that form the log.
LogsService handles communication with the logs related methods of the Travis CI API.
Message represents an individual Message.
MessagesOption specifies the optional parameters for messages endpoint.
MessagesService handles communication with the Message related methods of the Travis CI API.
Metadata is a metadata returned from the Travis CI API.
Organization is a standard representation of an individual organization Travis CI API docs: https://developer.travis-ci.com/resource/organization#standard-representation.
OrganizationOption specifies the optional parameters for organization endpoint.
OrganizationsOption specifies the optional parameters for organizations endpoint.
OrganizationsService handles communication with the organization related methods of the Travis CI API.
Owner represents a GitHub Repository Travis CI API docs: https://developer.travis-ci.com/resource/owner#standard-representation.
OwnerOption specifies the optional parameters for owner endpoint.
OwnerService handles communication with the GitHub owner related methods of the Travis CI API.
Preference is a standard representation of an individual preference Travis CI API docs: https://developer.travis-ci.com/resource/preference#standard-representation.
PreferenceBody is body for creating preference.
PreferencesService handles communication with the preferences related methods of the Travis CI API.
RepositoriesOption is query parameters to one can specify to find repositories.
RepositoriesService handles communication with the builds related methods of the Travis CI API.
Repository represents a Travis CI repository Travis CI API docs: https://developer.travis-ci.com/resource/repository#standard-representation.
RepositoryOption is query parameters to one can specify to find repository.
Request represents a Travis CI request.
RequestBody specifies body for creating request.
RequestOption specifies options for finding a request.
RequestsOption specifies options for listing requests.
RequestsService handles communication with the requests related methods of the Travis CI API.
Setting represents a Travis CI setting.
SettingBody is a body to update setting.
SettingsService handles communication with the setting related methods of the Travis CI API.
Stage is a standard representation of an individual stage Travis CI API docs: https://developer.travis-ci.com/resource/stage#standard-representation.
StagesOption is query parameters to one can specify to list stages.
StagesService handles communication with the stage related methods of the Travis CI API.
Tag is a standard representation of a Travis CI tag.
No description provided by the author
User represents a Travis CI user.
UserOption is query parameters to one can specify to find a user.
UserService handles communication with the users related methods of the Travis CI API.
Warning is a standard representation of a warning of .travis.yml content validation Travis CI API docs: https://developer.travis-ci.com/resource/lint.

# Type aliases

Author is an author of the commit.
Permissions represents permissions of Travis CI API.