routes.images#

Module Contents#

Functions#

upload_picture

Endpoint to upload a new picture.

delete_picture

Endpoint to delete a specific picture by its ID.

update_picture

Endpoint to update the description of a specific picture by its ID.

get_picture

Endpoint to retrieve a specific picture by its ID.

Data#

API#

routes.images.router = 'APIRouter(...)'#
async routes.images.upload_picture(file: fastapi.UploadFile = File(...), body: src.schemas.images.PictureSchema = Depends(PictureSchema), db: sqlalchemy.ext.asyncio.AsyncSession = Depends(get_db), user: src.entity.models.User = Depends(auth_service.get_current_user))#

Endpoint to upload a new picture.

Parameters:
  • file (UploadFile) – The image file to be uploaded.

  • body (PictureSchema) – PictureSchema instance containing picture data.

  • db (AsyncSession) – Asynchronous SQLAlchemy session (dependency injection).

  • user (User) – Current authenticated user (dependency injection).

Returns:

The uploaded picture.

Return type:

PictureResponseSchema

Raises:

HTTPException – If there is an issue with the upload or authentication fails.

async routes.images.delete_picture(picture_id: int = Path(ge=1), db: sqlalchemy.ext.asyncio.AsyncSession = Depends(get_db), user=Depends(auth_service.get_current_user))#

Endpoint to delete a specific picture by its ID.

Parameters:
  • picture_id (int) – ID of the picture to be deleted.

  • db (AsyncSession) – Asynchronous SQLAlchemy session (dependency injection).

  • user (User) – Current authenticated user (dependency injection).

Returns:

No content (HTTP 204).

Return type:

None

Raises:

HTTPException – If the picture is not found or the user lacks the necessary permissions.

async routes.images.update_picture(body: src.schemas.images.PictureUpdateSchema, picture_id: int = Path(ge=1), db: sqlalchemy.ext.asyncio.AsyncSession = Depends(get_db), user=Depends(auth_service.get_current_user))#

Endpoint to update the description of a specific picture by its ID.

Parameters:
  • body (PictureUpdateSchema) – PictureUpdateSchema instance containing updated picture data.

  • picture_id (int) – ID of the picture to be updated.

  • db (AsyncSession) – Asynchronous SQLAlchemy session (dependency injection).

  • user (User) – Current authenticated user (dependency injection).

Returns:

The updated picture.

Return type:

PictureResponseSchema

Raises:

HTTPException – If the picture is not found.

async routes.images.get_picture(picture_id: int = Path(ge=1), db: sqlalchemy.ext.asyncio.AsyncSession = Depends(get_db), user=Depends(auth_service.get_current_user))#

Endpoint to retrieve a specific picture by its ID.

Parameters:
  • picture_id (int) – ID of the picture to be retrieved.

  • db (AsyncSession) – Asynchronous SQLAlchemy session (dependency injection).

  • user (User) – Current authenticated user (dependency injection).

Returns:

The retrieved picture.

Return type:

PictureResponseSchema

Raises:

HTTPException – If the picture is not found.