From 91b30963d0c67fb1f6d1c8cf2425d7ae4ce26dd0 Mon Sep 17 00:00:00 2001 From: Simone Mainardi Date: Tue, 7 Dec 2021 10:16:14 +0100 Subject: [PATCH] Documents config. import/export via REST API --- doc/src/web_gui/import_export.rst | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/doc/src/web_gui/import_export.rst b/doc/src/web_gui/import_export.rst index 8ad5217767..071b1b3b79 100644 --- a/doc/src/web_gui/import_export.rst +++ b/doc/src/web_gui/import_export.rst @@ -35,4 +35,31 @@ All this is available from the *Settings* -> *Manage Configurations* menu, as sh The Manage Configurations Page - + +Import/Export via API +--------------------- + +Configuration can also be imported and exported programmatically via API. Following is an example that uses the REST API to export and then import the global ntopng configuration. + + +To export the global ntopng configuration in a local JSON file :code:`all_config.json` from an host :code:`office`, user :code:`admin` (identified with password :code:`admin`) can call the following endpoint + +.. code:: bash + + $ curl -u admin:admin1 "http://office:3000/lua/rest/v2/export/all/config.lua?download=1" > all_config.json + + +To import the configuration, the contents of :code:`all_config.json` must be POST-ed as the value of a string :code:`JSON` to the following endpoint: + + +.. code:: bash + + $ curl -uadmin:admin1 -H "Content-Type: application/x-www-form-urlencoded" --data-urlencode "JSON=`cat all_config.json`" "http://office:3000/lua/rest/v2/import/all/config.lua" + +A successful POST is confirmed by the following message: + +.. code:: bash + + {"rc":0,"rc_str":"OK","rc_str_hr":"Success","rsp":[]} + +A restart of ntopng is required after the import of the global configuration.