创建多步拨测任务¶
POST /api/v1/dialing_task/multi_task_add
概述¶
Body 请求参数¶
参数名 | 类型 | 必选 | 说明 |
---|---|---|---|
regions | array | Y | 地域列表 允许为空: False |
task | json | Y | 任务配置 允许为空: False $maxDictLength: 20000 |
task.name | string | Y | 任务名称 允许为空: False |
task.frequency | string | Y | 拨测频率 允许为空: False 可选值: ['1m', '5m', '15m', '30m', '1h', '6h', '12h', '24h'] |
task.desc | string | 任务描述 允许为空: False 允许为空字符串: True 例子: 这是一个描述 |
|
task.steps | array | Y | 地域列表 允许为空: False |
tags | array | 标签名称列表 允许为空: False 例子: ['xx', 'yy'] |
参数补充说明¶
数据说明.
参数名 | type | 必选 | 说明 |
---|---|---|---|
regions | array | Y | 任务执行区域 |
task | json | Y | 任务详情 |
task.name | string | Y | 任务名称 |
task.frequency | string | Y | 任务频率 |
task.desc | string | N | 任务描述 |
task.steps | string | Y | 多步拨测步骤列表 |
task.steps.allow_failure | boolean | N | 若此步骤失败,是否继续执行下一步(type为http时必传) |
task.steps.extracted_vars | array | N | 局部变量列表(type为http时必传) |
task.steps.task | json | N | 步骤任务详情(type为http时必传) |
task.steps.type | string | Y | 步骤任务类型,可选值:[http ,wait ] http-http请求步骤,wait-等待步骤 |
task.steps.value | integer | N | 等待时长(单位:秒,type为wait时必传) |
tags | array | N | 标签列表 |
注意: 步骤任务详情 task.steps.task 参数内部的具体细节可参考 自定义拨测¶
extracted_vars参数说明.
参数名 | type | 必选 | 说明 |
---|---|---|---|
field | string | Y | 变量值 |
name | string | Y | 变量名 |
secure | boolean | Y | 变量值是否加密 |
步骤任务详情task参数说明
参数名 | type | 必选 | 说明 |
---|---|---|---|
name | string | Y | 步骤名称 |
url | string | Y | url |
method | string | Y | url 请求方法 |
advance_options | json | N | 高级选项 |
success_when_logic | enum | N | 可选值:[and , or ], success_when 参数内的逻辑关系,默认为 and |
success_when | array | Y | 拨测判定条件 |
post_mode | string | N | 可用性判断模式 默认-default 脚本模式-script |
post_script | string | N | 可用性判断脚本内容 |
请求例子¶
curl 'https://openapi.guance.com/api/v1/dialing_task/multi_task_add' \
-H 'DF-API-KEY: <DF-API-KEY>' \
-H 'Content-Type: application/json;charset=UTF-8' \
--data-raw '{"regions":["reg_xxxx"],"task":{"desc":"这是一个描述","name":"multi-test3","steps":[{"task":{"name":"test","method":"GET","url":"https://xxxx","advance_options":{"request_options":{"headers":{"x-ft-auth-token":"xxxx","x-workspace-uuid":"wksp_xxxx"},"auth":{"username":"","password":""}},"request_body":{"body_type":"","body":""},"secret":{"not_save":false}},"post_mode":"script","post_script":"body = load_json(response[\"body\"])\n\nvars[\"uuid\"] = body[\"content\"][\"uuid\"]"},"type":"http","allow_failure":true,"extracted_vars":[{"name":"UUID","field":"uuid","secure":false}]},{"type":"wait","value":180},{"task":{"name":"test","method":"GET","url":"https://xxxx","advance_options":{"request_options":{"headers":{"x-ft-auth-token":"xxxx","x-workspace-uuid":"wksp_xxxx"},"auth":{"username":"","password":""}},"request_body":{"body_type":"","body":""},"secret":{"not_save":false}},"success_when":[{"status_code":[{"is":"200"}],"header":{"aaa":[{"is":"bbb"}]}}],"success_when_logic":"and","post_mode":"default"},"type":"http","allow_failure":true,"extracted_vars":[]}],"frequency":"30m"},"tags":[]}' \
--compressed
响应¶
{
"code": 200,
"content": {
"createAt": 1743501586,
"creator": "wsak_xxxx",
"declaration": {},
"deleteAt": -1,
"id": null,
"isLocked": false,
"regions": [
"reg_xxxx"
],
"regionsInfo": [
"reg_xxxx"
],
"status": 0,
"tagInfo": [],
"task": {
"config_vars": [],
"desc": "这是一个描述",
"df_label": "",
"external_id": "dial_xxxx",
"frequency": "30m",
"name": "multi-test3",
"owner_external_id": "wksp_xxxx",
"post_url": "http://xxxxx",
"status": "ok",
"steps": [
{
"allow_failure": true,
"extracted_vars": [
{
"field": "uuid",
"name": "UUID",
"secure": false
}
],
"stepId": "03db0636-e25f-4327-a70c-20e99b12e4bc",
"task": "{\"name\": \"test\", \"method\": \"GET\", \"url\": \"https://xxxx\", \"advance_options\": {\"request_options\": {\"headers\": {\"x-ft-auth-token\": \"xxxx\", \"x-workspace-uuid\": \"wksp_xxxxx\"}, \"auth\": {\"username\": \"\", \"password\": \"\"}}, \"request_body\": {\"body_type\": \"\", \"body\": \"\"}, \"secret\": {\"not_save\": false}}, \"post_mode\": \"script\", \"post_script\": \"body = load_json(response[\\\"body\\\"])\\n\\nvars[\\\"uuid\\\"] = body[\\\"content\\\"][\\\"uuid\\\"]\"}",
"type": "http"
},
{
"stepId": "6c97b32e-6e21-4e41-9d9b-c3deb4f0b3fe",
"type": "wait",
"value": 180
},
{
"allow_failure": true,
"extracted_vars": [],
"stepId": "88f9ab01-bd59-4ed7-afe0-62a875dc84e1",
"task": "{\"name\": \"test\", \"method\": \"GET\", \"url\": \"https://xxx\", \"advance_options\": {\"request_options\": {\"headers\": {\"x-ft-auth-token\": \"xxxx\", \"x-workspace-uuid\": \"wksp_xxxx\"}, \"auth\": {\"username\": \"\", \"password\": \"\"}}, \"request_body\": {\"body_type\": \"\", \"body\": \"\"}, \"secret\": {\"not_save\": false}}, \"success_when\": [{\"status_code\": [{\"is\": \"200\"}], \"header\": {\"aaa\": [{\"is\": \"bbb\"}]}}], \"success_when_logic\": \"and\", \"post_mode\": \"default\"}",
"type": "http"
}
],
"workspace_language": "zh"
},
"type": "multi",
"updateAt": -1,
"updator": "",
"uuid": "dial_xxxx",
"workspaceUUID": "wksp_xxxx"
},
"errorCode": "",
"message": "",
"success": true,
"traceId": "TRACE-2F7F4ABE-138C-453E-9295-EF58A1F70F4A"
}