CircleCI API written in python
Project description
pycci
Simple python client for the CircleCI API
Installation
pip install pycci
Usage
Example usage can be found in the examples
directory
Configuration
Before using the api you'll need to generate a circleci api token, and initialize the package with the key and the name of your organization.
from pycci import Config
Config.initialize('Your Org', 'Your Key')
If you want to store this configuration so you don't have to re-config everytime, pass in the store
param
Config.initialize('Your Org', 'Your Key', store=True)
Models
Project
from pycci import Project
project = Project('Project Name')
pipelines = project.get_pipelines(num=100) # default is 20 to limit api calls for testing
Pipeline/Workflow/Job/Test
These models can all be fetched from circle CI following the project
from pycci import Pipeline, Workflow, Job, Test
pipelines = project.get_pipelines(num=100)
pipeline = pipelines[0]
workflows = pipeline.get_workflows(failed_only=True) # Get only failed workflows, False by default
workflow = workflows[0]
jobs = workflow.get_jobs(type='type of job', failed_only=True) # type is a String, the JOBTYPE enum has some values to use
job = jobs[0]
tests = job.get_tests(failed_only=True)
All of the data for the objects is stored in a dictionary under the data
attribute.
API
All model instances are initialized with an api object instance that is accessible under the api
attribute
project_api = project.api
pipeline_api = pipeline.api
workflow_api = workflow.api
job_api = job.api
# Test has no api
The api objects can also be created directly
from pycci import ProjectApi, PipelineApi, WorkflowApi, JobApi, JOBTYPE
project_api = ProjectApi('Project name')
result = project_api.get_pipelines(page_token=None)
next_page_token = result['next_page_token']
pipelines = result['items']
pipeline_api = PipelineApi('Pipeline id')
result = pipeline_api.get_workflows(failed_only=True, page_token=None)
next_page_token = result['next_page_token']
workflows = result['items']
workflow_api = WorkflowApi('Workflow id')
result = workflow_api.get_jobs(type=JOBTYPE.BACKEND, failed_only=True, page_token=None)
next_page_token = result['next_page_token']
jobs = result['items']
job_api = JobApi('Job id', 'Job Number', 'Project Slug')
# project slug looks like gh/org/project where gh is your version control
result = job_api.get_tests(failed_only=True, page_token=None)
next_page_token = result['next_page_token']
tests = result['items']
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pycci-1.0.0.tar.gz
.
File metadata
- Download URL: pycci-1.0.0.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ae4e15f6ac3796c0701442b1a884b98897cfb286dafa1d6ac390182213d40ac |
|
MD5 | b7459530f909844ebf42f0b0fa5b9226 |
|
BLAKE2b-256 | 4001877be2f4cdd1f0b258e9220beee1d7f991d1c240da53126151666b7a52d7 |
Provenance
File details
Details for the file pycci-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: pycci-1.0.0-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 19aff05ab9afbc4106470d7302e979971bbeddb0c485005632f5408b8e7522f6 |
|
MD5 | c0c9e6aac9a449b6d78e5b76f3ffc660 |
|
BLAKE2b-256 | d654b77e47848b20a4a4c50bd27ced9496e162fa52f517d9b4cbc4d653edc99a |