lib/squall/firewall_rule.rb in squall-1.3.0 vs lib/squall/firewall_rule.rb in squall-1.3.1

- old
+ new

@@ -1,66 +1,59 @@ module Squall # OnApp FirewallRule class FirewallRule < Base - - # Return a list of all firewall rules for a virtual machine + # Public: Lists all firewall rules for a virtual machine. # - # ==== Params + # vm_id - ID of the virtual machine # - # * +vm_id*+ - ID of the virtual machine + # Returns an Array. def list(vm_id) response = request(:get, "/virtual_machines/#{vm_id}/firewall_rules.json") response.collect { |firewall_rule| user['firewall_rule'] } end - # Create a firewall rule for a virtual machine + # Public: Create a firewall rule for a virtual machine. # - # ==== Params + # vm_id - ID of the virtual machine + # options - A Hash of options for the firewall rule: + # :address - IP address or range scope for rule. + # Leave blank to apply to all. + # :command - DROP or ACCEPT + # :network_interface_id - ID of the network interface + # :port - Port address for rule + # :protocol - TCP or UDP # - # * +vm_id*+ - ID of the virtual machine + # Example # - # ==== Options + # create( + # command: "DROP", + # protocol "TCP", + # network_interface_id: 1 + # ) # - # * +command*+ - DROP or ACCEPT - # * +protocol*+ - TCP or UDP - # * +network_interface_id*+ - ID of the network interface - # * +address+ - IP address or range scope for rule. Leave blank to apply to all. - # * +port+ - Port address for rule - # - # ==== Example - # - # create :command => "DROP", - # :protocol => "TCP", - # :network_interface_id => 1 - def create(vm_id, options={}) - params.required(:command, :protocol, :network_interface_id).accepts(:address, :port).validate!(options) + # Returns a Hash. + def create(vm_id, options = {}) request(:post, "/virtual_machines/#{vm_id}/firewall_rules.json", default_params(options)) end - # Edit a firewall rule + # Public: Edit a firewall rule. # - # ==== Params + # vm_id - ID of the virtual machine + # id - ID of the firewall rule + # options - A Hash of options for the firewall rule, see `#create`. # - # * +vm_id+ - ID of the virtual machine - # * +id+ - ID of the firewall rule - # * +options+ - Options for the firewall rule. - # - # ==== Options - # - # See #create - def edit(vm_id, id, options={}) - params.accepts(:command, :protocol, :network_interface_id, :address, :port).validate!(options) + # Returns a Hash. + def edit(vm_id, id, options = {}) request(:put, "/virtual_machines/#{vm_id}/firewall_rules/#{id}.json", default_params(options)) end - # Delete a firewall rule + # Public: Delete a firewall rule. # - # ==== Params + # vm_id - ID of the virtual machine + # id - ID of the firewall rule # - # * +vm_id*+ - ID of the virtual machine - # * +id+ - ID of the firewall rule + # Returns a Hash. def delete(vm_id, id) request(:delete, "/virtual_machines/#{vm_id}/firewall_rules/#{id}.json") end - end end