squall 1.3.0 → 1.3.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.
Files changed (70) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +1 -1
  3. data/README.md +64 -41
  4. data/Rakefile +3 -9
  5. data/lib/squall/data_store_zone.rb +20 -26
  6. data/lib/squall/disk.rb +174 -0
  7. data/lib/squall/firewall_rule.rb +34 -41
  8. data/lib/squall/hypervisor.rb +40 -38
  9. data/lib/squall/hypervisor_zone.rb +51 -63
  10. data/lib/squall/ip_address.rb +32 -37
  11. data/lib/squall/ip_address_join.rb +13 -22
  12. data/lib/squall/network.rb +36 -33
  13. data/lib/squall/network_zone.rb +27 -29
  14. data/lib/squall/payment.rb +22 -32
  15. data/lib/squall/role.rb +30 -37
  16. data/lib/squall/statistic.rb +3 -1
  17. data/lib/squall/support/base.rb +35 -31
  18. data/lib/squall/support/config.rb +25 -1
  19. data/lib/squall/support/version.rb +1 -1
  20. data/lib/squall/template.rb +7 -5
  21. data/lib/squall/transaction.rb +6 -4
  22. data/lib/squall/user.rb +84 -83
  23. data/lib/squall/user_group.rb +17 -30
  24. data/lib/squall/virtual_machine.rb +154 -178
  25. data/lib/squall/whitelist.rb +29 -40
  26. data/lib/squall.rb +27 -25
  27. data/spec/spec_helper.rb +6 -11
  28. data/spec/squall/data_store_zone_spec.rb +2 -20
  29. data/spec/squall/disk_spec.rb +189 -0
  30. data/spec/squall/firewall_rule_spec.rb +2 -32
  31. data/spec/squall/hypervisor_spec.rb +3 -47
  32. data/spec/squall/hypervisor_zone_spec.rb +3 -28
  33. data/spec/squall/ip_address_join_spec.rb +1 -15
  34. data/spec/squall/ip_address_spec.rb +10 -35
  35. data/spec/squall/network_spec.rb +20 -31
  36. data/spec/squall/network_zone_spec.rb +2 -36
  37. data/spec/squall/payment_spec.rb +2 -21
  38. data/spec/squall/role_spec.rb +4 -16
  39. data/spec/squall/support/base_spec.rb +10 -16
  40. data/spec/squall/template_spec.rb +0 -4
  41. data/spec/squall/transaction_spec.rb +1 -3
  42. data/spec/squall/user_group_spec.rb +1 -17
  43. data/spec/squall/user_spec.rb +4 -92
  44. data/spec/squall/virtual_machine_spec.rb +8 -242
  45. data/spec/squall/whitelist_spec.rb +2 -40
  46. data/spec/squall_spec.rb +2 -2
  47. data/spec/vcr_cassettes/disk/add_schedule.yml +40 -0
  48. data/spec/vcr_cassettes/disk/auto_backup_off.yml +40 -0
  49. data/spec/vcr_cassettes/disk/auto_backup_on.yml +40 -0
  50. data/spec/vcr_cassettes/disk/backups.yml +40 -0
  51. data/spec/vcr_cassettes/disk/build.yml +40 -0
  52. data/spec/vcr_cassettes/disk/create.yml +40 -0
  53. data/spec/vcr_cassettes/disk/delete.yml +38 -0
  54. data/spec/vcr_cassettes/disk/edit.yml +40 -0
  55. data/spec/vcr_cassettes/disk/iops_usage.yml +40 -0
  56. data/spec/vcr_cassettes/disk/list.yml +40 -0
  57. data/spec/vcr_cassettes/disk/migrate.yml +38 -0
  58. data/spec/vcr_cassettes/disk/schedules.yml +40 -0
  59. data/spec/vcr_cassettes/disk/unlock.yml +40 -0
  60. data/spec/vcr_cassettes/disk/vm_disk_list.yml +40 -0
  61. data/spec/vcr_cassettes/network/rebuild.yml +41 -0
  62. metadata +217 -66
  63. data/.gitignore +0 -13
  64. data/.rspec +0 -2
  65. data/.rvmrc +0 -41
  66. data/.travis.yml +0 -17
  67. data/lib/squall/support/params.rb +0 -50
  68. data/lib/squall/support/yaml.rb +0 -5
  69. data/spec/squall/support/params_spec.rb +0 -195
  70. data/squall.gemspec +0 -32
