diff --git a/geomagio/api/ws/algorithms.py b/geomagio/api/ws/algorithms.py index bcc42a3590b1804c87d95ada48679e2ba7584b4c..fe6d3207853a6284e0449c62dfb4db248cd97719 100644 --- a/geomagio/api/ws/algorithms.py +++ b/geomagio/api/ws/algorithms.py @@ -1,3 +1,4 @@ +from os import name from fastapi import APIRouter, Depends, HTTPException from starlette.responses import Response @@ -14,7 +15,11 @@ from .data import format_timeseries, get_data_factory, get_data_query, get_times router = APIRouter() -@router.get("/algorithms/dbdt/") +@router.get( + "/algorithms/dbdt/", + description="First order derivative at requested interval", + name="Dbdt Algorithm", +) def get_dbdt( query: DataApiQuery = Depends(get_data_query), data_factory: TimeseriesFactory = Depends(get_data_factory), @@ -31,7 +36,12 @@ def get_dbdt( ) -@router.post("/algorithms/residual", response_model=Reading) +@router.post( + "/algorithms/residual", + description="Caclulates new absolutes and baselines from reading\n\n" + + "Returns posted reading object with updated values", + response_model=Reading, +) def calculate_residual(reading: Reading, adjust_reference: bool = True): try: return calculate(reading=reading, adjust_reference=adjust_reference) diff --git a/geomagio/api/ws/data.py b/geomagio/api/ws/data.py index 873de6db15d8cb305ee12ae469a5f9ac26e96406..bec7e546e39d1b3452597d7e428d6afac3f3db2b 100644 --- a/geomagio/api/ws/data.py +++ b/geomagio/api/ws/data.py @@ -158,7 +158,12 @@ def get_timeseries(data_factory: TimeseriesFactory, query: DataApiQuery) -> Stre router = APIRouter() -@router.get("/data/") +@router.get( + "/data/", + name="Request data", + description="Returns timeseries depending on query parameters\n\n" + + "Limited to 345600 data points", +) def get_data( query: DataApiQuery = Depends(get_data_query), ) -> Response: diff --git a/geomagio/api/ws/elements.py b/geomagio/api/ws/elements.py index a1379ad77df8ffbd7f8e3cdea0b40ee92ce88011..06da476a84d61ae94861472582113bbcc52bb5b7 100644 --- a/geomagio/api/ws/elements.py +++ b/geomagio/api/ws/elements.py @@ -8,7 +8,10 @@ from .Element import ELEMENTS router = APIRouter() -@router.get("/elements/") +@router.get( + "/elements/", + description="Information regarding available geomagnetic elements", +) def get_elements() -> Dict: features = [] for e in ELEMENTS: diff --git a/geomagio/api/ws/metadata.py b/geomagio/api/ws/metadata.py index 300dc3340428fcef198621378b226d9ee316d0b2..fb5627a0578702cdd2e763a4fe09e586ae1a51b9 100644 --- a/geomagio/api/ws/metadata.py +++ b/geomagio/api/ws/metadata.py @@ -10,7 +10,11 @@ from ..db import MetadataDatabaseFactory router = APIRouter() -@router.get("/metadata", response_model=List[Metadata]) +@router.get( + "/metadata", + description="Search metadata records with query parameters(excludes id and metadata id)", + response_model=List[Metadata], +) async def get_metadata( category: MetadataCategory = None, starttime: UTCDateTime = None, @@ -36,6 +40,6 @@ async def get_metadata( status=status, ) metas = await MetadataDatabaseFactory(database=database).get_metadata( - **query.datetime_dict(exclude={"id"}) + **query.datetime_dict(exclude={"id", "metadata_id"}) ) return metas diff --git a/geomagio/api/ws/observatories.py b/geomagio/api/ws/observatories.py index 3e4fe928cc99498bd33443b23105f118d57b6e46..1a8c797c258952ba8793f12a903ffb70b93b6abf 100644 --- a/geomagio/api/ws/observatories.py +++ b/geomagio/api/ws/observatories.py @@ -8,7 +8,10 @@ from .Observatory import OBSERVATORIES, OBSERVATORY_INDEX router = APIRouter() -@router.get("/observatories/") +@router.get( + "/observatories/", + description="Information regarding available geomagnetic observatories", +) def get_observatories() -> Dict: return { "type": "FeatureCollection", @@ -16,7 +19,10 @@ def get_observatories() -> Dict: } -@router.get("/observatories/{id}") +@router.get( + "/observatories/{id}", + description="Search observatories by 3-letter observatory code", +) async def get_observatory_by_id(id: str) -> Dict: try: return OBSERVATORY_INDEX[id].geojson()