"""Poiesis API constants."""importosfromdataclassesimportdataclassfromfunctoolsimportlru_cachefromtypingimportLiteral,castfrompoiesis.constantsimportget_poiesis_constantsconstants=get_poiesis_constants()
[docs]@dataclass(frozen=True)classPoiesisApiConstants:"""Constants used in the Poiesis API. Attributes: 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. """SPEC_GIT_HASH="c4c17c9"TES_VERSION="v1.1.0"BASE_PATH="ga4gh/tes/v1"
[docs]@dataclass(frozen=True)classTask:"""Constants used in the Task."""NAME="poiesis-tes-task"
[docs]@dataclass(frozen=True)classGunicorn:"""Constants used in the Gunicorn server. Attributes: 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="0.0.0.0"ifconstants.ENVIRONMENT=="prod"else"127.0.0.1"# nosec B104PORT=os.getenv("POIESIS_API_SERVER_PORT","8000")WORKERS=os.getenv("POIESIS_UVICORN_WORKERS")TIMEOUT=os.getenv("POIESIS_UVICORN_TIMEOUT","120")
[docs]@dataclass(frozen=True)classAuth:"""Constants used in the authentication. Attributes: AUTH: The authentication method. """AUTH:Literal["oidc","dummy"]=cast(Literal["oidc","dummy"],os.getenv("AUTH_TYPE","dummy"))
[docs]@dataclass(frozen=True)classOIDC:"""Constants used in the generic OpenID Connect client. Attributes: ISSUER: The OpenID Connect issuer URL. CLIENT_ID: The OpenID Connect client identifier. INTROSPECT_ENDPOINT: URL to validate tokens (optional). """ISSUER=os.getenv("OIDC_ISSUER")CLIENT_ID=os.getenv("OIDC_CLIENT_ID")DISCOVERY_URL=(f"{str(ISSUER).rstrip('/')}/.well-known/openid-configuration")
[docs]@lru_cachedefget_poiesis_api_constants()->PoiesisApiConstants:"""Get the Poiesis API constants. Returns: PoiesisApiConstants: The Poiesis API constants. """returnPoiesisApiConstants()