mirror of https://gitee.com/bigwinds/arangodb
Move call documentation over into the source.
This commit is contained in:
parent
182e07a9a2
commit
52406fa674
|
@ -115,395 +115,9 @@ rejected instantly in the same way as a "regular", non-queued request.
|
|||
|
||||
!CHAPTER Managing Async Results via HTTP
|
||||
|
||||
<!-- -------------------------------------------------------------------------------- -->
|
||||
@startDocuBlock JSF_job_fetch_result
|
||||
@startDocuBlock JSF_job_cancel
|
||||
@startDocuBlock JSF_job_delete
|
||||
@startDocuBlock JSF_job_getStatusById
|
||||
@startDocuBlock JSF_job_getByType
|
||||
|
||||
@RESTHEADER{PUT /_api/job/job-id, Return result of an async job}
|
||||
|
||||
@RESTURLPARAMS
|
||||
|
||||
@RESTURLPARAM{job-id,string,required}
|
||||
The async job id.
|
||||
|
||||
@RESTDESCRIPTION
|
||||
Returns the result of an async job identified by job-id. If the async job
|
||||
result is present on the server, the result will be removed from the list of
|
||||
result. That means this method can be called for each job-id once.
|
||||
The method will return the original job result's headers and body, plus the
|
||||
additional HTTP header x-arango-async-job-id. If this header is present, then
|
||||
the job was found and the response contains the original job's result. If
|
||||
the header is not present, the job was not found and the response contains
|
||||
status information from the job manager.
|
||||
|
||||
@RESTRETURNCODES
|
||||
|
||||
@RESTRETURNCODE{204}
|
||||
is returned if the job requested via job-id is still in the queue of pending
|
||||
(or not yet finished) jobs. In this case, no x-arango-async-id HTTP header
|
||||
will be returned.
|
||||
|
||||
@RESTRETURNCODE{400}
|
||||
is returned if no job-id was specified in the request. In this case,
|
||||
no x-arango-async-id HTTP header will be returned.
|
||||
|
||||
@RESTRETURNCODE{404}
|
||||
is returned if the job was not found or already deleted or fetched from
|
||||
the job result list. In this case, no x-arango-async-id HTTP header will
|
||||
be returned.
|
||||
|
||||
@EXAMPLES
|
||||
Not providing a job-id:
|
||||
|
||||
```js
|
||||
unix> curl -X PUT --dump - http://localhost:8529/_api/job/
|
||||
|
||||
HTTP/1.1 400 Bad Request
|
||||
content-type: application/json; charset=utf-8
|
||||
|
||||
{"error":true,"errorMessage":"bad parameter","code":400,"errorNum":400}
|
||||
```
|
||||
|
||||
Providing a job-id for a non-existing job:
|
||||
|
||||
```js
|
||||
unix> curl -X PUT --dump - http://localhost:8529/_api/job/foobar
|
||||
|
||||
HTTP/1.1 404 Not Found
|
||||
content-type: application/json; charset=utf-8
|
||||
|
||||
{"error":true,"errorMessage":"not found","code":404,"errorNum":404}
|
||||
```
|
||||
|
||||
Fetching the result of an HTTP GET job:
|
||||
|
||||
```js
|
||||
unix> curl --header 'x-arango-async: store' --dump - http://localhost:8529/_api/version
|
||||
|
||||
HTTP/1.1 202 Accepted
|
||||
content-type: text/plain; charset=utf-8
|
||||
x-arango-async-id: 265413601
|
||||
|
||||
unix> curl -X PUT --dump - http://localhost:8529/_api/job/265413601
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
content-type: application/json; charset=utf-8
|
||||
x-arango-async-id: 265413601
|
||||
|
||||
{"server":"arango","version":"2.1.0"}
|
||||
```
|
||||
|
||||
Fetching the result of an HTTP POST job that failed:
|
||||
|
||||
```js
|
||||
unix> curl -X POST --header 'x-arango-async: store' --data-binary @- --dump - http://localhost:8529/_api/collection
|
||||
{"name":" this name is invalid "}
|
||||
|
||||
HTTP/1.1 202 Accepted
|
||||
content-type: text/plain; charset=utf-8
|
||||
x-arango-async-id: 265479137
|
||||
|
||||
unix> curl -X PUT --dump - http://localhost:8529/_api/job/265479137
|
||||
|
||||
HTTP/1.1 400 Bad Request
|
||||
content-type: application/json; charset=utf-8
|
||||
x-arango-async-id: 265479137
|
||||
|
||||
{"error":true,"code":400,"errorNum":1208,"errorMessage":"cannot create collection: illegal name"}
|
||||
```
|
||||
|
||||
<!-- -------------------------------------------------------------------------------- -->
|
||||
|
||||
@RESTHEADER{PUT /_api/job/job-id/cancel, Cancel async job}
|
||||
|
||||
@RESTURLPARAMS
|
||||
|
||||
@RESTURLPARAM{job-id,string,required}
|
||||
The async job id.
|
||||
|
||||
@RESTDESCRIPTION
|
||||
Cancels the currently running job identified by job-id. Note that it still
|
||||
might take some time to actually cancel the running async job.
|
||||
|
||||
@RESTRETURNCODES
|
||||
|
||||
@RESTRETURNCODE{200}
|
||||
cancel has been initiated.
|
||||
|
||||
@RESTRETURNCODE{400}
|
||||
is returned if no job-id was specified in the request. In this case,
|
||||
no x-arango-async-id HTTP header will be returned.
|
||||
|
||||
@RESTRETURNCODE{404}
|
||||
is returned if the job was not found or already deleted or fetched from
|
||||
the job result list. In this case, no x-arango-async-id HTTP header will
|
||||
be returned.
|
||||
|
||||
@EXAMPLES
|
||||
|
||||
```js
|
||||
unix> curl -X POST --header 'x-arango-async: store' --data-binary @- --dump - http://localhost:8529/_api/cursor
|
||||
{"query": "FOR i IN 1..10 FOR j IN 1..10 LET x = sleep(1.0) FILTER i == 5 && j == 5 RETURN 42"}
|
||||
|
||||
HTTP/1.1 202 Accepted
|
||||
content-type: text/plain; charset=utf-8
|
||||
x-arango-async-id: 268952545
|
||||
|
||||
unix> curl --dump - http://localhost:8529/_api/job/pending
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
content-type: application/json; charset=utf-8
|
||||
|
||||
["268952545"]
|
||||
|
||||
unix> curl -X PUT --dump - http://localhost:8529/_api/job/268952545/cancel
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
content-type: application/json; charset=utf-8
|
||||
|
||||
{"result":true}
|
||||
|
||||
unix> curl --dump - http://localhost:8529/_api/job/pending
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
content-type: application/json; charset=utf-8
|
||||
|
||||
["268952545"]
|
||||
```
|
||||
|
||||
<!-- -------------------------------------------------------------------------------- -->
|
||||
|
||||
@RESTHEADER{DELETE /_api/job/type, Deletes async job}
|
||||
|
||||
@RESTURLPARAMS
|
||||
|
||||
@RESTURLPARAM{type,string,required}
|
||||
The type of jobs to delete. type can be:
|
||||
* *all*: Deletes all jobs results. Currently executing or queued async
|
||||
jobs will not be stopped by this call.
|
||||
* *expired*: Deletes expired results. To determine the expiration status of a
|
||||
result, pass the stamp URL parameter. stamp needs to be a UNIX timestamp,
|
||||
and all async job results created at a lower timestamp will be deleted.
|
||||
* *an actual job-id*: In this case, the call will remove the result of the
|
||||
specified async job. If the job is currently executing or queued, it will not be aborted.
|
||||
|
||||
@RESTQUERYPARAMS
|
||||
|
||||
@RESTPARAM{stamp, number, optional}
|
||||
|
||||
A UNIX timestamp specifying the expiration threshold when type is expired.
|
||||
|
||||
@RESTDESCRIPTION
|
||||
Deletes either all job results, expired job results, or the result of a specific job.
|
||||
Clients can use this method to perform an eventual garbage collection of job results.
|
||||
|
||||
@RESTRETURNCODES
|
||||
|
||||
@RESTRETURNCODE{200}
|
||||
is returned if the deletion operation was carried out successfully.
|
||||
This code will also be returned if no results were deleted.
|
||||
|
||||
@RESTRETURNCODE{400}
|
||||
is returned if type is not specified or has an invalid value.
|
||||
|
||||
@RESTRETURNCODE{404}
|
||||
is returned if type is a job-id but no async job with the specified id was found.
|
||||
|
||||
@EXAMPLES
|
||||
|
||||
Deleting all jobs:
|
||||
|
||||
```js
|
||||
unix> curl --header 'x-arango-async: store' --dump - http://localhost:8529/_api/version
|
||||
|
||||
HTTP/1.1 202 Accepted
|
||||
content-type: text/plain; charset=utf-8
|
||||
x-arango-async-id: 270132193
|
||||
|
||||
unix> curl -X DELETE --dump - http://localhost:8529/_api/job/all
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
content-type: application/json; charset=utf-8
|
||||
|
||||
{
|
||||
"result" : true
|
||||
}
|
||||
```
|
||||
|
||||
Deleting expired jobs:
|
||||
|
||||
```js
|
||||
unix> curl --header 'x-arango-async: store' --dump - http://localhost:8529/_api/version
|
||||
|
||||
HTTP/1.1 202 Accepted
|
||||
content-type: text/plain; charset=utf-8
|
||||
x-arango-async-id: 270197729
|
||||
|
||||
unix> curl -X DELETE --dump - http://localhost:8529/_api/job/expired?stamp=1401376184
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
content-type: application/json; charset=utf-8
|
||||
|
||||
{
|
||||
"result" : true
|
||||
}
|
||||
```
|
||||
|
||||
Deleting the result of a specific job:
|
||||
|
||||
```js
|
||||
unix> curl --header 'x-arango-async: store' --dump - http://localhost:8529/_api/version
|
||||
|
||||
HTTP/1.1 202 Accepted
|
||||
content-type: text/plain; charset=utf-8
|
||||
x-arango-async-id: 270263265
|
||||
|
||||
unix> curl -X DELETE --dump - http://localhost:8529/_api/job/270263265
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
content-type: application/json; charset=utf-8
|
||||
|
||||
{
|
||||
"result" : true
|
||||
}
|
||||
```
|
||||
|
||||
Deleting the result of a non-existing job:
|
||||
|
||||
```js
|
||||
unix> curl -X DELETE --dump - http://localhost:8529/_api/job/foobar
|
||||
|
||||
HTTP/1.1 404 Not Found
|
||||
content-type: application/json; charset=utf-8
|
||||
|
||||
{
|
||||
"error" : true,
|
||||
"errorMessage" : "not found",
|
||||
"code" : 404,
|
||||
"errorNum" : 404
|
||||
}
|
||||
```
|
||||
|
||||
<!-- -------------------------------------------------------------------------------- -->
|
||||
|
||||
@RESTHEADER{GET /_api/job/job-id, Returns async job}
|
||||
|
||||
@RESTURLPARAMS
|
||||
|
||||
@RESTURLPARAM{job-id,string,required}
|
||||
The async job id.
|
||||
|
||||
@RESTDESCRIPTION
|
||||
Returns the processing status of the specified job. The processing status can be
|
||||
determined by peeking into the HTTP response code of the response.
|
||||
|
||||
@RESTRETURNCODES
|
||||
|
||||
@RESTRETURNCODE{200}
|
||||
is returned if the job requested via job-id has been executed
|
||||
and its result is ready to fetch.
|
||||
|
||||
@RESTRETURNCODE{204}
|
||||
is returned if the job requested via job-id is still in the queue of pending
|
||||
(or not yet finished) jobs.
|
||||
|
||||
@RESTRETURNCODE{404}
|
||||
is returned if the job was not found or already deleted or fetched from the job result list.
|
||||
|
||||
@EXAMPLES
|
||||
|
||||
Querying the status of a done job:
|
||||
|
||||
```js
|
||||
unix> curl --header 'x-arango-async: store' --dump - http://localhost:8529/_api/version
|
||||
|
||||
HTTP/1.1 202 Accepted
|
||||
content-type: text/plain; charset=utf-8
|
||||
x-arango-async-id: 270328801
|
||||
|
||||
unix> curl --dump - http://localhost:8529/_api/job/270328801
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
content-type: text/plain; charset=utf-8
|
||||
|
||||
Querying the status of a pending job:
|
||||
|
||||
unix> curl --header 'x-arango-async: store' --dump - http://localhost:8529/_admin/sleep?duration=3
|
||||
|
||||
HTTP/1.1 202 Accepted
|
||||
content-type: text/plain; charset=utf-8
|
||||
x-arango-async-id: 270394337
|
||||
|
||||
unix> curl --dump - http://localhost:8529/_api/job/270394337
|
||||
|
||||
HTTP/1.1 204 No Content
|
||||
content-type: text/plain; charset=utf-8
|
||||
```
|
||||
|
||||
<!-- -------------------------------------------------------------------------------- -->
|
||||
|
||||
@RESTHEADER{GET /_api/job/type, Returns list of async job}
|
||||
|
||||
@RESTURLPARAMS
|
||||
|
||||
@RESTURLPARAM{type,string,required}
|
||||
The type of jobs to return. The type can be either done or pending. Setting
|
||||
the type to done will make the method return the ids of already completed async
|
||||
jobs for which results can be fetched. Setting the type to pending will return
|
||||
the ids of not yet finished async jobs.
|
||||
|
||||
@RESTQUERYPARAMS
|
||||
|
||||
@RESTPARAM{count, number, optional}
|
||||
|
||||
The maximum number of ids to return per call. If not specified, a
|
||||
server-defined maximum value will be used.
|
||||
|
||||
@RESTDESCRIPTION
|
||||
Returns the list of ids of async jobs with a specific status (either done or pending).
|
||||
The list can be used by the client to get an overview of the job system status and
|
||||
to retrieve completed job results later.
|
||||
|
||||
@RESTRETURNCODES
|
||||
|
||||
@RESTRETURNCODE{200}
|
||||
is returned if the list can be compiled successfully. Note: the list might be empty.
|
||||
|
||||
@RESTRETURNCODE{400}
|
||||
is returned if type is not specified or has an invalid value.
|
||||
|
||||
@EXAMPLES
|
||||
|
||||
Fetching the list of done jobs:
|
||||
|
||||
```js
|
||||
unix> curl --header 'x-arango-async: store' --dump - http://localhost:8529/_api/version
|
||||
|
||||
HTTP/1.1 202 Accepted
|
||||
content-type: text/plain; charset=utf-8
|
||||
x-arango-async-id: 270459873
|
||||
|
||||
unix> curl --dump - http://localhost:8529/_api/job/done
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
content-type: application/json; charset=utf-8
|
||||
|
||||
[
|
||||
"270459873"
|
||||
]
|
||||
```
|
||||
|
||||
Fetching the list of pending jobs:
|
||||
|
||||
```js
|
||||
unix> curl --header 'x-arango-async: store' --dump - http://localhost:8529/_api/version
|
||||
|
||||
HTTP/1.1 202 Accepted
|
||||
content-type: text/plain; charset=utf-8
|
||||
x-arango-async-id: 270525409
|
||||
|
||||
unix> curl --dump - http://localhost:8529/_api/job/pending
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
content-type: application/json; charset=utf-8
|
||||
|
||||
[ ]
|
||||
```
|
||||
|
|
|
@ -113,7 +113,102 @@ HttpHandler::status_t RestJobHandler::execute () {
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @startDocuBlock JSF_job_fetch_result
|
||||
/// @brief fetches a job result and removes it from the queue
|
||||
///
|
||||
/// @RESTHEADER{PUT /_api/job/job-id, Return result of an async job}
|
||||
///
|
||||
/// @RESTURLPARAMS
|
||||
///
|
||||
/// @RESTURLPARAM{job-id,string,required}
|
||||
/// The async job id.
|
||||
///
|
||||
/// @RESTDESCRIPTION
|
||||
/// Returns the result of an async job identified by job-id. If the async job
|
||||
/// result is present on the server, the result will be removed from the list of
|
||||
/// result. That means this method can be called for each job-id once.
|
||||
/// The method will return the original job result's headers and body, plus the
|
||||
/// additional HTTP header x-arango-async-job-id. If this header is present, then
|
||||
/// the job was found and the response contains the original job's result. If
|
||||
/// the header is not present, the job was not found and the response contains
|
||||
/// status information from the job manager.
|
||||
///
|
||||
/// @RESTRETURNCODES
|
||||
///
|
||||
/// @RESTRETURNCODE{204}
|
||||
/// is returned if the job requested via job-id is still in the queue of pending
|
||||
/// (or not yet finished) jobs. In this case, no x-arango-async-id HTTP header
|
||||
/// will be returned.
|
||||
///
|
||||
/// @RESTRETURNCODE{400}
|
||||
/// is returned if no job-id was specified in the request. In this case,
|
||||
/// no x-arango-async-id HTTP header will be returned.
|
||||
///
|
||||
/// @RESTRETURNCODE{404}
|
||||
/// is returned if the job was not found or already deleted or fetched from
|
||||
/// the job result list. In this case, no x-arango-async-id HTTP header will
|
||||
/// be returned.
|
||||
///
|
||||
/// @EXAMPLES
|
||||
/// Not providing a job-id:
|
||||
///
|
||||
/// ```js
|
||||
/// unix> curl -X PUT --dump - http://localhost:8529/_api/job/
|
||||
///
|
||||
/// HTTP/1.1 400 Bad Request
|
||||
/// content-type: application/json; charset=utf-8
|
||||
///
|
||||
/// {"error":true,"errorMessage":"bad parameter","code":400,"errorNum":400}
|
||||
/// ```
|
||||
///
|
||||
/// Providing a job-id for a non-existing job:
|
||||
///
|
||||
/// ```js
|
||||
/// unix> curl -X PUT --dump - http://localhost:8529/_api/job/foobar
|
||||
///
|
||||
/// HTTP/1.1 404 Not Found
|
||||
/// content-type: application/json; charset=utf-8
|
||||
///
|
||||
/// {"error":true,"errorMessage":"not found","code":404,"errorNum":404}
|
||||
/// ```
|
||||
///
|
||||
/// Fetching the result of an HTTP GET job:
|
||||
///
|
||||
/// ```js
|
||||
/// unix> curl --header 'x-arango-async: store' --dump - http://localhost:8529/_api/version
|
||||
///
|
||||
/// HTTP/1.1 202 Accepted
|
||||
/// content-type: text/plain; charset=utf-8
|
||||
/// x-arango-async-id: 265413601
|
||||
///
|
||||
/// unix> curl -X PUT --dump - http://localhost:8529/_api/job/265413601
|
||||
///
|
||||
/// HTTP/1.1 200 OK
|
||||
/// content-type: application/json; charset=utf-8
|
||||
/// x-arango-async-id: 265413601
|
||||
///
|
||||
/// {"server":"arango","version":"2.1.0"}
|
||||
/// ```
|
||||
///
|
||||
/// Fetching the result of an HTTP POST job that failed:
|
||||
///
|
||||
/// ```js
|
||||
/// unix> curl -X POST --header 'x-arango-async: store' --data-binary @- --dump - http://localhost:8529/_api/collection
|
||||
/// {"name":" this name is invalid "}
|
||||
///
|
||||
/// HTTP/1.1 202 Accepted
|
||||
/// content-type: text/plain; charset=utf-8
|
||||
/// x-arango-async-id: 265479137
|
||||
///
|
||||
/// unix> curl -X PUT --dump - http://localhost:8529/_api/job/265479137
|
||||
///
|
||||
/// HTTP/1.1 400 Bad Request
|
||||
/// content-type: application/json; charset=utf-8
|
||||
/// x-arango-async-id: 265479137
|
||||
///
|
||||
/// {"error":true,"code":400,"errorNum":1208,"errorMessage":"cannot create collection: illegal name"}
|
||||
/// ```
|
||||
/// @endDocuBlock
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void RestJobHandler::putJob () {
|
||||
|
@ -152,7 +247,66 @@ void RestJobHandler::putJob () {
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @startDocuBlock JSF_job_cancel
|
||||
/// @brief cancels an async job
|
||||
///
|
||||
/// @RESTHEADER{PUT /_api/job/job-id/cancel, Cancel async job}
|
||||
///
|
||||
/// @RESTURLPARAMS
|
||||
///
|
||||
/// @RESTURLPARAM{job-id,string,required}
|
||||
/// The async job id.
|
||||
///
|
||||
/// @RESTDESCRIPTION
|
||||
/// Cancels the currently running job identified by job-id. Note that it still
|
||||
/// might take some time to actually cancel the running async job.
|
||||
///
|
||||
/// @RESTRETURNCODES
|
||||
///
|
||||
/// @RESTRETURNCODE{200}
|
||||
/// cancel has been initiated.
|
||||
///
|
||||
/// @RESTRETURNCODE{400}
|
||||
/// is returned if no job-id was specified in the request. In this case,
|
||||
/// no x-arango-async-id HTTP header will be returned.
|
||||
///
|
||||
/// @RESTRETURNCODE{404}
|
||||
/// is returned if the job was not found or already deleted or fetched from
|
||||
/// the job result list. In this case, no x-arango-async-id HTTP header will
|
||||
/// be returned.
|
||||
///
|
||||
/// @EXAMPLES
|
||||
///
|
||||
/// ```js
|
||||
/// unix> curl -X POST --header 'x-arango-async: store' --data-binary @- --dump - http://localhost:8529/_api/cursor
|
||||
/// {"query": "FOR i IN 1..10 FOR j IN 1..10 LET x = sleep(1.0) FILTER i == 5 && j == 5 RETURN 42"}
|
||||
///
|
||||
/// HTTP/1.1 202 Accepted
|
||||
/// content-type: text/plain; charset=utf-8
|
||||
/// x-arango-async-id: 268952545
|
||||
///
|
||||
/// unix> curl --dump - http://localhost:8529/_api/job/pending
|
||||
///
|
||||
/// HTTP/1.1 200 OK
|
||||
/// content-type: application/json; charset=utf-8
|
||||
///
|
||||
/// ["268952545"]
|
||||
///
|
||||
/// unix> curl -X PUT --dump - http://localhost:8529/_api/job/268952545/cancel
|
||||
///
|
||||
/// HTTP/1.1 200 OK
|
||||
/// content-type: application/json; charset=utf-8
|
||||
///
|
||||
/// {"result":true}
|
||||
///
|
||||
/// unix> curl --dump - http://localhost:8529/_api/job/pending
|
||||
///
|
||||
/// HTTP/1.1 200 OK
|
||||
/// content-type: application/json; charset=utf-8
|
||||
///
|
||||
/// ["268952545"]
|
||||
/// ```
|
||||
/// @endDocuBlock
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void RestJobHandler::putJobMethod () {
|
||||
|
@ -205,7 +359,62 @@ void RestJobHandler::getJob () {
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @startDocuBlock JSF_job_getStatusById
|
||||
/// @brief Returns the status of a specific job
|
||||
/// @RESTHEADER{GET /_api/job/job-id, Returns async job}
|
||||
///
|
||||
/// @RESTURLPARAMS
|
||||
///
|
||||
/// @RESTURLPARAM{job-id,string,required}
|
||||
/// The async job id.
|
||||
///
|
||||
/// @RESTDESCRIPTION
|
||||
/// Returns the processing status of the specified job. The processing status can be
|
||||
/// determined by peeking into the HTTP response code of the response.
|
||||
///
|
||||
/// @RESTRETURNCODES
|
||||
///
|
||||
/// @RESTRETURNCODE{200}
|
||||
/// is returned if the job requested via job-id has been executed
|
||||
/// and its result is ready to fetch.
|
||||
///
|
||||
/// @RESTRETURNCODE{204}
|
||||
/// is returned if the job requested via job-id is still in the queue of pending
|
||||
/// (or not yet finished) jobs.
|
||||
///
|
||||
/// @RESTRETURNCODE{404}
|
||||
/// is returned if the job was not found or already deleted or fetched from the job result list.
|
||||
///
|
||||
/// @EXAMPLES
|
||||
///
|
||||
/// Querying the status of a done job:
|
||||
///
|
||||
/// ```js
|
||||
/// unix> curl --header 'x-arango-async: store' --dump - http://localhost:8529/_api/version
|
||||
///
|
||||
/// HTTP/1.1 202 Accepted
|
||||
/// content-type: text/plain; charset=utf-8
|
||||
/// x-arango-async-id: 270328801
|
||||
///
|
||||
/// unix> curl --dump - http://localhost:8529/_api/job/270328801
|
||||
///
|
||||
/// HTTP/1.1 200 OK
|
||||
/// content-type: text/plain; charset=utf-8
|
||||
///
|
||||
/// Querying the status of a pending job:
|
||||
///
|
||||
/// unix> curl --header 'x-arango-async: store' --dump - http://localhost:8529/_admin/sleep?duration=3
|
||||
///
|
||||
/// HTTP/1.1 202 Accepted
|
||||
/// content-type: text/plain; charset=utf-8
|
||||
/// x-arango-async-id: 270394337
|
||||
///
|
||||
/// unix> curl --dump - http://localhost:8529/_api/job/270394337
|
||||
///
|
||||
/// HTTP/1.1 204 No Content
|
||||
/// content-type: text/plain; charset=utf-8
|
||||
/// ```
|
||||
/// @endDocuBlock
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void RestJobHandler::getJobById (std::string const& value) {
|
||||
|
@ -231,7 +440,77 @@ void RestJobHandler::getJobById (std::string const& value) {
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @startDocuBlock JSF_job_getByType
|
||||
/// @brief Returns the ids of job results with a specific status
|
||||
///
|
||||
/// @RESTHEADER{GET /_api/job/type, Returns list of async job}
|
||||
///
|
||||
/// @RESTURLPARAMS
|
||||
///
|
||||
/// @RESTURLPARAM{type,string,required}
|
||||
/// The type of jobs to return. The type can be either done or pending. Setting
|
||||
/// the type to done will make the method return the ids of already completed async
|
||||
/// jobs for which results can be fetched. Setting the type to pending will return
|
||||
/// the ids of not yet finished async jobs.
|
||||
///
|
||||
/// @RESTQUERYPARAMS
|
||||
///
|
||||
/// @RESTPARAM{count, number, optional}
|
||||
///
|
||||
/// The maximum number of ids to return per call. If not specified, a
|
||||
/// server-defined maximum value will be used.
|
||||
///
|
||||
/// @RESTDESCRIPTION
|
||||
/// Returns the list of ids of async jobs with a specific status (either done or pending).
|
||||
/// The list can be used by the client to get an overview of the job system status and
|
||||
/// to retrieve completed job results later.
|
||||
///
|
||||
/// @RESTRETURNCODES
|
||||
///
|
||||
/// @RESTRETURNCODE{200}
|
||||
/// is returned if the list can be compiled successfully. Note: the list might be empty.
|
||||
///
|
||||
/// @RESTRETURNCODE{400}
|
||||
/// is returned if type is not specified or has an invalid value.
|
||||
///
|
||||
/// @EXAMPLES
|
||||
///
|
||||
/// Fetching the list of done jobs:
|
||||
///
|
||||
/// ```js
|
||||
/// unix> curl --header 'x-arango-async: store' --dump - http://localhost:8529/_api/version
|
||||
///
|
||||
/// HTTP/1.1 202 Accepted
|
||||
/// content-type: text/plain; charset=utf-8
|
||||
/// x-arango-async-id: 270459873
|
||||
///
|
||||
/// unix> curl --dump - http://localhost:8529/_api/job/done
|
||||
///
|
||||
/// HTTP/1.1 200 OK
|
||||
/// content-type: application/json; charset=utf-8
|
||||
///
|
||||
/// [
|
||||
/// "270459873"
|
||||
/// ]
|
||||
/// ```
|
||||
///
|
||||
/// Fetching the list of pending jobs:
|
||||
///
|
||||
/// ```js
|
||||
/// unix> curl --header 'x-arango-async: store' --dump - http://localhost:8529/_api/version
|
||||
///
|
||||
/// HTTP/1.1 202 Accepted
|
||||
/// content-type: text/plain; charset=utf-8
|
||||
/// x-arango-async-id: 270525409
|
||||
///
|
||||
/// unix> curl --dump - http://localhost:8529/_api/job/pending
|
||||
///
|
||||
/// HTTP/1.1 200 OK
|
||||
/// content-type: application/json; charset=utf-8
|
||||
///
|
||||
/// [ ]
|
||||
/// ```
|
||||
/// /// @endDocuBlock
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void RestJobHandler::getJobByType (std::string const& type) {
|
||||
|
@ -284,7 +563,120 @@ void RestJobHandler::getJobByType (std::string const& type) {
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @startDocuBlock JSF_job_delete
|
||||
/// @brief deletes an async job result
|
||||
///
|
||||
/// @RESTHEADER{DELETE /_api/job/type, Deletes async job}
|
||||
///
|
||||
/// @RESTURLPARAMS
|
||||
///
|
||||
/// @RESTURLPARAM{type,string,required}
|
||||
/// The type of jobs to delete. type can be:
|
||||
/// * *all*: Deletes all jobs results. Currently executing or queued async
|
||||
/// jobs will not be stopped by this call.
|
||||
/// * *expired*: Deletes expired results. To determine the expiration status of a
|
||||
/// result, pass the stamp URL parameter. stamp needs to be a UNIX timestamp,
|
||||
/// and all async job results created at a lower timestamp will be deleted.
|
||||
/// * *an actual job-id*: In this case, the call will remove the result of the
|
||||
/// specified async job. If the job is currently executing or queued, it will not be aborted.
|
||||
///
|
||||
/// @RESTQUERYPARAMS
|
||||
///
|
||||
/// @RESTPARAM{stamp, number, optional}
|
||||
///
|
||||
/// A UNIX timestamp specifying the expiration threshold when type is expired.
|
||||
///
|
||||
/// @RESTDESCRIPTION
|
||||
/// Deletes either all job results, expired job results, or the result of a specific job.
|
||||
/// Clients can use this method to perform an eventual garbage collection of job results.
|
||||
///
|
||||
/// @RESTRETURNCODES
|
||||
///
|
||||
/// @RESTRETURNCODE{200}
|
||||
/// is returned if the deletion operation was carried out successfully.
|
||||
/// This code will also be returned if no results were deleted.
|
||||
///
|
||||
/// @RESTRETURNCODE{400}
|
||||
/// is returned if type is not specified or has an invalid value.
|
||||
///
|
||||
/// @RESTRETURNCODE{404}
|
||||
/// is returned if type is a job-id but no async job with the specified id was found.
|
||||
///
|
||||
/// @EXAMPLES
|
||||
///
|
||||
/// Deleting all jobs:
|
||||
///
|
||||
/// ```js
|
||||
/// unix> curl --header 'x-arango-async: store' --dump - http://localhost:8529/_api/version
|
||||
///
|
||||
/// HTTP/1.1 202 Accepted
|
||||
/// content-type: text/plain; charset=utf-8
|
||||
/// x-arango-async-id: 270132193
|
||||
///
|
||||
/// unix> curl -X DELETE --dump - http://localhost:8529/_api/job/all
|
||||
///
|
||||
/// HTTP/1.1 200 OK
|
||||
/// content-type: application/json; charset=utf-8
|
||||
///
|
||||
/// {
|
||||
/// "result" : true
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// Deleting expired jobs:
|
||||
///
|
||||
/// ```js
|
||||
/// unix> curl --header 'x-arango-async: store' --dump - http://localhost:8529/_api/version
|
||||
///
|
||||
/// HTTP/1.1 202 Accepted
|
||||
/// content-type: text/plain; charset=utf-8
|
||||
/// x-arango-async-id: 270197729
|
||||
///
|
||||
/// unix> curl -X DELETE --dump - http://localhost:8529/_api/job/expired?stamp=1401376184
|
||||
///
|
||||
/// HTTP/1.1 200 OK
|
||||
/// content-type: application/json; charset=utf-8
|
||||
///
|
||||
/// {
|
||||
/// "result" : true
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// Deleting the result of a specific job:
|
||||
///
|
||||
/// ```js
|
||||
/// unix> curl --header 'x-arango-async: store' --dump - http://localhost:8529/_api/version
|
||||
///
|
||||
/// HTTP/1.1 202 Accepted
|
||||
/// content-type: text/plain; charset=utf-8
|
||||
/// x-arango-async-id: 270263265
|
||||
///
|
||||
/// unix> curl -X DELETE --dump - http://localhost:8529/_api/job/270263265
|
||||
///
|
||||
/// HTTP/1.1 200 OK
|
||||
/// content-type: application/json; charset=utf-8
|
||||
///
|
||||
/// {
|
||||
/// "result" : true
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// Deleting the result of a non-existing job:
|
||||
///
|
||||
/// ```js
|
||||
/// unix> curl -X DELETE --dump - http://localhost:8529/_api/job/foobar
|
||||
///
|
||||
/// HTTP/1.1 404 Not Found
|
||||
/// content-type: application/json; charset=utf-8
|
||||
///
|
||||
/// {
|
||||
/// "error" : true,
|
||||
/// "errorMessage" : "not found",
|
||||
/// "code" : 404,
|
||||
/// "errorNum" : 404
|
||||
/// }
|
||||
/// ```
|
||||
/// @endDocuBlock
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void RestJobHandler::deleteJob () {
|
||||
|
|
Loading…
Reference in New Issue