Skip to content

Commit

Permalink
add more API v2 endpoints (#22)
Browse files Browse the repository at this point in the history
* add more API v2 endpoints
* refactor tests
  • Loading branch information
alpinweis authored Nov 12, 2021
1 parent 354d9dd commit 9377620
Show file tree
Hide file tree
Showing 71 changed files with 1,080 additions and 529 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
### [0.5.0] - 2021-11-10
* Add more insights endpoints (API v2)
* Add more pipeline endpoints (API v2)
* Add more user endpoints (API v2)
* Add more workflow endpoints (API v2)
* Add schedule endpoints (API v2)

### [0.4.1] - 2021-11-07
* Fix get_contexts()
* Add endpoints for context environment variables (API v2)
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ clean:
rm -rf build/ dist/ pycircleci.egg-info/
find ./ | grep -E "(__pycache__|\.pytest_cache|\.cache|\.pyc|\.pyo$$)" | xargs rm -rf

console:
python pycircleci/console.py

pack:
python setup.py sdist bdist_wheel

test:
python -m pytest -v
pytest -v tests/
35 changes: 26 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
# pycircleci

[![PyPI version](https://badge.fury.io/py/pycircleci.svg)](https://badge.fury.io/py/pycircleci)
[![Build Status](https://github.com/alpinweis/pycircleci/actions/workflows/test.yml/badge.svg)](https://github.com/alpinweis/pycircleci/actions/workflows/test.yml)
[![Build Status](https://github.com/alpinweis/pycircleci/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/alpinweis/pycircleci/actions/workflows/test.yml?query=branch%3Amaster)

Python client for [CircleCI API](https://circleci.com/docs/2.0/api-intro/).

Based on the discontinued [circleci.py](https://github.com/levlaz/circleci.py) project.

Original Author & Credit: Lev Lazinskiy (https://levlaz.org)

## Features

- Supports [API v1.1](https://circleci.com/docs/api/#api-overview) and [API v2](https://circleci.com/docs/api/v2/)
Expand All @@ -22,18 +20,37 @@ Original Author & Credit: Lev Lazinskiy (https://levlaz.org)

Create a personal [API token](https://circleci.com/docs/2.0/managing-api-tokens/#creating-a-personal-api-token).

Set up the expected env vars:

CIRCLE_TOKEN # CircleCI API access token
CIRCLE_API_URL # CircleCI API base url. Defaults to https://circleci.com/api

```python
from pycircleci.api import Api
from pycircleci.api import Api, CIRCLE_TOKEN, CIRCLE_API_URL

circle_client = Api(token=CIRCLE_TOKEN, url=CIRCLE_API_URL)

circleci = Api(YOUR_CIRCLECI_TOKEN)
# get current user info
circle_client.get_user_info()

# get current user info
circleci.get_user_info()
# get list of projects
results = circle_client.get_projects()

# get list of projects
circleci.get_projects()
# pretty print results as json
circle_client.ppj(results)

# pretty print the details of the last request/response
circle_client.ppr()
```

### Interactive development console

make console

This starts a pre-configured python interactive console which gives you access to a
`client` object - an instance of the `Api` class to play around. From the console
type `man()` to see the help screen.

### Contributing

1. Fork it
Expand Down
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.5.0
Loading

0 comments on commit 9377620

Please sign in to comment.