# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
"""Client and server classes corresponding to protobuf-defined services."""
import grpc

from gen_proto.sdv.databroker.v1 import collector_pb2 as sdv_dot_databroker_dot_v1_dot_collector__pb2


class CollectorStub(object):
    """Missing associated documentation comment in .proto file."""

    def __init__(self, channel):
        """Constructor.

        Args:
            channel: A grpc.Channel.
        """
        self.RegisterDatapoints = channel.unary_unary(
                '/sdv.databroker.v1.Collector/RegisterDatapoints',
                request_serializer=sdv_dot_databroker_dot_v1_dot_collector__pb2.RegisterDatapointsRequest.SerializeToString,
                response_deserializer=sdv_dot_databroker_dot_v1_dot_collector__pb2.RegisterDatapointsReply.FromString,
                )
        self.UpdateDatapoints = channel.unary_unary(
                '/sdv.databroker.v1.Collector/UpdateDatapoints',
                request_serializer=sdv_dot_databroker_dot_v1_dot_collector__pb2.UpdateDatapointsRequest.SerializeToString,
                response_deserializer=sdv_dot_databroker_dot_v1_dot_collector__pb2.UpdateDatapointsReply.FromString,
                )
        self.StreamDatapoints = channel.stream_stream(
                '/sdv.databroker.v1.Collector/StreamDatapoints',
                request_serializer=sdv_dot_databroker_dot_v1_dot_collector__pb2.StreamDatapointsRequest.SerializeToString,
                response_deserializer=sdv_dot_databroker_dot_v1_dot_collector__pb2.StreamDatapointsReply.FromString,
                )


class CollectorServicer(object):
    """Missing associated documentation comment in .proto file."""

    def RegisterDatapoints(self, request, context):
        """A feeder (provider) shall call this as a first step to announce its "owned" data points
        to the Data Broker.
        If the registration of at least one of the passed data point fails, the overall registration
        is rejected and the gRPC status code ABORTED is returned (to indicate the "aborted" registration).
        The details, which data point(s) caused the failure and the reason, is passed in back in human-
        readable form in the status message. Possible failure resaons are:
        * PERMISSION_DENIED - Not allowed to register this name
        * ALREADY_REGISTERED - The data point is already registered by some other feeder
        * RE_REGISTRATION_MISMATCH - Already registered by this feeder but with differing metadata
        * INVALID_NAME - The passed name of the datapoint has an invalid structure
        * INVALID_VALUE_TYPE - The passed ValueType is not supported
        * INVALID_CHANGE_TYPE - The passed ChangeType is not supported
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def UpdateDatapoints(self, request, context):
        """TODO: Convert RegisterDatapointsReply into a stream in order to be able to communicate
        subscription state (i.e. if there are subscribing clients)
        or
        Use a separate function (typically immediately) called after successful
        registration of datapoints, e.g.:

        rpc GetSubscriptionStates(<list of ids>) returns (stream SubscriptionStatesReply);
        or
        rpc ProvideDatapoints(ProvideDatapointsRequest) returns (stream ProvideDatapointsReply);

        Provide a set of updated datapoint values to the broker.
        This is the unary equivalent of `StreamDatapoints` below and is better suited for cases
        where the frequency of updates is rather low.

        NOTE: The values provided in a single request are handled as a single update in the
        data broker. This ensures that any clients requesting (or subscribing to) a set of
        datapoints will get a consistent update, i.e. that either all values are updated or
        none are.

        Returns: any errors encountered updating the datapoints

        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def StreamDatapoints(self, request_iterator, context):
        """Provide a stream with updated datapoint values to the broker.
        This is the streaming equivalent of `UpdateDatapoints` above and is better suited for
        cases where the frequency of updates is high.

        NOTE: The values provided in a single request are handled as a single update in the
        data broker. This ensures that any clients requesting (or subscribing to) a set of
        datapoints will get a consistent update, i.e. that either all values are updated or
        none are.

        Returns: any errors encountered updating the datapoints

        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')


def add_CollectorServicer_to_server(servicer, server):
    rpc_method_handlers = {
            'RegisterDatapoints': grpc.unary_unary_rpc_method_handler(
                    servicer.RegisterDatapoints,
                    request_deserializer=sdv_dot_databroker_dot_v1_dot_collector__pb2.RegisterDatapointsRequest.FromString,
                    response_serializer=sdv_dot_databroker_dot_v1_dot_collector__pb2.RegisterDatapointsReply.SerializeToString,
            ),
            'UpdateDatapoints': grpc.unary_unary_rpc_method_handler(
                    servicer.UpdateDatapoints,
                    request_deserializer=sdv_dot_databroker_dot_v1_dot_collector__pb2.UpdateDatapointsRequest.FromString,
                    response_serializer=sdv_dot_databroker_dot_v1_dot_collector__pb2.UpdateDatapointsReply.SerializeToString,
            ),
            'StreamDatapoints': grpc.stream_stream_rpc_method_handler(
                    servicer.StreamDatapoints,
                    request_deserializer=sdv_dot_databroker_dot_v1_dot_collector__pb2.StreamDatapointsRequest.FromString,
                    response_serializer=sdv_dot_databroker_dot_v1_dot_collector__pb2.StreamDatapointsReply.SerializeToString,
            ),
    }
    generic_handler = grpc.method_handlers_generic_handler(
            'sdv.databroker.v1.Collector', rpc_method_handlers)
    server.add_generic_rpc_handlers((generic_handler,))


 # This class is part of an EXPERIMENTAL API.
class Collector(object):
    """Missing associated documentation comment in .proto file."""

    @staticmethod
    def RegisterDatapoints(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(request, target, '/sdv.databroker.v1.Collector/RegisterDatapoints',
            sdv_dot_databroker_dot_v1_dot_collector__pb2.RegisterDatapointsRequest.SerializeToString,
            sdv_dot_databroker_dot_v1_dot_collector__pb2.RegisterDatapointsReply.FromString,
            options, channel_credentials,
            insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

    @staticmethod
    def UpdateDatapoints(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(request, target, '/sdv.databroker.v1.Collector/UpdateDatapoints',
            sdv_dot_databroker_dot_v1_dot_collector__pb2.UpdateDatapointsRequest.SerializeToString,
            sdv_dot_databroker_dot_v1_dot_collector__pb2.UpdateDatapointsReply.FromString,
            options, channel_credentials,
            insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

    @staticmethod
    def StreamDatapoints(request_iterator,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.stream_stream(request_iterator, target, '/sdv.databroker.v1.Collector/StreamDatapoints',
            sdv_dot_databroker_dot_v1_dot_collector__pb2.StreamDatapointsRequest.SerializeToString,
            sdv_dot_databroker_dot_v1_dot_collector__pb2.StreamDatapointsReply.FromString,
            options, channel_credentials,
            insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
