# coding: utf-8

"""
    Fastify Template API

    API documentation using Swagger

    The version of the OpenAPI document: 1.0.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 pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional, Union
from keplar_api.models.call_analysis import CallAnalysis
from typing import Optional, Set
from typing_extensions import Self

class CallMetadata(BaseModel):
    """
    CallMetadata
    """ # noqa: E501
    recording_url: Optional[StrictStr] = Field(default=None, alias="recordingUrl")
    transcript: Optional[StrictStr] = None
    transcript_quality: Optional[StrictStr] = Field(default=None, alias="transcriptQuality")
    transcript_markdown: Optional[StrictStr] = Field(default=None, alias="transcriptMarkdown")
    transcript_insight: Optional[StrictStr] = Field(default=None, alias="transcriptInsight")
    analysis: Optional[CallAnalysis] = None
    gcs_url: Optional[StrictStr] = Field(default=None, alias="gcsUrl")
    gcs_path: Optional[StrictStr] = Field(default=None, alias="gcsPath")
    gcs_uploaded_at: Optional[StrictStr] = Field(default=None, alias="gcsUploadedAt")
    gcs_last_synced_at: Optional[StrictStr] = Field(default=None, alias="gcsLastSyncedAt")
    video_recording_url: Optional[StrictStr] = Field(default=None, alias="videoRecordingUrl")
    video_gcs_url: Optional[StrictStr] = Field(default=None, alias="videoGcsUrl")
    video_gcs_path: Optional[StrictStr] = Field(default=None, alias="videoGcsPath")
    video_uploaded_at: Optional[StrictStr] = Field(default=None, alias="videoUploadedAt")
    video_mime_type: Optional[StrictStr] = Field(default=None, alias="videoMimeType")
    video_duration_seconds: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="videoDurationSeconds")
    video_size_bytes: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="videoSizeBytes")
    video_recording_status: Optional[StrictStr] = Field(default=None, alias="videoRecordingStatus")
    video_recording_error: Optional[StrictStr] = Field(default=None, alias="videoRecordingError")
    __properties: ClassVar[List[str]] = ["recordingUrl", "transcript", "transcriptQuality", "transcriptMarkdown", "transcriptInsight", "analysis", "gcsUrl", "gcsPath", "gcsUploadedAt", "gcsLastSyncedAt", "videoRecordingUrl", "videoGcsUrl", "videoGcsPath", "videoUploadedAt", "videoMimeType", "videoDurationSeconds", "videoSizeBytes", "videoRecordingStatus", "videoRecordingError"]

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

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

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

        if value not in set(['recording', 'uploading', 'completed', 'failed', 'skipped']):
            raise ValueError("must be one of enum values ('recording', 'uploading', 'completed', 'failed', 'skipped')")
        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 CallMetadata 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 analysis
        if self.analysis:
            _dict['analysis'] = self.analysis.to_dict()
        # set to None if analysis (nullable) is None
        # and model_fields_set contains the field
        if self.analysis is None and "analysis" in self.model_fields_set:
            _dict['analysis'] = None

        return _dict

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

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

        _obj = cls.model_validate({
            "recordingUrl": obj.get("recordingUrl"),
            "transcript": obj.get("transcript"),
            "transcriptQuality": obj.get("transcriptQuality"),
            "transcriptMarkdown": obj.get("transcriptMarkdown"),
            "transcriptInsight": obj.get("transcriptInsight"),
            "analysis": CallAnalysis.from_dict(obj["analysis"]) if obj.get("analysis") is not None else None,
            "gcsUrl": obj.get("gcsUrl"),
            "gcsPath": obj.get("gcsPath"),
            "gcsUploadedAt": obj.get("gcsUploadedAt"),
            "gcsLastSyncedAt": obj.get("gcsLastSyncedAt"),
            "videoRecordingUrl": obj.get("videoRecordingUrl"),
            "videoGcsUrl": obj.get("videoGcsUrl"),
            "videoGcsPath": obj.get("videoGcsPath"),
            "videoUploadedAt": obj.get("videoUploadedAt"),
            "videoMimeType": obj.get("videoMimeType"),
            "videoDurationSeconds": obj.get("videoDurationSeconds"),
            "videoSizeBytes": obj.get("videoSizeBytes"),
            "videoRecordingStatus": obj.get("videoRecordingStatus"),
            "videoRecordingError": obj.get("videoRecordingError")
        })
        return _obj


