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
@@ -26,6 +26,8 @@ module Lumberg
26
26
  success, message, params = format_action_response(response)
27
27
  when :query
28
28
  success, message, params = format_query_response(response)
29
+ when :ssl
30
+ success, message, params = format_ssl_response(response)
29
31
  when :error
30
32
  message = response['error']
31
33
  when :unknown
@@ -98,5 +100,26 @@ module Lumberg
98
100
  return success, message, res
99
101
  end
100
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
101
124
  end
102
- end
125
+ end
@@ -1,3 +1,3 @@
1
1
  module Lumberg
2
- VERSION = '1.1.1'
2
+ VERSION = '2.0.0.pre3'
3
3
  end
@@ -5,6 +5,7 @@ module Lumberg
5
5
  autoload :Account, 'lumberg/whm/account'
6
6
  autoload :Dns, 'lumberg/whm/dns'
7
7
  autoload :Reseller, 'lumberg/whm/reseller'
8
+ autoload :Cert, 'lumberg/whm/cert'
8
9
 
9
10
  class << self
10
11
 
@@ -24,7 +25,7 @@ module Lumberg
24
25
  arg
25
26
  end
26
27
  end
27
-
28
+
28
29
  # Recursively converts values of 0 or 1 to true or false
29
30
  def to_bool(hash, *keys)
30
31
  if keys.empty?
@@ -42,7 +42,7 @@ module Lumberg
42
42
  def change_password(options = {})
43
43
  options[:user] = options.delete(:username)
44
44
  options[:pass] = options.delete(:password)
45
- server.perform_request('passwd', options.merge(:key => 'passwd'))
45
+ server.perform_request('passwd', options.merge(:response_key => 'passwd'))
46
46
  end
47
47
 
48
48
  # Displays pertinent information about a specific account
@@ -159,7 +159,7 @@ module Lumberg
159
159
  # ==== Required
160
160
  # * <tt>:domain</tt> - PENDING
161
161
  def domain_user_data(options = {})
162
- server.perform_request('domainuserdata', options.merge(:key => 'userdata')) do |s|
162
+ server.perform_request('domainuserdata', options.merge(:response_key => 'userdata')) do |s|
163
163
  s.boolean_params = :hascgi
164
164
  end
165
165
  end
@@ -196,7 +196,7 @@ module Lumberg
196
196
  # * <tt>:username</tt> - PENDING
197
197
  def privs(options ={})
198
198
  verify_user(options[:username]) do
199
- resp = server.perform_request('myprivs', options.merge(:key => 'privs')) do |s|
199
+ resp = server.perform_request('myprivs', options.merge(:response_key => 'privs')) do |s|
200
200
  s.boolean_params = :all
201
201
  end
202
202
  # if you get this far, it's successful
@@ -226,7 +226,7 @@ module Lumberg
226
226
  # * <tt>:subs</tt> - PENDING
227
227
  def restore_account(options = {})
228
228
  options[:user] = options.delete(:username) if options[:username]
229
- server.perform_request('restoreaccount', options.merge(:key => 'metadata'))
229
+ server.perform_request('restoreaccount', options.merge(:response_key => 'metadata'))
230
230
  end
231
231
 
232
232
  protected
@@ -0,0 +1,69 @@
1
+ module Lumberg
2
+ module Whm
3
+ class Cert < Base
4
+
5
+ # Displays the SSL certificate, private key, and CA bundle/intermediate
6
+ # certificate associated with a specified domain. Alternatively, it can
7
+ # display the private key and CA bundle associated with a specified cert
8
+ #
9
+ # ==== Required
10
+ # * <tt>:domain</tt> - PENDING
11
+ # * <tt>:crtdata</tt> - PENDING
12
+ #
13
+ # ==== Optional
14
+ # * <tt>none</tt> - PENDING
15
+ def fetchsslinfo(options = {})
16
+ server.force_response_type = :ssl
17
+ result = server.perform_request('fetchsslinfo', options)
18
+ end
19
+
20
+ # Generates a CSR
21
+ #
22
+ # ==== Required
23
+ # * <tt>:xemail</tt> - PENDING
24
+ # * <tt>:host</tt> - PENDING
25
+ # * <tt>:country</tt> - PENDING
26
+ # * <tt>:state</tt> - PENDING
27
+ # * <tt>:city</tt> - PENDING
28
+ # * <tt>:co</tt> - PENDING
29
+ # * <tt>:cod</tt> - PENDING
30
+ # * <tt>:email</tt> - PENDING
31
+ # * <tt>:pass</tt> - PENDING
32
+ #
33
+ # ==== Optional
34
+ # * <tt>none</tt> - PENDING
35
+ def generatessl(options = {})
36
+ server.force_response_type = :ssl
37
+ result = server.perform_request('generatessl', options)
38
+ end
39
+
40
+ # Install an SSL certificate
41
+ #
42
+ # ==== Required
43
+ # * <tt>:user</tt> - PENDING
44
+ # * <tt>:domain</tt> - PENDING
45
+ # * <tt>:cert</tt> - PENDING
46
+ # * <tt>:key</tt> - PENDING
47
+ # * <tt>:cab</tt> - PENDING
48
+ # * <tt>:ip</tt> - PENDING
49
+ #
50
+ # ==== Optional
51
+ # * <tt>none</tt> - PENDING
52
+ def installssl(options = {})
53
+ result = server.perform_request('installssl', options)
54
+ end
55
+
56
+ # List all the domains on the server that have SSL certificates installed
57
+ #
58
+ # ==== Required
59
+ # * <tt>none</tt> - PENDING
60
+ #
61
+ # ==== Optional
62
+ # * <tt>none</tt> - PENDING
63
+ def listcrts(options = {})
64
+ server.force_response_type = :ssl
65
+ result = server.perform_request('listcrts', options.merge(:response_key => 'crt'))
66
+ end
67
+ end
68
+ end
69
+ end
@@ -37,7 +37,7 @@ module Lumberg
37
37
 
38
38
  # Generates a list of all domains and corresponding DNS zones associated with your server
39
39
  def list_zones(options = {})
40
- server.perform_request('listzones', options.merge(:key => 'zone'))
40
+ server.perform_request('listzones', options.merge(:response_key => 'zone'))
41
41
  end
42
42
 
43
43
  # Return zone records for a domain.
@@ -66,7 +66,7 @@ module Lumberg
66
66
  # * <tt>:domain</tt> - PENDING
67
67
  # * <tt>:"api.version".to_sym</tt> - PENDING
68
68
  def resolve_domain(options = {})
69
- server.perform_request('resolvedomainname', options.merge(:key => 'data'))
69
+ server.perform_request('resolvedomainname', options.merge(:response_key => 'data'))
70
70
  end
71
71
 
72
72
  # Allows you to edit a DNS zone record on the server.
@@ -104,7 +104,7 @@ module Lumberg
104
104
  # ==== Required
105
105
  # * <tt>:nameserver</tt> - PENDING
106
106
  def lookup_nameserver_ip(options = {})
107
- server.perform_request('lookupnsip', options.merge(:key => 'ip'))
107
+ server.perform_request('lookupnsip', options.merge(:response_key => 'ip'))
108
108
  end
109
109
 
110
110
  # Allows you to remove a DNS zone record from the server.
@@ -131,6 +131,30 @@ module Lumberg
131
131
  server.perform_request('resetzone', options)
132
132
  end
133
133
 
134
+ # This function will change a specified domain's MX records
135
+ #
136
+ # ==== Required
137
+ # * <tt>:domain</tt> - PENDING
138
+ # * <tt>:exchange</tt> - PENDING
139
+ # * <tt>:oldexchange</tt> - PENDING
140
+ # * <tt>:oldpreference</tt> - PENDING
141
+ # * <tt>:preference</tt> - PENDING
142
+ # * <tt>:alwaysaccept</tt> - PENDING
143
+ def change_mx(options = {})
144
+ server.perform_request('changemx', options.merge(:response_key => 'data'))
145
+ end
146
+
147
+ # This function will add an MX record to a specified domain
148
+ #
149
+ # ==== Required
150
+ # * <tt>:domain</tt> - PENDING
151
+ # * <tt>:exchange</tt> - PENDING
152
+ # * <tt>:preference</tt> - PENDING
153
+ # * <tt>:alwaysaccept</tt> - PENDING
154
+ def add_mx(options = {})
155
+ server.perform_request('addmx', options.merge(:response_key => 'data'))
156
+ end
157
+
134
158
  # This function will list a specified domain's MX records
135
159
  #
136
160
  # *This function is only available in version 11.27/11.28+*
@@ -139,7 +163,7 @@ module Lumberg
139
163
  # * <tt>:domain</tt> - PENDING
140
164
  # * <tt>:"api.version".to_sym</tt> - PENDING
141
165
  def list_mxs(options = {})
142
- server.perform_request('listmxs', options.merge(:key => 'data'))
166
+ server.perform_request('listmxs', options.merge(:response_key => 'data'))
143
167
  end
144
168
 
145
169
  # This function will add an MX record
@@ -15,7 +15,7 @@ module Lumberg
15
15
  # Lists the usernames of all resellers on the server
16
16
  def list
17
17
  # This method is funky. That is all
18
- result = server.perform_request('listresellers', :key => 'reseller')
18
+ result = server.perform_request('listresellers', :response_key => 'reseller')
19
19
  result[:success] = true
20
20
  result[:params] = {:resellers => result.delete(:params)}
21
21
  result
@@ -115,7 +115,7 @@ module Lumberg
115
115
  # * <tt>:username</tt> - PENDING
116
116
  def account_counts(options = {})
117
117
  options[:user] = options.delete(:username)
118
- server.perform_request('acctcounts', options.merge(:key => 'reseller'))
118
+ server.perform_request('acctcounts', options.merge(:response_key => 'reseller'))
119
119
  end
120
120
 
121
121
  # Defines a reseller's nameservers. Additionally, you may use it to reset a reseller's nameservers to the default settings
@@ -140,7 +140,7 @@ module Lumberg
140
140
 
141
141
  # Lists the saved reseller ACL lists on the server
142
142
  def list_acls
143
- server.perform_request('listacls', {:key => 'acls'})
143
+ server.perform_request('listacls', {:response_key => 'acls'})
144
144
  end
145
145
 
146
146
  # Creates a new reseller ACL list
@@ -148,7 +148,7 @@ module Lumberg
148
148
  # ==== Required
149
149
  # * <tt>:acllist</tt> - PENDING
150
150
  def save_acl_list(options = {})
151
- server.perform_request('saveacllist', options.merge(:key => 'results'))
151
+ server.perform_request('saveacllist', options.merge(:response_key => 'results'))
152
152
  end
153
153
 
154
154
  # Sets the ACL for a reseller, or modifies specific ACL items for a reseller
@@ -39,6 +39,9 @@ module Lumberg
39
39
  # Force response type...ARG!
40
40
  attr_accessor :force_response_type
41
41
 
42
+ # HTTP read/open timeout
43
+ attr_accessor :timeout
44
+
42
45
  #
43
46
  # ==== Required
44
47
  # * <tt>:host</tt> - PENDING
@@ -55,12 +58,16 @@ module Lumberg
55
58
  @hash = format_hash(options.delete(:hash))
56
59
  @user = (options.has_key?(:user) ? options.delete(:user) : 'root')
57
60
  @basic_auth = options.delete(:basic_auth)
61
+ @timeout = options.delete(:timeout)
62
+
63
+ validate_server_host
64
+
58
65
  @base_url = format_url(options)
59
66
  end
60
67
 
61
68
  def perform_request(function, options = {})
62
69
  # WHM sometime uses different keys for the result hash
63
- @key = options.delete(:key) || 'result'
70
+ @response_key = options.delete(:response_key) || 'result'
64
71
  @function = function
65
72
  @params = format_query(options)
66
73
 
@@ -70,11 +77,11 @@ module Lumberg
70
77
  end
71
78
 
72
79
  def get_hostname
73
- perform_request('gethostname', {:key => 'hostname'})
80
+ perform_request('gethostname', {:response_key => 'hostname'})
74
81
  end
75
82
 
76
83
  def version
77
- perform_request('version', {:key => 'version'})
84
+ perform_request('version', {:response_key => 'version'})
78
85
  end
79
86
 
80
87
  def load_average
@@ -85,47 +92,75 @@ module Lumberg
85
92
  end
86
93
 
87
94
  def system_load_average(options = {})
88
- perform_request('systemloadavg', options.merge(:key => 'data'))
95
+ perform_request('systemloadavg', options.merge(:response_key => 'data'))
89
96
  end
90
97
 
91
98
  def languages
92
- perform_request('getlanglist', {:key => 'lang'})
99
+ perform_request('getlanglist', {:response_key => 'lang'})
100
+ end
101
+
102
+ def themes
103
+ perform_request('getlanglist', {:response_key => 'themes'})
93
104
  end
94
105
 
95
106
  def list_ips
96
- perform_request('listips', {:key => 'result'})
107
+ perform_request('listips', {:response_key => 'result'})
108
+ end
109
+
110
+ def get_tweaksetting(options = {})
111
+ request = perform_request('get_tweaksetting',
112
+ options.merge(
113
+ :response_key => 'data',
114
+ :'api.version' => 1
115
+ )
116
+ )
117
+
118
+ request[:success] = !request[:params].empty?
119
+ request
120
+ end
121
+
122
+ def set_tweaksetting(options = {})
123
+ request = perform_request('set_tweaksetting',
124
+ options.merge(
125
+ :response_key => 'metadata',
126
+ :'api.version' => 1
127
+ )
128
+ )
129
+
130
+ request[:success] = (request[:params][:reason] == 'OK')
131
+ request
97
132
  end
98
133
 
99
134
  def add_ip(options = {})
100
- perform_request('addip', options.merge(:key => 'addip'))
135
+ perform_request('addip', options.merge(:response_key => 'addip'))
101
136
  end
102
137
 
103
138
  def delete_ip(options = {})
104
- perform_request('delip', options.merge(:key => 'delip'))
139
+ perform_request('delip', options.merge(:response_key => 'delip'))
105
140
  end
106
141
 
107
142
  def set_hostname(options = {})
108
- perform_request('sethostname', options.merge(:key => 'sethostname'))
143
+ perform_request('sethostname', options.merge(:response_key => 'sethostname'))
109
144
  end
110
145
 
111
146
  def set_resolvers(options = {})
112
- perform_request('setresolvers', options.merge(:key => 'setresolvers'))
147
+ perform_request('setresolvers', options.merge(:response_key => 'setresolvers'))
113
148
  end
114
149
 
115
150
  def show_bandwidth(options = {})
116
- perform_request('showbw', options.merge(:key => 'bandwidth'))
151
+ perform_request('showbw', options.merge(:response_key => 'bandwidth'))
117
152
  end
118
153
 
119
154
  def set_nv_var(options = {})
120
- perform_request('nvset', options.merge(:key => 'nvset'))
155
+ perform_request('nvset', options.merge(:response_key => 'nvset'))
121
156
  end
122
157
 
123
158
  def get_nv_var(options = {})
124
- perform_request('nvget', options.merge(:key => 'nvget'))
159
+ perform_request('nvget', options.merge(:response_key => 'nvget'))
125
160
  end
126
161
 
127
162
  def reboot
128
- perform_request('reboot', {:key => "reboot"})
163
+ perform_request('reboot', {:response_key => "reboot"})
129
164
  end
130
165
 
131
166
  def account
@@ -140,6 +175,10 @@ module Lumberg
140
175
  @reseller ||= Reseller.new(:server => self)
141
176
  end
142
177
 
178
+ def cert
179
+ @cert ||= Cert.new(:server => self)
180
+ end
181
+
143
182
  private
144
183
 
145
184
  def do_request(uri, function, params)
@@ -149,12 +188,14 @@ module Lumberg
149
188
  else
150
189
  c.headers['Authorization'] = "WHM #{@user}:#{@hash}"
151
190
  end
191
+
152
192
  c.params = params
153
193
  c.request :url_encoded
154
- c.response :format_whm, @force_response_type, @key, @boolean_params
194
+ c.response :format_whm, @force_response_type, @response_key, @boolean_params
155
195
  c.response :logger, create_logger_instance
156
196
  c.response :json
157
197
  c.adapter :net_http
198
+ c.options[:timeout] = timeout if timeout
158
199
  end.get(function).body
159
200
  @force_response_type = nil
160
201
  @response
@@ -198,6 +239,14 @@ module Lumberg
198
239
  raise Lumberg::WhmArgumentError.new("Missing WHM hash") unless hash.is_a?(String)
199
240
  hash.gsub(/\n|\s/, '')
200
241
  end
242
+
243
+ def validate_server_host
244
+ Resolv.getaddress(@host)
245
+ rescue Resolv::ResolvError
246
+ raise Lumberg::WhmArgumentError.new(
247
+ "Unable to resolve #{@host}"
248
+ )
249
+ end
201
250
  end
202
251
  end
203
252
  end
@@ -11,16 +11,17 @@ Gem::Specification.new do |s|
11
11
  s.homepage = ""
12
12
  s.summary = %q{Ruby library for the WHM & cPanel API}
13
13
  s.description = %q{Ruby library for the WHM & cPanel API; It's not a half day or anything like that}
14
+ s.license = 'MIT'
14
15
 
15
16
  s.rubyforge_project = "lumberg"
16
17
 
17
18
  s.add_runtime_dependency 'json', '~> 1.7.3'
18
- s.add_runtime_dependency 'faraday', '~> 0.8.1'
19
- s.add_runtime_dependency 'faraday_middleware', '~> 0.8.4'
19
+ s.add_runtime_dependency 'faraday', '~> 0.8.8'
20
+ s.add_runtime_dependency 'faraday_middleware', '~> 0.9.0'
20
21
  s.add_runtime_dependency('jruby-openssl', '~> 0.7.3') if RUBY_PLATFORM == 'java'
21
22
  s.add_development_dependency 'rspec', '~> 2.10.0'
22
23
  s.add_development_dependency 'webmock', '~> 1.8.7'
23
- s.add_development_dependency 'vcr', '~> 2.0.0rc2'
24
+ s.add_development_dependency 'vcr', '~> 2.4.0'
24
25
  s.add_development_dependency 'rake', '~> 0.9.2.2'
25
26
 
26
27
  s.files = `git ls-files`.split("\n")