rpc.proto 33 KB

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