# 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, StrictBool, StrictInt
from .v1_deployment_strategy import V1DeploymentStrategy
from .v1_label_selector import V1LabelSelector
from .v1_pod_template_spec import V1PodTemplateSpec

class V1DeploymentSpec(BaseModel):
    """
    DeploymentSpec is the specification of the desired behavior of the Deployment.  # noqa: E501
    """
    min_ready_seconds: Optional[StrictInt] = Field(None, alias="minReadySeconds", description="Minimum number of seconds for which a newly created pod should be ready without any of its container crashing, for it to be considered available. Defaults to 0 (pod will be considered available as soon as it is ready)")
    paused: Optional[StrictBool] = Field(None, description="Indicates that the deployment is paused.")
    progress_deadline_seconds: Optional[StrictInt] = Field(None, alias="progressDeadlineSeconds", description="The maximum time in seconds for a deployment to make progress before it is considered to be failed. The deployment controller will continue to process failed deployments and a condition with a ProgressDeadlineExceeded reason will be surfaced in the deployment status. Note that progress will not be estimated during the time a deployment is paused. Defaults to 600s.")
    replicas: Optional[StrictInt] = Field(None, description="Number of desired pods. This is a pointer to distinguish between explicit zero and not specified. Defaults to 1.")
    revision_history_limit: Optional[StrictInt] = Field(None, alias="revisionHistoryLimit", description="The number of old ReplicaSets to retain to allow rollback. This is a pointer to distinguish between explicit zero and not specified. Defaults to 10.")
    selector: V1LabelSelector = Field(...)
    strategy: Optional[V1DeploymentStrategy] = None
    template: V1PodTemplateSpec = Field(...)
    __properties = ["minReadySeconds", "paused", "progressDeadlineSeconds", "replicas", "revisionHistoryLimit", "selector", "strategy", "template"]

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

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

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

        _obj = V1DeploymentSpec.parse_obj({
            "min_ready_seconds": obj.get("minReadySeconds"),
            "paused": obj.get("paused"),
            "progress_deadline_seconds": obj.get("progressDeadlineSeconds"),
            "replicas": obj.get("replicas"),
            "revision_history_limit": obj.get("revisionHistoryLimit"),
            "selector": V1LabelSelector.from_dict(obj.get("selector")) if obj.get("selector") is not None else None,
            "strategy": V1DeploymentStrategy.from_dict(obj.get("strategy")) if obj.get("strategy") is not None else None,
            "template": V1PodTemplateSpec.from_dict(obj.get("template")) if obj.get("template") is not None else None
        })
        return _obj


