The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Package and Feature question

Discussion in 'cPanel Developers' started by kishu27, Feb 16, 2011.

  1. kishu27

    kishu27 Member

    Joined:
    Feb 16, 2011
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Hi,

    I have two problems and searched everywhere in google and the forums I couldn't find an answer. However this seems pretty basic so I must be doing something wrong or thinking something wrong. Please guide.

    Problems:

    1. What is the API to create a feature list on WHM (preferably API2)
    2. While creating a Package, the addpkg API call, refers to an input variable 'featurelist (string) — Name of the feature list to be used for the package.'. In the example I see that the word 'Default' is passed indicating that a featurelist name has to be passed, which matches the documentation description. How to get this featurelist string names???

    The API Listed at getfeaturelist does not help.


    Please help
     
  2. cPanelDavidN

    cPanelDavidN Integration Developer
    Staff Member

    Joined:
    Dec 17, 2009
    Messages:
    571
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Hi kishu27,

    Unfortunately, our APIs do not offer the ability to list and create feature lists. This would be a really great feature request. In fact, I had to double check all the documentation because I thought I was missing something too.

    Regards,
    -DavidN
     
  3. kishu27

    kishu27 Member

    Joined:
    Feb 16, 2011
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Hey David,

    Thanks very much for the answer. I understand the situation and have raised a request in feature request section. I am hence hoping a quick addition be made to the API which supports these.

    I do have a small question if you can answer it, how were people earlier making these two functionalities happening. Were they using other methods (other version or suite of webservices or some roundabout method)

    Thanks David
     
  4. cPanelDavidN

    cPanelDavidN Integration Developer
    Staff Member

    Joined:
    Dec 17, 2009
    Messages:
    571
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    To my knowledge, there's not a work around other than emulating actions in WHM with cURL or LWP or some other browser agent.

    Scenario: add a list
    1) make a request to https://$server:2087/scripts2/dofeaturemanager , specifying the feature name and the action
    Code:
    // adding new list called "forumtest"
    https://10.0.0.1:2087/scripts2/dofeaturemanager?action=addfeature&feature=forumtest
    
    Minor Developer/Debug Note: I usually prefer sending a POST for "form submits", but it looks like WHM's template just uses GET on this particular dofeaturemanger URL. In most cases either should work, but on occasions I've notice some other, very specific, functions only take input properly from one or the other, not both. <shrug />

    2) edit the list appropriately using the edit scenario below​


    Scenario: retrieve a list of feature lists
    1) load https://$server:2087/scripts2/featuremanager
    2) find the select HTML element named "feature"
    Code:
    <select name="feature">
      <option value="default">default</option>
      <option value="disabled">disabled</option>
      <option value="forumtest">forumtest</option>
    </select>
    
    3) parse the option HTML elements for their value attribute (not innerHTML)​


    Scenario edit a list
    1) prepare a list of features you want included in a particular list into a URL query string, where "feature" is the featurelist that can be included for a package and all features that should be enabled are equal to 1. (your can get the mast list of features using the getfeaturlist XML-API call)
    Code:
    feature=forumtest&php-config=1&addoncgi=1&updatecontact=1&clamavconnector_scan=1&webdisk=1&webmail=1
    // The string above will add "php-config", "addoncgi", "updatecontact", "virsus scanner", "webdisk" and "webmail" to the "forumtest" featurelist
    
    2) submit a POST request to https://$server:2087/scripts2/savefeatures with the parameters from step #1​


    It's pretty much just utilizing the cURL and DOM libraries for your particular scripting language.

    NOTE TO ALL: cPanel DOES NOT SUPPORT THIS. I've seen many people suggest doing stuff like this as "commonplace" practice. I whole-heartedly DISAGREE. Script against a UI is fragile. UIs can change without notice; they can often have validators or required JS (which is difficult to handle in a scripted browser agent accurately and consistently). Scripts like ones I discuss above should be as a last resort. And any implementation of this should be a pluggable library or interface within your own application. That way, when the proper cPanel/WHM API call IS available, you can just make a new class/pluggable-object/function-set that is loaded instead your macro and the rest of you script/application is none the wiser (that the remote server communication is using a "real" API call instead of the browser-based macro).

    Best Regards,
    -DavidN
     
Loading...

Share This Page