Sha256: 4d8c15552f6af0d11a3641bdda21ead8798b3082fb4a3d0da5d90a1cfd550586

Contents?: true

Size: 1.62 KB

Versions: 27

Compression:

Stored size: 1.62 KB

Contents

require 'fog/core/model'

module Fog
  module Compute
    class Brightbox

      class FirewallPolicy < Fog::Model

        identity :id
        attribute :url
        attribute :resource_type

        attribute :name
        attribute :description

        attribute :default

        attribute :server_group_id, :aliases => "server_group", :squash => "id"
        attribute :created_at, :type => :time
        attribute :rules

        # Sticking with existing Fog behaviour, save does not update but creates a new resource
        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

        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

        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

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

Version data entries

27 entries across 27 versions & 3 rubygems

Version Path
fog-brightbox-0.1.0.dev2 lib/fog/brightbox/models/compute/firewall_policy.rb
fog-brightbox-0.1.0.dev1 lib/fog/brightbox/models/compute/firewall_policy.rb
fog-brightbox-0.0.2 lib/fog/brightbox/models/compute/firewall_policy.rb
fog-1.21.0 providers/brightbox/lib/fog/brightbox/models/compute/firewall_policy.rb
fog-maestrodev-1.20.0.20140305101839 lib/fog/brightbox/models/compute/firewall_policy.rb
fog-maestrodev-1.20.0.20140305101305 lib/fog/brightbox/models/compute/firewall_policy.rb
fog-brightbox-0.0.1 lib/fog/brightbox/models/compute/firewall_policy.rb
fog-maestrodev-1.19.0.20140212012611 lib/fog/brightbox/models/compute/firewall_policy.rb
fog-1.20.0 lib/fog/brightbox/models/compute/firewall_policy.rb
fog-maestrodev-1.19.0.20140110004459 lib/fog/brightbox/models/compute/firewall_policy.rb
fog-maestrodev-1.19.0.20140110003812 lib/fog/brightbox/models/compute/firewall_policy.rb
fog-maestrodev-1.19.0.20140109202555 lib/fog/brightbox/models/compute/firewall_policy.rb
fog-maestrodev-1.19.0.20140107192102 lib/fog/brightbox/models/compute/firewall_policy.rb
fog-maestrodev-1.19.0.20140107142106 lib/fog/brightbox/models/compute/firewall_policy.rb
fog-maestrodev-1.19.0.20131219203941 lib/fog/brightbox/models/compute/firewall_policy.rb
fog-maestrodev-1.18.0.20131219193542 lib/fog/brightbox/models/compute/firewall_policy.rb
fog-1.19.0 lib/fog/brightbox/models/compute/firewall_policy.rb
fog-maestrodev-1.18.0.20131219033443 lib/fog/brightbox/models/compute/firewall_policy.rb
fog-maestrodev-1.18.0.20131219032002 lib/fog/brightbox/models/compute/firewall_policy.rb
fog-maestrodev-1.18.0.20131219030716 lib/fog/brightbox/models/compute/firewall_policy.rb