mirror of https://gitee.com/bigwinds/arangodb
113 lines
17 KiB
JSON
113 lines
17 KiB
JSON
{
|
|
"basePath": "/",
|
|
"swaggerVersion": "1.1",
|
|
"apiVersion": "0.1",
|
|
"apis": [
|
|
{
|
|
"operations": [
|
|
{
|
|
"errorResponses": [
|
|
{
|
|
"reason": "is returned if the result set can be created by the server. <br><br>",
|
|
"code": "201"
|
|
},
|
|
{
|
|
"reason": "is returned if the JSON representation is malformed or the query specification is missing from the request. <br><br>",
|
|
"code": "400"
|
|
},
|
|
{
|
|
"reason": "The server will respond with <em>HTTP 404</em> in case a non-existing collection is accessed in the query. <br><br>",
|
|
"code": "404"
|
|
},
|
|
{
|
|
"reason": "The server will respond with <em>HTTP 405</em> if an unsupported HTTP method is used. <br><br>",
|
|
"code": "405"
|
|
}
|
|
],
|
|
"parameters": [
|
|
{
|
|
"dataType": "Json",
|
|
"paramType": "body",
|
|
"required": "true",
|
|
"name": "query",
|
|
"description": "A JSON object describing the query and query parameters. <br><br>"
|
|
}
|
|
],
|
|
"notes": "The query details include the query string plus optional query options and bind parameters. These values need to be passed in a JSON representation in the body of the POST request. <br><br> The following attributes can be used inside the JSON object: <br><br> <ul class=\"swagger-list\"><li><em>query</em>: contains the query string to be executed (mandatory) <li><em>count</em>: boolean flag that indicates whether the number of documents in the result set should be returned in the \"count\" attribute of the result (optional). Calculating the \"count\" attribute might in the future have a performance impact for some queries so this option is turned off by default, and \"count\" is only returned when requested. <li><em>batchSize</em>: maximum number of result documents to be transferred from the server to the client in one roundtrip (optional). If this attribute is not set, a server-controlled default value will be used. <li><em>ttl</em>: an optional time-to-live for the cursor (in seconds). The cursor will be removed on the server automatically after the specified amount of time. This is useful to ensure garbage collection of cursors that are not fully fetched by clients. If not set, a server-defined value will be used. <li><em>bindVars</em>: key/value list of bind parameters (optional). <li><em>options</em>: key/value list of extra options for the query (optional). </ul> The following options are supported at the moment: <br><br> <ul class=\"swagger-list\"><li><em>fullCount</em>: if set to <em>true</em> and the query contains a <em>LIMIT</em> clause, then the result will contain an extra attribute <em>extra</em> with a sub-attribute <em>fullCount</em>. This sub-attribute will contain the number of documents in the result before the last LIMIT in the query was applied. It can be used to count the number of documents that match certain filter criteria, but only return a subset of them, in one go. It is thus similar to MySQL's <em>SQL_CALC_FOUND_ROWS</em> hint. Note that setting the option will disable a few LIMIT optimizations and may lead to more documents being processed, and thus make queries run longer. Note that the <em>fullCount</em> sub-attribute will only be present in the result if the query has a LIMIT clause and the LIMIT clause is actually used in the query. </ul> If the result set can be created by the server, the server will respond with <em>HTTP 201</em>. The body of the response will contain a JSON object with the result set. <br><br> The returned JSON object has the following properties: <br><br> <ul class=\"swagger-list\"><li><em>error</em>: boolean flag to indicate that an error occurred (<em>false</em> in this case) <li><em>code</em>: the HTTP status code <li><em>result</em>: an array of result documents (might be empty if query has no results) <li><em>hasMore</em>: a boolean indicator whether there are more results available for the cursor on the server <li><em>count</em>: the total number of result documents available (only available if the query was executed with the <em>count</em> attribute set) <li><em>id</em>: id of temporary cursor created on the server (optional, see above) <li><em>extra</em>: an optional JSON object with extra information about the query result. For data-modification queries, the <em>extra</em> attribute will contain the number of modified documents and the number of documents that could not be modified due to an error (if <em>ignoreErrors</em> query option is specified) </ul> If the JSON representation is malformed or the query specification is missing from the request, the server will respond with <em>HTTP 400</em>. <br><br> The body of the response will contain a JSON object with additional error details. The object has the following attributes: <br><br> <ul class=\"swagger-list\"><li><em>error</em>: boolean flag to indicate that an error occurred (<em>true</em> in this case) <li><em>code</em>: the HTTP status code <li><em>errorNum</em>: the server error number <li><em>errorMessage</em>: a descriptive error message </ul> If the query specification is complete, the server will process the query. If an error occurs during query processing, the server will respond with <em>HTTP 400</em>. Again, the body of the response will contain details about the error. <br><br> A list of query errors can be found (../ArangoErrors/README.md) here. <br><br>",
|
|
"summary": " Create cursor",
|
|
"httpMethod": "POST",
|
|
"examples": "<br><br> Executes a query and extract the result in a single go: <br><br><br><br><pre><code class=\"json\">shell> curl -X POST --data-binary @- --dump - http://localhost:8529/_api/cursor\n{\"query\":\"FOR p IN products LIMIT 2 RETURN p\",\"count\":true,\"batchSize\":2}\n\nHTTP/1.1 201 Created\ncontent-type: application/json; charset=utf-8\n\n{ \n \"result\" : [ \n { \n \"_id\" : \"products/917896360\", \n \"_key\" : \"917896360\", \n \"_rev\" : \"917896360\", \n \"hello2\" : \"world1\" \n }, \n { \n \"_id\" : \"products/917568680\", \n \"_key\" : \"917568680\", \n \"_rev\" : \"917568680\", \n \"hello1\" : \"world1\" \n } \n ], \n \"hasMore\" : false, \n \"count\" : 2, \n \"error\" : false, \n \"code\" : 201 \n}\n</code></pre><br><br><br> Executes a query and extracts part of the result: <br><br><br><br><pre><code class=\"json\">shell> curl -X POST --data-binary @- --dump - http://localhost:8529/_api/cursor\n{\"query\":\"FOR p IN products LIMIT 5 RETURN p\",\"count\":true,\"batchSize\":2}\n\nHTTP/1.1 201 Created\ncontent-type: application/json; charset=utf-8\n\n{ \n \"result\" : [ \n { \n \"_id\" : \"products/919796904\", \n \"_key\" : \"919796904\", \n \"_rev\" : \"919796904\", \n \"hello5\" : \"world1\" \n }, \n { \n \"_id\" : \"products/919141544\", \n \"_key\" : \"919141544\", \n \"_rev\" : \"919141544\", \n \"hello3\" : \"world1\" \n } \n ], \n \"hasMore\" : true, \n \"id\" : \"919993512\", \n \"count\" : 5, \n \"error\" : false, \n \"code\" : 201 \n}\n</code></pre><br><br><br> Using a query option: <br><br><br><br><pre><code class=\"json\">shell> curl -X POST --data-binary @- --dump - http://localhost:8529/_api/cursor\n{\"query\":\"FOR i IN 1..1000 FILTER i > 500 LIMIT 10 RETURN i\",\"count\":true,\"options\":{\"fullCount\":true}}\n\nHTTP/1.1 201 Created\ncontent-type: application/json; charset=utf-8\n\n{ \n \"result\" : [ \n 501, \n 502, \n 503, \n 504, \n 505, \n 506, \n 507, \n 508, \n 509, \n 510 \n ], \n \"hasMore\" : false, \n \"count\" : 10, \n \"extra\" : { \n \"fullCount\" : 500 \n }, \n \"error\" : false, \n \"code\" : 201 \n}\n</code></pre><br><br><br> Executes a data-modification query and retrieves the number of modified documents: <br><br><br><br><pre><code class=\"json\">shell> curl -X POST --data-binary @- --dump - http://localhost:8529/_api/cursor\n{\"query\":\"FOR p IN products REMOVE p IN products\"}\n\nHTTP/1.1 201 Created\ncontent-type: application/json; charset=utf-8\n\n{ \n \"result\" : [ ], \n \"hasMore\" : false, \n \"extra\" : { \n \"operations\" : { \n \"executed\" : 2, \n \"ignored\" : 0 \n } \n }, \n \"error\" : false, \n \"code\" : 201 \n}\n</code></pre><br><br><br> Executes a data-modification query with option <em>ignoreErrors</em>: <br><br><br><br><pre><code class=\"json\">shell> curl -X POST --data-binary @- --dump - http://localhost:8529/_api/cursor\n{\"query\":\"REMOVE 'bar' IN products OPTIONS { ignoreErrors: true }\"}\n\nHTTP/1.1 201 Created\ncontent-type: application/json; charset=utf-8\n\n{ \n \"result\" : [ ], \n \"hasMore\" : false, \n \"extra\" : { \n \"operations\" : { \n \"executed\" : 0, \n \"ignored\" : 1 \n } \n }, \n \"error\" : false, \n \"code\" : 201 \n}\n</code></pre><br><br><br> Bad queries: <br><br> Missing body: <br><br><br><br><pre><code class=\"json\">shell> curl -X POST --dump - http://localhost:8529/_api/cursor\n\nHTTP/1.1 400 Bad Request\ncontent-type: application/json; charset=utf-8\n\n{ \n \"error\" : true, \n \"code\" : 400, \n \"errorNum\" : 1502, \n \"errorMessage\" : \"query is empty\" \n}\n</code></pre><br><br><br> Unknown collection: <br><br><br><br><pre><code class=\"json\">shell> curl -X POST --data-binary @- --dump - http://localhost:8529/_api/cursor\n{\"query\":\"FOR u IN unknowncoll LIMIT 2 RETURN u\",\"count\":true,\"batchSize\":2}\n\nHTTP/1.1 404 Not Found\ncontent-type: application/json; charset=utf-8\n\n{ \n \"error\" : true, \n \"code\" : 404, \n \"errorNum\" : 1203, \n \"errorMessage\" : \"cannot execute query: collection not found: 'unknowncoll'\" \n}\n</code></pre><br><br><br> Executes a data-modification query that attempts to remove a non-existing document: <br><br><br><br><pre><code class=\"json\">shell> curl -X POST --data-binary @- --dump - http://localhost:8529/_api/cursor\n{\"query\":\"REMOVE 'foo' IN products\"}\n\nHTTP/1.1 404 Not Found\ncontent-type: application/json; charset=utf-8\n\n{ \n \"error\" : true, \n \"code\" : 404, \n \"errorNum\" : 1202, \n \"errorMessage\" : \"document not found\" \n}\n</code></pre><br><br><br> <br><br>",
|
|
"nickname": "CreateCursor"
|
|
}
|
|
],
|
|
"path": "/_api/cursor"
|
|
},
|
|
{
|
|
"operations": [
|
|
{
|
|
"errorResponses": [
|
|
{
|
|
"reason": "The server will respond with <em>HTTP 200</em> in case of success. <br><br>",
|
|
"code": "200"
|
|
},
|
|
{
|
|
"reason": "If the cursor identifier is omitted, the server will respond with <em>HTTP 404</em>. <br><br>",
|
|
"code": "400"
|
|
},
|
|
{
|
|
"reason": "If no cursor with the specified identifier can be found, the server will respond with <em>HTTP 404</em>. <br><br>",
|
|
"code": "404"
|
|
}
|
|
],
|
|
"parameters": [
|
|
{
|
|
"dataType": "String",
|
|
"paramType": "path",
|
|
"required": "true",
|
|
"name": "cursor-identifier",
|
|
"description": "The name of the cursor <br><br>"
|
|
}
|
|
],
|
|
"notes": "<br><br> If the cursor is still alive, returns an object with the following attributes. <br><br> <ul class=\"swagger-list\"><li><em>id</em>: the <em>cursor-identifier</em> <li><em>result</em>: a list of documents for the current batch <li><em>hasMore</em>: <em>false</em> if this was the last batch <li><em>count</em>: if present the total number of elements </ul> Note that even if <em>hasMore</em> returns <em>true</em>, the next call might still return no documents. If, however, <em>hasMore</em> is <em>false</em>, then the cursor is exhausted. Once the <em>hasMore</em> attribute has a value of <em>false</em>, the client can stop. <br><br>",
|
|
"summary": " Read next batch from cursor",
|
|
"httpMethod": "PUT",
|
|
"examples": "<br><br> Valid request for next batch: <br><br><br><br><pre><code class=\"json\">shell> curl -X POST --data-binary @- --dump - http://localhost:8529/_api/cursor\n{\"query\":\"FOR p IN products LIMIT 5 RETURN p\",\"count\":true,\"batchSize\":2}\n\nshell> curl -X PUT --dump - http://localhost:8529/_api/cursor/924777640\n\nHTTP/1.1 200 OK\ncontent-type: application/json; charset=utf-8\n\n{ \n \"result\" : [ \n { \n \"_id\" : \"products/923597992\", \n \"_key\" : \"923597992\", \n \"_rev\" : \"923597992\", \n \"hello2\" : \"world1\" \n }, \n { \n \"_id\" : \"products/924253352\", \n \"_key\" : \"924253352\", \n \"_rev\" : \"924253352\", \n \"hello4\" : \"world1\" \n } \n ], \n \"hasMore\" : true, \n \"id\" : \"924777640\", \n \"count\" : 5, \n \"error\" : false, \n \"code\" : 200 \n}\n</code></pre><br><br><br> Missing identifier <br><br><br><br><pre><code class=\"json\">shell> curl -X PUT --dump - http://localhost:8529/_api/cursor\n\nHTTP/1.1 400 Bad Request\ncontent-type: application/json; charset=utf-8\n\n{ \n \"error\" : true, \n \"code\" : 400, \n \"errorNum\" : 400, \n \"errorMessage\" : \"bad parameter\" \n}\n</code></pre><br><br><br> Unknown identifier <br><br><br><br><pre><code class=\"json\">shell> curl -X PUT --dump - http://localhost:8529/_api/cursor/123123\n\nHTTP/1.1 404 Not Found\ncontent-type: application/json; charset=utf-8\n\n{ \n \"error\" : true, \n \"code\" : 404, \n \"errorNum\" : 1600, \n \"errorMessage\" : \"cursor not found\" \n}\n</code></pre><br><br><br>",
|
|
"nickname": "ReadNextBatchFromCursor"
|
|
}
|
|
],
|
|
"path": "/_api/cursor/{cursor-identifier}"
|
|
},
|
|
{
|
|
"operations": [
|
|
{
|
|
"errorResponses": [
|
|
{
|
|
"reason": "is returned if the server is aware of the cursor. <br><br>",
|
|
"code": "202"
|
|
},
|
|
{
|
|
"reason": "is returned if the server is not aware of the cursor. It is also returned if a cursor is used after it has been destroyed. <br><br>",
|
|
"code": "404"
|
|
}
|
|
],
|
|
"parameters": [
|
|
{
|
|
"dataType": "String",
|
|
"paramType": "path",
|
|
"required": "true",
|
|
"name": "cursor-identifier",
|
|
"description": "The name of the cursor <br><br>"
|
|
}
|
|
],
|
|
"notes": "Deletes the cursor and frees the resources associated with it. <br><br> The cursor will automatically be destroyed on the server when the client has retrieved all documents from it. The client can also explicitly destroy the cursor at any earlier time using an HTTP DELETE request. The cursor id must be included as part of the URL. <br><br> Note: the server will also destroy abandoned cursors automatically after a certain server-controlled timeout to avoid resource leakage. <br><br>",
|
|
"summary": " Delete cursor",
|
|
"httpMethod": "DELETE",
|
|
"examples": "<br><br><br><br><pre><code class=\"json\">shell> curl -X POST --data-binary @- --dump - http://localhost:8529/_api/cursor\n{\"query\":\"FOR p IN products LIMIT 5 RETURN p\",\"count\":true,\"batchSize\":2}\n\nHTTP/1.1 201 Created\ncontent-type: application/json; charset=utf-8\n\n{ \n \"result\" : [ \n { \n \"_id\" : \"products/925564072\", \n \"_key\" : \"925564072\", \n \"_rev\" : \"925564072\", \n \"hello2\" : \"world1\" \n }, \n { \n \"_id\" : \"products/926219432\", \n \"_key\" : \"926219432\", \n \"_rev\" : \"926219432\", \n \"hello4\" : \"world1\" \n } \n ], \n \"hasMore\" : true, \n \"id\" : \"926743720\", \n \"count\" : 5, \n \"error\" : false, \n \"code\" : 201 \n}\nshell> curl -X DELETE --data-binary @- --dump - http://localhost:8529/_api/cursor/926743720\n\n</code></pre><br><br><br>",
|
|
"nickname": "DeleteCursor"
|
|
}
|
|
],
|
|
"path": "/_api/cursor/{cursor-identifier}"
|
|
}
|
|
]
|
|
}
|