Add/Edit a device

Adds a device to AFA, or edits the device configuration for a device already managed by AFA.

Note: For information to be used in this API for devices managed by management devices , see Get device info about managed devices.

Resource details

Resource Name:

/api/v1/devices/

Request Methods:

  • POST - adds a device
  • PUT - edits a device

Request URL Parameters:

Parameter

Required

Type

Description

body

Mandatory

String

Data in JSON format that specifies the values for all parameters applicable to the brand of the added or edited device.

For more details, see Request parameters by brand.

addChildren

Optional

Boolean

True - managed devices are automatically added. (Default)

False - managed devices are not added unless specified explicitly.

testMode

Optional

Boolean

True - used as a test run without actually adding or editing the device specified. Returns all parameters that would have been sent by the request.

False (default) - performs the actual request.

Response:

Code

Description

200

Operation completed successfully

400

Bad request, with one of the following error messages:

  • ALREADY_EXISTS. Specified device not found in AFA.
  • SCHEME_ERROR. Failed to load the device schema.
  • Validation Error. API values are not valid according to the device schema.
  • Not Found. Relevant when editing a device configuration, if the specified device is not found in AFA.

401

Unauthorized

403

Non-admin user

Add device - Request example (Add FortiManager with specific Firewalls)

curl --insecure "https://localhost/afa/api/v1/devices?addChildren=false" --request POST \\
				-H "Content-Type: application/json" \
				-H "Cookie: PHPSESSID=et52j33f796dl86pt7ms7efq29" \
			-d '{"brand": "fortimanager","host_name": "10.23.30.200","user_name": "fmgr_admin","passwd": "algosec","rest_port":"3443","log_collection_mode":"none","arrFWs": [{"FWName": "FW1_root","FWParent": "FW1"}]}'

Edit device - Request example a (Edit FortiManager that was already added)

curl --insecure "https://localhost/afa/api/v1/devices?addChildren=true" --request PUT \
				-H "accept: */*" \
				-H "Content-Type: application/json" \
				-H "Cookie: PHPSESSID=et52j33f796dl86pt7ms7efq29" \
			-d '{"name":"10.23.30.200","brand": "fortimanager","arrFWs": [{"FWName": "FW1","FWDefined":"false"},{"FWName": "root","FWDefined":"true"}]}'

Edit device- Request example b

curl --location --request PUT 'https://docker:7443/afa/api/v1/devices/' \ --header 'Content-Type: application/json' \ --header 'Accept: */*' \ --header 'Cookie: PHPSESSID=r9psihhnjebng2oovhv268odh1' \ --data-raw '{ "display_name": "myUpdatedNSC", "name": "fw_10_20_13_1", "host_name": "10.20.13.1", "user_name": "admin", "passwd": "algosec", "collector": "Central Manager", "baseline_profile": "JuniperNetscreenProfile", "vrouters": "yes", "con": "SSH", "ssh_port": "", "log_collection_mode": "extensive", "collect_log": "yes", "collect_log_from": "nsm", "log_host_name": "10.0.0.2", "log_user_name": "root", "log_passwd": "algosec", "collct_log_from_adt": "nsm", "log_host_name_adt": "10.0.0.1", "log_user_name_adt": "root", "log_passwd_adt": "algosec", "additional_fw_ids": "1.1.1.1:2.2.2.2:ServerName", "log_collection_frequency": "20", "active_change": "yes", "monitoring": "no", "set_user_permissions": "no", "password_fields": "passwd:log_passwd:log_passwd_adt", "FW_TYPE": "FW_NSC"

}'

Edit device - Response example (Edit FortiManager that was already added)

{
				"httpStatus": "200",
				"message": "Successfully modified \"myUpdatedNSC\"",
				"LogData": "",
				"fw_name": "fw_10_20_13_1",
				"syslog_restart_needed": false,
				"not_supported_audit_from_clm": false,
				"set_user_permissions": false
			}

Request parameters by brand

The following tables list the parameters valid for each brand recognized by AFA. In the tables, click each parameter name to jump to more details.

Request parameters for device from file

The following table lists parameters for devices created from file.

Device parameter details

The following table lists all the parameters used by /api/v1/devices/ GET, POST and PUT methods. All of the listed values are formatted as Strings, unless otherwise indicated.