# 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 pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt
from typing import Any, ClassVar, Dict, List, Optional, Union
from cyberwave.rest.models.metadata import Metadata
from typing import Optional, Set
from typing_extensions import Self

class MapStreamFinalizeSchema(BaseModel):
    """
    Schema for finalizing a stream-started map with real file data.
    """ # noqa: E501
    resolution: Optional[Union[StrictFloat, StrictInt]] = None
    origin_x: Optional[Union[StrictFloat, StrictInt]] = None
    origin_y: Optional[Union[StrictFloat, StrictInt]] = None
    origin_z: Optional[Union[StrictFloat, StrictInt]] = None
    origin_roll: Optional[Union[StrictFloat, StrictInt]] = None
    origin_pitch: Optional[Union[StrictFloat, StrictInt]] = None
    origin_yaw: Optional[Union[StrictFloat, StrictInt]] = None
    metadata: Optional[Metadata] = None
    __properties: ClassVar[List[str]] = ["resolution", "origin_x", "origin_y", "origin_z", "origin_roll", "origin_pitch", "origin_yaw", "metadata"]

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

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

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

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

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

        # set to None if origin_yaw (nullable) is None
        # and model_fields_set contains the field
        if self.origin_yaw is None and "origin_yaw" in self.model_fields_set:
            _dict['origin_yaw'] = 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 MapStreamFinalizeSchema from a dict"""
        if obj is None:
            return None

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

        _obj = cls.model_validate({
            "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"),
            "metadata": Metadata.from_dict(obj["metadata"]) if obj.get("metadata") is not None else None
        })
        return _obj


