Skip to main content

UAPI has no documentation for cron jobs but replacing API 2?

Comments

3 comments

  • Andy Baugh cPanel Staff

    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 IV

    1
  • JAB Creations

    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
  • Andy Baugh cPanel Staff

    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.