"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from __future__ import annotations
from .s3compressiontype import S3CompressionType
from .s3encryptiontype import S3EncryptionType
from flexprice.types import BaseModel, UNSET_SENTINEL
from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict


class S3JobConfigTypedDict(TypedDict):
    bucket: NotRequired[str]
    r"""S3 bucket name"""
    compression: NotRequired[S3CompressionType]
    encryption: NotRequired[S3EncryptionType]
    endpoint_url: NotRequired[str]
    r"""Custom S3 endpoint URL (e.g., \"http://minio:9000\" for MinIO)"""
    key_prefix: NotRequired[str]
    r"""Optional prefix for S3 keys (e.g., \"flexprice-exports/\")"""
    region: NotRequired[str]
    r"""AWS region (e.g., \"us-west-2\")"""
    use_path_style: NotRequired[bool]
    r"""Use path-style addressing instead of virtual-hosted-style (required for MinIO)"""


class S3JobConfig(BaseModel):
    bucket: Optional[str] = None
    r"""S3 bucket name"""

    compression: Optional[S3CompressionType] = None

    encryption: Optional[S3EncryptionType] = None

    endpoint_url: Optional[str] = None
    r"""Custom S3 endpoint URL (e.g., \"http://minio:9000\" for MinIO)"""

    key_prefix: Optional[str] = None
    r"""Optional prefix for S3 keys (e.g., \"flexprice-exports/\")"""

    region: Optional[str] = None
    r"""AWS region (e.g., \"us-west-2\")"""

    use_path_style: Optional[bool] = None
    r"""Use path-style addressing instead of virtual-hosted-style (required for MinIO)"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "bucket",
                "compression",
                "encryption",
                "endpoint_url",
                "key_prefix",
                "region",
                "use_path_style",
            ]
        )
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k, serialized.get(n))

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m
