-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
NetBox version
v4.5.3
Feature type
Change to existing functionality
Proposed functionality
Currently, a PATCH request to most API endpoints (for example, /dcim/device-types) always returns a 200 OK response, even if no actual updates are made to a resource in Netbox.
It would be beneficial to return a different status code, such as 204 No Content with an empty response body, when a PATCH request does not result in any changes. This would better align with existing Netbox behavior, where a PATCH that makes no modifications does not generate a changelog entry.
Use case
We use Ansible to add and modify a large list of device and module types sourced from the device type community library. Currently, when a potential change is detected for a specific device or module type, we issue a PATCH request to update the resource and rely on Ansible to report whether a change was made. However, since the API always returns a 200 status code, there is no straightforward way to create a changed_when conditional based solely on the PATCH response.
As a workaround, we must make an additional API call to retrieve the resource and compare each field to determine if any changes occurred before issuing a PATCH request. This leads to numerous unnecessary API calls for resources that haven't actually changed.
With the proposed enhancement, a single PATCH request could be made, and the status code would immediately indicate whether the resource was updated. This would streamline automation workflows and reduce redundant API requests.
Database changes
N/A
External dependencies
N/A