17 lines
594 B
Python
17 lines
594 B
Python
"""API methods for listing API endpoints."""
|
|
|
|
import aiohttp
|
|
from pydantic import TypeAdapter
|
|
|
|
from ekilex.model.endpoints import EndpointDetail
|
|
from ekilex.protocol import EkilexAPIBase
|
|
|
|
|
|
class EndpointsMixin:
|
|
async def get_endpoints(self: EkilexAPIBase) -> list[EndpointDetail]:
|
|
adapter = TypeAdapter(list[EndpointDetail])
|
|
|
|
async with aiohttp.ClientSession(headers=self.headers) as client:
|
|
async with client.get(f"{self.url}/api/endpoints") as response:
|
|
endpoints = adapter.validate_json(await response.text())
|
|
return endpoints
|