# 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]

JoinerKit: typing_extensions.TypeAlias = schemas.StrSchema
BackupPassphrase: typing_extensions.TypeAlias = schemas.StrSchema


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

    __required_keys__: typing.FrozenSet[str] = frozenset({
        "backupPassphrase",
        "joinerKit",
        "members",
    })
    __optional_keys__: typing.FrozenSet[str] = frozenset({
    })
    
    def __new__(
        cls,
        *,
        backupPassphrase: str,
        joinerKit: str,
        members: typing.Union[
            MembersTupleInput,
            MembersTuple
        ],
        configuration_: typing.Optional[schema_configuration.SchemaConfiguration] = None,
        **kwargs: schemas.INPUT_TYPES_ALL,
    ):
        arg_: typing.Dict[str, typing.Any] = {
            "backupPassphrase": backupPassphrase,
            "joinerKit": joinerKit,
            "members": members,
        }
        arg_.update(kwargs)
        used_arg_ = typing.cast(ClusterJoinReqDictInput, arg_)
        return ClusterJoinReq.validate(used_arg_, configuration=configuration_)
    
    @staticmethod
    def from_dict_(
        arg: typing.Union[
            ClusterJoinReqDictInput,
            ClusterJoinReqDict
        ],
        configuration: typing.Optional[schema_configuration.SchemaConfiguration] = None
    ) -> ClusterJoinReqDict:
        return ClusterJoinReq.validate(arg, configuration=configuration)
    
    @property
    def backupPassphrase(self) -> str:
        return typing.cast(
            str,
            self.__getitem__("backupPassphrase")
        )
    
    @property
    def joinerKit(self) -> str:
        return typing.cast(
            str,
            self.__getitem__("joinerKit")
        )
    
    @property
    def members(self) -> MembersTuple:
        return typing.cast(
            MembersTuple,
            self.__getitem__("members")
        )
    
    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)
ClusterJoinReqDictInput = typing.Mapping[str, schemas.INPUT_TYPES_ALL]


@dataclasses.dataclass(frozen=True)
class ClusterJoinReq(
    schemas.Schema[ClusterJoinReqDict, 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.
    """
    types: typing.FrozenSet[typing.Type] = frozenset({schemas.immutabledict})
    required: typing.FrozenSet[str] = frozenset({
        "backupPassphrase",
        "joinerKit",
        "members",
    })
    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: ClusterJoinReqDict
        }
    )

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


from nethsm.client.components.schema import cluster_initial_member


class MembersTuple(
    typing.Tuple[
        cluster_initial_member.ClusterInitialMemberDict,
        ...
    ]
):

    def __new__(cls, arg: typing.Union[MembersTupleInput, MembersTuple], configuration: typing.Optional[schema_configuration.SchemaConfiguration] = None):
        return Members.validate(arg, configuration=configuration)
MembersTupleInput = typing.Union[
    typing.List[
        typing.Union[
            cluster_initial_member.ClusterInitialMemberDictInput,
            cluster_initial_member.ClusterInitialMemberDict,
        ],
    ],
    typing.Tuple[
        typing.Union[
            cluster_initial_member.ClusterInitialMemberDictInput,
            cluster_initial_member.ClusterInitialMemberDict,
        ],
        ...
    ]
]


@dataclasses.dataclass(frozen=True)
class Members(
    schemas.Schema[schemas.immutabledict, MembersTuple]
):
    types: typing.FrozenSet[typing.Type] = frozenset({tuple})
    items: typing.Type[cluster_initial_member.ClusterInitialMember] = dataclasses.field(default_factory=lambda: cluster_initial_member.ClusterInitialMember) # type: ignore
    type_to_output_cls: typing.Mapping[
        typing.Type,
        typing.Type
    ] = dataclasses.field(
        default_factory=lambda: {
            tuple: MembersTuple
        }
    )

    @classmethod
    def validate(
        cls,
        arg: typing.Union[
            MembersTupleInput,
            MembersTuple,
        ],
        configuration: typing.Optional[schema_configuration.SchemaConfiguration] = None
    ) -> MembersTuple:
        return super().validate_base(
            arg,
            configuration=configuration,
        )
Properties = typing.TypedDict(
    'Properties',
    {
        "members": typing.Type[Members],
        "joinerKit": typing.Type[JoinerKit],
        "backupPassphrase": typing.Type[BackupPassphrase],
    }
)
