lumberg 1.1.1 → 2.0.0.pre3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. checksums.yaml +7 -0
  2. data/.travis.yml +1 -6
  3. data/README.md +130 -23
  4. data/lib/lumberg.rb +2 -0
  5. data/lib/lumberg/cpanel.rb +29 -0
  6. data/lib/lumberg/cpanel/addon_domain.rb +50 -0
  7. data/lib/lumberg/cpanel/backups.rb +16 -0
  8. data/lib/lumberg/cpanel/base.rb +56 -0
  9. data/lib/lumberg/cpanel/box_trapper.rb +18 -0
  10. data/lib/lumberg/cpanel/branding.rb +89 -0
  11. data/lib/lumberg/cpanel/contact.rb +38 -0
  12. data/lib/lumberg/cpanel/cron.rb +89 -0
  13. data/lib/lumberg/cpanel/dns_lookup.rb +23 -0
  14. data/lib/lumberg/cpanel/domain_keys.rb +37 -0
  15. data/lib/lumberg/cpanel/domain_lookup.rb +71 -0
  16. data/lib/lumberg/cpanel/email.rb +491 -0
  17. data/lib/lumberg/cpanel/file_manager.rb +146 -0
  18. data/lib/lumberg/cpanel/gpg.rb +36 -0
  19. data/lib/lumberg/cpanel/locale.rb +15 -0
  20. data/lib/lumberg/cpanel/mime.rb +34 -0
  21. data/lib/lumberg/cpanel/mysql.rb +66 -0
  22. data/lib/lumberg/cpanel/net.rb +28 -0
  23. data/lib/lumberg/cpanel/park.rb +58 -0
  24. data/lib/lumberg/cpanel/password.rb +52 -0
  25. data/lib/lumberg/cpanel/random_data.rb +25 -0
  26. data/lib/lumberg/cpanel/redirect.rb +44 -0
  27. data/lib/lumberg/cpanel/ssl.rb +198 -0
  28. data/lib/lumberg/cpanel/sub_domain.rb +61 -0
  29. data/lib/lumberg/cpanel/support.rb +29 -0
  30. data/lib/lumberg/cpanel/zone_edit.rb +134 -0
  31. data/lib/lumberg/format_whm.rb +24 -1
  32. data/lib/lumberg/version.rb +1 -1
  33. data/lib/lumberg/whm.rb +2 -1
  34. data/lib/lumberg/whm/account.rb +4 -4
  35. data/lib/lumberg/whm/cert.rb +69 -0
  36. data/lib/lumberg/whm/dns.rb +28 -4
  37. data/lib/lumberg/whm/reseller.rb +4 -4
  38. data/lib/lumberg/whm/server.rb +64 -15
  39. data/lumberg.gemspec +4 -3
  40. data/spec/config_spec.rb +2 -2
  41. data/spec/cpanel/addon_domain_spec.rb +84 -0
  42. data/spec/cpanel/backups_spec.rb +22 -0
  43. data/spec/cpanel/base_spec.rb +128 -0
  44. data/spec/cpanel/box_trapper_spec.rb +22 -0
  45. data/spec/cpanel/branding_spec.rb +46 -0
  46. data/spec/cpanel/contact_spec.rb +50 -0
  47. data/spec/cpanel/cron_spec.rb +161 -0
  48. data/spec/cpanel/dns_lookup_spec.rb +22 -0
  49. data/spec/cpanel/domain_keys_spec.rb +46 -0
  50. data/spec/cpanel/domain_lookup_spec.rb +77 -0
  51. data/spec/cpanel/email_spec.rb +615 -0
  52. data/spec/cpanel/file_manager_spec.rb +73 -0
  53. data/spec/cpanel/gpg_spec.rb +48 -0
  54. data/spec/cpanel/locale_spec.rb +23 -0
  55. data/spec/cpanel/mime_spec.rb +0 -0
  56. data/spec/cpanel/mysql_spec.rb +0 -0
  57. data/spec/cpanel/net_spec.rb +30 -0
  58. data/spec/cpanel/park_spec.rb +94 -0
  59. data/spec/cpanel/password_spec.rb +35 -0
  60. data/spec/cpanel/random_data_spec.rb +24 -0
  61. data/spec/cpanel/redirect_spec.rb +0 -0
  62. data/spec/cpanel/ssl_spec.rb +138 -0
  63. data/spec/cpanel/sub_domain_spec.rb +72 -0
  64. data/spec/cpanel/support_spec.rb +38 -0
  65. data/spec/cpanel/zone_edit_spec.rb +0 -0
  66. data/spec/sample_certs/cpanel.crt +28 -0
  67. data/spec/sample_certs/cpanel.key +28 -0
  68. data/spec/sample_certs/main.crt +27 -0
  69. data/spec/sample_certs/sample.crt +26 -0
  70. data/spec/sample_certs/sample.key +27 -0
  71. data/spec/spec_helper.rb +7 -1
  72. data/spec/support/cpanel_matchers.rb +17 -0
  73. data/spec/vcr_cassettes/cpanel/addon_domain/add.yml +77 -0
  74. data/spec/vcr_cassettes/cpanel/addon_domain/list.yml +77 -0
  75. data/spec/vcr_cassettes/cpanel/addon_domain/remove.yml +77 -0
  76. data/spec/vcr_cassettes/cpanel/backups/list.yml +40 -0
  77. data/spec/vcr_cassettes/cpanel/box_trapper/list.yml +40 -0
  78. data/spec/vcr_cassettes/cpanel/branding/list_icons.yml +40 -0
  79. data/spec/vcr_cassettes/cpanel/branding/list_image_types.yml +40 -0
  80. data/spec/vcr_cassettes/cpanel/branding/list_object_types.yml +40 -0
  81. data/spec/vcr_cassettes/cpanel/branding/list_pkgs.yml +40 -0
  82. data/spec/vcr_cassettes/cpanel/branding/list_sprites.yml +40 -0
  83. data/spec/vcr_cassettes/cpanel/contact/show.yml +40 -0
  84. data/spec/vcr_cassettes/cpanel/contact/update.yml +40 -0
  85. data/spec/vcr_cassettes/cpanel/cron/add.yml +77 -0
  86. data/spec/vcr_cassettes/cpanel/cron/edit.yml +114 -0
  87. data/spec/vcr_cassettes/cpanel/cron/email.yml +77 -0
  88. data/spec/vcr_cassettes/cpanel/cron/list.yml +77 -0
  89. data/spec/vcr_cassettes/cpanel/cron/remove.yml +151 -0
  90. data/spec/vcr_cassettes/cpanel/cron/set_email.yml +77 -0
  91. data/spec/vcr_cassettes/cpanel/dns_lookup/name_to_ip.yml +40 -0
  92. data/spec/vcr_cassettes/cpanel/domain_keys/add.yml +40 -0
  93. data/spec/vcr_cassettes/cpanel/domain_keys/available.yml +40 -0
  94. data/spec/vcr_cassettes/cpanel/domain_keys/installed.yml +40 -0
  95. data/spec/vcr_cassettes/cpanel/domain_keys/remove.yml +40 -0
  96. data/spec/vcr_cassettes/cpanel/domain_lookup/count.yml +40 -0
  97. data/spec/vcr_cassettes/cpanel/domain_lookup/docroot.yml +40 -0
  98. data/spec/vcr_cassettes/cpanel/domain_lookup/docroots.yml +40 -0
  99. data/spec/vcr_cassettes/cpanel/domain_lookup/document_root.yml +40 -0
  100. data/spec/vcr_cassettes/cpanel/domain_lookup/document_roots.yml +40 -0
  101. data/spec/vcr_cassettes/cpanel/domain_lookup/list.yml +40 -0
  102. data/spec/vcr_cassettes/cpanel/email/acceptable_encodings.yml +40 -0
  103. data/spec/vcr_cassettes/cpanel/email/accounts.yml +188 -0
  104. data/spec/vcr_cassettes/cpanel/email/add_account.yml +77 -0
  105. data/spec/vcr_cassettes/cpanel/email/add_filter.yml +77 -0
  106. data/spec/vcr_cassettes/cpanel/email/add_forwarder.yml +77 -0
  107. data/spec/vcr_cassettes/cpanel/email/add_mailing_list.yml +73 -0
  108. data/spec/vcr_cassettes/cpanel/email/add_mx.yml +40 -0
  109. data/spec/vcr_cassettes/cpanel/email/change_mx.yml +40 -0
  110. data/spec/vcr_cassettes/cpanel/email/check_local_delivery_local.yml +77 -0
  111. data/spec/vcr_cassettes/cpanel/email/check_local_delivery_remote.yml +77 -0
  112. data/spec/vcr_cassettes/cpanel/email/default_address.yml +40 -0
  113. data/spec/vcr_cassettes/cpanel/email/delete_mx.yml +40 -0
  114. data/spec/vcr_cassettes/cpanel/email/disk_usage.yml +77 -0
  115. data/spec/vcr_cassettes/cpanel/email/domains.yml +40 -0
  116. data/spec/vcr_cassettes/cpanel/email/domains_with_aliases.yml +77 -0
  117. data/spec/vcr_cassettes/cpanel/email/edit_quota.yml +112 -0
  118. data/spec/vcr_cassettes/cpanel/email/filters.yml +114 -0
  119. data/spec/vcr_cassettes/cpanel/email/forwarders.yml +77 -0
  120. data/spec/vcr_cassettes/cpanel/email/mail_dir.yml +77 -0
  121. data/spec/vcr_cassettes/cpanel/email/mail_dirs.yml +77 -0
  122. data/spec/vcr_cassettes/cpanel/email/mailing_lists.yml +73 -0
  123. data/spec/vcr_cassettes/cpanel/email/main_discard.yml +40 -0
  124. data/spec/vcr_cassettes/cpanel/email/mx.yml +40 -0
  125. data/spec/vcr_cassettes/cpanel/email/remove.yml +77 -0
  126. data/spec/vcr_cassettes/cpanel/email/set_mail_delivery_local.yml +77 -0
  127. data/spec/vcr_cassettes/cpanel/email/set_mail_delivery_remote.yml +77 -0
  128. data/spec/vcr_cassettes/cpanel/email/set_mx_type.yml +40 -0
  129. data/spec/vcr_cassettes/cpanel/file_manager/disk_usage.yml +38 -0
  130. data/spec/vcr_cassettes/cpanel/file_manager/list.yml +38 -0
  131. data/spec/vcr_cassettes/cpanel/file_manager/operate.yml +77 -0
  132. data/spec/vcr_cassettes/cpanel/file_manager/show.yml +40 -0
  133. data/spec/vcr_cassettes/cpanel/file_manager/stat.yml +38 -0
  134. data/spec/vcr_cassettes/cpanel/gpg/count.yml +40 -0
  135. data/spec/vcr_cassettes/cpanel/gpg/count_private.yml +40 -0
  136. data/spec/vcr_cassettes/cpanel/gpg/list.yml +40 -0
  137. data/spec/vcr_cassettes/cpanel/gpg/list_private.yml +40 -0
  138. data/spec/vcr_cassettes/cpanel/locale/show.yml +40 -0
  139. data/spec/vcr_cassettes/cpanel/net/query_hostname.yml +40 -0
  140. data/spec/vcr_cassettes/cpanel/net/traceroute.yml +40 -0
  141. data/spec/vcr_cassettes/cpanel/park/add.yml +77 -0
  142. data/spec/vcr_cassettes/cpanel/park/list.yml +77 -0
  143. data/spec/vcr_cassettes/cpanel/park/list_addon_domains.yml +77 -0
  144. data/spec/vcr_cassettes/cpanel/park/remove.yml +77 -0
  145. data/spec/vcr_cassettes/cpanel/password/digest_authentication.yml +77 -0
  146. data/spec/vcr_cassettes/cpanel/password/modify.yml +77 -0
  147. data/spec/vcr_cassettes/cpanel/random_data/show.yml +40 -0
  148. data/spec/vcr_cassettes/cpanel/ssl/fetchcabundle.yml +40 -0
  149. data/spec/vcr_cassettes/cpanel/ssl/gencrt.yml +40 -0
  150. data/spec/vcr_cassettes/cpanel/ssl/gencsr.yml +40 -0
  151. data/spec/vcr_cassettes/cpanel/ssl/genkey.yml +40 -0
  152. data/spec/vcr_cassettes/cpanel/ssl/installssl.yml +40 -0
  153. data/spec/vcr_cassettes/cpanel/ssl/listcrts.yml +40 -0
  154. data/spec/vcr_cassettes/cpanel/ssl/listcsrs.yml +40 -0
  155. data/spec/vcr_cassettes/cpanel/ssl/listkeys.yml +40 -0
  156. data/spec/vcr_cassettes/cpanel/ssl/listsslitems.yml +40 -0
  157. data/spec/vcr_cassettes/cpanel/ssl/showcrt.yml +38 -0
  158. data/spec/vcr_cassettes/cpanel/ssl/showcsr.yml +38 -0
  159. data/spec/vcr_cassettes/cpanel/ssl/showkey.yml +38 -0
  160. data/spec/vcr_cassettes/cpanel/ssl/uploadcrt.yml +40 -0
  161. data/spec/vcr_cassettes/cpanel/sub_domain/add.yml +77 -0
  162. data/spec/vcr_cassettes/cpanel/sub_domain/list.yml +77 -0
  163. data/spec/vcr_cassettes/cpanel/sub_domain/remove.yml +77 -0
  164. data/spec/vcr_cassettes/cpanel/support/contactable.yml +40 -0
  165. data/spec/vcr_cassettes/whm/cert/fetchsslinfo.yml +38 -0
  166. data/spec/vcr_cassettes/whm/cert/generatessl.yml +38 -0
  167. data/spec/vcr_cassettes/whm/cert/installssl.yml +38 -0
  168. data/spec/vcr_cassettes/whm/cert/listcrts.yml +38 -0
  169. data/spec/vcr_cassettes/whm/server/gettweaksetting.yml +44 -0
  170. data/spec/vcr_cassettes/whm/server/settweaksetting.yml +44 -0
  171. data/spec/vcr_cassettes/whm/server/themes.yml +38 -0
  172. data/spec/whm/cert_spec.rb +62 -0
  173. data/spec/whm/server_spec.rb +79 -3
  174. metadata +376 -34
  175. data/.rvmrc +0 -49
