"""Delete method for backups namespace."""

from __future__ import annotations

from typing import Any

from pinecone._internal.logging import get_logger
from pinecone._internal.validation import require_non_empty


logger = get_logger(__name__)


def delete(self: Any, backup_id: str) -> None:
    """Delete a backup.

    Args:
        backup_id: Unique identifier of the backup to delete.

    Raises:
        ValueError: If backup_id is empty.
        NotFoundError: If backup not found.
        PreconditionFailedError: If there's a pending restore job from this backup.
        APIError: If deletion fails.

    Example:
        >>> pc.backups.delete("8c85e612-ed1c-4f97-9f8c-8194e07bcf71")
    """
    # Validate inputs
    require_non_empty("backup_id", backup_id)

    logger.info("Deleting backup", backup_id=backup_id)

    try:
        # Make HTTP request
        self._http.delete(
            f"{self._base_url}/backups/{backup_id}",
            headers=self._headers,
        )

        logger.info("Backup deletion initiated", backup_id=backup_id)
        # Note: API returns 202 (accepted, async deletion), no response body

    except Exception:
        logger.exception("Failed to delete backup", backup_id=backup_id)
        raise
