Skip to main content

Build Status

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 three functions, set_flask_metadata, add_metadata_route, and return_metadata, and a class, APIFlask.

The set_flask_metadata sets metadata on an existing Flask app and adds metadata routes. add_metadata_route is designed to add routing for each component in the route list to an existing Flask app. return_metadata returns the JSON representation of the metadata for the service.

The APIFlask class creates an instance of a subclass of flask.Flask which has the metadata added and the route(s) already baked into it.

The class comes with a method, add_route_prefix, which adds the metadata route underneath another route. This is useful, for instance, if wiring the microservice up through Kubernetes and its Ingress resources, which provide routing but not rewriting.

Installation

sqre-apikit runs on Python 2.7 or 3.5. You can install it with

pip install sqre-apikit

This will also install the dependency Flask.

Example usage

apikit.set_flask_metadata()

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

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

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:

py.test tests

Metadata

Release files for sqre-apikit 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sqre-apikit 0.1.3
File Size Uploaded Provenance
sqre-apikit-0.1.3.tar.gz 9.0 kB Without provenance Details

Release files / sqre-apikit-0.1.3.tar.gz

Download URL sqre-apikit-0.1.3.tar.gz
Size 9.0 kB
Tags Source
SHA-256 checksum
How to use checksums
e3af08de346287f40bbaa0e05c7df76f66910bed1960a51501085c9203dd6692
BLAKE2b-256 checksum
How to use checksums
a224b2e63ff7eea173ac0f1c584bd1ed8b2e375d8602df99cf94a21fa96f0936
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.7.6

Security for sqre-apikit 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page