Class: Fog::Compute::Brightbox::FirewallPolicy

Inherits:
Brightbox::Model show all
Defined in:
lib/fog/brightbox/models/compute/firewall_policy.rb

Instance Method Summary collapse

Methods included from Brightbox::ModelHelper

#collection_name, #resource_name

Instance Method Details

#apply_to(server_group_id) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/fog/brightbox/models/compute/firewall_policy.rb', line 31

def apply_to(server_group_id)
  requires :identity
  options = {
    :server_group => server_group_id
  }
  data = service.apply_to_firewall_policy(identity, options)
  merge_attributes(data)
  true
end

#destroyObject



51
52
53
54
55
# File 'lib/fog/brightbox/models/compute/firewall_policy.rb', line 51

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

#remove(server_group_id) ⇒ Object



41
42
43
44
45
46
47
48
49
# File 'lib/fog/brightbox/models/compute/firewall_policy.rb', line 41

def remove(server_group_id)
  requires :identity
  options = {
    :server_group => server_group_id
  }
  data = service.remove_firewall_policy(identity, options)
  merge_attributes(data)
  true
end

#saveObject

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

Raises:

  • (Fog::Errors::Error)


19
20
21
22
23
24
25
26
27
28
29
# File 'lib/fog/brightbox/models/compute/firewall_policy.rb', line 19

def save
  raise Fog::Errors::Error.new("Resaving an existing object may create a duplicate") if persisted?
  options = {
    :server_group => server_group_id,
    :name => name,
    :description => description
  }.delete_if { |_k, v| v.nil? || v == "" }
  data = service.create_firewall_policy(options)
  merge_attributes(data)
  true
end