An ASGI framework to build HTTP API's from a Python module structure.
Go to file
Maxime Alves LIRMM@home 7ef6e78010 [deps] Updated dependencies and added files for standard packaging.
The halfapi-cli tool needs to be installed using [cli] option :
pip3 install -e .[cli]
2020-07-29 22:07:16 +02:00
conf [release][0.1.0] First HalfAPI release 2020-07-23 17:54:47 +02:00
halfapi [cli] Added init-project command and cli tests 2020-07-29 22:07:16 +02:00
scripts [query] add fields list to query 2020-07-20 11:20:58 +02:00
tests [cli] Added init-project command and cli tests 2020-07-29 22:07:16 +02:00
.gitignore [middleware] put AclCallerMiddleware in lib file 2020-07-08 17:12:58 +02:00
CHANGELOG.md [release][0.1.0] First HalfAPI release 2020-07-23 17:54:47 +02:00
LICENSE [release][0.1.0] First HalfAPI release 2020-07-23 17:54:47 +02:00
MANIFEST.in [deps] Updated dependencies and added files for standard packaging. 2020-07-29 22:07:16 +02:00
README.md [release][0.1.0] First HalfAPI release 2020-07-23 17:54:47 +02:00
pyproject.toml [deps] Updated dependencies and added files for standard packaging. 2020-07-29 22:07:16 +02:00
pytest.ini [cli] Added init-project command and cli tests 2020-07-29 22:07:16 +02:00
requirements.txt [deps] Updated dependencies and added files for standard packaging. 2020-07-29 22:07:16 +02:00
setup.cfg [deps] Updated dependencies and added files for standard packaging. 2020-07-29 22:07:16 +02:00
setup.py [deps] Updated dependencies and added files for standard packaging. 2020-07-29 22:07:16 +02:00

README.md

HalfAPI

This Python-based ASGI application aims to provide the core functionality to multiple API domains.

It's developed at the LIRMM in Montpellier, France.

The name "halfAPI" comes from the deep relationship between it and halfORM, a project authored by Joël Maizi.

You'll need a database with the API details. You can find the database model in halfapi/models/api.sql

NOTE : The authentication module is deeply linked with auth_lirmm, so if you need to use the acl.connected function, you will need a running auth_lirmm server to get a token.

TODO : include a token generation tool for testing purpose.

Dependencies

  • python3
  • python3-pip
  • poetry
  • uvicorn

Installing

pip install .

As the project uses the poetry package manager, you first have to install it for the current user. Be sur to have pip binary directory ($HOME/.local/bin) included in your PATH.

pip3 install poetry

Be sur to include the bin directory of pip in your PATH.

Installation of the deps :

poetry install

If you need a domain, i.e: organigramme, just add -E organigramme to the command.

NOTE : You need to run poetry install before installing any domains (that depends on halfapi).

API database

Populate the API database with te server information, the domain's routes, and their ACL by running the following command :

poetry run halfapi dbupdate

NOTE: You need to have the domain's package installed if you want to populate the api routes module, as it check for the existence of the acl functions.

Database configuration

The api and domains' databases connection settings are stored by default in /etc/half_orm. Check halfORM documentation for more information on how to write these configuration files.

You can set the HALFORM_SECRET environment variable if you want to specify an authentication secret.

TODO : find a modular way to configure the database connection for each mounted domain

Running

Development mode

In the halfapi repository, type :

poetry run halfapi

If you need to launch the test suite (only works if you have pytest installed) :

poetry run pytest

Production

The production server may use different init systems. As our main server is Debian-based, we use systemd services to manage the api server. Find the right service files and configure them properly in order to make your production setup perfect.

cp conf/systemd/lirmm_api* /etc/systemd/system/
systemctl daemon-reload
systemctl start lirmm_api

To make it start at boot :

systemctl enable lirmm_api

To get the logs :

journalctl -f --unit lirmm_api