lumberg 1.0.6 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/lumberg.rb CHANGED
@@ -13,7 +13,6 @@ require 'lumberg/format_whm'
13
13
  require 'lumberg/version'
14
14
  require 'lumberg/exceptions'
15
15
  require 'lumberg/config'
16
- require 'lumberg/whm/args'
17
16
  require 'lumberg/whm'
18
17
 
19
18
  module Lumberg
@@ -1,3 +1,3 @@
1
1
  module Lumberg
2
- VERSION = '1.0.6'
2
+ VERSION = '1.1.1'
3
3
  end
@@ -1,18 +1,18 @@
1
1
  module Lumberg
2
2
  module Whm
3
3
  # Some WHM functions require different params for the same 'thing'
4
- # e.g. some accept 'username' while others accept 'user'
5
- # Be sure to keep our API consistent and work around those inconsistencies internally
4
+ # e.g. some accept 'username' while others accept 'user'
5
+ # Be sure to keep our API consistent and work around those inconsistencies internally
6
6
  class Account < Base
7
7
 
8
8
  # Creates a hosting account and sets up its associated domain information
9
9
  #
10
- # ==== Required
10
+ # ==== Required
11
11
  # * <tt>:username</tt> - PENDING
12
12
  # * <tt>:domain</tt> - PENDING
13
13
  # * <tt>:password</tt> - PENDING
14
14
  #
15
- # ==== Optional
15
+ # ==== Optional
16
16
  # * <tt>:plan</tt> - PENDING
17
17
  # * <tt>:pkgname</tt> - PENDING
18
18
  # * <tt>:savepkg</tt> - PENDING
@@ -22,43 +22,24 @@ module Lumberg
22
22
  # * <tt>:cgi</tt> - PENDING
23
23
  # * <tt>:</tt> - PENDING
24
24
  def create(options = {})
25
- Args.new(options) do |c|
26
- c.requires :username, :domain, :password
27
- c.booleans :savepkg, :ip, :cgi, :frontpage, :hasshell, :useregns, :reseller, :forcedns
28
- c.optionals :plan, :pkgname, :savepkg, :featurelist, :quota, :ip, :cgi,
29
- :frontpage, :hasshell, :contactemail, :cpmod, :maxftp, :maxsql, :maxpop, :maxlst,
30
- :maxsub, :maxpark, :maxaddon, :bwlimit, :customip, :language, :useregns, :hasuseregns,
31
- :reseller, :forcedns, :mxcheck
32
- end
33
-
34
25
  server.perform_request('createacct', options)
35
26
  end
36
27
 
37
28
  # Permanently removes a cPanel account
38
29
  #
39
- # ==== Required
30
+ # ==== Required
40
31
  # * <tt>:username</tt> - PENDING
41
32
  def remove(options = {})
42
- Args.new(options) do |c|
43
- c.requires :username
44
- c.booleans :keepdns
45
- end
46
-
47
33
  options[:user] = options.delete(:username)
48
34
  server.perform_request('removeacct', options)
49
35
  end
50
36
 
51
37
  # Changes the password of a domain owner (cPanel) or reseller (WHM) account
52
38
  #
53
- # ==== Required
39
+ # ==== Required
54
40
  # * <tt>:username</tt> - PENDING
55
41
  # * <tt>:password</tt> - PENDING
56
42
  def change_password(options = {})
57
- Args.new(options) do |c|
58
- c.requires :username, :password
59
- c.booleans :db_pass_update
60
- end
61
-
62
43
  options[:user] = options.delete(:username)
63
44
  options[:pass] = options.delete(:password)
64
45
  server.perform_request('passwd', options.merge(:key => 'passwd'))
@@ -66,27 +47,19 @@ module Lumberg
66
47
 
67
48
  # Displays pertinent information about a specific account
68
49
  #
69
- # ==== Required
50
+ # ==== Required
70
51
  # * <tt>:username</tt> - PENDING
71
52
  def summary(options = {})
72
- Args.new(options) do |c|
73
- c.requires :username
74
- end
75
-
76
53
  options[:user] = options.delete(:username)
77
54
  server.perform_request('accountsummary', options)
78
55
  end
79
56
 
80
57
  # Modifies the bandwidth usage (transfer) limit for a specific account
81
58
  #
82
- # ==== Required
59
+ # ==== Required
83
60
  # * <tt>:username</tt> - PENDING
84
61
  # * <tt>:bwlimit</tt> - PENDING
85
62
  def limit_bandwidth(options = {})
