[comment]: # translation:outdated

[comment]: # ({2ccfd922-2ccfd922})
# event.acknowledge

[comment]: # ({/2ccfd922-2ccfd922})

[comment]: # ({96ece3aa-eed7fdda})
### 描述

`object event.acknowledge(object/array parameters)`

此方法允许update事件。可以执行以下update操作：

-   关闭事件。如果事件已解决，此操作将被跳过。
-   确认事件。如果事件已被确认，此操作将被跳过。
-   取消acknowledge事件。如果事件未被确认，此操作将被跳过。
-   添加消息。
-   更改事件严重性。如果事件已具有相同的严重性，此操作将被跳过。
-   抑制事件。如果事件已被抑制，此操作将被跳过。
-   取消抑制事件。如果事件未被抑制，此操作将被跳过。

::: noteimportant
仅可以更新触发器事件。\
仅可以更新问题事件。\
需要触发器的读/写权限才能关闭事件或更改事件严重性。\
要关闭事件，触发器中应允许手动关闭。
:::

::: noteclassic
此方法适用于任何类型的用户。可以在用户角色设置中撤销调用此方法的权限。更多信息请参见[User
roles](/manual/web_interface/frontend_sections/users/user_roles)。
:::

[comment]: # ({/96ece3aa-eed7fdda})

[comment]: # ({ed60692c-32560b88})
### 参数

`(object/array)` 包含需要执行的事件ID和update操作的参数。

| 参数 | [数据类型](/manual/api/reference_commentary#数据类型) | 描述 |
|--|--|------|
| eventids | ID/array | 需要确认的[事件](/manual/api/reference/event/object#事件)的ID。<br><br>[参数行为](/manual/api/reference_commentary#参数行为):<br>- *必填* |
| action | integer | 事件update操作。<br><br>可能的位图值：<br>1 - 关闭问题；<br>2 - acknowledge事件；<br>4 - 添加消息；<br>8 - 更改严重性；<br>16 - 取消acknowledge事件；<br>32 - 抑制事件；<br>64 - 取消抑制事件；<br>128 - 更改事件等级为原因；<br>256 - 更改事件等级为症状。<br><br>这是一个位掩码字段；可以使用任意可能位图值的和（例如，34用于acknowledge和抑制事件）。<br><br>[参数行为](/manual/api/reference_commentary#参数行为):<br>- *必填* |
| cause_eventid | ID | 原因事件ID。<br><br>[参数行为](/manual/api/reference_commentary#参数行为):<br>- 如果`action`包含"更改事件等级为症状"位，则*必填* |
| message | string | 消息的文本。<br><br>[参数行为](/manual/api/reference_commentary#参数行为):<br>- 如果`action`包含"添加消息"位，则*必填* |
| severity | integer | 事件的新严重性。<br><br>可能的值：<br>0 - 未分类；<br>1 - 信息；<br>2 - 警告；<br>3 - 一般；<br>4 - 高；<br>5 - 灾难。<br><br>[参数行为](/manual/api/reference_commentary#参数行为):<br>- 如果`action`包含"更改严重性"位，则*必填* |
| suppress_until | integer | 事件需要被抑制到的Unix时间戳。<br><br>如果设置为"0"，则抑制将无限期持续。<br><br>[参数行为](/manual/api/reference_commentary#参数行为):<br>- 如果`action`包含"抑制事件"位，则*必填* |

[comment]: # ({/ed60692c-32560b88})

[comment]: # ({94f3ab84-94f3ab84})
### 返回值

`(object)` 返回一个 object，其中包含在 `eventids` 属性下列出的已更新事件的 ID。

[comment]: # ({/94f3ab84-94f3ab84})

[comment]: # ({b41637d2-b41637d2})
### 示例

[comment]: # ({/b41637d2-b41637d2})

[comment]: # ({2aa7a118-9e923e4c})
#### 确认事件

确认单个事件并留言。

[执行请求](/manual/api#执行请求):


```json
{
    "jsonrpc": "2.0",
    "method": "event.acknowledge",
    "params": {
        "eventids": "20427",
        "action": 6,
        "message": "Problem resolved."
    },
    "id": 1
}
```
响应：


```json
{
    "jsonrpc": "2.0",
    "result": {
        "eventids": [
            "20427"
        ]
    },
    "id": 1
}
```

[comment]: # ({/2aa7a118-9e923e4c})

[comment]: # ({63d8190d-94e25d7e})
#### 更改事件严重性

更改多个事件的严重性并留言。

[执行请求](/manual/api#执行请求):


```json
{
    "jsonrpc": "2.0",
    "method": "event.acknowledge",
    "params": {
        "eventids": ["20427", "20428"],
        "action": 12,
        "message": "Maintenance required to fix it.",
        "severity": 4
    },
    "id": 1
}
```
响应：


```json
{
    "jsonrpc": "2.0",
    "result": {
        "eventids": [
            "20427",
            "20428"
        ]
    },
    "id": 1
}
```

[comment]: # ({/63d8190d-94e25d7e})

[comment]: # ({aadd99f7-aadd99f7})
### 来源

CEvent::acknowledge() 在 *ui/include/classes/api/services/CEvent.php* 中。

[comment]: # ({/aadd99f7-aadd99f7})
