routes.comments#
Module Contents#
Functions#
Endpoint to create a new comment on a picture. |
|
Endpoint to retrieve a list of comments for a specific picture. |
|
Endpoint to retrieve a specific comment by its ID. |
|
Endpoint to update the text of a specific comment by its ID. |
|
Endpoint to delete a specific comment by its ID. |
Data#
API#
- routes.comments.router = 'APIRouter(...)'#
- routes.comments.delete_access = 'RoleAccess(...)'#
- async routes.comments.create_comment(body: src.schemas.comment.CommentSchema, picture_id: int = Path(ge=1), db: sqlalchemy.ext.asyncio.AsyncSession = Depends(get_db), user: src.entity.models.User = Depends(auth_service.get_current_user))#
Endpoint to create a new comment on a picture.
- Parameters:
body (CommentSchema) – CommentSchema instance containing comment data.
picture_id (int) – ID of the picture to which the comment is associated.
db (AsyncSession) – Asynchronous SQLAlchemy session (dependency injection).
user (User) – Current authenticated user (dependency injection).
- Returns:
The created comment.
- Return type:
- Raises:
HTTPException – If the text is missing or the request is malformed.
- async routes.comments.get_comments(picture_id: int = Path(ge=1), offset: int = Query(0, ge=0), limit: int = Query(10, ge=10, le=100), db: sqlalchemy.ext.asyncio.AsyncSession = Depends(get_db), user: src.entity.models.User = Depends(auth_service.get_current_user))#
Endpoint to retrieve a list of comments for a specific picture.
- Parameters:
picture_id (int) – ID of the picture for which comments are to be retrieved.
offset (int) – Offset for pagination.
limit (int) – Limit for pagination.
db (AsyncSession) – Asynchronous SQLAlchemy session (dependency injection).
user (User) – Current authenticated user (dependency injection).
- Returns:
List of comments.
- Return type:
list[CommentResponse]
- Raises:
HTTPException – If the picture is not found.
- async routes.comments.get_comment(comment_id: int = Path(ge=1), db: sqlalchemy.ext.asyncio.AsyncSession = Depends(get_db), user: src.entity.models.User = Depends(auth_service.get_current_user))#
Endpoint to retrieve a specific comment by its ID.
- Parameters:
comment_id (int) – ID of the comment to be retrieved.
db (AsyncSession) – Asynchronous SQLAlchemy session (dependency injection).
user (User) – Current authenticated user (dependency injection).
- Returns:
The retrieved comment.
- Return type:
- Raises:
HTTPException – If the comment is not found.
- async routes.comments.update_comment(body: src.schemas.comment.CommentSchema, comment_id: int = Path(ge=1), db: sqlalchemy.ext.asyncio.AsyncSession = Depends(get_db), user: src.entity.models.User = Depends(auth_service.get_current_user))#
Endpoint to update the text of a specific comment by its ID.
- Parameters:
body (CommentSchema) – CommentSchema instance containing updated comment data.
comment_id (int) – ID of the comment to be updated.
db (AsyncSession) – Asynchronous SQLAlchemy session (dependency injection).
user (User) – Current authenticated user (dependency injection).
- Returns:
The updated comment.
- Return type:
- Raises:
HTTPException – If the text is missing, the request is malformed, or the comment is not found.
- async routes.comments.delete_comment(comment_id: int = Path(ge=1), db: sqlalchemy.ext.asyncio.AsyncSession = Depends(get_db))#
Endpoint to delete a specific comment by its ID.
- Parameters:
comment_id (int) – ID of the comment to be deleted.
db (AsyncSession) – Asynchronous SQLAlchemy session (dependency injection).
- Returns:
The deleted comment.
- Return type:
- Raises:
HTTPException – If the comment is not found or the user lacks the necessary permissions.