mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
API: allow delete location by id (#14334)
* API: allow delete location by id Otherwise impossible to delete location "". * docs/API: location can be name or id for edit and delete
This commit is contained in:
@@ -65,9 +65,9 @@ Output:
|
||||
|
||||
Deletes an existing location
|
||||
|
||||
Route: `/api/v0/locations/location`
|
||||
Route: `/api/v0/locations/:location`
|
||||
|
||||
- location: name of the location to delete
|
||||
- location: name or id of the location to delete
|
||||
|
||||
Example:
|
||||
|
||||
@@ -89,9 +89,9 @@ Output:
|
||||
|
||||
Edits a location
|
||||
|
||||
Route: `/api/v0/locations/location`
|
||||
Route: `/api/v0/locations/:location`
|
||||
|
||||
- location: name of the location to edit
|
||||
- location: name or id of the location to edit
|
||||
|
||||
Input:
|
||||
|
||||
|
||||
@@ -2855,7 +2855,7 @@ function del_location(Illuminate\Http\Request $request)
|
||||
if (empty($location)) {
|
||||
return api_error(400, 'No location has been provided to delete');
|
||||
}
|
||||
$location_id = get_location_id_by_name($location);
|
||||
$location_id = ctype_digit($location) ? $location : get_location_id_by_name($location);
|
||||
if (empty($location_id)) {
|
||||
return api_error(400, "Failed to delete $location (Does not exists)");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user