poiesis.api package¶
Subpackages¶
- poiesis.api.auth package
- poiesis.api.controllers package
- poiesis.api.tes package
- Submodules
- poiesis.api.tes.models module
- Module contents
Submodules¶
poiesis.api.api_handlers module¶
poiesis.api.app module¶
Main module of the Poiesis API.
This module creates and configures the connexion app.
poiesis.api.asgi module¶
Configure Gunicorn to run the ASGI server.
Uses Uvicorn as the worker for the Poiesis API.
- poiesis.api.asgi.import_app_from_string(import_string)[source]¶
Import an application object from a string.
- Parameters:
import_string (str) – The import string in the format “<module>:<attribute>”.
- Returns:
The imported attribute object.
- Return type:
Any
- Raises:
ImportError – If the import string is invalid or the attribute is not found.
poiesis.api.constants module¶
Poiesis API constants.
- class poiesis.api.constants.PoiesisApiConstants[source]¶
Bases:
objectConstants used in the Poiesis API.
- SPEC_GIT_HASH¶
The git hash of the OpenAPI specification that the API uses. This refers to the git commit from where the specification was copied and then modified if needed without changing the TES specification.
- Note: The openAPI specification file is named as
“<SPEC_GIT_HASH>.openapi.yaml”, but it is not verbatim.
- class Auth(AUTH='dummy')[source]¶
Bases:
objectConstants used in the authentication.
- AUTH¶
The authentication method.
- AUTH: Literal['oidc', 'dummy'] = 'dummy'¶
- class OIDC[source]¶
Bases:
objectConstants used in the generic OpenID Connect client.
- ISSUER¶
The OpenID Connect issuer URL.
- CLIENT_ID¶
The OpenID Connect client identifier.
- INTROSPECT_ENDPOINT¶
URL to validate tokens (optional).
- CLIENT_ID = None¶
- DISCOVERY_URL = 'None/.well-known/openid-configuration'¶
- ISSUER = None¶
- BASE_PATH = 'ga4gh/tes/v1'¶
- class Gunicorn[source]¶
Bases:
objectConstants used in the Gunicorn server.
- PORT¶
The port on which the Gunicorn server listens.
- WORKERS¶
The number of Gunicorn workers. Note: Defaults to the (number of CPU cores) * 2 + 1.
- TIMEOUT¶
The timeout for the Gunicorn server.
- HOST = '127.0.0.1'¶
- PORT = '8000'¶
- TIMEOUT = '120'¶
- WORKERS = None¶
- SPEC_GIT_HASH = 'c4c17c9'¶
- TES_VERSION = 'v1.1.0'¶
poiesis.api.exceptions module¶
Exceptions and their handlers for the platform backend.
- exception poiesis.api.exceptions.APIException(message=None, details=None)[source]¶
Bases:
ExceptionBase exception for all API errors.
- error_code = 'internal_error'¶
- status_code = 500¶
- exception poiesis.api.exceptions.BadRequestException(message=None, details=None)[source]¶
Bases:
APIExceptionThe request was invalid or cannot be served.
- error_code = 'bad_request'¶
- status_code = 400¶
- exception poiesis.api.exceptions.DBException(message=None, details=None)[source]¶
Bases:
APIExceptionAn error occurred with the database.
- error_code = 'db_error'¶
- status_code = 500¶
- exception poiesis.api.exceptions.InternalServerException(message=None, details=None)[source]¶
Bases:
APIExceptionAn unexpected condition was encountered.
- error_code = 'internal_error'¶
- status_code = 500¶
- exception poiesis.api.exceptions.NotFoundException(message=None, details=None)[source]¶
Bases:
APIExceptionThe requested resource was not found.
- error_code = 'not_found'¶
- status_code = 404¶
- exception poiesis.api.exceptions.UnauthorizedException(message=None, details=None)[source]¶
Bases:
APIExceptionThe request is unauthorized.
- error_code = 'unauthorized'¶
- status_code = 401¶
poiesis.api.models module¶
Models used by the API.
These are extensions of the models defined in the TES API specification.
- class poiesis.api.models.MinimalTesTask(**data)[source]¶
Bases:
BaseModelMinimal task model.
- id: str¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- state: str¶
- class poiesis.api.models.TesListTasksFilter(**data)[source]¶
Bases:
BaseModelFilter for listing tasks.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- name_prefix: str | None¶
- tag_key: list[str] | None¶
- tag_value: list[str] | None¶
poiesis.api.security module¶
Handles security for the API.
Entrypoint of token validations.
- poiesis.api.security.validate_bearer_token(token)[source]¶
Validate bearer token.
This function validates a bearer token and returns the token info. This info is then added to the context for use in the API handlers.
- Parameters:
token (
str) – The bearer token.- Returns:
The token info.
- Return type:
dict[str, Any]
poiesis.api.utils module¶
Utility functions for the API.
- poiesis.api.utils.get_oidc_introspect_url()[source]¶
Get the OIDC introspect URL.
- Returns:
The OIDC introspect URL.
- Return type:
str
- poiesis.api.utils.get_oidc_jwks_uri()[source]¶
Get the OIDC JWKS URI from the discovery document.
- Return type:
str
- poiesis.api.utils.pydantic_to_dict_response(func)[source]¶
Decorator that converts a Pydantic model return value to a dict.
This decorator is useful for API endpoints that return Pydantic models, automatically converting the model to a dictionary using the model_dump method.
- Parameters:
func (
Callable[...,Any]) – The function to decorate.- Return type:
Callable[...,Any]- Returns:
A wrapped function that converts Pydantic model returns to dictionaries.
Example
```python from pydantic import BaseModel
- class User(BaseModel):
name: str age: int
@pydantic_to_dict_response def get_user() -> User:
return User(name=”John”, age=30)
# When called, get_user() will return a dict: {“name”: “John”, “age”: 30} ```
Module contents¶
poiesis API.