# coding: utf-8

"""
    NetHSM
    All endpoints expect exactly the specified JSON. Additional properties will cause a Bad Request Error (400). All HTTP errors contain a JSON structure with an explanation of type string. All [base64](https://tools.ietf.org/html/rfc4648#section-4) encoded values are Big Endian.   # noqa: E501
    The version of the OpenAPI document: v1
    Generated by: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator
"""

from __future__ import annotations
from nethsm.client.shared_imports.schema_imports import *  # pyright: ignore [reportWildcardImportFromLibrary]



@dataclasses.dataclass(frozen=True)
class Exited(
    schemas.IntSchema
):
    types: typing.FrozenSet[typing.Type] = frozenset({
        int,
    })
    format: str = 'int'
    inclusive_maximum: typing.Union[int, float] = 255
    inclusive_minimum: typing.Union[int, float] = 0


@dataclasses.dataclass(frozen=True)
class Signaled(
    schemas.IntSchema
):
    types: typing.FrozenSet[typing.Type] = frozenset({
        int,
    })
    format: str = 'int'
    inclusive_maximum: typing.Union[int, float] = 255
    inclusive_minimum: typing.Union[int, float] = 0


@dataclasses.dataclass(frozen=True)
class Stopped(
    schemas.IntSchema
):
    types: typing.FrozenSet[typing.Type] = frozenset({
        int,
    })
    format: str = 'int'
    inclusive_maximum: typing.Union[int, float] = 255
    inclusive_minimum: typing.Union[int, float] = 0
Running: typing_extensions.TypeAlias = schemas.BoolSchema
Properties = typing.TypedDict(
    'Properties',
    {
        "exited": typing.Type[Exited],
        "signaled": typing.Type[Signaled],
        "stopped": typing.Type[Stopped],
        "running": typing.Type[Running],
    }
)


class ClusterStateDict(schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]):

    __required_keys__: typing.FrozenSet[str] = frozenset({
        "running",
    })
    __optional_keys__: typing.FrozenSet[str] = frozenset({
        "exited",
        "signaled",
        "stopped",
    })
    
    def __new__(
        cls,
        *,
        running: bool,
        exited: typing.Union[
            int,
            schemas.Unset
        ] = schemas.unset,
        signaled: typing.Union[
            int,
            schemas.Unset
        ] = schemas.unset,
        stopped: typing.Union[
            int,
            schemas.Unset
        ] = schemas.unset,
        configuration_: typing.Optional[schema_configuration.SchemaConfiguration] = None,
        **kwargs: schemas.INPUT_TYPES_ALL,
    ):
        arg_: typing.Dict[str, typing.Any] = {
            "running": running,
        }
        for key_, val in (
            ("exited", exited),
            ("signaled", signaled),
            ("stopped", stopped),
        ):
            if isinstance(val, schemas.Unset):
                continue
            arg_[key_] = val
        arg_.update(kwargs)
        used_arg_ = typing.cast(ClusterStateDictInput, arg_)
        return ClusterState.validate(used_arg_, configuration=configuration_)
    
    @staticmethod
    def from_dict_(
        arg: typing.Union[
            ClusterStateDictInput,
            ClusterStateDict
        ],
        configuration: typing.Optional[schema_configuration.SchemaConfiguration] = None
    ) -> ClusterStateDict:
        return ClusterState.validate(arg, configuration=configuration)
    
    @property
    def running(self) -> bool:
        return typing.cast(
            bool,
            self.__getitem__("running")
        )
    
    @property
    def exited(self) -> typing.Union[int, schemas.Unset]:
        val = self.get("exited", schemas.unset)
        if isinstance(val, schemas.Unset):
            return val
        return typing.cast(
            int,
            val
        )
    
    @property
    def signaled(self) -> typing.Union[int, schemas.Unset]:
        val = self.get("signaled", schemas.unset)
        if isinstance(val, schemas.Unset):
            return val
        return typing.cast(
            int,
            val
        )
    
    @property
    def stopped(self) -> typing.Union[int, schemas.Unset]:
        val = self.get("stopped", schemas.unset)
        if isinstance(val, schemas.Unset):
            return val
        return typing.cast(
            int,
            val
        )
    
    def get_additional_property_(self, name: str) -> typing.Union[schemas.OUTPUT_BASE_TYPES, schemas.Unset]:
        schemas.raise_if_key_known(name, self.__required_keys__, self.__optional_keys__)
        return self.get(name, schemas.unset)
ClusterStateDictInput = typing.Mapping[str, schemas.INPUT_TYPES_ALL]


@dataclasses.dataclass(frozen=True)
class ClusterState(
    schemas.Schema[ClusterStateDict, tuple]
):
    """NOTE: This class is auto generated by OpenAPI JSON Schema Generator.
    Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator

    Do not edit the class manually.

    Status of etcd cluster process on the local node.

    """
    types: typing.FrozenSet[typing.Type] = frozenset({schemas.immutabledict})
    required: typing.FrozenSet[str] = frozenset({
        "running",
    })
    properties: Properties = dataclasses.field(default_factory=lambda: schemas.typed_dict_to_instance(Properties)) # type: ignore
    type_to_output_cls: typing.Mapping[
        typing.Type,
        typing.Type
    ] = dataclasses.field(
        default_factory=lambda: {
            schemas.immutabledict: ClusterStateDict
        }
    )

    @classmethod
    def validate(
        cls,
        arg: typing.Union[
            ClusterStateDictInput,
            ClusterStateDict,
        ],
        configuration: typing.Optional[schema_configuration.SchemaConfiguration] = None
    ) -> ClusterStateDict:
        return super().validate_base(
            arg,
            configuration=configuration,
        )

