# coding: utf-8

"""
    FreeClimb API

    FreeClimb is a cloud-based application programming interface (API) that puts the power of the Vail platform in your hands. FreeClimb simplifies the process of creating applications that can use a full range of telephony features without requiring specialized or on-site telephony equipment. Using the FreeClimb REST API to write applications is easy! You have the option to use the language of your choice or hit the API directly. Your application can execute a command by issuing a RESTful request to the FreeClimb API. The base URL to send HTTP requests to the FreeClimb REST API is: /apiserver. FreeClimb authenticates and processes your request.

    The version of the OpenAPI document: 1.0.0
    Contact: support@freeclimb.com
    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, StrictInt, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from pydantic import StrictStr
from typing import Optional, Set
from typing_extensions import Self


class BlobResult(
    BaseModel, populate_by_name=True, validate_assignment=True, protected_namespaces=()
):
    """
    BlobResult
    """  # noqa: E501

    blob_id: Optional[Annotated[str, Field(strict=True)]] = Field(
        default=None,
        description="Identifier which can be used to reference this blob in future interations.",
        alias="blobId",
    )
    account_id: Optional[Annotated[str, Field(strict=True)]] = Field(
        default=None, alias="accountId"
    )
    alias: Optional[Annotated[str, Field(strict=True, max_length=64)]] = Field(
        default=None,
        description="Custom identifier for this blob that is unique for the owning account. It will be set to the blobId by default if not provided in the creation request.",
    )
    revision: Optional[StrictInt] = None
    date_created: Optional[datetime] = Field(
        default=None,
        description="An RFC3339 timestamp with millisecond resolution. It represents the time this blob was created.",
        alias="dateCreated",
    )
    date_updated: Optional[datetime] = Field(
        default=None,
        description="An RFC3339 timestamp with millisecond resolution. It represents the time this blob was last modified, which at creation will always equal dateCreated.",
        alias="dateUpdated",
    )
    expires_at: Optional[datetime] = Field(
        default=None,
        description="An RFC3339 timestamp with millisecond resolution. It represents the time at which this blob will expire and self delete.",
        alias="expiresAt",
    )
    blob: Optional[Dict[str, Any]] = Field(default=None, description="Blob content")

    __properties: ClassVar[List[str]] = [
        "blobId",
        "accountId",
        "alias",
        "revision",
        "dateCreated",
        "dateUpdated",
        "expiresAt",
        "blob",
    ]

    @field_validator("blob_id")
    def blob_id_validate_regular_expression(cls, value):
        """Validates the regular expression"""
        if value is None:
            return value

        if not re.match(r"BL[0-9a-fA-F]{40}", value):
            raise ValueError(
                r"must validate the regular expression /BL[0-9a-fA-F]{40}/"
            )
        return value

    @field_validator("account_id")
    def account_id_validate_regular_expression(cls, value):
        """Validates the regular expression"""
        if value is None:
            return value

        if not re.match(r"AC[0-9a-fA-F]{40}", value):
            raise ValueError(
                r"must validate the regular expression /AC[0-9a-fA-F]{40}/"
            )
        return value

    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 BlobResult 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,
        )
        return _dict

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

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

        _obj = cls.model_validate(
            {
                "blobId": obj.get("blobId"),
                "accountId": obj.get("accountId"),
                "alias": obj.get("alias"),
                "revision": obj.get("revision"),
                "dateCreated": obj.get("dateCreated"),
                "dateUpdated": obj.get("dateUpdated"),
                "expiresAt": obj.get("expiresAt"),
                "blob": obj.get("blob"),
            }
        )
        return _obj
