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

from openra_env.generated import rl_bridge_pb2 as rl__bridge__pb2

GRPC_GENERATED_VERSION = '1.75.1'
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 rl_bridge_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 RLBridgeStub(object):
    """The RL Bridge service allows an external agent to interact with OpenRA
    via bidirectional streaming (lock-step) or unary state queries.
    """

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

        Args:
            channel: A grpc.Channel.
        """
        self.GameSession = channel.stream_stream(
                '/openra.rl.RLBridge/GameSession',
                request_serializer=rl__bridge__pb2.AgentAction.SerializeToString,
                response_deserializer=rl__bridge__pb2.GameObservation.FromString,
                _registered_method=True)
        self.GetState = channel.unary_unary(
                '/openra.rl.RLBridge/GetState',
                request_serializer=rl__bridge__pb2.StateRequest.SerializeToString,
                response_deserializer=rl__bridge__pb2.GameState.FromString,
                _registered_method=True)


class RLBridgeServicer(object):
    """The RL Bridge service allows an external agent to interact with OpenRA
    via bidirectional streaming (lock-step) or unary state queries.
    """

    def GameSession(self, request_iterator, context):
        """Bidirectional streaming: game sends observations, agent sends actions.
        Each observation waits for an action before advancing to the next tick.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def GetState(self, request, context):
        """Unary: query current game state on demand.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')


def add_RLBridgeServicer_to_server(servicer, server):
    rpc_method_handlers = {
            'GameSession': grpc.stream_stream_rpc_method_handler(
                    servicer.GameSession,
                    request_deserializer=rl__bridge__pb2.AgentAction.FromString,
                    response_serializer=rl__bridge__pb2.GameObservation.SerializeToString,
            ),
            'GetState': grpc.unary_unary_rpc_method_handler(
                    servicer.GetState,
                    request_deserializer=rl__bridge__pb2.StateRequest.FromString,
                    response_serializer=rl__bridge__pb2.GameState.SerializeToString,
            ),
    }
    generic_handler = grpc.method_handlers_generic_handler(
            'openra.rl.RLBridge', rpc_method_handlers)
    server.add_generic_rpc_handlers((generic_handler,))
    server.add_registered_method_handlers('openra.rl.RLBridge', rpc_method_handlers)


 # This class is part of an EXPERIMENTAL API.
class RLBridge(object):
    """The RL Bridge service allows an external agent to interact with OpenRA
    via bidirectional streaming (lock-step) or unary state queries.
    """

    @staticmethod
    def GameSession(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,
            '/openra.rl.RLBridge/GameSession',
            rl__bridge__pb2.AgentAction.SerializeToString,
            rl__bridge__pb2.GameObservation.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def GetState(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,
            '/openra.rl.RLBridge/GetState',
            rl__bridge__pb2.StateRequest.SerializeToString,
            rl__bridge__pb2.GameState.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)
