# coding: utf-8

"""
    Kubernetes

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

    The version of the OpenAPI document: release-1.29
    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 Dict, List, Optional
from pydantic import BaseModel, Field, StrictInt, conlist
from .v1_condition import V1Condition

class V1PodDisruptionBudgetStatus(BaseModel):
    """
    PodDisruptionBudgetStatus represents information about the status of a PodDisruptionBudget. Status may trail the actual state of a system.  # noqa: E501
    """
    conditions: Optional[conlist(V1Condition)] = Field(None, description="Conditions contain conditions for PDB. The disruption controller sets the DisruptionAllowed condition. The following are known values for the reason field (additional reasons could be added in the future): - SyncFailed: The controller encountered an error and wasn't able to compute               the number of allowed disruptions. Therefore no disruptions are               allowed and the status of the condition will be False. - InsufficientPods: The number of pods are either at or below the number                     required by the PodDisruptionBudget. No disruptions are                     allowed and the status of the condition will be False. - SufficientPods: There are more pods than required by the PodDisruptionBudget.                   The condition will be True, and the number of allowed                   disruptions are provided by the disruptionsAllowed property.")
    current_healthy: StrictInt = Field(..., alias="currentHealthy", description="current number of healthy pods")
    desired_healthy: StrictInt = Field(..., alias="desiredHealthy", description="minimum desired number of healthy pods")
    disrupted_pods: Optional[Dict[str, datetime]] = Field(None, alias="disruptedPods", description="DisruptedPods contains information about pods whose eviction was processed by the API server eviction subresource handler but has not yet been observed by the PodDisruptionBudget controller. A pod will be in this map from the time when the API server processed the eviction request to the time when the pod is seen by PDB controller as having been marked for deletion (or after a timeout). The key in the map is the name of the pod and the value is the time when the API server processed the eviction request. If the deletion didn't occur and a pod is still there it will be removed from the list automatically by PodDisruptionBudget controller after some time. If everything goes smooth this map should be empty for the most of the time. Large number of entries in the map may indicate problems with pod deletions.")
    disruptions_allowed: StrictInt = Field(..., alias="disruptionsAllowed", description="Number of pod disruptions that are currently allowed.")
    expected_pods: StrictInt = Field(..., alias="expectedPods", description="total number of pods counted by this disruption budget")
    observed_generation: Optional[StrictInt] = Field(None, alias="observedGeneration", description="Most recent generation observed when updating this PDB status. DisruptionsAllowed and other status information is valid only if observedGeneration equals to PDB's object generation.")
    __properties = ["conditions", "currentHealthy", "desiredHealthy", "disruptedPods", "disruptionsAllowed", "expectedPods", "observedGeneration"]

    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) -> V1PodDisruptionBudgetStatus:
        """Create an instance of V1PodDisruptionBudgetStatus 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 conditions (list)
        _items = []
        if self.conditions:
            for _item in self.conditions:
                if _item:
                    _items.append(_item.to_dict())
            _dict['conditions'] = _items
        return _dict

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

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

        _obj = V1PodDisruptionBudgetStatus.parse_obj({
            "conditions": [V1Condition.from_dict(_item) for _item in obj.get("conditions")] if obj.get("conditions") is not None else None,
            "current_healthy": obj.get("currentHealthy"),
            "desired_healthy": obj.get("desiredHealthy"),
            "disrupted_pods": obj.get("disruptedPods"),
            "disruptions_allowed": obj.get("disruptionsAllowed"),
            "expected_pods": obj.get("expectedPods"),
            "observed_generation": obj.get("observedGeneration")
        })
        return _obj


