#
# Copyright (c) 2021 Nitric Technologies Pty Ltd.
#
# This file is part of Nitric Python 3 SDK.
# See https://github.com/nitrictech/python-sdk for further info.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

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

from nitric.proto.kv.v1 import kv_pb2 as kv_dot_v1_dot_kv__pb2


class KeyValueStub(object):
    """Service for storage and retrieval of simple JSON keyValue
    """

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

        Args:
            channel: A grpc.Channel.
        """
        self.Get = channel.unary_unary(
                '/nitric.kv.v1.KeyValue/Get',
                request_serializer=kv_dot_v1_dot_kv__pb2.KeyValueGetRequest.SerializeToString,
                response_deserializer=kv_dot_v1_dot_kv__pb2.KeyValueGetResponse.FromString,
                )
        self.Put = channel.unary_unary(
                '/nitric.kv.v1.KeyValue/Put',
                request_serializer=kv_dot_v1_dot_kv__pb2.KeyValuePutRequest.SerializeToString,
                response_deserializer=kv_dot_v1_dot_kv__pb2.KeyValuePutResponse.FromString,
                )
        self.Delete = channel.unary_unary(
                '/nitric.kv.v1.KeyValue/Delete',
                request_serializer=kv_dot_v1_dot_kv__pb2.KeyValueDeleteRequest.SerializeToString,
                response_deserializer=kv_dot_v1_dot_kv__pb2.KeyValueDeleteResponse.FromString,
                )


class KeyValueServicer(object):
    """Service for storage and retrieval of simple JSON keyValue
    """

    def Get(self, request, context):
        """Get an existing key
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def Put(self, request, context):
        """Create a new or overwrite and existing key
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

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


def add_KeyValueServicer_to_server(servicer, server):
    rpc_method_handlers = {
            'Get': grpc.unary_unary_rpc_method_handler(
                    servicer.Get,
                    request_deserializer=kv_dot_v1_dot_kv__pb2.KeyValueGetRequest.FromString,
                    response_serializer=kv_dot_v1_dot_kv__pb2.KeyValueGetResponse.SerializeToString,
            ),
            'Put': grpc.unary_unary_rpc_method_handler(
                    servicer.Put,
                    request_deserializer=kv_dot_v1_dot_kv__pb2.KeyValuePutRequest.FromString,
                    response_serializer=kv_dot_v1_dot_kv__pb2.KeyValuePutResponse.SerializeToString,
            ),
            'Delete': grpc.unary_unary_rpc_method_handler(
                    servicer.Delete,
                    request_deserializer=kv_dot_v1_dot_kv__pb2.KeyValueDeleteRequest.FromString,
                    response_serializer=kv_dot_v1_dot_kv__pb2.KeyValueDeleteResponse.SerializeToString,
            ),
    }
    generic_handler = grpc.method_handlers_generic_handler(
            'nitric.kv.v1.KeyValue', rpc_method_handlers)
    server.add_generic_rpc_handlers((generic_handler,))


 # This class is part of an EXPERIMENTAL API.
class KeyValue(object):
    """Service for storage and retrieval of simple JSON keyValue
    """

    @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, '/nitric.kv.v1.KeyValue/Get',
            kv_dot_v1_dot_kv__pb2.KeyValueGetRequest.SerializeToString,
            kv_dot_v1_dot_kv__pb2.KeyValueGetResponse.FromString,
            options, channel_credentials,
            insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

    @staticmethod
    def Put(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, '/nitric.kv.v1.KeyValue/Put',
            kv_dot_v1_dot_kv__pb2.KeyValuePutRequest.SerializeToString,
            kv_dot_v1_dot_kv__pb2.KeyValuePutResponse.FromString,
            options, channel_credentials,
            insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

    @staticmethod
    def Delete(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, '/nitric.kv.v1.KeyValue/Delete',
            kv_dot_v1_dot_kv__pb2.KeyValueDeleteRequest.SerializeToString,
            kv_dot_v1_dot_kv__pb2.KeyValueDeleteResponse.FromString,
            options, channel_credentials,
            insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
