API¶
This document brings the public API of TravisPy.
-
travispy.travispy.
PUBLIC
= URI for Travis CI free service.¶
-
travispy.travispy.
PRIVATE
= URI for Travis CI paid service for GitHub private repositories.¶
-
travispy.travispy.
ENTERPRISE
= URI template for Travis CI service running under a personal domain. Usage will be something like ENTERPRISE % {'domain': 'http://travis.example.com'}.¶
-
class
travispy.travispy.
TravisPy
(token=None, uri='https://api.travis-ci.org')[source]¶ Instances of this class are responsible for comunicating with Travis CI, sending requests and handling responses properly. You can create as much instances as you want since each one will create a separated session.
Parameters: - token (str | None) –
Travis CI token linked to your GitHub account.
Even if you have a public repository, some information are related to your user account and not the repository itself so if token is not provided an error will be returned.
Required for private and enterprise repositories to access any information.
- uri (
PUBLIC
|PRIVATE
|ENTERPRISE
| str) – URI where Travis CI service is running.
Note
Do not confuse
token
with the one found on your profile page.-
account
(account_id)[source]¶ Parameters: account_id (int) – ID of the account to obtain information. Return type: Account
Note
This request always needs to be authenticated.
-
accounts
(all=False)[source]¶ Parameters: all (bool) – Whether or not to include accounts the user does not have admin access to. Return type: list( Account
)Returns: Information of all accounts that the user might have access.This is usually the account corresponding to the user directly and one account per GitHub organization. Note
This request always needs to be authenticated.
-
branch
(name, repo_id_or_slug, **kwargs)[source]¶ Parameters: - name (str) – Branch name that should be retrieved.
- repo_id_or_slug (int | str) – Repository where branch is located.
Return type:
-
branches
(**kwargs)[source]¶ Parameters: - repository_id (int) – Repository id the build belongs to.
- slug (str) – Repository slug the build belongs to.
Return type: list(
Branch
)Note
You have to supply either
repository_id
orslug
.
-
broadcasts
()[source]¶ Return type: list( Broadcast
)Note
This request always needs to be authenticated.
-
build
(build_id)[source]¶ Parameters: build_id (int) – ID of the build to obtain information. Return type: Build
-
builds
(**kwargs)[source]¶ Parameters: - ids (list(int)) – List of build ids to fetch.
- repository_id (int) – Repository id the build belongs to.
- slug (str) – Repository slug the build belongs to.
- number (str) – Filter by build number, requires
slug
orrepository_id
. - after_number (str) – List build after a given build number (use for pagination), requires
slug
orrepository_id
. - event_type (str) – Limit build to given event type (
push
orpull_request
).
Return type: list(
Build
)Note
You have to supply either
ids
,repository_id
orslug
.
-
classmethod
github_auth
(token, uri='https://api.travis-ci.org')[source]¶ Parameters: - token (str) – GitHub access token.
- uri – See
__init__()
Return type: Returns: A
TravisPy
instance authenticated with GitHub account.Raises: TravisError – when authentication against GitHub fails.
-
hooks
()[source]¶ Return type: list( Hook
)Returns: Returns list of existing hooks that user have access. Note
This request always needs to be authenticated.
-
jobs
(**kwargs)[source]¶ Parameters: - ids (list(int)) – List of jobs IDs.
- state (str) – Job state to filter by. Possible values are
passed
,canceled
,failed
anderrored
. - queue (str) – Job queue to filter by.
Return type: list(
Job
)Note
You need to provide exactly one of the above parameters. If you provide
state
orqueue
, a maximum of 250 jobs will be returned.
-
repo
(id_or_slug)[source]¶ Parameters: id_or_slug (int | str) – ID of slug of repository to obtain information. Return type: Repo
-
repos
(**kwargs)[source]¶ Parameters: - ids (list(int)) – List of repository ids to fetch, cannot be combined with other parameters.
- member (str) – Filter by user that has access to it (GitHub login).
- owner_name (str) – Filter by owner name (first segment of slug).
- slug (str) – Filter by slug.
- search (str) – Filter by search term.
- active (bool) – If
True
, will only return repositories that are enabled. Default isFalse
.
Return type: list(
Repo
)Note
If no parameters are given, a list of repositories with recent activity is returned.
- token (str | None) –