# Generated by the protocol buffer compiler.  DO NOT EDIT!
# sources: users.proto
# plugin: python-betterproto
from dataclasses import dataclass
from typing import TYPE_CHECKING, AsyncIterator, Dict, List, Optional

import betterproto
import grpclib
from betterproto.grpc.grpclib_server import ServiceBase

if TYPE_CHECKING:
    import grpclib.server
    from betterproto.grpc.grpclib_client import MetadataLike
    from grpclib.metadata import Deadline


@dataclass(eq=False, repr=False)
class CreateReq(betterproto.Message):
    options: "CreateReqOptions" = betterproto.message_field(1)


@dataclass(eq=False, repr=False)
class CreateReqOptions(betterproto.Message):
    login_name: str = betterproto.string_field(1)
    password: str = betterproto.string_field(2)
    full_name: str = betterproto.string_field(3)
    groups: List[str] = betterproto.string_field(4)


@dataclass(eq=False, repr=False)
class CreateResp(betterproto.Message):
    pass


@dataclass(eq=False, repr=False)
class UpdateReq(betterproto.Message):
    options: "UpdateReqOptions" = betterproto.message_field(1)


@dataclass(eq=False, repr=False)
class UpdateReqOptions(betterproto.Message):
    login_name: str = betterproto.string_field(1)
    password: str = betterproto.string_field(2)
    full_name: str = betterproto.string_field(3)
    groups: List[str] = betterproto.string_field(4)


@dataclass(eq=False, repr=False)
class UpdateResp(betterproto.Message):
    pass


@dataclass(eq=False, repr=False)
class DeleteReq(betterproto.Message):
    options: "DeleteReqOptions" = betterproto.message_field(1)


@dataclass(eq=False, repr=False)
class DeleteReqOptions(betterproto.Message):
    login_name: str = betterproto.string_field(1)


@dataclass(eq=False, repr=False)
class DeleteResp(betterproto.Message):
    pass


@dataclass(eq=False, repr=False)
class EnableReq(betterproto.Message):
    options: "EnableReqOptions" = betterproto.message_field(1)


@dataclass(eq=False, repr=False)
class EnableReqOptions(betterproto.Message):
    login_name: str = betterproto.string_field(1)


@dataclass(eq=False, repr=False)
class EnableResp(betterproto.Message):
    pass


@dataclass(eq=False, repr=False)
class DisableReq(betterproto.Message):
    options: "DisableReqOptions" = betterproto.message_field(1)


@dataclass(eq=False, repr=False)
class DisableReqOptions(betterproto.Message):
    login_name: str = betterproto.string_field(1)


@dataclass(eq=False, repr=False)
class DisableResp(betterproto.Message):
    pass


@dataclass(eq=False, repr=False)
class DetailsReq(betterproto.Message):
    options: "DetailsReqOptions" = betterproto.message_field(1)


@dataclass(eq=False, repr=False)
class DetailsReqOptions(betterproto.Message):
    login_name: str = betterproto.string_field(1)


@dataclass(eq=False, repr=False)
class DetailsResp(betterproto.Message):
    user_details: "DetailsRespUserDetails" = betterproto.message_field(1)


@dataclass(eq=False, repr=False)
class DetailsRespUserDetails(betterproto.Message):
    login_name: str = betterproto.string_field(1)
    full_name: str = betterproto.string_field(2)
    groups: List[str] = betterproto.string_field(3)
    last_updated: "DetailsRespUserDetailsDateTime" = betterproto.message_field(4)
    disabled: bool = betterproto.bool_field(5)


@dataclass(eq=False, repr=False)
class DetailsRespUserDetailsDateTime(betterproto.Message):
    ticks_since_epoch: int = betterproto.int64_field(1)


@dataclass(eq=False, repr=False)
class ChangePasswordReq(betterproto.Message):
    options: "ChangePasswordReqOptions" = betterproto.message_field(1)


@dataclass(eq=False, repr=False)
class ChangePasswordReqOptions(betterproto.Message):
    login_name: str = betterproto.string_field(1)
    current_password: str = betterproto.string_field(2)
    new_password: str = betterproto.string_field(3)


