From eec706b9ae6c80827a5390dac842a94df52beeaa Mon Sep 17 00:00:00 2001 From: Gyu-Ho Lee Date: Fri, 17 Jun 2016 15:04:07 -0700 Subject: [PATCH] etcdserverpb: generate Swagger API JSON --- .../apispec/swagger/rpc.swagger.json | 1275 +++++++++++++++++ scripts/genproto.sh | 13 +- 2 files changed, 1287 insertions(+), 1 deletion(-) create mode 100644 Documentation/dev-guide/apispec/swagger/rpc.swagger.json diff --git a/Documentation/dev-guide/apispec/swagger/rpc.swagger.json b/Documentation/dev-guide/apispec/swagger/rpc.swagger.json new file mode 100644 index 000000000..69be8da36 --- /dev/null +++ b/Documentation/dev-guide/apispec/swagger/rpc.swagger.json @@ -0,0 +1,1275 @@ +{ + "swagger": "2.0", + "info": { + "title": "etcdserver/etcdserverpb/rpc.proto", + "version": "version not set" + }, + "schemes": [ + "http", + "https" + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "paths": { + "/v3alpha/kv/compaction": { + "post": { + "summary": "Txn processes multiple requests in a single transaction.\nA txn request increments the revision of the key-value store\nand generates events with the same revision for every completed request.\nIt is not allowed to modify the same key several times within one txn.", + "operationId": "Compact", + "responses": { + "200": { + "description": "Description", + "schema": { + "$ref": "#/definitions/etcdserverpbCompactionResponse" + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/etcdserverpbCompactionRequest" + } + } + ], + "tags": [ + "KV" + ] + } + }, + "/v3alpha/kv/put": { + "post": { + "summary": "Put puts the given key into the key-value store.\nA put request increments the revision of the key-value store\nand generates one event in the event history.", + "operationId": "Put", + "responses": { + "200": { + "description": "Description", + "schema": { + "$ref": "#/definitions/etcdserverpbPutResponse" + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/etcdserverpbPutRequest" + } + } + ], + "tags": [ + "KV" + ] + } + }, + "/v3alpha/kv/range": { + "post": { + "summary": "Range gets the keys in the range from the key-value store.", + "operationId": "Range", + "responses": { + "200": { + "description": "Description", + "schema": { + "$ref": "#/definitions/etcdserverpbRangeResponse" + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/etcdserverpbRangeRequest" + } + } + ], + "tags": [ + "KV" + ] + } + }, + "/v3alpha/kv/txn": { + "post": { + "summary": "DeleteRange deletes the given range from the key-value store.\nA delete request increments the revision of the key-value store\nand generates a delete event in the event history for every deleted key.", + "operationId": "Txn", + "responses": { + "200": { + "description": "Description", + "schema": { + "$ref": "#/definitions/etcdserverpbTxnResponse" + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/etcdserverpbTxnRequest" + } + } + ], + "tags": [ + "KV" + ] + } + } + }, + "definitions": { + "AlarmRequestAlarmAction": { + "type": "string", + "enum": [ + "GET", + "ACTIVATE", + "DEACTIVATE" + ], + "default": "GET" + }, + "CompareCompareResult": { + "type": "string", + "enum": [ + "EQUAL", + "GREATER", + "LESS" + ], + "default": "EQUAL" + }, + "CompareCompareTarget": { + "type": "string", + "enum": [ + "VERSION", + "CREATE", + "MOD", + "VALUE" + ], + "default": "VERSION" + }, + "EventEventType": { + "type": "string", + "enum": [ + "PUT", + "DELETE" + ], + "default": "PUT" + }, + "RangeRequestSortOrder": { + "type": "string", + "enum": [ + "NONE", + "ASCEND", + "DESCEND" + ], + "default": "NONE" + }, + "RangeRequestSortTarget": { + "type": "string", + "enum": [ + "KEY", + "VERSION", + "CREATE", + "MOD", + "VALUE" + ], + "default": "KEY" + }, + "authpbPermission": { + "type": "object", + "properties": { + "key": { + "type": "string", + "format": "byte" + }, + "permType": { + "$ref": "#/definitions/authpbPermissionType" + }, + "range_end": { + "type": "string", + "format": "byte" + } + }, + "title": "Permission is a single entity" + }, + "authpbPermissionType": { + "type": "string", + "enum": [ + "READ", + "WRITE", + "READWRITE" + ], + "default": "READ" + }, + "etcdserverpbAlarmMember": { + "type": "object", + "properties": { + "alarm": { + "$ref": "#/definitions/etcdserverpbAlarmType", + "description": "alarm is the type of alarm which has been raised." + }, + "memberID": { + "type": "string", + "format": "uint64", + "description": "memberID is the ID of the member associated with the raised alarm." + } + } + }, + "etcdserverpbAlarmRequest": { + "type": "object", + "properties": { + "action": { + "$ref": "#/definitions/AlarmRequestAlarmAction", + "description": "action is the kind of alarm request to issue. The action\nmay GET alarm statuses, ACTIVATE an alarm, or DEACTIVATE a\nraised alarm." + }, + "alarm": { + "$ref": "#/definitions/etcdserverpbAlarmType", + "description": "alarm is the type of alarm to consider for this request." + }, + "memberID": { + "type": "string", + "format": "uint64", + "description": "memberID is the ID of the member associated with the alarm. If memberID is 0, the\nalarm request covers all members." + } + } + }, + "etcdserverpbAlarmResponse": { + "type": "object", + "properties": { + "alarms": { + "type": "array", + "items": { + "$ref": "#/definitions/etcdserverpbAlarmMember" + }, + "description": "alarms is a list of alarms associated with the alarm request." + }, + "header": { + "$ref": "#/definitions/etcdserverpbResponseHeader" + } + } + }, + "etcdserverpbAlarmType": { + "type": "string", + "enum": [ + "NONE", + "NOSPACE" + ], + "default": "NONE" + }, + "etcdserverpbAuthDisableRequest": { + "type": "object" + }, + "etcdserverpbAuthDisableResponse": { + "type": "object", + "properties": { + "header": { + "$ref": "#/definitions/etcdserverpbResponseHeader" + } + } + }, + "etcdserverpbAuthEnableRequest": { + "type": "object" + }, + "etcdserverpbAuthEnableResponse": { + "type": "object", + "properties": { + "header": { + "$ref": "#/definitions/etcdserverpbResponseHeader" + } + } + }, + "etcdserverpbAuthRoleAddRequest": { + "type": "object", + "properties": { + "name": { + "type": "string", + "format": "string", + "description": "name is the name of the role to add to the authentication system." + } + } + }, + "etcdserverpbAuthRoleAddResponse": { + "type": "object", + "properties": { + "header": { + "$ref": "#/definitions/etcdserverpbResponseHeader" + } + } + }, + "etcdserverpbAuthRoleDeleteRequest": { + "type": "object", + "properties": { + "role": { + "type": "string", + "format": "string" + } + } + }, + "etcdserverpbAuthRoleDeleteResponse": { + "type": "object", + "properties": { + "header": { + "$ref": "#/definitions/etcdserverpbResponseHeader" + } + } + }, + "etcdserverpbAuthRoleGetRequest": { + "type": "object", + "properties": { + "role": { + "type": "string", + "format": "string" + } + } + }, + "etcdserverpbAuthRoleGetResponse": { + "type": "object", + "properties": { + "header": { + "$ref": "#/definitions/etcdserverpbResponseHeader" + }, + "perm": { + "type": "array", + "items": { + "$ref": "#/definitions/authpbPermission" + } + } + } + }, + "etcdserverpbAuthRoleGrantPermissionRequest": { + "type": "object", + "properties": { + "name": { + "type": "string", + "format": "string", + "description": "name is the name of the role which will be granted the permission." + }, + "perm": { + "$ref": "#/definitions/authpbPermission", + "description": "perm is the permission to grant to the role." + } + } + }, + "etcdserverpbAuthRoleGrantPermissionResponse": { + "type": "object", + "properties": { + "header": { + "$ref": "#/definitions/etcdserverpbResponseHeader" + } + } + }, + "etcdserverpbAuthRoleListRequest": { + "type": "object" + }, + "etcdserverpbAuthRoleListResponse": { + "type": "object", + "properties": { + "header": { + "$ref": "#/definitions/etcdserverpbResponseHeader" + }, + "roles": { + "type": "array", + "items": { + "type": "string", + "format": "string" + } + } + } + }, + "etcdserverpbAuthRoleRevokePermissionRequest": { + "type": "object", + "properties": { + "key": { + "type": "string", + "format": "string" + }, + "range_end": { + "type": "string", + "format": "string" + }, + "role": { + "type": "string", + "format": "string" + } + } + }, + "etcdserverpbAuthRoleRevokePermissionResponse": { + "type": "object", + "properties": { + "header": { + "$ref": "#/definitions/etcdserverpbResponseHeader" + } + } + }, + "etcdserverpbAuthUserAddRequest": { + "type": "object", + "properties": { + "name": { + "type": "string", + "format": "string" + }, + "password": { + "type": "string", + "format": "string" + } + } + }, + "etcdserverpbAuthUserAddResponse": { + "type": "object", + "properties": { + "header": { + "$ref": "#/definitions/etcdserverpbResponseHeader" + } + } + }, + "etcdserverpbAuthUserChangePasswordRequest": { + "type": "object", + "properties": { + "name": { + "type": "string", + "format": "string", + "description": "name is the name of the user whose password is being changed." + }, + "password": { + "type": "string", + "format": "string", + "description": "password is the new password for the user." + } + } + }, + "etcdserverpbAuthUserChangePasswordResponse": { + "type": "object", + "properties": { + "header": { + "$ref": "#/definitions/etcdserverpbResponseHeader" + } + } + }, + "etcdserverpbAuthUserDeleteRequest": { + "type": "object", + "properties": { + "name": { + "type": "string", + "format": "string", + "description": "name is the name of the user to delete." + } + } + }, + "etcdserverpbAuthUserDeleteResponse": { + "type": "object", + "properties": { + "header": { + "$ref": "#/definitions/etcdserverpbResponseHeader" + } + } + }, + "etcdserverpbAuthUserGetRequest": { + "type": "object", + "properties": { + "name": { + "type": "string", + "format": "string" + } + } + }, + "etcdserverpbAuthUserGetResponse": { + "type": "object", + "properties": { + "header": { + "$ref": "#/definitions/etcdserverpbResponseHeader" + }, + "roles": { + "type": "array", + "items": { + "type": "string", + "format": "string" + } + } + } + }, + "etcdserverpbAuthUserGrantRoleRequest": { + "type": "object", + "properties": { + "role": { + "type": "string", + "format": "string", + "description": "role is the name of the role to grant to the user." + }, + "user": { + "type": "string", + "format": "string", + "description": "user is the name of the user which should be granted a given role." + } + } + }, + "etcdserverpbAuthUserGrantRoleResponse": { + "type": "object", + "properties": { + "header": { + "$ref": "#/definitions/etcdserverpbResponseHeader" + } + } + }, + "etcdserverpbAuthUserListRequest": { + "type": "object" + }, + "etcdserverpbAuthUserListResponse": { + "type": "object", + "properties": { + "header": { + "$ref": "#/definitions/etcdserverpbResponseHeader" + }, + "users": { + "type": "array", + "items": { + "type": "string", + "format": "string" + } + } + } + }, + "etcdserverpbAuthUserRevokeRoleRequest": { + "type": "object", + "properties": { + "name": { + "type": "string", + "format": "string" + }, + "role": { + "type": "string", + "format": "string" + } + } + }, + "etcdserverpbAuthUserRevokeRoleResponse": { + "type": "object", + "properties": { + "header": { + "$ref": "#/definitions/etcdserverpbResponseHeader" + } + } + }, + "etcdserverpbAuthenticateRequest": { + "type": "object", + "properties": { + "name": { + "type": "string", + "format": "string" + }, + "password": { + "type": "string", + "format": "string" + } + } + }, + "etcdserverpbAuthenticateResponse": { + "type": "object", + "properties": { + "header": { + "$ref": "#/definitions/etcdserverpbResponseHeader" + }, + "token": { + "type": "string", + "format": "string", + "title": "token is an authorized token that can be used in succeeding RPCs" + } + } + }, + "etcdserverpbCompactionRequest": { + "type": "object", + "properties": { + "physical": { + "type": "boolean", + "format": "boolean", + "description": "physical is set so the RPC will wait until the compaction is physically\napplied to the local database such that compacted entries are totally\nremoved from the backend database." + }, + "revision": { + "type": "string", + "format": "int64", + "description": "revision is the key-value store revision for the compaction operation." + } + }, + "description": "CompactionRequest compacts the key-value store up to a given revision. All superseded keys\nwith a revision less than the compaction revision will be removed." + }, + "etcdserverpbCompactionResponse": { + "type": "object", + "properties": { + "header": { + "$ref": "#/definitions/etcdserverpbResponseHeader" + } + } + }, + "etcdserverpbCompare": { + "type": "object", + "properties": { + "create_revision": { + "type": "string", + "format": "int64", + "title": "create_revision is the creation revision of the given key" + }, + "key": { + "type": "string", + "format": "byte", + "description": "key is the subject key for the comparison operation." + }, + "mod_revision": { + "type": "string", + "format": "int64", + "description": "mod_revision is the last modified revision of the given key." + }, + "result": { + "$ref": "#/definitions/CompareCompareResult", + "description": "result is logical comparison operation for this comparison." + }, + "target": { + "$ref": "#/definitions/CompareCompareTarget", + "description": "target is the key-value field to inspect for the comparison." + }, + "value": { + "type": "string", + "format": "byte", + "description": "value is the value of the given key, in bytes." + }, + "version": { + "type": "string", + "format": "int64", + "title": "version is the version of the given key" + } + } + }, + "etcdserverpbDefragmentRequest": { + "type": "object" + }, + "etcdserverpbDefragmentResponse": { + "type": "object", + "properties": { + "header": { + "$ref": "#/definitions/etcdserverpbResponseHeader" + } + } + }, + "etcdserverpbDeleteRangeRequest": { + "type": "object", + "properties": { + "key": { + "type": "string", + "format": "byte", + "description": "key is the first key to delete in the range." + }, + "range_end": { + "type": "string", + "format": "byte", + "description": "range_end is the key following the last key to delete for the range [key, range_end).\nIf range_end is not given, the range is defined to contain only the key argument.\nIf range_end is '\\0', the range is all keys greater than or equal to the key argument." + } + } + }, + "etcdserverpbDeleteRangeResponse": { + "type": "object", + "properties": { + "deleted": { + "type": "string", + "format": "int64", + "description": "deleted is the number of keys deleted by the delete range request." + }, + "header": { + "$ref": "#/definitions/etcdserverpbResponseHeader" + } + } + }, + "etcdserverpbHashRequest": { + "type": "object" + }, + "etcdserverpbHashResponse": { + "type": "object", + "properties": { + "hash": { + "type": "integer", + "format": "int64", + "description": "hash is the hash value computed from the responding member's key-value store." + }, + "header": { + "$ref": "#/definitions/etcdserverpbResponseHeader" + } + } + }, + "etcdserverpbLeaseGrantRequest": { + "type": "object", + "properties": { + "ID": { + "type": "string", + "format": "int64", + "description": "ID is the requested ID for the lease. If ID is set to 0, the lessor chooses an ID." + }, + "TTL": { + "type": "string", + "format": "int64", + "description": "TTL is the advisory time-to-live in seconds." + } + } + }, + "etcdserverpbLeaseGrantResponse": { + "type": "object", + "properties": { + "ID": { + "type": "string", + "format": "int64", + "description": "ID is the lease ID for the granted lease." + }, + "TTL": { + "type": "string", + "format": "int64", + "description": "TTL is the server chosen lease time-to-live in seconds." + }, + "error": { + "type": "string", + "format": "string" + }, + "header": { + "$ref": "#/definitions/etcdserverpbResponseHeader" + } + } + }, + "etcdserverpbLeaseKeepAliveRequest": { + "type": "object", + "properties": { + "ID": { + "type": "string", + "format": "int64", + "description": "ID is the lease ID for the lease to keep alive." + } + } + }, + "etcdserverpbLeaseKeepAliveResponse": { + "type": "object", + "properties": { + "ID": { + "type": "string", + "format": "int64", + "description": "ID is the lease ID from the keep alive request." + }, + "TTL": { + "type": "string", + "format": "int64", + "description": "TTL is the new time-to-live for the lease." + }, + "header": { + "$ref": "#/definitions/etcdserverpbResponseHeader" + } + } + }, + "etcdserverpbLeaseRevokeRequest": { + "type": "object", + "properties": { + "ID": { + "type": "string", + "format": "int64", + "description": "ID is the lease ID to revoke. When the ID is revoked, all associated keys will be deleted." + } + } + }, + "etcdserverpbLeaseRevokeResponse": { + "type": "object", + "properties": { + "header": { + "$ref": "#/definitions/etcdserverpbResponseHeader" + } + } + }, + "etcdserverpbMember": { + "type": "object", + "properties": { + "ID": { + "type": "string", + "format": "uint64", + "description": "ID is the member ID for this member." + }, + "clientURLs": { + "type": "array", + "items": { + "type": "string", + "format": "string" + }, + "description": "clientURLs is the list of URLs the member exposes to clients for communication. If the member is not started, clientURLs will be empty." + }, + "name": { + "type": "string", + "format": "string", + "description": "name is the human-readable name of the member. If the member is not started, the name will be an empty string." + }, + "peerURLs": { + "type": "array", + "items": { + "type": "string", + "format": "string" + }, + "description": "peerURLs is the list of URLs the member exposes to the cluster for communication." + } + } + }, + "etcdserverpbMemberAddRequest": { + "type": "object", + "properties": { + "peerURLs": { + "type": "array", + "items": { + "type": "string", + "format": "string" + }, + "description": "peerURLs is the list of URLs the added member will use to communicate with the cluster." + } + } + }, + "etcdserverpbMemberAddResponse": { + "type": "object", + "properties": { + "header": { + "$ref": "#/definitions/etcdserverpbResponseHeader" + }, + "member": { + "$ref": "#/definitions/etcdserverpbMember", + "description": "member is the member information for the added member." + } + } + }, + "etcdserverpbMemberListRequest": { + "type": "object" + }, + "etcdserverpbMemberListResponse": { + "type": "object", + "properties": { + "header": { + "$ref": "#/definitions/etcdserverpbResponseHeader" + }, + "members": { + "type": "array", + "items": { + "$ref": "#/definitions/etcdserverpbMember" + }, + "description": "members is a list of all members associated with the cluster." + } + } + }, + "etcdserverpbMemberRemoveRequest": { + "type": "object", + "properties": { + "ID": { + "type": "string", + "format": "uint64", + "description": "ID is the member ID of the member to remove." + } + } + }, + "etcdserverpbMemberRemoveResponse": { + "type": "object", + "properties": { + "header": { + "$ref": "#/definitions/etcdserverpbResponseHeader" + } + } + }, + "etcdserverpbMemberUpdateRequest": { + "type": "object", + "properties": { + "ID": { + "type": "string", + "format": "uint64", + "description": "ID is the member ID of the member to update." + }, + "peerURLs": { + "type": "array", + "items": { + "type": "string", + "format": "string" + }, + "description": "peerURLs is the new list of URLs the member will use to communicate with the cluster." + } + } + }, + "etcdserverpbMemberUpdateResponse": { + "type": "object", + "properties": { + "header": { + "$ref": "#/definitions/etcdserverpbResponseHeader" + } + } + }, + "etcdserverpbPutRequest": { + "type": "object", + "properties": { + "key": { + "type": "string", + "format": "byte", + "description": "key is the key, in bytes, to put into the key-value store." + }, + "lease": { + "type": "string", + "format": "int64", + "description": "lease is the lease ID to associate with the key in the key-value store. A lease\nvalue of 0 indicates no lease." + }, + "value": { + "type": "string", + "format": "byte", + "description": "value is the value, in bytes, to associate with the key in the key-value store." + } + } + }, + "etcdserverpbPutResponse": { + "type": "object", + "properties": { + "header": { + "$ref": "#/definitions/etcdserverpbResponseHeader" + } + } + }, + "etcdserverpbRangeRequest": { + "type": "object", + "properties": { + "key": { + "type": "string", + "format": "byte", + "description": "key is the first key for the range. If range_end is not given, the request only looks up key." + }, + "limit": { + "type": "string", + "format": "int64", + "description": "limit is a limit on the number of keys returned for the request." + }, + "range_end": { + "type": "string", + "format": "byte", + "description": "range_end is the upper bound on the requested range [key, range_end).\nIf range_end is '\\0', the range is all keys \u003e= key.\nIf the range_end is one bit larger than the given key,\nthen the range requests get the all keys with the prefix (the given key).\nIf both key and range_end are '\\0', then range requests returns all keys." + }, + "revision": { + "type": "string", + "format": "int64", + "description": "revision is the point-in-time of the key-value store to use for the range.\nIf revision is less or equal to zero, the range is over the newest key-value store.\nIf the revision has been compacted, ErrCompacted is returned as a response." + }, + "serializable": { + "type": "boolean", + "format": "boolean", + "description": "serializable sets the range request to use serializable member-local reads.\nRange requests are linearizable by default; linearizable requests have higher\nlatency and lower throughput than serializable requests but reflect the current\nconsensus of the cluster. For better performance, in exchange for possible stale reads,\na serializable range request is served locally without needing to reach consensus\nwith other nodes in the cluster." + }, + "sort_order": { + "$ref": "#/definitions/RangeRequestSortOrder", + "description": "sort_order is the order for returned sorted results." + }, + "sort_target": { + "$ref": "#/definitions/RangeRequestSortTarget", + "description": "sort_target is the key-value field to use for sorting." + } + } + }, + "etcdserverpbRangeResponse": { + "type": "object", + "properties": { + "header": { + "$ref": "#/definitions/etcdserverpbResponseHeader" + }, + "kvs": { + "type": "array", + "items": { + "$ref": "#/definitions/mvccpbKeyValue" + }, + "description": "kvs is the list of key-value pairs matched by the range request." + }, + "more": { + "type": "boolean", + "format": "boolean", + "description": "more indicates if there are more keys to return in the requested range." + } + } + }, + "etcdserverpbRequestOp": { + "type": "object", + "properties": { + "request_delete_range": { + "$ref": "#/definitions/etcdserverpbDeleteRangeRequest" + }, + "request_put": { + "$ref": "#/definitions/etcdserverpbPutRequest" + }, + "request_range": { + "$ref": "#/definitions/etcdserverpbRangeRequest" + } + } + }, + "etcdserverpbResponseHeader": { + "type": "object", + "properties": { + "cluster_id": { + "type": "string", + "format": "uint64", + "description": "cluster_id is the ID of the cluster which sent the response." + }, + "member_id": { + "type": "string", + "format": "uint64", + "description": "member_id is the ID of the member which sent the response." + }, + "raft_term": { + "type": "string", + "format": "uint64", + "description": "raft_term is the raft term when the request was applied." + }, + "revision": { + "type": "string", + "format": "int64", + "description": "revision is the key-value store revision when the request was applied." + } + } + }, + "etcdserverpbResponseOp": { + "type": "object", + "properties": { + "response_delete_range": { + "$ref": "#/definitions/etcdserverpbDeleteRangeResponse" + }, + "response_put": { + "$ref": "#/definitions/etcdserverpbPutResponse" + }, + "response_range": { + "$ref": "#/definitions/etcdserverpbRangeResponse" + } + } + }, + "etcdserverpbSnapshotRequest": { + "type": "object" + }, + "etcdserverpbSnapshotResponse": { + "type": "object", + "properties": { + "blob": { + "type": "string", + "format": "byte", + "description": "blob contains the next chunk of the snapshot in the snapshot stream." + }, + "header": { + "$ref": "#/definitions/etcdserverpbResponseHeader", + "description": "header has the current key-value store information. The first header in the snapshot\nstream indicates the point in time of the snapshot." + }, + "remaining_bytes": { + "type": "string", + "format": "uint64", + "title": "remaining_bytes is the number of blob bytes to be sent after this message" + } + } + }, + "etcdserverpbStatusRequest": { + "type": "object" + }, + "etcdserverpbStatusResponse": { + "type": "object", + "properties": { + "dbSize": { + "type": "string", + "format": "int64", + "description": "dbSize is the size of the backend database, in bytes, of the responding member." + }, + "header": { + "$ref": "#/definitions/etcdserverpbResponseHeader" + }, + "leader": { + "type": "string", + "format": "uint64", + "description": "leader is the member ID which the responding member believes is the current leader." + }, + "raftIndex": { + "type": "string", + "format": "uint64", + "description": "raftIndex is the current raft index of the responding member." + }, + "raftTerm": { + "type": "string", + "format": "uint64", + "description": "raftTerm is the current raft term of the responding member." + }, + "version": { + "type": "string", + "format": "string", + "description": "version is the cluster protocol version used by the responding member." + } + } + }, + "etcdserverpbTxnRequest": { + "type": "object", + "properties": { + "compare": { + "type": "array", + "items": { + "$ref": "#/definitions/etcdserverpbCompare" + }, + "description": "compare is a list of predicates representing a conjunction of terms.\nIf the comparisons succeed, then the success requests will be processed in order,\nand the response will contain their respective responses in order.\nIf the comparisons fail, then the failure requests will be processed in order,\nand the response will contain their respective responses in order." + }, + "failure": { + "type": "array", + "items": { + "$ref": "#/definitions/etcdserverpbRequestOp" + }, + "description": "failure is a list of requests which will be applied when compare evaluates to false." + }, + "success": { + "type": "array", + "items": { + "$ref": "#/definitions/etcdserverpbRequestOp" + }, + "description": "success is a list of requests which will be applied when compare evaluates to true." + } + }, + "description": "From google paxosdb paper:\nOur implementation hinges around a powerful primitive which we call MultiOp. All other database\noperations except for iteration are implemented as a single call to MultiOp. A MultiOp is applied atomically\nand consists of three components:\n1. A list of tests called guard. Each test in guard checks a single entry in the database. It may check\nfor the absence or presence of a value, or compare with a given value. Two different tests in the guard\nmay apply to the same or different entries in the database. All tests in the guard are applied and\nMultiOp returns the results. If all tests are true, MultiOp executes t op (see item 2 below), otherwise\nit executes f op (see item 3 below).\n2. A list of database operations called t op. Each operation in the list is either an insert, delete, or\nlookup operation, and applies to a single database entry. Two different operations in the list may apply\nto the same or different entries in the database. These operations are executed\nif guard evaluates to\ntrue.\n3. A list of database operations called f op. Like t op, but executed if guard evaluates to false." + }, + "etcdserverpbTxnResponse": { + "type": "object", + "properties": { + "header": { + "$ref": "#/definitions/etcdserverpbResponseHeader" + }, + "responses": { + "type": "array", + "items": { + "$ref": "#/definitions/etcdserverpbResponseOp" + }, + "description": "responses is a list of responses corresponding to the results from applying\nsuccess if succeeded is true or failure if succeeded is false." + }, + "succeeded": { + "type": "boolean", + "format": "boolean", + "description": "succeeded is set to true if the compare evaluated to true or false otherwise." + } + } + }, + "etcdserverpbWatchCancelRequest": { + "type": "object", + "properties": { + "watch_id": { + "type": "string", + "format": "int64", + "description": "watch_id is the watcher id to cancel so that no more events are transmitted." + } + } + }, + "etcdserverpbWatchCreateRequest": { + "type": "object", + "properties": { + "key": { + "type": "string", + "format": "byte", + "description": "key is the key to register for watching." + }, + "progress_notify": { + "type": "boolean", + "format": "boolean", + "description": "progress_notify is set so that the etcd server will periodically send a WatchResponse with\nno events to the new watcher if there are no recent events. It is useful when clients\nwish to recover a disconnected watcher starting from a recent known revision.\nThe etcd server may decide how often it will send notifications based on current load." + }, + "range_end": { + "type": "string", + "format": "byte", + "description": "range_end is the end of the range [key, range_end) to watch. If range_end is not given,\nonly the key argument is watched. If range_end is equal to '\\0', all keys greater than\nor equal to the key argument are watched." + }, + "start_revision": { + "type": "string", + "format": "int64", + "description": "start_revision is an optional revision to watch from (inclusive). No start_revision is \"now\"." + } + } + }, + "etcdserverpbWatchRequest": { + "type": "object", + "properties": { + "cancel_request": { + "$ref": "#/definitions/etcdserverpbWatchCancelRequest" + }, + "create_request": { + "$ref": "#/definitions/etcdserverpbWatchCreateRequest" + } + } + }, + "etcdserverpbWatchResponse": { + "type": "object", + "properties": { + "canceled": { + "type": "boolean", + "format": "boolean", + "description": "canceled is set to true if the response is for a cancel watch request.\nNo further events will be sent to the canceled watcher." + }, + "compact_revision": { + "type": "string", + "format": "int64", + "description": "compact_revision is set to the minimum index if a watcher tries to watch\nat a compacted index.\n\nThis happens when creating a watcher at a compacted revision or the watcher cannot\ncatch up with the progress of the key-value store. \n\nThe client should treat the watcher as canceled and should not try to create any\nwatcher with the same start_revision again." + }, + "created": { + "type": "boolean", + "format": "boolean", + "description": "created is set to true if the response is for a create watch request.\nThe client should record the watch_id and expect to receive events for\nthe created watcher from the same stream.\nAll events sent to the created watcher will attach with the same watch_id." + }, + "events": { + "type": "array", + "items": { + "$ref": "#/definitions/mvccpbEvent" + } + }, + "header": { + "$ref": "#/definitions/etcdserverpbResponseHeader" + }, + "watch_id": { + "type": "string", + "format": "int64", + "description": "watch_id is the ID of the watcher that corresponds to the response." + } + } + }, + "mvccpbEvent": { + "type": "object", + "properties": { + "kv": { + "$ref": "#/definitions/mvccpbKeyValue", + "description": "kv holds the KeyValue for the event.\nA PUT event contains current kv pair.\nA PUT event with kv.Version=1 indicates the creation of a key.\nA DELETE/EXPIRE event contains the deleted key with\nits modification revision set to the revision of deletion." + }, + "type": { + "$ref": "#/definitions/EventEventType", + "description": "type is the kind of event. If type is a PUT, it indicates\nnew data has been stored to the key. If type is a DELETE,\nit indicates the key was deleted." + } + } + }, + "mvccpbKeyValue": { + "type": "object", + "properties": { + "create_revision": { + "type": "string", + "format": "int64", + "description": "create_revision is the revision of last creation on this key." + }, + "key": { + "type": "string", + "format": "byte", + "description": "key is the key in bytes. An empty key is not allowed." + }, + "lease": { + "type": "string", + "format": "int64", + "description": "lease is the ID of the lease that attached to key.\nWhen the attached lease expires, the key will be deleted.\nIf lease is 0, then no lease is attached to the key." + }, + "mod_revision": { + "type": "string", + "format": "int64", + "description": "mod_revision is the revision of last modification on this key." + }, + "value": { + "type": "string", + "format": "byte", + "description": "value is the value held by the key, in bytes." + }, + "version": { + "type": "string", + "format": "int64", + "description": "version is the version of the key. A deletion resets\nthe version to zero and any modification of the key\nincreases its version." + } + } + } + } +} diff --git a/scripts/genproto.sh b/scripts/genproto.sh index 91d517aba..bfb7f87dc 100755 --- a/scripts/genproto.sh +++ b/scripts/genproto.sh @@ -49,6 +49,7 @@ popd # generate gateway code go get -u github.com/gengo/grpc-gateway/protoc-gen-grpc-gateway +go get -u github.com/gengo/grpc-gateway/protoc-gen-swagger pushd "${GRPC_GATEWAY_ROOT}" git reset --hard "${GRPC_GATEWAY_SHA}" go install ./protoc-gen-grpc-gateway @@ -70,7 +71,17 @@ done protoc -I. \ -I${GRPC_GATEWAY_ROOT}/third_party/googleapis \ -I${GOGOPROTO_PATH} \ - -I${COREOS_ROOT} --grpc-gateway_out=logtostderr=true:. ./etcdserver/etcdserverpb/rpc.proto + -I${COREOS_ROOT} \ + --grpc-gateway_out=logtostderr=true:. \ + --swagger_out=logtostderr=true:./Documentation/dev-guide/apispec/swagger/. \ + ./etcdserver/etcdserverpb/rpc.proto + +# TODO: change this whenever we add more swagger API +mv \ + Documentation/dev-guide/apispec/swagger/etcdserver/etcdserverpb/rpc.swagger.json \ + Documentation/dev-guide/apispec/swagger/rpc.swagger.json +rm -rf Documentation/dev-guide/apispec/swagger/etcdserver/etcdserverpb + # install protodoc # go get -v -u github.com/coreos/protodoc