# coding: utf-8

"""
    Canva Connect API

    API for building integrations with Canva via a REST api

    The version of the OpenAPI document: latest
    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, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from canva_alpha_ti.models.asset_type import AssetType
from canva_alpha_ti.models.import_status import ImportStatus
from canva_alpha_ti.models.thumbnail import Thumbnail
from typing import Optional, Set
from typing_extensions import Self

class Asset(BaseModel):
    """
    The asset object, which contains metadata about the asset.
    """ # noqa: E501
    type: AssetType
    id: StrictStr = Field(description="The ID of the asset.")
    name: StrictStr = Field(description="The name of the asset.")
    tags: List[StrictStr] = Field(description="The user-facing tags attached to the asset. Users can add these tags to their uploaded assets, and they can search their uploaded assets in the Canva UI by searching for these tags. For information on how users use tags, see the [Canva Help Center page on asset tags](https://www.canva.com/help/add-edit-tags/).")
    import_status: Optional[ImportStatus] = None
    created_at: StrictInt = Field(description="When the asset was added to Canva, as a Unix timestamp (in seconds since the Unix Epoch).")
    updated_at: StrictInt = Field(description="When the asset was last updated in Canva, as a Unix timestamp (in seconds since the Unix Epoch).")
    thumbnail: Optional[Thumbnail] = None
    __properties: ClassVar[List[str]] = ["type", "id", "name", "tags", "import_status", "created_at", "updated_at", "thumbnail"]

    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 Asset 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 import_status
        if self.import_status:
            _dict['import_status'] = self.import_status.to_dict()
        # override the default output from pydantic by calling `to_dict()` of thumbnail
        if self.thumbnail:
            _dict['thumbnail'] = self.thumbnail.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "type": obj.get("type"),
            "id": obj.get("id"),
            "name": obj.get("name"),
            "tags": obj.get("tags"),
            "import_status": ImportStatus.from_dict(obj["import_status"]) if obj.get("import_status") is not None else None,
            "created_at": obj.get("created_at"),
            "updated_at": obj.get("updated_at"),
            "thumbnail": Thumbnail.from_dict(obj["thumbnail"]) if obj.get("thumbnail") is not None else None
        })
        return _obj


