API server providing access to Red Hat Enterprise Linux roadmap information.
- Python 3.12 or later.
- A container runtime such as
docker
orpodman
. - To use the
/relevant/
APIs, create an offline token in order to generate an access token.
In order to create a local installation of psycopg
, the the following packages and configuration are required.
RHEL
PYTHON_VERSION=3.12
yum -y install "python${PYTHON_VERSION}-devel" gcc libpq-devel
Debian
PYTHON_VERSION=3.12
apt install -y \
python3-pip \
"python${PYTHON_VERSION}-dev" \
"python${PYTHON_VERSION}-venv" \
gcc libpq-dev
libpq
is required and pg_config
must be in the PATH
. These directions assume zsh
, but you can run brew info libpq
for instructions specific to your shell.
brew install libpq
echo 'export PATH="/opt/homebrew/opt/libpq/bin:$PATH"' >> ~/.zshrc
Create a virtual environment, install the requirements, and run the server.
make install
make start-db run
This runs a server using the default virtual environment. Documentation can be found at http://127.0.0.1:8081/docs
.
The /relevant/
APIs query host inventory in order to return relevant results. To avoid querying the inventory API and return fixture data, set ROADMAP_DEV=1
in the environment.
export ROADMAP_DEV=1
make run
This will return data from tests/fixtures/, making it easy to change the response for testing and development.
In order to query host inventory, a Red Hat API access token is required. Access tokens are only valid for fifteen minutes and require an offline token in order to generate new ones.
export RH_OFFLINE_TOKEN="[offline token]"
export RH_TOKEN="$(./scripts/get-redhat-access-token.py)"
Use the access token in the request header. Here is an example using httpie.
http localhost:8081/api/roadmap/v1/relevant/lifecycle/rhel/ \
Authorization:"Bearer $RH_TOKEN"
Install the developer tools and run the server.
make install-dev
make start-db run
Alternatively you may create your own virtual environment, install the requirements, and run the server manually.
# After creating and activating a virtual environment
pip install -r requirements/requirements-dev-{Python version}.txt
fastapi run src/roadmap/main.py --reload --host 127.0.0.1 --port 8081
The database runs in a container and contains data already. To specify a different container image, set DB_IMAGE
.
export DB_IMAGE=digital-roadmap:latest
make start-db
To restart the database container, run make start-db
.
To stop the database, run make stop-db
.
Lint and run tests.
make lint
make test
All make
targets use the default virtual environment. If you want to use your own virtual environment, run the commands directly.
ruff check --fix
ruff format
pytest
pre-commit run --all-files
Python 3.12 and 3.13 must be available in order to generate requirements files.
The following files are used for updating requirements:
requirements.in
- Direct project dependenciesrequirements-dev.in
- Requirements for developmentrequirements-test.in
- Requirements for running testsconstraints.txt
- Indirect project dependencies
make freeze
Commit the changes.