# 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, StrictBytes, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional, Union
from youtube_ti.models.monitor_stream_info import MonitorStreamInfo
from typing import Optional, Set
from typing_extensions import Self

class LiveBroadcastContentDetails(BaseModel):
    """
    Detailed settings of a broadcast.
    """ # noqa: E501
    bound_stream_id: Optional[StrictStr] = Field(default=None, description="This value uniquely identifies the live stream bound to the broadcast.", alias="boundStreamId")
    bound_stream_last_update_time_ms: Optional[datetime] = Field(default=None, description="The date and time that the live stream referenced by boundStreamId was last updated.", alias="boundStreamLastUpdateTimeMs")
    closed_captions_type: Optional[StrictStr] = Field(default=None, alias="closedCaptionsType")
    enable_auto_start: Optional[StrictBool] = Field(default=None, description="This setting indicates whether auto start is enabled for this broadcast. The default value for this property is false. This setting can only be used by Events.", alias="enableAutoStart")
    enable_auto_stop: Optional[StrictBool] = Field(default=None, description="This setting indicates whether auto stop is enabled for this broadcast. The default value for this property is false. This setting can only be used by Events.", alias="enableAutoStop")
    enable_closed_captions: Optional[StrictBool] = Field(default=None, description="This setting indicates whether HTTP POST closed captioning is enabled for this broadcast. The ingestion URL of the closed captions is returned through the liveStreams API. This is mutually exclusive with using the closed_captions_type property, and is equivalent to setting closed_captions_type to CLOSED_CAPTIONS_HTTP_POST.", alias="enableClosedCaptions")
    enable_content_encryption: Optional[StrictBool] = Field(default=None, description="This setting indicates whether YouTube should enable content encryption for the broadcast.", alias="enableContentEncryption")
    enable_dvr: Optional[StrictBool] = Field(default=None, description="This setting determines whether viewers can access DVR controls while watching the video. DVR controls enable the viewer to control the video playback experience by pausing, rewinding, or fast forwarding content. The default value for this property is true. *Important:* You must set the value to true and also set the enableArchive property's value to true if you want to make playback available immediately after the broadcast ends.", alias="enableDvr")
    enable_embed: Optional[StrictBool] = Field(default=None, description="This setting indicates whether the broadcast video can be played in an embedded player. If you choose to archive the video (using the enableArchive property), this setting will also apply to the archived video.", alias="enableEmbed")
    enable_low_latency: Optional[StrictBool] = Field(default=None, description="Indicates whether this broadcast has low latency enabled.", alias="enableLowLatency")
    latency_preference: Optional[StrictStr] = Field(default=None, description="If both this and enable_low_latency are set, they must match. LATENCY_NORMAL should match enable_low_latency=false LATENCY_LOW should match enable_low_latency=true LATENCY_ULTRA_LOW should have enable_low_latency omitted.", alias="latencyPreference")
    mesh: Optional[Union[StrictBytes, StrictStr]] = Field(default=None, description="The mesh for projecting the video if projection is mesh. The mesh value must be a UTF-8 string containing the base-64 encoding of 3D mesh data that follows the Spherical Video V2 RFC specification for an mshp box, excluding the box size and type but including the following four reserved zero bytes for the version and flags.")
    monitor_stream: Optional[MonitorStreamInfo] = Field(default=None, alias="monitorStream")
    projection: Optional[StrictStr] = Field(default=None, description="The projection format of this broadcast. This defaults to rectangular.")
    record_from_start: Optional[StrictBool] = Field(default=None, description="Automatically start recording after the event goes live. The default value for this property is true. *Important:* You must also set the enableDvr property's value to true if you want the playback to be available immediately after the broadcast ends. If you set this property's value to true but do not also set the enableDvr property to true, there may be a delay of around one day before the archived video will be available for playback.", alias="recordFromStart")
    start_with_slate: Optional[StrictBool] = Field(default=None, description="This setting indicates whether the broadcast should automatically begin with an in-stream slate when you update the broadcast's status to live. After updating the status, you then need to send a liveCuepoints.insert request that sets the cuepoint's eventState to end to remove the in-stream slate and make your broadcast stream visible to viewers.", alias="startWithSlate")
    stereo_layout: Optional[StrictStr] = Field(default=None, description="The 3D stereo layout of this broadcast. This defaults to mono.", alias="stereoLayout")
    __properties: ClassVar[List[str]] = ["boundStreamId", "boundStreamLastUpdateTimeMs", "closedCaptionsType", "enableAutoStart", "enableAutoStop", "enableClosedCaptions", "enableContentEncryption", "enableDvr", "enableEmbed", "enableLowLatency", "latencyPreference", "mesh", "monitorStream", "projection", "recordFromStart", "startWithSlate", "stereoLayout"]

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

        if value not in set(['closedCaptionsTypeUnspecified', 'closedCaptionsDisabled', 'closedCaptionsHttpPost', 'closedCaptionsEmbedded']):
            raise ValueError("must be one of enum values ('closedCaptionsTypeUnspecified', 'closedCaptionsDisabled', 'closedCaptionsHttpPost', 'closedCaptionsEmbedded')")
        return value

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

        if value not in set(['latencyPreferenceUnspecified', 'normal', 'low', 'ultraLow']):
            raise ValueError("must be one of enum values ('latencyPreferenceUnspecified', 'normal', 'low', 'ultraLow')")
        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(['projectionUnspecified', 'rectangular', '360', 'mesh']):
            raise ValueError("must be one of enum values ('projectionUnspecified', 'rectangular', '360', 'mesh')")
        return value

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

        if value not in set(['stereoLayoutUnspecified', 'mono', 'leftRight', 'topBottom']):
            raise ValueError("must be one of enum values ('stereoLayoutUnspecified', 'mono', 'leftRight', 'topBottom')")
        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 LiveBroadcastContentDetails 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 monitor_stream
        if self.monitor_stream:
            _dict['monitorStream'] = self.monitor_stream.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "boundStreamId": obj.get("boundStreamId"),
            "boundStreamLastUpdateTimeMs": obj.get("boundStreamLastUpdateTimeMs"),
            "closedCaptionsType": obj.get("closedCaptionsType"),
            "enableAutoStart": obj.get("enableAutoStart"),
            "enableAutoStop": obj.get("enableAutoStop"),
            "enableClosedCaptions": obj.get("enableClosedCaptions"),
            "enableContentEncryption": obj.get("enableContentEncryption"),
            "enableDvr": obj.get("enableDvr"),
            "enableEmbed": obj.get("enableEmbed"),
            "enableLowLatency": obj.get("enableLowLatency"),
            "latencyPreference": obj.get("latencyPreference"),
            "mesh": obj.get("mesh"),
            "monitorStream": MonitorStreamInfo.from_dict(obj["monitorStream"]) if obj.get("monitorStream") is not None else None,
            "projection": obj.get("projection"),
            "recordFromStart": obj.get("recordFromStart"),
            "startWithSlate": obj.get("startWithSlate"),
            "stereoLayout": obj.get("stereoLayout")
        })
        return _obj


