[comment]: # translation:outdated

[comment]: # ({3ab1bd41-d756b50a})
# 更新

[comment]: # ({/3ab1bd41-d756b50a})

[comment]: # ({b63fa4d3-74746e1d})
### 说明

`object discoveryrule.update(object/array lldRules)`

此方法允许更新已存在的LLD规则。

[comment]: # ({/b63fa4d3-74746e1d})

[comment]: # ({762b0e0b-cf98658c})
### 参数

`(object/array)` 要更新的LLD规则属性。

每个LLD规则的`itemid`属性必须被定义，其他属性为可选。值传递要被更新的属性，其他属性保持不变。

另外见[标准的LLD规则属性](object#lld_rule)，此方法接受如下参数。

|属性                类|描述|<|
|-------------------------|------|-|
|filter|object|LLD规则LLD规则的[过滤对象](/zh/manual/api/reference/discoveryrule/object#lld_rule_filter)。|
|preprocessing|array|LLD规则[预处理选项](/zh/manual/api/reference/discoveryrule/object#lld_rule_preprocessing)。|
|lld\_macro\_paths|array|LLD规则[预处理选项](/zh/manual/api/reference/discoveryrule/object#lld_macro_path)。|
|overrides|array|LLD规则[覆盖选项](/zh/manual/api/reference/discoveryrule/object#lld_rule_overrides)。|

[comment]: # ({/762b0e0b-cf98658c})

[comment]: # ({a8607213-6f962e26})
### 返回值

`(object)`在`itemids`属性下返回一个包含被更新的LLD规则的IDs。

[comment]: # ({/a8607213-6f962e26})

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

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

[comment]: # ({c7391afa-67c9278f})
#### 为LLD规则添加一个筛选器

添加一个过滤器，以便*{\#FSTYPE}*宏的内容与lld发现规则 *\@File systems
for discovery*的正则表达式匹配。

请求:

``` {.java}
{
    "jsonrpc": "2.0",
    "method": "discoveryrule.update",
    "params": {
        "itemid": "22450",
        "filter": {
            "evaltype": 1,
            "conditions": [
                {
                    "macro": "{#FSTYPE}",
                    "value": "@File systems for discovery"
                }
            ]
        }
    },
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 1
}
```

响应:

``` {.java}
{
    "jsonrpc": "2.0",
    "result": {
        "itemids": [
            "22450"
        ]
    },
    "id": 1
}
```

[comment]: # ({/c7391afa-67c9278f})

[comment]: # ({286e3161-f3fd4d6c})
#### 禁用trapping

禁用LLD trapping 发现规则。

请求:

``` {.java}
{
    "jsonrpc": "2.0",
    "method": "discoveryrule.update",
    "params": {
        "itemid": "22450",
        "lld_macro_paths": [
            {
                "lld_macro": "{#MACRO1}",
                "path": "$.json.path"
            }
        ]
    },
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 1
}
```

响应:

``` {.java}
{
    "jsonrpc": "2.0",
    "result": {
        "itemids": [
            "28336"
        ]
    },
    "id": 36
}
```

[comment]: # ({/286e3161-f3fd4d6c})

[comment]: # ({356d4f3c-8d8cc019})
### 来源

CDiscoveryRule::update() in
*frontends/php/include/classes/api/services/CDiscoveryRule.php*.

[comment]: # ({/356d4f3c-8d8cc019})

[comment]: # ({bef0a5f5-bef0a5f5})
#### Updating LLD rule preprocessing options

Update an LLD rule with preprocessing rule “JSONPath”.

Request:

``` {.java}
{
    "jsonrpc": "2.0",
    "method": "discoveryrule.update",
    "params": {
        "itemid": "44211",
        "preprocessing": [
            {
                "type": "12",
                "params": "$.path.to.json",
                "error_handler": "2",
                "error_handler_params": "5"
            }
        ]
    },
    "auth": "700ca65537074ec963db7efabda78259",
    "id": 1
}
```

Response:

``` {.java}
{
    "jsonrpc": "2.0",
    "result": {
        "itemids": [
            "44211"
        ]
    },
    "id": 1
}
```

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

[comment]: # ({6a73b645-6a73b645})
### Source

CDiscoveryRule::update() in
*ui/include/classes/api/services/CDiscoveryRule.php*.

[comment]: # ({/6a73b645-6a73b645})
