# coding: utf-8

"""
    ARL Infrastructure API

    OpenAPI specification for ARL (Agentic RL) Infrastructure custom resources. This SDK provides models for WarmPool, Sandbox, and Task Kubernetes custom resources. 

    The version of the OpenAPI document: v1alpha1
    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 pydantic import BaseModel, ConfigDict, Field, StrictInt
from typing import Any, ClassVar, Dict, List, Optional
from .models.warm_pool_spec_template_spec_containers_inner_lifecycle_post_start_exec import WarmPoolSpecTemplateSpecContainersInnerLifecyclePostStartExec
from .models.warm_pool_spec_template_spec_containers_inner_lifecycle_post_start_http_get import WarmPoolSpecTemplateSpecContainersInnerLifecyclePostStartHttpGet
from .models.warm_pool_spec_template_spec_containers_inner_lifecycle_post_start_tcp_socket import WarmPoolSpecTemplateSpecContainersInnerLifecyclePostStartTcpSocket
from .models.warm_pool_spec_template_spec_containers_inner_liveness_probe_grpc import WarmPoolSpecTemplateSpecContainersInnerLivenessProbeGrpc
from typing import Optional, Set
from typing_extensions import Self

class WarmPoolSpecTemplateSpecContainersInnerLivenessProbe(BaseModel):
    """
    WarmPoolSpecTemplateSpecContainersInnerLivenessProbe
    """ # noqa: E501
    var_exec: Optional[WarmPoolSpecTemplateSpecContainersInnerLifecyclePostStartExec] = Field(default=None, alias="exec")
    failure_threshold: Optional[StrictInt] = Field(default=None, alias="failureThreshold")
    grpc: Optional[WarmPoolSpecTemplateSpecContainersInnerLivenessProbeGrpc] = None
    http_get: Optional[WarmPoolSpecTemplateSpecContainersInnerLifecyclePostStartHttpGet] = Field(default=None, alias="httpGet")
    initial_delay_seconds: Optional[StrictInt] = Field(default=None, alias="initialDelaySeconds")
    period_seconds: Optional[StrictInt] = Field(default=None, alias="periodSeconds")
    success_threshold: Optional[StrictInt] = Field(default=None, alias="successThreshold")
    tcp_socket: Optional[WarmPoolSpecTemplateSpecContainersInnerLifecyclePostStartTcpSocket] = Field(default=None, alias="tcpSocket")
    termination_grace_period_seconds: Optional[StrictInt] = Field(default=None, alias="terminationGracePeriodSeconds")
    timeout_seconds: Optional[StrictInt] = Field(default=None, alias="timeoutSeconds")
    __properties: ClassVar[List[str]] = ["exec", "failureThreshold", "grpc", "httpGet", "initialDelaySeconds", "periodSeconds", "successThreshold", "tcpSocket", "terminationGracePeriodSeconds", "timeoutSeconds"]

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )


    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.model_dump(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of WarmPoolSpecTemplateSpecContainersInnerLivenessProbe from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self) -> Dict[str, Any]:
        """Return the dictionary representation of the model using alias.

        This has the following differences from calling pydantic's
        `self.model_dump(by_alias=True)`:

        * `None` is only added to the output dict for nullable fields that
          were set at model initialization. Other fields with value `None`
          are ignored.
        """
        excluded_fields: Set[str] = set([
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # override the default output from pydantic by calling `to_dict()` of var_exec
        if self.var_exec:
            _dict['exec'] = self.var_exec.to_dict()
        # override the default output from pydantic by calling `to_dict()` of grpc
        if self.grpc:
            _dict['grpc'] = self.grpc.to_dict()
        # override the default output from pydantic by calling `to_dict()` of http_get
        if self.http_get:
            _dict['httpGet'] = self.http_get.to_dict()
        # override the default output from pydantic by calling `to_dict()` of tcp_socket
        if self.tcp_socket:
            _dict['tcpSocket'] = self.tcp_socket.to_dict()
        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of WarmPoolSpecTemplateSpecContainersInnerLivenessProbe from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        _obj = cls.model_validate({
            "exec": WarmPoolSpecTemplateSpecContainersInnerLifecyclePostStartExec.from_dict(obj["exec"]) if obj.get("exec") is not None else None,
            "failureThreshold": obj.get("failureThreshold"),
            "grpc": WarmPoolSpecTemplateSpecContainersInnerLivenessProbeGrpc.from_dict(obj["grpc"]) if obj.get("grpc") is not None else None,
            "httpGet": WarmPoolSpecTemplateSpecContainersInnerLifecyclePostStartHttpGet.from_dict(obj["httpGet"]) if obj.get("httpGet") is not None else None,
            "initialDelaySeconds": obj.get("initialDelaySeconds"),
            "periodSeconds": obj.get("periodSeconds"),
            "successThreshold": obj.get("successThreshold"),
            "tcpSocket": WarmPoolSpecTemplateSpecContainersInnerLifecyclePostStartTcpSocket.from_dict(obj["tcpSocket"]) if obj.get("tcpSocket") is not None else None,
            "terminationGracePeriodSeconds": obj.get("terminationGracePeriodSeconds"),
            "timeoutSeconds": obj.get("timeoutSeconds")
        })
        return _obj


