[comment]: # translation:outdated

[comment]: # aside: 1

[comment]: # ({ee4a2645-28092341})
# 用户宏 object

以下objects与`usermacro`API直接相关。

[comment]: # ({/ee4a2645-28092341})

[comment]: # ({2cec3bc3-e654cd12})
### 全局宏

全局宏 object 具有以下属性。

| 属性 | [数据类型](/manual/api/reference_commentary#数据类型) | 描述 |
|--|--|------|
| globalmacroid | ID | 全局宏的 ID。<br><br>[属性行为](/manual/api/reference_commentary#属性行为):<br>- *只读*<br>- 对于 update 操作是 *必填的* |
| macro | string | 宏 string。<br><br>[属性行为](/manual/api/reference_commentary#属性行为):<br>- 对于 create 操作是 *必填的* |
| value | string | 宏的值。<br><br>[属性行为](/manual/api/reference_commentary#属性行为):<br>- 如果 `type` 设置为 "Secret macro"，则为 *写入权限*<br>- 对于 create 操作是 *必填的* |
| type | integer | 宏的类型。<br><br>可能的值：<br>0 - *(默认)* 文本宏；<br>1 - 秘密宏；<br>2 - Vault 密钥。 |
| description | string | 宏的描述。 |

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

[comment]: # ({7b2b2ada-5a3a9f9f})
### 主机宏

主机 宏 object 定义了在 一个主机、主机 原型或模板上可用的宏。它具有以下属性。

| 属性 | [数据类型](/manual/api/reference_commentary#数据类型) | 描述 |
|--|--|------|
| hostmacroid | ID | 主机 宏的 ID。<br><br>[属性行为](/manual/api/reference_commentary#属性行为)：<br>- *只读*<br>- 对于 update 操作是*必填*的 |
| hostid | ID | 所属 主机 的 ID。<br><br>[属性行为](/manual/api/reference_commentary#属性行为)：<br>- *常量*<br>- 对于 create 操作是*必填*的 |
| macro | string | 宏的 string。<br><br>[属性行为](/manual/api/reference_commentary#属性行为)：<br>- 对于 create 操作是*必填*的 |
| value | string | 宏的值。<br><br>[属性行为](/manual/api/reference_commentary#属性行为)：<br>- 如果 `type` 设置为 "Secret macro"，则为*写入权限*<br>- 对于 create 操作是*必填*的 |
| type | integer | 宏的类型。<br><br>可能的值：<br>0 - *(默认)* 文本宏；<br>1 - 密钥宏；<br>2 - Vault 密钥。 |
| description | string | 宏的描述。 |
| automatic | integer | 定义宏是否由发现规则控制。<br><br>可能的值：<br>0 - *(默认)* 宏由用户管理；<br>1 - 宏由发现规则管理。<br><br>用户不允许对自动宏执行 create 操作。<br>要对自动宏执行 update 操作，必须将其 [更改由发现规则创建的宏值](/manual/api/reference/usermacro/update#更改由发现规则创建的宏值)。 |

[comment]: # ({/7b2b2ada-5a3a9f9f})
