/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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.
 */

syntax = "proto3";

package resdb;

message KVRequest {
    enum CMD {
        NONE = 0;
        SET = 1;
        GET = 2;
        GETALLVALUES = 3;
        GETRANGE = 4;
        SET_WITH_VERSION = 5;
        GET_WITH_VERSION = 6;
        GET_ALL_ITEMS = 7;
        GET_KEY_RANGE = 8;
        GET_HISTORY = 9;
        GET_TOP = 10;
    }
    CMD cmd = 1;
    string key = 2;
    bytes value = 3;
    int32 version = 4;
    // For get key range
    string min_key = 5;
    string max_key = 6;
    // For get history for a key
    int32 min_version = 7;
    int32 max_version = 8;
    // For top history
    int32 top_number = 9;
    bytes smart_contract_request = 10;
}

message ValueInfo {
  bytes value = 2;
  int32 version = 3;
}

message Item {
  string key = 1;
  ValueInfo value_info = 2;
}

message Items {
  repeated Item item = 1;
}

message KVResponse {
    string key = 1;
    bytes value = 2;
    ValueInfo value_info = 3;
    Items items = 4;
    bytes smart_contract_response = 10;
}

