跳转至

编辑分派策略

该接口基于分派策略id对具体的分派策略进行修改。


示例

请求URl(POST)

curl --location 'https://caweb.aiops.com/api/alert/rest/api/v1/escalation/{escalationId}' \
--user 'email@example.com:<access_token>' \
--header 'Accept: application/json' \
--data '{
    "description": "分派",
    "workId": null,
    "triggers": [
        {
            "integrateType": "awscloud",
            "exps": [
                {
                    "labelId": "00000000-0000-0000-0000-000000000017",
                    "condition": "equals",
                    "tagValue": "61a966d45eb64e4b87e15f9770ceb3ef",
                    "tagKey": "app",
                    "useReg": 1,
                    "symbol": 0
                }
            ]
        }
    ],
    "policies": [
        {
            "interval": "30",
            "users": "100004604423",
            "schedulers": "",
            "cooperation": "",
            "groups": "",
            "cooperationUsers": [],
            "operationUsers": [],
            "selist": [
                {
                    "type": "users",
                    "id": "100004604423",
                    "flag": false,
                    "showBig": false,
                    "cooperationUsers": {
                        "cooperation": "100004604423",
                        "users": []
                    },
                    "operationUsers": 
                    {
                        "cooperation": "100004604423",
                        "users": []
                    },
                    "usersNotify": 
                    {
                        "id": "100004604423",
                        "notify": []
                    },
                    "schedulersNotify": 
                    {
                        "id": "100004604423",
                        "notify": []
                    },
                    "groupsNotify": 
                    {
                        "id": "100004604423",
                        "notify": []
                    },
                    "cooperationNotify": 
                    {
                        "id": "100004604423",
                        "notify": []
                    }
                }
            ],
            "usersNotify": [
                {
                    "id": "100004604423",
                    "notify": []
                }
            ],
            "cooperationNotify": [],
            "schedulersNotify": [],
            "groupsNotify": [],
            "isAck": 0,
            "cycles": 0,
            "ruleId": null
        }
    ],
    "cycles": 0
}'

请求报文头参数说明

参数 类型 说明
escalationId string 策略ID,可通过查询接口获取

access_token如何获取请参考文档 api令牌

提示

• 示例邮箱应替换为用户注册所用邮箱

• access_token应替换为您手动获取的access_token

• 如需对请求进行加密处理:请将

--user 'email@example.com:access_token' \

--header 'Accept: application/json'

替换为:

--header 'Authorization: Basic Z2FveWluaW5nOTk5NUAxNjMuY29tOmt1WWl6bmljZ3oxN0JBVjk=' \

--header 'Content-Type: application/json'

• 替换步骤请参考加密步骤

请求报文参数

字段名 类型 说明
description string 必填,升级规则的描述信息
workId string 非必填,工作空间 ID(可为 null)
triggers Array 必填,触发器配置
policies Array 必填,升级策略的详细配置
cycles Number 必填,升级周期(触发后循环次数)。0默认走一次

触发器配置(triggers)

triggers 是一个数组,每个元素定义一个触发条件

字段名 类型 说明
integrateType string 必填,集成类型(例如 awscloud)
exps Array 必填,具体的条件表达式配置

条件表达式(exps)

字段名 类型 说明
labelId string 必填,标签的唯一标识符
condition string 必填,条件运算符(例如 equals、notEquals)
tagKey string 必填,标签键
tagValu string 必填,标签值
useReg Number 非必填,是否启用正则(1 表示启用)

策略配置(policies)

policies 是一个数组,每个元素定义一个策略

字段名 类型 说明
interval string 必填,升级的时间间隔(分钟)
users string 非必填,指定的用户 ID(多个用户以逗号分隔)
schedulers string 非必填,排班ID
cooperation string 非必填,协作组 ID
groups string 非必填,用户组配置
cooperationUsers Array 非必填,协作组用户配置,包含用户和协作组关联
operationUsers Array 非必填,操作用户配置,包含用户和协作组关联
selist Array 非必填,配置选择列表的详细信息
usersNotify Array 非必填,通知用户配置
cooperationNotify Array 非必填,通知协作组配置
schedulersNotify Array 非必填,通知调度器配
groupsNotify Array 非必填,通知用户组配置
isAck Number 非必填,是否是确认后升级策略 1是0否
cycles Number 必填,升级策略的循环次数。0默认走一次
ruleId string 非必填,关联规则的 ID

