# 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 terrascope_api.models import algorithm_computation_pb2 as algorithm__computation__pb2

GRPC_GENERATED_VERSION = '1.68.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},'
        + f' but the generated code in algorithm_computation_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 AlgorithmComputationApiStub(object):
    """*************************************************************
    Computation Interface
    *************************************************************

    """

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

        Args:
            channel: A grpc.Channel.
        """
        self.create = channel.unary_unary(
                '/oi.papi.AlgorithmComputationApi/create',
                request_serializer=algorithm__computation__pb2.AlgorithmComputationCreateRequest.SerializeToString,
                response_deserializer=algorithm__computation__pb2.AlgorithmComputationCreateResponse.FromString,
                _registered_method=True)
        self.run = channel.unary_unary(
                '/oi.papi.AlgorithmComputationApi/run',
                request_serializer=algorithm__computation__pb2.AlgorithmComputationRunRequest.SerializeToString,
                response_deserializer=algorithm__computation__pb2.AlgorithmComputationRunResponse.FromString,
                _registered_method=True)
        self.get = channel.unary_unary(
                '/oi.papi.AlgorithmComputationApi/get',
                request_serializer=algorithm__computation__pb2.AlgorithmComputationGetRequest.SerializeToString,
                response_deserializer=algorithm__computation__pb2.AlgorithmComputationGetResponse.FromString,
                _registered_method=True)
        self.list = channel.unary_unary(
                '/oi.papi.AlgorithmComputationApi/list',
                request_serializer=algorithm__computation__pb2.AlgorithmComputationListRequest.SerializeToString,
                response_deserializer=algorithm__computation__pb2.AlgorithmComputationListResponse.FromString,
                _registered_method=True)


class AlgorithmComputationApiServicer(object):
    """*************************************************************
    Computation Interface
    *************************************************************

    """

    def create(self, request, context):
        """
        Create the runnable component in the system, by specifying the AlgorithmConfig to be run,
        the set of AOIs to be run on, and the TOI. The algorithm_computation_id is returned so that it can be run.
        Note that until an algorithm_computation has been run, its underlying resources are NOT locked and therefore can be changed.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def run(self, request, context):
        """
        The first time this endpoint is called, the system initiates the running of the provided algorithm_computation_id.
        This causes credits to be place in pending status and eventually consumed when the computation completes.
        Credits are consumed as each result is produced.
        Once an algorithm_computation has been run, it is considered locked and cannot be changed, as are its constituents.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def get(self, request, context):
        """
        Retrieves the details of the provided algorithm_computation including its current state and its progress.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def list(self, request, context):
        """
        Lists the details for all AlgorithmComputations that the requester has access to including their current state and their progress.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')


def add_AlgorithmComputationApiServicer_to_server(servicer, server):
    rpc_method_handlers = {
            'create': grpc.unary_unary_rpc_method_handler(
                    servicer.create,
                    request_deserializer=algorithm__computation__pb2.AlgorithmComputationCreateRequest.FromString,
                    response_serializer=algorithm__computation__pb2.AlgorithmComputationCreateResponse.SerializeToString,
            ),
            'run': grpc.unary_unary_rpc_method_handler(
                    servicer.run,
                    request_deserializer=algorithm__computation__pb2.AlgorithmComputationRunRequest.FromString,
                    response_serializer=algorithm__computation__pb2.AlgorithmComputationRunResponse.SerializeToString,
            ),
            'get': grpc.unary_unary_rpc_method_handler(
                    servicer.get,
                    request_deserializer=algorithm__computation__pb2.AlgorithmComputationGetRequest.FromString,
                    response_serializer=algorithm__computation__pb2.AlgorithmComputationGetResponse.SerializeToString,
            ),
            'list': grpc.unary_unary_rpc_method_handler(
                    servicer.list,
                    request_deserializer=algorithm__computation__pb2.AlgorithmComputationListRequest.FromString,
                    response_serializer=algorithm__computation__pb2.AlgorithmComputationListResponse.SerializeToString,
            ),
    }
    generic_handler = grpc.method_handlers_generic_handler(
            'oi.papi.AlgorithmComputationApi', rpc_method_handlers)
    server.add_generic_rpc_handlers((generic_handler,))
    server.add_registered_method_handlers('oi.papi.AlgorithmComputationApi', rpc_method_handlers)


 # This class is part of an EXPERIMENTAL API.
class AlgorithmComputationApi(object):
    """*************************************************************
    Computation Interface
    *************************************************************

    """

    @staticmethod
    def create(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,
            '/oi.papi.AlgorithmComputationApi/create',
            algorithm__computation__pb2.AlgorithmComputationCreateRequest.SerializeToString,
            algorithm__computation__pb2.AlgorithmComputationCreateResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def run(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,
            '/oi.papi.AlgorithmComputationApi/run',
            algorithm__computation__pb2.AlgorithmComputationRunRequest.SerializeToString,
            algorithm__computation__pb2.AlgorithmComputationRunResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def get(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,
            '/oi.papi.AlgorithmComputationApi/get',
            algorithm__computation__pb2.AlgorithmComputationGetRequest.SerializeToString,
            algorithm__computation__pb2.AlgorithmComputationGetResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def list(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,
            '/oi.papi.AlgorithmComputationApi/list',
            algorithm__computation__pb2.AlgorithmComputationListRequest.SerializeToString,
            algorithm__computation__pb2.AlgorithmComputationListResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)
