rpc.proto 33 KB

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