# coding: utf-8

"""
    Secore API

    API for the Seres core platform

    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 datetime import datetime
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from typing import Optional, Set
from typing_extensions import Self

class FlightPlanCreationRequestCreationSchema(BaseModel):
    """
    FlightPlanCreationRequestCreationSchema
    """ # noqa: E501
    flight_plan_schema_id: StrictInt
    reference: Annotated[str, Field(strict=True, max_length=120)] = Field(description="The reference that will be given to the generated flight plan")
    future_id: Optional[StrictInt] = None
    meta_launch_now: Optional[StrictBool] = False
    meta_critical_leg_datetime: Optional[datetime] = None
    meta_critical_leg_id: Optional[StrictInt] = None
    meta_landing_datetime: Optional[datetime] = None
    meta_launch_datetime: Optional[datetime] = None
    parent_flight_plan_creation_request_id: Optional[StrictInt] = None
    primary_bot_id: Optional[StrictInt] = None
    primary_bot_schema_id: Optional[StrictInt] = None
    primary_payload_id: Optional[StrictInt] = None
    primary_payload_schema_id: Optional[StrictInt] = None
    resource_assembly_schema_id: Optional[StrictInt] = None
    __properties: ClassVar[List[str]] = ["flight_plan_schema_id", "reference", "future_id", "meta_launch_now", "meta_critical_leg_datetime", "meta_critical_leg_id", "meta_landing_datetime", "meta_launch_datetime", "parent_flight_plan_creation_request_id", "primary_bot_id", "primary_bot_schema_id", "primary_payload_id", "primary_payload_schema_id", "resource_assembly_schema_id"]

    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 FlightPlanCreationRequestCreationSchema 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,
        )
        # set to None if future_id (nullable) is None
        # and model_fields_set contains the field
        if self.future_id is None and "future_id" in self.model_fields_set:
            _dict['future_id'] = None

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

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

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

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "flight_plan_schema_id": obj.get("flight_plan_schema_id"),
            "reference": obj.get("reference"),
            "future_id": obj.get("future_id"),
            "meta_launch_now": obj.get("meta_launch_now") if obj.get("meta_launch_now") is not None else False,
            "meta_critical_leg_datetime": obj.get("meta_critical_leg_datetime"),
            "meta_critical_leg_id": obj.get("meta_critical_leg_id"),
            "meta_landing_datetime": obj.get("meta_landing_datetime"),
            "meta_launch_datetime": obj.get("meta_launch_datetime"),
            "parent_flight_plan_creation_request_id": obj.get("parent_flight_plan_creation_request_id"),
            "primary_bot_id": obj.get("primary_bot_id"),
            "primary_bot_schema_id": obj.get("primary_bot_schema_id"),
            "primary_payload_id": obj.get("primary_payload_id"),
            "primary_payload_schema_id": obj.get("primary_payload_schema_id"),
            "resource_assembly_schema_id": obj.get("resource_assembly_schema_id")
        })
        return _obj