@@ -1,311 +1,287 @@
1
1
  module Squall
2
2
  # OnApp VirtualMachine
3
3
  class VirtualMachine < Base
4
- # Return a list of virtual machines
4
+ # Public: List all virtual machines.
5
+ #
6
+ # Returns an Array.
5
7
  def list
6
8
  response = request(:get, '/virtual_machines.json')
7
9
  response.collect { |v| v['virtual_machine'] }
8
10
  end
9
11
 
10
- # Return a Hash for the given virtual machines
12
+ # Public: Get info for a virtual machine.
11
13
  #
12
- # ==== Params
14
+ # id - ID of the virtual machine
13
15
  #
14
- # * +id*+ - ID of the virtual machine
16
+ # Returns a Hash.
15
17
  def show(id)
16
18
  response = request(:get, "/virtual_machines/#{id}.json")
17
19
  response.first[1]
18
20
  end
19
21
 
20
- # Create a new virtual machine
21
- #
22
- # ==== Params
23
- #
24
- # * +options+ - Params for creating the virtual machine
25
- #
26
- # ==== Options
27
- #
28
- # * +label*+ - Label for the virtual machine
29
- # * +hostname*+ - Hostname for the virtual machine
30
- # * +memory*+ - Amount of RAM assigned to this virtual machine
31
- # * +cpus*+ - Number of CPUs assigned to the virtual machine
32
- # * +cpu_shares*+ - CPU priority for this virtual machine
33
- # * +primary_disk_size*+ - Disk space for this virtual machine
34
- # * +template_id*+ - ID for a template from which the virtual machine will be built
35
- # * +hypervisor_id+ - ID for a hypervisor where virtual machine will be built. If not provided the virtual machine will be assigned to the first available hypervisor
36
- # * +swap_disk_size+ - Swap space (does not apply to Windows virtual machines)
37
- # * +primary_network_id+ - ID of the primary network
38
- # * +required_automatic_backup+ - Set to '1' if automatic backups are required
39
- # * +rate_limit+ - Max port speed
40
- # * +required_ip_address_assignment+ - Set to '1' if you wish to assign an IP address automatically
41
- # * +required_virtual_machine_build+ - Set to '1' to build virtual machine automatically
42
- # * +admin_note+ - Comment that can only be set by admin of virtual machine
43
- # * +note+ - Comment that can be set by the user of the virtual machine
44
- # * +allowed_hot_migrate+ - Set to '1' to allow hot migration
45
- # * +initial_root_password+ - Root password for the virtual machine. 6-31 characters consisting of letters, numbers, '-' and '_'
46
- # * hypervisor_group_id - the ID of the hypervisor zone in which the VM will be created. Optional: if no hypervisor zone is set, the VM will be built in any available hypervisor zone.
47
-
48
- #
49
- # ==== Example
50
- #
51
- # params = {
52
- # :label => 'testmachine',
53
- # :hypervisor_id => 5,
54
- # :hostname => 'testmachine',
55
- # :memory => 512,
56
- # :cpus => 1,
57
- # :cpu_shares => 10,
58
- # :primary_disk_size => 10,
59
- # :template_id => 1
60
- # }
61
- #
62
- # create params
22
+ # Public: Create a new virtual machine.
23
+ #
24
+ # options - Params for creating the virtual machine:
25
+ # admin_note - Comment that can only be set by
26
+ # admin of virtual machine
27
+ # allowed_hot_migrate - Set to '1' to allow hot
28
+ # migration
29
+ # cpu_shares - CPU priority for this virtual
30
+ # machine
31
+ # cpus - Number of CPUs assigned to the
32
+ # virtual machine
33
+ # hostname - Hostname for the virtual machine
34
+ # hypervisor_group_id - the ID of the hypervisor zone in
35
+ # which the VM will be created.
36
+ # Optional: if no hypervisor zone
37
+ # is set, the VM will be built in
38
+ # any available hypervisor zone.
39
+ # hypervisor_id - ID for a hypervisor where
40
+ # virtual machine will be built.
41
+ # If not provided the virtual
42
+ # machine will be assigned to the
43
+ # first available hypervisor
44
+ # initial_root_password - Root password for the virtual
45
+ # machine. 6-31 characters
46
+ # consisting of letters, numbers,
47
+ # '-' and '_'
48
+ # label - Label for the virtual machine
49
+ # memory - Amount of RAM assigned to this
50
+ # virtual machine
51
+ # note - Comment that can be set by the
52
+ # user of the virtual machine
53
+ # primary_disk_size - Disk space for this virtual
54
+ # machine
55
+ # primary_network_id - ID of the primary network
56
+ # rate_limit - Max port speed
57
+ # required_automatic_backup - Set to '1' if automatic backups
58
+ # are required
59
+ # required_ip_address_assignment - Set to '1' if you wish to
60
+ # assign an IP address
61
+ # automatically
62
+ # required_virtual_machine_build - Set to '1' to build virtual
63
+ # machine automatically
64
+ # swap_disk_size - Swap space (does not apply to
65
+ # Windows virtual machines)
66
+ # template_id - ID for a template from which
67
+ # the virtual machine will be
68
+ # built
69
+ #
70
+ # Example
71
+ # create(
72
+ # label: 'testmachine',
73
+ # hypervisor_id: 5,
74
+ # hostname: 'testmachine',
75
+ # memory: 512,
76
+ # cpus: 1,
77
+ # cpu_shares: 10,
78
+ # primary_disk_size: 10,
79
+ # template_id: 1
80
+ # )
81
+ #
82
+ # Returns a Hash.
63
83
  def create(options = {})
