Minimal SQuaRE API wrapper for status.lsst.codes
Project description
[![Build Status](https://travis-ci.org/lsst-sqre/sqre-apikit.svg?branch=master)](https://travis-ci.org/lsst-sqre/sqre-apikit)
# sqre-apikit
LSST DM SQuaRE microservice convenience tools.
## Rationale
In order to create a microservice hosted behind https://api.lsst.codes,
a service will need to provide a route on `/metadata` and
`/v{{api_version}}/metadata`. That route must serve appropriate
metadata about the service.
### Metadata format
The metadata served must be a JSON object, and must contain the
following fields:
`name`: `str`
`version`: `str`
`repository`: `str`
`description`: `str`
`api_version`: `str`
`auth`: `str`
The fields `name`, `version`, `api_version`, and `description` are
arbitrary, although semantic versioning is strongly encouraged, and the
API version should reflect the version of the `api.lsst.codes` API in
use (currently `1.0`, documentation pending).
Auth must be one of `none`, `basic`, or `bitly-proxy`. It represents
the way in which the microservice will authenticate to GitHub: either it
doesn't need to, it uses HTTP Basic Auth with a username and service
token, or it uses the Bitly OAuth2 Proxy with a username, a password,
and the proxy starting-OAuth2 endpoint.
## Provided Functionality
`sqre-apikit` provides one module, `apikit`, which contains a function,
`set_flask_metadata`, and a class, `APIFlask`.
The function is designed to add the metadata route to an existing Flask
app, and the class is designed to return a subclass of
`flask.Flask` which has the metadata route already baked into it.
## Installation
`sqre-apikit` runs on Python 2.7 or 3.5. You can install it with
```bash
pip install sqre-apikit
```
This will also install the dependency `Flask`.
## Example usage
### `apikit.set_flask_metadata()`
```python
import apikit
import flask
app = flask.Flask("Hello")
apikit.set_flask_metadata(app,
version="0.0.1",
repository="http://example.repo",
description="Hello World App")
```
### `apikit.APIFlask`
```python
import apikit
app = apikit.APIFlask(name="Hello",
version="0.0.1",
repository="http://example.repo",
description="Hello World App")
```
## Development
To develop apikit, create a Python virtual environment, and
```bash
git clone https://github.com/lsst-sqre/sqre-apikit.git
cd sqre-apikit
virtualenv venv
. venv/bin/activate
pip install -r requirements.txt
python setup.py develop
```
Tests can be run with [pytest](http://pytest.org/latest/):
```bash
py.test tests
```
# sqre-apikit
LSST DM SQuaRE microservice convenience tools.
## Rationale
In order to create a microservice hosted behind https://api.lsst.codes,
a service will need to provide a route on `/metadata` and
`/v{{api_version}}/metadata`. That route must serve appropriate
metadata about the service.
### Metadata format
The metadata served must be a JSON object, and must contain the
following fields:
`name`: `str`
`version`: `str`
`repository`: `str`
`description`: `str`
`api_version`: `str`
`auth`: `str`
The fields `name`, `version`, `api_version`, and `description` are
arbitrary, although semantic versioning is strongly encouraged, and the
API version should reflect the version of the `api.lsst.codes` API in
use (currently `1.0`, documentation pending).
Auth must be one of `none`, `basic`, or `bitly-proxy`. It represents
the way in which the microservice will authenticate to GitHub: either it
doesn't need to, it uses HTTP Basic Auth with a username and service
token, or it uses the Bitly OAuth2 Proxy with a username, a password,
and the proxy starting-OAuth2 endpoint.
## Provided Functionality
`sqre-apikit` provides one module, `apikit`, which contains a function,
`set_flask_metadata`, and a class, `APIFlask`.
The function is designed to add the metadata route to an existing Flask
app, and the class is designed to return a subclass of
`flask.Flask` which has the metadata route already baked into it.
## Installation
`sqre-apikit` runs on Python 2.7 or 3.5. You can install it with
```bash
pip install sqre-apikit
```
This will also install the dependency `Flask`.
## Example usage
### `apikit.set_flask_metadata()`
```python
import apikit
import flask
app = flask.Flask("Hello")
apikit.set_flask_metadata(app,
version="0.0.1",
repository="http://example.repo",
description="Hello World App")
```
### `apikit.APIFlask`
```python
import apikit
app = apikit.APIFlask(name="Hello",
version="0.0.1",
repository="http://example.repo",
description="Hello World App")
```
## Development
To develop apikit, create a Python virtual environment, and
```bash
git clone https://github.com/lsst-sqre/sqre-apikit.git
cd sqre-apikit
virtualenv venv
. venv/bin/activate
pip install -r requirements.txt
python setup.py develop
```
Tests can be run with [pytest](http://pytest.org/latest/):
```bash
py.test tests
```
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
Built Distribution
Close
Hashes for sqre-uservice-status-0.0.7.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ebc69e3230ca805532a69c8161af74b6a6334b47db5b7578747b269ee0fdf7f |
|
MD5 | dd89e235c6b21414e442ad3277ec9d21 |
|
BLAKE2b-256 | b5b5f501bda1fff104e8eedd9a113b55d669c423c2881d8d58bc4c120bcca581 |
Close
Hashes for sqre_uservice_status-0.0.7-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3a283f29815a62978cba3edeab6d674c1780b695064252ff49da0b5af9a873ed |
|
MD5 | 0649f07e7962d47d4429086b5263269b |
|
BLAKE2b-256 | 6a98cf8163cd95f98cb73f361f50aadef7b06098c49b7c9b9b18abb8a4c3b5ce |