lumberg 1.0.1 → 2.0.0.pre4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (248) hide show
  1. checksums.yaml +7 -0
  2. data/.travis.yml +8 -7
  3. data/LICENSE +1 -1
  4. data/README.md +130 -23
  5. data/Rakefile +3 -1
  6. data/lib/lumberg/config.rb +19 -0
  7. data/lib/lumberg/cpanel/addon_domain.rb +50 -0
  8. data/lib/lumberg/cpanel/backups.rb +16 -0
  9. data/lib/lumberg/cpanel/base.rb +56 -0
  10. data/lib/lumberg/cpanel/box_trapper.rb +18 -0
  11. data/lib/lumberg/cpanel/branding.rb +89 -0
  12. data/lib/lumberg/cpanel/contact.rb +38 -0
  13. data/lib/lumberg/cpanel/cron.rb +89 -0
  14. data/lib/lumberg/cpanel/dns_lookup.rb +23 -0
  15. data/lib/lumberg/cpanel/domain_keys.rb +37 -0
  16. data/lib/lumberg/cpanel/domain_lookup.rb +71 -0
  17. data/lib/lumberg/cpanel/email.rb +491 -0
  18. data/lib/lumberg/cpanel/file_manager.rb +146 -0
  19. data/lib/lumberg/cpanel/gpg.rb +36 -0
  20. data/lib/lumberg/cpanel/locale.rb +15 -0
  21. data/lib/lumberg/cpanel/mime.rb +34 -0
  22. data/lib/lumberg/cpanel/mysql.rb +66 -0
  23. data/lib/lumberg/cpanel/net.rb +28 -0
  24. data/lib/lumberg/cpanel/park.rb +58 -0
  25. data/lib/lumberg/cpanel/password.rb +52 -0
  26. data/lib/lumberg/cpanel/random_data.rb +25 -0
  27. data/lib/lumberg/cpanel/redirect.rb +44 -0
  28. data/lib/lumberg/cpanel/ssl.rb +206 -0
  29. data/lib/lumberg/cpanel/sub_domain.rb +61 -0
  30. data/lib/lumberg/cpanel/support.rb +29 -0
  31. data/lib/lumberg/cpanel/zone_edit.rb +134 -0
  32. data/lib/lumberg/cpanel.rb +29 -0
  33. data/lib/lumberg/format_whm.rb +125 -0
  34. data/lib/lumberg/version.rb +1 -1
  35. data/lib/lumberg/whm/account.rb +28 -105
  36. data/lib/lumberg/whm/base.rb +3 -7
  37. data/lib/lumberg/whm/cert.rb +76 -0
  38. data/lib/lumberg/whm/dns.rb +49 -77
  39. data/lib/lumberg/whm/reseller.rb +24 -117
  40. data/lib/lumberg/whm/server.rb +111 -230
  41. data/lib/lumberg/whm.rb +2 -1
  42. data/lib/lumberg.rb +34 -8
  43. data/lumberg.gemspec +7 -4
  44. data/spec/config_spec.rb +28 -0
  45. data/spec/cpanel/addon_domain_spec.rb +84 -0
  46. data/spec/cpanel/backups_spec.rb +22 -0
  47. data/spec/cpanel/base_spec.rb +128 -0
  48. data/spec/cpanel/box_trapper_spec.rb +22 -0
  49. data/spec/cpanel/branding_spec.rb +46 -0
  50. data/spec/cpanel/contact_spec.rb +50 -0
  51. data/spec/cpanel/cron_spec.rb +161 -0
  52. data/spec/cpanel/dns_lookup_spec.rb +22 -0
  53. data/spec/cpanel/domain_keys_spec.rb +46 -0
  54. data/spec/cpanel/domain_lookup_spec.rb +77 -0
  55. data/spec/cpanel/email_spec.rb +615 -0
  56. data/spec/cpanel/file_manager_spec.rb +73 -0
  57. data/spec/cpanel/gpg_spec.rb +48 -0
  58. data/spec/cpanel/locale_spec.rb +23 -0
  59. data/spec/cpanel/mime_spec.rb +0 -0
  60. data/spec/cpanel/mysql_spec.rb +0 -0
  61. data/spec/cpanel/net_spec.rb +30 -0
  62. data/spec/cpanel/park_spec.rb +94 -0
  63. data/spec/cpanel/password_spec.rb +35 -0
  64. data/spec/cpanel/random_data_spec.rb +24 -0
  65. data/spec/cpanel/redirect_spec.rb +0 -0
  66. data/spec/cpanel/ssl_spec.rb +148 -0
  67. data/spec/cpanel/sub_domain_spec.rb +72 -0
  68. data/spec/cpanel/support_spec.rb +38 -0
  69. data/spec/cpanel/zone_edit_spec.rb +0 -0
  70. data/spec/sample_certs/cpanel.crt +28 -0
  71. data/spec/sample_certs/cpanel.key +28 -0
  72. data/spec/sample_certs/main.crt +27 -0
  73. data/spec/sample_certs/sample.crt +26 -0
  74. data/spec/sample_certs/sample.key +27 -0
  75. data/spec/spec_helper.rb +9 -3
  76. data/spec/support/cpanel_matchers.rb +17 -0
  77. data/spec/vcr_cassettes/cpanel/addon_domain/add.yml +77 -0
  78. data/spec/vcr_cassettes/cpanel/addon_domain/list.yml +77 -0
  79. data/spec/vcr_cassettes/cpanel/addon_domain/remove.yml +77 -0
  80. data/spec/vcr_cassettes/cpanel/backups/list.yml +40 -0
  81. data/spec/vcr_cassettes/cpanel/box_trapper/list.yml +40 -0
  82. data/spec/vcr_cassettes/cpanel/branding/list_icons.yml +40 -0
  83. data/spec/vcr_cassettes/cpanel/branding/list_image_types.yml +40 -0
  84. data/spec/vcr_cassettes/cpanel/branding/list_object_types.yml +40 -0
  85. data/spec/vcr_cassettes/cpanel/branding/list_pkgs.yml +40 -0
  86. data/spec/vcr_cassettes/cpanel/branding/list_sprites.yml +40 -0
  87. data/spec/vcr_cassettes/cpanel/contact/show.yml +40 -0
  88. data/spec/vcr_cassettes/cpanel/contact/update.yml +40 -0
  89. data/spec/vcr_cassettes/cpanel/cron/add.yml +77 -0
  90. data/spec/vcr_cassettes/cpanel/cron/edit.yml +114 -0
  91. data/spec/vcr_cassettes/cpanel/cron/email.yml +77 -0
  92. data/spec/vcr_cassettes/cpanel/cron/list.yml +77 -0
  93. data/spec/vcr_cassettes/cpanel/cron/remove.yml +151 -0
  94. data/spec/vcr_cassettes/cpanel/cron/set_email.yml +77 -0
  95. data/spec/vcr_cassettes/cpanel/dns_lookup/name_to_ip.yml +40 -0
  96. data/spec/vcr_cassettes/cpanel/domain_keys/add.yml +40 -0
  97. data/spec/vcr_cassettes/cpanel/domain_keys/available.yml +40 -0
  98. data/spec/vcr_cassettes/cpanel/domain_keys/installed.yml +40 -0
  99. data/spec/vcr_cassettes/cpanel/domain_keys/remove.yml +40 -0
  100. data/spec/vcr_cassettes/cpanel/domain_lookup/count.yml +40 -0
  101. data/spec/vcr_cassettes/cpanel/domain_lookup/docroot.yml +40 -0
  102. data/spec/vcr_cassettes/cpanel/domain_lookup/docroots.yml +40 -0
  103. data/spec/vcr_cassettes/cpanel/domain_lookup/document_root.yml +40 -0
  104. data/spec/vcr_cassettes/cpanel/domain_lookup/document_roots.yml +40 -0
  105. data/spec/vcr_cassettes/cpanel/domain_lookup/list.yml +40 -0
  106. data/spec/vcr_cassettes/cpanel/email/acceptable_encodings.yml +40 -0
  107. data/spec/vcr_cassettes/cpanel/email/accounts.yml +188 -0
  108. data/spec/vcr_cassettes/cpanel/email/add_account.yml +77 -0
  109. data/spec/vcr_cassettes/cpanel/email/add_filter.yml +77 -0
  110. data/spec/vcr_cassettes/cpanel/email/add_forwarder.yml +77 -0
  111. data/spec/vcr_cassettes/cpanel/email/add_mailing_list.yml +73 -0
  112. data/spec/vcr_cassettes/cpanel/email/add_mx.yml +40 -0
  113. data/spec/vcr_cassettes/cpanel/email/change_mx.yml +40 -0
  114. data/spec/vcr_cassettes/cpanel/email/check_local_delivery_local.yml +77 -0
  115. data/spec/vcr_cassettes/cpanel/email/check_local_delivery_remote.yml +77 -0
  116. data/spec/vcr_cassettes/cpanel/email/default_address.yml +40 -0
  117. data/spec/vcr_cassettes/cpanel/email/delete_mx.yml +40 -0
  118. data/spec/vcr_cassettes/cpanel/email/disk_usage.yml +77 -0
  119. data/spec/vcr_cassettes/cpanel/email/domains.yml +40 -0
  120. data/spec/vcr_cassettes/cpanel/email/domains_with_aliases.yml +77 -0
  121. data/spec/vcr_cassettes/cpanel/email/edit_quota.yml +112 -0
  122. data/spec/vcr_cassettes/cpanel/email/filters.yml +114 -0
  123. data/spec/vcr_cassettes/cpanel/email/forwarders.yml +77 -0
  124. data/spec/vcr_cassettes/cpanel/email/mail_dir.yml +77 -0
  125. data/spec/vcr_cassettes/cpanel/email/mail_dirs.yml +77 -0
  126. data/spec/vcr_cassettes/cpanel/email/mailing_lists.yml +73 -0
  127. data/spec/vcr_cassettes/cpanel/email/main_discard.yml +40 -0
  128. data/spec/vcr_cassettes/cpanel/email/mx.yml +40 -0
  129. data/spec/vcr_cassettes/cpanel/email/remove.yml +77 -0
  130. data/spec/vcr_cassettes/cpanel/email/set_mail_delivery_local.yml +77 -0
  131. data/spec/vcr_cassettes/cpanel/email/set_mail_delivery_remote.yml +77 -0
  132. data/spec/vcr_cassettes/cpanel/email/set_mx_type.yml +40 -0
  133. data/spec/vcr_cassettes/cpanel/file_manager/disk_usage.yml +38 -0
  134. data/spec/vcr_cassettes/cpanel/file_manager/list.yml +38 -0
  135. data/spec/vcr_cassettes/cpanel/file_manager/operate.yml +77 -0
  136. data/spec/vcr_cassettes/cpanel/file_manager/show.yml +40 -0
  137. data/spec/vcr_cassettes/cpanel/file_manager/stat.yml +38 -0
  138. data/spec/vcr_cassettes/cpanel/gpg/count.yml +40 -0
  139. data/spec/vcr_cassettes/cpanel/gpg/count_private.yml +40 -0
  140. data/spec/vcr_cassettes/cpanel/gpg/list.yml +40 -0
  141. data/spec/vcr_cassettes/cpanel/gpg/list_private.yml +40 -0
  142. data/spec/vcr_cassettes/cpanel/locale/show.yml +40 -0
  143. data/spec/vcr_cassettes/cpanel/net/query_hostname.yml +40 -0
  144. data/spec/vcr_cassettes/cpanel/net/traceroute.yml +40 -0
  145. data/spec/vcr_cassettes/cpanel/park/add.yml +77 -0
  146. data/spec/vcr_cassettes/cpanel/park/list.yml +77 -0
  147. data/spec/vcr_cassettes/cpanel/park/list_addon_domains.yml +77 -0
  148. data/spec/vcr_cassettes/cpanel/park/remove.yml +77 -0
  149. data/spec/vcr_cassettes/cpanel/password/digest_authentication.yml +77 -0
  150. data/spec/vcr_cassettes/cpanel/password/modify.yml +77 -0
  151. data/spec/vcr_cassettes/cpanel/random_data/show.yml +40 -0
  152. data/spec/vcr_cassettes/cpanel/ssl/fetchcabundle.yml +40 -0
  153. data/spec/vcr_cassettes/cpanel/ssl/gencrt.yml +43 -0
  154. data/spec/vcr_cassettes/cpanel/ssl/gencsr.yml +43 -0
  155. data/spec/vcr_cassettes/cpanel/ssl/genkey.yml +40 -0
  156. data/spec/vcr_cassettes/cpanel/ssl/installssl.yml +40 -0
  157. data/spec/vcr_cassettes/cpanel/ssl/listcrts.yml +40 -0
  158. data/spec/vcr_cassettes/cpanel/ssl/listcsrs.yml +40 -0
  159. data/spec/vcr_cassettes/cpanel/ssl/listkeys.yml +40 -0
  160. data/spec/vcr_cassettes/cpanel/ssl/listsslitems.yml +40 -0
  161. data/spec/vcr_cassettes/cpanel/ssl/showcrt.yml +38 -0
  162. data/spec/vcr_cassettes/cpanel/ssl/showcsr.yml +38 -0
  163. data/spec/vcr_cassettes/cpanel/ssl/showkey.yml +38 -0
  164. data/spec/vcr_cassettes/cpanel/ssl/uploadcrt.yml +40 -0
  165. data/spec/vcr_cassettes/cpanel/sub_domain/add.yml +77 -0
  166. data/spec/vcr_cassettes/cpanel/sub_domain/list.yml +77 -0
  167. data/spec/vcr_cassettes/cpanel/sub_domain/remove.yml +77 -0
  168. data/spec/vcr_cassettes/cpanel/support/contactable.yml +40 -0
  169. data/spec/vcr_cassettes/whm/account/accountsummary.yml +41 -29
  170. data/spec/vcr_cassettes/whm/account/changepackage.yml +73 -43
  171. data/spec/vcr_cassettes/whm/account/createacct.yml +101 -31
  172. data/spec/vcr_cassettes/whm/account/domainuserdata.yml +43 -29
  173. data/spec/vcr_cassettes/whm/account/editquota.yml +78 -57
  174. data/spec/vcr_cassettes/whm/account/limitbw.yml +79 -57
  175. data/spec/vcr_cassettes/whm/account/listaccts.yml +195 -100
  176. data/spec/vcr_cassettes/whm/account/listsuspended.yml +41 -29
  177. data/spec/vcr_cassettes/whm/account/modifyacct.yml +61 -42
  178. data/spec/vcr_cassettes/whm/account/myprivs.yml +41 -29
  179. data/spec/vcr_cassettes/whm/account/passwd.yml +44 -29
  180. data/spec/vcr_cassettes/whm/account/removeacct.yml +134 -57
  181. data/spec/vcr_cassettes/whm/account/restoreaccount.yml +310 -135
  182. data/spec/vcr_cassettes/whm/account/setsiteip.yml +166 -127
  183. data/spec/vcr_cassettes/whm/account/suspend.yml +75 -43
  184. data/spec/vcr_cassettes/whm/account/unsuspend.yml +46 -29
  185. data/spec/vcr_cassettes/whm/cert/fetchsslinfo.yml +38 -0
  186. data/spec/vcr_cassettes/whm/cert/generatessl.yml +94 -0
  187. data/spec/vcr_cassettes/whm/cert/installssl.yml +38 -0
  188. data/spec/vcr_cassettes/whm/cert/listcrts.yml +38 -0
  189. data/spec/vcr_cassettes/whm/dns/adddns.yml +61 -43
  190. data/spec/vcr_cassettes/whm/dns/addzonerecord.yml +42 -29
  191. data/spec/vcr_cassettes/whm/dns/dumpzone.yml +44 -29
  192. data/spec/vcr_cassettes/whm/dns/editzonerecord.yml +61 -43
  193. data/spec/vcr_cassettes/whm/dns/getzonerecord.yml +60 -43
  194. data/spec/vcr_cassettes/whm/dns/killdns.yml +42 -29
  195. data/spec/vcr_cassettes/whm/dns/listmxs.yml +23 -15
  196. data/spec/vcr_cassettes/whm/dns/listzones.yml +22 -15
  197. data/spec/vcr_cassettes/whm/dns/lookupnsip.yml +40 -29
  198. data/spec/vcr_cassettes/whm/dns/removezonerecord.yml +61 -43
  199. data/spec/vcr_cassettes/whm/dns/resetzone.yml +42 -29
  200. data/spec/vcr_cassettes/whm/dns/resolvedomainname.yml +40 -29
  201. data/spec/vcr_cassettes/whm/dns/savemxs.yml +23 -15
  202. data/spec/vcr_cassettes/whm/reseller/acctcounts.yml +41 -29
  203. data/spec/vcr_cassettes/whm/reseller/listacls.yml +22 -15
  204. data/spec/vcr_cassettes/whm/reseller/listresellers.yml +22 -15
  205. data/spec/vcr_cassettes/whm/reseller/resellerstats.yml +42 -29
  206. data/spec/vcr_cassettes/whm/reseller/saveacllist.yml +76 -57
  207. data/spec/vcr_cassettes/whm/reseller/setacls.yml +40 -29
  208. data/spec/vcr_cassettes/whm/reseller/setresellerips.yml +42 -28
  209. data/spec/vcr_cassettes/whm/reseller/setresellerlimits.yml +41 -29
  210. data/spec/vcr_cassettes/whm/reseller/setresellermainip.yml +59 -43
  211. data/spec/vcr_cassettes/whm/reseller/setresellernameservers.yml +58 -43
  212. data/spec/vcr_cassettes/whm/reseller/setresellerpackagelimit.yml +61 -43
  213. data/spec/vcr_cassettes/whm/reseller/setupreseller.yml +41 -29
  214. data/spec/vcr_cassettes/whm/reseller/suspendreseller.yml +75 -44
  215. data/spec/vcr_cassettes/whm/reseller/terminatereseller.yml +83 -46
  216. data/spec/vcr_cassettes/whm/reseller/unsetupreseller.yml +41 -29
  217. data/spec/vcr_cassettes/whm/reseller/unsuspendreseller.yml +46 -29
  218. data/spec/vcr_cassettes/whm/server/addip.yml +24 -15
  219. data/spec/vcr_cassettes/whm/server/applist.yml +22 -15
  220. data/spec/vcr_cassettes/whm/server/delip.yml +23 -15
  221. data/spec/vcr_cassettes/whm/server/gethostname.yml +22 -15
  222. data/spec/vcr_cassettes/whm/server/getlanglist.yml +22 -15
  223. data/spec/vcr_cassettes/whm/server/gettweaksetting.yml +44 -0
  224. data/spec/vcr_cassettes/whm/server/listips.yml +22 -15
  225. data/spec/vcr_cassettes/whm/server/loadavg.yml +26 -19
  226. data/spec/vcr_cassettes/whm/server/my_function.yml +59 -43
  227. data/spec/vcr_cassettes/whm/server/nvget.yml +22 -15
  228. data/spec/vcr_cassettes/whm/server/nvset.yml +22 -15
  229. data/spec/vcr_cassettes/whm/server/reboot.yml +22 -15
  230. data/spec/vcr_cassettes/whm/server/sethostname.yml +24 -15
  231. data/spec/vcr_cassettes/whm/server/setresolvers.yml +23 -15
  232. data/spec/vcr_cassettes/whm/server/settweaksetting.yml +44 -0
  233. data/spec/vcr_cassettes/whm/server/showbw.yml +22 -15
  234. data/spec/vcr_cassettes/whm/server/systemloadavg.yml +40 -29
  235. data/spec/vcr_cassettes/whm/server/themes.yml +38 -0
  236. data/spec/vcr_cassettes/whm/server/version.yml +22 -15
  237. data/spec/whm/account_spec.rb +40 -199
  238. data/spec/whm/base_spec.rb +0 -4
  239. data/spec/whm/cert_spec.rb +99 -0
  240. data/spec/whm/dns_spec.rb +5 -123
  241. data/spec/whm/reseller_spec.rb +11 -79
  242. data/spec/whm/server_spec.rb +85 -142
  243. metadata +367 -47
  244. data/.rvmrc +0 -49
  245. data/lib/lumberg/whm/args.rb +0 -113
  246. data/lib/net_http_hacked.rb +0 -42
  247. data/spec/vcr_cassettes/whm/server/response_type.yml +0 -85
  248. data/spec/whm/args_spec.rb +0 -179
