# coding: utf-8

"""
    asset-lake-api-server

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

    The version of the OpenAPI document: 0.1
    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 typing import Any, ClassVar, Dict, List, Optional
from pydantic import BaseModel, StrictBool, StrictStr
from pydantic import Field
from typing_extensions import Annotated
from clients.asset_lake.models.asset_type import AssetType
from clients.asset_lake.models.transfer_api_type import TransferApiType
try:
    from typing import Self
except ImportError:
    from typing_extensions import Self

class CreateAssetRequest(BaseModel):
    """
    CreateAssetRequest
    """ # noqa: E501
    asset_type: AssetType
    data: Dict[str, Any] = Field(description="Data specific to the asset type; use the class named ${asset_type}Data")
    description: Optional[StrictStr]
    hf_repo: Optional[StrictStr] = None
    is_public: Optional[StrictBool] = Field(default=False, description="True if asset is public.")
    name: StrictStr = Field(description="Asset name.")
    transfer_api_type: Optional[TransferApiType] = None
    url: Optional[Annotated[str, Field(min_length=1, strict=True, max_length=2083)]] = None
    __properties: ClassVar[List[str]] = ["asset_type", "data", "description", "hf_repo", "is_public", "name", "transfer_api_type", "url"]

    model_config = {
        "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) -> Self:
        """Create an instance of CreateAssetRequest 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.
        """
        _dict = self.model_dump(
            by_alias=True,
            exclude={
            },
            exclude_none=True,
        )
        # set to None if description (nullable) is None
        # and model_fields_set contains the field
        if self.description is None and "description" in self.model_fields_set:
            _dict['description'] = None

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

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

        return _dict

    @classmethod
    def from_dict(cls, obj: Dict) -> Self:
        """Create an instance of CreateAssetRequest from a dict"""
        if obj is None:
            return None

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

        _obj = cls.model_validate({
            "asset_type": obj.get("asset_type"),
            "data": obj.get("data"),
            "description": obj.get("description"),
            "hf_repo": obj.get("hf_repo"),
            "is_public": obj.get("is_public") if obj.get("is_public") is not None else False,
            "name": obj.get("name"),
            "transfer_api_type": obj.get("transfer_api_type"),
            "url": obj.get("url")
        })
        return _obj


