Skip to content

Profile Manager

profile_manager

Module defining helper functions meant to be run inside FastAPI endpoints for management of Mirumoji Profiles

Attributes:

Name Type Description
LOGGER Logger

Module's Logging object.

ensure_profile_exists(profile_id=Depends(get_profile_id_from_header)) async

Function meant to be run inside FastAPI endpoint which ensures a profile exists for the given ID.

Parameters:

Name Type Description Default
profile_id str

The profile ID to check.

Depends(get_profile_id_from_header)

Returns:

Name Type Description
str str

The profile ID from input if it exists or could be created.

Raises:

Type Description
HTTPException

If ID is None or profile doesn't exist and cannot be created

get_profile_id_from_header(x_profile_id=Header(None)) async

Function meant to be run inside FastAPI endpoint which extracts X-Profile-ID header if present.

Parameters:

Name Type Description Default
x_profile_id str

The X-Profile-ID Header

Header(None)

Returns:

Name Type Description
str Optional[str]

The X-Profile-ID Header content.

get_profile_id_optional(profile_id=Depends(get_profile_id_from_header)) async

Function meant to be run inside FastAPI endpoint which returns the content of Profile ID Header.

Parameters:

Name Type Description Default
profile_id str

Profile ID from header.

Depends(get_profile_id_from_header)

Returns:

Type Description
Optional[str]

Union[str, None]: If profile ID if X-Profile-ID is provided and the profile exists or could be implicitly created returns str, otherwise returns None.