@@ -0,0 +1,38 @@
1
+ module Lumberg
2
+ module Cpanel
3
+ # Public: Allows users to specify contact information and preferences
4
+ class Contact < Base
5
+ def self.api_module; "CustInfo"; end
6
+
7
+ # Public: Show your contact information and email notfication settings
8
+ #
9
+ # Returns Hash API response
10
+ def show
11
+ perform_request({ :api_function => 'displaycontactinfo' })
12
+ end
13
+
14
+ # Public: Updates the user's contact info and settings for email
15
+ # notifications
16
+ #
17
+ # options - Hash options for API call params (default: {})
18
+ # :email - String email account to send notifications to
19
+ # :second_email - String secondary email account to send notifications
20
+ # to (default: String)
21
+ # :email_quota - Boolean value. Set to true to be notified when you are
22
+ # when one of your email accounts approaches or is over
23
+ # quota (default: Boolean)
24
+ # :disk_quota - Boolean value. Set to true to be notified when you are
25
+ # when you are reaching your disk quota (default: Boolean)
26
+ # :bandwidth - Boolean value. Set to true to be notified when you are
27
+ # reaching your bandwidth usage limit (default: Boolean)
28
+ #
29
+ # Returns Hash API response
30
+ def update(options = {})
31
+ options[:notify_disk_limit] = options.delete(:disk_quota)
32
+ options[:notify_bandwidth_limit] = options.delete(:bandwidth)
33
+ options[:notify_email_quota_limit] = options.delete(:email_quota)
34
+ perform_request({ :api_function => 'savecontactinfo' }.merge(options))
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,89 @@
1
+ module Lumberg
2
+ module Cpanel
3
+ class Cron < Base
4
+ # Public: Set default cron notification email address.
5
+ #
6
+ # options - Hash options for API call params (default: {}):
7
+ # :email - String email address to receive notifications.
8
+ #
9
+ # Returns Hash API response.
10
+ def set_email(options = {})
11
+ perform_request({
12
+ :api_function => "set_email"
13
+ }.merge(options))
14
+ end
15
+
16
+ # Public: Get the default cron notification email address.
17
+ #
18
+ # options - Hash options for API call params (default: {})
19
+ #
20
+ # Returns Hash API response.
21
+ def email(options = {})
22
+ perform_request({
23
+ :api_function => "get_email"
24
+ }.merge(options))
25
+ end
26
+
27
+ # Public: Get list of cron jobs.
28
+ #
29
+ # options - Hash options for API call params (default: {})
30
+ #
31
+ # Returns Hash API response.
32
+ def list(options = {})
33
+ perform_request({
34
+ :api_function => "listcron"
35
+ }.merge(options))
36
+ end
37
+
38
+ # Public: Add a cron job.
39
+ #
40
+ # options - Hash options for API call params (default: {}):
41
+ # :command - String command to execute.
42
+ # :day - String day value.
43
+ # :hour - String hour value.
44
+ # :minute - String minute value.
45
+ # :month - String month value.
46
+ # :weekday - String weekday value.
47
+ #
48
+ # Returns Hash API response.
49
+ def add(options = {})
50
+ perform_request({
51
+ :api_function => "add_line"
52
+ }.merge(options))
53
+ end
54
+
55
+ # Public: Remove a cron job.
56
+ #
57
+ # options - Hash options for API call params (default: {}):
58
+ # :linekey - String linekey of the crontab entry to remove.
59
+ #
60
+ # Returns Hash API response.
61
+ def remove(options = {})
62
+ perform_request({
63
+ :api_function => "remove_line"
64
+ }.merge(options))
65
+ end
66
+
67
+ # Public: Edit a crontab entry.
68
+ #
69
+ # options - Hash options for API call params (default: {}):
70
+ # :command - String command to execute.
71
+ # :day - String day value.
72
+ # :hour - String hour value.
73
+ # :minute - String minute value.
74
+ # :month - String month value.
75
+ # :weekday - String weekday value.
76
+ # :commandnumber - Integer Line of cron entry to edit (optional).
77
+ # If not present, :linekey is required.
78
+ # :linekey - String Linekey for entry to edit (optional).
79
+ # If not present, :commandnumber is required.
80
+ #
81
+ # Returns Hash API response.
82
+ def edit(options = {})
83
+ perform_request({
84
+ :api_function => "edit_line"
85
+ }.merge(options))
86
+ end
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,23 @@
1
+ module Lumberg
2
+ module Cpanel
3
+ class DnsLookup < Base
4
+ # Public: Basic DNS functionality. This function will return the ip
5
+ # address associated with a domain. If multiple addresses are associated
6
+ # with that domain, only one will be returned
7
+ #
8
+ # options - Hash options for API call params (default: {})
9
+ # :domain - String domain you wish to lookup
10
+ #
11
+ # Examples
12
+ # api_args = { host: "x.x.x.x", hash: "pass", api_username: "user" }
13
+ # dns_lookup = Lumberg::Cpanel::DnsLookup.new(api_args.dup)
14
+ #
15
+ # dns_lookup.name_to_ip(domain: 'google.com')
16
+ #
17
+ # Returns Hash API response.
18
+ def name_to_ip(options = {})
19
+ perform_request({ :api_function => 'name2ip' }.merge(options))
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,37 @@
1
+ module Lumberg
2
+ module Cpanel
3
+ # Public: Allows users to edit domain keys
4
+ class DomainKeys < Base
5
+ def self.api_module ; "DKIMUI" ; end
6
+
7
+ # Public: Install DomainKeys for your cPanel account
8
+ #
9
+ # Returns Hash API response
10
+ def add
11
+ perform_request({ :api_function => "install" })
12
+ end
13
+
14
+ # Public: Remove DomainKeys corresponding to your domain
15
+ #
16
+ # Returns Hash API response
17
+ def remove
18
+ perform_request({ :api_function => "uninstall" })
19
+ end
20
+
21
+ # Public: Check to see if your domain has DomainKeys installed
22
+ #
23
+ # Returns Hash API response
24
+ def installed
25
+ perform_request({ :api_function => "installed" })
26
+ end
27
+
28
+ # Public: Check to see if DomainKeys are available on the server
29
+ #
30
+ # Returns Hash API response
31
+ def available
32
+ perform_request({ :api_function => "available" })
33
+ end
34
+ end
35
+ end
36
+ end
37
+
@@ -0,0 +1,71 @@
1
+ module Lumberg
2
+ module Cpanel
3
+ # Public: This module allows you to gather domain and document root maps
4
+ # from authenticated accounts.
5
+ class DomainLookup < Base
6
+ # Public: Retrieve parked, addon and main domains for a Cpanel account
7
+ #
8
+ # Examples
9
+ # api_args = { host: "x.x.x.x", hash: "pass", api_username: "user" }
10
+ # domain_lookup = Lumberg::Cpanel::DomainLookup.new(api_args.dup)
11
+ #
12
+ # domain_lookup.list
13
+ #
14
+ # Returns Hash API response.
15
+ def list
16
+ perform_request({ :api_function => 'getbasedomains' })
17
+ end
18
+
19
+ # Public: Retrieve the absolute and relative paths to a specific domain's
20
+ # document root.
21
+ #
22
+ # options - Hash options for API call params (default: {})
23
+ # :domain - String domain corresponding to the document root you wish
24
+ # to know (default: 'your main domain')
25
+ #
26
+ # Examples
27
+ # api_args = { host: "x.x.x.x", hash: "pass", api_username: "user" }
28
+ # domain_lookup = Lumberg::Cpanel::DomainLookup.new(api_args.dup)
29
+ #
30
+ # # gets DocumentRoot for primary domain
31
+ # domain_lookup.document_root
32
+ # # gets DocumentRoot for addon domain (or subdomain)
33
+ # domain_lookup.document_root(domain: 'addon.example.com')
34
+ #
35
+ # Returns Hash API response.
36
+ def document_root(options = {})
37
+ perform_request({ :api_function => 'getdocroot' }.merge(options))
38
+ end
39
+ alias :docroot :document_root
40
+
41
+ # Public: Retrieve the full paths to all of your document roots
42
+ #
43
+ # Examples
44
+ # api_args = { host: "x.x.x.x", hash: "pass", api_username: "user" }
45
+ # domain_lookup = Lumberg::Cpanel::DomainLookup.new(api_args.dup)
46
+ #
47
+ # domain_lookup.document_roots
48
+ #
49
+ # Returns Hash API response.
50
+ def document_roots
51
+ perform_request({ :api_function => 'getdocroots' })
52
+ end
53
+ alias :docroots :document_roots
54
+
55
+ # Public: Retrieve the total number of base domains associated with your
56
+ # cPanel account.
57
+ #
58
+ # Examples
59
+ # api_args = { host: "x.x.x.x", hash: "pass", api_username: "user" }
60
+ # domain_lookup = Lumberg::Cpanel::DomainLookup.new(api_args.dup)
61
+ #
62
+ # domain_lookup.count_domains
63
+ #
64
+ # Returns Hash API response.
65
+ def count
66
+ perform_request({ :api_function => 'countbasedomains' })
67
+ end
68
+ end
69
+ end
70
+ end
71
+
@@ -0,0 +1,491 @@
1
+ module Lumberg
2
+ module Cpanel
3
+ class Email < Base
4
+ # Public: Get info about how the main email account handles
5
+ # undeliverable mail.
6
+ #
7
+ # options - Hash options for API call params (default: {}).
8
+ #
9
+ # Returns Hash API response.
10
+ def main_discard(options = {})
11
+ perform_request(
12
+ :api_function => "checkmaindiscard"
13
+ )
14
+ end
15
+
16
+ # Public: Add a forwarder.
17
+ #
18
+ # options - Hash options for API call params (default: {}):
19
+ # :domain - String forwarder domain.
20
+ # :email - String local part ("user" if "user@domain.com").
21
+ # :fwdopt - String type of forwarder. Accepted values:
22
+ # "pipe", "fwd", "system", "blackhole", "fail"
23
+ # :fwdemail - String Destination email address.
24
+ # :fwdsystem - String system account to forward to (optional). Should
25
+ # only be used if :fwdopt is set to "system".
26
+ # :failmsgs - String failure message (optional). Only used if "fwdopt"
27
+ # is set to "fail".
28
+ # :pipefwd - String path to program to pipe to (optional). Only used
29
+ # if "fwdopt" is set to "pipe"
30
+ #
31
+ # Returns Hash API response.
32
+ def add_forwarder(options = {})
33
+ perform_request({
34
+ :api_function => "addforward"
35
+ }.merge(options))
36
+ end
37
+
38
+ # Public: Get list of forwarders.
39
+ #
40
+ # options - Hash options for API call params (default: {}):
41
+ # :domain - String domain for which to retrieve forwarders (optional).
42
+ # :regex - String regular expression to filter results (optional).
43
+ #
44
+ # Returns Hash API response.
45
+ def forwarders(options = {})
46
+ perform_request({
47
+ :api_function => "listforwards"
48
+ }.merge(options))
49
+ end
50
+
51
+ # Public: Retrieve a list of domains that use aliases and custom
52
+ # catch-all addresses.
53
+ #
54
+ # options - Hash options for API call params (default: {}).
55
+ #
56
+ # Returns Hash API response.
57
+ def domains_with_aliases(options = {})
58
+ perform_request(
59
+ :api_function => "listaliasbackups"
60
+ )
61
+ end
62
+
63
+ # Public: Add a mailing list. Uses API1 because API2 doesn't provide
64
+ # an equivalent method.
65
+ #
66
+ # options - Hash options for API call params (default: {}):
67
+ # :list - String mailing liist name.
68
+ # :password - String mailing list password.
69
+ # :domain - String mailing list domain.
70
+ #
71
+ # Returns Hash API response.
72
+ def add_mailing_list(options = {})
73
+ perform_request({
74
+ :api_function => "addlist",
75
+ :api_version => 1,
76
+ "arg-0" => options[:list],
77
+ "arg-1" => options[:password],
78
+ "arg-2" => options[:domain]
79
+ })
80
+ end
81
+
82
+ # Public: Get list Mailman mailing lists.
83
+ #
84
+ # options - Hash options for API call params (default: {}):
85
+ # :domain - String domain for which to retrieve mailing lists
86
+ # (optional).
87
+ # :regex - String regular expression to filter results (optional).
88
+ #
89
+ # Returns Hash API response.
90
+ def mailing_lists(options = {})
91
+ perform_request({
92
+ :api_function => "listlists"
93
+ }.merge(options))
94
+ end
95
+
96
+ # Public: Get list of domains that can send/receive mail.
97
+ #
98
+ # options - Hash options for API call params (default: {}):
99
+ # :skipmain - String skip main domain by passing "1" (optional).
100
+ #
101
+ # Returns Hash API response.
102
+ def domains(options = {})
103
+ perform_request({
104
+ :api_function => "listmaildomains"
105
+ }.merge(options))
106
+ end
107
+
108
+ # Public: Change values for a specific MX record
109
+ #
110
+ # options - Hash options for API call params (default: {}):
111
+ # :domain - String domain for the MX record you wish to change.
112
+ # :exchange - String name of the new exchanger.
113
+ # :oldexchange - String name of the exchanger to replace (optional).
114
+ # :oldpreference - Integer priority value of the old exchanger.
115
+ # :preference - Integer priority value for the new exchange.
116
+ # :alwaysaccept - String setting to define behavior for the exchanger.
117
+ # Accepted: "backup", "local", "secondary", "remote".
118
+ # (optional)
119
+ #
120
+ # Returns Hash API response.
121
+ def change_mx(options = {})
122
+ perform_request({ :api_function => "changemx" }.merge(options))
123
+ end
124
+
125
+ # Public: Add an MX record
126
+ #
127
+ # options - Hash options for API call params (default: {}):
128
+ # :domain - String domain for the MX record you wish to change.
129
+ # :exchange - String name of the new exchanger.
130
+ # :preference - Integer priority value for the new exchange.
131
+ # :alwaysaccept - String setting to define behavior for the exchanger.
132
+ # Accepted: "backup", "local", "secondary", "remote".
133
+ # (optional)
134
+ #
135
+ # Returns Hash API response.
136
+ def add_mx(options = {})
137
+ perform_request({ :api_function => "addmx" }.merge(options))
138
+ end
139
+
140
+ # Public: Get list of mail exchanger information.
141
+ #
142
+ # options - Hash options for API call params (default: {}):
143
+ # :domain - String domain for which to retrieve mail exchangers.
144
+ #
145
+ # Returns Hash API response.
146
+ def mx(options = {})
147
+ perform_request({
148
+ :api_function => "listmxs"
149
+ }.merge(options))
150
+ end
151
+
152
+ # Public: Delete an MX record
153
+ #
154
+ # options - Hash options for API call params (default: {}):
155
+ # :domain - String domain for the MX record you wish to change.
156
+ # :exchange - String name of the new exchanger.
157
+ # :preference - Integer priority value for the new exchange.
158
+ #
159
+ # Returns Hash API response.
160
+ def delete_mx(options = {})
161
+ perform_request({ :api_function => "delmx" }.merge(options))
162
+ end
163
+
164
+ # Public: Set a mail exchanger for a specified domain to local,
165
+ # remote, secondary, or auto
166
+ #
167
+ # options - Hash options for API call params (default: {}):
168
+ # :domain - String domain for the MX record you wish to change.
169
+ # :mxcheck - String setting to define behavior for the exchanger.
170
+ # Accepted: "auto", "local", "secondary", "remote".
171
+ #
172
+ # Returns Hash API response.
173
+ def set_mx_type(options = {})
174
+ perform_request({ :api_function => "setmxcheck" }.merge(options))
175
+ end
176
+
177
+ # Public: Set mail delivery for a domain.
178
+ #
179
+ # options - Hash options for API call params (default: {}):
180
+ # :domain - String domain corresponding to the mail exchanger to set.
181
+ # :delivery - String status to set for the mail exchanger. Accepted:
182
+ # "auto", "local", "secondary", "remote".
183
+ # :user - String user of the cPanel account whose domain
184
+ # corresponds to the mail exchanger you with to set.
185
+ #
186
+ # Returns Hash API response.
187
+ def set_mail_delivery(options = {})
188
+ perform_request({
189
+ :api_function => "setalwaysaccept",
190
+ :mxcheck => options[:delivery]
191
+ }.merge(options))
192
+ end
193
+
194
+ # Public: Check cPanel config for local mail delivery setting.
195
+ # This function checks cPanel config, not DNS.
196
+ #
197
+ # options - Hash options for API call params (default: {}):
198
+ # :domain - String domain to check. Will return settings for all
199
+ # domains if omitted.
200
+ #
201
+ # Returns Hash API response.
202
+ def check_local_delivery(options = {})
203
+ perform_request({
204
+ :api_function => "getalwaysaccept"
205
+ }.merge(options))
206
+ end
207
+
208
+ # Public: Add a new email filter. See
209
+ # http://docs.cpanel.net/twiki/bin/view/ApiDocs/Api2/ApiEmail#Email::storefilter
210
+ # for gory details.
211
+ #
212
+ # options - Hash options for API call params (default: {}). Options
213
+ # with * indicate numeric suffix corresponding to filter
214
+ # number:
215
+ # :account - String value. For user-level filters, enter email
216
+ # address. Leave empty for account-level filter. Use
217
+ # cPanel username for default address filters.
218
+ # :action* - String action taken by filter. Accepted: "deliver",
219
+ # "fail", "finish", "save", "pipe"
220
+ # :dest* - String destination for mail received by the filter.
221
+ # :filtername - String name of filter.
222
+ # :match* - String filter match type. Accepted: "is", "matches",
223
+ # "contains", "does not contain", "begins", "ends",
224
+ # "does not begin", "does not end", "does not match",
225
+ # "is above" (numeric), "is not above" (numeric),
226
+ # "is below" (numeric), "is not below" (numeric)
227
+ # :opt* - String value used to connect conditions. Accepted:
228
+ # "or", "and".
229
+ # :part* - String part of the email to apply the :match option
230
+ # to. Accepted: "$header_from:", "$header_subject:",
231
+ # "$header_to:", "$reply_address:", "$message_body",
232
+ # "$message_headers",
233
+ # 'foranyaddress $h_to",$h_cc:,$h_bcc:',
234
+ # "not delivered", "error_message",
235
+ # "$h_X-Spam-Status:",
236
+ # "$h_X-Spam-Score:", and "$h_X-Spam-Bar:". The last 3
237
+ # options require SpamAssassin to be enabled. You may
238
+ # also use "error_message" or "not delivered" which
239
+ # do not require the :match parameter.
240
+ # :val* - String value to match.
241
+ # :oldfiltername - String value. Use current filter name here and
242
+ # specify new filter name in :filtername option to
243
+ # rename filter (optional).
244
+ #
245
+ # Returns Hash API response.
246
+ def add_filter(options = {})
247
+ perform_request({
248
+ :api_function => "storefilter"
249
+ }.merge(options))
250
+ end
251
+
252
+ # Public: Get a list of email filters.
253
+ #
254
+ # options - Hash options for API call params (default: {}):
255
+ # :account - String value (optional). Lists user-level filters if
256
+ # email address given. Lists user-level filters
257
+ # associated with default address if cPanel username
258
+ # given. Lists account-level filters if omitted.
259
+ # :old_style - Boolean (optional, default: false). Use deprecated
260
+ # Email::listfilters.
261
+ #
262
+ # Returns Hash API response.
263
+ def filters(options = {})
264
+ func = options.delete(:old_style) ? "listfilters" : "filterlist"
265
+
266
+ perform_request({
267
+ :api_function => func
268
+ }.merge(options))
269
+ end
270
+
271
+ # Public: Add a POP account.
272
+ #
273
+ # options - Hash options for API call params (default: {}):
274
+ # :domain - String domain for the email account.
275
+ # :email - String local part of email address. "user" if
276
+ # "user@domain".
277
+ # :password - String password for email account.
278
+ # :quota - Integer disk space quota in MB, 0 for unlimited.
279
+ #
280
+ # Returns Hash API response.
281
+ def add_account(options = {})
282
+ perform_request({
283
+ :api_function => "addpop"
284
+ }.merge(options))
285
+ end
286
+
287
+ # Public: Get a list of email accounts. Uses the cPanel-preferred
288
+ # API call Email::listpopswithdisk.
289
+ #
290
+ # options - Hash options for API call params (default: {}):
291
+ # :domain - String domain for which to retrieve email accounts
292
+ # (optional).
293
+ # :regex - String regular expression to filter results
294
+ # (optional).
295
+ # :nearquotaonly - String value. Set to "1" to only view accounts that
296
+ # have used >= 95% of their quota (optional).
297
+ # :no_validate - String vlaue. Set to "1" to only read data from
298
+ # account's ".cpanel/email_accounts.yaml" file. This
299
+ # parameter is "off" by default, causing the function
300
+ # to check the passwd file, quota files, etc.
301
+ # (optional).
302
+ # :style - Symbol account list style (optional,
303
+ # default: :with_disk). Accepted: :with_disk,
304
+ # :without_disk, :with_image, :single.
305
+ #
306
+ # Returns Hash API response.
307
+ def accounts(options = {})
308
+ styles = {
309
+ :with_disk => "listpopswithdisk",
310
+ :without_disk => "listpops",
311
+ :with_image => "listpopswithimage",
312
+ :single => "listpopssingle"
313
+ }
314
+ func = styles.fetch(options.delete(:style), styles[:with_disk])
315
+
316
+ perform_request({
317
+ :api_function => func
318
+ }.merge(options))
319
+ end
320
+
321
+ # Public: Get default address info.
322
+ #
323
+ # options - Hash options for API call params (default: {}):
324
+ # :domain - String efault address domain.
325
+ #
326
+ # Returns Hash API response.
327
+ def default_address(options = {})
328
+ perform_request({
329
+ :api_function => "listdefaultaddresses"
330
+ }.merge(options))
331
+ end
332
+
333
+ # Public: Get disk usage information for an email account.
334
+ #
335
+ # options - Hash options for API call params (default: {}):
336
+ # :domain - String value. "domain.com" if "user@domain.com"
337
+ # :login - String value. "user" if "user@domain.com".
338
+ #
339
+ # Returns Hash API response.
340
+ def disk_usage(options = {})
341
+ perform_request({
342
+ :api_function => "getdiskusage"
343
+ }.merge(options))
344
+ end
345
+
346
+ # Public: Get full path to a mail folder.
347
+ #
348
+ # options - Hash options for API call params (default: {}):
349
+ # :account - String email address.
350
+ # :dir - String mail folder you wish to query for its full path
351
+ # (optional, default: "mail").
352
+ #
353
+ # Returns Hash API response.
354
+ def mail_dir(options = {})
355
+ perform_request({
356
+ :api_function => "getabsbrowsedir"
357
+ }.merge(options))
358
+ end
359
+
360
+ # Public: Retrieve a list of mail dirs.
361
+ #
362
+ # options - Hash options for API call params (default: {}):
363
+ # :account - String email account (optional).
364
+ # :dir - String mail directories to display (optional).
365
+ # "default" or "mail" will list all mail dirs.
366
+ # Providing a domain will list dirs related to the
367
+ # domain.
368
+ # :showdotfiles - Boolean view hidden directories?
369
+ #
370
+ # Returns Hash API response.
371
+ def mail_dirs(options = {})
372
+ perform_request({
373
+ :api_function => "browseboxes"
374
+ }.merge(options))
375
+ end
376
+
377
+ # Public: Remove an email account
378
+ #
379
+ # options - Hash options for API call params (default: {})
380
+ # :domain - String domain for which you wish to remove the email
381
+ # account
382
+ # :email - String email address you wish to remove
383
+ #
384
+ # Returns Hash API response.
385
+ def remove(options = {})
386
+ perform_request({ :api_function => 'delpop' }.merge(options))
387
+ end
388
+
389
+ # Public: Modify an email account's quota.
390
+ #
391
+ # options - Hash options for API call params (default: {})
392
+ # :domain - String domain for which you wish to modify
393
+ # :email - String username of the email address you wish to modify,
394
+ # e.g: 'user' if the address is 'user@domain.com'
395
+ # :quota - Integer indicating the new disk quota value in MB. Enter 0
396
+ # for an unlimited quota
397
+ #
398
+ # Returns Hash API response.
399
+ def edit_quota(options = {})
400
+ perform_request({ :api_function => 'editquota' }.merge(options))
401
+ end
402
+
403
+ # Public: Retrieve a list of character encodings supported by cPanel
404
+ #
405
+ # Returns Hash API response.
406
+ def acceptable_encodings
407
+ perform_request({ :api_function => 'fetchcharmaps' })
408
+ end
409
+
410
+ # Public: Retrieve the destination for email forwarded by a domain
411
+ # forwarder
412
+ # options - Hash options for API call params (default: {})
413
+ # :domain - String domain corresponding to the forwarder whose
414
+ # destination you wish to view
415
+ #
416
+ # Returns Hash API response
417
+ def listdomainforwards(options = {})
418
+ perform_request({ :api_function => "listdomainforwards" }.merge(options))
419
+ end
420
+
421
+ # Public: Retrieve a list of auto responders associated with a domain
422
+ #
423
+ # options - Hash options for API call params (default: {})
424
+ # :domain - String domain whose auto responders you wish to view
425
+ # (default: String)
426
+ # :regex - String regular expresion to filter search results (default:
427
+ # String)
428
+ #
429
+ # Returns Hash API response
430
+ def listautoresponders(options = {})
431
+ perform_request({ :api_function => "listautoresponders" }.merge(options))
432
+ end
433
+
434
+ # Public: Retrieve a list of domains that use domain-level filters
435
+ #
436
+ # Returns Hash API response
437
+ def listfilterbackups
438
+ perform_request({ :api_function => "listfilterbackups" })
439
+ end
440
+
441
+ # Public: Retrieve a list of email filters
442
+ #
443
+ # options - Hash options for API call params (default: {})
444
+ # :account - String parameter allows you to specify an email address or
445
+ # account username to review user-level filters. Specifying
446
+ # an email address will cause the function to retrieve user
447
+ # level filters associated with the account. Entering a
448
+ # cPanel username will cause the function to return user
449
+ # level filters associated with your account's default email
450
+ # address. If you do not specify this value, the function
451
+ # will retrieve account level filter information (default:
452
+ # String)
453
+ #
454
+ # Returns Hash API response
455
+ def filterlist(options={})
456
+ perform_request({ :api_function => "filterlist" }.merge(options))
457
+ end
458
+
459
+ # Public: Test the action of account-level mail filters. You can only
460
+ # test filters for your cPanel account's main domain. This function only
461
+ # tests the body of the message. You must have access to the 'blockers'
462
+ # feature to use this function.
463
+ #
464
+ # options - Hash options for API call params (default: {})
465
+ # :message - String body of the message you wish to test
466
+ # :account - String to test old-style Cpanel filters in $home/filters.
467
+ # By not specifying this parameter, you will test your main
468
+ # domain's filters found in the /etc/vfilters/ directory (
469
+ # default: String)
470
+ #
471
+ # Returns Hash API response
472
+ def tracefilter(options={})
473
+ options[:msg] = options.delete(:message)
474
+ perform_request({ :api_function => "tracefilter" }.merge(options))
475
+ end
476
+
477
+ # Public: Retrieve information about an auto responder used by a
478
+ # specified email address
479
+ #
480
+ # options - Hash options for API call params (default: {})
481
+ # :email - String email address corresponding to the auto responder
482
+ # information you wish to review
483
+ #
484
+ # Returns Hash API response
485
+ def fetchautoresponder(options={})
486
+ perform_request({ :api_function => "fetchautoresponder" }.merge(options))
487
+ end
488
+ end
489
+ end
490
+ end
491
+