Skip to main content

Extend API with Plugin

Comments

6 comments

  • cPanelMichael
    Hello, Are you looking to use standardized hooks? We document how to use hooks at:
    0
  • Berenger Z
    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
  • cPanelMichael
    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
  • Berenger Z
    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
  • Berenger Z
    *" 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
  • cPanelMichael
    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.