API: allow add device to set location (#15469)

This commit is contained in:
Tony Murray
2023-10-18 02:00:39 -05:00
committed by GitHub
parent 78a85fe3ef
commit 0e453e5938
2 changed files with 6 additions and 0 deletions

View File

@@ -1189,6 +1189,7 @@ Input (JSON):
- port_association_mode: method to identify ports: ifIndex (default), ifName, ifDescr, ifAlias
- poller_group: This is the poller_group id used for distributed
poller setup. Defaults to 0.
- location or location_id: set the location by text or location id
- force_add: Set to true to force the device to be added regardless of it being able
to respond to snmp or icmp.

View File

@@ -413,6 +413,7 @@ function add_device(Illuminate\Http\Request $request)
'hostname',
'display',
'overwrite_ip',
'location_id',
'port',
'transport',
'poller_group',
@@ -427,6 +428,10 @@ function add_device(Illuminate\Http\Request $request)
'cryptoalgo',
]));
if (! empty($data['location'])) {
$device->location_id = \App\Models\Location::firstOrCreate(['location' => $data['location']])->id;
}
// uses different name in legacy call
if (! empty($data['version'])) {
$device->snmpver = $data['version'];