-
Notifications
You must be signed in to change notification settings - Fork 46
Add API endpoint for posting maintenance tasks #3570
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
base: master
Are you sure you want to change the base?
Add API endpoint for posting maintenance tasks #3570
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3570 +/- ##
==========================================
+ Coverage 62.11% 62.15% +0.03%
==========================================
Files 611 611
Lines 44880 44938 +58
Branches 43 43
==========================================
+ Hits 27876 27930 +54
- Misses 16994 16998 +4
Partials 10 10 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
6a38056 to
6262dd0
Compare
|
lunkwill42
left a comment
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.
I'm not going to delve too deeply into this quite yet. Suffice to say that if we are implementing a new endpoint for the MaintenanceTask model, it should be feature-complete: I.e. it should support GET for fetching existing tasks (both lists of tasks and individual tasks by id), POST for making new ones, and PATCH for modifying existing ones.
| Example POST request: | ||
| `/api/1/maintenance/` with body | ||
| `{ | ||
| "start_time": "2025-09-29T11:11:11", | ||
| "end_time": "2025-09-29T13:11:11", | ||
| "no_end_time": false, | ||
| "description": "Changing out old equipment in serverroom", | ||
| "location": [1, 2], | ||
| "room": ["myroom", "secondroom"], | ||
| "netbox": [1, 2], | ||
| "service": [1, 2], | ||
| "netboxgroup": [1, 2] | ||
| }` | ||
| Example POST response: | ||
| `{ | ||
| "id": 59, | ||
| "maintenance_components": "[<Netbox: buick.lab.uninett.no>, | ||
| <Netbox: oldsmobile.lab.uninett.no>]", | ||
| "start_time": "2025-10-01T09:17:00", | ||
| "end_time": "9999-12-31T23:59:59.999999", | ||
| "description": "Changing out old equipment in serverroom", | ||
| "author": "admin", | ||
| "state": "scheduled" | ||
| }` | ||
| """ |
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.
The POST body and the response body should preferably be symmetric when dealing with model API calls. These are definitely not symmetric (e.g. I can't take the response body, remove the id attribute and post it again as new record).
I was just following the spec of the issue :D |

Scope and purpose
Fixes #2927.
This is very inspired by
nav/python/nav/web/maintenance/views.py
Lines 246 to 328 in 5adb5d3
This pull request
maintenanceto the APIContributor Checklist
Every pull request should have this checklist filled out, no matter how small it is.
More information about contributing to NAV can be found in the
Hacker's guide to NAV.
<major>.<minor>.x). For a new feature or other additions, it should be based onmaster.