Endpoint¶
aana.api.Endpoint
¶
Endpoint(name, path, summary, admin_required=False, active_subscription_required=False, defer_option=DeferOption.OPTIONAL, initialized=False, event_handlers=None)
Class used to represent an endpoint.
ATTRIBUTE | DESCRIPTION |
---|---|
name |
Name of the endpoint.
TYPE:
|
path |
Path of the endpoint (e.g. "/video/transcribe").
TYPE:
|
summary |
Description of the endpoint that will be shown in the API documentation.
TYPE:
|
admin_required |
Flag indicating if the endpoint requires admin access.
TYPE:
|
active_subscription_required |
Flag indicating if the endpoint requires an active subscription.
TYPE:
|
defer_option |
Defer option for the endpoint (always, never, optional).
TYPE:
|
event_handlers |
The list of event handlers to register for the endpoint.
TYPE:
|
initialize
¶
Initialize the endpoint.
Redefine this method to add initialization logic for the endpoint (e.g. create a handle to the deployment). Call super().initialize() to ensure the endpoint is initialized.
Example
Source code in aana/api/api_generation.py
run
¶
The main method of the endpoint that is called when the endpoint receives a request.
Redefine this method to implement the logic of the endpoint.
Example
Source code in aana/api/api_generation.py
register
¶
Register the endpoint in the FastAPI application.
PARAMETER | DESCRIPTION |
---|---|
app |
FastAPI application.
TYPE:
|
custom_schemas |
Dictionary containing custom schemas.
TYPE:
|
event_manager |
Event manager for the application.
TYPE:
|
Source code in aana/api/api_generation.py
get_request_model
¶
Generate the request Pydantic model for the endpoint.
RETURNS | DESCRIPTION |
---|---|
type[BaseModel]
|
type[BaseModel]: Request Pydantic model. |
Source code in aana/api/api_generation.py
get_response_model
¶
Generate the response Pydantic model for the endpoint.
RETURNS | DESCRIPTION |
---|---|
type[BaseModel]
|
type[BaseModel]: Response Pydantic model. |
Source code in aana/api/api_generation.py
is_streaming_response
¶
Check if the endpoint returns a streaming response.
RETURNS | DESCRIPTION |
---|---|
bool
|
True if the endpoint returns a streaming response, False otherwise.
TYPE:
|
Source code in aana/api/api_generation.py
send_usage_event
¶
Send a usage event to the LAGO API service.
PARAMETER | DESCRIPTION |
---|---|
api_key |
The API key information.
TYPE:
|
metric |
The metric code.
TYPE:
|
properties |
The properties of the event (usage data, e.g. {"count": 10}).
TYPE:
|