# 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, StrictFloat, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional, Union
from orbital_transfer.models.bounded_ephemeris import BoundedEphemeris
from orbital_transfer.models.numerical_orbital_transfer_result_field_indexes_inner import NumericalOrbitalTransferResultFieldIndexesInner
from orbital_transfer.models.orbit import Orbit
from orbital_transfer.models.spacecraft_state import SpacecraftState
from typing import Optional, Set
from typing_extensions import Self

class NumericalOrbitalTransferResult(BaseModel):
    """
    NumericalOrbitalTransferResult
    """ # noqa: E501
    delta_inclination: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="TODO", alias="deltaInclination")
    delta_eccentricity: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="TODO", alias="deltaEccentricity")
    delta_semi_major_axis: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="TODO", alias="deltaSemiMajorAxis")
    total_number_of_burns: Optional[StrictInt] = Field(default=None, description="TODO", alias="totalNumberOfBurns")
    total_burn_duration: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="TODO", alias="totalBurnDuration")
    total_consumption: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="TODO", alias="totalConsumption")
    total_delta_v: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="TODO", alias="totalDeltaV")
    thruster_duty_cycle: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="TODO", alias="thrusterDutyCycle")
    total_warmup_duty_cycle: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="TODO", alias="totalWarmupDutyCycle")
    average_thrust_duration: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="TODO", alias="averageThrustDuration")
    simulation_duration: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="TODO", alias="simulationDuration")
    number_of_periods: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="TODO", alias="numberOfPeriods")
    total_impulse: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="TODO", alias="totalImpulse")
    final_duty_cycle: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="TODO", alias="finalDutyCycle")
    ephemerides: Optional[List[List[Union[StrictFloat, StrictInt]]]] = Field(default=None, description="TODO")
    field_indexes: Optional[List[NumericalOrbitalTransferResultFieldIndexesInner]] = Field(default=None, description="TODO", alias="fieldIndexes")
    threed_ephemerides: Optional[List[List[Union[StrictFloat, StrictInt]]]] = Field(default=None, description="TODO", alias="threedEphemerides")
    threed_field_indexes: Optional[List[NumericalOrbitalTransferResultFieldIndexesInner]] = Field(default=None, description="TODO", alias="threedFieldIndexes")
    osc_bounded_ephemerides: Optional[List[BoundedEphemeris]] = Field(default=None, description="TODO", alias="oscBoundedEphemerides")
    mean_bounded_ephemerides: Optional[List[BoundedEphemeris]] = Field(default=None, description="TODO", alias="meanBoundedEphemerides")
    osc_ephemerides_for_thrust: Optional[List[SpacecraftState]] = Field(default=None, description="TODO", alias="oscEphemeridesForThrust")
    ephemerides_frame: Optional[StrictStr] = Field(default=None, description="TODO", alias="ephemeridesFrame")
    maneuver_model: Optional[StrictStr] = Field(default=None, description="TODO", alias="maneuverModel")
    final_orbit: Optional[Orbit] = Field(default=None, alias="finalOrbit")
    errors: Optional[List[StrictStr]] = None
    warnings: Optional[List[StrictStr]] = None
    computation_date: Optional[StrictStr] = Field(default=None, alias="computationDate")
    __properties: ClassVar[List[str]] = ["deltaInclination", "deltaEccentricity", "deltaSemiMajorAxis", "totalNumberOfBurns", "totalBurnDuration", "totalConsumption", "totalDeltaV", "thrusterDutyCycle", "totalWarmupDutyCycle", "averageThrustDuration", "simulationDuration", "numberOfPeriods", "totalImpulse", "finalDutyCycle", "ephemerides", "fieldIndexes", "threedEphemerides", "threedFieldIndexes", "oscBoundedEphemerides", "meanBoundedEphemerides", "oscEphemeridesForThrust", "ephemeridesFrame", "maneuverModel", "finalOrbit", "errors", "warnings", "computationDate"]

    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 NumericalOrbitalTransferResult 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 each item in field_indexes (list)
        _items = []
        if self.field_indexes:
            for _item in self.field_indexes:
                if _item:
                    _items.append(_item.to_dict())
            _dict['fieldIndexes'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in threed_field_indexes (list)
        _items = []
        if self.threed_field_indexes:
            for _item in self.threed_field_indexes:
                if _item:
                    _items.append(_item.to_dict())
            _dict['threedFieldIndexes'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in osc_bounded_ephemerides (list)
        _items = []
        if self.osc_bounded_ephemerides:
            for _item in self.osc_bounded_ephemerides:
                if _item:
                    _items.append(_item.to_dict())
            _dict['oscBoundedEphemerides'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in mean_bounded_ephemerides (list)
        _items = []
        if self.mean_bounded_ephemerides:
            for _item in self.mean_bounded_ephemerides:
                if _item:
                    _items.append(_item.to_dict())
            _dict['meanBoundedEphemerides'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in osc_ephemerides_for_thrust (list)
        _items = []
        if self.osc_ephemerides_for_thrust:
            for _item in self.osc_ephemerides_for_thrust:
                if _item:
                    _items.append(_item.to_dict())
            _dict['oscEphemeridesForThrust'] = _items
        # override the default output from pydantic by calling `to_dict()` of final_orbit
        if self.final_orbit:
            _dict['finalOrbit'] = self.final_orbit.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "deltaInclination": obj.get("deltaInclination"),
            "deltaEccentricity": obj.get("deltaEccentricity"),
            "deltaSemiMajorAxis": obj.get("deltaSemiMajorAxis"),
            "totalNumberOfBurns": obj.get("totalNumberOfBurns"),
            "totalBurnDuration": obj.get("totalBurnDuration"),
            "totalConsumption": obj.get("totalConsumption"),
            "totalDeltaV": obj.get("totalDeltaV"),
            "thrusterDutyCycle": obj.get("thrusterDutyCycle"),
            "totalWarmupDutyCycle": obj.get("totalWarmupDutyCycle"),
            "averageThrustDuration": obj.get("averageThrustDuration"),
            "simulationDuration": obj.get("simulationDuration"),
            "numberOfPeriods": obj.get("numberOfPeriods"),
            "totalImpulse": obj.get("totalImpulse"),
            "finalDutyCycle": obj.get("finalDutyCycle"),
            "ephemerides": obj.get("ephemerides"),
            "fieldIndexes": [NumericalOrbitalTransferResultFieldIndexesInner.from_dict(_item) for _item in obj["fieldIndexes"]] if obj.get("fieldIndexes") is not None else None,
            "threedEphemerides": obj.get("threedEphemerides"),
            "threedFieldIndexes": [NumericalOrbitalTransferResultFieldIndexesInner.from_dict(_item) for _item in obj["threedFieldIndexes"]] if obj.get("threedFieldIndexes") is not None else None,
            "oscBoundedEphemerides": [BoundedEphemeris.from_dict(_item) for _item in obj["oscBoundedEphemerides"]] if obj.get("oscBoundedEphemerides") is not None else None,
            "meanBoundedEphemerides": [BoundedEphemeris.from_dict(_item) for _item in obj["meanBoundedEphemerides"]] if obj.get("meanBoundedEphemerides") is not None else None,
            "oscEphemeridesForThrust": [SpacecraftState.from_dict(_item) for _item in obj["oscEphemeridesForThrust"]] if obj.get("oscEphemeridesForThrust") is not None else None,
            "ephemeridesFrame": obj.get("ephemeridesFrame"),
            "maneuverModel": obj.get("maneuverModel"),
            "finalOrbit": Orbit.from_dict(obj["finalOrbit"]) if obj.get("finalOrbit") is not None else None,
            "errors": obj.get("errors"),
            "warnings": obj.get("warnings"),
            "computationDate": obj.get("computationDate")
        })
        return _obj