64
- required = [:label, :hostname, :memory, :cpus, :cpu_shares, :primary_disk_size, :template_id]
65
- optional = [:hypervisor_id,
66
- :swap_disk_size,
67
- :primary_network_id,
68
- :required_automatic_backup,
69
- :rate_limit,
70
- :required_ip_address_assignment,
71
- :required_virtual_machine_build,
72
- :admin_note,
73
- :note,
74
- :allowed_hot_migrate,
75
- :initial_root_password,
76
- :hypervisor_group_id
77
- ]
78
- params.required(required).accepts(optional).validate! options
79
84
  response = request(:post, '/virtual_machines.json', default_params(options))
80
85
  response['virtual_machine']
81
86
  end
82
87
 
83
- # Build a virtual machine
84
- #
85
- # ==== Params
88
+ # Public: Build a virtual machine.
86
89
  #
87
- # * +id*+ - ID of the virtual machine
88
- # * +options+ - Params for creating the virtual machine
90
+ # id - ID of the virtual machine
91
+ # options - Params for creating the virtual machine
92
+ # :required_startup - Set to '1' to startup virtual machine after
93
+ # building
94
+ # :template_id - ID of the template to be used to build the
95
+ # virtual machine
89
96
  #
90
- # ==== Options
91
- #
92
- # * +template_id*+ - ID of the template to be used to build the virtual machine
93
- # * +required_startup+ - Set to '1' to startup virtual machine after building
97
+ # Returns a Hash.
94
98
  def build(id, options = {})
95
- params.required(:template_id).accepts(:required_startup).validate! options
96
99
  response = request(:post, "/virtual_machines/#{id}/build.json", default_params(options))
97
100
  response.first[1]
98
101
  end
99
102
 
100
- # Edit a virtual machine
101
- #
102
- # ==== Params
103
+ # Public: Edit a virtual machine.
103
104
  #
