template.massupdate
Description说明
object template.massupdate(object parameters)
This method allows to simultaneously replace or remove related objects and update properties on multiple templates此方法允许同时替换或删除相关对象并更新多个模板上的属性.
Parameters参数
(object)
Parameters containing the IDs of the templates to update and the properties that should be updated包含要更新的模板的ID和应更新的属性的参数.
Additionally to the standard template properties, the method accepts the following parameters.除standard template properties之外,该方法接受以下参数。
Parameter参数 | Type类型 | Description说明 |
---|---|---|
templates(required) | object/array | Templates to be updated要更新的模板. The templates must have the templateid property defined模板必须定义templateid 属性. |
groups | object/array | Host groups to replace the current host groups the templates belong to主机组替换模板所属的当前主机组. The host groups must have the groupid property defined主机组必须定义groupid 属性. |
hosts | object/array | Hosts and templates to replace the ones the templates are currently linked to主机和模板来替换当前链接到的模板. Both hosts and templates must use the hostid property to pass an ID主机和模板都必须使用hostid 属性传递一个ID. |
macros | object/array | User macros to replace the current user macros on the given templates用户宏替换给定模板上的当前用户宏. |
templates_clear | object/array | Templates to unlink and clear from the given templates从指定模板中取消链接和清除的模板. The templates must have the templateid property defined模板必须定义templateid 属性. |
templates_link | object/array | Templates to replace the currently linked templates用于替换当前链接的模板的模板. The templates must have the templateid property defined模板必须定义templateid 属性. |
Return values返回值
(object)
Returns an object containing the IDs of the updated templates under the templateids
property.(object)
返回一个对象,它包含templateids
属性下更新的模板的ID.
Examples范例
Replacing host groups更换主机组
Unlink and clear template “10091” from the given templates从给定的模板中取消链接并清除模板“10091”.
Request请求:
- {
- "jsonrpc": "2.0",
- "method": "template.massupdate",
- "params": {
- "templates": [
- {
- "templateid": "10085"
- },
- {
- "templateid": "10086"
- }
- ],
- "templates_clear": [
- {
- "templateid": "10091"
- }
- ]
- },
- "auth": "038e1d7b1735c6a5436ee9eae095879e",
- "id": 1
- }
Response响应:
- {
- "jsonrpc": "2.0",
- "result": {
- "templateids": [
- "10085",
- "10086"
- ]
- },
- "id": 1
- }
See also参考
Source来源
CTemplate::massUpdate() in frontends/php/include/classes/api/services/CTemplate.php.