# coding: utf-8

"""
    Orbital transfer API

    An orbital transfer corresponds to a non-coplanar orbit transfer where semi-major axis, inclination and eccentricity can be simultaneously changed.  When considering a change in inclination, an efficiency factor is taken into account to consider the fact that this maneuver is  less efficient away from the orbital nodes. The length of the thrust arcs about the nodes is dictated by the duty cycle.   Different perturbations can be considered while performing this manoeuvre: Earth potential, third-body (Sun, Moon), atmospheric drag  and solar radiation pressure.   <b>CHANGELOG</b> <ul>   <li><b>2.2.0</b> - 2024-07-11 - Add space weather data source choice to <b>NRLMSISE00AtmosphericModel</b> schema</li>   <li><b>2.1.0</b> - 2024-07-03 - Add <b>atmosphericModel</b> in <b>DragPerturbation</b> schema</li>   <li><b>2.0.0</b> - 2024-06-06 - Complete refactoring of the API</li> </ul> 

    The version of the OpenAPI document: 2.2.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 importlib import import_module
from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional, Union
from typing import Optional, Set
from typing_extensions import Self

from typing import TYPE_CHECKING
if TYPE_CHECKING:
    from orbital_transfer.models.box_spacecraft_geometry import BoxSpacecraftGeometry
    from orbital_transfer.models.spherical_spacecraft_geometry import SphericalSpacecraftGeometry

class SpacecraftGeometry(BaseModel):
    """
    If drag perturbation is request, the geometry of the spacecraft.
    """ # noqa: E501
    type: Optional[StrictStr] = Field(default=None, description="The type of spacecraft geometry")
    __properties: ClassVar[List[str]] = ["type"]

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

        if value not in set(['SPHERICAL', 'BOX']):
            raise ValueError("must be one of enum values ('SPHERICAL', 'BOX')")
        return value

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )


    # JSON field name that stores the object type
    __discriminator_property_name: ClassVar[str] = 'type'

    # discriminator mappings
    __discriminator_value_class_map: ClassVar[Dict[str, str]] = {
        'BOX': 'BoxSpacecraftGeometry','SPHERICAL': 'SphericalSpacecraftGeometry'
    }

    @classmethod
    def get_discriminator_value(cls, obj: Dict[str, Any]) -> Optional[str]:
        """Returns the discriminator value (object type) of the data"""
        discriminator_value = obj[cls.__discriminator_property_name]
        if discriminator_value:
            return cls.__discriminator_value_class_map.get(discriminator_value)
        else:
            return None

    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[Union[BoxSpacecraftGeometry, SphericalSpacecraftGeometry]]:
        """Create an instance of SpacecraftGeometry 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,
        )
        return _dict

    @classmethod
    def from_dict(cls, obj: Dict[str, Any]) -> Optional[Union[BoxSpacecraftGeometry, SphericalSpacecraftGeometry]]:
        """Create an instance of SpacecraftGeometry from a dict"""
        # look up the object type based on discriminator mapping
        object_type = cls.get_discriminator_value(obj)
        if object_type ==  'BoxSpacecraftGeometry':
            return import_module("orbital_transfer.models.box_spacecraft_geometry").BoxSpacecraftGeometry.from_dict(obj)
        if object_type ==  'SphericalSpacecraftGeometry':
            return import_module("orbital_transfer.models.spherical_spacecraft_geometry").SphericalSpacecraftGeometry.from_dict(obj)

        raise ValueError("SpacecraftGeometry failed to lookup discriminator value from " +
                            json.dumps(obj) + ". Discriminator property name: " + cls.__discriminator_property_name +
                            ", mapping: " + json.dumps(cls.__discriminator_value_class_map))