104
- # * +id*+ - ID of the virtual machine
105
- # * +options+ - Params for creating the virtual machine
105
+ # id - ID of the virtual machine
106
+ # options - Params for creating the virtual machine, see `#create`
106
107
  #
107
- # ==== Options
108
- #
109
- # See #create
108
+ # Returns a Hash.
110
109
  def edit(id, options = {})
111
- optional = [:label,
112
- :hypervisor_id,
113
- :hostname,
114
- :memory,
115
- :cpus,
116
- :cpu_shares,
117
- :primary_disk_size,
118
- :cpu_shares,
119
- :swap_disk_size,
120
- :primary_network_id,
121
- :required_automatic_backup,
122
- :rate_limit,
123
- :required_ip_address_assignment,
124
- :required_virtual_machine_build,
125
- :admin_note,
126
- :note,
127
- :allowed_hot_migrate,
128
- :template_id,
129
- :initial_root_password
130
- ]
131
- params.accepts(optional).validate! options
132
- request(:put, "/virtual_machines/#{id}.json", default_params(options))
110
+ response = request(:put, "/virtual_machines/#{id}.json", default_params(options))
111
+ response['virtual_machine']
133
112
  end
134
113
 
135
- # Change the owner of a virtual machine
114
+ # Public: Change the owner of a virtual machine.
136
115
  #
137
- # ==== Params
116
+ # id - ID of the virtual machine
117
+ # user_id - ID of the target User
138
118
  #
139
- # * +id*+ - ID of the virtual machine
140
- # * +user_id*+ - ID of the target User
119
+ # Returns a Hash.
141
120
  def change_owner(id, user_id)
142
- response = request(:post, "/virtual_machines/#{id}/change_owner.json", :query => { :user_id => user_id })
121
+ response = request(:post, "/virtual_machines/#{id}/change_owner.json", query: { user_id: user_id })
143
122
  response['virtual_machine']
144
123
  end
145
124
 
146
- # Change the password
125
+ # Public: Change the password.
147
126
  #
148
- # ==== Params
127
+ # id - ID of the virtual machine
128
+ # password - New password
149
129
  #
150
- # * +id*+ - ID of the virtual machine
151
- # * +password*+ - New password
130
+ # Returns a Hash.
152
131
  def change_password(id, password)
153
- response = request(:post, "/virtual_machines/#{id}/reset_password.json", :query => { :new_password => password })
132
+ response = request(:post, "/virtual_machines/#{id}/reset_password.json", query: { new_password: password })
154
133
  response['virtual_machine']
155
134
  end
156
135
 
157
- # Assigns SSH keys of all administrators and a owner to a virtual machine
136
+ # Public: Assigns SSH keys of all administrators and a owner to a virtual
137
+ # machine.
158
138
  #
159
- # ==== Params
139
+ # id - ID of the virtual machine
160
140
  #
161
- # * +id*+ - ID of the virtual machine
141
+ # Returns a Hash.
162
142
  def set_ssh_keys(id)
163
143
  response = request(:post, "/virtual_machines/#{id}/set_ssh_keys.json")
164
144
  response['virtual_machine']
165
145
  end
166
146
 
167
- # Migrate a virtual machine to a new hypervisor
168
- #
169
- # ==== Params
170
- #
171
- # * +id*+ - ID of the virtual machine
172
- # * +options+ - :destination, :cold_migrate_on_rollback
147
+ # Public: Migrate a virtual machine to a new hypervisor.
173
148
  #
174
- # ==== Options
149
+ # id - ID of the virtual machine
150
+ # options - A Hash of options:
151
+ # :destination - ID of a hypervisor to which to
152
+ # migrate the virtual machine
153
+ # :cold_migrate_on_rollback - Set to '1' to switch to cold
154
+ # migration if migration fails
175
155
  #
