# coding: utf-8

"""
    Cyberwave API

    Cyberwave platform REST API. Use 'Bearer YOUR_TOKEN' for authentication.

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

class MapDataSchema(BaseModel):
    """
    Schema for map data.
    """ # noqa: E501
    uuid: StrictStr
    twin_uuid: Optional[StrictStr] = None
    environment_uuid: Optional[StrictStr] = None
    map_type: StrictStr
    resolution: Optional[Union[StrictFloat, StrictInt]] = None
    origin_x: Union[StrictFloat, StrictInt]
    origin_y: Union[StrictFloat, StrictInt]
    origin_z: Union[StrictFloat, StrictInt]
    origin_roll: Union[StrictFloat, StrictInt]
    origin_pitch: Union[StrictFloat, StrictInt]
    origin_yaw: Union[StrictFloat, StrictInt]
    data_file_uuid: StrictStr
    image_width: Optional[StrictInt] = None
    image_height: Optional[StrictInt] = None
    metadata: Optional[Dict[str, Any]] = None
    created_at: datetime
    updated_at: datetime
    __properties: ClassVar[List[str]] = ["uuid", "twin_uuid", "environment_uuid", "map_type", "resolution", "origin_x", "origin_y", "origin_z", "origin_roll", "origin_pitch", "origin_yaw", "data_file_uuid", "image_width", "image_height", "metadata", "created_at", "updated_at"]

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

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

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

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

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

        # 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 MapDataSchema from a dict"""
        if obj is None:
            return None

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

        _obj = cls.model_validate({
            "uuid": obj.get("uuid"),
            "twin_uuid": obj.get("twin_uuid"),
            "environment_uuid": obj.get("environment_uuid"),
            "map_type": obj.get("map_type"),
            "resolution": obj.get("resolution"),
            "origin_x": obj.get("origin_x"),
            "origin_y": obj.get("origin_y"),
            "origin_z": obj.get("origin_z"),
            "origin_roll": obj.get("origin_roll"),
            "origin_pitch": obj.get("origin_pitch"),
            "origin_yaw": obj.get("origin_yaw"),
            "data_file_uuid": obj.get("data_file_uuid"),
            "image_width": obj.get("image_width"),
            "image_height": obj.get("image_height"),
            "metadata": obj.get("metadata"),
            "created_at": obj.get("created_at"),
            "updated_at": obj.get("updated_at")
        })
        return _obj


