hostinterface.replacehostinterfaces

Description

object hostinterface.replacehostinterfaces(object **parameters**)

This method allows to replace all host interfaces on a given host.

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) Parameters containing the ID of the host to be updated and the new host interfaces.

ParameterTypeDescription
hostid
(required)
stringID of the host to be updated.
interfaces
(required)
object/arrayHost interfaces to replace the current host interfaces with.

Return values

(object) Returns an object containing the IDs of the created host interfaces under the interfaceids property.

Examples

Replacing host interfaces

Replace all host interfaces with a single agent interface.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "hostinterface.replacehostinterfaces",
  4. "params": {
  5. "hostid": "30052",
  6. "interfaces": {
  7. "dns": "",
  8. "ip": "127.0.0.1",
  9. "main": 1,
  10. "port": "10050",
  11. "type": 1,
  12. "useip": 1
  13. }
  14. },
  15. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  16. "id": 1
  17. }

Response:

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

See also

Source

CHostInterface::replaceHostInterfaces() in ui/include/classes/api/services/CHostInterface.php.