# 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, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from mixpeek.models.tigris_access_key_credentials import TigrisAccessKeyCredentials
from typing import Optional, Set
from typing_extensions import Self

class TigrisConfig(BaseModel):
    """
    Tigris Data globally distributed object storage configuration.  Tigris is an S3-compatible object storage service with automatic global distribution, zero egress fees, and built-in CDN capabilities. It uses the AWS S3 API, making integration straightforward.  Key Features:     - S3-compatible API (drop-in replacement)     - Automatic global data distribution     - Zero egress fees     - Built-in CDN and caching     - Strong consistency guarantees  Authentication:     - Access keys only (similar to S3 access keys)     - No IAM role assumption (Tigris is not AWS)  Requirements:     - Tigris account with access keys     - Bucket created in Tigris console     - Network connectivity to fly.storage.tigris.dev  Use Cases:     - Globally distributed media assets     - Low-latency content delivery worldwide     - Cost-effective storage with no egress fees     - S3-compatible workflows outside AWS
    """ # noqa: E501
    provider_type: Optional[StrictStr] = 'tigris'
    credentials: TigrisAccessKeyCredentials = Field(description="REQUIRED. Tigris access key credentials. Obtain from Tigris Console at https://console.tigris.dev")
    region: Optional[StrictStr] = Field(default='auto', description="Region for Tigris. Typically 'auto' for automatic global distribution. Tigris automatically distributes data globally, so region is usually 'auto'. Default: auto")
    endpoint_url: Optional[StrictStr] = Field(default='https://fly.storage.tigris.dev', description="Tigris S3-compatible endpoint URL. Default: https://fly.storage.tigris.dev This is the standard Tigris endpoint and usually doesn't need to be changed.")
    __properties: ClassVar[List[str]] = ["provider_type", "credentials", "region", "endpoint_url"]

    @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(['tigris']):
            raise ValueError("must be one of enum values ('tigris')")
        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 TigrisConfig 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 TigrisConfig 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 'tigris',
            "credentials": TigrisAccessKeyCredentials.from_dict(obj["credentials"]) if obj.get("credentials") is not None else None,
            "region": obj.get("region") if obj.get("region") is not None else 'auto',
            "endpoint_url": obj.get("endpoint_url") if obj.get("endpoint_url") is not None else 'https://fly.storage.tigris.dev'
        })
        return _obj