@dataclass(eq=False, repr=False)
class ChangePasswordResp(betterproto.Message):
    pass


@dataclass(eq=False, repr=False)
class ResetPasswordReq(betterproto.Message):
    options: "ResetPasswordReqOptions" = betterproto.message_field(1)


@dataclass(eq=False, repr=False)
class ResetPasswordReqOptions(betterproto.Message):
    login_name: str = betterproto.string_field(1)
    new_password: str = betterproto.string_field(2)


@dataclass(eq=False, repr=False)
class ResetPasswordResp(betterproto.Message):
    pass


class UsersStub(betterproto.ServiceStub):
    async def create(
        self,
        create_req: "CreateReq",
        *,
        timeout: Optional[float] = None,
        deadline: Optional["Deadline"] = None,
        metadata: Optional["MetadataLike"] = None,
    ) -> "CreateResp":
        return await self._unary_unary(
            "/event_store.client.users.Users/Create",
            create_req,
            CreateResp,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        )

    async def update(
        self,
        update_req: "UpdateReq",
        *,
        timeout: Optional[float] = None,
        deadline: Optional["Deadline"] = None,
        metadata: Optional["MetadataLike"] = None,
    ) -> "UpdateResp":
        return await self._unary_unary(
            "/event_store.client.users.Users/Update",
            update_req,
            UpdateResp,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        )

    async def delete(
        self,
        delete_req: "DeleteReq",
        *,
        timeout: Optional[float] = None,
        deadline: Optional["Deadline"] = None,
        metadata: Optional["MetadataLike"] = None,
    ) -> "DeleteResp":
        return await self._unary_unary(
            "/event_store.client.users.Users/Delete",
            delete_req,
            DeleteResp,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        )

    async def disable(
        self,
        disable_req: "DisableReq",
        *,
        timeout: Optional[float] = None,
        deadline: Optional["Deadline"] = None,
        metadata: Optional["MetadataLike"] = None,
    ) -> "DisableResp":
        return await self._unary_unary(
            "/event_store.client.users.Users/Disable",
            disable_req,
            DisableResp,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        )

    async def enable(
        self,
        enable_req: "EnableReq",
        *,
        timeout: Optional[float] = None,
        deadline: Optional["Deadline"] = None,
        metadata: Optional["MetadataLike"] = None,
    ) -> "EnableResp":
        return await self._unary_unary(
            "/event_store.client.users.Users/Enable",
            enable_req,
            EnableResp,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        )

    async def details(
        self,
        details_req: "DetailsReq",
        *,
        timeout: Optional[float] = None,
        deadline: Optional["Deadline"] = None,
        metadata: Optional["MetadataLike"] = None,
    ) -> AsyncIterator["DetailsResp"]:
        async for response in self._unary_stream(
            "/event_store.client.users.Users/Details",
            details_req,
            DetailsResp,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        ):
            yield response

    async def change_password(
        self,
        change_password_req: "ChangePasswordReq",
        *,
        timeout: Optional[float] = None,
        deadline: Optional["Deadline"] = None,
        metadata: Optional["MetadataLike"] = None,
    ) -> "ChangePasswordResp":
        return await self._unary_unary(
            "/event_store.client.users.Users/ChangePassword",
            change_password_req,
            ChangePasswordResp,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        )

    async def reset_password(
        self,
        reset_password_req: "ResetPasswordReq",
        *,
        timeout: Optional[float] = None,
        deadline: Optional["Deadline"] = None,
        metadata: Optional["MetadataLike"] = None,
    ) -> "ResetPasswordResp":
        return await self._unary_unary(
            "/event_store.client.users.Users/ResetPassword",
            reset_password_req,
            ResetPasswordResp,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        )


