apifrom.adapters.azure_functions ================================ Azure Functions adapter for APIFromAnything. This module provides an adapter for running APIFromAnything applications on Azure Functions. .. py:currentmodule:: apifrom.adapters.azure_functions Overview -------- **Classes** * :py:class:`API` * :py:class:`AzureFunctionAdapter` * :py:class:`Request` * :py:class:`Response` Classes ------- .. py:class:: API(debug = False, title = 'APIFromAnything API', description = 'API created with APIFromAnything', version = '1.0.0', docs_url = '/docs', openapi_config = None, swagger_ui_config = None, enable_docs = True) Main application container for APIFromAnything. This class serves as the central registry for all API endpoints, middleware, and configuration. It provides methods for registering endpoints, middleware, and starting the server. .. attribute:: router The router instance for managing routes. :type: Router .. attribute:: middleware List of middleware instances. :type: list .. attribute:: debug Whether to run in debug mode. :type: bool .. attribute:: title The title of the API. :type: str .. attribute:: description The description of the API. :type: str .. attribute:: version The version of the API. :type: str .. attribute:: docs_url The URL for the API documentation. :type: str Initialize a new API instance. :param debug: Whether to run in debug mode. :param title: The title of the API. :param description: The description of the API. :param version: The version of the API. :param docs_url: The URL for the API documentation. :param openapi_config: Configuration for OpenAPI documentation. :param swagger_ui_config: Configuration for Swagger UI. :param enable_docs: Whether to enable API documentation. .. py:class:: AzureFunctionAdapter(app) Adapter for running APIFromAnything applications on Azure Functions. This adapter translates between Azure Functions request/response objects and APIFromAnything's Request/Response objects. Initialize the Azure Function adapter. :param app: The APIFromAnything application to adapt. .. :: app .. method:: _create_azure_function_response(response) Create an Azure Function response from a Response object. :param response: The Response object. :returns: An Azure Function HTTP response object. .. method:: _create_request(req) Create a Request object from an Azure Function request. :param req: The Azure Function HTTP request object. :returns: A Request object. .. method:: handle(req) Handle an Azure Function HTTP request. :param req: The Azure Function HTTP request object. :returns: An Azure Function HTTP response object. .. py:class:: Request(request = None, path_params = None, method = None, path = None, query_params = None, headers = None, body = None, client_ip = None) Request class for APIFromAnything. This class wraps a Starlette request and provides methods for accessing request data in a convenient way. .. attribute:: _request The underlying Starlette request. .. attribute:: path_params Path parameters extracted from the URL. .. attribute:: query_params Query parameters extracted from the URL. .. attribute:: headers HTTP headers. .. attribute:: method HTTP method. .. attribute:: path Request path. .. attribute:: _body Cached request body. Initialize a new Request instance. :param request: The underlying Starlette request. :param path_params: Path parameters extracted from the URL. :param method: The HTTP method. :param path: The request path. :param query_params: Query parameters. :param headers: HTTP headers. :param body: Request body. :param client_ip: Client IP address. .. py:class:: Response(content = None, status_code = 200, headers = None, content_type = 'application/json') Response class for APIFromAnything. This class represents an HTTP response and provides methods for setting response data, status code, and headers. .. attribute:: content The response content. .. attribute:: status_code The HTTP status code. .. attribute:: headers HTTP headers. .. attribute:: content_type The content type of the response. Initialize a new Response instance. :param content: The response content. :param status_code: The HTTP status code. :param headers: HTTP headers. :param content_type: The content type of the response.