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

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


@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, *, options: "CreateReqOptions" = None) -> "CreateResp":

        request = CreateReq()
        if options is not None:
            request.options = options

        return await self._unary_unary(
            "/event_store.client.users.Users/Create", request, CreateResp
        )

    async def update(self, *, options: "UpdateReqOptions" = None) -> "UpdateResp":

        request = UpdateReq()
        if options is not None:
            request.options = options

        return await self._unary_unary(
            "/event_store.client.users.Users/Update", request, UpdateResp
        )

    async def delete(self, *, options: "DeleteReqOptions" = None) -> "DeleteResp":

        request = DeleteReq()
        if options is not None:
            request.options = options

        return await self._unary_unary(
            "/event_store.client.users.Users/Delete", request, DeleteResp
        )

    async def disable(self, *, options: "DisableReqOptions" = None) -> "DisableResp":

        request = DisableReq()
        if options is not None:
            request.options = options

        return await self._unary_unary(
            "/event_store.client.users.Users/Disable", request, DisableResp
        )

    async def enable(self, *, options: "EnableReqOptions" = None) -> "EnableResp":

        request = EnableReq()
        if options is not None:
            request.options = options

        return await self._unary_unary(
            "/event_store.client.users.Users/Enable", request, EnableResp
        )

    async def details(
        self, *, options: "DetailsReqOptions" = None
    ) -> AsyncIterator["DetailsResp"]:

        request = DetailsReq()
        if options is not None:
            request.options = options

        async for response in self._unary_stream(
            "/event_store.client.users.Users/Details",
            request,
            DetailsResp,
        ):
            yield response

    async def change_password(
        self, *, options: "ChangePasswordReqOptions" = None
    ) -> "ChangePasswordResp":

        request = ChangePasswordReq()
        if options is not None:
            request.options = options

        return await self._unary_unary(
            "/event_store.client.users.Users/ChangePassword",
            request,
            ChangePasswordResp,
        )

    async def reset_password(
        self, *, options: "ResetPasswordReqOptions" = None
    ) -> "ResetPasswordResp":

        request = ResetPasswordReq()
        if options is not None:
            request.options = options

        return await self._unary_unary(
            "/event_store.client.users.Users/ResetPassword", request, ResetPasswordResp
        )


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

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

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

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

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

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

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

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

    async def __rpc_create(self, stream: grpclib.server.Stream) -> None:
        request = await stream.recv_message()

        request_kwargs = {
            "options": request.options,
        }

        response = await self.create(**request_kwargs)
        await stream.send_message(response)

    async def __rpc_update(self, stream: grpclib.server.Stream) -> None:
        request = await stream.recv_message()

        request_kwargs = {
            "options": request.options,
        }

        response = await self.update(**request_kwargs)
        await stream.send_message(response)

    async def __rpc_delete(self, stream: grpclib.server.Stream) -> None:
        request = await stream.recv_message()

        request_kwargs = {
            "options": request.options,
        }

        response = await self.delete(**request_kwargs)
        await stream.send_message(response)

    async def __rpc_disable(self, stream: grpclib.server.Stream) -> None:
        request = await stream.recv_message()

        request_kwargs = {
            "options": request.options,
        }

        response = await self.disable(**request_kwargs)
        await stream.send_message(response)

    async def __rpc_enable(self, stream: grpclib.server.Stream) -> None:
        request = await stream.recv_message()

        request_kwargs = {
            "options": request.options,
        }

        response = await self.enable(**request_kwargs)
        await stream.send_message(response)

    async def __rpc_details(self, stream: grpclib.server.Stream) -> None:
        request = await stream.recv_message()

        request_kwargs = {
            "options": request.options,
        }

        await self._call_rpc_handler_server_stream(
            self.details,
            stream,
            request_kwargs,
        )

    async def __rpc_change_password(self, stream: grpclib.server.Stream) -> None:
        request = await stream.recv_message()

        request_kwargs = {
            "options": request.options,
        }

        response = await self.change_password(**request_kwargs)
        await stream.send_message(response)

    async def __rpc_reset_password(self, stream: grpclib.server.Stream) -> None:
        request = await stream.recv_message()

        request_kwargs = {
            "options": request.options,
        }

        response = await self.reset_password(**request_kwargs)
        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,
            ),
        }
