# coding: utf-8

"""
    AI Stats Gateway API

    Programmatic access to the AI Stats AI Gateway. All endpoints forward requests to the best available provider for the specified model, and return normalised responses with clear structured metadata.

    The version of the OpenAPI document: 0.1.0
    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 datetime import datetime
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from typing import Optional, Set
from typing_extensions import Self

class GatewayModelProvider(BaseModel):
    """
    GatewayModelProvider
    """ # noqa: E501
    api_provider_id: StrictStr = Field(description="Identifier for the provider.")
    api_provider_name: Optional[StrictStr] = Field(description="Human readable provider name.")
    link: Optional[StrictStr] = Field(description="Canonical URL for the provider.")
    country_code: Optional[StrictStr] = Field(description="Provider headquarters country code.")
    endpoint: StrictStr = Field(description="Gateway endpoint served by this provider.")
    provider_model_slug: Optional[StrictStr] = Field(description="Provider specific model identifier.")
    is_active_gateway: StrictBool = Field(description="Whether the provider is currently routable via the gateway.")
    input_modalities: List[StrictStr] = Field(description="Input modalities supported by this provider-model pairing.")
    output_modalities: List[StrictStr] = Field(description="Output modalities supported by this provider-model pairing.")
    effective_from: Optional[datetime] = Field(description="Timestamp from which the pairing is effective.")
    effective_to: Optional[datetime] = Field(description="Timestamp when the pairing stops being effective.")
    __properties: ClassVar[List[str]] = ["api_provider_id", "api_provider_name", "link", "country_code", "endpoint", "provider_model_slug", "is_active_gateway", "input_modalities", "output_modalities", "effective_from", "effective_to"]

    @field_validator('endpoint')
    def endpoint_validate_enum(cls, value):
        """Validates the enum"""
        if value not in set(['chat.completions', 'images.generations', 'audio.speech', 'audio.transcription', 'moderations', 'video.generation', 'embeddings', 'batch']):
            raise ValueError("must be one of enum values ('chat.completions', 'images.generations', 'audio.speech', 'audio.transcription', 'moderations', 'video.generation', 'embeddings', 'batch')")
        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 GatewayModelProvider 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,
        )
        # set to None if api_provider_name (nullable) is None
        # and model_fields_set contains the field
        if self.api_provider_name is None and "api_provider_name" in self.model_fields_set:
            _dict['api_provider_name'] = None

        # set to None if link (nullable) is None
        # and model_fields_set contains the field
        if self.link is None and "link" in self.model_fields_set:
            _dict['link'] = None

        # set to None if country_code (nullable) is None
        # and model_fields_set contains the field
        if self.country_code is None and "country_code" in self.model_fields_set:
            _dict['country_code'] = None

        # set to None if provider_model_slug (nullable) is None
        # and model_fields_set contains the field
        if self.provider_model_slug is None and "provider_model_slug" in self.model_fields_set:
            _dict['provider_model_slug'] = None

        # set to None if effective_from (nullable) is None
        # and model_fields_set contains the field
        if self.effective_from is None and "effective_from" in self.model_fields_set:
            _dict['effective_from'] = None

        # set to None if effective_to (nullable) is None
        # and model_fields_set contains the field
        if self.effective_to is None and "effective_to" in self.model_fields_set:
            _dict['effective_to'] = None

        return _dict

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

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

        _obj = cls.model_validate({
            "api_provider_id": obj.get("api_provider_id"),
            "api_provider_name": obj.get("api_provider_name"),
            "link": obj.get("link"),
            "country_code": obj.get("country_code"),
            "endpoint": obj.get("endpoint"),
            "provider_model_slug": obj.get("provider_model_slug"),
            "is_active_gateway": obj.get("is_active_gateway"),
            "input_modalities": obj.get("input_modalities"),
            "output_modalities": obj.get("output_modalities"),
            "effective_from": obj.get("effective_from"),
            "effective_to": obj.get("effective_to")
        })
        return _obj


