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

import betterproto
import grpclib


@dataclass(eq=False, repr=False)
class Data(betterproto.Message):
    length: int = betterproto.uint32_field(1)
    data: bytes = betterproto.bytes_field(2)

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


@dataclass(eq=False, repr=False)
class PingRequest(betterproto.Message):
    payload: "Data" = betterproto.message_field(1)
    timestamp: int = betterproto.uint64_field(2)
    repeat_count: int = betterproto.uint32_field(3)

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


@dataclass(eq=False, repr=False)
class PingResponse(betterproto.Message):
    payload: "Data" = betterproto.message_field(1)
    timestamp: int = betterproto.uint64_field(2)

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


class PerfServiceStub(betterproto.ServiceStub):
    """PerfService provides a simple API for benchmarking gRPC."""

    async def ping(
        self, *, payload: "Data" = None, timestamp: int = 0, repeat_count: int = 0
    ) -> "PingResponse":

        request = PingRequest()
        if payload is not None:
            request.payload = payload
        request.timestamp = timestamp
        request.repeat_count = repeat_count

        return await self._unary_unary(
            "/onos.perf.PerfService/Ping", request, PingResponse
        )

    async def ping_stream(
        self,
        request_iterator: Union[AsyncIterable["PingRequest"], Iterable["PingRequest"]],
    ) -> AsyncIterator["PingResponse"]:

        async for response in self._stream_stream(
            "/onos.perf.PerfService/PingStream",
            request_iterator,
            PingRequest,
            PingResponse,
        ):
            yield response
