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

from ydb._grpc.v3.protos import ydb_operation_pb2 as protos_dot_ydb__operation__pb2
from ydb._grpc.v3.protos import ydb_query_pb2 as protos_dot_ydb__query__pb2


class QueryServiceStub(object):
    """Missing associated documentation comment in .proto file."""

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

        Args:
            channel: A grpc.Channel.
        """
        self.CreateSession = channel.unary_unary(
                '/Ydb.Query.V1.QueryService/CreateSession',
                request_serializer=protos_dot_ydb__query__pb2.CreateSessionRequest.SerializeToString,
                response_deserializer=protos_dot_ydb__query__pb2.CreateSessionResponse.FromString,
                )
        self.DeleteSession = channel.unary_unary(
                '/Ydb.Query.V1.QueryService/DeleteSession',
                request_serializer=protos_dot_ydb__query__pb2.DeleteSessionRequest.SerializeToString,
                response_deserializer=protos_dot_ydb__query__pb2.DeleteSessionResponse.FromString,
                )
        self.AttachSession = channel.unary_stream(
                '/Ydb.Query.V1.QueryService/AttachSession',
                request_serializer=protos_dot_ydb__query__pb2.AttachSessionRequest.SerializeToString,
                response_deserializer=protos_dot_ydb__query__pb2.SessionState.FromString,
                )
        self.BeginTransaction = channel.unary_unary(
                '/Ydb.Query.V1.QueryService/BeginTransaction',
                request_serializer=protos_dot_ydb__query__pb2.BeginTransactionRequest.SerializeToString,
                response_deserializer=protos_dot_ydb__query__pb2.BeginTransactionResponse.FromString,
                )
        self.CommitTransaction = channel.unary_unary(
                '/Ydb.Query.V1.QueryService/CommitTransaction',
                request_serializer=protos_dot_ydb__query__pb2.CommitTransactionRequest.SerializeToString,
                response_deserializer=protos_dot_ydb__query__pb2.CommitTransactionResponse.FromString,
                )
        self.RollbackTransaction = channel.unary_unary(
                '/Ydb.Query.V1.QueryService/RollbackTransaction',
                request_serializer=protos_dot_ydb__query__pb2.RollbackTransactionRequest.SerializeToString,
                response_deserializer=protos_dot_ydb__query__pb2.RollbackTransactionResponse.FromString,
                )
        self.ExecuteQuery = channel.unary_stream(
                '/Ydb.Query.V1.QueryService/ExecuteQuery',
                request_serializer=protos_dot_ydb__query__pb2.ExecuteQueryRequest.SerializeToString,
                response_deserializer=protos_dot_ydb__query__pb2.ExecuteQueryResponsePart.FromString,
                )
        self.ExecuteScript = channel.unary_unary(
                '/Ydb.Query.V1.QueryService/ExecuteScript',
                request_serializer=protos_dot_ydb__query__pb2.ExecuteScriptRequest.SerializeToString,
                response_deserializer=protos_dot_ydb__operation__pb2.Operation.FromString,
                )
        self.FetchScriptResults = channel.unary_unary(
                '/Ydb.Query.V1.QueryService/FetchScriptResults',
                request_serializer=protos_dot_ydb__query__pb2.FetchScriptResultsRequest.SerializeToString,
                response_deserializer=protos_dot_ydb__query__pb2.FetchScriptResultsResponse.FromString,
                )


class QueryServiceServicer(object):
    """Missing associated documentation comment in .proto file."""

    def CreateSession(self, request, context):
        """Sessions are basic primitives for communicating with YDB Query Service. The are similar to
        connections for classic relational DBs. Sessions serve three main purposes:
        1. Provide a flow control for DB requests with limited number of active channels.
        2. Distribute load evenly across multiple DB nodes.
        3. Store state for volatile stateful operations, such as short-living transactions.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def DeleteSession(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 AttachSession(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 BeginTransaction(self, request, context):
        """Short-living transactions allow transactional execution of several queries, including support
        for interactive transactions. Transaction control can be implemented via flags in ExecuteQuery
        call (recommended), or via explicit calls to Begin/Commit/RollbackTransaction.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def CommitTransaction(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 RollbackTransaction(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 ExecuteQuery(self, request, context):
        """Execute interactive query in a specified short-living transaction.
        YDB query can contain DML, DDL and DCL statements. Supported mix of different statement types depends
        on the chosen transaction type.
        In case of error, including transport errors such as interrupted stream, whole transaction
        needs to be retried. For non-idempotent transaction, a custom client logic is required to
        retry conditionally retriable statuses, when transaction execution state is unknown.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def ExecuteScript(self, request, context):
        """Execute long-running script.
        YDB scripts can contain all type of statements, including TCL statements. This way you can execute multiple
        transactions in a single YDB script.
        ExecuteScript call returns long-running Ydb.Operation object with:
        operation.metadata = ExecuteScriptMetadata
        operation.result = Empty
        Script execution metadata contains all information about current execution state, including
        execution_id, execution statistics and result sets info.
        You can use standard operation methods such as Get/Cancel/Forget/ListOperations to work with script executions.
        Script can be executed as persistent, in which case all execution information and results will be stored
        persistently and available after successful or unsuccessful execution.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def FetchScriptResults(self, request, context):
        """Fetch results for script execution using fetch_token for continuation.
        For script with multiple result sets, parts of different results sets are interleaved in responses.
        For persistent scripts, you can fetch results in specific position of specific result set using
        position instead of fetch_token.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')


def add_QueryServiceServicer_to_server(servicer, server):
    rpc_method_handlers = {
            'CreateSession': grpc.unary_unary_rpc_method_handler(
                    servicer.CreateSession,
                    request_deserializer=protos_dot_ydb__query__pb2.CreateSessionRequest.FromString,
                    response_serializer=protos_dot_ydb__query__pb2.CreateSessionResponse.SerializeToString,
            ),
            'DeleteSession': grpc.unary_unary_rpc_method_handler(
                    servicer.DeleteSession,
                    request_deserializer=protos_dot_ydb__query__pb2.DeleteSessionRequest.FromString,
                    response_serializer=protos_dot_ydb__query__pb2.DeleteSessionResponse.SerializeToString,
            ),
            'AttachSession': grpc.unary_stream_rpc_method_handler(
                    servicer.AttachSession,
                    request_deserializer=protos_dot_ydb__query__pb2.AttachSessionRequest.FromString,
                    response_serializer=protos_dot_ydb__query__pb2.SessionState.SerializeToString,
            ),
            'BeginTransaction': grpc.unary_unary_rpc_method_handler(
                    servicer.BeginTransaction,
                    request_deserializer=protos_dot_ydb__query__pb2.BeginTransactionRequest.FromString,
                    response_serializer=protos_dot_ydb__query__pb2.BeginTransactionResponse.SerializeToString,
            ),
            'CommitTransaction': grpc.unary_unary_rpc_method_handler(
                    servicer.CommitTransaction,
                    request_deserializer=protos_dot_ydb__query__pb2.CommitTransactionRequest.FromString,
                    response_serializer=protos_dot_ydb__query__pb2.CommitTransactionResponse.SerializeToString,
            ),
            'RollbackTransaction': grpc.unary_unary_rpc_method_handler(
                    servicer.RollbackTransaction,
                    request_deserializer=protos_dot_ydb__query__pb2.RollbackTransactionRequest.FromString,
                    response_serializer=protos_dot_ydb__query__pb2.RollbackTransactionResponse.SerializeToString,
            ),
            'ExecuteQuery': grpc.unary_stream_rpc_method_handler(
                    servicer.ExecuteQuery,
                    request_deserializer=protos_dot_ydb__query__pb2.ExecuteQueryRequest.FromString,
                    response_serializer=protos_dot_ydb__query__pb2.ExecuteQueryResponsePart.SerializeToString,
            ),
            'ExecuteScript': grpc.unary_unary_rpc_method_handler(
                    servicer.ExecuteScript,
                    request_deserializer=protos_dot_ydb__query__pb2.ExecuteScriptRequest.FromString,
                    response_serializer=protos_dot_ydb__operation__pb2.Operation.SerializeToString,
            ),
            'FetchScriptResults': grpc.unary_unary_rpc_method_handler(
                    servicer.FetchScriptResults,
                    request_deserializer=protos_dot_ydb__query__pb2.FetchScriptResultsRequest.FromString,
                    response_serializer=protos_dot_ydb__query__pb2.FetchScriptResultsResponse.SerializeToString,
            ),
    }
    generic_handler = grpc.method_handlers_generic_handler(
            'Ydb.Query.V1.QueryService', rpc_method_handlers)
    server.add_generic_rpc_handlers((generic_handler,))


 # This class is part of an EXPERIMENTAL API.
class QueryService(object):
    """Missing associated documentation comment in .proto file."""

    @staticmethod
    def CreateSession(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, '/Ydb.Query.V1.QueryService/CreateSession',
            protos_dot_ydb__query__pb2.CreateSessionRequest.SerializeToString,
            protos_dot_ydb__query__pb2.CreateSessionResponse.FromString,
            options, channel_credentials,
            insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

    @staticmethod
    def DeleteSession(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, '/Ydb.Query.V1.QueryService/DeleteSession',
            protos_dot_ydb__query__pb2.DeleteSessionRequest.SerializeToString,
            protos_dot_ydb__query__pb2.DeleteSessionResponse.FromString,
            options, channel_credentials,
            insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

    @staticmethod
    def AttachSession(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, '/Ydb.Query.V1.QueryService/AttachSession',
            protos_dot_ydb__query__pb2.AttachSessionRequest.SerializeToString,
            protos_dot_ydb__query__pb2.SessionState.FromString,
            options, channel_credentials,
            insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

    @staticmethod
    def BeginTransaction(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, '/Ydb.Query.V1.QueryService/BeginTransaction',
            protos_dot_ydb__query__pb2.BeginTransactionRequest.SerializeToString,
            protos_dot_ydb__query__pb2.BeginTransactionResponse.FromString,
            options, channel_credentials,
            insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

    @staticmethod
    def CommitTransaction(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, '/Ydb.Query.V1.QueryService/CommitTransaction',
            protos_dot_ydb__query__pb2.CommitTransactionRequest.SerializeToString,
            protos_dot_ydb__query__pb2.CommitTransactionResponse.FromString,
            options, channel_credentials,
            insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

    @staticmethod
    def RollbackTransaction(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, '/Ydb.Query.V1.QueryService/RollbackTransaction',
            protos_dot_ydb__query__pb2.RollbackTransactionRequest.SerializeToString,
            protos_dot_ydb__query__pb2.RollbackTransactionResponse.FromString,
            options, channel_credentials,
            insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

    @staticmethod
    def ExecuteQuery(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, '/Ydb.Query.V1.QueryService/ExecuteQuery',
            protos_dot_ydb__query__pb2.ExecuteQueryRequest.SerializeToString,
            protos_dot_ydb__query__pb2.ExecuteQueryResponsePart.FromString,
            options, channel_credentials,
            insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

    @staticmethod
    def ExecuteScript(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, '/Ydb.Query.V1.QueryService/ExecuteScript',
            protos_dot_ydb__query__pb2.ExecuteScriptRequest.SerializeToString,
            protos_dot_ydb__operation__pb2.Operation.FromString,
            options, channel_credentials,
            insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

    @staticmethod
    def FetchScriptResults(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, '/Ydb.Query.V1.QueryService/FetchScriptResults',
            protos_dot_ydb__query__pb2.FetchScriptResultsRequest.SerializeToString,
            protos_dot_ydb__query__pb2.FetchScriptResultsResponse.FromString,
            options, channel_credentials,
            insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
