Class: Fog::Compute::Brightbox::FirewallRule

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/brightbox/models/compute/firewall_rule.rb

Instance Attribute Summary

Attributes inherited from Model

#collection, #connection

Instance Method Summary collapse

Methods inherited from Model

#initialize, #inspect, #reload, #symbolize_keys, #to_json, #wait_for

Methods included from Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #requires, #requires_one

Constructor Details

This class inherits a constructor from Fog::Model

Instance Method Details

#destroyObject



44
45
46
47
48
# File 'lib/fog/brightbox/models/compute/firewall_rule.rb', line 44

def destroy
  requires :identity
  connection.destroy_firewall_rule(identity)
  true
end

#saveObject

Sticking with existing Fog behaviour, save does not update but creates a new resource

Raises:



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/fog/brightbox/models/compute/firewall_rule.rb', line 26

def save
  raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
  requires :firewall_policy_id
  options = {
    :firewall_policy => firewall_policy_id,
    :protocol => protocol,
    :description => description,
    :source => source,
    :source_port => source_port,
    :destination => destination,
    :destination_port => destination_port,
    :icmp_type_name => icmp_type_name
  }.delete_if {|k,v| v.nil? || v == "" }
  data = connection.create_firewall_rule(options)
  merge_attributes(data)
  true
end