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

import betterproto
import grpclib


class EncodingType(betterproto.Enum):
    """EncodingType determines encoding type for the response messages"""

    PROTO = 0
    ASN1_PER = 1
    ASN1_XER = 2


class ResponseStatus(betterproto.Enum):
    """ResponseStatus"""

    FAILED = 0
    SUCCEEDED = 1


@dataclass(eq=False, repr=False)
class ServiceModelInfo(betterproto.Message):
    """ServiceModelInfo E2 service model information"""

    service_model_id: str = betterproto.string_field(1)

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


@dataclass(eq=False, repr=False)
class RequestHeader(betterproto.Message):
    """
    RequestHeader a common request header for all requests including encoding
    type, client/xApp/session info, ordering info, etc
    """

    encoding_type: "EncodingType" = betterproto.enum_field(1)
    service_model_info: "ServiceModelInfo" = betterproto.message_field(2)

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


@dataclass(eq=False, repr=False)
class ResponseHeader(betterproto.Message):
    """
    ResponseHeader a common response header for all responses including
    encoding type, client/xApp/session info, ordering info, etc
    """

    encoding_type: "EncodingType" = betterproto.enum_field(1)
    service_model_info: "ServiceModelInfo" = betterproto.message_field(2)
    response_status: "ResponseStatus" = betterproto.enum_field(3)
    indication_header: bytes = betterproto.bytes_field(4)

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


@dataclass(eq=False, repr=False)
class StreamRequest(betterproto.Message):
    """StreamRequest"""

    header: "RequestHeader" = betterproto.message_field(1)
    app_id: str = betterproto.string_field(2)
    instance_id: str = betterproto.string_field(3)
    subscription_id: str = betterproto.string_field(4)

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


@dataclass(eq=False, repr=False)
class StreamResponse(betterproto.Message):
    """StreamResponse"""

    header: "ResponseHeader" = betterproto.message_field(1)
    indication_message: bytes = betterproto.bytes_field(2)

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


class E2TServiceStub(betterproto.ServiceStub):
    """
    E2TService provides means for enhanced interactions with the ONOS RIC E2
    Termination service.
    """

    async def stream(
        self,
        request_iterator: Union[
            AsyncIterable["StreamRequest"], Iterable["StreamRequest"]
        ],
    ) -> AsyncIterator["StreamResponse"]:
        """Stream opens an indications stream"""

        async for response in self._stream_stream(
            "/onos.e2t.e2.E2TService/Stream",
            request_iterator,
            StreamRequest,
            StreamResponse,
        ):
            yield response
