# 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 pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from youtube_ti.models.access_policy import AccessPolicy
from youtube_ti.models.content_rating import ContentRating
from youtube_ti.models.video_content_details_region_restriction import VideoContentDetailsRegionRestriction
from typing import Optional, Set
from typing_extensions import Self

class VideoContentDetails(BaseModel):
    """
    Details about the content of a YouTube Video.
    """ # noqa: E501
    caption: Optional[StrictStr] = Field(default=None, description="The value of captions indicates whether the video has captions or not.")
    content_rating: Optional[ContentRating] = Field(default=None, alias="contentRating")
    country_restriction: Optional[AccessPolicy] = Field(default=None, alias="countryRestriction")
    definition: Optional[StrictStr] = Field(default=None, description="The value of definition indicates whether the video is available in high definition or only in standard definition.")
    dimension: Optional[StrictStr] = Field(default=None, description="The value of dimension indicates whether the video is available in 3D or in 2D.")
    duration: Optional[StrictStr] = Field(default=None, description="The length of the video. The tag value is an ISO 8601 duration in the format PT#M#S, in which the letters PT indicate that the value specifies a period of time, and the letters M and S refer to length in minutes and seconds, respectively. The # characters preceding the M and S letters are both integers that specify the number of minutes (or seconds) of the video. For example, a value of PT15M51S indicates that the video is 15 minutes and 51 seconds long.")
    has_custom_thumbnail: Optional[StrictBool] = Field(default=None, description="Indicates whether the video uploader has provided a custom thumbnail image for the video. This property is only visible to the video uploader.", alias="hasCustomThumbnail")
    licensed_content: Optional[StrictBool] = Field(default=None, description="The value of is_license_content indicates whether the video is licensed content.", alias="licensedContent")
    projection: Optional[StrictStr] = Field(default=None, description="Specifies the projection format of the video.")
    region_restriction: Optional[VideoContentDetailsRegionRestriction] = Field(default=None, alias="regionRestriction")
    __properties: ClassVar[List[str]] = ["caption", "contentRating", "countryRestriction", "definition", "dimension", "duration", "hasCustomThumbnail", "licensedContent", "projection", "regionRestriction"]

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

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

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

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

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

        if value not in set(['rectangular', '360']):
            raise ValueError("must be one of enum values ('rectangular', '360')")
        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 VideoContentDetails 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 content_rating
        if self.content_rating:
            _dict['contentRating'] = self.content_rating.to_dict()
        # override the default output from pydantic by calling `to_dict()` of country_restriction
        if self.country_restriction:
            _dict['countryRestriction'] = self.country_restriction.to_dict()
        # override the default output from pydantic by calling `to_dict()` of region_restriction
        if self.region_restriction:
            _dict['regionRestriction'] = self.region_restriction.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "caption": obj.get("caption"),
            "contentRating": ContentRating.from_dict(obj["contentRating"]) if obj.get("contentRating") is not None else None,
            "countryRestriction": AccessPolicy.from_dict(obj["countryRestriction"]) if obj.get("countryRestriction") is not None else None,
            "definition": obj.get("definition"),
            "dimension": obj.get("dimension"),
            "duration": obj.get("duration"),
            "hasCustomThumbnail": obj.get("hasCustomThumbnail"),
            "licensedContent": obj.get("licensedContent"),
            "projection": obj.get("projection"),
            "regionRestriction": VideoContentDetailsRegionRestriction.from_dict(obj["regionRestriction"]) if obj.get("regionRestriction") is not None else None
        })
        return _obj


