-
Notifications
You must be signed in to change notification settings - Fork 16
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
Add linknet PUT method and clean up linknet API a bit #243
Conversation
…ith mgmtdomain and device APIs
…n with pydantic model for IPs.
…exists), added update/PUT docs, docs for GET of single linknet
Codecov Report
@@ Coverage Diff @@
## develop #243 +/- ##
===========================================
+ Coverage 59.80% 60.81% +1.01%
===========================================
Files 62 62
Lines 6229 6331 +102
===========================================
+ Hits 3725 3850 +125
+ Misses 2504 2481 -23
Continue to review full report at Codecov.
|
Not sure how to add external users as reviewers but if you have some input @lunkwill42 @stveit go ahead! |
We might have discussed this before in general regarding the API, but is there a need to have endpoints for both linket and linknetS? If I post something to api/linknets and it gets id=1, I would expect to be able to access it from api/v1.0/linknets/1, not api/v1.0/linknet/1 as it currently is. i.e I would expect it to become a resource under the endpoint I posted to. In general i think avoiding double endpoints would streamline the API more. Another thing that I have thought about before is the use of the PUT method. If I've understood correctly you mainly use PUT as a way to update a resource, not replacing it. For example you allow someone to use PUT to only change one field of an object. The general understanding I have of PUT is that it should be used to effectively replace an object with a modified version (so for a linknet you would define the entirety of the linket object in the PUT message, needing all required fields to be set) , while PATCH can be used to change individual fields (ex. only update port). I am not trying to say that your approach is wrong, but I wonder if this distinction between PUT and PATCH is something you guys have thought about? Ive just scimmed the changes a little so this is all I have to say for now, I'll look more in depth on friday :) |
Ah yeah the discussion on linknet vs linknetS etc has come up before, so I guess it's something people care about. I think it's mostly personal preference if you like to have same URL or URL that sounds more like natural language. One suggestion could be to just add all single item paths on to the plural paths as well, so if you like to always have the S in the end it will actually work, but maybe docs stay the same for now and maybe just a note you can add ending S optionally? Either way the most important thing for me consistency, which we don't really have today :) I haven't thought about PUT vs PATCH, it sounds pretty logical they way you say it but I can't remember that I used any APIs that made a distinction and provided both PUT and PATCH. |
Busy week so been a bit slower than i wanted to be. Could linknet_device_ip_validator in linknet.py be put inside the f_linknet model? It doesnt seem to be used anywhere else. And just slap @validator('device_a_ip', 'device_b_ip') on it so you can remove the _device_a_ip_valid and _device_b_ip_valid fields. |
Ah yes @validator('device_a_ip', 'device_b_ip') seems to work great! I guess I never realized you can put two arguments there, instead I did that roundabout way with _device_a_ip_valid field and allow_reuse etc :P |
Allow update/PUT on linknets
Allow GET a single linknet
Update DELETE to use same path/syntax as other parts of API