Creates a scheduled task for an OpenSearch application.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request headers

This operation uses only the common request headers. For more information, see Common request parameters.

Request syntax

POST /v4/openapi/app-groups/[appGroupIdentity]/scheduled-tasks HTTP/1.1

Request parameters

Parameter Type Position Required Example Description
appGroupIdentity String Path Yes my_app_group_name

The name of the application.

Request body

Parameter

Type

Required

Example

Description

type

String

Yes

"wipe"

The type of the scheduled task. Valid values:

  • wipe: data cleaning
  • fork: data import and reindexing
  • reindex: reindexing
  • clear: data clearing

cron

String

Yes

"10 20 * * 1,2,3,4,5"

The configurations of the scheduled task.

For more information, see the cron field in ScheduledTask.

enabled

Boolean

Yes

true

Specifies whether to enable the scheduled task.

appStrategy

String

No

delete-idle

The policy that is used to create a version. Valid values:

  • delete-idle: The application has two versions. This policy deletes the offline version before it creates another version.
  • need-slot: The application has only one version. This policy directly creates another version.

filter

Object

No

The filter condition for data cleaning.

filter.days

Integer

Yes

7

The validity period, in days.

Valid values: [7,180].

filter.unit

String

Yes

"s"

The unit to which the validity period is converted. Valid values:

  • s
  • ms

filter.field

String

--

"cate_id"

The field for which you want to clean the expired data.

runNow

Boolean

--

false

Specifies whether to immediately execute the task. Default value: false.

permanent

Boolean

--

true

Specifies whether the scheduled task permanently takes effect. Default value: true.

Response parameters

Parameter Type Example Description
requestId String ABCDEFGH

The ID of the request.

result Map {}

The details of the scheduled task.

Examples

Sample requests

POST /v4/openapi/app-groups/130091942/scheduled-tasks

// Data cleaning.
{
  "type": "wipe",
  "cron": "0 0 * * 1,2,3,4,5,6,7",
  "enabled": true,
  "filter": {
    "field": "title",
    "days": 30,
    "unit": "s"
  }
}
// Data clearing.
{
  "type": "clear",
  "cron": "0 0 * * 1,2,3,4,5,6,7",
  "enabled": true,
  "runNow": true,
  "permanent": false
}
// Data import and reindexing.
{
  "type": "fork",
  "cron": "0 0 * * 1,2,3,4,5,6,7",
  "enabled": true
}
// Manual reindexing.
{
  "type": "reindex",
  "cron": "0 0 * * 1,2,3,4,5,6,7",
  "enabled": true,
  "appStrategy": "need-slot",
  "runNow": true,
  "permanent": false
}

Sample success responses

XML format

<requestId>0BECF34E-125A-D35F-1E5D-ABB66B11FAB8</requestId>
<result>
    <id>cfd5ebe9-bcdd-11ea-a58d-98039b07e4ec</id>
    <progress>0</progress>
    <status>3</status>
    <lastRanTimestamp/>
    <type>wipe</type>
    <running>false</running>
    <paused>false</paused>
    <finished>false</finished>
    <idle>true</idle>
    <created>1593747144</created>
    <updated>1593747144</updated>
    <cron>0 0 * * 1,2,3,4,5,6,7</cron>
    <enabled>true</enabled>
    <lastScheduledTimestamp/>
    <forkedAppId/>
    <filter>
        <field>title</field>
        <days>30</days>
        <unit>s</unit>
    </filter>
</result>

JSON format

{
    "requestId": "0BECF34E-125A-D35F-1E5D-ABB66B11FAB8",
    "result": {
        "id": "cfd5ebe9-bcdd-11ea-a58d-98039b07e4ec",
        "progress": 0,
        "status": 3,
        "lastRanTimestamp": "",
        "type": "wipe",
        "running": false,
        "paused": false,
        "finished": false,
        "idle": true,
        "created": 1593747144,
        "updated": 1593747144,
        "cron": "0 0 * * 1,2,3,4,5,6,7",
        "enabled": true,
        "lastScheduledTimestamp": "",
        "forkedAppId": "",
        "filter": {
            "field": "title",
            "days": 30,
            "unit": "s"
        }
    }
}

Error codes

For a list of error codes, visit the API Error Center.