https://github.com/strigo/pystrigo
Strigo's not-yet-official-but-maybe-soon-will-be Python REST client and CLI
https://github.com/strigo/pystrigo
cli client python3 rest-api rest-client strigo
Last synced: 3 months ago
JSON representation
Strigo's not-yet-official-but-maybe-soon-will-be Python REST client and CLI
- Host: GitHub
- URL: https://github.com/strigo/pystrigo
- Owner: strigo
- Created: 2019-05-02T18:09:55.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2021-07-22T19:44:54.000Z (over 4 years ago)
- Last Synced: 2023-03-02T18:56:01.015Z (about 3 years ago)
- Topics: cli, client, python3, rest-api, rest-client, strigo
- Language: Python
- Homepage: https://docs.strigo.io/api/reference
- Size: 25.4 KB
- Stars: 3
- Watchers: 7
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# pystrigo
**This is WIP**. Please do not consider this to be production ready.
`pystrigo` is Strigo's official Python REST API client and CLI. It allows to easily retrieve information from Strigo's REST API and to automate processes.
Visit [Strigo's REST API Reference](http://docs.strigo.io/api/reference) from more information on the API and on retrieving your `ORG_ID` and `API_KEY`.
## Installation
`pystrigo` supports Linux, Windows and OSX on Python 3.4+
```shell
git clone git@github.com:strigo/pystrigo.git
cd pystrigo
pip install .
```
To install the CLI run:
```shell
pip install .[cli]
```
## Usage
### Python
```python
from strigo import Strigo
from strigo.logger import log
ORG_ID = os.getenv('STRIGO_ORG_ID')
API_KEY = os.getenv('STRIGO_API_KEY')
STRIGO_API_ENDPOINT = 'https://app.strigo.io/api/v1'
# To have the logger log both requests and responses to the console
log.set_level('debug')
strigo = Strigo(org_id=ORG_ID, api_key=API_KEY, endpoint=STRIGO_API_ENDPOINT)
strigo.classes.get(class_id='DsAnDSjmPe2wnCRw2')
# >> GET /classes/DsAnDSjmPe2wnCRw2...
# >> GET /classes/DsAnDSjmPe2wnCRw2 response
# >> status_code=200
# >> data={
# >> "result": "success",
# >> "data": {
# >> "id": "DsAnDSjmPe2wnCRw2",
# >> "name": "Coding",
# >> "owner": {
# >> "id": "rMWNrMT2PCySh2PGo",
# >> "email": "nir+1@strigo.io"
# >> },
# >> "resources": [
# >> {
# >> "type": "lab_instance",
# >> "id": "oqgcyawx6PXsu4r43",
# >> "name": "Lab",
# >> "instance_type": "t2.large",
# >> "image_id": "ami-614dcd0e",
# >> "image_user": "ubuntu",
# >> "is_custom_image": false
# >> }
# >> ],
# >> "presentation_notes": [],
# >> "created_at": "2019-04-11T21:51:49.274Z"
# >> }
# >> }
response = client.events.post({
'class_id': 'DsAnDSjmPe2wnCRw2',
'name': 'My Event',
'owner': 'nir+1@strigo.io',
'date_start': '2019-08-01 00:00:00.000Z',
'date_end': '2019-08-01 01:00:00.000Z'
})
assert response.status_code == 200
event_id = response.data['id']
...
```
### CLI
`pystrigo` exposes a CLI called `siesta` (Rest. Get it? :))
This CLI is supposed to provide a reasonable abstraction on top of the client, just so that it's easier to perform actions without having to write code. It is not optimized as a standard CLI in itself.
```shell
$ siesta --help
Usage: siesta [OPTIONS] METHOD ENDPOINT [ARGUMENTS]...
Options:
--help Show this message and exit.
export STRIGO_ORG_ID="YOUR_ORG_ID" # Org admins can see in settings
export STRIGO_API_KEY="YOUR_API_KEY" # Org admins can see in settings
export STRIGO_API_ENDPOINT="https://app.strigo.io/api/v1"
# e.g.
$ siesta GET classes :class_id="DsAnDSjmPe2wnCRw2"
...
$ siesta POST events \
class_id="DsAnDSjmPe2wnCRw2" \
name="My Event" \
owner="nir+1@strigo.io" \
date_start="2019-08-01 00:00:00.000Z" \
date_end="2019-08-01 01:00:00.000Z"
...
```
# Contributions
Any contribution is appreciated. We'd like to add tests, pytype validations, an official pypi deployment, and API documentation.