# 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 em_toolhub.models.get_survey200_response_body_data_raw import GetSurvey200ResponseBodyDataRaw
from typing import Optional, Set
from typing_extensions import Self

class ListSurveys200ResponseBodyDataSurveysInner(BaseModel):
    """
    ListSurveys200ResponseBodyDataSurveysInner
    """ # noqa: E501
    id: StrictStr
    wellbore_id: StrictStr
    md: Union[StrictFloat, StrictInt]
    inclination: Union[StrictFloat, StrictInt]
    azimuth: Union[StrictFloat, StrictInt]
    gyro_azimuth: Optional[Union[StrictFloat, StrictInt]]
    toolface: Optional[Union[StrictFloat, StrictInt]]
    magnetic_toolface: Optional[Union[StrictFloat, StrictInt]]
    gyro_toolface: Optional[Union[StrictFloat, StrictInt]]
    timestamp: StrictStr
    status: StrictStr
    raw: Optional[GetSurvey200ResponseBodyDataRaw] = None
    __properties: ClassVar[List[str]] = ["id", "wellbore_id", "md", "inclination", "azimuth", "gyro_azimuth", "toolface", "magnetic_toolface", "gyro_toolface", "timestamp", "status", "raw"]

    @field_validator('status')
    def status_validate_enum(cls, value):
        """Validates the enum"""
        if value not in set(['pending', 'approved', 'rejected']):
            raise ValueError("must be one of enum values ('pending', 'approved', 'rejected')")
        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 ListSurveys200ResponseBodyDataSurveysInner 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 raw
        if self.raw:
            _dict['raw'] = self.raw.to_dict()
        # set to None if gyro_azimuth (nullable) is None
        # and model_fields_set contains the field
        if self.gyro_azimuth is None and "gyro_azimuth" in self.model_fields_set:
            _dict['gyro_azimuth'] = None

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

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

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

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of ListSurveys200ResponseBodyDataSurveysInner 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"),
            "wellbore_id": obj.get("wellbore_id"),
            "md": obj.get("md"),
            "inclination": obj.get("inclination"),
            "azimuth": obj.get("azimuth"),
            "gyro_azimuth": obj.get("gyro_azimuth"),
            "toolface": obj.get("toolface"),
            "magnetic_toolface": obj.get("magnetic_toolface"),
            "gyro_toolface": obj.get("gyro_toolface"),
            "timestamp": obj.get("timestamp"),
            "status": obj.get("status"),
            "raw": GetSurvey200ResponseBodyDataRaw.from_dict(obj["raw"]) if obj.get("raw") is not None else None
        })
        return _obj