176
- # * +destination*+ - ID of a hypervisor to which to migrate the virtual machine
177
- # * +cold_migrate_on_rollback+ - Set to '1' to switch to cold migration if migration fails
156
+ # Returns a Hash.
178
157
  def migrate(id, options = {})
179
- params.required(:destination).accepts(:cold_migrate_on_rollback).validate! options
180
- response = request(:post, "/virtual_machines/#{id}/migrate.json", :query => {:virtual_machine => options} )
158
+ request(:post, "/virtual_machines/#{id}/migrate.json", query: { virtual_machine: options } )
181
159
  end
182
160
 
183
- # Toggle the VIP status of the virtual machine
161
+ # Public: Toggle the VIP status of the virtual machine.
184
162
  #
185
- # ==== Params
163
+ # id - ID of the virtual machine
186
164
  #
187
- # * +id*+ - ID of the virtual machine
165
+ # Returns a Hash.
188
166
  def set_vip(id)
189
167
  response = request(:post, "/virtual_machines/#{id}/set_vip.json")
190
168
  response['virtual_machine']
191
169
  end
192
170
 
193
- # Delete a virtual machine
171
+ # Public: Delete a virtual machine.
194
172
  #
195
- # ==== Params
173
+ # id - ID of the virtual machine
196
174
  #
197
- # * +id*+ - ID of the virtual machine
175
+ # Returns a Hash.
198
176
  def delete(id)
199
177
  request(:delete, "/virtual_machines/#{id}.json")
200
178
  end
201
179
 
202
- # Resize a virtual machine's memory
203
- #
204
- # ==== Params
205
- #
206
- # * +id*+ - ID of the virtual machine
207
- # * +options+ - Options for resizing
208
- #
209
- # * ==== Options
210
- #
211
- # * +memory*+ - Amount of RAM assigned to this virtual machine
212
- # * +cpus*+ - Number of CPUs assigned to the virtual machine
213
- # * +cpu_shares*+ - CPU priority for this virtual machine
214
- # * +allow_cold_resize*+ - Set to '1' to allow cold resize
180
+ # Public: Resize a virtual machine's memory.
181
+ #
182
+ # id - ID of the virtual machine
183
+ # options - Options for resizing:
184
+ # :memory - Amount of RAM assigned to this virtual
185
+ # machine
186
+ # :cpus - Number of CPUs assigned to the virtual
187
+ # machine
188
+ # :cpu_shares - CPU priority for this virtual machine
189
+ # :allow_cold_resize - Set to '1' to allow cold resize
190
+ #
191
+ # Returns a Hash.
215
192
  def resize(id, options = {})
216
- raise ArgumentError, "You must specify at least one of the following attributes to resize: :memory, :cpus, :cpu_shares, :allow_cold_resize" if options.empty?
217
- params.accepts(:memory, :cpus, :cpu_shares, :allow_cold_resize).validate! options
218
193
  response = request(:post, "/virtual_machines/#{id}/resize.json", default_params(options))
219
194
  response['virtual_machine']
220
195
  end
221
196
 
222
- # Suspend/Unsuspend a virtual machine
197
+ # Public: Suspend/Unsuspend a virtual machine.
223
198
  #
224
- # ==== Params
199
+ # id - ID of the virtual machine
225
200
  #
226
- # * +id*+ - ID of the virtual machine
201
+ # Returns a Hash.
227
202
  def suspend(id)
228
203
  response = request(:post, "/virtual_machines/#{id}/suspend.json")
229
204
  response['virtual_machine']
230
205
  end
231
206
 
232
- # Unlock a virtual machine
207
+ # Public: Unlock a virtual machine.
233
208
  #
234
- # ==== Params
209
+ # id - ID of the virtual machine
235
210
  #
236
- # * +id*+ - ID of the virtual machine
211
+ # Returns a Hash.
237
212
  def unlock(id)
238
213
  response = request(:post, "/virtual_machines/#{id}/unlock.json")
239
214
  response['virtual_machine']
240
215
  end
241
216
 
242
- # Boot a virtual machine
217
+ # Public: Boot a virtual machine.
243
218
  #
