Skip to content

Commit 7ec3d19

Browse files
committed
migrated service extras endpoint
1 parent 11aa54e commit 7ec3d19

File tree

1 file changed

+33
-4
lines changed

1 file changed

+33
-4
lines changed
Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,43 @@
1-
import arrow
2-
from fastapi import APIRouter
1+
import logging
2+
from typing import Annotated, Any
3+
4+
from fastapi import APIRouter, Depends, FastAPI, HTTPException, status
5+
from models_library.generics import Envelope
36
from models_library.services_types import ServiceKey, ServiceVersion
7+
from servicelib.fastapi.dependencies import get_app
8+
9+
from ... import exceptions, registry_proxy
410

511
router = APIRouter()
612

13+
log = logging.getLogger(__name__)
14+
715

816
@router.get("/service_extras/{service_key}/{service_version}")
917
async def list_service_extras(
18+
the_app: Annotated[FastAPI, Depends(get_app)],
1019
service_key: ServiceKey,
1120
service_version: ServiceVersion,
1221
):
13-
# NOTE: sync url in docker/healthcheck.py with this entrypoint!
14-
return f"{__name__}.health_check@{arrow.utcnow().isoformat()}"
22+
log.debug(
23+
"Client does service_extras_by_key_version_get request with service_key %s, service_version %s",
24+
service_key,
25+
service_version,
26+
)
27+
try:
28+
service_extras = await registry_proxy.get_service_extras(
29+
the_app, service_key, service_version
30+
)
31+
return Envelope[dict[str, Any]](data=service_extras)
32+
except exceptions.ServiceNotAvailableError as err:
33+
raise HTTPException(
34+
status_code=status.HTTP_404_NOT_FOUND, detail=f"{err}"
35+
) from err
36+
except exceptions.RegistryConnectionError as err:
37+
raise HTTPException(
38+
status_code=status.HTTP_401_UNAUTHORIZED, detail=f"{err}"
39+
) from err
40+
except Exception as err:
41+
raise HTTPException(
42+
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, detail=f"{err}"
43+
) from err

0 commit comments

Comments
 (0)