# coding: utf-8

"""
    Corva API

    The Corva API is a powerful interface providing great flexibility and extensibility with Corva. Whether your needs are simple UI visualizations, data entry, replication/sync tasks, real-time stream processing, or complex machine learning CPU-intensive apps, the Corva API is the way to make it happen. Our concepts are split into three distinct silos: data apps, visualization apps, and a REST API

    The version of the OpenAPI document: v2.146.0
    Contact: support@corva.ai
    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 typing import Optional, Union
from pydantic import BaseModel, Field, StrictFloat, StrictInt, StrictStr
from corva_assets.models.asset_attributes_source_well import AssetAttributesSourceWell

class AssetAttributes(BaseModel):
    """
    AssetAttributes
    """
    id: Optional[StrictStr] = None
    name: Optional[StrictStr] = None
    status: Optional[StrictStr] = None
    state: Optional[StrictStr] = None
    api_number: Optional[StrictStr] = None
    county: Optional[StrictStr] = None
    basin: Optional[StrictStr] = None
    area: Optional[StrictStr] = None
    contractor_name: Optional[StrictStr] = None
    directional_driller: Optional[StrictStr] = None
    mud_company: Optional[StrictStr] = None
    customer_well_id: Optional[StrictStr] = None
    original_well_id: Optional[StrictStr] = None
    original_well_created_at: Optional[datetime] = None
    visible_rerun_id: Optional[Union[StrictFloat, StrictInt]] = Field(None, description="If the asset has been rerun and the rerun has been set visible, the ID of the rerun asset is returned here.")
    source_well: Optional[AssetAttributesSourceWell] = None
    __properties = ["id", "name", "status", "state", "api_number", "county", "basin", "area", "contractor_name", "directional_driller", "mud_company", "customer_well_id", "original_well_id", "original_well_created_at", "visible_rerun_id", "source_well"]

    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) -> AssetAttributes:
        """Create an instance of AssetAttributes 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 source_well
        if self.source_well:
            _dict['source_well'] = self.source_well.to_dict()
        # set to None if id (nullable) is None
        # and __fields_set__ contains the field
        if self.id is None and "id" in self.__fields_set__:
            _dict['id'] = None

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = AssetAttributes.parse_obj({
            "id": obj.get("id"),
            "name": obj.get("name"),
            "status": obj.get("status"),
            "state": obj.get("state"),
            "api_number": obj.get("api_number"),
            "county": obj.get("county"),
            "basin": obj.get("basin"),
            "area": obj.get("area"),
            "contractor_name": obj.get("contractor_name"),
            "directional_driller": obj.get("directional_driller"),
            "mud_company": obj.get("mud_company"),
            "customer_well_id": obj.get("customer_well_id"),
            "original_well_id": obj.get("original_well_id"),
            "original_well_created_at": obj.get("original_well_created_at"),
            "visible_rerun_id": obj.get("visible_rerun_id"),
            "source_well": AssetAttributesSourceWell.from_dict(obj.get("source_well")) if obj.get("source_well") is not None else None
        })
        return _obj


