# 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 typing import List, Optional
from pydantic import BaseModel, Field, StrictInt, StrictStr, conlist
from .v1_stateful_set_condition import V1StatefulSetCondition

class V1StatefulSetStatus(BaseModel):
    """
    StatefulSetStatus represents the current state of a StatefulSet.  # noqa: E501
    """
    available_replicas: Optional[StrictInt] = Field(None, alias="availableReplicas", description="Total number of available pods (ready for at least minReadySeconds) targeted by this statefulset.")
    collision_count: Optional[StrictInt] = Field(None, alias="collisionCount", description="collisionCount is the count of hash collisions for the StatefulSet. The StatefulSet controller uses this field as a collision avoidance mechanism when it needs to create the name for the newest ControllerRevision.")
    conditions: Optional[conlist(V1StatefulSetCondition)] = Field(None, description="Represents the latest available observations of a statefulset's current state.")
    current_replicas: Optional[StrictInt] = Field(None, alias="currentReplicas", description="currentReplicas is the number of Pods created by the StatefulSet controller from the StatefulSet version indicated by currentRevision.")
    current_revision: Optional[StrictStr] = Field(None, alias="currentRevision", description="currentRevision, if not empty, indicates the version of the StatefulSet used to generate Pods in the sequence [0,currentReplicas).")
    observed_generation: Optional[StrictInt] = Field(None, alias="observedGeneration", description="observedGeneration is the most recent generation observed for this StatefulSet. It corresponds to the StatefulSet's generation, which is updated on mutation by the API Server.")
    ready_replicas: Optional[StrictInt] = Field(None, alias="readyReplicas", description="readyReplicas is the number of pods created for this StatefulSet with a Ready Condition.")
    replicas: StrictInt = Field(..., description="replicas is the number of Pods created by the StatefulSet controller.")
    update_revision: Optional[StrictStr] = Field(None, alias="updateRevision", description="updateRevision, if not empty, indicates the version of the StatefulSet used to generate Pods in the sequence [replicas-updatedReplicas,replicas)")
    updated_replicas: Optional[StrictInt] = Field(None, alias="updatedReplicas", description="updatedReplicas is the number of Pods created by the StatefulSet controller from the StatefulSet version indicated by updateRevision.")
    __properties = ["availableReplicas", "collisionCount", "conditions", "currentReplicas", "currentRevision", "observedGeneration", "readyReplicas", "replicas", "updateRevision", "updatedReplicas"]

    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) -> V1StatefulSetStatus:
        """Create an instance of V1StatefulSetStatus 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) -> V1StatefulSetStatus:
        """Create an instance of V1StatefulSetStatus from a dict"""
        if obj is None:
            return None

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

        _obj = V1StatefulSetStatus.parse_obj({
            "available_replicas": obj.get("availableReplicas"),
            "collision_count": obj.get("collisionCount"),
            "conditions": [V1StatefulSetCondition.from_dict(_item) for _item in obj.get("conditions")] if obj.get("conditions") is not None else None,
            "current_replicas": obj.get("currentReplicas"),
            "current_revision": obj.get("currentRevision"),
            "observed_generation": obj.get("observedGeneration"),
            "ready_replicas": obj.get("readyReplicas"),
            "replicas": obj.get("replicas"),
            "update_revision": obj.get("updateRevision"),
            "updated_replicas": obj.get("updatedReplicas")
        })
        return _obj


