# coding: utf-8

"""
    YouTube Data API v3

    The YouTube Data API v3 is an API that provides access to YouTube data, such as videos, playlists, and channels.

    The version of the OpenAPI document: v3
    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 CaptionSnippet(BaseModel):
    """
    Basic details about a caption track, such as its language and name.
    """ # noqa: E501
    audio_track_type: Optional[StrictStr] = Field(default=None, description="The type of audio track associated with the caption track.", alias="audioTrackType")
    failure_reason: Optional[StrictStr] = Field(default=None, description="The reason that YouTube failed to process the caption track. This property is only present if the state property's value is failed.", alias="failureReason")
    is_auto_synced: Optional[StrictBool] = Field(default=None, description="Indicates whether YouTube synchronized the caption track to the audio track in the video. The value will be true if a sync was explicitly requested when the caption track was uploaded. For example, when calling the captions.insert or captions.update methods, you can set the sync parameter to true to instruct YouTube to sync the uploaded track to the video. If the value is false, YouTube uses the time codes in the uploaded caption track to determine when to display captions.", alias="isAutoSynced")
    is_cc: Optional[StrictBool] = Field(default=None, description="Indicates whether the track contains closed captions for the deaf and hard of hearing. The default value is false.", alias="isCC")
    is_draft: Optional[StrictBool] = Field(default=None, description="Indicates whether the caption track is a draft. If the value is true, then the track is not publicly visible. The default value is false. @mutable youtube.captions.insert youtube.captions.update", alias="isDraft")
    is_easy_reader: Optional[StrictBool] = Field(default=None, description="Indicates whether caption track is formatted for \"easy reader,\" meaning it is at a third-grade level for language learners. The default value is false.", alias="isEasyReader")
    is_large: Optional[StrictBool] = Field(default=None, description="Indicates whether the caption track uses large text for the vision-impaired. The default value is false.", alias="isLarge")
    language: Optional[StrictStr] = Field(default=None, description="The language of the caption track. The property value is a BCP-47 language tag.")
    last_updated: Optional[datetime] = Field(default=None, description="The date and time when the caption track was last updated.", alias="lastUpdated")
    name: Optional[StrictStr] = Field(default=None, description="The name of the caption track. The name is intended to be visible to the user as an option during playback.")
    status: Optional[StrictStr] = Field(default=None, description="The caption track's status.")
    track_kind: Optional[StrictStr] = Field(default=None, description="The caption track's type.", alias="trackKind")
    video_id: Optional[StrictStr] = Field(default=None, description="The ID that YouTube uses to uniquely identify the video associated with the caption track. @mutable youtube.captions.insert", alias="videoId")
    __properties: ClassVar[List[str]] = ["audioTrackType", "failureReason", "isAutoSynced", "isCC", "isDraft", "isEasyReader", "isLarge", "language", "lastUpdated", "name", "status", "trackKind", "videoId"]

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

        if value not in set(['unknown', 'primary', 'commentary', 'descriptive']):
            raise ValueError("must be one of enum values ('unknown', 'primary', 'commentary', 'descriptive')")
        return value

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

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

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

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

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

        if value not in set(['standard', 'ASR', 'forced']):
            raise ValueError("must be one of enum values ('standard', 'ASR', 'forced')")
        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 CaptionSnippet 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,
        )
        return _dict

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

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

        _obj = cls.model_validate({
            "audioTrackType": obj.get("audioTrackType"),
            "failureReason": obj.get("failureReason"),
            "isAutoSynced": obj.get("isAutoSynced"),
            "isCC": obj.get("isCC"),
            "isDraft": obj.get("isDraft"),
            "isEasyReader": obj.get("isEasyReader"),
            "isLarge": obj.get("isLarge"),
            "language": obj.get("language"),
            "lastUpdated": obj.get("lastUpdated"),
            "name": obj.get("name"),
            "status": obj.get("status"),
            "trackKind": obj.get("trackKind"),
            "videoId": obj.get("videoId")
        })
        return _obj