86
- Args.new(options) do |c|
87
- c.requires :username, :bwlimit
88
- end
89
-
90
63
  verify_user(options[:username]) do
91
64
  options[:user] = options.delete(:username)
92
65
  server.perform_request('limitbw', options) do |s|
@@ -98,14 +71,10 @@ module Lumberg
98
71
  # Lists all accounts on the server, and also allows you to search for a specific account or set of accounts
99
72
 
100
73
  #
101
- # ==== Optional
74
+ # ==== Optional
102
75
  # * <tt>:searchtype</tt> - PENDING
103
76
  # * <tt>:search</tt> - PENDING
104
77
  def list(options = {})
105
- Args.new(options) do |c|
106
- c.optionals :searchtype, :search
107
- end
108
-
109
78
  server.perform_request('listaccts', options) do |s|
110
79
  s.boolean_params = :suspended
111
80
  end
@@ -113,10 +82,10 @@ module Lumberg
113
82
 
114
83
  # Modifies settings for an account
115
84
  #
116
- # ==== Required
85
+ # ==== Required
117
86
  # * <tt>:username</tt> - PENDING
118
87
  #
119
- # ==== Optional
88
+ # ==== Optional
120
89
  # * <tt>:domain</tt> - PENDING
121
90
  # * <tt>:newuser</tt> - PENDING
122
91
  # * <tt>:owner</tt> - PENDING
@@ -133,11 +102,6 @@ module Lumberg
133
102
  # * <tt>:MAXADDON</tt> - PENDING
134
103
  # * <tt>:shell</tt> - PENDING
135
104
  def modify(options = {})
136
- Args.new(options) do |c|
137
- c.requires :username
138
- c.optionals :domain, :newuser, :owner, :CPTHEME, :HASCGI, :LANG, :LOCALE, :MAXFTP, :MAXSQL, :MAXPOP, :MAXLST, :MAXSUB, :MAXPARK, :MAXADDON, :shell
139
- end
140
-
141
105
  options[:user] = options.delete(:username)
142
106
  server.perform_request('modifyacct', options) do |s|
143
107
  s.boolean_params = :DEMO
@@ -146,24 +110,20 @@ module Lumberg
146
110
 
147
111
  # Changes an account's disk space usage quota
148
112
  #
149
- # ==== Required
113
+ # ==== Required
150
114
  # * <tt>:username</tt> - PENDING
151
115
  # * <tt>:quota</tt> - PENDING
152
116
  def edit_quota(options = {})
153
- Args.new(options) do |c|
154
- c.requires :username, :quota
155
- end
156
-
157
117
  options[:user] = options.delete(:username)
158
118
  server.perform_request('editquota', options)
159
119
  end
160
120
 
161
121
  # Adds a new hosting package
162
122
  #
163
- # ==== Required
123
+ # ==== Required
164
124
  # * <tt>:name</tt> - PENDING
165
125
  #
166
- # ==== Optional
126
+ # ==== Optional
167
127
  # * <tt>:featurelist</tt> - PENDING
168
128
  # * <tt>:quota</tt> - PENDING
169
129
  # * <tt>:ip</tt> - PENDING
@@ -181,38 +141,24 @@ module Lumberg
181
141
  # * <tt>:hasshell</tt> - PENDING
182
142
  # * <tt>:bwlimit</tt> - PENDING
183
143
  def add_package(options = {})
184
- Args.new(options) do |c|
185
- c.requires :name
186
- c.optionals :featurelist, :quota, :ip, :cgi, :frontpage, :cpmod, :language, :maxftp, :maxsql, :maxpop, :maxlists, :maxsub, :maxpark, :maxaddon, :hasshell, :bwlimit
187
- c.booleans :ip, :cgi, :frontpage, :hasshell
188
- end
189
-
190
144
  server.perform_request('addpkg', options)
191
145
  end
192
146
 
193
147
  # Changes the hosting package associated with a cPanel account
194
148
  #
195
- # ==== Required
149
+ # ==== Required
196
150
  # * <tt>:username</tt> - PENDING
197
151
  # * <tt>:pkg</tt> - PENDING
198
152
  def change_package(options = {})
199
- Args.new(options) do |c|
200
- c.requires :username, :pkg
201
- end
202
-
203
153
  options[:user] = options.delete(:username)
204
154
  server.perform_request('changepackage', options)
205
155
  end
206
156
 
207
157
  # Obtains user data for a specific domain
208
158
  #
209
- # ==== Required
159
+ # ==== Required
210
160
  # * <tt>:domain</tt> - PENDING
