# coding: utf-8

"""
    Graphiant APIs

    Graphiant API documentation.

    The version of the OpenAPI document: 1.0.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 pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from graphiant_sdk.models.v2_assurance_applicationdetailsbyname_post200_response_app_id_record_flex_algo_inner import V2AssuranceApplicationdetailsbynamePost200ResponseAppIdRecordFlexAlgoInner
from typing import Optional, Set
from typing_extensions import Self

class V2AssuranceApplicationdetailsbynamePost200ResponseAppIdRecord(BaseModel):
    """
    V2AssuranceApplicationdetailsbynamePost200ResponseAppIdRecord
    """ # noqa: E501
    affected_hosts: Optional[StrictInt] = Field(default=None, alias="affectedHosts")
    affected_regions: Optional[StrictInt] = Field(default=None, alias="affectedRegions")
    affected_sites: Optional[StrictInt] = Field(default=None, alias="affectedSites")
    affected_vrfs: Optional[StrictInt] = Field(default=None, alias="affectedVrfs")
    app_id_key: Optional[StrictStr] = Field(default=None, alias="appIdKey")
    app_name: Optional[StrictStr] = Field(default=None, alias="appName")
    app_type: Optional[StrictStr] = Field(default=None, alias="appType")
    blocked_reason_list: Optional[List[StrictStr]] = Field(default=None, alias="blockedReasonList")
    category: Optional[StrictStr] = None
    classfication_field: Optional[StrictStr] = Field(default=None, alias="classficationField")
    classification_field: Optional[StrictStr] = Field(default=None, alias="classificationField")
    first_seen: Optional[StrictInt] = Field(default=None, alias="firstSeen")
    flex_algo: Optional[List[V2AssuranceApplicationdetailsbynamePost200ResponseAppIdRecordFlexAlgoInner]] = Field(default=None, alias="flexAlgo")
    flows_analyzed: Optional[StrictInt] = Field(default=None, alias="flowsAnalyzed")
    last_seen: Optional[StrictInt] = Field(default=None, alias="lastSeen")
    new_ip_hint: Optional[StrictBool] = Field(default=None, alias="newIpHint")
    recommendation: Optional[StrictStr] = None
    region_list: Optional[List[StrictStr]] = Field(default=None, alias="regionList")
    risk_status: Optional[StrictStr] = Field(default=None, alias="riskStatus")
    server_ip: Optional[StrictStr] = Field(default=None, alias="serverIp")
    server_port: Optional[StrictStr] = Field(default=None, alias="serverPort")
    site_list: Optional[List[StrictStr]] = Field(default=None, alias="siteList")
    threat_score: Optional[StrictInt] = Field(default=None, alias="threatScore")
    vrf_list: Optional[List[StrictStr]] = Field(default=None, alias="vrfList")
    __properties: ClassVar[List[str]] = ["affectedHosts", "affectedRegions", "affectedSites", "affectedVrfs", "appIdKey", "appName", "appType", "blockedReasonList", "category", "classficationField", "classificationField", "firstSeen", "flexAlgo", "flowsAnalyzed", "lastSeen", "newIpHint", "recommendation", "regionList", "riskStatus", "serverIp", "serverPort", "siteList", "threatScore", "vrfList"]

    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 V2AssuranceApplicationdetailsbynamePost200ResponseAppIdRecord 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,
        )
        # override the default output from pydantic by calling `to_dict()` of each item in flex_algo (list)
        _items = []
        if self.flex_algo:
            for _item_flex_algo in self.flex_algo:
                if _item_flex_algo:
                    _items.append(_item_flex_algo.to_dict())
            _dict['flexAlgo'] = _items
        return _dict

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

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

        _obj = cls.model_validate({
            "affectedHosts": obj.get("affectedHosts"),
            "affectedRegions": obj.get("affectedRegions"),
            "affectedSites": obj.get("affectedSites"),
            "affectedVrfs": obj.get("affectedVrfs"),
            "appIdKey": obj.get("appIdKey"),
            "appName": obj.get("appName"),
            "appType": obj.get("appType"),
            "blockedReasonList": obj.get("blockedReasonList"),
            "category": obj.get("category"),
            "classficationField": obj.get("classficationField"),
            "classificationField": obj.get("classificationField"),
            "firstSeen": obj.get("firstSeen"),
            "flexAlgo": [V2AssuranceApplicationdetailsbynamePost200ResponseAppIdRecordFlexAlgoInner.from_dict(_item) for _item in obj["flexAlgo"]] if obj.get("flexAlgo") is not None else None,
            "flowsAnalyzed": obj.get("flowsAnalyzed"),
            "lastSeen": obj.get("lastSeen"),
            "newIpHint": obj.get("newIpHint"),
            "recommendation": obj.get("recommendation"),
            "regionList": obj.get("regionList"),
            "riskStatus": obj.get("riskStatus"),
            "serverIp": obj.get("serverIp"),
            "serverPort": obj.get("serverPort"),
            "siteList": obj.get("siteList"),
            "threatScore": obj.get("threatScore"),
            "vrfList": obj.get("vrfList")
        })
        return _obj


