// api/etcdserverpb/rpc.proto
syntax = "proto3";
package etcdserverpb;
import"google/api/annotations.proto";
import"api/mvccpb/kv.proto";
service KV {
// Range gets the keys in the range from the key-value store.rpc Range(RangeRequest) returns (RangeResponse) {}
// Put puts the given key into the key-value store.// A put request increments the revision of the key-value store// and generates one event in the event history.rpc Put(PutRequest) returns (PutResponse) {
option (google.api.http) = {
post: "/v3/kv/put"
body: "*"
};
}
}
message RangeRequest {
enum SortOrder {
NONE = 0; // default, no sorting
ASCEND = 1; // lowest target value first
DESCEND = 2; // highest target value first
}
enum SortTarget {
KEY = 0;
VERSION = 1;
CREATE = 2;
MOD = 3;
VALUE = 4;
}
bytes key = 1;
bytes range_end = 2;
int64 limit = 3;
int64 revision = 4;
SortOrder sort_order = 5;
SortTarget sort_target = 6;
bool serializable = 7;
bool keys_only = 8;
bool count_only = 9;
int64 min_mod_revision = 10;
int64 max_mod_revision = 11;
int64 min_create_revision = 12;
int64 max_create_revision = 13;
}
message RangeResponse {
ResponseHeader header = 1;
// kvs is the list of key-value pairs matched by the range request.// kvs is empty when count is requested.repeated mvccpb.KeyValue kvs = 2;
// more indicates if there are more keys to return in the requested range.bool more = 3;
// count is set to the number of keys within the range when requested.int64 count = 4;
}
message ResponseHeader {
// cluster_id is the ID of the cluster which sent the response.uint64 cluster_id = 1;
// member_id is the ID of the member which sent the response.uint64 member_id = 2;
// revision is the key-value store revision when the request was applied, and it's// unset (so 0) in case of calls not interacting with key-value store.// For watch progress responses, the header.revision indicates progress. All future events// received in this stream are guaranteed to have a higher revision number than the// header.revision number.int64 revision = 3;
// raft_term is the raft term when the request was applied.uint64 raft_term = 4;
}
message PutRequest {
// key is the key, in bytes, to put into the key-value store.bytes key = 1;
// value is the value, in bytes, to associate with the key in the key-value store.bytes value = 2;
// lease is the lease ID to associate with the key in the key-value store. A lease// value of 0 indicates no lease.int64 lease = 3;
// If prev_kv is set, etcd gets the previous key-value pair before changing it.// The previous key-value pair will be returned in the put response.bool prev_kv = 4;
// If ignore_value is set, etcd updates the key using its current value.// Returns an error if the key does not exist.bool ignore_value = 5;
// If ignore_lease is set, etcd updates the key using its current lease.// Returns an error if the key does not exist.bool ignore_lease = 6;
}
message PutResponse {
ResponseHeader header = 1;
// if prev_kv is set in the request, the previous key-value pair will be returned.
mvccpb.KeyValue prev_kv = 2;
}
proto
// api/mvccpb/kv.proto
syntax = "proto3";
package mvccpb;
message KeyValue {
// key is the key in bytes. An empty key is not allowed.bytes key = 1;
// create_revision is the revision of last creation on this key.int64 create_revision = 2;
// mod_revision is the revision of last modification on this key.int64 mod_revision = 3;
// version is the version of the key. A deletion resets// the version to zero and any modification of the key// increases its version.int64 version = 4;
// value is the value held by the key, in bytes.bytes value = 5;
// lease is the ID of the lease that attached to key.// When the attached lease expires, the key will be deleted.// If lease is 0, then no lease is attached to the key.int64 lease = 6;
}