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
Added #6695: add API endpoint for license seats #8058
Conversation
it makes no sense and we don't have any particular sorting order so the numbering would be inconsistent anyway
Hmm, i don't really know how to simplify/reduce the complexity Codacy is complaining about. Sure, could skip sanity checks and some other validation logic, but i'd rather have a slightly more complex function than an API that doesn't tell the user why the input is not plausible... Similarly, i could of course make dedicated checkin/checkout functions but the point of this endpoint is to have an easy way of manipulating seats externally. This is especially useful if the user doesn't agree with the way snipe-it determines how and when these fields should be populated (e.g. the annoying bug that seats which are assigned to assets stick with the original user when an asset is reassigned). |
@marcquark Codacy suggestions don't really make sense in this case I believe. I wonder how would the functions measure if you created smaller functions for all those ifs... Disclaim: I do not code in php so it is just a general observation |
That's what i thought too. For the sanity checks, it feels like there should be some elegant way to inject those into Laravel for specific routes or methods of the controller, but i couldn't find a decent example online. Having that could avoid having to copy+paste the same logic twice. The approach of moving it into a private function and calling that became complex quickly, so i bailed out. As far as the other logic goes, i'm actually less happy with what i produced now vs the original PR. Got the codacy score slightly lower, but it's now harder to understand imho. @snipe must there absolutely be a green tick in the codacy check for the PR to be accepted? |
TBH I don't really follow the suggestion that "else" statements should be completely avoided |
@marcquark Is it possible to get your fork and install it myself? |
Just a heads up - once v5 is out, we're going to be completely reworking the license section to make it work a bit more like asset models, with seats being more like assets. |
@snipe When do you reckon it will be out? Any plans in place? |
@jkour sure you can just pull the develop branch from my forked repo. though i don't know whether that is a wise thing to do. after all if major changes are coming with v5 it's very likely that the endpoint will be shuffled around. don't know how urgently you need the feature but it may not be worth adjusting all you tools and then redo everything in a few months or so |
@marcquark Not in a rush really...Maybe I will wait for the new version Thanks anyway |
Hi @snipe, so it looks like v5 didn't include any major changes to the license model and API. Hence i'd like to bring back attention to this PR. Any chance to get it merged at some point? A lot of people have been waiting for this feature for quite some time now. |
Congrats on merging your first pull request! 🎉🎉🎉 |
This PR implements a dedicated API endpoint for license seats. The endpoint can be used to get all seats of a particular license, get one specific seat aswell as update one specific seat's assignments. The new controller contains logic to determine whether an update operation is a checkin or checkout and adds logs accordingly.
It also deprecates the existing /licenses/{id}/seats route, which was only used in one instance anyway. It the output format remains the same, so should be backwards compatible.
There are also a bunch of tests. I haven't yet fully understood on what data the testing framework operates. But the seeded DB data only contains licenses that haven't been checked out to anyone. Hence i think a proper test for checkin cannot be implemented at the moment.