# 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_status_cause import V1StatusCause

class V1StatusDetails(BaseModel):
    """
    StatusDetails is a set of additional properties that MAY be set by the server to provide additional information about a response. The Reason field of a Status object defines what attributes will be set. Clients must ignore fields that do not match the defined type of each attribute, and should assume that any attribute may be empty, invalid, or under defined.  # noqa: E501
    """
    causes: Optional[conlist(V1StatusCause)] = Field(None, description="The Causes array includes more details associated with the StatusReason failure. Not all StatusReasons may provide detailed causes.")
    group: Optional[StrictStr] = Field(None, description="The group attribute of the resource associated with the status StatusReason.")
    kind: Optional[StrictStr] = Field(None, description="The kind attribute of the resource associated with the status StatusReason. On some operations may differ from the requested resource Kind. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds")
    name: Optional[StrictStr] = Field(None, description="The name attribute of the resource associated with the status StatusReason (when there is a single name which can be described).")
    retry_after_seconds: Optional[StrictInt] = Field(None, alias="retryAfterSeconds", description="If specified, the time in seconds before the operation should be retried. Some errors may indicate the client must take an alternate action - for those errors this field may indicate how long to wait before taking the alternate action.")
    uid: Optional[StrictStr] = Field(None, description="UID of the resource. (when there is a single resource which can be described). More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names#uids")
    __properties = ["causes", "group", "kind", "name", "retryAfterSeconds", "uid"]

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

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

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

        _obj = V1StatusDetails.parse_obj({
            "causes": [V1StatusCause.from_dict(_item) for _item in obj.get("causes")] if obj.get("causes") is not None else None,
            "group": obj.get("group"),
            "kind": obj.get("kind"),
            "name": obj.get("name"),
            "retry_after_seconds": obj.get("retryAfterSeconds"),
            "uid": obj.get("uid")
        })
        return _obj


