Repository¶
Just another Python API for Travis CI (API).
A module which provides the “Repository” resource type.
- Author:
- Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom
- Project link:
- https://github.com/funilrys/PyTravisCI
- Project documentation:
- https://pytravisci.readthedocs.io/en/latest/
License
MIT License
Copyright (c) 2019, 2020, 2021, 2022 Nissar Chababy
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-
class
PyTravisCI.resource_types.repository.
Repository
(**kwargs)[source]¶ Bases:
PyTravisCI.resource_types.base.ResourceTypesBase
Provides the description of a repository.
- Official Travis CI API documentation
Variables: - id (int) – Value uniquely identifying the repository.
- name (str) – The repository’s name on GitHub.
- slug (str) – Same as {repository.owner.name}/{repository.name}.
- description (str) – The repository’s description from GitHub.
- github_id (int) – The repository’s id on GitHub.
- vcs_id – The repository’s vcs_id.
- vcs_type – The repository’s vcs_type.
- github_language (str) – The main programming language used according to GitHub.
- active (bool) – Whether or not this repository is currently enabled on Travis CI.
- private (bool) – Whether or not this repository is private.
- owner – GitHub user or organization the repository belongs to.
- owner_name – The repository’s owner_name.
- vcs_name – The repository’s vcs_name.
- default_branch (
Branch
) – The default branch on GitHub. - starred (bool) – Whether or not this repository is starred.
- managed_by_installation (bool) – Whether or not this repository is managed by a GitHub App installation.
- active_on_org (bool) – Whether or not this repository runs builds on travis-ci.org (may also be null).
- migration_status – The repository’s migration_status.
- history_migration_status – The repository’s history_migration_status.
- shared – The repository’s shared.
- config_validation – The repository’s config_validation.
- allow_migration – The repository’s allow_migration.
-
activate
(*, params: Optional[dict] = None) → PyTravisCI.resource_types.repository.Repository[source]¶ Activates the current repository, allowing its test to be run on Travis Ci.
Parameters: params – The query parameters to append to the URL.
-
create_env_var
(name: str, value: str, *, is_public: bool = False, branch: Optional[str] = None, params: Optional[dict] = None) → PyTravisCI.resource_types.env_var.EnvVar[source]¶ Creates a new environment variable into the current repository.
- Official Travis CI API documentation:
Parameters: - name – The environment variable name, e.g. FOO.
- value – The environment variable’s value, e.g. bar.
- is_public – Whether this environment variable should be publicly visible or not.
- branch – The env_var’s branch.
Raises: TypeError – When the types of
name
andvalue
are not :py:class`str`.
-
create_key_pair
(description: str, value: Union[str, bytes], *, params: Optional[dict] = None) → PyTravisCI.resource_types.key_pair.KeyPair[source]¶ Creates a new RSA key pair.
Parameters: - description – A text description.
- value – The private key.
Raises: TypeError – When the types of
name
andvalue
are not :py:class`str` nor :py:class`bytes`.
-
create_request
(message: str, branch: str, *, config: Optional[dict] = None, params: Optional[dict] = None) → PyTravisCI.resource_types.request.Request[source]¶ Creates a Request
Parameters: - message – Travis-ci status message attached to the request.
- branch – Branch requested to be built.
- config – Build configuration (as parsed from .travis.yml).
Raises: TypeError – When the types of
name
andvalue
are not :py:class`str` nor :py:class`bytes`.
-
deactivate
(*, params: Optional[dict] = None) → PyTravisCI.resource_types.repository.Repository[source]¶ Activates the current repository, preventing any tests from runningIs on Travis CI.
Parameters: params – The query parameters to append to the URL.
-
encrypt_env_var
(env_vars: dict, padding: Optional[str] = 'PKCS1v15') → dict[source]¶ Process the encryption of the given environment variables.
Parameters: - env_vars –
The key-value representing the environment variables to encrypt.
Warning
Spaces in keys will be automatically converted to underscore!
- padding –
The padding to use.
Supported by PyTravisCI:
PKCS1v15
OAEP
Supported by Travis CI:
PKCS1v15
Warning
DO NOT CHANGE THIS UNLESS INVITED TO.
As of today, Travis CI use the
PKCS1v15
padding. But it may be possible that one day they will change it to OAEP.Please report to the following references/discussion:
Returns: A list representing each encrypted values.
As example, if the following is given:
{ "HELLO": "WORLD", "WORLD": "HELLO" }
The response will be:
[ {"secure": "encrypted version of HELLO=WORLD" }, {"secure": "encrypted version of WORLD=HELLo" } ]
- env_vars –
-
encrypt_file
(input_file: Union[io.IOBase, str], output_file: Union[io.IOBase, str], *, branch: Optional[str] = None) → dict[source]¶ Encrypts the content of the given
input_file
intooutput_file
.- Side Effects:
- Generates a new IV key.
- Generates a new encryption key.
- Save the IV key into a (new) repository environment variable.
- Save the encryption key into a (new) repository environment variable.
Parameters: - input_file –
The (plain) file to read.
If a
str
is given, this method will open and close the file for you.If a
io.TextIOWrapper
is given, this method expects it to be in rb mode. - output_file –
The file to write.
If a
str
is given, this method will open and close the file for you.If a
io.TextIOWrapper
is given, this method expects it to be in wb mode. - branch – The branch to save the IV and key for.
Returns: A
dict
which represents the data which are supposed to help the end-user decrypt the encrypted data.Given an input file
hello
and an output filehello.enc
, this method will provides the following:{ "command": "openssl aes-256-cbc -K " "$ENCRYPTED_BB6A5397D5B2_KEY -iv $ENCRYPTED_BB6A5397D5B2_IV " "-in hello.enc -out hello -d", "iv": { "ENCRYPTED_BB6A5397D5B2_IV": "hexadecimal representation of the IV." }, "key": { "ENCRYPTED_BB6A5397D5B2_KEY": "hexadecimal representation of the key." }, }
-
encrypt_secrets
(secrets: List[Union[str, bytes]], padding: Optional[str] = 'PKCS1v15') → str[source]¶ Encrypts the given secret.
Parameters: - secret – A list of secrets to encrypt.
- padding –
The padding to use.
Supported by PyTravisCI:
PKCS1v15
OAEP
Supported by Travis CI:
PKCS1v15
Warning
DO NOT CHANGE THIS UNLESS INVITED TO.
As of today, Travis CI use the
PKCS1v15
padding. But it may be possible that one day they will change it to OAEP.Please report to the following references/discussion:
Returns: A list of encrypted secrets.
-
generate_key_pair
(*, params: Optional[dict] = None) → PyTravisCI.resource_types.key_pair_generated.KeyPairGenerated[source]¶ Generates a new RSA key pair.
-
get_branch
(branch_name: str, *, params: Optional[dict] = None) → PyTravisCI.resource_types.branch.Branch[source]¶ Provides the information of a given branch.
- Official Travis CI API documentation:
Parameters: - branch_name – Name of the git branch.
- params – The query parameters to append to the URL.
-
get_branches
(*, params: Optional[dict] = None) → PyTravisCI.resource_types.branches.Branches[source]¶ Provides the list of branches of the current repository.
- Official Travis CI API documentation:
Parameters: params – The query parameters to append to the URL.
-
get_builds
(*, params: Optional[dict] = None) → PyTravisCI.resource_types.builds.Builds[source]¶ Provides the list of builds of the current repository.
- Official Travis CI API documentation:
Parameters: params – The query parameters to append to the URL.
-
get_caches
(*, params: Optional[dict] = None) → PyTravisCI.resource_types.caches.Caches[source]¶ Provides the list of caches of the current repository.
- Official Travis CI API documentation:
Parameters: params – The query parameters to append to the URL.
-
get_crons
(*, params: Optional[dict] = None) → PyTravisCI.resource_types.crons.Crons[source]¶ Provides the list of crons of the current repository.
- Official Travis CI API documentation:
Parameters: params – The query parameters to append to the URL.
-
get_env_var
(env_var_id: str, *, params: Optional[dict] = None) → PyTravisCI.resource_types.env_var.EnvVar[source]¶ Provides an environment variable from its ID.
- Official Travis CI API documentation:
Parameters: - env_var_id – The ID of the environment variable to get.
- params – The query parameters to append to the URL.
-
get_env_vars
(*, params: Optional[dict] = None) → PyTravisCI.resource_types.env_vars.EnvVars[source]¶ Provides the list of environment variables of the current repository.
- Official Travis CI API documentation:
Parameters: params – The query parameters to append to the URL.
-
get_key_pair
(*, params: Optional[dict] = None) → PyTravisCI.resource_types.key_pair.KeyPair[source]¶ Provides the RSA key pair of the current repository.
- Official Travis CI API documentation:
Parameters: params – The query parameters to append to the URL.
-
get_key_pair_generated
(*, params: Optional[dict] = None) → PyTravisCI.resource_types.key_pair_generated.KeyPairGenerated[source]¶ Provides the generated RSA key pair of the current repository.
- Official Travis CI API documentation:
Parameters: params – The query parameters to append to the URL.
-
get_request
(request_id: Union[str, int], *, params: Optional[dict] = None) → PyTravisCI.resource_types.request.Request[source]¶ Provides a single request from its given ID.
- Official Travis CI API documentation:
Parameters: - request_id – The ID of the request to get.
- params – The query parameters to append to the URL.
-
get_requests
(*, params: Optional[dict] = None) → PyTravisCI.resource_types.requests.Requests[source]¶ Provides the list of requests of the current repository.
- Official Travis CI API documentation:
Parameters: params – The query parameters to append to the URL.
-
get_setting
(setting_name: str, *, params: Optional[dict] = None) → PyTravisCI.resource_types.setting.Setting[source]¶ Provides a single setting from its given name.
- Official Travis CI API documentation:
Parameters: params – The query parameters to append to the URL.
-
get_settings
(*, params: Optional[dict] = None) → PyTravisCI.resource_types.settings.Settings[source]¶ Provides the list of settings of the current repository.
- Official Travis CI API documentation:
Parameters: params – The query parameters to append to the URL.