# Generated by the protocol buffer compiler.  DO NOT EDIT!
# sources: onos/a1t/a1/a1.proto, onos/a1t/a1/ei.proto, onos/a1t/a1/policy.proto
# plugin: python-betterproto
from dataclasses import dataclass
from typing import AsyncIterable, AsyncIterator, Iterable, Optional, Union

import betterproto
import grpclib


class Encoding(betterproto.Enum):
    PROTO = 0
    JSON = 1


class PayloadType(betterproto.Enum):
    POLICY = 0
    STATUS = 1


@dataclass(eq=False, repr=False)
class Header(betterproto.Message):
    request_id: str = betterproto.string_field(1)
    app_id: str = betterproto.string_field(2)
    app_instance_id: str = betterproto.string_field(3)
    a1_node_id: str = betterproto.string_field(4)
    encoding: "Encoding" = betterproto.enum_field(5)
    payload_type: "PayloadType" = betterproto.enum_field(6)

    def __post_init__(self) -> None:
        super().__post_init__()


@dataclass(eq=False, repr=False)
class Result(betterproto.Message):
    success: bool = betterproto.bool_field(1)
    reason: str = betterproto.string_field(2)

    def __post_init__(self) -> None:
        super().__post_init__()


@dataclass(eq=False, repr=False)
class RequestMessage(betterproto.Message):
    header: "Header" = betterproto.message_field(1)
    payload: bytes = betterproto.bytes_field(2)

    def __post_init__(self) -> None:
        super().__post_init__()


@dataclass(eq=False, repr=False)
class ResultMessage(betterproto.Message):
    header: "Header" = betterproto.message_field(1)
    payload: bytes = betterproto.bytes_field(2)
    result: "Result" = betterproto.message_field(3)

    def __post_init__(self) -> None:
        super().__post_init__()


@dataclass(eq=False, repr=False)
class StatusMessage(betterproto.Message):
    header: "Header" = betterproto.message_field(1)
    payload: bytes = betterproto.bytes_field(2)

    def __post_init__(self) -> None:
        super().__post_init__()


@dataclass(eq=False, repr=False)
class AckMessage(betterproto.Message):
    header: "Header" = betterproto.message_field(1)
    payload: bytes = betterproto.bytes_field(2)
    result: "Result" = betterproto.message_field(3)

    def __post_init__(self) -> None:
        super().__post_init__()


@dataclass(eq=False, repr=False)
class EiRequestMessage(betterproto.Message):
    ei_job_id: str = betterproto.string_field(1)
    message: "RequestMessage" = betterproto.message_field(2)

    def __post_init__(self) -> None:
        super().__post_init__()


@dataclass(eq=False, repr=False)
class EiResultMessage(betterproto.Message):
    ei_job_id: str = betterproto.string_field(1)
    message: "ResultMessage" = betterproto.message_field(2)

    def __post_init__(self) -> None:
        super().__post_init__()


@dataclass(eq=False, repr=False)
class EiStatusMessage(betterproto.Message):
    ei_job_id: str = betterproto.string_field(1)
    message: "StatusMessage" = betterproto.message_field(2)

    def __post_init__(self) -> None:
        super().__post_init__()


@dataclass(eq=False, repr=False)
class EiAckMessage(betterproto.Message):
    ei_job_id: str = betterproto.string_field(1)
    message: "AckMessage" = betterproto.message_field(2)

    def __post_init__(self) -> None:
        super().__post_init__()


@dataclass(eq=False, repr=False)
class PolicyType(betterproto.Message):
    id: str = betterproto.string_field(1)
    name: str = betterproto.string_field(2)
    version: str = betterproto.string_field(3)

    def __post_init__(self) -> None:
        super().__post_init__()


@dataclass(eq=False, repr=False)
class PolicyRequestMessage(betterproto.Message):
    policy_id: str = betterproto.string_field(1)
    policy_type: "PolicyType" = betterproto.message_field(2)
    message: "RequestMessage" = betterproto.message_field(3)
    notification_destination: str = betterproto.string_field(4)

    def __post_init__(self) -> None:
        super().__post_init__()


@dataclass(eq=False, repr=False)
class PolicyResultMessage(betterproto.Message):
    policy_id: str = betterproto.string_field(1)
    policy_type: "PolicyType" = betterproto.message_field(2)
    message: "ResultMessage" = betterproto.message_field(3)
    notification_destination: str = betterproto.string_field(4)

    def __post_init__(self) -> None:
        super().__post_init__()


@dataclass(eq=False, repr=False)
class PolicyStatusMessage(betterproto.Message):
    policy_id: str = betterproto.string_field(1)
    policy_type: "PolicyType" = betterproto.message_field(2)
    message: "StatusMessage" = betterproto.message_field(3)
    notification_destination: str = betterproto.string_field(4)

    def __post_init__(self) -> None:
        super().__post_init__()


@dataclass(eq=False, repr=False)
class PolicyAckMessage(betterproto.Message):
    policy_id: str = betterproto.string_field(1)
    policy_type: "PolicyType" = betterproto.message_field(2)
    message: "AckMessage" = betterproto.message_field(3)
    notification_destination: str = betterproto.string_field(4)

    def __post_init__(self) -> None:
        super().__post_init__()


