# 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, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional, Union
from orbital_transfer.models.orbit import Orbit
from orbital_transfer.models.spacecraft import Spacecraft
from typing import Optional, Set
from typing_extensions import Self

class NumericalOrbitalTransferRequest(BaseModel):
    """
    NumericalOrbitalTransferRequest
    """ # noqa: E501
    mission_date_time: Optional[StrictStr] = Field(default=None, description="The simulation date", alias="missionDateTime")
    maximum_duration: Optional[StrictInt] = Field(default=None, description="The simulation maximum duration (in days)", alias="maximumDuration")
    propagation_type: StrictStr = Field(description="The type of propagation to use for the computation", alias="propagationType")
    spacecraft: Spacecraft
    initial_orbit: Orbit = Field(alias="initialOrbit")
    target_orbit: Orbit = Field(alias="targetOrbit")
    perturbations: Optional[List[StrictStr]] = Field(default=None, description="The perturbations to take into account for the propagation")
    ephemerides_requested: Optional[List[StrictStr]] = Field(default=None, alias="ephemeridesRequested")
    ephemerides_step_in_seconds: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="ephemeridesStepInSeconds")
    ephemerides_mean_choice: Optional[StrictBool] = Field(default=None, alias="ephemeridesMeanChoice")
    ephemerides_osc_choice: Optional[StrictBool] = Field(default=None, alias="ephemeridesOscChoice")
    custom_solar_flux: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="If drag perturbation is enabled, the custom solar flux to use", alias="customSolarFlux")
    custom_earth_potential_order: Optional[StrictInt] = Field(default=None, description="If earth potential perturbation is enabled, the custom earth potential order", alias="customEarthPotentialOrder")
    custom_earth_potential_degree: Optional[StrictInt] = Field(default=None, description="If earth potential perturbation is enabled, the custom earth potential degree", alias="customEarthPotentialDegree")
    with_eclipse: Optional[StrictBool] = Field(default=None, description=" Indicates whether to take eclipse into consideration or not", alias="withEclipse")
    __properties: ClassVar[List[str]] = ["missionDateTime", "maximumDuration", "propagationType", "spacecraft", "initialOrbit", "targetOrbit", "perturbations", "ephemeridesRequested", "ephemeridesStepInSeconds", "ephemeridesMeanChoice", "ephemeridesOscChoice", "customSolarFlux", "customEarthPotentialOrder", "customEarthPotentialDegree", "withEclipse"]

    @field_validator('propagation_type')
    def propagation_type_validate_enum(cls, value):
        """Validates the enum"""
        if value not in set(['NUMERICAL', 'SEMI_ANALYTICAL']):
            raise ValueError("must be one of enum values ('NUMERICAL', 'SEMI_ANALYTICAL')")
        return value

    @field_validator('perturbations')
    def perturbations_validate_enum(cls, value):
        """Validates the enum"""
        if value is None:
            return value

        for i in value:
            if i not in set(['DRAG', 'SRP', 'EARTH_POTENTIAL', 'THIRD_BODY']):
                raise ValueError("each list item must be one of ('DRAG', 'SRP', 'EARTH_POTENTIAL', 'THIRD_BODY')")
        return value

    @field_validator('ephemerides_requested')
    def ephemerides_requested_validate_enum(cls, value):
        """Validates the enum"""
        if value is None:
            return value

        for i in value:
            if i not in set(['CARTESIAN', 'KEPLERIAN', 'CIRCULAR', 'EQUINOCTIAL', 'THRUST', 'SYSTEM', 'ECLIPSE', 'ATTITUDE', 'MANOEUVRING_STRATEGIES', 'CESIUM_POSITION', 'CESIUM_ATTITUDE', 'THRUSTER_AXES_CONSUMPTION', 'QUATERNIONS', 'EULER_ANGLES', 'LINK_BUDGET']):
                raise ValueError("each list item must be one of ('CARTESIAN', 'KEPLERIAN', 'CIRCULAR', 'EQUINOCTIAL', 'THRUST', 'SYSTEM', 'ECLIPSE', 'ATTITUDE', 'MANOEUVRING_STRATEGIES', 'CESIUM_POSITION', 'CESIUM_ATTITUDE', 'THRUSTER_AXES_CONSUMPTION', 'QUATERNIONS', 'EULER_ANGLES', 'LINK_BUDGET')")
        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 NumericalOrbitalTransferRequest 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 spacecraft
        if self.spacecraft:
            _dict['spacecraft'] = self.spacecraft.to_dict()
        # override the default output from pydantic by calling `to_dict()` of initial_orbit
        if self.initial_orbit:
            _dict['initialOrbit'] = self.initial_orbit.to_dict()
        # override the default output from pydantic by calling `to_dict()` of target_orbit
        if self.target_orbit:
            _dict['targetOrbit'] = self.target_orbit.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "missionDateTime": obj.get("missionDateTime"),
            "maximumDuration": obj.get("maximumDuration"),
            "propagationType": obj.get("propagationType"),
            "spacecraft": Spacecraft.from_dict(obj["spacecraft"]) if obj.get("spacecraft") is not None else None,
            "initialOrbit": Orbit.from_dict(obj["initialOrbit"]) if obj.get("initialOrbit") is not None else None,
            "targetOrbit": Orbit.from_dict(obj["targetOrbit"]) if obj.get("targetOrbit") is not None else None,
            "perturbations": obj.get("perturbations"),
            "ephemeridesRequested": obj.get("ephemeridesRequested"),
            "ephemeridesStepInSeconds": obj.get("ephemeridesStepInSeconds"),
            "ephemeridesMeanChoice": obj.get("ephemeridesMeanChoice"),
            "ephemeridesOscChoice": obj.get("ephemeridesOscChoice"),
            "customSolarFlux": obj.get("customSolarFlux"),
            "customEarthPotentialOrder": obj.get("customEarthPotentialOrder"),
            "customEarthPotentialDegree": obj.get("customEarthPotentialDegree"),
            "withEclipse": obj.get("withEclipse")
        })
        return _obj


