# generated by fastapi-codegen:
#   filename:  /Users/jgopalak/Documents/projects/contracts/guardicore/connector
#   timestamp: 2026-03-12T06:37:37+00:00

from __future__ import annotations

from enum import Enum
from typing import List, Optional

from pydantic import BaseModel, ConfigDict, Field, RootModel

from centra_sdk.utils.gc_serializer import GcSerializer


class FlowlogsPartition(Enum):
    DAILY = 'daily'
    HOURLY = 'hourly'


class BucketConfig(BaseModel, GcSerializer):
    model_config = ConfigDict(
        populate_by_name=True,
        from_attributes=True,
    )
    bucket_name: str = Field(
        ..., alias='bucket-name', description='Name of the S3 bucket'
    )
    flowlogs_path_prefix: Optional[str] = Field(
        '',
        alias='flowlogs-path-prefix',
        description='Path prefix for flow logs within the bucket',
    )
    hive_compatible_partition: Optional[bool] = Field(
        False,
        alias='hive-compatible-partition',
        description='Whether the bucket uses Hive-compatible partitioning',
    )
    flowlogs_partition: Optional[FlowlogsPartition] = Field(
        'daily',
        alias='flowlogs-partition',
        description='Partition granularity for flow logs',
    )
    bucket_region: Optional[str] = Field(
        'us-east-1',
        alias='bucket-region',
        description='AWS region where the flow log bucket is located',
    )


class FlowlogConfig(RootModel[List[BucketConfig]]):
    model_config = ConfigDict(
        populate_by_name=True,
        from_attributes=True,
    )
    root: List[BucketConfig] = Field(
        ..., description='List of bucket flow log configurations', min_length=1
    )

    def __getattr__(self, attr: str):
        return getattr(self.root, attr)

    def __iter__(self):
        for item in self.root:
            yield item


class FlowlogBucketMetadataResponse(BaseModel, GcSerializer):
    model_config = ConfigDict(
        populate_by_name=True,
        from_attributes=True,
    )
    message: str = Field(..., description='Flowlog bucket metadata stored successfully')


class FlowlogBucketMetadataErrorResponse(BaseModel, GcSerializer):
    model_config = ConfigDict(
        populate_by_name=True,
        from_attributes=True,
    )
    error: str = Field(
        ...,
        description='Error message describing which bucket and field failed validation',
    )
