# coding: utf-8

"""
    authentik

    Making authentication simple.

    The version of the OpenAPI document: 2024.2.2
    Contact: hello@goauthentik.io
    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 Any, Optional
from pydantic import BaseModel, Field, StrictStr, conint

class Reputation(BaseModel):
    """
    Reputation Serializer  # noqa: E501
    """
    pk: Optional[StrictStr] = None
    identifier: StrictStr = Field(...)
    ip: StrictStr = Field(...)
    ip_geo_data: Optional[Any] = None
    ip_asn_data: Optional[Any] = None
    score: Optional[conint(strict=True, le=9223372036854775807, ge=-9223372036854775808)] = None
    updated: datetime = Field(...)
    __properties = ["pk", "identifier", "ip", "ip_geo_data", "ip_asn_data", "score", "updated"]

    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) -> Reputation:
        """Create an instance of Reputation 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={
                            "updated",
                          },
                          exclude_none=True)
        # set to None if ip_geo_data (nullable) is None
        # and __fields_set__ contains the field
        if self.ip_geo_data is None and "ip_geo_data" in self.__fields_set__:
            _dict['ip_geo_data'] = None

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

        return _dict

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

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

        _obj = Reputation.parse_obj({
            "pk": obj.get("pk"),
            "identifier": obj.get("identifier"),
            "ip": obj.get("ip"),
            "ip_geo_data": obj.get("ip_geo_data"),
            "ip_asn_data": obj.get("ip_asn_data"),
            "score": obj.get("score"),
            "updated": obj.get("updated")
        })
        return _obj


