rpc.proto 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914
  1. syntax = "proto3";
  2. package etcdserverpb;
  3. import "gogoproto/gogo.proto";
  4. import "etcd/mvcc/mvccpb/kv.proto";
  5. import "etcd/auth/authpb/auth.proto";
  6. // for grpc-gateway
  7. import "google/api/annotations.proto";
  8. option (gogoproto.marshaler_all) = true;
  9. option (gogoproto.unmarshaler_all) = true;
  10. service KV {
  11. // Range gets the keys in the range from the key-value store.
  12. rpc Range(RangeRequest) returns (RangeResponse) {
  13. option (google.api.http) = {
  14. post: "/v3alpha/kv/range"
  15. body: "*"
  16. };
  17. }
  18. // Put puts the given key into the key-value store.
  19. // A put request increments the revision of the key-value store
  20. // and generates one event in the event history.
  21. rpc Put(PutRequest) returns (PutResponse) {
  22. option (google.api.http) = {
  23. post: "/v3alpha/kv/put"
  24. body: "*"
  25. };
  26. }
  27. // DeleteRange deletes the given range from the key-value store.
  28. // A delete request increments the revision of the key-value store
  29. // and generates a delete event in the event history for every deleted key.
  30. rpc DeleteRange(DeleteRangeRequest) returns (DeleteRangeResponse) {}
  31. // Txn processes multiple requests in a single transaction.
  32. // A txn request increments the revision of the key-value store
  33. // and generates events with the same revision for every completed request.
  34. // It is not allowed to modify the same key several times within one txn.
  35. rpc Txn(TxnRequest) returns (TxnResponse) {
  36. option (google.api.http) = {
  37. post: "/v3alpha/kv/txn"
  38. body: "*"
  39. };
  40. }
  41. // Compact compacts the event history in the etcd key-value store. The key-value
  42. // store should be periodically compacted or the event history will continue to grow
  43. // indefinitely.
  44. rpc Compact(CompactionRequest) returns (CompactionResponse) {
  45. option (google.api.http) = {
  46. post: "/v3alpha/kv/compaction"
  47. body: "*"
  48. };
  49. }
  50. }
  51. service Watch {
  52. // Watch watches for events happening or that have happened. Both input and output
  53. // are streams; the input stream is for creating and canceling watchers and the output
  54. // stream sends events. One watch RPC can watch on multiple key ranges, streaming events
  55. // for several watches at once. The entire event history can be watched starting from the
  56. // last compaction revision.
  57. rpc Watch(stream WatchRequest) returns (stream WatchResponse) {
  58. option (google.api.http) = {
  59. post: "/v3alpha/watch"
  60. body: "*"
  61. };
  62. }
  63. }
  64. service Lease {
  65. // LeaseGrant creates a lease which expires if the server does not receive a keepAlive
  66. // within a given time to live period. All keys attached to the lease will be expired and
  67. // deleted if the lease expires. Each expired key generates a delete event in the event history.
  68. rpc LeaseGrant(LeaseGrantRequest) returns (LeaseGrantResponse) {
  69. option (google.api.http) = {
  70. post: "/v3alpha/lease/grant"
  71. body: "*"
  72. };
  73. }
  74. // LeaseRevoke revokes a lease. All keys attached to the lease will expire and be deleted.
  75. rpc LeaseRevoke(LeaseRevokeRequest) returns (LeaseRevokeResponse) {
  76. option (google.api.http) = {
  77. post: "/v3alpha/kv/lease/revoke"
  78. body: "*"
  79. };
  80. }
  81. // LeaseKeepAlive keeps the lease alive by streaming keep alive requests from the client
  82. // to the server and streaming keep alive responses from the server to the client.
  83. rpc LeaseKeepAlive(stream LeaseKeepAliveRequest) returns (stream LeaseKeepAliveResponse) {
  84. option (google.api.http) = {
  85. post: "/v3alpha/lease/keepalive"
  86. body: "*"
  87. };
  88. }
  89. // TODO(xiangli) List all existing Leases?
  90. // TODO(xiangli) Get details information (expirations, leased keys, etc.) of a lease?
  91. }
  92. service Cluster {
  93. // MemberAdd adds a member into the cluster.
  94. rpc MemberAdd(MemberAddRequest) returns (MemberAddResponse) {
  95. option (google.api.http) = {
  96. post: "/v3alpha/cluster/member/add"
  97. body: "*"
  98. };
  99. }
  100. // MemberRemove removes an existing member from the cluster.
  101. rpc MemberRemove(MemberRemoveRequest) returns (MemberRemoveResponse) {
  102. option (google.api.http) = {
  103. post: "/v3alpha/cluster/member/remove"
  104. body: "*"
  105. };
  106. }
  107. // MemberUpdate updates the member configuration.
  108. rpc MemberUpdate(MemberUpdateRequest) returns (MemberUpdateResponse) {
  109. option (google.api.http) = {
  110. post: "/v3alpha/cluster/member/update"
  111. body: "*"
  112. };
  113. }
  114. // MemberList lists all the members in the cluster.
  115. rpc MemberList(MemberListRequest) returns (MemberListResponse) {
  116. option (google.api.http) = {
  117. post: "/v3alpha/cluster/member/list"
  118. body: "*"
  119. };
  120. }
  121. }
  122. service Maintenance {
  123. // Alarm activates, deactivates, and queries alarms regarding cluster health.
  124. rpc Alarm(AlarmRequest) returns (AlarmResponse) {
  125. option (google.api.http) = {
  126. post: "/v3alpha/maintenance/alarm"
  127. body: "*"
  128. };
  129. }
  130. // Status gets the status of the member.
  131. rpc Status(StatusRequest) returns (StatusResponse) {
  132. option (google.api.http) = {
  133. post: "/v3alpha/maintenance/status"
  134. body: "*"
  135. };
  136. }
  137. // Defragment defragments a member's backend database to recover storage space.
  138. rpc Defragment(DefragmentRequest) returns (DefragmentResponse) {
  139. option (google.api.http) = {
  140. post: "/v3alpha/maintenance/defragment"
  141. body: "*"
  142. };
  143. }
  144. // Hash returns the hash of the local KV state for consistency checking purpose.
  145. // This is designed for testing; do not use this in production when there
  146. // are ongoing transactions.
  147. rpc Hash(HashRequest) returns (HashResponse) {
  148. option (google.api.http) = {
  149. post: "/v3alpha/maintenance/hash"
  150. body: "*"
  151. };
  152. }
  153. // Snapshot sends a snapshot of the entire backend from a member over a stream to a client.
  154. rpc Snapshot(SnapshotRequest) returns (stream SnapshotResponse) {
  155. option (google.api.http) = {
  156. post: "/v3alpha/maintenance/snapshot"
  157. body: "*"
  158. };
  159. }
  160. }
  161. service Auth {
  162. // AuthEnable enables authentication.
  163. rpc AuthEnable(AuthEnableRequest) returns (AuthEnableResponse) {
  164. option (google.api.http) = {
  165. post: "/v3alpha/auth/enable"
  166. body: "*"
  167. };
  168. }
  169. // AuthDisable disables authentication.
  170. rpc AuthDisable(AuthDisableRequest) returns (AuthDisableResponse) {
  171. option (google.api.http) = {
  172. post: "/v3alpha/auth/disable"
  173. body: "*"
  174. };
  175. }
  176. // Authenticate processes an authenticate request.
  177. rpc Authenticate(AuthenticateRequest) returns (AuthenticateResponse) {
  178. option (google.api.http) = {
  179. post: "/v3alpha/auth/authenticate"
  180. body: "*"
  181. };
  182. }
  183. // UserAdd adds a new user.
  184. rpc UserAdd(AuthUserAddRequest) returns (AuthUserAddResponse) {
  185. option (google.api.http) = {
  186. post: "/v3alpha/auth/user/add"
  187. body: "*"
  188. };
  189. }
  190. // UserGet gets detailed user information.
  191. rpc UserGet(AuthUserGetRequest) returns (AuthUserGetResponse) {
  192. option (google.api.http) = {
  193. post: "/v3alpha/auth/user/get"
  194. body: "*"
  195. };
  196. }
  197. // UserList gets a list of all users.
  198. rpc UserList(AuthUserListRequest) returns (AuthUserListResponse) {
  199. option (google.api.http) = {
  200. post: "/v3alpha/auth/user/list"
  201. body: "*"
  202. };
  203. }
  204. // UserDelete deletes a specified user.
  205. rpc UserDelete(AuthUserDeleteRequest) returns (AuthUserDeleteResponse) {
  206. option (google.api.http) = {
  207. post: "/v3alpha/auth/user/delete"
  208. body: "*"
  209. };
  210. }
  211. // UserChangePassword changes the password of a specified user.
  212. rpc UserChangePassword(AuthUserChangePasswordRequest) returns (AuthUserChangePasswordResponse) {
  213. option (google.api.http) = {
  214. post: "/v3alpha/auth/user/changepw"
  215. body: "*"
  216. };
  217. }
  218. // UserGrant grants a role to a specified user.
  219. rpc UserGrantRole(AuthUserGrantRoleRequest) returns (AuthUserGrantRoleResponse) {
  220. option (google.api.http) = {
  221. post: "/v3alpha/auth/user/grant"
  222. body: "*"
  223. };
  224. }
  225. // UserRevokeRole revokes a role of specified user.
  226. rpc UserRevokeRole(AuthUserRevokeRoleRequest) returns (AuthUserRevokeRoleResponse) {
  227. option (google.api.http) = {
  228. post: "/v3alpha/auth/user/revoke"
  229. body: "*"
  230. };
  231. }
  232. // RoleAdd adds a new role.
  233. rpc RoleAdd(AuthRoleAddRequest) returns (AuthRoleAddResponse) {
  234. option (google.api.http) = {
  235. post: "/v3alpha/auth/role/add"
  236. body: "*"
  237. };
  238. }
  239. // RoleGet gets detailed role information.
  240. rpc RoleGet(AuthRoleGetRequest) returns (AuthRoleGetResponse) {
  241. option (google.api.http) = {
  242. post: "/v3alpha/auth/role/get"
  243. body: "*"
  244. };
  245. }
  246. // RoleList gets lists of all roles.
  247. rpc RoleList(AuthRoleListRequest) returns (AuthRoleListResponse) {
  248. option (google.api.http) = {
  249. post: "/v3alpha/auth/role/list"
  250. body: "*"
  251. };
  252. }
  253. // RoleDelete deletes a specified role.
  254. rpc RoleDelete(AuthRoleDeleteRequest) returns (AuthRoleDeleteResponse) {
  255. option (google.api.http) = {
  256. post: "/v3alpha/auth/role/delete"
  257. body: "*"
  258. };
  259. }
  260. // RoleGrantPermission grants a permission of a specified key or range to a specified role.
  261. rpc RoleGrantPermission(AuthRoleGrantPermissionRequest) returns (AuthRoleGrantPermissionResponse) {
  262. option (google.api.http) = {
  263. post: "/v3alpha/auth/role/grant"
  264. body: "*"
  265. };
  266. }
  267. // RoleRevokePermission revokes a key or range permission of a specified role.
  268. rpc RoleRevokePermission(AuthRoleRevokePermissionRequest) returns (AuthRoleRevokePermissionResponse) {
  269. option (google.api.http) = {
  270. post: "/v3alpha/auth/role/revoke"
  271. body: "*"
  272. };
  273. }
  274. }
  275. message ResponseHeader {
  276. // cluster_id is the ID of the cluster which sent the response.
  277. uint64 cluster_id = 1;
  278. // member_id is the ID of the member which sent the response.
  279. uint64 member_id = 2;
  280. // revision is the key-value store revision when the request was applied.
  281. int64 revision = 3;
  282. // raft_term is the raft term when the request was applied.
  283. uint64 raft_term = 4;
  284. }
  285. message RangeRequest {
  286. enum SortOrder {
  287. NONE = 0; // default, no sorting
  288. ASCEND = 1; // lowest target value first
  289. DESCEND = 2; // highest target value first
  290. }
  291. enum SortTarget {
  292. KEY = 0;
  293. VERSION = 1;
  294. CREATE = 2;
  295. MOD = 3;
  296. VALUE = 4;
  297. }
  298. // key is the first key for the range. If range_end is not given, the request only looks up key.
  299. bytes key = 1;
  300. // range_end is the upper bound on the requested range [key, range_end).
  301. // If range_end is '\0', the range is all keys >= key.
  302. // If the range_end is one bit larger than the given key,
  303. // then the range requests get the all keys with the prefix (the given key).
  304. // If both key and range_end are '\0', then range requests returns all keys.
  305. bytes range_end = 2;
  306. // limit is a limit on the number of keys returned for the request.
  307. int64 limit = 3;
  308. // revision is the point-in-time of the key-value store to use for the range.
  309. // If revision is less or equal to zero, the range is over the newest key-value store.
  310. // If the revision has been compacted, ErrCompacted is returned as a response.
  311. int64 revision = 4;
  312. // sort_order is the order for returned sorted results.
  313. SortOrder sort_order = 5;
  314. // sort_target is the key-value field to use for sorting.
  315. SortTarget sort_target = 6;
  316. // serializable sets the range request to use serializable member-local reads.
  317. // Range requests are linearizable by default; linearizable requests have higher
  318. // latency and lower throughput than serializable requests but reflect the current
  319. // consensus of the cluster. For better performance, in exchange for possible stale reads,
  320. // a serializable range request is served locally without needing to reach consensus
  321. // with other nodes in the cluster.
  322. bool serializable = 7;
  323. // keys_only when set returns only the keys and not the values.
  324. bool keys_only = 8;
  325. // count_only when set returns only the count of the keys in the range.
  326. bool count_only = 9;
  327. }
  328. message RangeResponse {
  329. ResponseHeader header = 1;
  330. // kvs is the list of key-value pairs matched by the range request.
  331. // kvs is empty when count is requested.
  332. repeated mvccpb.KeyValue kvs = 2;
  333. // more indicates if there are more keys to return in the requested range.
  334. bool more = 3;
  335. // count is set to the number of keys within the range when requested.
  336. int64 count = 4;
  337. }
  338. message PutRequest {
  339. // key is the key, in bytes, to put into the key-value store.
  340. bytes key = 1;
  341. // value is the value, in bytes, to associate with the key in the key-value store.
  342. bytes value = 2;
  343. // lease is the lease ID to associate with the key in the key-value store. A lease
  344. // value of 0 indicates no lease.
  345. int64 lease = 3;
  346. // If prev_kv is set, etcd gets the previous key-value pair before changing it.
  347. // The previous key-value pair will be returned in the put response.
  348. bool prev_kv = 4;
  349. }
  350. message PutResponse {
  351. ResponseHeader header = 1;
  352. // if prev_kv is set in the request, the previous key-value pair will be returned.
  353. mvccpb.KeyValue prev_kv = 2;
  354. }
  355. message DeleteRangeRequest {
  356. // key is the first key to delete in the range.
  357. bytes key = 1;
  358. // range_end is the key following the last key to delete for the range [key, range_end).
  359. // If range_end is not given, the range is defined to contain only the key argument.
  360. // If range_end is '\0', the range is all keys greater than or equal to the key argument.
  361. bytes range_end = 2;
  362. // If prev_kv is set, etcd gets the previous key-value pairs before deleting it.
  363. // The previous key-value pairs will be returned in the delte response.
  364. bool prev_kv = 3;
  365. }
  366. message DeleteRangeResponse {
  367. ResponseHeader header = 1;
  368. // deleted is the number of keys deleted by the delete range request.
  369. int64 deleted = 2;
  370. // if prev_kv is set in the request, the previous key-value pairs will be returned.
  371. repeated mvccpb.KeyValue prev_kvs = 3;
  372. }
  373. message RequestOp {
  374. // request is a union of request types accepted by a transaction.
  375. oneof request {
  376. RangeRequest request_range = 1;
  377. PutRequest request_put = 2;
  378. DeleteRangeRequest request_delete_range = 3;
  379. }
  380. }
  381. message ResponseOp {
  382. // response is a union of response types returned by a transaction.
  383. oneof response {
  384. RangeResponse response_range = 1;
  385. PutResponse response_put = 2;
  386. DeleteRangeResponse response_delete_range = 3;
  387. }
  388. }
  389. message Compare {
  390. enum CompareResult {
  391. EQUAL = 0;
  392. GREATER = 1;
  393. LESS = 2;
  394. }
  395. enum CompareTarget {
  396. VERSION = 0;
  397. CREATE = 1;
  398. MOD = 2;
  399. VALUE= 3;
  400. }
  401. // result is logical comparison operation for this comparison.
  402. CompareResult result = 1;
  403. // target is the key-value field to inspect for the comparison.
  404. CompareTarget target = 2;
  405. // key is the subject key for the comparison operation.
  406. bytes key = 3;
  407. oneof target_union {
  408. // version is the version of the given key
  409. int64 version = 4;
  410. // create_revision is the creation revision of the given key
  411. int64 create_revision = 5;
  412. // mod_revision is the last modified revision of the given key.
  413. int64 mod_revision = 6;
  414. // value is the value of the given key, in bytes.
  415. bytes value = 7;
  416. }
  417. }
  418. // From google paxosdb paper:
  419. // Our implementation hinges around a powerful primitive which we call MultiOp. All other database
  420. // operations except for iteration are implemented as a single call to MultiOp. A MultiOp is applied atomically
  421. // and consists of three components:
  422. // 1. A list of tests called guard. Each test in guard checks a single entry in the database. It may check
  423. // for the absence or presence of a value, or compare with a given value. Two different tests in the guard
  424. // may apply to the same or different entries in the database. All tests in the guard are applied and
  425. // MultiOp returns the results. If all tests are true, MultiOp executes t op (see item 2 below), otherwise
  426. // it executes f op (see item 3 below).
  427. // 2. A list of database operations called t op. Each operation in the list is either an insert, delete, or
  428. // lookup operation, and applies to a single database entry. Two different operations in the list may apply
  429. // to the same or different entries in the database. These operations are executed
  430. // if guard evaluates to
  431. // true.
  432. // 3. A list of database operations called f op. Like t op, but executed if guard evaluates to false.
  433. message TxnRequest {
  434. // compare is a list of predicates representing a conjunction of terms.
  435. // If the comparisons succeed, then the success requests will be processed in order,
  436. // and the response will contain their respective responses in order.
  437. // If the comparisons fail, then the failure requests will be processed in order,
  438. // and the response will contain their respective responses in order.
  439. repeated Compare compare = 1;
  440. // success is a list of requests which will be applied when compare evaluates to true.
  441. repeated RequestOp success = 2;
  442. // failure is a list of requests which will be applied when compare evaluates to false.
  443. repeated RequestOp failure = 3;
  444. }
  445. message TxnResponse {
  446. ResponseHeader header = 1;
  447. // succeeded is set to true if the compare evaluated to true or false otherwise.
  448. bool succeeded = 2;
  449. // responses is a list of responses corresponding to the results from applying
  450. // success if succeeded is true or failure if succeeded is false.
  451. repeated ResponseOp responses = 3;
  452. }
  453. // CompactionRequest compacts the key-value store up to a given revision. All superseded keys
  454. // with a revision less than the compaction revision will be removed.
  455. message CompactionRequest {
  456. // revision is the key-value store revision for the compaction operation.
  457. int64 revision = 1;
  458. // physical is set so the RPC will wait until the compaction is physically
  459. // applied to the local database such that compacted entries are totally
  460. // removed from the backend database.
  461. bool physical = 2;
  462. }
  463. message CompactionResponse {
  464. ResponseHeader header = 1;
  465. }
  466. message HashRequest {
  467. }
  468. message HashResponse {
  469. ResponseHeader header = 1;
  470. // hash is the hash value computed from the responding member's key-value store.
  471. uint32 hash = 2;
  472. }
  473. message SnapshotRequest {
  474. }
  475. message SnapshotResponse {
  476. // header has the current key-value store information. The first header in the snapshot
  477. // stream indicates the point in time of the snapshot.
  478. ResponseHeader header = 1;
  479. // remaining_bytes is the number of blob bytes to be sent after this message
  480. uint64 remaining_bytes = 2;
  481. // blob contains the next chunk of the snapshot in the snapshot stream.
  482. bytes blob = 3;
  483. }
  484. message WatchRequest {
  485. // request_union is a request to either create a new watcher or cancel an existing watcher.
  486. oneof request_union {
  487. WatchCreateRequest create_request = 1;
  488. WatchCancelRequest cancel_request = 2;
  489. }
  490. }
  491. message WatchCreateRequest {
  492. // key is the key to register for watching.
  493. bytes key = 1;
  494. // range_end is the end of the range [key, range_end) to watch. If range_end is not given,
  495. // only the key argument is watched. If range_end is equal to '\0', all keys greater than
  496. // or equal to the key argument are watched.
  497. bytes range_end = 2;
  498. // start_revision is an optional revision to watch from (inclusive). No start_revision is "now".
  499. int64 start_revision = 3;
  500. // progress_notify is set so that the etcd server will periodically send a WatchResponse with
  501. // no events to the new watcher if there are no recent events. It is useful when clients
  502. // wish to recover a disconnected watcher starting from a recent known revision.
  503. // The etcd server may decide how often it will send notifications based on current load.
  504. bool progress_notify = 4;
  505. enum FilterType {
  506. // filter out put event.
  507. NOPUT = 0;
  508. // filter out delete event.
  509. NODELETE = 1;
  510. }
  511. // filters filter the events at server side before it sends back to the watcher.
  512. repeated FilterType filters = 5;
  513. // If prev_kv is set, created watcher gets the previous KV before the event happens.
  514. // If the previous KV is already compacted, nothing will be returned.
  515. bool prev_kv = 6;
  516. }
  517. message WatchCancelRequest {
  518. // watch_id is the watcher id to cancel so that no more events are transmitted.
  519. int64 watch_id = 1;
  520. }
  521. message WatchResponse {
  522. ResponseHeader header = 1;
  523. // watch_id is the ID of the watcher that corresponds to the response.
  524. int64 watch_id = 2;
  525. // created is set to true if the response is for a create watch request.
  526. // The client should record the watch_id and expect to receive events for
  527. // the created watcher from the same stream.
  528. // All events sent to the created watcher will attach with the same watch_id.
  529. bool created = 3;
  530. // canceled is set to true if the response is for a cancel watch request.
  531. // No further events will be sent to the canceled watcher.
  532. bool canceled = 4;
  533. // compact_revision is set to the minimum index if a watcher tries to watch
  534. // at a compacted index.
  535. //
  536. // This happens when creating a watcher at a compacted revision or the watcher cannot
  537. // catch up with the progress of the key-value store.
  538. //
  539. // The client should treat the watcher as canceled and should not try to create any
  540. // watcher with the same start_revision again.
  541. int64 compact_revision = 5;
  542. repeated mvccpb.Event events = 11;
  543. }
  544. message LeaseGrantRequest {
  545. // TTL is the advisory time-to-live in seconds.
  546. int64 TTL = 1;
  547. // ID is the requested ID for the lease. If ID is set to 0, the lessor chooses an ID.
  548. int64 ID = 2;
  549. }
  550. message LeaseGrantResponse {
  551. ResponseHeader header = 1;
  552. // ID is the lease ID for the granted lease.
  553. int64 ID = 2;
  554. // TTL is the server chosen lease time-to-live in seconds.
  555. int64 TTL = 3;
  556. string error = 4;
  557. }
  558. message LeaseRevokeRequest {
  559. // ID is the lease ID to revoke. When the ID is revoked, all associated keys will be deleted.
  560. int64 ID = 1;
  561. }
  562. message LeaseRevokeResponse {
  563. ResponseHeader header = 1;
  564. }
  565. message LeaseKeepAliveRequest {
  566. // ID is the lease ID for the lease to keep alive.
  567. int64 ID = 1;
  568. }
  569. message LeaseKeepAliveResponse {
  570. ResponseHeader header = 1;
  571. // ID is the lease ID from the keep alive request.
  572. int64 ID = 2;
  573. // TTL is the new time-to-live for the lease.
  574. int64 TTL = 3;
  575. }
  576. message Member {
  577. // ID is the member ID for this member.
  578. uint64 ID = 1;
  579. // name is the human-readable name of the member. If the member is not started, the name will be an empty string.
  580. string name = 2;
  581. // peerURLs is the list of URLs the member exposes to the cluster for communication.
  582. repeated string peerURLs = 3;
  583. // clientURLs is the list of URLs the member exposes to clients for communication. If the member is not started, clientURLs will be empty.
  584. repeated string clientURLs = 4;
  585. }
  586. message MemberAddRequest {
  587. // peerURLs is the list of URLs the added member will use to communicate with the cluster.
  588. repeated string peerURLs = 1;
  589. }
  590. message MemberAddResponse {
  591. ResponseHeader header = 1;
  592. // member is the member information for the added member.
  593. Member member = 2;
  594. }
  595. message MemberRemoveRequest {
  596. // ID is the member ID of the member to remove.
  597. uint64 ID = 1;
  598. }
  599. message MemberRemoveResponse {
  600. ResponseHeader header = 1;
  601. }
  602. message MemberUpdateRequest {
  603. // ID is the member ID of the member to update.
  604. uint64 ID = 1;
  605. // peerURLs is the new list of URLs the member will use to communicate with the cluster.
  606. repeated string peerURLs = 2;
  607. }
  608. message MemberUpdateResponse{
  609. ResponseHeader header = 1;
  610. }
  611. message MemberListRequest {
  612. }
  613. message MemberListResponse {
  614. ResponseHeader header = 1;
  615. // members is a list of all members associated with the cluster.
  616. repeated Member members = 2;
  617. }
  618. message DefragmentRequest {
  619. }
  620. message DefragmentResponse {
  621. ResponseHeader header = 1;
  622. }
  623. enum AlarmType {
  624. NONE = 0; // default, used to query if any alarm is active
  625. NOSPACE = 1; // space quota is exhausted
  626. }
  627. message AlarmRequest {
  628. enum AlarmAction {
  629. GET = 0;
  630. ACTIVATE = 1;
  631. DEACTIVATE = 2;
  632. }
  633. // action is the kind of alarm request to issue. The action
  634. // may GET alarm statuses, ACTIVATE an alarm, or DEACTIVATE a
  635. // raised alarm.
  636. AlarmAction action = 1;
  637. // memberID is the ID of the member associated with the alarm. If memberID is 0, the
  638. // alarm request covers all members.
  639. uint64 memberID = 2;
  640. // alarm is the type of alarm to consider for this request.
  641. AlarmType alarm = 3;
  642. }
  643. message AlarmMember {
  644. // memberID is the ID of the member associated with the raised alarm.
  645. uint64 memberID = 1;
  646. // alarm is the type of alarm which has been raised.
  647. AlarmType alarm = 2;
  648. }
  649. message AlarmResponse {
  650. ResponseHeader header = 1;
  651. // alarms is a list of alarms associated with the alarm request.
  652. repeated AlarmMember alarms = 2;
  653. }
  654. message StatusRequest {
  655. }
  656. message StatusResponse {
  657. ResponseHeader header = 1;
  658. // version is the cluster protocol version used by the responding member.
  659. string version = 2;
  660. // dbSize is the size of the backend database, in bytes, of the responding member.
  661. int64 dbSize = 3;
  662. // leader is the member ID which the responding member believes is the current leader.
  663. uint64 leader = 4;
  664. // raftIndex is the current raft index of the responding member.
  665. uint64 raftIndex = 5;
  666. // raftTerm is the current raft term of the responding member.
  667. uint64 raftTerm = 6;
  668. }
  669. message AuthEnableRequest {
  670. }
  671. message AuthDisableRequest {
  672. }
  673. message AuthenticateRequest {
  674. string name = 1;
  675. string password = 2;
  676. }
  677. message AuthUserAddRequest {
  678. string name = 1;
  679. string password = 2;
  680. }
  681. message AuthUserGetRequest {
  682. string name = 1;
  683. }
  684. message AuthUserDeleteRequest {
  685. // name is the name of the user to delete.
  686. string name = 1;
  687. }
  688. message AuthUserChangePasswordRequest {
  689. // name is the name of the user whose password is being changed.
  690. string name = 1;
  691. // password is the new password for the user.
  692. string password = 2;
  693. }
  694. message AuthUserGrantRoleRequest {
  695. // user is the name of the user which should be granted a given role.
  696. string user = 1;
  697. // role is the name of the role to grant to the user.
  698. string role = 2;
  699. }
  700. message AuthUserRevokeRoleRequest {
  701. string name = 1;
  702. string role = 2;
  703. }
  704. message AuthRoleAddRequest {
  705. // name is the name of the role to add to the authentication system.
  706. string name = 1;
  707. }
  708. message AuthRoleGetRequest {
  709. string role = 1;
  710. }
  711. message AuthUserListRequest {
  712. }
  713. message AuthRoleListRequest {
  714. }
  715. message AuthRoleDeleteRequest {
  716. string role = 1;
  717. }
  718. message AuthRoleGrantPermissionRequest {
  719. // name is the name of the role which will be granted the permission.
  720. string name = 1;
  721. // perm is the permission to grant to the role.
  722. authpb.Permission perm = 2;
  723. }
  724. message AuthRoleRevokePermissionRequest {
  725. string role = 1;
  726. string key = 2;
  727. string range_end = 3;
  728. }
  729. message AuthEnableResponse {
  730. ResponseHeader header = 1;
  731. }
  732. message AuthDisableResponse {
  733. ResponseHeader header = 1;
  734. }
  735. message AuthenticateResponse {
  736. ResponseHeader header = 1;
  737. // token is an authorized token that can be used in succeeding RPCs
  738. string token = 2;
  739. }
  740. message AuthUserAddResponse {
  741. ResponseHeader header = 1;
  742. }
  743. message AuthUserGetResponse {
  744. ResponseHeader header = 1;
  745. repeated string roles = 2;
  746. }
  747. message AuthUserDeleteResponse {
  748. ResponseHeader header = 1;
  749. }
  750. message AuthUserChangePasswordResponse {
  751. ResponseHeader header = 1;
  752. }
  753. message AuthUserGrantRoleResponse {
  754. ResponseHeader header = 1;
  755. }
  756. message AuthUserRevokeRoleResponse {
  757. ResponseHeader header = 1;
  758. }
  759. message AuthRoleAddResponse {
  760. ResponseHeader header = 1;
  761. }
  762. message AuthRoleGetResponse {
  763. ResponseHeader header = 1;
  764. repeated authpb.Permission perm = 2;
  765. }
  766. message AuthRoleListResponse {
  767. ResponseHeader header = 1;
  768. repeated string roles = 2;
  769. }
  770. message AuthUserListResponse {
  771. ResponseHeader header = 1;
  772. repeated string users = 2;
  773. }
  774. message AuthRoleDeleteResponse {
  775. ResponseHeader header = 1;
  776. }
  777. message AuthRoleGrantPermissionResponse {
  778. ResponseHeader header = 1;
  779. }
  780. message AuthRoleRevokePermissionResponse {
  781. ResponseHeader header = 1;
  782. }