hostprototype.update

Description

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.

Parameters

(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.

ParameterTypeDescription
groupLinksarrayGroup links to replace the current group links on the host prototype.

Parameter behavior:
- read-only for inherited objects
groupPrototypesarrayGroup prototypes to replace the existing group prototypes on the host prototype.

Parameter behavior:
- read-only for inherited objects
macrosobject/arrayUser macros to replace the current user macros.

All macros that are not listed in the request will be removed.
tagsobject/arrayHost 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
interfacesobject/arrayHost 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
templatesobject/arrayTemplates to replace the currently linked templates.

The templates must have the templateid property defined.

Return values

(object) Returns an object containing the IDs of the updated host prototypes under the hostids property.

Examples

Disabling a host prototype

Disable a host prototype, that is, set its status to “1”.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "hostprototype.update",
  4. "params": {
  5. "hostid": "10092",
  6. "status": 1
  7. },
  8. "id": 1
  9. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "hostids": [
  5. "10092"
  6. ]
  7. },
  8. "id": 1
  9. }

Updating host prototype tags

Replace host prototype tags with new ones.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "hostprototype.update",
  4. "params": {
  5. "hostid": "10092",
  6. "tags": [
  7. {
  8. "tag": "Datacenter",
  9. "value": "{#DATACENTER.NAME}"
  10. },
  11. {
  12. "tag": "Instance type",
  13. "value": "{#INSTANCE_TYPE}"
  14. }
  15. ]
  16. },
  17. "id": 1
  18. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "hostids": [
  5. "10092"
  6. ]
  7. },
  8. "id": 1
  9. }

Updating host prototype custom interfaces

Replace inherited interfaces with host prototype custom interfaces.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "hostprototype.update",
  4. "params": {
  5. "hostid": "10092",
  6. "custom_interfaces": "1",
  7. "interfaces": [
  8. {
  9. "main": "1",
  10. "type": "2",
  11. "useip": "1",
  12. "ip": "127.0.0.1",
  13. "dns": "",
  14. "port": "161",
  15. "details": {
  16. "version": "2",
  17. "bulk": "1",
  18. "community": "{$SNMP_COMMUNITY}"
  19. }
  20. }
  21. ]
  22. },
  23. "id": 1
  24. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "hostids": [
  5. "10092"
  6. ]
  7. },
  8. "id": 1
  9. }

See also

Source

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