[comment]: # translation:outdated

[comment]: # ({04928fa3-04928fa3})
# 复制

[comment]: # ({/04928fa3-04928fa3})

[comment]: # ({5b66b213-8ae93b5b})
### 描述

`object discoveryrule.copy(object parameters)`

此方法允许将带有所有原型的 LLD 规则复制到给定主机。

::: noteclassic
此方法只有 *Admin(管理员)* 和 *Super admin(超级管理员)* 用户可用。可以在用户角色设置中撤销调用该方法的权限。更多信息请查看[用户角色](/manual/web_interface/frontend_sections/administration/user_roles)。
:::

[comment]: # ({/5b66b213-8ae93b5b})

[comment]: # ({14e9b8f3-47295f20})
### 参数

`(object)` 定义要复制的 LLD 规则和目标主机的参数。

|参数|[类型](/manual/api/reference_commentary#数据类型)|描述|
|---------|---------------------------------------------------|-----------|
|discoveryids|array|要复制的 LLD 规则的 ID。|
|hostids|array|将 LLD 规则复制到的主机的 ID。|

[comment]: # ({/14e9b8f3-47295f20})

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

`(boolean)` 如果复制成功，则返回 `true`。

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

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

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

[comment]: # ({a43e0306-91be874e})
#### LLD 规则复制到多个主机

将 LLD 规则复制到两台主机。

请求：

``` {.java}
{
    "jsonrpc": "2.0",
    "method": "discoveryrule.copy",
    "params": {
        "discoveryids": [
            "27426"
        ],
        "hostids": [
            "10196",
            "10197"
        ]
    },
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 1
}
```

响应：

``` {.java}
{
    "jsonrpc": "2.0",
    "result": true,
    "id": 1
}
```

[comment]: # ({/a43e0306-91be874e})

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

*ui/include/classes/api/services/CDiscoveryRule.php* 中的 CDiscoveryrule::copy() 。

[comment]: # ({/8870f994-8870f994})