211
161
  def domain_user_data(options = {})
212
- Args.new(options) do |c|
213
- c.requires :domain
214
- end
215
-
216
162
  server.perform_request('domainuserdata', options.merge(:key => 'userdata')) do |s|
217
163
  s.boolean_params = :hascgi
218
164
  end
@@ -220,30 +166,21 @@ module Lumberg
220
166
 
221
167
  # Prevents a cPanel user from accessing his or her account. Once an account is suspended, it can be un-suspended to allow a user to access the account again
222
168
  #
223
- # ==== Required
169
+ # ==== Required
224
170
  # * <tt>:username</tt> - PENDING
225
171
  #
226
- # ==== Optional
172
+ # ==== Optional
227
173
  # * <tt>:reason</tt> - PENDING
228
174
  def suspend(options ={})
229
- Args.new(options) do |c|
230
- c.requires :username
231
- c.optionals :reason
232
- end
233
-
234
175
  options[:user] = options.delete(:username)
235
176
  server.perform_request('suspendacct', options)
236
177
  end
237
178
 
238
179
  # Unsuspend a suspended account. When a user's account is unsuspended, he or she will be able to access cPanel again
239
180
  #
240
- # ==== Required
181
+ # ==== Required
241
182
  # * <tt>:username</tt> - PENDING
242
183
  def unsuspend(options ={})
243
- Args.new(options) do |c|
244
- c.requires :username
245
- end
246
-
247
184
  options[:user] = options.delete(:username)
248
185
  server.perform_request('unsuspendacct', options)
249
186
  end
@@ -255,13 +192,9 @@ module Lumberg
255
192
 
256
193
  # Generates a list of features you are allowed to use in WHM. Each feature will display either a 1 or 0. You are only able to use features with a corresponding 1
257
194
  #
258
- # ==== Required
195
+ # ==== Required
259
196
  # * <tt>:username</tt> - PENDING
260
197
  def privs(options ={})
261
- Args.new(options) do |c|
262
- c.requires :username
263
- end
264
-
265
198
  verify_user(options[:username]) do
266
199
  resp = server.perform_request('myprivs', options.merge(:key => 'privs')) do |s|
267
200
  s.boolean_params = :all
@@ -274,21 +207,16 @@ module Lumberg
274
207
 
275
208
  # Changes the IP address of a website, or a user account, hosted on your server
276
209
  #
277
- # ==== Required
210
+ # ==== Required
278
211
  # * <tt>:ip</tt> - PENDING
279
212
  def set_site_ip(options = {})
280
- Args.new(options) do |c|
281
- c.requires :ip
282
- c.one_of :username, :domain
283
- end
284
-
285
213
  options[:user] = options.delete(:username) if options[:username]
286
214
  server.perform_request('setsiteip', options)
287
215
  end
288
216
 
289
217
  # Restores a user's account from a backup file. You may restore a monthly, weekly, or daily backup
290
218
  #
291
- # ==== Required
219
+ # ==== Required
292
220
  # * <tt>:username</tt> - PENDING
293
221
  # * <tt>:type</tt> - PENDING
294
222
  # * <tt>:all</tt> - PENDING
@@ -297,18 +225,13 @@ module Lumberg
297
225
  # * <tt>:mysql</tt> - PENDING
298
226
  # * <tt>:subs</tt> - PENDING
299
227
  def restore_account(options = {})
300
- Args.new(options) do |c|
301
- c.requires "api.version".to_sym, :username, :type, :all, :ip, :mail, :mysql, :subs
302
- c.booleans :all, :ip, :mail, :mysql, :subs
303
- end
304
-
305
228
  options[:user] = options.delete(:username) if options[:username]
306
229
  server.perform_request('restoreaccount', options.merge(:key => 'metadata'))
307
230
  end
308
231
 
309
- protected
232
+ protected
310
233
  # Some WHM API methods always return a result, even if the user
311
- # doesn't actually exist. This makes it seem like your request
234
+ # doesn't actually exist. This makes it seem like your request
312
235
  # was successful when it really wasn't
313
236
  #
314
237
  # Example
@@ -5,18 +5,14 @@ module Lumberg
5
5
  attr_accessor :server
6
6
 
7
7
  #
8
- # ==== Required
8
+ # ==== Required
9
9
  # * <tt>:server</tt> - PENDING
10
10
  def initialize(options = {})
11
- Args.new(options) do |c|
12
- c.requires :server
13
- end
14
-
15
- @server = setup_server options.delete(:server)
11
+ @server = setup_server options.delete(:server)
16
12
  end