class UsersBase(ServiceBase):
    async def create(self, create_req: "CreateReq") -> "CreateResp":
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def update(self, update_req: "UpdateReq") -> "UpdateResp":
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def delete(self, delete_req: "DeleteReq") -> "DeleteResp":
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def disable(self, disable_req: "DisableReq") -> "DisableResp":
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def enable(self, enable_req: "EnableReq") -> "EnableResp":
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def details(self, details_req: "DetailsReq") -> AsyncIterator["DetailsResp"]:
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def change_password(
        self, change_password_req: "ChangePasswordReq"
    ) -> "ChangePasswordResp":
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def reset_password(
        self, reset_password_req: "ResetPasswordReq"
    ) -> "ResetPasswordResp":
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def __rpc_create(
        self, stream: "grpclib.server.Stream[CreateReq, CreateResp]"
    ) -> None:
        request = await stream.recv_message()
        response = await self.create(request)
        await stream.send_message(response)

    async def __rpc_update(
        self, stream: "grpclib.server.Stream[UpdateReq, UpdateResp]"
    ) -> None:
        request = await stream.recv_message()
        response = await self.update(request)
        await stream.send_message(response)

    async def __rpc_delete(
        self, stream: "grpclib.server.Stream[DeleteReq, DeleteResp]"
    ) -> None:
        request = await stream.recv_message()
        response = await self.delete(request)
        await stream.send_message(response)

    async def __rpc_disable(
        self, stream: "grpclib.server.Stream[DisableReq, DisableResp]"
    ) -> None:
        request = await stream.recv_message()
        response = await self.disable(request)
        await stream.send_message(response)

    async def __rpc_enable(
        self, stream: "grpclib.server.Stream[EnableReq, EnableResp]"
    ) -> None:
        request = await stream.recv_message()
        response = await self.enable(request)
        await stream.send_message(response)

    async def __rpc_details(
        self, stream: "grpclib.server.Stream[DetailsReq, DetailsResp]"
    ) -> None:
        request = await stream.recv_message()
        await self._call_rpc_handler_server_stream(
            self.details,
            stream,
            request,
        )

    async def __rpc_change_password(
        self, stream: "grpclib.server.Stream[ChangePasswordReq, ChangePasswordResp]"
    ) -> None:
        request = await stream.recv_message()
        response = await self.change_password(request)
        await stream.send_message(response)

    async def __rpc_reset_password(
        self, stream: "grpclib.server.Stream[ResetPasswordReq, ResetPasswordResp]"
    ) -> None:
        request = await stream.recv_message()
        response = await self.reset_password(request)
        await stream.send_message(response)

    def __mapping__(self) -> Dict[str, grpclib.const.Handler]:
        return {
            "/event_store.client.users.Users/Create": grpclib.const.Handler(
                self.__rpc_create,
                grpclib.const.Cardinality.UNARY_UNARY,
                CreateReq,
                CreateResp,
            ),
            "/event_store.client.users.Users/Update": grpclib.const.Handler(
                self.__rpc_update,
                grpclib.const.Cardinality.UNARY_UNARY,
                UpdateReq,
                UpdateResp,
            ),
            "/event_store.client.users.Users/Delete": grpclib.const.Handler(
                self.__rpc_delete,
                grpclib.const.Cardinality.UNARY_UNARY,
                DeleteReq,
                DeleteResp,
            ),
            "/event_store.client.users.Users/Disable": grpclib.const.Handler(
                self.__rpc_disable,
                grpclib.const.Cardinality.UNARY_UNARY,
                DisableReq,
                DisableResp,
            ),
            "/event_store.client.users.Users/Enable": grpclib.const.Handler(
                self.__rpc_enable,
                grpclib.const.Cardinality.UNARY_UNARY,
                EnableReq,
                EnableResp,
            ),
            "/event_store.client.users.Users/Details": grpclib.const.Handler(
                self.__rpc_details,
                grpclib.const.Cardinality.UNARY_STREAM,
                DetailsReq,
                DetailsResp,
            ),
            "/event_store.client.users.Users/ChangePassword": grpclib.const.Handler(
                self.__rpc_change_password,
                grpclib.const.Cardinality.UNARY_UNARY,
                ChangePasswordReq,
                ChangePasswordResp,
            ),
            "/event_store.client.users.Users/ResetPassword": grpclib.const.Handler(
                self.__rpc_reset_password,
                grpclib.const.Cardinality.UNARY_UNARY,
                ResetPasswordReq,
                ResetPasswordResp,
            ),
        }
