# coding: utf-8

"""
    ToolHub Customer API

    REST API for customer access to ToolHub well data.  ## Authentication  All endpoints require Bearer token authentication using an API key:  ``` Authorization: Bearer thub_live_xxxxxxxxxxxxxxxxxxxx ```  API keys are issued per-organization and inherit well access permissions.  ## Rate Limits  - Standard tier: 70 requests/minute - Premium tier: 300 requests/minute

    The version of the OpenAPI document: 0.1.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, StrictFloat, StrictInt, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional, Union
from typing import Optional, Set
from typing_extensions import Self

class GetFile200ResponseBodyData(BaseModel):
    """
    GetFile200ResponseBodyData
    """ # noqa: E501
    id: StrictStr
    filename: StrictStr
    file_type: StrictStr
    content_type: StrictStr
    size_bytes: Union[StrictFloat, StrictInt]
    uploaded_by: StrictStr
    uploaded_at: StrictStr
    metadata: Optional[Dict[str, Any]]
    download_url: Optional[StrictStr] = None
    __properties: ClassVar[List[str]] = ["id", "filename", "file_type", "content_type", "size_bytes", "uploaded_by", "uploaded_at", "metadata", "download_url"]

    @field_validator('file_type')
    def file_type_validate_enum(cls, value):
        """Validates the enum"""
        if value not in set(['tool_download', 'las', 'report', 'csv', 'image', 'unknown']):
            raise ValueError("must be one of enum values ('tool_download', 'las', 'report', 'csv', 'image', 'unknown')")
        return value

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

        return _dict

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

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

        _obj = cls.model_validate({
            "id": obj.get("id"),
            "filename": obj.get("filename"),
            "file_type": obj.get("file_type"),
            "content_type": obj.get("content_type"),
            "size_bytes": obj.get("size_bytes"),
            "uploaded_by": obj.get("uploaded_by"),
            "uploaded_at": obj.get("uploaded_at"),
            "metadata": obj.get("metadata"),
            "download_url": obj.get("download_url")
        })
        return _obj


