# 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, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from youtube_ti.models.playlist_content_details import PlaylistContentDetails
from youtube_ti.models.playlist_player import PlaylistPlayer
from youtube_ti.models.playlist_snippet import PlaylistSnippet
from youtube_ti.models.playlist_status import PlaylistStatus
from typing import Optional, Set
from typing_extensions import Self

class Playlist(BaseModel):
    """
    A *playlist* resource represents a YouTube playlist. A playlist is a collection of videos that can be viewed sequentially and shared with other users. A playlist can contain up to 200 videos, and YouTube does not limit the number of playlists that each user creates. By default, playlists are publicly visible to other users, but playlists can be public or private. YouTube also uses playlists to identify special collections of videos for a channel, such as: - uploaded videos - favorite videos - positively rated (liked) videos - watch history - watch later To be more specific, these lists are associated with a channel, which is a collection of a person, group, or company's videos, playlists, and other YouTube information. You can retrieve the playlist IDs for each of these lists from the channel resource for a given channel. You can then use the playlistItems.list method to retrieve any of those lists. You can also add or remove items from those lists by calling the playlistItems.insert and playlistItems.delete methods.
    """ # noqa: E501
    content_details: Optional[PlaylistContentDetails] = Field(default=None, alias="contentDetails")
    etag: Optional[StrictStr] = Field(default=None, description="Etag of this resource.")
    id: Optional[StrictStr] = Field(default=None, description="The ID that YouTube uses to uniquely identify the playlist.")
    kind: Optional[StrictStr] = Field(default='youtube#playlist', description="Identifies what kind of resource this is. Value: the fixed string \"youtube#playlist\".")
    localizations: Optional[Dict[str, Any]] = Field(default=None, description="Localizations for different languages")
    player: Optional[PlaylistPlayer] = None
    snippet: Optional[PlaylistSnippet] = None
    status: Optional[PlaylistStatus] = None
    __properties: ClassVar[List[str]] = ["contentDetails", "etag", "id", "kind", "localizations", "player", "snippet", "status"]

    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 Playlist 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_details
        if self.content_details:
            _dict['contentDetails'] = self.content_details.to_dict()
        # override the default output from pydantic by calling `to_dict()` of player
        if self.player:
            _dict['player'] = self.player.to_dict()
        # override the default output from pydantic by calling `to_dict()` of snippet
        if self.snippet:
            _dict['snippet'] = self.snippet.to_dict()
        # override the default output from pydantic by calling `to_dict()` of status
        if self.status:
            _dict['status'] = self.status.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "contentDetails": PlaylistContentDetails.from_dict(obj["contentDetails"]) if obj.get("contentDetails") is not None else None,
            "etag": obj.get("etag"),
            "id": obj.get("id"),
            "kind": obj.get("kind") if obj.get("kind") is not None else 'youtube#playlist',
            "localizations": obj.get("localizations"),
            "player": PlaylistPlayer.from_dict(obj["player"]) if obj.get("player") is not None else None,
            "snippet": PlaylistSnippet.from_dict(obj["snippet"]) if obj.get("snippet") is not None else None,
            "status": PlaylistStatus.from_dict(obj["status"]) if obj.get("status") is not None else None
        })
        return _obj


