# coding: utf-8

"""
    Jellyfin API

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

    The version of the OpenAPI document: 10.11.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, StrictBool, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from openapi_client.models.device_profile import DeviceProfile
from openapi_client.models.general_command_type import GeneralCommandType
from openapi_client.models.media_type import MediaType
from typing import Optional, Set
from typing_extensions import Self

class ClientCapabilitiesDto(BaseModel):
    """
    Client capabilities dto.
    """ # noqa: E501
    playable_media_types: Optional[List[MediaType]] = Field(default=None, description="Gets or sets the list of playable media types.", alias="PlayableMediaTypes")
    supported_commands: Optional[List[GeneralCommandType]] = Field(default=None, description="Gets or sets the list of supported commands.", alias="SupportedCommands")
    supports_media_control: Optional[StrictBool] = Field(default=None, description="Gets or sets a value indicating whether session supports media control.", alias="SupportsMediaControl")
    supports_persistent_identifier: Optional[StrictBool] = Field(default=None, description="Gets or sets a value indicating whether session supports a persistent identifier.", alias="SupportsPersistentIdentifier")
    device_profile: Optional[DeviceProfile] = Field(default=None, description="Gets or sets the device profile.", alias="DeviceProfile")
    app_store_url: Optional[StrictStr] = Field(default=None, description="Gets or sets the app store url.", alias="AppStoreUrl")
    icon_url: Optional[StrictStr] = Field(default=None, description="Gets or sets the icon url.", alias="IconUrl")
    __properties: ClassVar[List[str]] = ["PlayableMediaTypes", "SupportedCommands", "SupportsMediaControl", "SupportsPersistentIdentifier", "DeviceProfile", "AppStoreUrl", "IconUrl"]

    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 ClientCapabilitiesDto 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 device_profile
        if self.device_profile:
            _dict['DeviceProfile'] = self.device_profile.to_dict()
        # set to None if device_profile (nullable) is None
        # and model_fields_set contains the field
        if self.device_profile is None and "device_profile" in self.model_fields_set:
            _dict['DeviceProfile'] = None

        # set to None if app_store_url (nullable) is None
        # and model_fields_set contains the field
        if self.app_store_url is None and "app_store_url" in self.model_fields_set:
            _dict['AppStoreUrl'] = None

        # set to None if icon_url (nullable) is None
        # and model_fields_set contains the field
        if self.icon_url is None and "icon_url" in self.model_fields_set:
            _dict['IconUrl'] = None

        return _dict

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

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

        _obj = cls.model_validate({
            "PlayableMediaTypes": obj.get("PlayableMediaTypes"),
            "SupportedCommands": obj.get("SupportedCommands"),
            "SupportsMediaControl": obj.get("SupportsMediaControl"),
            "SupportsPersistentIdentifier": obj.get("SupportsPersistentIdentifier"),
            "DeviceProfile": DeviceProfile.from_dict(obj["DeviceProfile"]) if obj.get("DeviceProfile") is not None else None,
            "AppStoreUrl": obj.get("AppStoreUrl"),
            "IconUrl": obj.get("IconUrl")
        })
        return _obj


