Skip to content

Commit

Permalink
Add about endpoint with version number
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartcampbell committed Dec 20, 2023
1 parent f8debba commit 6a5abd7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/nsls2api/api/models/stats_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 11 additions & 1 deletion src/nsls2api/api/v1/stats_api.py
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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

0 comments on commit 6a5abd7

Please sign in to comment.