class EiServiceStub(betterproto.ServiceStub):
    async def ei_query(
        self,
        request_iterator: Union[
            AsyncIterable["EiResultMessage"], Iterable["EiResultMessage"]
        ],
    ) -> AsyncIterator["EiRequestMessage"]:

        async for response in self._stream_stream(
            "/onos.a1t.a1.EIService/EIQuery",
            request_iterator,
            EiResultMessage,
            EiRequestMessage,
        ):
            yield response

    async def ei_job_setup(
        self,
        request_iterator: Union[
            AsyncIterable["EiResultMessage"], Iterable["EiResultMessage"]
        ],
    ) -> AsyncIterator["EiRequestMessage"]:

        async for response in self._stream_stream(
            "/onos.a1t.a1.EIService/EIJobSetup",
            request_iterator,
            EiResultMessage,
            EiRequestMessage,
        ):
            yield response

    async def ei_job_update(
        self,
        request_iterator: Union[
            AsyncIterable["EiResultMessage"], Iterable["EiResultMessage"]
        ],
    ) -> AsyncIterator["EiRequestMessage"]:

        async for response in self._stream_stream(
            "/onos.a1t.a1.EIService/EIJobUpdate",
            request_iterator,
            EiResultMessage,
            EiRequestMessage,
        ):
            yield response

    async def ei_job_delete(
        self,
        request_iterator: Union[
            AsyncIterable["EiResultMessage"], Iterable["EiResultMessage"]
        ],
    ) -> AsyncIterator["EiRequestMessage"]:

        async for response in self._stream_stream(
            "/onos.a1t.a1.EIService/EIJobDelete",
            request_iterator,
            EiResultMessage,
            EiRequestMessage,
        ):
            yield response

    async def ei_job_status_query(
        self,
        request_iterator: Union[
            AsyncIterable["EiResultMessage"], Iterable["EiResultMessage"]
        ],
    ) -> AsyncIterator["EiRequestMessage"]:

        async for response in self._stream_stream(
            "/onos.a1t.a1.EIService/EIJobStatusQuery",
            request_iterator,
            EiResultMessage,
            EiRequestMessage,
        ):
            yield response

    async def ei_job_status_notify(self) -> "EiAckMessage":

        request = EiStatusMessage()

        return await self._unary_unary(
            "/onos.a1t.a1.EIService/EIJobStatusNotify", request, EiAckMessage
        )

    async def ei_job_result_delivery(self) -> "EiAckMessage":

        request = EiResultMessage()

        return await self._unary_unary(
            "/onos.a1t.a1.EIService/EIJobResultDelivery", request, EiAckMessage
        )


class PolicyServiceStub(betterproto.ServiceStub):
    async def policy_setup(
        self,
        *,
        policy_id: str = "",
        policy_type: "PolicyType" = None,
        message: "RequestMessage" = None,
        notification_destination: str = "",
    ) -> "PolicyResultMessage":

        request = PolicyRequestMessage()
        request.policy_id = policy_id
        if policy_type is not None:
            request.policy_type = policy_type
        if message is not None:
            request.message = message
        request.notification_destination = notification_destination

        return await self._unary_unary(
            "/onos.a1t.a1.PolicyService/PolicySetup", request, PolicyResultMessage
        )

    async def policy_update(
        self,
        *,
        policy_id: str = "",
        policy_type: "PolicyType" = None,
        message: "RequestMessage" = None,
        notification_destination: str = "",
    ) -> "PolicyResultMessage":

        request = PolicyRequestMessage()
        request.policy_id = policy_id
        if policy_type is not None:
            request.policy_type = policy_type
        if message is not None:
            request.message = message
        request.notification_destination = notification_destination

        return await self._unary_unary(
            "/onos.a1t.a1.PolicyService/PolicyUpdate", request, PolicyResultMessage
        )

    async def policy_delete(
        self,
        *,
        policy_id: str = "",
        policy_type: "PolicyType" = None,
        message: "RequestMessage" = None,
        notification_destination: str = "",
    ) -> "PolicyResultMessage":

        request = PolicyRequestMessage()
        request.policy_id = policy_id
        if policy_type is not None:
            request.policy_type = policy_type
        if message is not None:
            request.message = message
        request.notification_destination = notification_destination

        return await self._unary_unary(
            "/onos.a1t.a1.PolicyService/PolicyDelete", request, PolicyResultMessage
        )

    async def policy_query(
        self,
        *,
        policy_id: str = "",
        policy_type: "PolicyType" = None,
        message: "RequestMessage" = None,
        notification_destination: str = "",
    ) -> "PolicyResultMessage":

        request = PolicyRequestMessage()
        request.policy_id = policy_id
        if policy_type is not None:
            request.policy_type = policy_type
        if message is not None:
            request.message = message
        request.notification_destination = notification_destination

        return await self._unary_unary(
            "/onos.a1t.a1.PolicyService/PolicyQuery", request, PolicyResultMessage
        )

    async def policy_status(
        self,
        request_iterator: Union[
            AsyncIterable["PolicyAckMessage"], Iterable["PolicyAckMessage"]
        ],
    ) -> AsyncIterator["PolicyStatusMessage"]:

        async for response in self._stream_stream(
            "/onos.a1t.a1.PolicyService/PolicyStatus",
            request_iterator,
            PolicyAckMessage,
            PolicyStatusMessage,
        ):
            yield response