17
13
 
18
14
  def setup_server(value)
19
- if value.is_a?(Whm::Server)
15
+ if value.is_a?(Whm::Server)
20
16
  value
21
17
  else
22
18
  Whm::Server.new value
@@ -4,28 +4,23 @@ module Lumberg
4
4
  # Creates a DNS zone. All zone information other than domain name and IP address is created based on the standard zone template in WHM.
5
5
  # Your MX, nameserver, domain PTR, and A records will all be generated automatically
6
6
  #
7
- # ==== Required
7
+ # ==== Required
8
8
  # * <tt>:domain</tt> - PENDING
9
9
  # * <tt>:ip</tt> - PENDING
10
10
  #
11
- # ==== Optional
11
+ # ==== Optional
12
12
  # * <tt>:template</tt> - PENDING
13
13
  # * <tt>:trueowner</tt> - PENDING
14
14
  def add_zone(options = {})
15
- Args.new(options) do |c|
16
- c.requires :domain, :ip
17
- c.optionals :template, :trueowner
18
- end
19
-
20
15
  server.perform_request('adddns', options)
21
16
  end
22
17
 
23
18
  # Adds a DNS zone record to the server
24
19
  #
25
- # ==== Required
20
+ # ==== Required
26
21
  # * <tt>:zone</tt> - PENDING
27
22
  #
28
- # ==== Optional
23
+ # ==== Optional
29
24
  # * <tt>:name</tt> - PENDING
30
25
  # * <tt>:address</tt> - PENDING
31
26
  # * <tt>:type</tt> - PENDING
@@ -37,11 +32,6 @@ module Lumberg
37
32
  # * <tt>:preference</tt> - PENDING
38
33
  # * <tt>:ttl</tt> - PENDING
39
34
  def add_zone_record(options = {})
40
- Args.new(options) do |c|
41
- c.requires :zone
42
- c.optionals :name, :address, :type, :class, :cname, :exchange, :nsdname, :ptdrname, :preference, :ttl
43
- end
44
-
45
35
  server.perform_request('addzonerecord', options)
46
36
  end
47
37
 
@@ -51,56 +41,44 @@ module Lumberg
51
41
  end
52
42
 
53
43
  # Return zone records for a domain.
54
- #
55
- # To use this function most effectively, you may first wish to run the dumpzone function for the domain(s) whose record(s) you wish to retrieve.
44
+ #
45
+ # To use this function most effectively, you may first wish to run the dumpzone function for the domain(s) whose record(s) you wish to retrieve.
56
46
  # The Line output variable from that function call can then be used as a reference to create the input for this function.
57
47
  #
58
- # ==== Required
48
+ # ==== Required
59
49
  # * <tt>:domain</tt> - PENDING
60
50
  # * <tt>:Line</tt> - PENDING
61
51
  def get_zone_record(options = {})
62
- Args.new(options) do |c|
63
- c.requires :domain, :Line
64
- end
65
-
66
52
  server.perform_request('getzonerecord', options)
67
53
  end
68
54
 
69
55
  # Displays the DNS zone configuration for a specific domain
70
56
  #
71
- # ==== Required
57
+ # ==== Required
72
58
  # * <tt>:domain</tt> - PENDING
73
59
  def dump_zone(options = {})
74
- Args.new(options) do |c|
75
- c.requires :domain
76
- end
77
-
78
60
  server.perform_request('dumpzone', options)
79
61
  end
80
62
 
81
63
  # Attempts to resolve an IP address for a specified domain name
82
64
  #
83
- # ==== Required
65
+ # ==== Required
84
66
  # * <tt>:domain</tt> - PENDING
85
67
  # * <tt>:"api.version".to_sym</tt> - PENDING
86
68
  def resolve_domain(options = {})
87
- Args.new(options) do |c|
88
- c.requires :domain, "api.version".to_sym
89
- end
90
-
91
69
  server.perform_request('resolvedomainname', options.merge(:key => 'data'))
92
70
  end
93
71
 
94
72
  # Allows you to edit a DNS zone record on the server.
95
73
  #
96
- # To use this function most effectively, you should first run the dumpzone function for the domain(s) whose record(s) you wish to edit.
74
+ # To use this function most effectively, you should first run the dumpzone function for the domain(s) whose record(s) you wish to edit.
97
75
  # The output of that function call will be used as a reference to create the input for this function.
98
76
  #
99
- # ==== Required
77
+ # ==== Required
100
78
  # * <tt>:domain</tt> - PENDING
