-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: OBS-398 - netbox-diode-plugin: create api endpoint for applying change sets #49
feat: OBS-398 - netbox-diode-plugin: create api endpoint for applying change sets #49
Conversation
Added permissions; Added "update" to the view.
Added more tests.
OBS-398 Create API endpoint for applying change sets
In the NetBox diode plugin, we need to create an API endpoint for change sets to process by the plugin.
Diode's reconciler service will make change sets based on ingested data and existing matching NetBox object states and send a request to this API endpoint. Payload will contain a list of changes to action with following fields:
Example payload:
Once we receive the request, we should action given change sets based on the
should create a new We should use atomic transactions and attempt to commit all changes in a set or rollback on any failure. Example use of Django's built-in These change sets should be applied utilising existing corresponding NetBox models. Note that each NetBox object type (model) might have some requirements, i.e. API endpoint should respond with with a success response or return an error. Success:
Error:
(response structure may change as we find it appropriate during development and testing). This API should be unit tested appropriately. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Julio-Oliveira-Encora, a few comments to think about.
diode-netbox-plugin/netbox_diode_plugin/tests/test_apply_change_set.py
Outdated
Show resolved
Hide resolved
diode-netbox-plugin/netbox_diode_plugin/tests/test_apply_change_set.py
Outdated
Show resolved
Hide resolved
Changed the model ObjectState to Diode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Atomic transactions are working 🎉
A couple of comments on error handling/responses.
Adjusts in the error response.
Added ApplyChangeSetRequestSerializer to validate the request. Changed "post" method in ApplyChangeSetView to use the serializer to validate the request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Julio-Oliveira-Encora, a few more suggestions/points to think and discuss if needed.
Replaced ChangeSetSerialiazer to ChangeSerialiazer. Updated some variables names.
Add an endpoint to apply changes (create and update) objects in the Netbox.