244
- # ==== Params
219
+ # id - ID of the virtual machine
245
220
  #
246
- # * +id*+ - ID of the virtual machine
221
+ # Returns a Hash.
247
222
  def startup(id)
248
223
  response = request(:post, "/virtual_machines/#{id}/startup.json")
249
224
  response['virtual_machine']
250
225
  end
251
226
 
252
- # Shutdown a virtual machine
227
+ # Public: Shutdown a virtual machine.
253
228
  #
254
- # ==== Params
229
+ # id - ID of the virtual machine
255
230
  #
256
- # * +id*+ - ID of the virtual machine
231
+ # Returns a Hash.
257
232
  def shutdown(id)
258
233
  response = request(:post, "/virtual_machines/#{id}/shutdown.json")
259
234
  response['virtual_machine']
260
235
  end
261
236
 
262
- # Stop a virtual machine
237
+ # Public: Stop a virtual machine.
263
238
  #
264
- # ==== Params
239
+ # id - ID of the virtual machine
265
240
  #
266
- # * +id*+ - ID of the virtual machine
241
+ # Returns a Hash.
267
242
  def stop(id)
268
243
  response = request(:post, "/virtual_machines/#{id}/stop.json")
269
244
  response['virtual_machine']
270
245
  end
271
246
 
272
- # Reboot a virtual machine
247
+ # Public: Reboot a virtual machine
273
248
  #
274
- # ==== Params
249
+ # id - ID of the virtual machine
250
+ # recovery - Set to true to reboot in recovery, defaults to false
275
251
  #
276
- # * +id*+ - ID of the virtual machine
277
- # * +recovery+ - Set to true to reboot in recovery, defaults to false
252
+ # Returns a Hash.
278
253
  def reboot(id, recovery=false)
279
- response = request(:post, "/virtual_machines/#{id}/reboot.json", {:query => recovery ? {:mode => :recovery} : nil})
254
+ response = request(:post, "/virtual_machines/#{id}/reboot.json", { query: recovery ? { mode: :recovery } : nil })
280
255
  response['virtual_machine']
281
256
  end
282
257
 
283
- # Segregate a virtual machine from another virtual machine
258
+ # Public: Segregate a virtual machine from another virtual machine.
284
259
  #
285
- # ==== Params
260
+ # id - ID of the virtual machine
261
+ # target_vm_id - ID of another virtual machine from which it should be
262
+ # segregated
286
263
  #
287
- # * +id*+ - ID of the virtual machine
288
- # * +target_vm_id+* - ID of another virtual machine from which it should be segregated
264
+ # Returns a Hash.
289
265
  def segregate(id, target_vm_id)
290
- response = request(:post, "/virtual_machines/#{id}/strict_vm.json", default_params(:strict_virtual_machine_id => target_vm_id))
266
+ response = request(:post, "/virtual_machines/#{id}/strict_vm.json", default_params(strict_virtual_machine_id: target_vm_id))
291
267
  response['virtual_machine']
292
268
  end
293
269
 
294
- # Open a console for a virtual machine
270
+ # Public: Open a console for a virtual machine.
295
271
  #
296
- # ==== Params
272
+ # id - ID of the virtual machine
297
273
  #
298
- # * +id*+ - ID of the virtual machine
274
+ # Returns a Hash.
299
275
  def console(id)
300
276
  response = request(:post, "/virtual_machines/#{id}/console.json")
301
277
  response['virtual_machine']
302
278
  end
303
279
 
304
- # Get billing statistics for a virtual machine
280
+ # Public: Get billing statistics for a virtual machine.
305
281
  #
306
- # ==== Params
282
+ # id - ID of the virtual machine
307
283
  #
308
- # * +id*+ - ID of the virtual machine
284
+ # Returns a Hash.
309
285
  def stats(id)
310
286
  response = request(:post, "/virtual_machines/#{id}/vm_stats.json")
311
287
  response['virtual_machine']
