# coding: utf-8

"""
    Orbital transfer API

    Orbital transfer API

    The version of the OpenAPI document: 0.0.6
    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, Field, StrictBool, StrictFloat, StrictInt
from typing import Any, ClassVar, Dict, List, Optional, Union
from orbital_transfer.models.parametric_propulsion_system import ParametricPropulsionSystem
from typing import Optional, Set
from typing_extensions import Self

class ParametricSpacecraft(BaseModel):
    """
    ParametricSpacecraft
    """ # noqa: E501
    platform_mass: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="platformMass")
    orbital_average_power: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="orbitalAveragePower")
    custom_orbital_duty_cycle: Optional[StrictBool] = Field(default=None, alias="customOrbitalDutyCycle")
    orbital_duty_cycle: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="orbitalDutyCycle")
    drag_area: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="dragArea")
    drag_coefficient: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="dragCoefficient")
    solar_radiation_pressure_center_in_spacecraft_frame_x: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="solarRadiationPressureCenterInSpacecraftFrameX")
    solar_radiation_pressure_center_in_spacecraft_frame_y: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="solarRadiationPressureCenterInSpacecraftFrameY")
    solar_radiation_pressure_center_in_spacecraft_frame_z: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="solarRadiationPressureCenterInSpacecraftFrameZ")
    inertia_xx: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="inertiaXX")
    inertia_xy: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="inertiaXY")
    inertia_xz: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="inertiaXZ")
    inertia_yy: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="inertiaYY")
    inertia_yz: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="inertiaYZ")
    inertia_zz: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="inertiaZZ")
    inertia_zx: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="inertiaZX")
    inertia_zy: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="inertiaZY")
    inertia_yx: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="inertiaYX")
    max_angular_rate: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="maxAngularRate")
    min_angular_rate: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="minAngularRate")
    thruster: Optional[ParametricPropulsionSystem] = None
    __properties: ClassVar[List[str]] = ["platformMass", "orbitalAveragePower", "customOrbitalDutyCycle", "orbitalDutyCycle", "dragArea", "dragCoefficient", "solarRadiationPressureCenterInSpacecraftFrameX", "solarRadiationPressureCenterInSpacecraftFrameY", "solarRadiationPressureCenterInSpacecraftFrameZ", "inertiaXX", "inertiaXY", "inertiaXZ", "inertiaYY", "inertiaYZ", "inertiaZZ", "inertiaZX", "inertiaZY", "inertiaYX", "maxAngularRate", "minAngularRate", "thruster"]

    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 ParametricSpacecraft 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 thruster
        if self.thruster:
            _dict['thruster'] = self.thruster.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "platformMass": obj.get("platformMass"),
            "orbitalAveragePower": obj.get("orbitalAveragePower"),
            "customOrbitalDutyCycle": obj.get("customOrbitalDutyCycle"),
            "orbitalDutyCycle": obj.get("orbitalDutyCycle"),
            "dragArea": obj.get("dragArea"),
            "dragCoefficient": obj.get("dragCoefficient"),
            "solarRadiationPressureCenterInSpacecraftFrameX": obj.get("solarRadiationPressureCenterInSpacecraftFrameX"),
            "solarRadiationPressureCenterInSpacecraftFrameY": obj.get("solarRadiationPressureCenterInSpacecraftFrameY"),
            "solarRadiationPressureCenterInSpacecraftFrameZ": obj.get("solarRadiationPressureCenterInSpacecraftFrameZ"),
            "inertiaXX": obj.get("inertiaXX"),
            "inertiaXY": obj.get("inertiaXY"),
            "inertiaXZ": obj.get("inertiaXZ"),
            "inertiaYY": obj.get("inertiaYY"),
            "inertiaYZ": obj.get("inertiaYZ"),
            "inertiaZZ": obj.get("inertiaZZ"),
            "inertiaZX": obj.get("inertiaZX"),
            "inertiaZY": obj.get("inertiaZY"),
            "inertiaYX": obj.get("inertiaYX"),
            "maxAngularRate": obj.get("maxAngularRate"),
            "minAngularRate": obj.get("minAngularRate"),
            "thruster": ParametricPropulsionSystem.from_dict(obj["thruster"]) if obj.get("thruster") is not None else None
        })
        return _obj


