lumberg 1.0.1 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +1 -1
- data/README.md +184 -70
- data/Rakefile +3 -1
- data/lib/lumberg/config.rb +19 -0
- data/lib/lumberg/cpanel/addon_domain.rb +50 -0
- data/lib/lumberg/cpanel/backups.rb +16 -0
- data/lib/lumberg/cpanel/base.rb +56 -0
- data/lib/lumberg/cpanel/box_trapper.rb +18 -0
- data/lib/lumberg/cpanel/branding.rb +89 -0
- data/lib/lumberg/cpanel/contact.rb +38 -0
- data/lib/lumberg/cpanel/cron.rb +89 -0
- data/lib/lumberg/cpanel/dns_lookup.rb +23 -0
- data/lib/lumberg/cpanel/domain_keys.rb +37 -0
- data/lib/lumberg/cpanel/domain_lookup.rb +71 -0
- data/lib/lumberg/cpanel/email.rb +522 -0
- data/lib/lumberg/cpanel/file_manager.rb +146 -0
- data/lib/lumberg/cpanel/ftp.rb +101 -0
- data/lib/lumberg/cpanel/gpg.rb +36 -0
- data/lib/lumberg/cpanel/locale.rb +15 -0
- data/lib/lumberg/cpanel/mime.rb +34 -0
- data/lib/lumberg/cpanel/mysql.rb +66 -0
- data/lib/lumberg/cpanel/mysql_db.rb +190 -0
- data/lib/lumberg/cpanel/net.rb +28 -0
- data/lib/lumberg/cpanel/park.rb +58 -0
- data/lib/lumberg/cpanel/password.rb +52 -0
- data/lib/lumberg/cpanel/password_strength.rb +63 -0
- data/lib/lumberg/cpanel/random_data.rb +25 -0
- data/lib/lumberg/cpanel/redirect.rb +44 -0
- data/lib/lumberg/cpanel/ssl.rb +220 -0
- data/lib/lumberg/cpanel/sub_domain.rb +61 -0
- data/lib/lumberg/cpanel/support.rb +29 -0
- data/lib/lumberg/cpanel/zone_edit.rb +134 -0
- data/lib/lumberg/cpanel.rb +32 -0
- data/lib/lumberg/format_whm.rb +162 -0
- data/lib/lumberg/version.rb +1 -1
- data/lib/lumberg/whm/account.rb +29 -106
- data/lib/lumberg/whm/base.rb +3 -7
- data/lib/lumberg/whm/cert.rb +88 -0
- data/lib/lumberg/whm/dns.rb +49 -77
- data/lib/lumberg/whm/reseller.rb +25 -118
- data/lib/lumberg/whm/server.rb +163 -222
- data/lib/lumberg/whm/transfer_tool.rb +165 -0
- data/lib/lumberg/whm.rb +11 -9
- data/lib/lumberg/whostmgr/base.rb +13 -0
- data/lib/lumberg/whostmgr/ssl.rb +57 -0
- data/lib/lumberg/whostmgr.rb +6 -0
- data/lib/lumberg.rb +35 -8
- data/spec/config_spec.rb +28 -0
- data/spec/cpanel/addon_domain_spec.rb +84 -0
- data/spec/cpanel/backups_spec.rb +22 -0
- data/spec/cpanel/base_spec.rb +128 -0
- data/spec/cpanel/box_trapper_spec.rb +22 -0
- data/spec/cpanel/branding_spec.rb +46 -0
- data/spec/cpanel/contact_spec.rb +50 -0
- data/spec/cpanel/cron_spec.rb +161 -0
- data/spec/cpanel/dns_lookup_spec.rb +22 -0
- data/spec/cpanel/domain_keys_spec.rb +46 -0
- data/spec/cpanel/domain_lookup_spec.rb +77 -0
- data/spec/cpanel/email_spec.rb +639 -0
- data/spec/cpanel/file_manager_spec.rb +73 -0
- data/spec/cpanel/ftp_spec.rb +71 -0
- data/spec/cpanel/gpg_spec.rb +48 -0
- data/spec/cpanel/locale_spec.rb +23 -0
- data/spec/cpanel/mime_spec.rb +0 -0
- data/spec/cpanel/mysql_db_spec.rb +119 -0
- data/spec/cpanel/mysql_spec.rb +0 -0
- data/spec/cpanel/net_spec.rb +30 -0
- data/spec/cpanel/park_spec.rb +94 -0
- data/spec/cpanel/password_spec.rb +35 -0
- data/spec/cpanel/password_strength_spec.rb +50 -0
- data/spec/cpanel/random_data_spec.rb +24 -0
- data/spec/cpanel/redirect_spec.rb +0 -0
- data/spec/cpanel/ssl_spec.rb +158 -0
- data/spec/cpanel/sub_domain_spec.rb +72 -0
- data/spec/cpanel/support_spec.rb +38 -0
- data/spec/cpanel/zone_edit_spec.rb +0 -0
- data/spec/format_whm_spec.rb +53 -0
- data/spec/sample_certs/cpanel.crt +28 -0
- data/spec/sample_certs/cpanel.key +28 -0
- data/spec/sample_certs/main.crt +27 -0
- data/spec/sample_certs/sample.crt +26 -0
- data/spec/sample_certs/sample.key +27 -0
- data/spec/spec_helper.rb +10 -3
- data/spec/support/cpanel_matchers.rb +17 -0
- data/spec/vcr_cassettes/cpanel/addon_domain/add.yml +77 -0
- data/spec/vcr_cassettes/cpanel/addon_domain/list.yml +77 -0
- data/spec/vcr_cassettes/cpanel/addon_domain/remove.yml +77 -0
- data/spec/vcr_cassettes/cpanel/backups/list.yml +40 -0
- data/spec/vcr_cassettes/cpanel/box_trapper/list.yml +40 -0
- data/spec/vcr_cassettes/cpanel/branding/list_icons.yml +40 -0
- data/spec/vcr_cassettes/cpanel/branding/list_image_types.yml +40 -0
- data/spec/vcr_cassettes/cpanel/branding/list_object_types.yml +40 -0
- data/spec/vcr_cassettes/cpanel/branding/list_pkgs.yml +40 -0
- data/spec/vcr_cassettes/cpanel/branding/list_sprites.yml +40 -0
- data/spec/vcr_cassettes/cpanel/contact/show.yml +40 -0
- data/spec/vcr_cassettes/cpanel/contact/update.yml +40 -0
- data/spec/vcr_cassettes/cpanel/cron/add.yml +77 -0
- data/spec/vcr_cassettes/cpanel/cron/edit.yml +114 -0
- data/spec/vcr_cassettes/cpanel/cron/email.yml +77 -0
- data/spec/vcr_cassettes/cpanel/cron/list.yml +77 -0
- data/spec/vcr_cassettes/cpanel/cron/remove.yml +151 -0
- data/spec/vcr_cassettes/cpanel/cron/set_email.yml +77 -0
- data/spec/vcr_cassettes/cpanel/dns_lookup/name_to_ip.yml +40 -0
- data/spec/vcr_cassettes/cpanel/domain_keys/add.yml +40 -0
- data/spec/vcr_cassettes/cpanel/domain_keys/available.yml +40 -0
- data/spec/vcr_cassettes/cpanel/domain_keys/installed.yml +40 -0
- data/spec/vcr_cassettes/cpanel/domain_keys/remove.yml +40 -0
- data/spec/vcr_cassettes/cpanel/domain_lookup/count.yml +40 -0
- data/spec/vcr_cassettes/cpanel/domain_lookup/docroot.yml +40 -0
- data/spec/vcr_cassettes/cpanel/domain_lookup/docroots.yml +40 -0
- data/spec/vcr_cassettes/cpanel/domain_lookup/document_root.yml +40 -0
- data/spec/vcr_cassettes/cpanel/domain_lookup/document_roots.yml +40 -0
- data/spec/vcr_cassettes/cpanel/domain_lookup/list.yml +40 -0
- data/spec/vcr_cassettes/cpanel/email/acceptable_encodings.yml +40 -0
- data/spec/vcr_cassettes/cpanel/email/accounts.yml +188 -0
- data/spec/vcr_cassettes/cpanel/email/add_account.yml +77 -0
- data/spec/vcr_cassettes/cpanel/email/add_filter.yml +77 -0
- data/spec/vcr_cassettes/cpanel/email/add_forwarder.yml +77 -0
- data/spec/vcr_cassettes/cpanel/email/add_mailing_list.yml +73 -0
- data/spec/vcr_cassettes/cpanel/email/add_mx.yml +40 -0
- data/spec/vcr_cassettes/cpanel/email/change_mx.yml +40 -0
- data/spec/vcr_cassettes/cpanel/email/change_password.yml +43 -0
- data/spec/vcr_cassettes/cpanel/email/check_local_delivery_local.yml +77 -0
- data/spec/vcr_cassettes/cpanel/email/check_local_delivery_remote.yml +77 -0
- data/spec/vcr_cassettes/cpanel/email/default_address.yml +40 -0
- data/spec/vcr_cassettes/cpanel/email/delete_mx.yml +40 -0
- data/spec/vcr_cassettes/cpanel/email/disk_usage.yml +77 -0
- data/spec/vcr_cassettes/cpanel/email/domains.yml +40 -0
- data/spec/vcr_cassettes/cpanel/email/domains_with_aliases.yml +77 -0
- data/spec/vcr_cassettes/cpanel/email/edit_quota.yml +112 -0
- data/spec/vcr_cassettes/cpanel/email/filters.yml +114 -0
- data/spec/vcr_cassettes/cpanel/email/forwarders.yml +77 -0
- data/spec/vcr_cassettes/cpanel/email/mail_dir.yml +77 -0
- data/spec/vcr_cassettes/cpanel/email/mail_dirs.yml +77 -0
- data/spec/vcr_cassettes/cpanel/email/mailing_lists.yml +73 -0
- data/spec/vcr_cassettes/cpanel/email/main_discard.yml +40 -0
- data/spec/vcr_cassettes/cpanel/email/mx.yml +40 -0
- data/spec/vcr_cassettes/cpanel/email/remove.yml +77 -0
- data/spec/vcr_cassettes/cpanel/email/set_default_address.yml +43 -0
- data/spec/vcr_cassettes/cpanel/email/set_mail_delivery_local.yml +77 -0
- data/spec/vcr_cassettes/cpanel/email/set_mail_delivery_remote.yml +77 -0
- data/spec/vcr_cassettes/cpanel/email/set_mx_type.yml +40 -0
- data/spec/vcr_cassettes/cpanel/file_manager/disk_usage.yml +38 -0
- data/spec/vcr_cassettes/cpanel/file_manager/list.yml +38 -0
- data/spec/vcr_cassettes/cpanel/file_manager/operate.yml +77 -0
- data/spec/vcr_cassettes/cpanel/file_manager/show.yml +40 -0
- data/spec/vcr_cassettes/cpanel/file_manager/stat.yml +38 -0
- data/spec/vcr_cassettes/cpanel/ftp/addftp.yml +43 -0
- data/spec/vcr_cassettes/cpanel/ftp/delftp.yml +43 -0
- data/spec/vcr_cassettes/cpanel/ftp/listftp.yml +43 -0
- data/spec/vcr_cassettes/cpanel/ftp/listftpsessions.yml +43 -0
- data/spec/vcr_cassettes/cpanel/ftp/listftpwithdisk.yml +95 -0
- data/spec/vcr_cassettes/cpanel/ftp/passwd.yml +43 -0
- data/spec/vcr_cassettes/cpanel/ftp/setquota.yml +43 -0
- data/spec/vcr_cassettes/cpanel/gpg/count.yml +40 -0
- data/spec/vcr_cassettes/cpanel/gpg/count_private.yml +40 -0
- data/spec/vcr_cassettes/cpanel/gpg/list.yml +40 -0
- data/spec/vcr_cassettes/cpanel/gpg/list_private.yml +40 -0
- data/spec/vcr_cassettes/cpanel/locale/show.yml +40 -0
- data/spec/vcr_cassettes/cpanel/mysql_db/add_db.yml +42 -0
- data/spec/vcr_cassettes/cpanel/mysql_db/add_host.yml +42 -0
- data/spec/vcr_cassettes/cpanel/mysql_db/add_user.yml +42 -0
- data/spec/vcr_cassettes/cpanel/mysql_db/add_user_db.yml +42 -0
- data/spec/vcr_cassettes/cpanel/mysql_db/check_db.yml +42 -0
- data/spec/vcr_cassettes/cpanel/mysql_db/del_db.yml +42 -0
- data/spec/vcr_cassettes/cpanel/mysql_db/del_host.yml +42 -0
- data/spec/vcr_cassettes/cpanel/mysql_db/del_user.yml +42 -0
- data/spec/vcr_cassettes/cpanel/mysql_db/del_user_db.yml +42 -0
- data/spec/vcr_cassettes/cpanel/mysql_db/init_cache.yml +42 -0
- data/spec/vcr_cassettes/cpanel/mysql_db/number_of_dbs.yml +42 -0
- data/spec/vcr_cassettes/cpanel/mysql_db/repair_db.yml +42 -0
- data/spec/vcr_cassettes/cpanel/mysql_db/update_privs.yml +42 -0
- data/spec/vcr_cassettes/cpanel/net/query_hostname.yml +40 -0
- data/spec/vcr_cassettes/cpanel/net/traceroute.yml +40 -0
- data/spec/vcr_cassettes/cpanel/park/add.yml +77 -0
- data/spec/vcr_cassettes/cpanel/park/list.yml +77 -0
- data/spec/vcr_cassettes/cpanel/park/list_addon_domains.yml +77 -0
- data/spec/vcr_cassettes/cpanel/park/remove.yml +77 -0
- data/spec/vcr_cassettes/cpanel/password/digest_authentication.yml +77 -0
- data/spec/vcr_cassettes/cpanel/password/modify.yml +77 -0
- data/spec/vcr_cassettes/cpanel/password_strength/all_required_strengths.yml +43 -0
- data/spec/vcr_cassettes/cpanel/password_strength/required_strength.yml +43 -0
- data/spec/vcr_cassettes/cpanel/password_strength/strength.yml +83 -0
- data/spec/vcr_cassettes/cpanel/random_data/show.yml +40 -0
- data/spec/vcr_cassettes/cpanel/ssl/fetchcabundle.yml +40 -0
- data/spec/vcr_cassettes/cpanel/ssl/gencrt.yml +43 -0
- data/spec/vcr_cassettes/cpanel/ssl/gencsr.yml +43 -0
- data/spec/vcr_cassettes/cpanel/ssl/genkey.yml +40 -0
- data/spec/vcr_cassettes/cpanel/ssl/installssl.yml +40 -0
- data/spec/vcr_cassettes/cpanel/ssl/listcrts.yml +40 -0
- data/spec/vcr_cassettes/cpanel/ssl/listcsrs.yml +40 -0
- data/spec/vcr_cassettes/cpanel/ssl/listkeys.yml +40 -0
- data/spec/vcr_cassettes/cpanel/ssl/listsslitems.yml +40 -0
- data/spec/vcr_cassettes/cpanel/ssl/remove.yml +43 -0
- data/spec/vcr_cassettes/cpanel/ssl/showcrt.yml +38 -0
- data/spec/vcr_cassettes/cpanel/ssl/showcsr.yml +38 -0
- data/spec/vcr_cassettes/cpanel/ssl/showkey.yml +38 -0
- data/spec/vcr_cassettes/cpanel/ssl/uploadcrt.yml +40 -0
- data/spec/vcr_cassettes/cpanel/sub_domain/add.yml +77 -0
- data/spec/vcr_cassettes/cpanel/sub_domain/list.yml +77 -0
- data/spec/vcr_cassettes/cpanel/sub_domain/remove.yml +77 -0
- data/spec/vcr_cassettes/cpanel/support/contactable.yml +40 -0
- data/spec/vcr_cassettes/whm/account/accountsummary.yml +41 -29
- data/spec/vcr_cassettes/whm/account/changepackage.yml +73 -43
- data/spec/vcr_cassettes/whm/account/createacct.yml +101 -31
- data/spec/vcr_cassettes/whm/account/domainuserdata.yml +43 -29
- data/spec/vcr_cassettes/whm/account/editquota.yml +78 -57
- data/spec/vcr_cassettes/whm/account/limitbw.yml +79 -57
- data/spec/vcr_cassettes/whm/account/listaccts.yml +195 -100
- data/spec/vcr_cassettes/whm/account/listsuspended.yml +41 -29
- data/spec/vcr_cassettes/whm/account/modifyacct.yml +61 -42
- data/spec/vcr_cassettes/whm/account/myprivs.yml +41 -29
- data/spec/vcr_cassettes/whm/account/passwd.yml +44 -29
- data/spec/vcr_cassettes/whm/account/removeacct.yml +134 -57
- data/spec/vcr_cassettes/whm/account/restoreaccount.yml +310 -135
- data/spec/vcr_cassettes/whm/account/setsiteip.yml +166 -127
- data/spec/vcr_cassettes/whm/account/suspend.yml +75 -43
- data/spec/vcr_cassettes/whm/account/unsuspend.yml +46 -29
- data/spec/vcr_cassettes/whm/cert/fetch_ssl_vhosts.yml +44 -0
- data/spec/vcr_cassettes/whm/cert/fetchsslinfo.yml +38 -0
- data/spec/vcr_cassettes/whm/cert/generatessl.yml +94 -0
- data/spec/vcr_cassettes/whm/cert/installssl.yml +38 -0
- data/spec/vcr_cassettes/whm/cert/listcrts.yml +38 -0
- data/spec/vcr_cassettes/whm/dns/adddns.yml +61 -43
- data/spec/vcr_cassettes/whm/dns/addzonerecord.yml +42 -29
- data/spec/vcr_cassettes/whm/dns/dumpzone.yml +44 -29
- data/spec/vcr_cassettes/whm/dns/editzonerecord.yml +61 -43
- data/spec/vcr_cassettes/whm/dns/getzonerecord.yml +60 -43
- data/spec/vcr_cassettes/whm/dns/killdns.yml +42 -29
- data/spec/vcr_cassettes/whm/dns/listmxs.yml +23 -15
- data/spec/vcr_cassettes/whm/dns/listzones.yml +22 -15
- data/spec/vcr_cassettes/whm/dns/lookupnsip.yml +40 -29
- data/spec/vcr_cassettes/whm/dns/removezonerecord.yml +61 -43
- data/spec/vcr_cassettes/whm/dns/resetzone.yml +42 -29
- data/spec/vcr_cassettes/whm/dns/resolvedomainname.yml +40 -29
- data/spec/vcr_cassettes/whm/dns/savemxs.yml +23 -15
- data/spec/vcr_cassettes/whm/reseller/acctcounts.yml +41 -29
- data/spec/vcr_cassettes/whm/reseller/listacls.yml +22 -15
- data/spec/vcr_cassettes/whm/reseller/listresellers.yml +22 -15
- data/spec/vcr_cassettes/whm/reseller/resellerstats.yml +42 -29
- data/spec/vcr_cassettes/whm/reseller/saveacllist.yml +76 -57
- data/spec/vcr_cassettes/whm/reseller/setacls.yml +40 -29
- data/spec/vcr_cassettes/whm/reseller/setresellerips.yml +42 -28
- data/spec/vcr_cassettes/whm/reseller/setresellerlimits.yml +41 -29
- data/spec/vcr_cassettes/whm/reseller/setresellermainip.yml +59 -43
- data/spec/vcr_cassettes/whm/reseller/setresellernameservers.yml +58 -43
- data/spec/vcr_cassettes/whm/reseller/setresellerpackagelimit.yml +61 -43
- data/spec/vcr_cassettes/whm/reseller/setupreseller.yml +41 -29
- data/spec/vcr_cassettes/whm/reseller/suspendreseller.yml +75 -44
- data/spec/vcr_cassettes/whm/reseller/terminatereseller.yml +83 -46
- data/spec/vcr_cassettes/whm/reseller/unsetupreseller.yml +41 -29
- data/spec/vcr_cassettes/whm/reseller/unsuspendreseller.yml +46 -29
- data/spec/vcr_cassettes/whm/server/addip.yml +24 -15
- data/spec/vcr_cassettes/whm/server/applist.yml +22 -15
- data/spec/vcr_cassettes/whm/server/delip.yml +23 -15
- data/spec/vcr_cassettes/whm/server/disk_usage.yml +45 -0
- data/spec/vcr_cassettes/whm/server/edit_hook.yml +44 -0
- data/spec/vcr_cassettes/whm/server/gethostname.yml +22 -15
- data/spec/vcr_cassettes/whm/server/getlanglist.yml +22 -15
- data/spec/vcr_cassettes/whm/server/gettweaksetting.yml +44 -0
- data/spec/vcr_cassettes/whm/server/list_hooks.yml +44 -0
- data/spec/vcr_cassettes/whm/server/listips.yml +22 -15
- data/spec/vcr_cassettes/whm/server/loadavg.yml +26 -19
- data/spec/vcr_cassettes/whm/server/lookup_nameserver_ip.yml +44 -0
- data/spec/vcr_cassettes/whm/server/my_function.yml +59 -43
- data/spec/vcr_cassettes/whm/server/nvget.yml +22 -15
- data/spec/vcr_cassettes/whm/server/nvset.yml +22 -15
- data/spec/vcr_cassettes/whm/server/reboot.yml +22 -15
- data/spec/vcr_cassettes/whm/server/sethostname.yml +24 -15
- data/spec/vcr_cassettes/whm/server/setresolvers.yml +23 -15
- data/spec/vcr_cassettes/whm/server/settweaksetting.yml +44 -0
- data/spec/vcr_cassettes/whm/server/showbw.yml +22 -15
- data/spec/vcr_cassettes/whm/server/systemloadavg.yml +40 -29
- data/spec/vcr_cassettes/whm/server/themes.yml +38 -0
- data/spec/vcr_cassettes/whm/server/version.yml +22 -15
- data/spec/vcr_cassettes/whm/transfer_tool/check.yml +44 -0
- data/spec/vcr_cassettes/whm/transfer_tool/create.yml +72 -0
- data/spec/vcr_cassettes/whm/transfer_tool/enqueue.yml +44 -0
- data/spec/vcr_cassettes/whm/transfer_tool/pause.yml +44 -0
- data/spec/vcr_cassettes/whm/transfer_tool/show_log.yml +44 -0
- data/spec/vcr_cassettes/whm/transfer_tool/start.yml +44 -0
- data/spec/vcr_cassettes/whm/transfer_tool/status.yml +44 -0
- data/spec/vcr_cassettes/whm/transfer_tool/validate_user.yml +44 -0
- data/spec/vcr_cassettes/whostmgr/ssl/create.yml +219 -0
- data/spec/vcr_cassettes/whostmgr/ssl/remove.yml +172 -0
- data/spec/vcr_cassettes/whostmgr/ssl/remove_data.yml +179 -0
- data/spec/whm/account_spec.rb +90 -249
- data/spec/whm/base_spec.rb +3 -7
- data/spec/whm/cert_spec.rb +110 -0
- data/spec/whm/dns_spec.rb +37 -155
- data/spec/whm/reseller_spec.rb +46 -114
- data/spec/whm/server_spec.rb +142 -156
- data/spec/whm/transfer_tool_spec.rb +172 -0
- data/spec/whm/whm_spec.rb +8 -8
- data/spec/whostmgr/ssl_spec.rb +55 -0
- metadata +528 -108
- data/.gitignore +0 -10
- data/.rspec +0 -2
- data/.rvmrc +0 -49
- data/.travis.yml +0 -11
- data/lib/lumberg/whm/args.rb +0 -113
- data/lib/net_http_hacked.rb +0 -42
- data/lumberg.gemspec +0 -28
- data/spec/vcr_cassettes/whm/server/response_type.yml +0 -85
- data/spec/whm/args_spec.rb +0 -179
@@ -0,0 +1,44 @@
|
|
1
|
+
module Lumberg
|
2
|
+
module Cpanel
|
3
|
+
# Public: Allows users to create and manage redirects
|
4
|
+
class Redirect < Base
|
5
|
+
def self.api_module; "Mime"; end
|
6
|
+
|
7
|
+
# Public: List redirects parsed from your various .htaccess files in
|
8
|
+
# human-readable form
|
9
|
+
#
|
10
|
+
# options - Hash options for API call params (default: {})
|
11
|
+
# :regex - String value to filter results by applying perl regurlar
|
12
|
+
# expressions to the "sourceurl" output key, and accepts a
|
13
|
+
# simple string also (default: '')
|
14
|
+
#
|
15
|
+
# Returns Hash API response
|
16
|
+
def list(options = {})
|
17
|
+
perform_request({ api_function: 'listredirects' }.merge(options))
|
18
|
+
end
|
19
|
+
|
20
|
+
# Public: This function returns either the domain name entered or '** All
|
21
|
+
# Public Domains **'.
|
22
|
+
#
|
23
|
+
# options - Hash options for API call params (default: {})
|
24
|
+
# :domain - String value. If a domain name is entered, it will be
|
25
|
+
# returned. If this is set to '.*', '** All Public Domains **'
|
26
|
+
# will be returned. (default: '')
|
27
|
+
# :url - String value. If a url is entered, it will be returned. If this
|
28
|
+
# is set to '.*' or '(.*)', '** All Requests **' will be
|
29
|
+
# returned (default: '')
|
30
|
+
#
|
31
|
+
# Returns Hash API response
|
32
|
+
def show(options = {})
|
33
|
+
if options[:domain] && options[:url]
|
34
|
+
raise ArgumentError,
|
35
|
+
"#{self.class.name}##{__method__} cannot accept both `:url` and `:domain`"
|
36
|
+
end
|
37
|
+
function = options[:domain].present? ? 'redirectname' : 'redirecturlname'
|
38
|
+
perform_request({ api_function: function }.merge(options))
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
|
@@ -0,0 +1,220 @@
|
|
1
|
+
module Lumberg
|
2
|
+
module Cpanel
|
3
|
+
class Ssl < Base
|
4
|
+
def self.api_module; "SSL"; end
|
5
|
+
|
6
|
+
# Public: Install an SSL certificate, key, and cabundle.
|
7
|
+
#
|
8
|
+
# options - Hash options for API call params (default: {}):
|
9
|
+
# :cabundle - Contents of the CA bundle file (optional)
|
10
|
+
# :crt - Contents of the certificate file
|
11
|
+
# :domain - Domain name for the cert (optional)
|
12
|
+
# :key - Contents of the key file associated with the CSR
|
13
|
+
# :subject - String subject line.
|
14
|
+
#
|
15
|
+
# Returns Hash API response.
|
16
|
+
def installssl(options = {})
|
17
|
+
perform_request({
|
18
|
+
api_function: "installssl"
|
19
|
+
}.merge(options))
|
20
|
+
end
|
21
|
+
|
22
|
+
# Public: List CSRs associated with your cPanel account.
|
23
|
+
#
|
24
|
+
# options - Hash options for API call params (default: {}):
|
25
|
+
#
|
26
|
+
# Returns Hash API response.
|
27
|
+
def listcsrs(options = {})
|
28
|
+
perform_request({
|
29
|
+
api_function: "listcsrs",
|
30
|
+
}.merge(options))
|
31
|
+
end
|
32
|
+
|
33
|
+
# Public: Print a specific Certificate Signing Request.
|
34
|
+
#
|
35
|
+
# options - Hash options for API call params (default: {}):
|
36
|
+
# :domain - The name of the domain the CSR was generated for.
|
37
|
+
# :textmode - 0 for human readable, 1 for binary.
|
38
|
+
#
|
39
|
+
# Returns Hash API response.
|
40
|
+
def showcsr(options = {})
|
41
|
+
perform_request({
|
42
|
+
api_function: "showcsr",
|
43
|
+
api_version: 1,
|
44
|
+
user: options[:user],
|
45
|
+
response_key: "data",
|
46
|
+
"arg-0" => options[:domain],
|
47
|
+
"arg-1" => options[:textmode]
|
48
|
+
})
|
49
|
+
end
|
50
|
+
|
51
|
+
# Public: Print a key that has already been generated.
|
52
|
+
#
|
53
|
+
# options - Hash options for API call params (default: {}):
|
54
|
+
# :domain - The name of the domain the CSR was generated for.
|
55
|
+
# :textmode - 0 for human readable, 1 for binary.
|
56
|
+
#
|
57
|
+
# Returns Hash API response.
|
58
|
+
def showkey(options = {})
|
59
|
+
perform_request({
|
60
|
+
api_function: "showkey",
|
61
|
+
api_version: 1,
|
62
|
+
user: options[:user],
|
63
|
+
response_key: "data",
|
64
|
+
"arg-0" => options[:domain],
|
65
|
+
"arg-1" => options[:textmode]
|
66
|
+
})
|
67
|
+
end
|
68
|
+
|
69
|
+
# Public: Print the current cert for a specific host.
|
70
|
+
#
|
71
|
+
# options - Hash options for API call params (default: {}):
|
72
|
+
#
|
73
|
+
# Returns Hash API response.
|
74
|
+
def showcrt(options = {})
|
75
|
+
perform_request({
|
76
|
+
api_function: "showcrt",
|
77
|
+
api_version: 1,
|
78
|
+
user: options[:user],
|
79
|
+
response_key: "data",
|
80
|
+
"arg-0" => options[:domain],
|
81
|
+
"arg-1" => options[:textmode]
|
82
|
+
})
|
83
|
+
end
|
84
|
+
|
85
|
+
# Public: List SSL certificates currently installed for a cPanel account.
|
86
|
+
#
|
87
|
+
# options - Hash options for API call params (default: {}):
|
88
|
+
#
|
89
|
+
# Returns Hash API response.
|
90
|
+
def listcrts(options = {})
|
91
|
+
perform_request({
|
92
|
+
api_function: "listcrts",
|
93
|
+
}.merge(options))
|
94
|
+
end
|
95
|
+
|
96
|
+
# Public: List SSL keys associated with a domain.
|
97
|
+
#
|
98
|
+
# options - Hash options for API call params (default: {}):
|
99
|
+
#
|
100
|
+
# Returns Hash API response.
|
101
|
+
def listkeys(options = {})
|
102
|
+
perform_request({
|
103
|
+
api_function: "listkeys",
|
104
|
+
}.merge(options))
|
105
|
+
end
|
106
|
+
|
107
|
+
# Public: Fetch the cabundle that corresponds to the certificate
|
108
|
+
#
|
109
|
+
# options - Hash options for API call params (default: {}):
|
110
|
+
# :crt - Contents of the certificate file
|
111
|
+
#
|
112
|
+
# Returns Hash API response.
|
113
|
+
def fetchcabundle(options = {})
|
114
|
+
perform_request({
|
115
|
+
api_function: "fetchcabundle",
|
116
|
+
}.merge(options))
|
117
|
+
end
|
118
|
+
|
119
|
+
# Public: Query for SSL related items installed via cPanel
|
120
|
+
#
|
121
|
+
# options - Hash options for API call params (default: {}):
|
122
|
+
# :domains - The domains you wish to query.
|
123
|
+
# :items - The type of SSL items for which you wish to query.
|
124
|
+
# Acceptable values include 'key', 'crt', and 'csr'.
|
125
|
+
#
|
126
|
+
# Returns Hash API response.
|
127
|
+
def listsslitems(options = {})
|
128
|
+
perform_request({
|
129
|
+
api_function: "listsslitems",
|
130
|
+
}.merge(options))
|
131
|
+
end
|
132
|
+
|
133
|
+
# Public: Generate a certificate signing request.
|
134
|
+
#
|
135
|
+
# options - Hash options for API call params (default: {}):
|
136
|
+
# :city - The city in which your server resides.
|
137
|
+
# :company - The name of the company.
|
138
|
+
# :company_division - The division of your company.
|
139
|
+
# :country - A two letter abbreviation for the country.
|
140
|
+
# :email - A valid email address that will correspond to
|
141
|
+
# the certificate signing request
|
142
|
+
# :host - The domain that corresponds to the csr.
|
143
|
+
# :state - A two letter abbreviation that corresponds to the
|
144
|
+
# state.
|
145
|
+
# :pass - The password of the csr.
|
146
|
+
#
|
147
|
+
# Returns Hash API response.
|
148
|
+
def gencsr(options = {})
|
149
|
+
options[:companydivision] = options.delete(:company_division)
|
150
|
+
|
151
|
+
perform_request({
|
152
|
+
api_function: "gencsr",
|
153
|
+
response_key: "cpanelresult",
|
154
|
+
}.merge(options))
|
155
|
+
end
|
156
|
+
|
157
|
+
# Public: Generate a self-signed SSL certificate for a specific domain.
|
158
|
+
#
|
159
|
+
# options - Hash options for API call params (default: {}):
|
160
|
+
# :city - The city in which your server resides.
|
161
|
+
# :company - The name of the company.
|
162
|
+
# :company_division - The division of your company.
|
163
|
+
# :country - A two letter abbreviation for the country.
|
164
|
+
# :email - A valid email address that will correspond to
|
165
|
+
# the certificate signing request
|
166
|
+
# :host - The domain that corresponds to the csr.
|
167
|
+
# :state - A two letter abbreviation that corresponds to the
|
168
|
+
# state.
|
169
|
+
#
|
170
|
+
# Returns Hash API response.
|
171
|
+
def gencrt(options = {})
|
172
|
+
options[:companydivision] = options.delete(:company_division)
|
173
|
+
|
174
|
+
perform_request({
|
175
|
+
api_function: "gencrt",
|
176
|
+
}.merge(options))
|
177
|
+
end
|
178
|
+
|
179
|
+
# Public: Generate an SSL key. You must have access to the 'sslmanager'.
|
180
|
+
#
|
181
|
+
# options - Hash options for API call params (default: {}):
|
182
|
+
# :host - The domain that corresponds to the csr.
|
183
|
+
# :keysize - The size of the key
|
184
|
+
# Optional, may range from 1024 to 4096.
|
185
|
+
#
|
186
|
+
# Returns Hash API response.
|
187
|
+
def genkey(options = {})
|
188
|
+
perform_request({
|
189
|
+
api_function: "genkey",
|
190
|
+
}.merge(options))
|
191
|
+
end
|
192
|
+
|
193
|
+
# Public: Upload an SSL certificate.
|
194
|
+
#
|
195
|
+
# options - Hash options for API call params (default: {}):
|
196
|
+
# :crt - Contents of the SSL certificate
|
197
|
+
#
|
198
|
+
# Returns Hash API response.
|
199
|
+
def uploadcrt(options = {})
|
200
|
+
perform_request({
|
201
|
+
api_function: "uploadcrt",
|
202
|
+
}.merge(options))
|
203
|
+
end
|
204
|
+
|
205
|
+
# Public: Removes a domain's SSL certificate. This function requires
|
206
|
+
# access to the 'sslinstall' feature
|
207
|
+
#
|
208
|
+
# options - Hash options for API call params (default: {})
|
209
|
+
# domain: String domain corresponding to the SSL certificate
|
210
|
+
# to remove
|
211
|
+
#
|
212
|
+
# Returns Hash API response
|
213
|
+
def remove(options = {})
|
214
|
+
perform_request({
|
215
|
+
api_version: 1, api_function: "delete", response_key: "data"
|
216
|
+
}.merge(options))
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
220
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module Lumberg
|
2
|
+
module Cpanel
|
3
|
+
class SubDomain < Base
|
4
|
+
# Public: Add a subdomain.
|
5
|
+
#
|
6
|
+
# options - Hash options for API call params (default: {}):
|
7
|
+
# :domain - String local part of the subdomain to add.
|
8
|
+
# "sub" if "sub.domain.com".
|
9
|
+
# :rootdomain - String domain on which to add the subdomain.
|
10
|
+
# :dir - String docroot for subdomain (optional, default:
|
11
|
+
# "public_html/[:domain value]")
|
12
|
+
# :disallowdot - String value (optional). Set to "1" to strip "."
|
13
|
+
# chars from specified :domain value.
|
14
|
+
#
|
15
|
+
# Returns Hash API response.
|
16
|
+
def add(options = {})
|
17
|
+
perform_request({
|
18
|
+
api_function: "addsubdomain"
|
19
|
+
}.merge(options))
|
20
|
+
end
|
21
|
+
|
22
|
+
# Public: Remove a subdomain.
|
23
|
+
#
|
24
|
+
# options - Hash options for API call params (default: {}):
|
25
|
+
# :domain - String subdomain to delete.
|
26
|
+
#
|
27
|
+
# Returns Hash API response.
|
28
|
+
def remove(options = {})
|
29
|
+
perform_request({
|
30
|
+
api_function: "delsubdomain"
|
31
|
+
}.merge(options))
|
32
|
+
end
|
33
|
+
|
34
|
+
# Public: Get list of subdomains.
|
35
|
+
#
|
36
|
+
# options - Hash options for API call params (default: {}):
|
37
|
+
# :regex - String regular expression to filter results (optional).
|
38
|
+
#
|
39
|
+
# Returns Hash API response.
|
40
|
+
def list(options = {})
|
41
|
+
perform_request({
|
42
|
+
api_function: "listsubdomains"
|
43
|
+
}.merge(options))
|
44
|
+
end
|
45
|
+
|
46
|
+
# Public: Modify the document root of a subdomain
|
47
|
+
#
|
48
|
+
# options - Hash options for API call params (default: {}):
|
49
|
+
# :dir - String docroot to which you want to move the subdomain
|
50
|
+
# :subdomain - String subdomain whose docroot you want to modify
|
51
|
+
# :rootdomain - String domain on which to modify the subdomain
|
52
|
+
#
|
53
|
+
# Returns Hash API response
|
54
|
+
def modify(options = {})
|
55
|
+
perform_request({
|
56
|
+
api_function: "changedocroot"
|
57
|
+
}.merge(options))
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Lumberg
|
2
|
+
module Cpanel
|
3
|
+
class Support < Base
|
4
|
+
def self.api_module; "Contactus"; end
|
5
|
+
|
6
|
+
# Public: Send a support request.
|
7
|
+
#
|
8
|
+
# options - Hash options for API call params (default: {}):
|
9
|
+
# :email - String destination email address.
|
10
|
+
# :issue - String brief explantation of issue (body text).
|
11
|
+
# :subject - String subject line.
|
12
|
+
#
|
13
|
+
# Returns Hash API response.
|
14
|
+
def open_ticket(options = {})
|
15
|
+
perform_request({
|
16
|
+
api_function: "sendcontact"
|
17
|
+
}.merge(options))
|
18
|
+
end
|
19
|
+
|
20
|
+
# Public: Check if you can open a support ticket, or if you are able to
|
21
|
+
# contact your hosting provider through Cpanel
|
22
|
+
#
|
23
|
+
# Returns Hash API response
|
24
|
+
def contactable
|
25
|
+
perform_request({ api_function: "isenabled" })
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,134 @@
|
|
1
|
+
module Lumberg
|
2
|
+
module Cpanel
|
3
|
+
# Public: This module allows users to modify their domains
|
4
|
+
class ZoneEdit < Base
|
5
|
+
# Public: Retrieve a list of your account's zones and zone file contents.
|
6
|
+
#
|
7
|
+
# Returns Hash API Response
|
8
|
+
def list
|
9
|
+
perform_request({ api_function: 'fetchzones' })
|
10
|
+
end
|
11
|
+
|
12
|
+
# Public: Add an A, CNAME, or TXT record to a zone file, specified by
|
13
|
+
# line number
|
14
|
+
#
|
15
|
+
# options - Hash options for API call params (default: {})
|
16
|
+
# :domain - String addon domain for which yo wish to add an entry
|
17
|
+
# :name - String name of the record, aka subdomain
|
18
|
+
# :type - String type of the record you wish to add to the zone file.
|
19
|
+
# Acceptable values include A, CNAME or TXT
|
20
|
+
# :txt - String text you wish to contain in your TXT record. Required
|
21
|
+
# parameter when you specify "TXT" in the :type parameter
|
22
|
+
# (default: '')
|
23
|
+
# :cname - String required parameter when you specify CNAME in the
|
24
|
+
# :type parameter (default: '')
|
25
|
+
# :address - String ip address to map to the subdomain. (default: '')
|
26
|
+
# :ttl - Integer time to live in seconds (default: 0)
|
27
|
+
# :class - String class to be used for the record. Ordinarily this
|
28
|
+
# parameter is not required (default: '')
|
29
|
+
#
|
30
|
+
# Returns Hash API response.
|
31
|
+
def create(options = {})
|
32
|
+
options[:txtdata] = options.delete(:txt)
|
33
|
+
perform_request({ api_function: 'add_zone_record' }.merge(options))
|
34
|
+
end
|
35
|
+
|
36
|
+
# Public: Show dns zone for a domain
|
37
|
+
#
|
38
|
+
# options - Hash options for API call params (default: {})
|
39
|
+
# :domain - String domain that corresponds to the zone file you wish to
|
40
|
+
# show
|
41
|
+
# :get_custom_entries - Boolean parameter. Entering a value of "1" will
|
42
|
+
# cause the function to return only non-essential
|
43
|
+
# A and CNAME records. These will include www.*,
|
44
|
+
# ftp.*, mail.* and localhost.* (default: '')
|
45
|
+
# :keys - String parameter that may contain a serie of values, all of
|
46
|
+
# which act the same way. Each value searches the data
|
47
|
+
# structure, like a grep, for a single hash (line of the zone
|
48
|
+
# file). Acceptable values include: line, ttl, name, class,
|
49
|
+
# address, type, txtdata, preference and exchange.
|
50
|
+
#
|
51
|
+
# Returns Hash API response.
|
52
|
+
def show(options = {})
|
53
|
+
options[:customonly] = options.delete(:get_custom_entries)
|
54
|
+
perform_request({ api_function: 'fetchzone' }.merge(options))
|
55
|
+
end
|
56
|
+
|
57
|
+
# Public: Revert a zone file to its original state.
|
58
|
+
#
|
59
|
+
# options - Hash options for API call params (default: {})
|
60
|
+
# :domain - String domain that corresponds to the zone file you wish to
|
61
|
+
# revert
|
62
|
+
#
|
63
|
+
# Returns Hash API response
|
64
|
+
def reset(options = {})
|
65
|
+
perform_request({ api_function: 'resetzone' })
|
66
|
+
end
|
67
|
+
|
68
|
+
# Public: Edit an A, CNAME, or TXT record in a zone file, specified by
|
69
|
+
# line number. This function works nicely with "show" method to easily
|
70
|
+
# fetch line number and record information.
|
71
|
+
#
|
72
|
+
# options - Hash options for API call params (default: {})
|
73
|
+
# :domain - String domain that corresponds to the zone you wish to edit
|
74
|
+
# :line - Integer line number of the zone file you wish to edit
|
75
|
+
# :type - The type fo record you wish to add to the zone file.
|
76
|
+
# Acceptable values include A, CNAME or TXT. Each type of
|
77
|
+
# record requires a specific parameter
|
78
|
+
# :txt - String text you wish to contain in your TXT record. Required
|
79
|
+
# parameter when you specify "TXT" in the :type parameter
|
80
|
+
# (default: '')
|
81
|
+
# :cname - String required parameter when you specify CNAME in the
|
82
|
+
# :type parameter (default: '')
|
83
|
+
# :address - String ip address to map to the subdomain. (default: '')
|
84
|
+
# :ttl - Integer time to live in seconds (default: 0)
|
85
|
+
# :class - String class to be used for the record. Ordinarily this
|
86
|
+
# parameter is not required (default: '')
|
87
|
+
#
|
88
|
+
# Returns Hash API response.
|
89
|
+
def edit(options = {})
|
90
|
+
options[:Line] = options.delete(:line)
|
91
|
+
options[:txtdata] = options.delete(:txt)
|
92
|
+
perform_request({ api_function: 'edit_zone_record' }.merge(options))
|
93
|
+
end
|
94
|
+
|
95
|
+
# Public: Remove lines from a DNS zone file. You may only remove A, TXT,
|
96
|
+
# and CNAME records with this function.
|
97
|
+
#
|
98
|
+
# options - Hash options for API call params (default: {})
|
99
|
+
# :domain - String domain that corresponds to the zone you wish to
|
100
|
+
# remove a line
|
101
|
+
# :line - Integer line number of the zone file you wish to remove. Use
|
102
|
+
# "show" method to obtain the line number of a record
|
103
|
+
#
|
104
|
+
# Returns Hash API response.
|
105
|
+
def remove(options = {})
|
106
|
+
perform_request({ api_function: 'remove_zone_record' }.merge(options))
|
107
|
+
end
|
108
|
+
|
109
|
+
# Public: Retrieve a list of domains, created within cPanel, associated
|
110
|
+
# with your cPanel account.
|
111
|
+
#
|
112
|
+
# options - Hash options for API call params (default: {})
|
113
|
+
# :domain - String domain parameter which allows you to append one
|
114
|
+
# domain name to the end of the resulting output
|
115
|
+
# (default: '')
|
116
|
+
#
|
117
|
+
# Returns Hash API response.
|
118
|
+
def show_domains(options = {})
|
119
|
+
perform_request({ api_function: 'fetch_cpanel_generated_domains' })
|
120
|
+
end
|
121
|
+
|
122
|
+
# Public: Retrieve a list of zone modifications for a specific domain.
|
123
|
+
#
|
124
|
+
# options - Hash options for API call params (default: {})
|
125
|
+
# :domain - String domain whose zone modifications you wish to view
|
126
|
+
#
|
127
|
+
# Returns Hash API response.
|
128
|
+
def modifications_for(options = {})
|
129
|
+
perform_request({ api_function: 'fetchzone_records' }.merge(options))
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Lumberg
|
2
|
+
module Cpanel
|
3
|
+
require "lumberg/cpanel/base"
|
4
|
+
require "lumberg/cpanel/addon_domain"
|
5
|
+
require "lumberg/cpanel/sub_domain"
|
6
|
+
require "lumberg/cpanel/park"
|
7
|
+
require "lumberg/cpanel/email"
|
8
|
+
require "lumberg/cpanel/backups"
|
9
|
+
require "lumberg/cpanel/box_trapper"
|
10
|
+
require "lumberg/cpanel/branding"
|
11
|
+
require "lumberg/cpanel/contact"
|
12
|
+
require "lumberg/cpanel/cron"
|
13
|
+
require "lumberg/cpanel/ssl"
|
14
|
+
require "lumberg/cpanel/dns_lookup"
|
15
|
+
require "lumberg/cpanel/domain_lookup"
|
16
|
+
require "lumberg/cpanel/password"
|
17
|
+
require "lumberg/cpanel/password_strength"
|
18
|
+
require "lumberg/cpanel/file_manager"
|
19
|
+
require "lumberg/cpanel/zone_edit"
|
20
|
+
require "lumberg/cpanel/support"
|
21
|
+
require "lumberg/cpanel/random_data"
|
22
|
+
require "lumberg/cpanel/net"
|
23
|
+
require "lumberg/cpanel/mime"
|
24
|
+
require "lumberg/cpanel/redirect"
|
25
|
+
require "lumberg/cpanel/gpg"
|
26
|
+
require "lumberg/cpanel/locale"
|
27
|
+
require "lumberg/cpanel/mysql"
|
28
|
+
require "lumberg/cpanel/domain_keys"
|
29
|
+
require "lumberg/cpanel/ftp"
|
30
|
+
require "lumberg/cpanel/mysql_db"
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,162 @@
|
|
1
|
+
require 'zlib'
|
2
|
+
|
3
|
+
module Lumberg
|
4
|
+
class FormatWhm < Faraday::Response::Middleware
|
5
|
+
|
6
|
+
def initialize(env, *args, &block)
|
7
|
+
@type = args[0]
|
8
|
+
@key = args[1]
|
9
|
+
@boolean_params = args[2]
|
10
|
+
super(env)
|
11
|
+
end
|
12
|
+
|
13
|
+
def on_complete(env)
|
14
|
+
encoding = env[:response_headers]['content-encoding']
|
15
|
+
|
16
|
+
encoding = encoding.to_s.downcase if encoding
|
17
|
+
|
18
|
+
body = case encoding
|
19
|
+
when 'gzip'
|
20
|
+
env[:response_headers].delete('content-encoding')
|
21
|
+
Zlib::GzipReader.new(StringIO.new(env[:body])).read
|
22
|
+
when 'deflate'
|
23
|
+
env[:response_headers].delete('content-encoding')
|
24
|
+
Zlib::Inflate.inflate(env[:body])
|
25
|
+
else
|
26
|
+
env[:body]
|
27
|
+
end
|
28
|
+
|
29
|
+
env[:body] = format_response body
|
30
|
+
end
|
31
|
+
|
32
|
+
def response_values(env)
|
33
|
+
{status: env[:status], headers: env[:response_headers], body: env[:body]}
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def format_response(response)
|
39
|
+
success, message, params = false, nil, {}
|
40
|
+
|
41
|
+
case @type || response_type(response)
|
42
|
+
when :action
|
43
|
+
success, message, params = format_action_response(response)
|
44
|
+
when :query
|
45
|
+
success, message, params = format_query_response(response)
|
46
|
+
when :ssl
|
47
|
+
success, message, params = format_ssl_response(response)
|
48
|
+
when :whostmgr
|
49
|
+
success, message, params = format_whostmgr_response(response)
|
50
|
+
when :error
|
51
|
+
message = response['error']
|
52
|
+
when :xfer
|
53
|
+
success, message, params = format_xfer_response(response)
|
54
|
+
else
|
55
|
+
message = "Unknown error occurred #{response.inspect}"
|
56
|
+
end
|
57
|
+
|
58
|
+
params = Whm::symbolize_keys(params)
|
59
|
+
params = Whm::to_bool(params, @boolean_params)
|
60
|
+
|
61
|
+
{ success: success, message: message, params: params }
|
62
|
+
end
|
63
|
+
|
64
|
+
def response_type(response)
|
65
|
+
if !response.respond_to?(:has_key?)
|
66
|
+
:unknown
|
67
|
+
elsif response.has_key?('error')
|
68
|
+
:error
|
69
|
+
elsif response.has_key?(@key)
|
70
|
+
:action
|
71
|
+
elsif response.has_key?('status') && response.has_key?('statusmsg')
|
72
|
+
:query
|
73
|
+
else
|
74
|
+
:unknown
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def format_action_response(response)
|
79
|
+
# Some API methods ALSO return a 'status' as
|
80
|
+
# part of a result. We only use this value if it's
|
81
|
+
# part of the results hash
|
82
|
+
item = response[@key]
|
83
|
+
unless item.is_a?(Array) || item.is_a?(Hash)
|
84
|
+
res = {@key => item}
|
85
|
+
success, message = true, ""
|
86
|
+
else
|
87
|
+
result = nil
|
88
|
+
if item.first.is_a?(Hash)
|
89
|
+
result = item.first
|
90
|
+
res = (item.size > 1 ? item.dup : item.first.dup)
|
91
|
+
else
|
92
|
+
res = item.dup
|
93
|
+
|
94
|
+
# more hacks for WHM silly API
|
95
|
+
if response.has_key?('result')
|
96
|
+
result_node = response['result']
|
97
|
+
node_with_key_status = result_node.is_a?(Hash) && result_node.has_key?('status')
|
98
|
+
result = (node_with_key_status ? result_node : result_node.first)
|
99
|
+
else
|
100
|
+
res.delete('status')
|
101
|
+
res.delete('statusmsg')
|
102
|
+
end
|
103
|
+
end
|
104
|
+
unless result.nil?
|
105
|
+
success = result['status'].to_i == 1
|
106
|
+
message = result['statusmsg']
|
107
|
+
end
|
108
|
+
end
|
109
|
+
return success, message, res
|
110
|
+
end
|
111
|
+
|
112
|
+
def format_query_response(response)
|
113
|
+
success = response['status'].to_i == 1
|
114
|
+
message = response['statusmsg']
|
115
|
+
|
116
|
+
# returns the rest as a params arg
|
117
|
+
res = response.dup
|
118
|
+
res.delete('status')
|
119
|
+
res.delete('statusmsg')
|
120
|
+
|
121
|
+
return success, message, res
|
122
|
+
end
|
123
|
+
|
124
|
+
def format_ssl_response(response)
|
125
|
+
if response.has_key?('crt')
|
126
|
+
success = response['crt'].any?
|
127
|
+
message = true
|
128
|
+
res = response['crt']
|
129
|
+
elsif response.has_key?('sslinfo')
|
130
|
+
success = response['sslinfo'].first.fetch('status').to_i == 1
|
131
|
+
message = response['sslinfo'].first.fetch('statusmsg')
|
132
|
+
# returns the rest as a params arg
|
133
|
+
res = response['sslinfo'].first.dup
|
134
|
+
res.delete('status')
|
135
|
+
res.delete('statusmsg')
|
136
|
+
elsif response.has_key?('results')
|
137
|
+
success, message = response['results'].values_at 'status', 'message'
|
138
|
+
# returns the rest as a params arg
|
139
|
+
res = response['results'].dup
|
140
|
+
res.delete('status')
|
141
|
+
res.delete('message')
|
142
|
+
end
|
143
|
+
return success, message, res
|
144
|
+
end
|
145
|
+
|
146
|
+
def format_whostmgr_response(response)
|
147
|
+
message = "successfully deleted|deleted successfully|successfully" \
|
148
|
+
" generated"
|
149
|
+
if res = response.match(/(?<message>#{message})/)
|
150
|
+
return true, res[:message], []
|
151
|
+
else
|
152
|
+
return false, "", []
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
def format_xfer_response(response)
|
157
|
+
metadata = response['metadata']
|
158
|
+
|
159
|
+
return metadata['result'].to_i == 1, metadata['reason'], response['data']
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
data/lib/lumberg/version.rb
CHANGED