# 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 Optional
from pydantic import BaseModel, Field, StrictStr
from .v1_node_config_source import V1NodeConfigSource

class V1NodeConfigStatus(BaseModel):
    """
    NodeConfigStatus describes the status of the config assigned by Node.Spec.ConfigSource.  # noqa: E501
    """
    active: Optional[V1NodeConfigSource] = None
    assigned: Optional[V1NodeConfigSource] = None
    error: Optional[StrictStr] = Field(None, description="Error describes any problems reconciling the Spec.ConfigSource to the Active config. Errors may occur, for example, attempting to checkpoint Spec.ConfigSource to the local Assigned record, attempting to checkpoint the payload associated with Spec.ConfigSource, attempting to load or validate the Assigned config, etc. Errors may occur at different points while syncing config. Earlier errors (e.g. download or checkpointing errors) will not result in a rollback to LastKnownGood, and may resolve across Kubelet retries. Later errors (e.g. loading or validating a checkpointed config) will result in a rollback to LastKnownGood. In the latter case, it is usually possible to resolve the error by fixing the config assigned in Spec.ConfigSource. You can find additional information for debugging by searching the error message in the Kubelet log. Error is a human-readable description of the error state; machines can check whether or not Error is empty, but should not rely on the stability of the Error text across Kubelet versions.")
    last_known_good: Optional[V1NodeConfigSource] = Field(None, alias="lastKnownGood")
    __properties = ["active", "assigned", "error", "lastKnownGood"]

    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) -> V1NodeConfigStatus:
        """Create an instance of V1NodeConfigStatus 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 active
        if self.active:
            _dict['active'] = self.active.to_dict()
        # override the default output from pydantic by calling `to_dict()` of assigned
        if self.assigned:
            _dict['assigned'] = self.assigned.to_dict()
        # override the default output from pydantic by calling `to_dict()` of last_known_good
        if self.last_known_good:
            _dict['lastKnownGood'] = self.last_known_good.to_dict()
        return _dict

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

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

        _obj = V1NodeConfigStatus.parse_obj({
            "active": V1NodeConfigSource.from_dict(obj.get("active")) if obj.get("active") is not None else None,
            "assigned": V1NodeConfigSource.from_dict(obj.get("assigned")) if obj.get("assigned") is not None else None,
            "error": obj.get("error"),
            "last_known_good": V1NodeConfigSource.from_dict(obj.get("lastKnownGood")) if obj.get("lastKnownGood") is not None else None
        })
        return _obj


