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
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8729386fae62f1240d8ca35e0b2440a5c13fd121
4
+ data.tar.gz: 0da476df19735bf334e8addb63f6507e1946a6be
5
+ SHA512:
6
+ metadata.gz: 48a7cf27c6d95dd99e2fe3553f8c91fe12a96a58996c38f0058997131798d55b5c317876a255d04059d586b36386a35cf3ba1749529766bfadf7f209681be0b7
7
+ data.tar.gz: ec675a24333fa0ba2b7e6070959c57eb7663a4df9b7a351818ecb5a165e50f7a20ce5e0a53a6818cddefaacc819e99d8f2eb0ce9b7d2f18656948d7becef927c
data/.travis.yml CHANGED
@@ -1,11 +1,12 @@
1
+ language: ruby
1
2
  script: "bundle exec rake spec"
2
3
  notifications:
3
- disabled: true
4
+ email:
5
+ recipients:
6
+ - engineering@internal.site5.com
7
+ on_success: never
8
+ on_failure: always
4
9
  rvm:
5
- - 1.8.7
6
- - 1.9.2
7
10
  - 1.9.3
8
- - ree
9
- - rbx
10
- - rbx-head
11
- - jruby
11
+ - 2.0.0
12
+ - jruby-19mode
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011 Site5 LLC
1
+ Copyright (c) 2012 Site5.com <http://www.site5.com>
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,5 +1,4 @@
1
- Lumberg [![Lumberg Build Status][Build Icon]][Build Status]
2
- ===========================================================
1
+ # Lumberg [![Lumberg Build Status][Build Icon]][Build Status]
3
2
 
4
3
  ![Lumberg logo](http://i.imgur.com/xC4Sw.jpg)
5
4
 
@@ -8,21 +7,19 @@ beta-ish. Please report any issues you find. :)
8
7
 
