# generated by fastapi-codegen:
#   filename:  connector
#   timestamp: 2026-03-12T06:37:37+00:00

from __future__ import annotations

from typing import Annotated

from fastapi import APIRouter, Depends, HTTPException
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer

from centra_sdk.utils.gc_handler import GcHandler
from centra_sdk.utils.handler_registry import HandlerRegistry

from ..dependencies import *

router = APIRouter(tags=['FlowLogs'])
security = HTTPBearer(auto_error=False)
registry = HandlerRegistry()


@registry.register()
class FlowLogsHandler(GcHandler):

    async def store_flowlog_config(
        self, body: FlowlogConfig
    ) -> FlowlogBucketMetadataResponse:
        """This method should be implemented by the subclass."""
        raise HTTPException(
            status_code=404, detail=f"store_flowlog_config not implemented"
        )


@router.post(
    '/v1/operations/aws/flowlog_config',
    response_model=FlowlogBucketMetadataResponse,
    responses={
        '400': {'model': FlowlogBucketMetadataErrorResponse},
        '500': {'model': FlowlogBucketMetadataErrorResponse},
    },
    tags=['FlowLogs'],
)
async def store_flowlog_config(
    credentials: Annotated[HTTPAuthorizationCredentials, Depends(security)],
    body: FlowlogConfig,
) -> Union[FlowlogBucketMetadataResponse, FlowlogBucketMetadataErrorResponse]:
    """
    Store and validate flowlog bucket configuration
    """

    token = credentials.credentials if credentials else None
    return await registry.call_handler(store_flowlog_config.__name__, token, body)


__all__ = ['FlowLogsHandler', 'registry']
