# Copyright (c) 2017-2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
# fmt: off
# isort: skip_file
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
"""Client and server classes corresponding to protobuf-defined services."""
import grpc

from . import pruning_service_pb2 as com_dot_digitalasset_dot_canton_dot_participant_dot_admin_dot_v0_dot_pruning__service__pb2
from ....pruning.admin.v0 import pruning_pb2 as com_dot_digitalasset_dot_canton_dot_pruning_dot_admin_dot_v0_dot_pruning__pb2


class PruningServiceStub(object):
    """Canton-internal pruning service that prunes only canton state, but leaves the ledger-api
    state unpruned.
    """

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

        Args:
            channel: A grpc.Channel.
        """
        self.Prune = channel.unary_unary(
                '/com.digitalasset.canton.participant.admin.v0.PruningService/Prune',
                request_serializer=com_dot_digitalasset_dot_canton_dot_participant_dot_admin_dot_v0_dot_pruning__service__pb2.PruneRequest.SerializeToString,
                response_deserializer=com_dot_digitalasset_dot_canton_dot_participant_dot_admin_dot_v0_dot_pruning__service__pb2.PruneResponse.FromString,
                )
        self.GetSafePruningOffset = channel.unary_unary(
                '/com.digitalasset.canton.participant.admin.v0.PruningService/GetSafePruningOffset',
                request_serializer=com_dot_digitalasset_dot_canton_dot_participant_dot_admin_dot_v0_dot_pruning__service__pb2.GetSafePruningOffsetRequest.SerializeToString,
                response_deserializer=com_dot_digitalasset_dot_canton_dot_participant_dot_admin_dot_v0_dot_pruning__service__pb2.GetSafePruningOffsetResponse.FromString,
                )
        self.SetSchedule = channel.unary_unary(
                '/com.digitalasset.canton.participant.admin.v0.PruningService/SetSchedule',
                request_serializer=com_dot_digitalasset_dot_canton_dot_pruning_dot_admin_dot_v0_dot_pruning__pb2.SetSchedule.Request.SerializeToString,
                response_deserializer=com_dot_digitalasset_dot_canton_dot_pruning_dot_admin_dot_v0_dot_pruning__pb2.SetSchedule.Response.FromString,
                )
        self.SetCron = channel.unary_unary(
                '/com.digitalasset.canton.participant.admin.v0.PruningService/SetCron',
                request_serializer=com_dot_digitalasset_dot_canton_dot_pruning_dot_admin_dot_v0_dot_pruning__pb2.SetCron.Request.SerializeToString,
                response_deserializer=com_dot_digitalasset_dot_canton_dot_pruning_dot_admin_dot_v0_dot_pruning__pb2.SetCron.Response.FromString,
                )
        self.SetMaxDuration = channel.unary_unary(
                '/com.digitalasset.canton.participant.admin.v0.PruningService/SetMaxDuration',
                request_serializer=com_dot_digitalasset_dot_canton_dot_pruning_dot_admin_dot_v0_dot_pruning__pb2.SetMaxDuration.Request.SerializeToString,
                response_deserializer=com_dot_digitalasset_dot_canton_dot_pruning_dot_admin_dot_v0_dot_pruning__pb2.SetMaxDuration.Response.FromString,
                )
        self.SetRetention = channel.unary_unary(
                '/com.digitalasset.canton.participant.admin.v0.PruningService/SetRetention',
                request_serializer=com_dot_digitalasset_dot_canton_dot_pruning_dot_admin_dot_v0_dot_pruning__pb2.SetRetention.Request.SerializeToString,
                response_deserializer=com_dot_digitalasset_dot_canton_dot_pruning_dot_admin_dot_v0_dot_pruning__pb2.SetRetention.Response.FromString,
                )
        self.ClearSchedule = channel.unary_unary(
                '/com.digitalasset.canton.participant.admin.v0.PruningService/ClearSchedule',
                request_serializer=com_dot_digitalasset_dot_canton_dot_pruning_dot_admin_dot_v0_dot_pruning__pb2.ClearSchedule.Request.SerializeToString,
                response_deserializer=com_dot_digitalasset_dot_canton_dot_pruning_dot_admin_dot_v0_dot_pruning__pb2.ClearSchedule.Response.FromString,
                )
        self.GetSchedule = channel.unary_unary(
                '/com.digitalasset.canton.participant.admin.v0.PruningService/GetSchedule',
                request_serializer=com_dot_digitalasset_dot_canton_dot_pruning_dot_admin_dot_v0_dot_pruning__pb2.GetSchedule.Request.SerializeToString,
                response_deserializer=com_dot_digitalasset_dot_canton_dot_pruning_dot_admin_dot_v0_dot_pruning__pb2.GetSchedule.Response.FromString,
                )


class PruningServiceServicer(object):
    """Canton-internal pruning service that prunes only canton state, but leaves the ledger-api
    state unpruned.
    """

    def Prune(self, request, context):
        """Prune the participant specifying the offset before and at which ledger transactions
        should be removed. Only returns when the potentially long-running prune request ends
        successfully or with one of the following errors:
        - ``INVALID_ARGUMENT``: if the payload, particularly the offset is malformed or missing
        - ``INTERNAL``: if the participant has encountered a failure and has potentially
        applied pruning partially. Such cases warrant verifying the participant health before
        retrying the prune with the same (or a larger, valid) offset. Successful retries
        after such errors ensure that different components reach a consistent pruning state.
        - ``FAILED_PRECONDITION``: if the participant is not yet able to prune at the specified
        offset or if pruning is invoked on a participant running the Community Edition.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def GetSafePruningOffset(self, request, context):
        """Retrieve the safe pruning offset
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def SetSchedule(self, request, context):
        """Enable automatic pruning using the specified schedule parameters
        The following errors may occur on the SetSchedule or Update commands:
        - ``INVALID_ARGUMENT``: if a parameter is missing or an invalid cron expression
        or duration.
        - ``FAILED_PRECONDITION``: if automatic background pruning has not been enabled
        or if invoked on a participant running the Community Edition.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def SetCron(self, request, context):
        """Modify individual pruning schedule parameters.
        - ``INVALID_ARGUMENT``: if the payload is malformed or no schedule is configured
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def SetMaxDuration(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 SetRetention(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 ClearSchedule(self, request, context):
        """Disable automatic pruning and remove the persisted schedule configuration.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def GetSchedule(self, request, context):
        """Retrieve the automatic pruning configuration.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')


def add_PruningServiceServicer_to_server(servicer, server):
    rpc_method_handlers = {
            'Prune': grpc.unary_unary_rpc_method_handler(
                    servicer.Prune,
                    request_deserializer=com_dot_digitalasset_dot_canton_dot_participant_dot_admin_dot_v0_dot_pruning__service__pb2.PruneRequest.FromString,
                    response_serializer=com_dot_digitalasset_dot_canton_dot_participant_dot_admin_dot_v0_dot_pruning__service__pb2.PruneResponse.SerializeToString,
            ),
            'GetSafePruningOffset': grpc.unary_unary_rpc_method_handler(
                    servicer.GetSafePruningOffset,
                    request_deserializer=com_dot_digitalasset_dot_canton_dot_participant_dot_admin_dot_v0_dot_pruning__service__pb2.GetSafePruningOffsetRequest.FromString,
                    response_serializer=com_dot_digitalasset_dot_canton_dot_participant_dot_admin_dot_v0_dot_pruning__service__pb2.GetSafePruningOffsetResponse.SerializeToString,
            ),
            'SetSchedule': grpc.unary_unary_rpc_method_handler(
                    servicer.SetSchedule,
                    request_deserializer=com_dot_digitalasset_dot_canton_dot_pruning_dot_admin_dot_v0_dot_pruning__pb2.SetSchedule.Request.FromString,
                    response_serializer=com_dot_digitalasset_dot_canton_dot_pruning_dot_admin_dot_v0_dot_pruning__pb2.SetSchedule.Response.SerializeToString,
            ),
            'SetCron': grpc.unary_unary_rpc_method_handler(
                    servicer.SetCron,
                    request_deserializer=com_dot_digitalasset_dot_canton_dot_pruning_dot_admin_dot_v0_dot_pruning__pb2.SetCron.Request.FromString,
                    response_serializer=com_dot_digitalasset_dot_canton_dot_pruning_dot_admin_dot_v0_dot_pruning__pb2.SetCron.Response.SerializeToString,
            ),
            'SetMaxDuration': grpc.unary_unary_rpc_method_handler(
                    servicer.SetMaxDuration,
                    request_deserializer=com_dot_digitalasset_dot_canton_dot_pruning_dot_admin_dot_v0_dot_pruning__pb2.SetMaxDuration.Request.FromString,
                    response_serializer=com_dot_digitalasset_dot_canton_dot_pruning_dot_admin_dot_v0_dot_pruning__pb2.SetMaxDuration.Response.SerializeToString,
            ),
            'SetRetention': grpc.unary_unary_rpc_method_handler(
                    servicer.SetRetention,
                    request_deserializer=com_dot_digitalasset_dot_canton_dot_pruning_dot_admin_dot_v0_dot_pruning__pb2.SetRetention.Request.FromString,
                    response_serializer=com_dot_digitalasset_dot_canton_dot_pruning_dot_admin_dot_v0_dot_pruning__pb2.SetRetention.Response.SerializeToString,
            ),
            'ClearSchedule': grpc.unary_unary_rpc_method_handler(
                    servicer.ClearSchedule,
                    request_deserializer=com_dot_digitalasset_dot_canton_dot_pruning_dot_admin_dot_v0_dot_pruning__pb2.ClearSchedule.Request.FromString,
                    response_serializer=com_dot_digitalasset_dot_canton_dot_pruning_dot_admin_dot_v0_dot_pruning__pb2.ClearSchedule.Response.SerializeToString,
            ),
            'GetSchedule': grpc.unary_unary_rpc_method_handler(
                    servicer.GetSchedule,
                    request_deserializer=com_dot_digitalasset_dot_canton_dot_pruning_dot_admin_dot_v0_dot_pruning__pb2.GetSchedule.Request.FromString,
                    response_serializer=com_dot_digitalasset_dot_canton_dot_pruning_dot_admin_dot_v0_dot_pruning__pb2.GetSchedule.Response.SerializeToString,
            ),
    }
    generic_handler = grpc.method_handlers_generic_handler(
            'com.digitalasset.canton.participant.admin.v0.PruningService', rpc_method_handlers)
    server.add_generic_rpc_handlers((generic_handler,))


 # This class is part of an EXPERIMENTAL API.
class PruningService(object):
    """Canton-internal pruning service that prunes only canton state, but leaves the ledger-api
    state unpruned.
    """

    @staticmethod
    def Prune(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, '/com.digitalasset.canton.participant.admin.v0.PruningService/Prune',
            com_dot_digitalasset_dot_canton_dot_participant_dot_admin_dot_v0_dot_pruning__service__pb2.PruneRequest.SerializeToString,
            com_dot_digitalasset_dot_canton_dot_participant_dot_admin_dot_v0_dot_pruning__service__pb2.PruneResponse.FromString,
            options, channel_credentials,
            insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

    @staticmethod
    def GetSafePruningOffset(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, '/com.digitalasset.canton.participant.admin.v0.PruningService/GetSafePruningOffset',
            com_dot_digitalasset_dot_canton_dot_participant_dot_admin_dot_v0_dot_pruning__service__pb2.GetSafePruningOffsetRequest.SerializeToString,
            com_dot_digitalasset_dot_canton_dot_participant_dot_admin_dot_v0_dot_pruning__service__pb2.GetSafePruningOffsetResponse.FromString,
            options, channel_credentials,
            insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

    @staticmethod
    def SetSchedule(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, '/com.digitalasset.canton.participant.admin.v0.PruningService/SetSchedule',
            com_dot_digitalasset_dot_canton_dot_pruning_dot_admin_dot_v0_dot_pruning__pb2.SetSchedule.Request.SerializeToString,
            com_dot_digitalasset_dot_canton_dot_pruning_dot_admin_dot_v0_dot_pruning__pb2.SetSchedule.Response.FromString,
            options, channel_credentials,
            insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

    @staticmethod
    def SetCron(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, '/com.digitalasset.canton.participant.admin.v0.PruningService/SetCron',
            com_dot_digitalasset_dot_canton_dot_pruning_dot_admin_dot_v0_dot_pruning__pb2.SetCron.Request.SerializeToString,
            com_dot_digitalasset_dot_canton_dot_pruning_dot_admin_dot_v0_dot_pruning__pb2.SetCron.Response.FromString,
            options, channel_credentials,
            insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

    @staticmethod
    def SetMaxDuration(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, '/com.digitalasset.canton.participant.admin.v0.PruningService/SetMaxDuration',
            com_dot_digitalasset_dot_canton_dot_pruning_dot_admin_dot_v0_dot_pruning__pb2.SetMaxDuration.Request.SerializeToString,
            com_dot_digitalasset_dot_canton_dot_pruning_dot_admin_dot_v0_dot_pruning__pb2.SetMaxDuration.Response.FromString,
            options, channel_credentials,
            insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

    @staticmethod
    def SetRetention(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, '/com.digitalasset.canton.participant.admin.v0.PruningService/SetRetention',
            com_dot_digitalasset_dot_canton_dot_pruning_dot_admin_dot_v0_dot_pruning__pb2.SetRetention.Request.SerializeToString,
            com_dot_digitalasset_dot_canton_dot_pruning_dot_admin_dot_v0_dot_pruning__pb2.SetRetention.Response.FromString,
            options, channel_credentials,
            insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

    @staticmethod
    def ClearSchedule(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, '/com.digitalasset.canton.participant.admin.v0.PruningService/ClearSchedule',
            com_dot_digitalasset_dot_canton_dot_pruning_dot_admin_dot_v0_dot_pruning__pb2.ClearSchedule.Request.SerializeToString,
            com_dot_digitalasset_dot_canton_dot_pruning_dot_admin_dot_v0_dot_pruning__pb2.ClearSchedule.Response.FromString,
            options, channel_credentials,
            insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

    @staticmethod
    def GetSchedule(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, '/com.digitalasset.canton.participant.admin.v0.PruningService/GetSchedule',
            com_dot_digitalasset_dot_canton_dot_pruning_dot_admin_dot_v0_dot_pruning__pb2.GetSchedule.Request.SerializeToString,
            com_dot_digitalasset_dot_canton_dot_pruning_dot_admin_dot_v0_dot_pruning__pb2.GetSchedule.Response.FromString,
            options, channel_credentials,
            insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
