rpc.proto 30 KB

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