routes.transform#
Module Contents#
Functions#
Helper function for checking access to the picture. |
|
Endpoint to create a transformed picture. |
|
Endpoint to list transformed pictures for the current user. |
|
Endpoint to retrieve a specific transformed picture by its ID. |
|
Endpoint to retrieve the QR code URL for a specific transformed picture by its ID. |
|
Endpoint to update a specific transformed picture by its ID. |
|
Endpoint to delete a specific transformed picture by its ID. |
Data#
API#
- routes.transform.router = 'APIRouter(...)'#
- routes.transform.access_checking(picture, current_user: src.entity.models.User)#
Helper function for checking access to the picture.
- async routes.transform.create_transform(request: src.schemas.transform.TransformSchema, original_picture_id: int = Path(ge=1), current_user: src.entity.models.User = Depends(auth_service.get_current_user), session: sqlalchemy.ext.asyncio.AsyncSession = Depends(get_db))#
Endpoint to create a transformed picture.
- Parameters:
request (TransformSchema) – TransformCreate instance containing transformation parameters.
original_picture_id (int) – ID of the original picture.
current_user (User) – Current authenticated user (dependency injection).
session (AsyncSession) – Asynchronous SQLAlchemy session (dependency injection).
- Returns:
The created transformed picture.
- Return type:
- Raises:
HTTPException – If transformation parameters are missing or the transformation fails.
Available transformation params: - width: The width of the transformed image. 100-2000. - height: The height of the transformed image. 100-2000. - crop: The crop mode. fill, limit, scale, thumb, fit, lfill - effect: grayscale, sepia, vignette, cartoonify,`pixelate`, blur, brightness, contrast, saturation, sharpen - border: 5px_solid_lightblue, 5px_dotted_lightblue, 5px_dashed_lightblue - angle: 0-360
- async routes.transform.list_user_transforms(current_user: src.entity.models.User = Depends(auth_service.get_current_user), session: sqlalchemy.ext.asyncio.AsyncSession = Depends(get_db))#
Endpoint to list transformed pictures for the current user.
- Parameters:
current_user (User) – Current authenticated user (dependency injection).
session (AsyncSession) – Asynchronous SQLAlchemy session (dependency injection).
- Returns:
List of transformed pictures for the user.
- Return type:
List[TransformResponse]
- Raises:
HTTPException – If no transformed pictures are found.
- async routes.transform.get_transform(transform_id: int = Path(ge=1), current_user: src.entity.models.User = Depends(auth_service.get_current_user), session: sqlalchemy.ext.asyncio.AsyncSession = Depends(get_db))#
Endpoint to retrieve a specific transformed picture by its ID.
- Parameters:
transform_id (int) – ID of the transformed picture to be retrieved.
current_user (User) – Current authenticated user (dependency injection).
session (AsyncSession) – Asynchronous SQLAlchemy session (dependency injection).
- Returns:
The retrieved transformed picture.
- Return type:
- Raises:
HTTPException – If the transformed picture is not found.
- async routes.transform.get_transform_qr(transform_id: int = Path(ge=1), current_user: src.entity.models.User = Depends(auth_service.get_current_user), session: sqlalchemy.ext.asyncio.AsyncSession = Depends(get_db))#
Endpoint to retrieve the QR code URL for a specific transformed picture by its ID.
- Parameters:
transform_id (int) – ID of the transformed picture.
current_user (User) – Current authenticated user (dependency injection).
session (AsyncSession) – Asynchronous SQLAlchemy session (dependency injection).
- Returns:
Dictionary containing the QR code URL.
- Return type:
dict
- Raises:
HTTPException – If the transformed picture is not found.
- async routes.transform.update_transform(request: src.schemas.transform.TransformSchema, transform_id: int = Path(ge=1), current_user: src.entity.models.User = Depends(auth_service.get_current_user), session: sqlalchemy.ext.asyncio.AsyncSession = Depends(get_db))#
Endpoint to update a specific transformed picture by its ID.
- Parameters:
request (TransformSchema) – TransformSchema instance containing updated transformation parameters.
transform_id (int) – ID of the transformed picture to be updated.
current_user (User) – Current authenticated user (dependency injection).
session (AsyncSession) – Asynchronous SQLAlchemy session (dependency injection).
- Returns:
The updated transformed picture.
- Return type:
- Raises:
HTTPException – If the transformed picture is not found.
Available transformation params: - width: The width of the transformed image. 100-2000. - height: The height of the transformed image. 100-2000. - crop: The crop mode. fill, limit, scale, thumb, fit, lfill - effect: grayscale, sepia, vignette, cartoonify,`pixelate`, blur, brightness, contrast, saturation, sharpen - border: 5px_solid_lightblue, 5px_dotted_lightblue, 5px_dashed_lightblue - angle: 0-360
- async routes.transform.delete_transform(transform_id: int, current_user: src.entity.models.User = Depends(auth_service.get_current_user), session: sqlalchemy.ext.asyncio.AsyncSession = Depends(get_db))#
Endpoint to delete a specific transformed picture by its ID.
- Parameters:
transform_id (int) – ID of the transformed picture to be deleted.
current_user (User) – Current authenticated user (dependency injection).
session (AsyncSession) – Asynchronous SQLAlchemy session (dependency injection).
- Raises:
HTTPException – If the transformed picture is not found or deletion fails.