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

from truffle.app import background_pb2 as truffle_dot_app_dot_background__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 truffle/app/background_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 BackgroundAppServiceStub(object):
    """
    The service exposed to background apps when running in the Truffle OS.
    gated by per app api key, available in the environment when the app is run.
    """

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

        Args:
            channel: A grpc.Channel.
        """
        self.Submit = channel.unary_unary(
                '/truffle.app.BackgroundAppService/Submit',
                request_serializer=truffle_dot_app_dot_background__pb2.BackgroundAppSubmitContextRequest.SerializeToString,
                response_deserializer=truffle_dot_app_dot_background__pb2.BackgroundAppSubmitContextResponse.FromString,
                _registered_method=True)
        self.OnRun = channel.unary_unary(
                '/truffle.app.BackgroundAppService/OnRun',
                request_serializer=truffle_dot_app_dot_background__pb2.BackgroundAppOnRunRequest.SerializeToString,
                response_deserializer=truffle_dot_app_dot_background__pb2.BackgroundAppOnRunResponse.FromString,
                _registered_method=True)
        self.Yield = channel.unary_unary(
                '/truffle.app.BackgroundAppService/Yield',
                request_serializer=truffle_dot_app_dot_background__pb2.BackgroundAppYieldRequest.SerializeToString,
                response_deserializer=truffle_dot_app_dot_background__pb2.BackgroundAppYieldResponse.FromString,
                _registered_method=True)


class BackgroundAppServiceServicer(object):
    """
    The service exposed to background apps when running in the Truffle OS.
    gated by per app api key, available in the environment when the app is run.
    """

    def Submit(self, request, context):
        """post context 
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def OnRun(self, request, context):
        """must be called when the app is run by the system scheduler in the first few seconds of execution or the run will be considered failed
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def Yield(self, request, context):
        """Missing associated documentation comment in .proto file."""
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')


def add_BackgroundAppServiceServicer_to_server(servicer, server):
    rpc_method_handlers = {
            'Submit': grpc.unary_unary_rpc_method_handler(
                    servicer.Submit,
                    request_deserializer=truffle_dot_app_dot_background__pb2.BackgroundAppSubmitContextRequest.FromString,
                    response_serializer=truffle_dot_app_dot_background__pb2.BackgroundAppSubmitContextResponse.SerializeToString,
            ),
            'OnRun': grpc.unary_unary_rpc_method_handler(
                    servicer.OnRun,
                    request_deserializer=truffle_dot_app_dot_background__pb2.BackgroundAppOnRunRequest.FromString,
                    response_serializer=truffle_dot_app_dot_background__pb2.BackgroundAppOnRunResponse.SerializeToString,
            ),
            'Yield': grpc.unary_unary_rpc_method_handler(
                    servicer.Yield,
                    request_deserializer=truffle_dot_app_dot_background__pb2.BackgroundAppYieldRequest.FromString,
                    response_serializer=truffle_dot_app_dot_background__pb2.BackgroundAppYieldResponse.SerializeToString,
            ),
    }
    generic_handler = grpc.method_handlers_generic_handler(
            'truffle.app.BackgroundAppService', rpc_method_handlers)
    server.add_generic_rpc_handlers((generic_handler,))
    server.add_registered_method_handlers('truffle.app.BackgroundAppService', rpc_method_handlers)


 # This class is part of an EXPERIMENTAL API.
class BackgroundAppService(object):
    """
    The service exposed to background apps when running in the Truffle OS.
    gated by per app api key, available in the environment when the app is run.
    """

    @staticmethod
    def Submit(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,
            '/truffle.app.BackgroundAppService/Submit',
            truffle_dot_app_dot_background__pb2.BackgroundAppSubmitContextRequest.SerializeToString,
            truffle_dot_app_dot_background__pb2.BackgroundAppSubmitContextResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def OnRun(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,
            '/truffle.app.BackgroundAppService/OnRun',
            truffle_dot_app_dot_background__pb2.BackgroundAppOnRunRequest.SerializeToString,
            truffle_dot_app_dot_background__pb2.BackgroundAppOnRunResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def Yield(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,
            '/truffle.app.BackgroundAppService/Yield',
            truffle_dot_app_dot_background__pb2.BackgroundAppYieldRequest.SerializeToString,
            truffle_dot_app_dot_background__pb2.BackgroundAppYieldResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)
