# coding: utf-8

"""
    OurSky SDA

    The basic flow for a new organization is as follows: 1. View the available satellite targets with the [satellite targets](#tag/satellite-targets/GET/v1/satellite-targets) endpoint. Copy the id of the target you want to observe. 2. Create an organization target with the [organization target](#tag/organization-targets/GET/v1/organization-targets) endpoint. Use the id copied from above. 3. Create a webhook with the [webhook](#tag/webhooks/POST/v1/communications/webhook) endpoint to receive OSRs automatically (preferred) or use the [OSRs](#tag/observation-sequence-results/GET/v1/observation-sequence-results) endpoint to poll for OSRs.  Check out our [examples](https://github.com/ourskyai/oursky-examples) repository to see usage in each language.

    The version of the OpenAPI document: 1.3.9821
    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 typing import List, Optional, Union
from pydantic import BaseModel, Field, StrictBool, StrictFloat, StrictInt, conlist
from ourskyai_sda_api.models.v1_matched_star import V1MatchedStar
from ourskyai_sda_api.models.v1_plate_solve_status import V1PlateSolveStatus
from ourskyai_sda_api.models.v1_transformation import V1Transformation

class V1PlateSolveResult(BaseModel):
    """
    V1PlateSolveResult
    """
    status: Optional[V1PlateSolveStatus] = None
    matched_stars: Optional[conlist(V1MatchedStar)] = Field(None, alias="matchedStars")
    pixel_width: StrictInt = Field(..., alias="pixelWidth", description="The number of pixels in X directions")
    pixel_height: StrictInt = Field(..., alias="pixelHeight", description="The number of pixels in Y directions")
    number_matched_stars: StrictInt = Field(..., alias="numberMatchedStars", description="The number of matched stars")
    center_right_ascension_radians: Union[StrictFloat, StrictInt] = Field(..., alias="centerRightAscensionRadians", description="In radians, the exact RA center when matched")
    center_declination_radians: Union[StrictFloat, StrictInt] = Field(..., alias="centerDeclinationRadians", description="In radians, the exact Dec center when matched")
    x_size_radians: Union[StrictFloat, StrictInt] = Field(..., alias="xSizeRadians", description="The approximate plate size in X-direction, in radians")
    y_size_radians: Union[StrictFloat, StrictInt] = Field(..., alias="ySizeRadians", description="The approximate plate size in Y-direction, in radians")
    is_matched: StrictBool = Field(..., alias="isMatched", description="True if there is a valid plate match")
    transformation: V1Transformation = Field(...)
    __properties = ["status", "matchedStars", "pixelWidth", "pixelHeight", "numberMatchedStars", "centerRightAscensionRadians", "centerDeclinationRadians", "xSizeRadians", "ySizeRadians", "isMatched", "transformation"]

    class Config:
        """Pydantic configuration"""
        allow_population_by_field_name = True
        validate_assignment = True

    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.dict(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> V1PlateSolveResult:
        """Create an instance of V1PlateSolveResult from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self):
        """Returns the dictionary representation of the model using alias"""
        _dict = self.dict(by_alias=True,
                          exclude={
                          },
                          exclude_none=True)
        # override the default output from pydantic by calling `to_dict()` of each item in matched_stars (list)
        _items = []
        if self.matched_stars:
            for _item in self.matched_stars:
                if _item:
                    _items.append(_item.to_dict())
            _dict['matchedStars'] = _items
        # override the default output from pydantic by calling `to_dict()` of transformation
        if self.transformation:
            _dict['transformation'] = self.transformation.to_dict()
        return _dict

    @classmethod
    def from_dict(cls, obj: dict) -> V1PlateSolveResult:
        """Create an instance of V1PlateSolveResult from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return V1PlateSolveResult.parse_obj(obj)

        _obj = V1PlateSolveResult.parse_obj({
            "status": obj.get("status"),
            "matched_stars": [V1MatchedStar.from_dict(_item) for _item in obj.get("matchedStars")] if obj.get("matchedStars") is not None else None,
            "pixel_width": obj.get("pixelWidth"),
            "pixel_height": obj.get("pixelHeight"),
            "number_matched_stars": obj.get("numberMatchedStars"),
            "center_right_ascension_radians": obj.get("centerRightAscensionRadians"),
            "center_declination_radians": obj.get("centerDeclinationRadians"),
            "x_size_radians": obj.get("xSizeRadians"),
            "y_size_radians": obj.get("ySizeRadians"),
            "is_matched": obj.get("isMatched"),
            "transformation": V1Transformation.from_dict(obj.get("transformation")) if obj.get("transformation") is not None else None
        })
        return _obj


