Extend API with Plugin
Hello All!
I didn't find a specific answer in the documentation of the DSK.
I'd like to know how I could extend the WMH API to some of my custom plugin methods.
Is there a way?
My plugin is integrated in WHM, but I'd like to be able to extend it to be able to use it through the WHM API 1. How can I register endpoints and process them?
Thank you
-
Thank you! I didn't see the describe part in the hooks section, but I think it actually goes the other way for me. An example would be: My plugin browses all the accounts, and for each of them check the presence of a readme.txt in the public_html. If there is one, then the app parses it, and extracts a version number located in it (we have a specific architecture for our projects). That allows me to have, from the WHM, a quick overview at the versions present for all the accounts, and which accounts do not have such configuration. That code exists, and I would like to be able to call it from the WMH API 1 to get a JSON response. Taking an example from the WMH API 1, I would like, for example, to be able to call : https://hostname.example.com:2087/cpsess##########/json-api/my-own-action-get-global-configurations?api.version=1&user=username " and get the JSON response using a method in my own plugin. Is there a way I do not see in the documentation? Thank you! 0 -
Hello, No, you are limited to using the existing API functions that are offered with cPanel/WHM. You'd need to develop a custom script to run those commands and output the results to the UI, as described in our WHM Plugins documentation: Guide to WHM Plugins - Software Development Kit - cPanel Documentation Thank you. 0 -
Hum, I'm not sure I understand. - Limited to existing API functions - gotcha. - Custom script to run the commands - I have, and it already outputs to the UI/Panel online. After browsing UAPI, it seems that if I break down my logic in two layer, I could do something like: - Get list of existing accounts using the WHM API 1, - For each account, use the WHM to UAPI (Use WHM API to Call cPanel API and UAPI - Software Development Kit - cPanel Documentation) to call a specific Module (to be created) that would carry the logic of getting the version on that specific user. That would multiply the calls, but I should be able to rely on the API to do that. Do you agree? Or is there some restriction on that? Thank you 0 -
*" that would carry the logic of getting the version on that specific user (ie, searching for a readme file, and extracting data from it if present). An UAPI Module could do that in perl, I guess. 0 -
For each account, use the WHM to UAPI (UAPI - Custom UAPI Modules - Software Development Kit - cPanel Documentation Let us know if this helps. Thank you.
0
Please sign in to leave a comment.
Comments
6 comments