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.
- checksums.yaml +7 -0
- data/LICENSE +1 -1
- data/README.md +64 -41
- data/Rakefile +3 -9
- data/lib/squall/data_store_zone.rb +20 -26
- data/lib/squall/disk.rb +174 -0
- data/lib/squall/firewall_rule.rb +34 -41
- data/lib/squall/hypervisor.rb +40 -38
- data/lib/squall/hypervisor_zone.rb +51 -63
- data/lib/squall/ip_address.rb +32 -37
- data/lib/squall/ip_address_join.rb +13 -22
- data/lib/squall/network.rb +36 -33
- data/lib/squall/network_zone.rb +27 -29
- data/lib/squall/payment.rb +22 -32
- data/lib/squall/role.rb +30 -37
- data/lib/squall/statistic.rb +3 -1
- data/lib/squall/support/base.rb +35 -31
- data/lib/squall/support/config.rb +25 -1
- data/lib/squall/support/version.rb +1 -1
- data/lib/squall/template.rb +7 -5
- data/lib/squall/transaction.rb +6 -4
- data/lib/squall/user.rb +84 -83
- data/lib/squall/user_group.rb +17 -30
- data/lib/squall/virtual_machine.rb +154 -178
- data/lib/squall/whitelist.rb +29 -40
- data/lib/squall.rb +27 -25
- data/spec/spec_helper.rb +6 -11
- data/spec/squall/data_store_zone_spec.rb +2 -20
- data/spec/squall/disk_spec.rb +189 -0
- data/spec/squall/firewall_rule_spec.rb +2 -32
- data/spec/squall/hypervisor_spec.rb +3 -47
- data/spec/squall/hypervisor_zone_spec.rb +3 -28
- data/spec/squall/ip_address_join_spec.rb +1 -15
- data/spec/squall/ip_address_spec.rb +10 -35
- data/spec/squall/network_spec.rb +20 -31
- data/spec/squall/network_zone_spec.rb +2 -36
- data/spec/squall/payment_spec.rb +2 -21
- data/spec/squall/role_spec.rb +4 -16
- data/spec/squall/support/base_spec.rb +10 -16
- data/spec/squall/template_spec.rb +0 -4
- data/spec/squall/transaction_spec.rb +1 -3
- data/spec/squall/user_group_spec.rb +1 -17
- data/spec/squall/user_spec.rb +4 -92
- data/spec/squall/virtual_machine_spec.rb +8 -242
- data/spec/squall/whitelist_spec.rb +2 -40
- data/spec/squall_spec.rb +2 -2
- data/spec/vcr_cassettes/disk/add_schedule.yml +40 -0
- data/spec/vcr_cassettes/disk/auto_backup_off.yml +40 -0
- data/spec/vcr_cassettes/disk/auto_backup_on.yml +40 -0
- data/spec/vcr_cassettes/disk/backups.yml +40 -0
- data/spec/vcr_cassettes/disk/build.yml +40 -0
- data/spec/vcr_cassettes/disk/create.yml +40 -0
- data/spec/vcr_cassettes/disk/delete.yml +38 -0
- data/spec/vcr_cassettes/disk/edit.yml +40 -0
- data/spec/vcr_cassettes/disk/iops_usage.yml +40 -0
- data/spec/vcr_cassettes/disk/list.yml +40 -0
- data/spec/vcr_cassettes/disk/migrate.yml +38 -0
- data/spec/vcr_cassettes/disk/schedules.yml +40 -0
- data/spec/vcr_cassettes/disk/unlock.yml +40 -0
- data/spec/vcr_cassettes/disk/vm_disk_list.yml +40 -0
- data/spec/vcr_cassettes/network/rebuild.yml +41 -0
- metadata +217 -66
- data/.gitignore +0 -13
- data/.rspec +0 -2
- data/.rvmrc +0 -41
- data/.travis.yml +0 -17
- data/lib/squall/support/params.rb +0 -50
- data/lib/squall/support/yaml.rb +0 -5
- data/spec/squall/support/params_spec.rb +0 -195
- data/squall.gemspec +0 -32
@@ -1,311 +1,287 @@
|
|
1
1
|
module Squall
|
2
2
|
# OnApp VirtualMachine
|
3
3
|
class VirtualMachine < Base
|
4
|
-
#
|
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
|
-
#
|
12
|
+
# Public: Get info for a virtual machine.
|
11
13
|
#
|
12
|
-
#
|
14
|
+
# id - ID of the virtual machine
|
13
15
|
#
|
14
|
-
#
|
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
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
37
|
-
#
|
38
|
-
#
|
39
|
-
#
|
40
|
-
#
|
41
|
-
#
|
42
|
-
#
|
43
|
-
#
|
44
|
-
#
|
45
|
-
#
|
46
|
-
#
|
47
|
-
|
48
|
-
#
|
49
|
-
#
|
50
|
-
#
|
51
|
-
#
|
52
|
-
#
|
53
|
-
#
|
54
|
-
#
|
55
|
-
#
|
56
|
-
#
|
57
|
-
#
|
58
|
-
#
|
59
|
-
#
|
60
|
-
#
|
61
|
-
#
|
62
|
-
#
|
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
|
-
#
|
88
|
-
#
|
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
|
-
#
|
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
|
-
#
|
105
|
-
#
|
105
|
+
# id - ID of the virtual machine
|
106
|
+
# options - Params for creating the virtual machine, see `#create`
|
106
107
|
#
|
107
|
-
#
|
108
|
-
#
|
109
|
-
# See #create
|
108
|
+
# Returns a Hash.
|
110
109
|
def edit(id, options = {})
|
111
|
-
|
112
|
-
|
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
|
-
#
|
116
|
+
# id - ID of the virtual machine
|
117
|
+
# user_id - ID of the target User
|
138
118
|
#
|
139
|
-
#
|
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", :
|
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
|
-
#
|
127
|
+
# id - ID of the virtual machine
|
128
|
+
# password - New password
|
149
129
|
#
|
150
|
-
#
|
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", :
|
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
|
136
|
+
# Public: Assigns SSH keys of all administrators and a owner to a virtual
|
137
|
+
# machine.
|
158
138
|
#
|
159
|
-
#
|
139
|
+
# id - ID of the virtual machine
|
160
140
|
#
|
161
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
|
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
|
-
#
|
163
|
+
# id - ID of the virtual machine
|
186
164
|
#
|
187
|
-
#
|
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
|
-
#
|
173
|
+
# id - ID of the virtual machine
|
196
174
|
#
|
197
|
-
#
|
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
|
-
#
|
205
|
-
#
|
206
|
-
#
|
207
|
-
#
|
208
|
-
#
|
209
|
-
#
|
210
|
-
#
|
211
|
-
#
|
212
|
-
#
|
213
|
-
#
|
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
|
-
#
|
199
|
+
# id - ID of the virtual machine
|
225
200
|
#
|
226
|
-
#
|
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
|
-
#
|
209
|
+
# id - ID of the virtual machine
|
235
210
|
#
|
236
|
-
#
|
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
|
-
#
|
219
|
+
# id - ID of the virtual machine
|
245
220
|
#
|
246
|
-
#
|
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
|
-
#
|
229
|
+
# id - ID of the virtual machine
|
255
230
|
#
|
256
|
-
#
|
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
|
-
#
|
239
|
+
# id - ID of the virtual machine
|
265
240
|
#
|
266
|
-
#
|
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
|
-
#
|
249
|
+
# id - ID of the virtual machine
|
250
|
+
# recovery - Set to true to reboot in recovery, defaults to false
|
275
251
|
#
|
276
|
-
#
|
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", {:
|
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
|
-
#
|
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
|
-
#
|
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(:
|
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
|
-
#
|
272
|
+
# id - ID of the virtual machine
|
297
273
|
#
|
298
|
-
#
|
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
|
-
#
|
282
|
+
# id - ID of the virtual machine
|
307
283
|
#
|
308
|
-
#
|
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']
|
data/lib/squall/whitelist.rb
CHANGED
@@ -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
|
-
#
|
6
|
+
# user_id - ID of the user to display whitelists for
|
8
7
|
#
|
9
|
-
#
|
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
|
-
#
|
16
|
+
# user_id - ID of the user
|
17
|
+
# id - ID of the whitelist
|
18
18
|
#
|
19
|
-
#
|
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
|
-
#
|
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
|
-
#
|
36
|
-
# * +description+ - Description of the whitelist
|
32
|
+
# Example
|
37
33
|
#
|
38
|
-
#
|
34
|
+
# create ip: 192.168.1.1,
|
35
|
+
# description: "Computer that someone I trust uses"
|
39
36
|
#
|
40
|
-
#
|
41
|
-
|
42
|
-
|
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
|
-
#
|
44
|
+
# user_id - ID of the user
|
45
|
+
# id - ID of whitelist
|
46
|
+
# options - Params for editing the whitelist, see `#create`
|
50
47
|
#
|
51
|
-
#
|
52
|
-
|
53
|
-
|
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
|
-
#
|
55
|
+
# user_id - ID of the user
|
56
|
+
# id - ID of whitelist
|
66
57
|
#
|
67
|
-
#
|
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
|