Skylab Genesis python client
Project description
# Skylab Genesis Python Client
[](https://circleci.com/gh/skylab-tech/genesis_client_python)
[](https://codeclimate.com/github/skylab-tech/genesis_client_python/maintainability)
[](https://codeclimate.com/github/skylab-tech/genesis_client_python/test_coverage)
SkylabTech Genesis Python client.
[genesis.skylabtech.ai](https://genesis.skylabtech.ai)
## Requirements
- [Python requests library](http://docs.python-requests.org/en/master/user/install/#install)
## Installation
```bash
$ pip install skylab_genesis
```
## Usage
For all examples, assume:
```python
import skylab_genesis
api = skylab_genesis.api(api_key='YOUR-API-KEY')
```
### Error Handling
By default, the API calls return a response object no matter the type of response.
### Endpoints
#### List all jobs
```python
api.list_jobs()
```
#### Create job
```python
payload = {
'profile_id': 1
}
api.create_job(payload=payload)
```
For all payload options, consult the [API documentation](http://docs.genesis.skylabtech.ai/#operation/createJob).
#### Get job
```python
api.get_job(job_id=1)
```
#### Update job
```python
payload = {
'profile_id': 2
}
api.create_job(job_id=1, payload=payload)
```
For all payload options, consult the [API documentation](http://docs.genesis.skylabtech.ai/#operation/updateJobById).
#### Delete job
```python
api.delete_job(job_id=1)
```
#### Process job
```python
api.process_job(job_id=1)
```
#### Cancel job
```python
api.cancel_job(job_id=1)
```
#### List all profiles
```python
api.list_profiles()
```
#### Create profile
```python
payload = {
'profile_id': 1
}
api.create_profile(payload=payload)
```
For all payload options, consult the [API documentation](http://docs.genesis.skylabtech.ai/#operation/createProfile).
#### Get profile
```python
api.get_profile(profile_id=1)
```
#### Update profile
```python
payload = {
'profile_id': 2
}
api.create_profile(profile_id=1, payload=payload)
```
For all payload options, consult the [API documentation](http://docs.genesis.skylabtech.ai/#operation/updateProfileById).
#### Delete profile
```python
api.delete_profile(profile_id=1)
```
#### List all photos
```python
api.list_photos()
```
#### Create photo
```python
payload = {
'photo_id': 1
}
api.create_photo(payload=payload)
```
For all payload options, consult the [API documentation](http://docs.genesis.skylabtech.ai/#operation/createPhoto).
#### Get photo
```python
api.get_photo(photo_id=1)
```
#### Update photo
```python
payload = {
'photo_id': 2
}
api.create_photo(photo_id=1, payload=payload)
```
For all payload options, consult the [API documentation](http://docs.genesis.skylabtech.ai/#operation/updatePhotoById).
#### Delete photo
```python
api.delete_photo(photo_id=1)
```
### Expected Responses
#### Success
```bash
>>> response.status_code
200
>>> response.json().get('success')
True
>>> response.json().get('status')
u'OK'
>>> response.json().get('profile_id')
u'numeric-profile-id'
```
#### Error
* Malformed request
```bash
>>> response.status_code
400
```
* Bad API key
```bash
>>> response.status_code
403
```
## Testing
Use [tox](https://tox.readthedocs.io/en/latest/) to run the tests:
```bash
tox
```
### Testing Multiple Python Versions
This assumes you have [tox](https://tox.readthedocs.io/en/latest/) installed and used
[pyenv](https://github.com/yyuu/pyenv) to install multiple versions of python.
Once all the supported python versions are installed simply run:
```bash
tox
```
This will run the tests against all the versions specified in `tox.ini`.
## Troubleshooting
### General Troubleshooting
- Enable debug mode
- Make sure you're using the latest Python client
- Capture the response data and check your logs — often this will have the exact error
### Enable Debug Mode
Debug mode prints out the underlying request information as well as the data
payload that gets sent to Genesis. You will most likely find this information
in your logs. To enable it, simply put `debug=True` as a parameter when instantiating
the API object. Use the debug mode to compare the data payload getting
sent to [Genesis' API docs](http://docs.genesis.skylabtech.ai/#).
```python
import skylab_genesis
api = skylab_genesis.api(api_key='YOUR-API-KEY', debug=True)
```
### Response Ranges
Genesis' API typically sends responses back in these ranges:
- 2xx – Successful Request
- 4xx – Failed Request (Client error)
- 5xx – Failed Request (Server error)
If you're receiving an error in the 400 response range follow these steps:
- Double check the data and ID's getting passed to Genesis
- Ensure your API key is correct
- Log and check the body of the response
## Distribution
To package:
```bash
python setup.py sdist bdist_wheel upload
```
[](https://circleci.com/gh/skylab-tech/genesis_client_python)
[](https://codeclimate.com/github/skylab-tech/genesis_client_python/maintainability)
[](https://codeclimate.com/github/skylab-tech/genesis_client_python/test_coverage)
SkylabTech Genesis Python client.
[genesis.skylabtech.ai](https://genesis.skylabtech.ai)
## Requirements
- [Python requests library](http://docs.python-requests.org/en/master/user/install/#install)
## Installation
```bash
$ pip install skylab_genesis
```
## Usage
For all examples, assume:
```python
import skylab_genesis
api = skylab_genesis.api(api_key='YOUR-API-KEY')
```
### Error Handling
By default, the API calls return a response object no matter the type of response.
### Endpoints
#### List all jobs
```python
api.list_jobs()
```
#### Create job
```python
payload = {
'profile_id': 1
}
api.create_job(payload=payload)
```
For all payload options, consult the [API documentation](http://docs.genesis.skylabtech.ai/#operation/createJob).
#### Get job
```python
api.get_job(job_id=1)
```
#### Update job
```python
payload = {
'profile_id': 2
}
api.create_job(job_id=1, payload=payload)
```
For all payload options, consult the [API documentation](http://docs.genesis.skylabtech.ai/#operation/updateJobById).
#### Delete job
```python
api.delete_job(job_id=1)
```
#### Process job
```python
api.process_job(job_id=1)
```
#### Cancel job
```python
api.cancel_job(job_id=1)
```
#### List all profiles
```python
api.list_profiles()
```
#### Create profile
```python
payload = {
'profile_id': 1
}
api.create_profile(payload=payload)
```
For all payload options, consult the [API documentation](http://docs.genesis.skylabtech.ai/#operation/createProfile).
#### Get profile
```python
api.get_profile(profile_id=1)
```
#### Update profile
```python
payload = {
'profile_id': 2
}
api.create_profile(profile_id=1, payload=payload)
```
For all payload options, consult the [API documentation](http://docs.genesis.skylabtech.ai/#operation/updateProfileById).
#### Delete profile
```python
api.delete_profile(profile_id=1)
```
#### List all photos
```python
api.list_photos()
```
#### Create photo
```python
payload = {
'photo_id': 1
}
api.create_photo(payload=payload)
```
For all payload options, consult the [API documentation](http://docs.genesis.skylabtech.ai/#operation/createPhoto).
#### Get photo
```python
api.get_photo(photo_id=1)
```
#### Update photo
```python
payload = {
'photo_id': 2
}
api.create_photo(photo_id=1, payload=payload)
```
For all payload options, consult the [API documentation](http://docs.genesis.skylabtech.ai/#operation/updatePhotoById).
#### Delete photo
```python
api.delete_photo(photo_id=1)
```
### Expected Responses
#### Success
```bash
>>> response.status_code
200
>>> response.json().get('success')
True
>>> response.json().get('status')
u'OK'
>>> response.json().get('profile_id')
u'numeric-profile-id'
```
#### Error
* Malformed request
```bash
>>> response.status_code
400
```
* Bad API key
```bash
>>> response.status_code
403
```
## Testing
Use [tox](https://tox.readthedocs.io/en/latest/) to run the tests:
```bash
tox
```
### Testing Multiple Python Versions
This assumes you have [tox](https://tox.readthedocs.io/en/latest/) installed and used
[pyenv](https://github.com/yyuu/pyenv) to install multiple versions of python.
Once all the supported python versions are installed simply run:
```bash
tox
```
This will run the tests against all the versions specified in `tox.ini`.
## Troubleshooting
### General Troubleshooting
- Enable debug mode
- Make sure you're using the latest Python client
- Capture the response data and check your logs — often this will have the exact error
### Enable Debug Mode
Debug mode prints out the underlying request information as well as the data
payload that gets sent to Genesis. You will most likely find this information
in your logs. To enable it, simply put `debug=True` as a parameter when instantiating
the API object. Use the debug mode to compare the data payload getting
sent to [Genesis' API docs](http://docs.genesis.skylabtech.ai/#).
```python
import skylab_genesis
api = skylab_genesis.api(api_key='YOUR-API-KEY', debug=True)
```
### Response Ranges
Genesis' API typically sends responses back in these ranges:
- 2xx – Successful Request
- 4xx – Failed Request (Client error)
- 5xx – Failed Request (Server error)
If you're receiving an error in the 400 response range follow these steps:
- Double check the data and ID's getting passed to Genesis
- Ensure your API key is correct
- Log and check the body of the response
## Distribution
To package:
```bash
python setup.py sdist bdist_wheel upload
```
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
skylab_genesis-1.0.0.tar.gz
(5.8 kB
view hashes)
Built Distribution
Close
Hashes for skylab_genesis-1.0.0-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 80a42bf8141978a80e747b94cf011bd5ec082a8b92c52f46fc424a2b67f7fa58 |
|
MD5 | f7d825fe935cc11129cff9dcb402447e |
|
BLAKE2b-256 | 357a4cc8fd53a733974ac14ac85a8b97bf5d61d64df2a0eda41b9510e4e20004 |