Skip to content

Latest commit

 

History

History
63 lines (42 loc) · 2.13 KB

README.textile

File metadata and controls

63 lines (42 loc) · 2.13 KB

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.

Invoking the API helper

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.

Invoking “local” CPanel functions

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.

Changelog

0.4.1

  • Support calling UAPI functions via CPanelHelper::API.call_uapi

0.3.3

  • introduce CPanelHelper::Local.get_suspended_users

0.3.2

  • show proper way of setting access hash
  • reformat the code

0.3.1

  • get_dominfo_by_user now able to retrieve remote_mx information if it’s told to

0.2.5

  • get_dominfo_by_user now returns whether main domain is on dedicated IP

0.2.2

  • bugfix in get_installed_certificates

0.2.1

  • Added get_installed_certificates function that returns installed certs