1
0
Fork 0

Bug fix 3.5/add swagger apis for shards (#9733)

* added swagger API examples for shards methods

* renamed examples

* arhhggg
This commit is contained in:
Jan 2019-08-19 14:40:10 +02:00 committed by KVS85
parent 7fac859524
commit a608e38992
3 changed files with 115 additions and 1 deletions

View File

@ -4,6 +4,10 @@
@RESTHEADER{PUT /_api/collection/{collection-name}/responsibleShard, Return responsible shard for a document, getResponsibleShard:Collection}
@RESTALLBODYPARAM{document,json,required}
The body must consist of a JSON object with at least the shard key
attributes set to some values.
@RESTURLPARAMETERS
@RESTURLPARAM{collection-name,string,required}
@ -14,6 +18,9 @@ Returns the ID of the shard that is responsible for the given document
(if the document exists) or that would be responsible if such document
existed.
The request must body must contain a JSON document with at least the
collection's shard key attributes set to some values.
The response is a JSON object with a *shardId* attribute, which will
contain the ID of the responsible shard.
@ -22,14 +29,37 @@ contain the ID of the responsible shard.
@RESTRETURNCODES
@RESTRETURNCODE{200}
Returns the ID of the responsible shard:
Returns the ID of the responsible shard.
@RESTRETURNCODE{400}
If the *collection-name* is missing, then a *HTTP 400* is
returned.
Additionally, if not all of the collection's shard key
attributes are present in the input document, then a
*HTTP 400* is returned as well.
@RESTRETURNCODE{404}
If the *collection-name* is unknown, then an *HTTP 404*
is returned.
@RESTRETURNCODE{501}
*HTTP 501* is returned if the method is called on a single server.
@EXAMPLES
@EXAMPLE_ARANGOSH_RUN{RestGetResponsibleShardExample_cluster}
var cn = "testCollection";
db._drop(cn);
db._create(cn, { numberOfShards: 3, shardKeys: ["_key"] });
var body = JSON.stringify({ _key: "testkey", value: 23 });
var response = logCurlRequestRaw('PUT', "/_api/collection/" + cn + "/responsibleShard", body);
assert(response.code === 200);
assert(JSON.parse(response.body).hasOwnProperty("shardId"));
logJsonResponse(response);
db._drop(cn);
@END_EXAMPLE_ARANGOSH_RUN
@endDocuBlock

View File

@ -0,0 +1,72 @@
@startDocuBlock get_api_collection_shards
@brief Return the shard ids of a collection
@RESTHEADER{GET /_api/collection/{collection-name}/shards, Return the shard ids of a collection, shards:Collection}
@RESTURLPARAMETERS
@RESTURLPARAM{collection-name,string,required}
The name of the collection.
@RESTQUERYPARAMETERS
@RESTQUERYPARAM{details,boolean,optional}
If set to true, the return value will also contain the responsible servers for the collections' shards.
@RESTDESCRIPTION
By default returns a JSON array with the shard IDs of the collection.
If the `details` parameter is set to `true`, it will return a JSON object with the
shard IDs as object attribute keys, and the responsible servers for each shard mapped to them.
In the detailed response, the leader shards will be first in the arrays.
**Note** : This method is only available in a cluster coordinator.
@RESTRETURNCODES
@RESTRETURNCODE{200}
Returns the collection's shards.
@RESTRETURNCODE{400}
If the *collection-name* is missing, then a *HTTP 400* is
returned.
@RESTRETURNCODE{404}
If the *collection-name* is unknown, then an *HTTP 404*
is returned.
@RESTRETURNCODE{501}
*HTTP 501* is returned if the method is called on a single server.
@EXAMPLES
Retrieves the list of shards:
@EXAMPLE_ARANGOSH_RUN{RestGetShards_cluster}
var cn = "testCollection";
db._drop(cn);
db._create(cn, { numberOfShards: 3 });
var response = logCurlRequest('GET', "/_api/collection/" + cn + "/shards");
assert(response.code === 200);
logRawResponse(response);
db._drop(cn);
@END_EXAMPLE_ARANGOSH_RUN
Retrieves the list of shards with the responsible servers:
@EXAMPLE_ARANGOSH_RUN{RestGetShardsWithDetails_cluster}
var cn = "testCollection";
db._drop(cn);
db._create(cn, { numberOfShards: 3 });
var response = logCurlRequest('GET', "/_api/collection/" + cn + "/shards?details=true");
assert(response.code === 200);
logRawResponse(response);
db._drop(cn);
@END_EXAMPLE_ARANGOSH_RUN
@endDocuBlock

View File

@ -353,6 +353,16 @@ rest::ResponseCode GeneralResponse::responseCode(int code) {
case TRI_ERROR_GRAPH_COLLECTION_USED_IN_ORPHANS:
case TRI_ERROR_GRAPH_EDGE_COL_DOES_NOT_EXIST:
case TRI_ERROR_ARANGO_NO_JOURNAL:
case TRI_ERROR_NO_SMART_COLLECTION:
case TRI_ERROR_NO_SMART_GRAPH_ATTRIBUTE:
case TRI_ERROR_CANNOT_DROP_SMART_COLLECTION:
case TRI_ERROR_KEY_MUST_BE_PREFIXED_WITH_SMART_GRAPH_ATTRIBUTE:
case TRI_ERROR_ILLEGAL_SMART_GRAPH_ATTRIBUTE:
case TRI_ERROR_SMART_GRAPH_ATTRIBUTE_MISMATCH:
case TRI_ERROR_INVALID_SMART_JOIN_ATTRIBUTE:
case TRI_ERROR_KEY_MUST_BE_PREFIXED_WITH_SMART_JOIN_ATTRIBUTE:
case TRI_ERROR_NO_SMART_JOIN_ATTRIBUTE:
case TRI_ERROR_CLUSTER_MUST_NOT_CHANGE_SMART_JOIN_ATTRIBUTE:
return ResponseCode::BAD;
case TRI_ERROR_ARANGO_USE_SYSTEM_DATABASE:
@ -420,6 +430,8 @@ rest::ResponseCode GeneralResponse::responseCode(int code) {
case TRI_ERROR_CLUSTER_UNSUPPORTED:
case TRI_ERROR_NOT_IMPLEMENTED:
case TRI_ERROR_ONLY_ENTERPRISE:
case TRI_ERROR_CLUSTER_ONLY_ON_COORDINATOR:
case TRI_ERROR_CLUSTER_ONLY_ON_DBSERVER:
return ResponseCode::NOT_IMPLEMENTED;
default: