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,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b22e147b50255ebe87b7c3592dc4f6e42c1d15cb
4
+ data.tar.gz: aaea7f8b4385e62a9913f77d72a0a6efe754a9b3
5
+ SHA512:
6
+ metadata.gz: 20e11aa01b835eea33dceccf8fcf758b58dae495896b5c2b45cab92c474a389dab8c9590fed251fff9c3820f066af321c0e4f28b5e6b674b34899bc31cea09b5
7
+ data.tar.gz: e3d4b304d424184e3e5d8137c8240d8c59ff16c87e5bba7d117c3279418d193b28fe4534a0557fbe6f28f6dcc03b627c02fe04549ba9fab9742be947f4636cd6
@@ -7,11 +7,6 @@ notifications:
7
7
  on_success: never
8
8
  on_failure: always
9
9
  rvm:
10
- - 1.8.7
11
- - 1.9.2
12
10
  - 1.9.3
13
- - ree
14
- - rbx-head
15
- - rbx-18mode
16
- - jruby-18mode
11
+ - 2.0.0
17
12
  - jruby-19mode
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) 2012 Site5.com. See LICENSE for details.
353
+ Copyright (c) 2012-2013 Site5.com. See LICENSE for details.
@@ -7,6 +7,7 @@ require 'uri'
7
7
  require 'faraday'
8
8
  require 'faraday_middleware'
9
9
  require 'logger'
10
+ require 'resolv'
10
11
 
11
12
  # Internal Libs
12
13
  require 'lumberg/format_whm'
@@ -14,6 +15,7 @@ require 'lumberg/version'
14
15
  require 'lumberg/exceptions'
15
16
  require 'lumberg/config'
16
17
  require 'lumberg/whm'
18
+ require 'lumberg/cpanel'
17
19
 
18
20
  module Lumberg
19
21
 
@@ -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,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