管理 API 任务

任务是异步执行的 API作,因为它超出了同步请求/响应模型允许的时间。

Redis 云

使用任务的 API作示例包括:

  • 创建订阅
  • 创建数据库
  • 更新数据库
  • 删除数据库

所有创建、更新和删除 API作 (POST,PUTDELETE) 和一些查询作 (GET) 使用任务。

请求异步作后,该作将返回一个taskId,该任务标识特定任务,并包含有关任务执行的 API作的上下文和状态数据。

任务是 API 处理和预置生命周期的一部分。

任务信息

当您请求异步作时,对请求的响应包括任务状态和有关任务的其他信息:

{
  "taskId": "f3ec0e7b-0548-46e3-82f3-1977012ec738",
  "commandType": "subscriptionCreateRequest",
  "status": "received",
  "description": "Task request received and is being queued for processing.",
  "timestamp": "2019-08-08T09:07:39.826Z",
  "_links": {
    "task": {
      "href": "https://api.redislabs.com/v1/tasks/f3ec0e7b-0548-46e3-82f3-1977012ec738",
      "title": "getTaskStatusUpdates",
      "type": "GET"
    }
  }
}

Where:

  • taskId - The unique identifier (UUID) of the specific task
  • commandType - The request (command) type
  • status - The status of the task
  • description - A description of the status
  • timestamp - The time of the response in ISO-8601 date format and in the UTC timezone
  • _links - URI links to resources related to the task including:
    • A link to itself
    • Additional links based on the context of the response

Task status updates

With the task ID, you can query the task status for updates and progress information. The response in the above example shows a URL with the title getTaskStatusUpdates. The URL in the href property returns updates for the specified task.

Use GET /v1/tasks/{taskId} to check the task status.

This endpoint returns information about the queried task.

{
  "taskId": "36d4b04d-72d4-4404-8600-a223120a553e",
  "commandType": "subscriptionCreateRequest",
  "status": "processing-completed",
  "description": "Request processing completed successfully and its resources are now being provisioned / de-provisioned.",
  "timestamp": "2019-08-08T06:49:15.929Z",
  "response": {
    "resourceId": 77899
  },
  "_links": {
    "resource": {
      "href": "https://api.redislabs.com/v1/subscriptions/77899",
      "title": "getSubscriptionInformation",
      "type": "GET"
    },
    "self": {
      "href": "https://api.redislabs.com/v1/tasks/36d4b04d-72d4-4404-8600-a223120a553e",
      "type": "GET"
    }
  }
}

This response example shows:

  • The status value is "processing-completed".
  • The response field contains the resource identifier of the subscription resource changed by this task.
  • The links array contains another getSubscriptionInformation URL that links to the newly created subscription. This link queries the subscription status during provisioning)

Tasks list

You can use the API operation GET /tasks to list the recently submitted and completed tasks for the current account.

This API operation returns a list of tasks for the current account, sorted by most recent status update.

The result returns all the tasks submitted during the past 10 days.

RATE THIS PAGE
Back to top ↑