# coding: utf-8

"""
    Onboarding Buddy API

    This document details all the available operations in the Onboarding Buddy API specification

    The version of the OpenAPI document: v1
    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, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing import Optional, Set
from typing_extensions import Self

class IpAddressResultM(BaseModel):
    """
    IpAddressResultM
    """ # noqa: E501
    ip_address: Optional[StrictStr] = Field(default=None, alias="ipAddress")
    iso_code: Optional[StrictStr] = Field(default=None, alias="isoCode")
    country: Optional[StrictStr] = None
    asn: Optional[StrictStr] = None
    asn_organization: Optional[StrictStr] = Field(default=None, alias="asnOrganization")
    isp: Optional[StrictStr] = None
    threat: Optional[StrictStr] = None
    risk_level: Optional[StrictStr] = Field(default=None, alias="riskLevel")
    is_tor_address: Optional[StrictBool] = Field(default=None, alias="isTorAddress")
    is_vpn_address: Optional[StrictBool] = Field(default=None, alias="isVpnAddress")
    check_status: Optional[StrictStr] = Field(default=None, alias="checkStatus")
    __properties: ClassVar[List[str]] = ["ipAddress", "isoCode", "country", "asn", "asnOrganization", "isp", "threat", "riskLevel", "isTorAddress", "isVpnAddress", "checkStatus"]

    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 IpAddressResultM 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 ip_address (nullable) is None
        # and model_fields_set contains the field
        if self.ip_address is None and "ip_address" in self.model_fields_set:
            _dict['ipAddress'] = None

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

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "ipAddress": obj.get("ipAddress"),
            "isoCode": obj.get("isoCode"),
            "country": obj.get("country"),
            "asn": obj.get("asn"),
            "asnOrganization": obj.get("asnOrganization"),
            "isp": obj.get("isp"),
            "threat": obj.get("threat"),
            "riskLevel": obj.get("riskLevel"),
            "isTorAddress": obj.get("isTorAddress"),
            "isVpnAddress": obj.get("isVpnAddress"),
            "checkStatus": obj.get("checkStatus")
        })
        return _obj


