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

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

Instance Method Summary collapse

Methods included from ModelHelper

#collection_name, #resource_name

Instance Method Details

#destroyObject



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

def destroy
  requires :identity
  service.delete_firewall_rule(identity)
  true
end

#saveObject

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

Raises:

  • (Fog::Errors::Error)


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

def save
  raise Fog::Errors::Error, "Resaving an existing object may create a duplicate" if persisted?
  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 = service.create_firewall_rule(options)
  merge_attributes(data)
  true
end