# coding: utf-8

"""
    

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

    The version of the OpenAPI document: 
    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
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from goodmem._generated.models.endpoint_authentication import EndpointAuthentication
from goodmem._generated.models.modality import Modality
from typing import Optional, Set
from typing_extensions import Self

class UpdateRerankerRequest(BaseModel):
    """
    Request body for updating an existing Reranker. Only fields that should be updated need to be included.
    """ # noqa: E501
    display_name: Optional[Annotated[str, Field(min_length=1, strict=True, max_length=255)]] = Field(default=None, description="User-facing name of the reranker", alias="displayName")
    description: Optional[StrictStr] = Field(default=None, description="Description of the reranker")
    endpoint_url: Optional[StrictStr] = Field(default=None, description="API endpoint URL", alias="endpointUrl")
    api_path: Optional[StrictStr] = Field(default=None, description="API path for reranking request", alias="apiPath")
    model_identifier: Optional[StrictStr] = Field(default=None, description="Model identifier", alias="modelIdentifier")
    supported_modalities: Optional[List[Modality]] = Field(default=None, description="Supported content modalities", alias="supportedModalities")
    credentials: Optional[EndpointAuthentication] = None
    replace_labels: Optional[Dict[str, StrictStr]] = Field(default=None, description="Replace all existing labels with these (mutually exclusive with mergeLabels)", alias="replaceLabels")
    merge_labels: Optional[Dict[str, StrictStr]] = Field(default=None, description="Merge these labels with existing ones (mutually exclusive with replaceLabels)", alias="mergeLabels")
    version: Optional[StrictStr] = Field(default=None, description="Version information")
    monitoring_endpoint: Optional[StrictStr] = Field(default=None, description="Monitoring endpoint URL", alias="monitoringEndpoint")
    __properties: ClassVar[List[str]] = ["displayName", "description", "endpointUrl", "apiPath", "modelIdentifier", "supportedModalities", "credentials", "replaceLabels", "mergeLabels", "version", "monitoringEndpoint"]

    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 UpdateRerankerRequest 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()
        # set to None if display_name (nullable) is None
        # and model_fields_set contains the field
        if self.display_name is None and "display_name" in self.model_fields_set:
            _dict['displayName'] = None

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

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "displayName": obj.get("displayName"),
            "description": obj.get("description"),
            "endpointUrl": obj.get("endpointUrl"),
            "apiPath": obj.get("apiPath"),
            "modelIdentifier": obj.get("modelIdentifier"),
            "supportedModalities": obj.get("supportedModalities"),
            "credentials": EndpointAuthentication.from_dict(obj["credentials"]) if obj.get("credentials") is not None else None,
            "replaceLabels": obj.get("replaceLabels"),
            "mergeLabels": obj.get("mergeLabels"),
            "version": obj.get("version"),
            "monitoringEndpoint": obj.get("monitoringEndpoint")
        })
        return _obj