响应报文

{
    "result": "success",
    "message": "ok",
    "data": 
    {
        "id": "2f812b7e-7a05-4b3f-90c8-31a05f6eff96",
        "description": "分派",
        "username": "768215042",
        "isDefault": 0,
        "createTime": 1726219454023,
        "updateTime": 1733987042407,
        "deleted": 0,
        "status": "DISABLED",
        "ruleId": null,
        "cycles": 0,
        "workId": null,
        "workName": null,
        "policies":
         [
            {
                "id": "e50e0562-5037-4051-9b4b-d3cfb3fb817c",
                "escalationId": "2f812b7e-7a05-4b3f-90c8-31a05f6eff96",
                "step": 1,
                "users": "100004604423",
                "schedulers": "",
                "inter": 1800000,
                "createTime": 1735272200426,
                "updateTime": 1735272200426,
                "deleted": 0,
                "status": "ACTIVE",
                "groups": "",
                "cooperation": "",
                "cooperationUsers": null,
                "operationUsers": null,
                "usersNotify": "[{\"id\":\"100004604423\",\"notify\":[]}]",
                "schedulersNotify": "[]",
                "groupsNotify": "[]",
                "cooperationNotify": "[]",
                "cycles": 0,
                "isAck": 0,
                "ruleId": null,
                "groupNames": null,
                "schedulerLabels": null,
                "contactName": "高一宁",
                "cooperationDesc": null,
                "policyId": "e50e0562-5037-4051-9b4b-d3cfb3fb817c",
                "interval": 1800000,
                "steps": ["1"]
            }
        ],
        "entities": [],
        "triggers": 
        [
            {
                "id": null,
                "escalationId": null,
                "integrateType": "awscloud",
                "owner": null,
                "createTime": null,
                "updateTime": null,
                "deleted": null,
                "exps": 
                [
                    {
                        "id": "e4b1dadb-ef9e-48e6-a3a2-0e40c0957880",
                        "tagKey": "app",
                        "tagValue": "61a966d45eb64e4b87e15f9770ceb3ef",
                        "conditions": "equals",
                        "triggerId": "0de3a95d-fc10-4cf7-8cfa-9c4e22172da3",
                        "createTime": 1735272200747,
                        "updateTime": 1735272200747,
                        "deleted": 0,
                        "useReg": 1,
                        "symbol": 0,
                        "labelId": "00000000-0000-0000-0000-000000000017",
                        "appDescription": null,
                        "condition": "equals"
                    }
                ]
            }
        ]
    },
    "totalCount": 1,
    "code": 200
}

响应参数

字段名 类型 说明
result string 请求结果,可能值:success 或 failed
message string 请求状态描述
data 维护窗口的详细信息。没有维护计划为null
totalCount int 回的记录总数(通常为 1)
code int HTTP 状态码(成功为 200)

data结果集

参数 类型 说明
id string 分派策略唯一标识
username string 用户名
isDefault Integer 是否为默认分派(0:否,1:是)
createTime Long 创建时间(毫秒时间戳)
updateTime Long 更新时间(毫秒时间戳)
deleted Integer 是否被删除(0:否,1:是)
status string 状态(如 "ACTIVE", "DISABLED")
ruleId string 规则 ID
cycles Integer 循环次数
workId string 工作空间ID
workName string 工作空间名称
policies Array 策略列表,每个元素为对象
entities Array 实体列表,通常为空
triggers Array 触发器列表,每个元素为对象

错误响应

{ 
    "result": "failed", 
    "message": "error", 
    "data": "失败,请检查请求参数,null", 
    "totalCount": 0, 
    "code": 400 
}

错误响应码

错误码 说明
200 成功
400 失败,传入的参数有问题
401 认证失败,用户名密码错误
403 权限失败,用户没有权限做此操作