configuration.import

Description

boolean configuration.import(object **parameters**)

This method allows to import configuration data from a serialized string.

Parameters

(object) Parameters containing the data to import and rules how the data should be handled.

ParameterTypeDescription
format
(required)
stringFormat of the serialized string.

Possible values:
json - JSON;
xml - XML.
source
(required)
stringSerialized string containing the configuration data.
rules
(required)
objectRules on how new and existing objects should be imported.

The rules parameter is described in detail in the table below.

If no rules are given, the configuration will not be updated.

The rules object supports the following parameters.

ParameterTypeDescription
applicationsobjectRules on how to import applications.

Supported parameters:
createMissing - (boolean) if set to true, new applications will be created; default: false;
deleteMissing - (boolean) if set to true, applications not present in the imported data will be deleted from the database; default: false.
discoveryRulesobjectRules on how to import LLD rules.

Supported parameters:
createMissing - (boolean) if set to true, new LLD rules will be created; default: false;
updateExisting - (boolean) if set to true, existing LLD rules will be updated; default: false;
deleteMissing - (boolean) if set to true, LLD rules not present in the imported data will be deleted from the database; default: false.
graphsobjectRules on how to import graphs.

Supported parameters:
createMissing - (boolean) if set to true, new graphs will be created; default: false;
updateExisting - (boolean) if set to true, existing graphs will be updated; default: false;
deleteMissing - (boolean) if set to true, graphs not present in the imported data will be deleted from the database; default: false.
groupsobjectRules on how to import host groups.

Supported parameters:
createMissing - (boolean) if set to true, new host groups will be created; default: false.
hostsobjectRules on how to import hosts.

Supported parameters:
createMissing - (boolean) if set to true, new hosts will be created; default: false;
updateExisting - (boolean) if set to true, existing hosts will be updated; default: false.
httptestsobjectRules on how to import web scenarios.

Supported parameters:
createMissing - (boolean) if set to true, new web scenarios will be created; default: false;
updateExisting - (boolean) if set to true, existing web scenarios will be updated; default: false;
deleteMissing - (boolean) if set to true, web scenarios not present in the imported data will be deleted from the database; default: false.
imagesobjectRules on how to import images.

Supported parameters:
createMissing - (boolean) if set to true, new images will be created; default: false;
updateExisting - (boolean) if set to true, existing images will be updated; default: false.
itemsobjectRules on how to import items.

Supported parameters:
createMissing - (boolean) if set to true, new items will be created; default: false;
updateExisting - (boolean) if set to true, existing items will be updated; default: false;
deleteMissing - (boolean) if set to true, items not present in the imported data will be deleted from the database; default: false.
mapsobjectRules on how to import maps.

Supported parameters:
createMissing - (boolean) if set to true, new maps will be created; default: false;
updateExisting - (boolean) if set to true, existing maps will be updated; default: false.
mediaTypesobjectRules on how to import media types.

Supported parameters:
createMissing - (boolean) if set to true, new media types will be created; default: false;
updateExisting - (boolean) if set to true, existing media types will be updated; default: false.
screensobjectRules on how to import screens.

Supported parameters:
createMissing - (boolean) if set to true, new screens will be created; default: false;
updateExisting - (boolean) if set to true, existing screens will be updated; default: false.
templateLinkageobjectRules on how to import template links.

Supported parameters:
createMissing - (boolean) if set to true, new links between templates and host will be created; default: false;
deleteMissing - (boolean) if set to true, template links not present in the imported data will be deleted from the database; default: false.
templatesobjectRules on how to import templates.

Supported parameters:
createMissing - (boolean) if set to true, new templates will be created; default: false;
updateExisting - (boolean) if set to true, existing templates will be updated; default: false.
templateScreensobjectRules on how to import template screens.

Supported parameters:
createMissing - (boolean) if set to true, new template screens will be created; default: false;
updateExisting - (boolean) if set to true, existing template screens will be updated; default: false;
deleteMissing - (boolean) if set to true, template screens not present in the imported data will be deleted from the database; default: false.
triggersobjectRules on how to import triggers.

Supported parameters:
createMissing - (boolean) if set to true, new triggers will be created; default: false;
updateExisting - (boolean) if set to true, existing triggers will be updated; default: false;
deleteMissing - (boolean) if set to true, triggers not present in the imported data will be deleted from the database; default: false.
valueMapsobjectRules on how to import value maps.

Supported parameters:
createMissing - (boolean) if set to true, new value maps will be created; default: false;
updateExisting - (boolean) if set to true, existing value maps will be updated; default: false.

Return values

(boolean) Returns true if importing has been successful.

Examples

Importing hosts and items

Import the host and items contained in the XML string. If any items in XML are missing, they will be deleted from the database, and everything else will be left unchanged.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "configuration.import",
  4. "params": {
  5. "format": "xml",
  6. "rules": {
  7. "applications": {
  8. "createMissing": true,
  9. "deleteMissing": false
  10. },
  11. "valueMaps": {
  12. "createMissing": true,
  13. "updateExisting": false
  14. },
  15. "hosts": {
  16. "createMissing": true,
  17. "updateExisting": true
  18. },
  19. "items": {
  20. "createMissing": true,
  21. "updateExisting": true,
  22. "deleteMissing": true
  23. }
  24. },
  25. "source": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<zabbix_export><version>5.0</version><date>2020-03-13T15:31:45Z</date><groups><group><name>Zabbix servers</name></group></groups><hosts><host><host>Export host</host><name>Export host</name><groups><group><name>Zabbix servers</name></group></groups><interfaces><interface><interface_ref>if1</interface_ref></interface></interfaces><applications><application><name>Application</name></application></applications><items><item><name>Item</name><key>item.key</key><delay>30s</delay><applications><application><name>Application</name></application></applications><valuemap><name>Host status</name></valuemap><interface_ref>if1</interface_ref><request_method>POST</request_method></item></items></host></hosts><value_maps><value_map><name>Host status</name><mappings><mapping><value>0</value><newvalue>Up</newvalue></mapping><mapping><value>2</value><newvalue>Unreachable</newvalue></mapping></mappings></value_map></value_maps></zabbix_export>"
  26. },
  27. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  28. "id": 1
  29. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": true,
  4. "id": 1
  5. }

Source

CConfiguration::import() in ui/include/classes/api/services/CConfiguration.php.