"""Storage-related endpoints."""

import logging

from fastapi import APIRouter

from src.models.schemas import ResponseModel
from src.utils.errors import ErrorCode
from src.services.storage_service import storage_manager

logger = logging.getLogger(__name__)
router = APIRouter()


class SignUrlRequest:
    """Request to sign a URL."""
    url: str


@router.post("/storage/sign-url", response_model=ResponseModel)
async def sign_url_endpoint(request: dict):
    """Re-sign an OSS URL."""
    new_url = storage_manager.sign_url(request.get("url", ""))
    return ResponseModel(code=ErrorCode.SUCCESS, message="URL signed", data={"url": new_url})