@@ -1,74 +1,63 @@
1
1
  module Squall
2
2
  # OnApp Whitelist
3
3
  class Whitelist < Base
4
-
5
- # Return a list of all whitelists
4
+ # Public: Lists all whitelists.
6
5
  #
7
- # ==== Params
6
+ # user_id - ID of the user to display whitelists for
8
7
  #
9
- # * +user_id*+ - ID of the user to display whitelists for
8
+ # Returns an Array.
10
9
  def list(user_id)
11
10
  response = request(:get, "/users/#{user_id}/user_white_lists.json")
12
11
  response.collect { |user| user['user_white_list'] }
13
12
  end
14
13
 
15
- # Get the details for a whitelist
14
+ # Public: Get the details for a whitelist.
16
15
  #
17
- # ==== Params
16
+ # user_id - ID of the user
17
+ # id - ID of the whitelist
18
18
  #
19
- # * +user_id*+ - ID of the user
20
- # * +id*+ - ID of the whitelist
19
+ # Returns a Hash.
21
20
  def show(user_id, id)
22
21
  response = request(:get, "/users/#{user_id}/user_white_lists/#{id}.json")
23
22
  response['user_white_list']
24
23
  end
25
24
 
26
- # Create a whitelist for a user
27
- #
28
- # ==== Params
29
- #
30
- # * +user_id*+ - ID of the user
31
- # * +options+ - Params for creating the whitelist
25
+ # Public: Create a whitelist for a user.
32
26
  #
33
- # ==== Options
27
+ # user_id - ID of the user
28
+ # options - Params for creating the whitelist:
29
+ # :ip - IP to be whitelisted
30
+ # :description - Description of the whitelist
34
31
  #
35
- # * +ip*+ - IP to be whitelisted
36
- # * +description+ - Description of the whitelist
32
+ # Example
37
33
  #
38
- # ==== Example
34
+ # create ip: 192.168.1.1,
35
+ # description: "Computer that someone I trust uses"
39
36
  #
40
- # create :ip => 192.168.1.1,
41
- # :description => "Computer that someone I trust uses"
42
- def create(user_id, options={})
43
- params.required(:ip).accepts(:description).validate!(options)
44
- request(:post, "/users/#{user_id}/user_white_lists.json", :query => {:user_white_list => options})
37
+ # Returns a Hash.
38
+ def create(user_id, options = {})
39
+ request(:post, "/users/#{user_id}/user_white_lists.json", query: { user_white_list: options })
45
40
  end
46
41
 
47
- # Edit a whitelist
42
+ # Public: Edit a whitelist.
48
43
  #
49
- # ==== Params
44
+ # user_id - ID of the user
45
+ # id - ID of whitelist
46
+ # options - Params for editing the whitelist, see `#create`
50
47
  #
51
- # * +user_id*+ - ID of the user
52
- # * +id*+ - ID of whitelist
53
- # * +options+ - Params for editing the whitelist
54
- #
55
- # ==== Options
56
- #
57
- # See #create
58
- def edit(user_id, id, options={})
59
- params.accepts(:ip, :description).validate!(options)
60
- request(:put, "/users/#{user_id}/user_white_lists/#{id}.json", :query => {:user_white_list => options})
48
+ # Returns a Hash.
49
+ def edit(user_id, id, options = {})
50
+ request(:put, "/users/#{user_id}/user_white_lists/#{id}.json", query: { user_white_list: options })
61
51
  end
62
52
 
63
- # Delete a whitelist
53
+ # Public: Delete a whitelist.
64
54
  #
65
- # ==== Params
55
+ # user_id - ID of the user
56
+ # id - ID of whitelist
66
57
  #
67
- # * +user_id*+ - ID of the user
68
- # * +id*+ - ID of whitelist
58
+ # Returns a Hash.
69
59
  def delete(user_id, id)
70
60
  request(:delete, "/users/#{user_id}/user_white_lists/#{id}.json")
71
61
  end
72
-
73
62
  end
74
63
  end