From 6a5abd793c33d3d291cd404b6fba5d467afcba45 Mon Sep 17 00:00:00 2001 From: Stuart Campbell Date: Tue, 19 Dec 2023 20:39:15 -0500 Subject: [PATCH] Add about endpoint with version number --- src/nsls2api/api/models/stats_model.py | 5 +++++ src/nsls2api/api/v1/stats_api.py | 12 +++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/nsls2api/api/models/stats_model.py b/src/nsls2api/api/models/stats_model.py index 0c064ba3..e0c2b897 100644 --- a/src/nsls2api/api/models/stats_model.py +++ b/src/nsls2api/api/models/stats_model.py @@ -6,3 +6,8 @@ class StatsModel(pydantic.BaseModel): proposal_count: int beamline_count: int commissioning_proposal_count: int + + +class AboutModel(pydantic.BaseModel): + description: str + version: str diff --git a/src/nsls2api/api/v1/stats_api.py b/src/nsls2api/api/v1/stats_api.py index f740d5df..3b3d6250 100644 --- a/src/nsls2api/api/v1/stats_api.py +++ b/src/nsls2api/api/v1/stats_api.py @@ -1,6 +1,7 @@ import fastapi -from nsls2api.api.models.stats_model import StatsModel +from nsls2api._version import version as api_version +from nsls2api.api.models.stats_model import StatsModel, AboutModel from nsls2api.services import ( proposal_service, facility_service, @@ -24,3 +25,12 @@ async def stats(): commissioning_proposal_count=commissioning, ) return model + + +@router.get("/about", response_model=AboutModel) +async def about(): + model = AboutModel( + version=api_version, + description="NSLS-II Facility API" + ) + return model