101
79
  # * <tt>:Line</tt> - PENDING
102
80
  #
103
- # ==== Optional
81
+ # ==== Optional
104
82
  # * <tt>:address</tt> - PENDING
105
83
  # * <tt>:class</tt> - PENDING
106
84
  # * <tt>:cname</tt> - PENDING
@@ -110,68 +88,46 @@ module Lumberg
110
88
  # * <tt>:minimum</tt> - PENDING
111
89
  # * <tt>:mname</tt> - PENDING
112
90
  def edit_zone_record(options = {})
113
- Args.new(options) do |c|
114
- c.requires :domain, :Line
115
- c.optionals :address, :class, :cname, :exchange, :preference, :expire, :minimum, :mname,
116
- :name, :nsdname, :raw, :refresh, :retry, :rname, :serial, :ttl, :type, :txtdata
117
- end
118
-
119
91
  server.perform_request('editzonerecord', options)
120
92
  end
121
93
 
122
94
  # Deletes a DNS zone
123
95
  #
124
- # ==== Required
96
+ # ==== Required
125
97
  # * <tt>:domain</tt> - PENDING
126
98
  def kill_dns(options = {})
127
- Args.new(options) do |c|
128
- c.requires :domain
129
- end
130
-
131
99
  server.perform_request('killdns', options)
132
100
  end
133
101
 
134
102
  # Obtains the IP address of a registered nameserver from the root nameservers
135
103
  #
136
- # ==== Required
104
+ # ==== Required
137
105
  # * <tt>:nameserver</tt> - PENDING
138
106
  def lookup_nameserver_ip(options = {})
139
- Args.new(options) do |c|
140
- c.requires :nameserver
141
- end
142
-
143
107
  server.perform_request('lookupnsip', options.merge(:key => 'ip'))
144
108
  end
145
109
 
146
110
  # Allows you to remove a DNS zone record from the server.
147
- #
148
- # To use this function most effectively, you should first run the dumpzone function for the domain(s) whose record(s) you wish to remove.
111
+ #
112
+ # To use this function most effectively, you should first run the dumpzone function for the domain(s) whose record(s) you wish to remove.
149
113
  # The output of that function call will be used as a reference to create the input for this function.
150
114
  #
151
- # ==== Required
115
+ # ==== Required
152
116
  # * <tt>:zone</tt> - PENDING
153
117
  # * <tt>:Line</tt> - PENDING
154
118
  def remove_zone_record(options = {})
155
- Args.new(options) do |c|
156
- c.requires :zone, :Line
157
- end
158
-
159
119
  server.perform_request('removezonerecord', options)
160
120
  end
161
121
 
162
122
  # Restore a DNS zone to its default values. This includes any subdomain DNS records associated with the domain.
163
- #
164
- # This function can be useful for restoring DNS zones that have become corrupted or have been improperly edited.
123
+ #
124
+ # This function can be useful for restoring DNS zones that have become corrupted or have been improperly edited.
165
125
  # It will also restore zone file subdomains listed in the server's httpd.conf file, along with default settings for new accounts.
166
126
  #
167
- # ==== Required
127
+ # ==== Required
168
128
  # * <tt>:domain</tt> - PENDING
169
129
  # * <tt>:zone</tt> - PENDING
170
130
  def reset_zone(options = {})
171
- Args.new(options) do |c|
172
- c.requires :domain, :zone
173
- end
174
-
175
131
  server.perform_request('resetzone', options)
176
132
  end
177
133
 
@@ -179,14 +135,10 @@ module Lumberg
179
135
  #
180
136
  # *This function is only available in version 11.27/11.28+*
181
137
  #
182
- # ==== Required
138
+ # ==== Required
183
139
  # * <tt>:domain</tt> - PENDING
184
140
  # * <tt>:"api.version".to_sym</tt> - PENDING
185
141
  def list_mxs(options = {})
186
- Args.new(options) do |c|
187
- c.requires :domain, "api.version".to_sym
188
- end
189
-
190
142
  server.perform_request('listmxs', options.merge(:key => 'data'))
191
143
  end
192
144
 
@@ -194,10 +146,6 @@ module Lumberg
194
146
  #
195
147
  # *This function is only available in version 11.27/11.28+*
196
148
  def save_mx(options = {})
197
- Args.new(options) do |c|
198
- c.requires "api.version".to_sym, :domain, :name, :exchange, :preference
199
- end
200
-
201
149
  server.perform_request('savemxs', options)
202
150
  end
203
151
  end