CPanelHelper is a Ruby library for interaction with External CPanel XML/JSON API and with CPanel Internal XML APIv2.
It also allows local cpanel information retrieval, such as finding user & domain by supplied query string.
require 'cpanelhelper'
CPanelHelper.configure do |config| config.uri_host = 'https://remote.cpanel.host:2087' config.user = 'root' config.password = 'assword' config.logger = Logger.new($stderr) config.call_type = :json #config.access_hash = open('/root/.accesshash').read # or better use chunk below end
# CPanelHelper::API.load_api_key
# The call interface is as following: # CPanelHelper::API.*function_name*(*:parameter1* => *value1*, *:parameter2* => *value2*, ...) # For "adjusted" functions, see their respective invokation documentation
# retrieve available funcs resp = CPanelHelper::API.applist available_funcs = resp['app']
# search accounts by domain. (This is an "adjusted" function) accounts = CPanelHelper::API.listaccts('domain', 'somedomain.com')
Note that CPanelHelper::API
functions raise CallError
on any critical error.
Please note that CPanelHelper::Local
functions require access to CPanel data files, thus these calls are invoked only locally.
It’s possible to create access hash by invoking CPanelHelper::Local.create_access_hash
method before doing
any local API calls. Be careful as this method will echo back the hash.
- Support calling UAPI functions via
CPanelHelper::API.call_uapi
- introduce
CPanelHelper::Local.get_suspended_users
- show proper way of setting access hash
- reformat the code
get_dominfo_by_user
now able to retrieve remote_mx information if it’s told to
get_dominfo_by_user
now returns whether main domain is on dedicated IP
- bugfix in
get_installed_certificates
- Added
get_installed_certificates
function that returns installed certs