这是原厂英文文档的翻译页面. 欢迎帮助我们 完善文档.

更新主机宏

描述

object usermacro.update(object/array hostMacros)

此方法用于更新现有的主机宏.

此方法只有Admin(管理员)Super admin(超级管理员) 用户可用.可以在用户角色设置中撤销调用该方法的权限.更多信息请查看 User roles.

参数

(object/array) 需要更新的Host macro properties .

每个主机宏必须定义 hostmacroid 参数, 其他参数均为可选的. 只有通过的属性才会被更新,其他属性保持不变.

返回值

(object) 返回包含 hostmacroids 属性(其中包含被更新主机宏的ID)的对象.

示例

更改一个主机宏的值

更改一个主机宏"public"的值.

请求:

{
           "jsonrpc": "2.0",
           "method": "usermacro.update",
           "params": {
               "hostmacroid": "1",
               "value": "public"
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

返回:

{
           "jsonrpc": "2.0",
           "result": {
               "hostmacroids": [
                   "1"
               ]
           },
           "id": 1
       }

Change macro value that was created by discovery rule

Convert discovery rule created "automatic" macro to "manual" and change its value to "new-value".

Request:

{
           "jsonrpc": "2.0",
           "method": "usermacro.update",
           "params": {
               "hostmacroid": "1",
               "value": "new-value",
               "automatic": "0"
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": {
               "hostmacroids": [
                   "1"
               ]
           },
           "id": 1
       }

来源

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