# coding: utf-8

"""
    Mixpeek API

    This is the Mixpeek API, providing access to various endpoints for data processing and retrieval.

    The version of the OpenAPI document: 1.3.0
    Contact: info@mixpeek.com
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


from __future__ import annotations
import pprint
import re  # noqa: F401
import json

from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from mixpeek.models.credentials1 import Credentials1
from typing import Optional, Set
from typing_extensions import Self

class S3Config(BaseModel):
    """
    Amazon S3 and S3-compatible storage provider configuration.  This configuration enables Mixpeek to connect to Amazon S3 or S3-compatible storage services (MinIO, DigitalOcean Spaces, Wasabi, Backblaze B2, etc.) for automated object ingestion and synchronization.  Authentication Methods:     1. IAM Role Assumption (RECOMMENDED for production):         - Most secure option with automatic credential rotation         - No long-lived credentials shared         - Ideal for customer-owned S3 buckets      2. Access Keys:         - Simpler setup for development and testing         - Works with S3-compatible services         - Requires manual credential rotation  Requirements:     - Valid AWS credentials or IAM role configuration     - S3 bucket with appropriate permissions (s3:GetObject, s3:ListBucket)     - Network connectivity to S3 endpoint     - Correct region configuration  Supported Services:     - Amazon S3 (all regions)     - MinIO (self-hosted or cloud)     - DigitalOcean Spaces     - Wasabi Cloud Storage     - Backblaze B2     - Any S3-compatible storage with compatible API  Use Cases:     - Ingest videos from data lakes     - Sync images from marketing asset buckets     - Process documents from archive storage     - Monitor and index uploaded files     - Backup and disaster recovery workflows
    """ # noqa: E501
    provider_type: Optional[StrictStr] = 's3'
    credentials: Credentials1
    region: StrictStr = Field(description="REQUIRED. AWS region where the S3 bucket is located. Must match the bucket's actual region to avoid routing errors. For S3-compatible services, use their documented region value or 'us-east-1' as a default if regions are not applicable. Format: AWS region code (e.g., us-east-1, eu-west-1)")
    endpoint_url: Optional[StrictStr] = Field(default=None, description="NOT REQUIRED for AWS S3 (uses default AWS endpoints). REQUIRED for S3-compatible services to specify custom endpoint URL. Must be a valid HTTPS or HTTP URL without trailing slash. Examples: - MinIO: https://minio.example.com - DigitalOcean Spaces: https://nyc3.digitaloceanspaces.com - Wasabi: https://s3.wasabisys.com")
    use_ssl: Optional[StrictBool] = Field(default=True, description="Whether to use TLS/SSL encryption for connections to S3. RECOMMENDED: Always True for production environments. Set to False only for local development with unencrypted endpoints. Default: True")
    verify_ssl: Optional[StrictBool] = Field(default=True, description="Whether to verify TLS/SSL certificates when connecting. RECOMMENDED: Always True for production to prevent MITM attacks. Set to False only for development with self-signed certificates. Requires use_ssl=True to have any effect. Default: True")
    __properties: ClassVar[List[str]] = ["provider_type", "credentials", "region", "endpoint_url", "use_ssl", "verify_ssl"]

    @field_validator('provider_type')
    def provider_type_validate_enum(cls, value):
        """Validates the enum"""
        if value is None:
            return value

        if value not in set(['s3']):
            raise ValueError("must be one of enum values ('s3')")
        return value

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )


    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.model_dump(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of S3Config from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self) -> Dict[str, Any]:
        """Return the dictionary representation of the model using alias.

        This has the following differences from calling pydantic's
        `self.model_dump(by_alias=True)`:

        * `None` is only added to the output dict for nullable fields that
          were set at model initialization. Other fields with value `None`
          are ignored.
        """
        excluded_fields: Set[str] = set([
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # override the default output from pydantic by calling `to_dict()` of credentials
        if self.credentials:
            _dict['credentials'] = self.credentials.to_dict()
        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of S3Config from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        _obj = cls.model_validate({
            "provider_type": obj.get("provider_type") if obj.get("provider_type") is not None else 's3',
            "credentials": Credentials1.from_dict(obj["credentials"]) if obj.get("credentials") is not None else None,
            "region": obj.get("region"),
            "endpoint_url": obj.get("endpoint_url"),
            "use_ssl": obj.get("use_ssl") if obj.get("use_ssl") is not None else True,
            "verify_ssl": obj.get("verify_ssl") if obj.get("verify_ssl") is not None else True
        })
        return _obj


