UAPI has no documentation for cron jobs but replacing API 2?
After the server migration, because of what a mess everything was I somehow forgot to reestablish the cron jobs on the newer server. I decided to automate the process a bit and went looking for the API documentation:
I could only find the API 2 documentation with strong recommendations to not use it. Only a generic link was provided but a Google search yielded in zero results:
"cron job" site:https://api.docs.cpanel.net/openapi/
- Is there a UAPI page for cron jobs?
- Will cPanel provide proper UAPI access for the entire API 2 access before dropping API 2?
- When, if yet determined, does cPanel plan on dropping API 2?
I'm really struggling to determine how to not waste my time on things that as far as I can determine might be dropped the next week! I really need solid reliable information. As developers we can't be changing things for no reason once every few years otherwise we'd never get anything done!
-
Howdy,
Any API2 calls that do not have UAPI equivalent will very likely *not* be dropped from the product despite the deprecation (which at this point is 10 years deprecated yet still in use at many places in the product). Despite the lack of assurances towards API2, I'm pretty sure it isn't going anywhere. There's certainly no initiative currently even being considered internally to remove *any* of the API2 or API1 methods in cPanel, and there hasn't been any such movement since we deprecated them in the first place.
Cheers,
Andy Baugh
Software Development Engineer IV1 -
Greetings Andy,
Thank you very much for the clarification! As I'm fast approaching an exceptionally pivotal moment in my life building my business I've actually spent a day and a half so far creating an audit of all of the cPanel commands (cpapi2 and uapi) to ensure that on the normal update server that I'll setup sometime later this year that if a command stops working with a newer version that I'll know about it before I manually update my primary server. The APIs are an absolutely invaluable connection to the rest of the server. I'm not sure what the API version 1 command is offhand, though looking it up it appears the command line command is
whmapi1
which I could find zero instances of in my software.My only grip right now is that even in the uapi determining success or failure from a command (presuming it executes in the terminal via PHP using shell_exec()) is very inconsistent and non-predictable. If I'm counting correctly I have 20 API commands between cpapi2 and uapi and have this morning already implemented proper success checking (often no-errors checking) for 13 of the commands. Good design is consistency and the returned JSON that I convert to an array (not PHP objects, ehck!) it's all over the place even for uapi. But it's more important that I have access to those commands than the consistency between them.
So thank you for the clarification. Thanks to Rex's comments elsewhere I'm starting to notice that the Linux distribution is actually more responsible (still in part) to the third party instability that I've had to deal with. I'm very close to locking down all third parties from causing absolute chaos. The open communication like this and especially from Rex this year has helped tremendously as I shift from locking down the last vulnerabilities to shifting to, goodie - sales. 😂︀
0 -
Consistency of output data structures is indeed hard to get across the various APIs. It is somewhat easier if you can execute from the context of whmapi1's "cpanel" function (which executes cPanel api calls "on behalf" of the user as either root or a reseller), as at least then the returns are all going to at least have the success parameter in the same place regardless of what call you used.
As an aside, you said you were using shell_exec to grab data from the API, which may not be optimal from a performance perspective in some contexts. You may want to take a look at the livephp classes in /usr/local/cpanel/php/ (which talk over a socket) or the old PHP API client (https://github.com/CpanelInc/xmlapi-php) if you wind up needing some other options/examples of ways to do this without shell_exec in php.
Best of luck in any event, I always want to see our customers succeed :)
0
Please sign in to leave a comment.
Comments
3 comments