From c647363b6dc77b3135fcf69da512bd4f7b846134 Mon Sep 17 00:00:00 2001 From: Oscar Krause Date: Tue, 20 Dec 2022 18:24:59 +0100 Subject: [PATCH] main.py - added some debug endpoints --- README.md | 18 ++++++++++++++++++ app/main.py | 13 +++++++++++++ 2 files changed, 31 insertions(+) diff --git a/README.md b/README.md index 6ad402e..f42e3b2 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,24 @@ 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) **Run this on the Docker-Host** diff --git a/app/main.py b/app/main.py index 7e545ab..e09ebcc 100644 --- a/app/main.py +++ b/app/main.py @@ -5,6 +5,7 @@ from os.path import join, dirname from os import getenv from fastapi import FastAPI, HTTPException from fastapi.requests import Request +from fastapi.encoders import jsonable_encoder import json from datetime import datetime from dateutil.relativedelta import relativedelta @@ -60,6 +61,18 @@ async def status(request: Request): 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 @app.get('/client-token') async def client_token():