9
8
  [RDoc](http://rdoc.info/github/site5/lumberg/master/frames)
10
9
 
11
- Confirmed to work with ruby 1.8.7, 1.9.2, Rubinius, REE and JRuby 1.6.0 on
10
+ Confirmed to work with ruby 1.8.7, 1.9.2, REE and JRuby 1.6.0 on
12
11
  cPanel 11.28+
13
12
 
14
13
  [Build Status]: http://travis-ci.org/site5/lumberg
15
14
  [Build Icon]: https://secure.travis-ci.org/site5/lumberg.png?branch=master
16
15
 
17
16
 
18
- Install
19
- -------
17
+ ## Install
20
18
 
21
19
  gem install lumberg
22
20
 
23
21
 
24
- Usage
25
- -----
22
+ ## Usage
26
23
 
27
24
  Create a server object and connect to WHM using your host and hash:
28
25
 
@@ -108,8 +105,7 @@ pp result[:params][:acct].first
108
105
  ```
109
106
 
110
107
 
111
- Account Example
112
- ---------------
108
+ ### Account Example
113
109
 
114
110
  Creating a new account requires only a username, domain, and password.
115
111
 
@@ -168,8 +164,7 @@ newuser account removed
168
164
  ```
169
165
 
170
166
 
171
- Reseller Example
172
- ----------------
167
+ ### Reseller Example
173
168
 
174
169
  Creating a reseller works by changing the status of an existing user account,
175
170
  so first we create a user account and then we can create that user as a reseller.
@@ -218,20 +213,133 @@ p result[:message]
218
213
  Account Terminations Complete
219
214
  ```
220
215
 
221
- Contributors
222
- ============
216
+ ### Accessing cPanel API
223
217
 
224
- * [Justin Mazzi](http://github.com/jmazzi)
225
- * [Tim Parkin](http://github.com/tparkin)
218
+ [cPanel API](http://docs.cpanel.net/twiki/bin/view/SoftwareDevelopmentKit/ApiIntroduction)
219
+ interface is provided by the `Lumberg::Cpanel` module. Classes within the module
220
+ correspond to cPanel API modules. cPanel API module coverage is currently
221
+ incomplete and we're seeking contributions. Check out [Extending
222
+ Lumberg::Cpanel](#extending-lumbergcpanel) for details on how you can help.
226
223
 
227
- Note on Patches/Pull Requests
228
- =============================
229
224
 
230
- All HTTP interactions are recorded using VCR and FakeWeb. Please be sure to
231
- remove any sensitive information from your cassettes.
225
+ #### Email example
226
+
227
+ ```ruby
228
+ # Create an interface object for cPanel API Email module
229
+ email = Lumberg::Cpanel::Email.new(
230
+ :server => server, # An instance of Lumberg::Server
231
+ :api_username => "jerry" # User whose cPanel we'll be interacting with
232
+ )
233
+
234
+ # Get a list of email accounts
235
+ email.accounts[:params][:data] #=> Array of info hashes for each email account
236
+
237
+ # Add an email forwarder to forward mail for my-forwarder@domain.com to
238
+ # dest@other-domain.com
239
+ email.add_forwarder(
240
+ :domain => "domain.com",
241
+ :email => "my-forwarder",
242
+ :fwdopt => "fwd",
243
+ :fwdemail => "dest@other-domain.com"
244
+ )
245
+
246
+ ```
247
+
248
+ ## Contributing
249
+
250
+ ### Extending Lumberg::Cpanel
251
+
252
+ 1. Find a cPanel API module that isn't already covered. See
253
+ [cPanel API documentation](http://docs.cpanel.net/twiki/bin/view/SoftwareDevelopmentKit/ApiIntroduction)
254
+ for a full list of available API modules.
255
+
256
+ 2. Create a file (underscore style) in `lib/lumberg/cpanel/` named after the
257
+ cPanel API module you're working on. If the cPanel API module is "LangMods"
258
+ name the file "lang_mods.rb". You'll define your class here. `require` this
259
+ file from `lib/lumberg/cpanel.rb`.
260
+
261
+ 3. Define a class that inherits from `Lumberg::Cpanel::Base`:
262
+ ```ruby
263
+ # Create a class for (fictional) "SomeModule" API module
264
+ module Lumberg
265
+ module Cpanel
266
+ class SomeModule < Base
267
+ end
268
+ end
269
+ end
270
+ ```
271
+ The cPanel API module name is normally inferred from the class name, e.g., if
272
+ the class name is `Email` the cPanel "Email" API module will be used. If the
273
+ cPanel API module you're working with doesn't match up with Ruby class naming
274
+ convention, override the `::api_module` class method:
275
+ ```ruby
276
+ module Lumberg
277
+ module Cpanel
278
+ class SslInfo
279
+ def self.api_module; "SSLInfo"; end
280
+ end
281
+ end
282
+ end
283
+ ```
284
+ 4. Fill in the methods.
285
+ ```ruby
286
+ module Lumberg
287
+ module Cpanel
288
+ class Branding
289
+ # Public: Get URL locations for specific sprites.
290
+ #
291
+ # options - Hash options for API call params (default: {}):
292
+ # :img - String branding object label for the image you want to
293
+ # retrieve.
294
+ # :imgtype - String branding image type you want to retrieve, e.g.,
295
+ # "icon" or "heading".
296
+ # :method - String specification for returned value options.
297
+ # Acceptable values are: "only_filetype_gif",
298
+ # "skip_filetype_gif", "snap_to_smallest_width", and
299
+ # "scale_60percent".
300
+ # :subtype - String branding image subtype, e.g., "img", "bg",
301
+ # "compleximg".
302
+ # :image - String parameter allows you to force appropriate
303
+ # output by setting it to "heading" (optional).
304
+ # :skipgroups - String parameter allows you to specify whether or not
305
+ # to include "img" values that begin with "group_" in
306
+ # the output. "1" indicates that you wish to skip "img"
307
+ # values that begin with "group_" (optional).
308
+ #
309
+ # Returns Hash API response.
310
+ def list_sprites(options = {})
311
+ perform_request({
312
+ :api_function => "spritelist"
313
+ }.merge(options))
314
+ end
315
+ end
316
+ end
317
+ end
318
+ ```
319
+ - In many cases, you'll name your methods to match up
320
+ with the documented cPanel API methods. However, the documented method
321
+ names are sometimes a bit lengthy, confusing, or otherwise unwiedly; feel
322
+ free to give your corresponding method an improved name.
323
+ - Use [TomDoc](http://tomdoc.org/) documentation for your methods.
324
+ Be sure to document all required and optional parameters from the
325
+ cPanel API documentation.
326
+ - All methods should take an options arg that defaults to {}.
327
+ These options should be merged onto the options passed to
328
+ #perform_request to allow overriding of :api_username or
329
+ other parameters.
330
+
331
+ ### Sanitizing VCR cassettes
332
+ All HTTP interactions are recorded using VCR and FakeWeb. Please be sure to remove
333
+ sensitive data from your cassettes. A Rake task is provided for this purpose:
334
+ ```
335
+ WHM_HOST=my-cpanel-server.com WHM_HASH=$(cat my-access-hash) bundle exec rake sanitize_cassettes
336
+ ```
337
+ Once you've sanitized your cassettes, manually verify that there's no sensitive
338
+ information still present (check URLs, authorization params, etc.).
339
+
340
+ ### Note on Patches/Pull Requests
232
341
 
233
342
  * Fork the project.
234
- * Add yourself to the Contributors list
235
343
  * Make your feature addition or bug fix.
236
344
  * Add tests for it. This is important so I don't break it in a
237
345
  future version unintentionally.
@@ -240,7 +348,6 @@ remove any sensitive information from your cassettes.
240
348
  commit by itself I can ignore when I pull)
241
349
  * Send me a pull request. Bonus points for topic branches.
242
350
 
243
- Copyright
244
- =========
351
+ ## Copyright
245
352
 
246
- Copyright (c) 2011 Site5. See LICENSE for details.
353
+ Copyright (c) 2012-2013 Site5.com. See LICENSE for details.
data/Rakefile CHANGED
@@ -14,6 +14,8 @@ begin
14
14
  rescue LoadError
15
15
  end
16
16
 
17
+ load 'vcr/tasks/vcr.rake'
18
+
17
19
  RSpec::Core::RakeTask.new :spec
18
20
  Bundler::GemHelper.install_tasks
19
21
 
@@ -26,7 +28,7 @@ task :sanitize_cassettes do
26
28
  files.each do |file|
27
29
  old = File.read(file)
28
30
  if old.match(/#{ENV['WHM_HASH']}|#{ENV['WHM_HOST']}/)
29
- puts "Sanitizing #{file}"
31
+ puts "Sanitizing #{file}"
30
32
  old.gsub!(ENV['WHM_HASH'], 'iscool')
31
33
  old.gsub!(ENV['WHM_HOST'], 'myhost.com')
32
34
  File.open(file, 'w') do |f|
@@ -0,0 +1,19 @@
1
+ module Lumberg
2
+ # Holds the configuration for Lumberg
3
+ class Config
4
+ attr_accessor :options
5
+
6
+ def initialize
7
+ @options = {}
8
+ end
9
+
10
+ def [](v)
11
+ @options[v]
12
+ end
13
+
14
+ # Debug output. value can be either true to output to $stderr or a path to a file
15
+ def debug(output)
16
+ @options[:debug] = output
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,50 @@
1
+ module Lumberg
2
+ module Cpanel
3
+ class AddonDomain < Base
4
+ # Public: Delete an addon domain. This will also remove the corresponding
5
+ # subdomain and FTP account.
6
+ #
7
+ # options - Hash options for API call params (default: {}):
8
+ # :domain - String addon domain to be deleted.
9
+ # :subdomain - String adddon domain's username followed by "_", then
10
+ # the addon domain's main domain, e.g.,
11
+ # "user_addon.com"
12
+ #
13
+ # Returns Hash API response.
14
+ def remove(options = {})
15
+ perform_request({
16
+ :api_function => "deladdondomain"
17
+ }.merge(options))
18
+ end
19
+
20
+ # Public: Add an addon domain with a coresponding subdomain.
21
+ #
22
+ # options - Hash options for API call params (default: {}):
23
+ # :dir - String path for addon domain docroot.
24
+ # :newdomain - String domain to use for addon domain.
25
+ # :subdomain - String subdomain / FTP username corresponding to new
26
+ # addon domain, e.g., "user".
27
+ #
28
+ # Returns Hash API response.
29
+ def add(options = {})
30
+ perform_request({
31
+ :api_function => "addaddondomain"
32
+ }.merge(options))
33
+ end
34
+
35
+ # Public: Get a list of addon domains.
36
+ #
37
+ # options - Hash options for API call params (default: {}):
38
+ # :regex - String regular expression to filter search results
39
+ # (optional).
40
+ #
41
+ # Returns Hash API response.
42
+ def list(options={})
43
+ perform_request({
44
+ :api_function => "listaddondomains"
45
+ }.merge(options))
46
+ end
47
+ end
48
+ end
49
+ end
50
+
@@ -0,0 +1,16 @@
1
+ module Lumberg
2
+ module Cpanel
3
+ class Backups < Base
4
+ # Public: Get a list backups.
5
+ #
6
+ # options - Hash options for API call params (default: {})
7
+ #
8
+ # Returns Hash API response.
9
+ def list(options = {})
10
+ perform_request({
11
+ :api_function => "listfullbackups"
12
+ }.merge(options))
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,56 @@
1
+ module Lumberg
2
+ module Cpanel
3
+ class Base < Whm::Base
4
+ attr_accessor :api_username
5
+
6
+ # Public: Gets cPanel API module name based on class name. This method
7
+ # should be overriden in subclasses where the cPanel API module name
8
+ # and the class name don't match up.
9
+ #
10
+ # Returns String cPanel API module name.
11
+ def self.api_module
12
+ self.name.split("::").last
13
+ end
14
+
15
+ # Public: Initialize a new cPanel API interface.
16
+ #
17
+ # options - Hash options (default: {}):
18
+ # :api_username - String username to set as the default account
19
+ # username for cPanel API calls (optional).
20
+ def initialize(options = {})
21
+ @api_username = options.delete(:api_username)
22
+
23
+ super options
24
+ end
25
+
26
+ # Public: Perform a cPanel API method call.
27
+ #
28
+ # options - Hash options for API call params (default: {}):
29
+ # :api_function - String API function name to call.
30
+ # :api_module - String API module on which API function will be
31
+ # called (optional, default: self.class.api_module).
32
+ # :response_key - String key used to select desired part of API
33
+ # response (optional, default: "cpanelresult").
34
+ # :api_username - String account username for API call (optional,
35
+ # default: @api_username)
36
+ # :api_version - Integer cPanel API version to use (optional,
37
+ # default: 2)
38
+ #
39
+ # Returns Hash API response.
40
+ def perform_request(options = {})
41
+ options[:api_username] ||= api_username
42
+
43
+ api_module = options.delete(:api_module) || self.class.api_module
44
+ params = {
45
+ :response_key => options.delete(:response_key) || "cpanelresult",
46
+ :cpanel_jsonapi_user => options.delete(:api_username),
47
+ :cpanel_jsonapi_module => api_module,
48
+ :cpanel_jsonapi_func => options.delete(:api_function),
49
+ :cpanel_jsonapi_apiversion => options.delete(:api_version) || 2,
50
+ }.merge(options)
51
+
52
+ server.perform_request("cpanel", params)
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,18 @@
1
+ module Lumberg
2
+ module Cpanel
3
+ class BoxTrapper < Base
4
+ # Public: Get list of email accounts and their BoxTrapper statuses.
5
+ #
6
+ # options - Hash options for API call params (default: {}):
7
+ # :regex - String regular expression to filter search results
8
+ # (optional).
9
+ #
10
+ # Returns Hash API response.
11
+ def list(options = {})
12
+ perform_request({
13
+ :api_function => "accountmanagelist"
14
+ }.merge(options))
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,89 @@
1
+ module Lumberg
2
+ module Cpanel
3
+ class Branding < Base
4
+ # Public: Get list of branding packages.
5
+ #
6
+ # options - Hash options for API call params (default: {}):
7
+ # :onlyshowyours - Return only packages that the user owns?
8
+ # String "1" or "0" (optional).
9
+ # :showroot - Only return system branding packages?
10
+ # String "1" or "0" (optional).
11
+ # :skipglobal - Only return customized branding packages?
12
+ # String "1" or "0" (optional).
13
+ # :skiphidden - Skip branding packages owned by the user?
14
+ # String "1" or "0" (optional).
15
+ #
16
+ # Returns Hash API response.
17
+ def list_pkgs(options = {})
18
+ perform_request({
19
+ :api_function => "showpkgs"
20
+ }.merge(options))
21
+ end
22
+
23
+ # Public: Get URL locations for specific sprites.
24
+ #
25
+ # options - Hash options for API call params (default: {}):
26
+ # :img - String branding object label for the image you want to
27
+ # retrieve.
28
+ # :imgtype - String branding image type you want to retrieve, e.g.,
29
+ # "icon" or "heading".
30
+ # :method - String specification for returned value options.
31
+ # Acceptable values are: "only_filetype_gif",
32
+ # "skip_filetype_gif", "snap_to_smallest_width", and
33
+ # "scale_60percent".
34
+ # :subtype - String branding image subtype, e.g., "img", "bg",
35
+ # "compleximg".
36
+ # :image - String parameter allows you to force appropriate
37
+ # output by setting it to "heading" (optional).
38
+ # :skipgroups - String parameter allows you to specify whether or not
39
+ # to include "img" values that begin with "group_" in
40
+ # the output. "1" indicates that you wish to skip "img"
41
+ # values that begin with "group_" (optional).
42
+ #
43
+ # Returns Hash API response.
44
+ def list_sprites(options = {})
45
+ perform_request({
46
+ :api_function => "spritelist"
47
+ }.merge(options))
48
+ end
49
+
50
+ # Public: Retrieve a list of icons within the x3 interface.
51
+ #
52
+ # options - Hash options for API call params (default: {}):
53
+ # :nvarglist - String parameter allows you to specify the order in
54
+ # which you wish to have groups returned, separated by
55
+ # pipes, e.g., "mail|files|domains|logs". This is the
56
+ # last filter on the data and is stored in your
57
+ # xmaingroupsorder NVDATA variable (optional).
58
+ #
59
+ # Returns Hash API response.
60
+ def list_icons(options = {})
61
+ perform_request({
62
+ :api_function => "applist"
63
+ }.merge(options))
64
+ end
65
+
66
+ # Public: Get list of branding object types.
67
+ #
68
+ # options - Hash options for API call params (default: {}):
69
+ #
70
+ # Returns Hash API response.
71
+ def list_object_types(options = {})
72
+ perform_request({
73
+ :api_function => "listobjecttypes"
74
+ }.merge(options))
75
+ end
76
+
77
+ # Public: Get list of branding image types.
78
+ #
79
+ # options - Hash options for API call params (default: {}):
80
+ #
81
+ # Returns Hash API response.
82
+ def list_image_types(options = {})
83
+ perform_request({
84
+ :api_function => "listimgtypes"
85
+ }.merge(options))
86
+ end
87
+ end
88
+ end
89
+ end
@@ -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