REST API fixes

This commit is contained in:
Dinesh Yeduguru 2025-01-16 13:42:52 -08:00
parent 59eeaf7f81
commit 5d0eaac87e
8 changed files with 51 additions and 43 deletions

View file

@ -12,6 +12,7 @@ from pydantic import BaseModel
@json_schema_type
class ProviderInfo(BaseModel):
api: str
provider_id: str
provider_type: str

View file

@ -44,15 +44,18 @@ class DistributionInspectImpl(Inspect):
ret = []
for api, providers in run_config.providers.items():
ret.append(
ProviderInfo(
provider_id=p.provider_id,
provider_type=p.provider_type,
)
for p in providers
ret.extend(
[
ProviderInfo(
api=api,
provider_id=p.provider_id,
provider_type=p.provider_type,
)
for p in providers
]
)
return ret
return ListProvidersResponse(data=ret)
async def list_routes(self) -> ListRoutesResponse:
run_config = self.config.run_config
@ -61,16 +64,18 @@ class DistributionInspectImpl(Inspect):
all_endpoints = get_all_api_endpoints()
for api, endpoints in all_endpoints.items():
providers = run_config.providers.get(api.value, [])
ret.append(
RouteInfo(
route=e.route,
method=e.method,
provider_types=[p.provider_type for p in providers],
)
for e in endpoints
ret.extend(
[
RouteInfo(
route=e.route,
method=e.method,
provider_types=[p.provider_type for p in providers],
)
for e in endpoints
]
)
return ret
return ListRoutesResponse(data=ret)
async def health(self) -> HealthInfo:
return HealthInfo(status="OK")