object hostprototype.update(object/array hostPrototypes)
This method allows to update existing host prototypes.
This method is only available to Admin and Super admin user types. Permissions to call the method can be revoked in user role settings. See User roles for more information.
(object/array)
Host prototype properties to be updated.
The hostid
property must be defined for each host prototype, all other properties are optional. Only the passed properties will be updated, all others will remain unchanged.
Additionally to the standard host prototype properties, the method accepts the following parameters.
Parameter | Type | Description |
---|---|---|
groupLinks | array | Group links to replace the current group links on the host prototype. Parameter behavior: - read-only for inherited objects |
groupPrototypes | array | Group prototypes to replace the existing group prototypes on the host prototype. Parameter behavior: - read-only for inherited objects |
macros | object/array | User macros to replace the current user macros. All macros that are not listed in the request will be removed. |
tags | object/array | Host prototype tags to replace the current tags. All tags that are not listed in the request will be removed. Parameter behavior: - read-only for inherited objects |
interfaces | object/array | Host prototype custom interfaces to replace the current interfaces. Custom interface object should contain all its parameters. All interfaces that are not listed in the request will be removed. Parameter behavior: - supported if custom_interfaces of Host prototype object is set to "use host prototypes custom interfaces"- read-only for inherited objects |
templates | object/array | Templates to replace the currently linked templates. The templates must have only the templateid property defined. |
(object)
Returns an object containing the IDs of the updated host prototypes under the hostids
property.
Disable a host prototype, that is, set its status to "1".
{
"jsonrpc": "2.0",
"method": "hostprototype.update",
"params": {
"hostid": "10092",
"status": 1
},
"id": 1
}
Response:
Replace host prototype tags with new ones.
{
"jsonrpc": "2.0",
"method": "hostprototype.update",
"params": {
"hostid": "10092",
"tags": [
{
"tag": "Datacenter",
"value": "{#DATACENTER.NAME}"
},
{
"tag": "Instance type",
"value": "{#INSTANCE_TYPE}"
}
]
},
"id": 1
}
Response:
Replace inherited interfaces with host prototype custom interfaces.
{
"jsonrpc": "2.0",
"method": "hostprototype.update",
"params": {
"hostid": "10092",
"custom_interfaces": "1",
"interfaces": [
{
"main": "1",
"type": "2",
"useip": "1",
"ip": "127.0.0.1",
"dns": "",
"port": "161",
"details": {
"version": "2",
"bulk": "1",
"community": "{$SNMP_COMMUNITY}"
}
}
]
},
"id": 1
}
Response:
CHostPrototype::update() in ui/include/classes/api/services/CHostPrototype.php.