main.py - added some debug endpoints

This commit is contained in:
Oscar Krause 2022-12-20 18:24:59 +01:00
parent fad0545942
commit c647363b6d
2 changed files with 31 additions and 0 deletions

View File

@ -2,6 +2,24 @@
Minimal Delegated License Service (DLS). Minimal Delegated License Service (DLS).
## Endpoints
### `GET /`
Just a simple *hello world* endpoint.
### `GET /status`
Status endpoint, used for *healthcheck*.
### `GET /-/origins`
List registered origins.
### `GET /-/leases`
List current leases.
# Setup (Docker) # Setup (Docker)
**Run this on the Docker-Host** **Run this on the Docker-Host**

View File

@ -5,6 +5,7 @@ from os.path import join, dirname
from os import getenv from os import getenv
from fastapi import FastAPI, HTTPException from fastapi import FastAPI, HTTPException
from fastapi.requests import Request from fastapi.requests import Request
from fastapi.encoders import jsonable_encoder
import json import json
from datetime import datetime from datetime import datetime
from dateutil.relativedelta import relativedelta from dateutil.relativedelta import relativedelta
@ -60,6 +61,18 @@ async def status(request: Request):
return JSONResponse({'status': 'up'}) return JSONResponse({'status': 'up'})
@app.get('/-/origins')
async def _origins(request: Request):
response = list(map(lambda x: jsonable_encoder(x), db['origin'].all()))
return JSONResponse(response)
@app.get('/-/leases')
async def _leases(request: Request):
response = list(map(lambda x: jsonable_encoder(x), db['lease'].all()))
return JSONResponse(response)
# venv/lib/python3.9/site-packages/nls_core_service_instance/service_instance_token_manager.py # venv/lib/python3.9/site-packages/nls_core_service_instance/service_instance_token_manager.py
@app.get('/client-token') @app.get('/client-token')
async def client_token(): async def client_token():