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

import weather_pb2 as weather__pb2

GRPC_GENERATED_VERSION = '1.76.0'
GRPC_VERSION = grpc.__version__
_version_not_supported = False

try:
    from grpc._utilities import first_version_is_lower
    _version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION)
except ImportError:
    _version_not_supported = True

if _version_not_supported:
    raise RuntimeError(
        f'The grpc package installed is at version {GRPC_VERSION},'
        + ' but the generated code in weather_pb2_grpc.py depends on'
        + f' grpcio>={GRPC_GENERATED_VERSION}.'
        + f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}'
        + f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.'
    )


class WeatherAnalyticsServiceStub(object):
    """Services and RPCs
    ----------------------------------------------------------------

    1. Weather Sensor Service (Go)
    *This service won't act as a server; it's the client for the main RPC.*

    2. Weather Analytics Service (Python) - The central server
    """

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

        Args:
            channel: A grpc.Channel.
        """
        self.StreamWeatherData = channel.stream_unary(
                '/weather_system.WeatherAnalyticsService/StreamWeatherData',
                request_serializer=weather__pb2.WeatherData.SerializeToString,
                response_deserializer=weather__pb2.WeatherStats.FromString,
                _registered_method=True)
        self.StreamAnalytics = channel.unary_stream(
                '/weather_system.WeatherAnalyticsService/StreamAnalytics',
                request_serializer=weather__pb2.Empty.SerializeToString,
                response_deserializer=weather__pb2.WeatherStats.FromString,
                _registered_method=True)
        self.GetLastReport = channel.unary_unary(
                '/weather_system.WeatherAnalyticsService/GetLastReport',
                request_serializer=weather__pb2.Empty.SerializeToString,
                response_deserializer=weather__pb2.WeatherStats.FromString,
                _registered_method=True)
        self.ControlSensor = channel.stream_stream(
                '/weather_system.WeatherAnalyticsService/ControlSensor',
                request_serializer=weather__pb2.AlertMessage.SerializeToString,
                response_deserializer=weather__pb2.WeatherData.FromString,
                _registered_method=True)


class WeatherAnalyticsServiceServicer(object):
    """Services and RPCs
    ----------------------------------------------------------------

    1. Weather Sensor Service (Go)
    *This service won't act as a server; it's the client for the main RPC.*

    2. Weather Analytics Service (Python) - The central server
    """

    def StreamWeatherData(self, request_iterator, context):
        """A. Client Streaming (Required: Receive from Sensor)
        Sensor streams data; the server (Analytics) returns the final stats.
        Auth note: Token validation will use gRPC Metadata, not this message field.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def StreamAnalytics(self, request, context):
        """B. Server Streaming (Required: Send to Dashboard)
        Dashboard requests (with Empty) a continuous stream of reports.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def GetLastReport(self, request, context):
        """C. Unary RPC (Optional Requirement: Retrieve last report)
        Dashboard manually requests the last stored stats.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def ControlSensor(self, request_iterator, context):
        """D. Bidirectional Streaming (Academic addition)
        Allows the server to send immediate alerts and potentially control the sensor.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')


def add_WeatherAnalyticsServiceServicer_to_server(servicer, server):
    rpc_method_handlers = {
            'StreamWeatherData': grpc.stream_unary_rpc_method_handler(
                    servicer.StreamWeatherData,
                    request_deserializer=weather__pb2.WeatherData.FromString,
                    response_serializer=weather__pb2.WeatherStats.SerializeToString,
            ),
            'StreamAnalytics': grpc.unary_stream_rpc_method_handler(
                    servicer.StreamAnalytics,
                    request_deserializer=weather__pb2.Empty.FromString,
                    response_serializer=weather__pb2.WeatherStats.SerializeToString,
            ),
            'GetLastReport': grpc.unary_unary_rpc_method_handler(
                    servicer.GetLastReport,
                    request_deserializer=weather__pb2.Empty.FromString,
                    response_serializer=weather__pb2.WeatherStats.SerializeToString,
            ),
            'ControlSensor': grpc.stream_stream_rpc_method_handler(
                    servicer.ControlSensor,
                    request_deserializer=weather__pb2.AlertMessage.FromString,
                    response_serializer=weather__pb2.WeatherData.SerializeToString,
            ),
    }
    generic_handler = grpc.method_handlers_generic_handler(
            'weather_system.WeatherAnalyticsService', rpc_method_handlers)
    server.add_generic_rpc_handlers((generic_handler,))
    server.add_registered_method_handlers('weather_system.WeatherAnalyticsService', rpc_method_handlers)


 # This class is part of an EXPERIMENTAL API.
class WeatherAnalyticsService(object):
    """Services and RPCs
    ----------------------------------------------------------------

    1. Weather Sensor Service (Go)
    *This service won't act as a server; it's the client for the main RPC.*

    2. Weather Analytics Service (Python) - The central server
    """

    @staticmethod
    def StreamWeatherData(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_unary(
            request_iterator,
            target,
            '/weather_system.WeatherAnalyticsService/StreamWeatherData',
            weather__pb2.WeatherData.SerializeToString,
            weather__pb2.WeatherStats.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def StreamAnalytics(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_stream(
            request,
            target,
            '/weather_system.WeatherAnalyticsService/StreamAnalytics',
            weather__pb2.Empty.SerializeToString,
            weather__pb2.WeatherStats.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def GetLastReport(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,
            '/weather_system.WeatherAnalyticsService/GetLastReport',
            weather__pb2.Empty.SerializeToString,
            weather__pb2.WeatherStats.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def ControlSensor(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,
            '/weather_system.WeatherAnalyticsService/ControlSensor',
            weather__pb2.AlertMessage.SerializeToString,
            weather__pb2.WeatherData.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)
