apifrom.adapters.gcp_functionsο
Google Cloud Functions adapter for APIFromAnything.
This module provides an adapter for running APIFromAnything applications on Google Cloud Functions.
Overviewο
Classes
Classesο
- class apifrom.adapters.gcp_functions.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)[source]ο
- Parameters:
debug (bool)
title (str)
description (str)
version (str)
docs_url (str)
openapi_config (apifrom.docs.openapi.OpenAPIConfig | None)
swagger_ui_config (apifrom.docs.swagger_ui.SwaggerUIConfig | None)
enable_docs (bool)
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.
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.
- class apifrom.adapters.gcp_functions.CloudFunctionAdapter(app)[source]ο
- Parameters:
app (apifrom.core.app.API)
Adapter for running APIFromAnything applications on Google Cloud Functions.
This adapter translates between Google Cloud Functions request/response objects and APIFromAnythingβs Request/Response objects.
Initialize the Cloud Function adapter.
- param app:
The APIFromAnything application to adapt.
- apifrom.adapters.gcp_functions._create_cloud_function_response(response)ο
Create a Cloud Function response from an APIFromAnything response.
- param response:
The APIFromAnything response or a dictionary
- returns:
A response object that Cloud Functions can understand
- apifrom.adapters.gcp_functions._create_request(request)ο
Create a Request object from a Cloud Function request.
- param request:
The Google Cloud Functions request object.
- returns:
A Request object.
- apifrom.adapters.gcp_functions.handle(request)ο
Handle a Google Cloud Functions request.
- param request:
The Google Cloud Functions request object.
- returns:
A response that can be returned from a Cloud Function.
- class apifrom.adapters.gcp_functions.Request(request=None, path_params=None, method=None, path=None, query_params=None, headers=None, body=None, client_ip=None)[source]ο
Request class for APIFromAnything.
This class wraps a Starlette request and provides methods for accessing request data in a convenient way.
- apifrom.adapters.gcp_functions._requestο
The underlying Starlette request.
- apifrom.adapters.gcp_functions.path_paramsο
Path parameters extracted from the URL.
- apifrom.adapters.gcp_functions.query_paramsο
Query parameters extracted from the URL.
- apifrom.adapters.gcp_functions.headersο
HTTP headers.
- apifrom.adapters.gcp_functions.methodο
HTTP method.
- apifrom.adapters.gcp_functions.pathο
Request path.
- apifrom.adapters.gcp_functions._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.
- class apifrom.adapters.gcp_functions.Response(content=None, status_code=200, headers=None, content_type='application/json')[source]ο
Response class for APIFromAnything.
This class represents an HTTP response and provides methods for setting response data, status code, and headers.
- apifrom.adapters.gcp_functions.contentο
The response content.
- apifrom.adapters.gcp_functions.status_codeο
The HTTP status code.
- apifrom.adapters.gcp_functions.headersο
HTTP headers.
- apifrom.adapters.gcp_functions.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.