@@ -0,0 +1,206 @@
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
+ end
205
+ end
206
+ 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,29 @@
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/file_manager"
18
+ require "lumberg/cpanel/zone_edit"
19
+ require "lumberg/cpanel/support"
20
+ require "lumberg/cpanel/random_data"
21
+ require "lumberg/cpanel/net"
22
+ require "lumberg/cpanel/mime"
23
+ require "lumberg/cpanel/redirect"
24
+ require "lumberg/cpanel/gpg"
25
+ require "lumberg/cpanel/locale"
26
+ require "lumberg/cpanel/mysql"
27
+ require "lumberg/cpanel/domain_keys"
28
+ end
29
+ end
@@ -0,0 +1,125 @@
1
+ module Lumberg
2
+ class FormatWhm < Faraday::Response::Middleware
3
+
4
+ def initialize(env, *args, &block)
5
+ @type = args[0]
6
+ @key = args[1]
7
+ @boolean_params = args[2]
8
+ super(env)
9
+ end
10
+
11
+ def on_complete(env)
12
+ env[:body] = format_response(env[:body])
13
+ end
14
+
15
+ def response_values(env)
16
+ {:status => env[:status], :headers => env[:response_headers], :body => env[:body]}
17
+ end
18
+
19
+ private
20
+
21
+ def format_response(response)
22
+ success, message, params = false, nil, {}
23
+
24
+ case @type || response_type(response)
25
+ when :action
26
+ success, message, params = format_action_response(response)
27
+ when :query
28
+ success, message, params = format_query_response(response)
29
+ when :ssl
30
+ success, message, params = format_ssl_response(response)
31
+ when :error
32
+ message = response['error']
33
+ when :unknown
34
+ message = "Unknown error occurred #{response.inspect}"
35
+ end
36
+
37
+ params = Whm::symbolize_keys(params)
38
+ params = Whm::to_bool(params, @boolean_params)
39
+
40
+ {:success => success, :message => message, :params => params}
41
+ end
42
+
43
+ def response_type(response)
44
+ if !response.respond_to?(:has_key?)
45
+ :unknown
46
+ elsif response.has_key?('error')
47
+ :error
48
+ elsif response.has_key?(@key)
49
+ :action
50
+ elsif response.has_key?('status') && response.has_key?('statusmsg')
51
+ :query
52
+ else
53
+ :unknown
54
+ end
55
+ end
56
+
57
+ def format_action_response(response)
58
+ # Some API methods ALSO return a 'status' as
59
+ # part of a result. We only use this value if it's
60
+ # part of the results hash
61
+ item = response[@key]
62
+ unless item.is_a?(Array) || item.is_a?(Hash)
63
+ res = {@key => item}
64
+ success, message = true, ""
65
+ else
66
+ result = nil
67
+ if item.first.is_a?(Hash)
68
+ result = item.first
69
+ res = (item.size > 1 ? item.dup : item.first.dup)
70
+ else
71
+ res = item.dup
72
+
73
+ # more hacks for WHM silly API
74
+ if response.has_key?('result')
75
+ result_node = response['result']
76
+ node_with_key_status = result_node.is_a?(Hash) && result_node.has_key?('status')
77
+ result = (node_with_key_status ? result_node : result_node.first)
78
+ else
79
+ res.delete('status')
80
+ res.delete('statusmsg')
81
+ end
82
+ end
83
+ unless result.nil?
84
+ success = result['status'].to_i == 1
85
+ message = result['statusmsg']
86
+ end
87
+ end
88
+ return success, message, res
89
+ end
90
+
91
+ def format_query_response(response)
92
+ success = response['status'].to_i == 1
93
+ message = response['statusmsg']
94
+
95
+ # returns the rest as a params arg
96
+ res = response.dup
97
+ res.delete('status')
98
+ res.delete('statusmsg')
99
+
100
+ return success, message, res
101
+ end
102
+
103
+ def format_ssl_response(response)
104
+ if response.has_key?('crt')
105
+ success = response['crt'].any?
106
+ message = true
107
+ res = response['crt']
108
+ elsif response.has_key?('sslinfo')
109
+ success = response['sslinfo'].first.fetch('status').to_i == 1
110
+ message = response['sslinfo'].first.fetch('statusmsg')
111
+ # returns the rest as a params arg
112
+ res = response['sslinfo'].first.dup
113
+ res.delete('status')
114
+ res.delete('statusmsg')
115
+ elsif response.has_key?('results')
116
+ success, message = response['results'].values_at 'status', 'message'
117
+ # returns the rest as a params arg
118
+ res = response['results'].dup
119
+ res.delete('status')
120
+ res.delete('message')
121
+ end
122
+ return success, message, res
123
+ end
124
+ end
125
+ end
@@ -1,3 +1,3 @@
1
1
  module Lumberg
2
- VERSION = '1.0.1'
2
+ VERSION = '2.0.0.pre4'
3
3
  end