Sha256: 6ed935f8fcc3f3c76682cea76086135ea689f8f3f30ac1ed579779b12de34413

Contents?: true

Size: 1.46 KB

Versions: 10

Compression:

Stored size: 1.46 KB

Contents

module Fog
  module Brightbox
    class Compute
      class FirewallRule < Fog::Brightbox::Model
        identity :id
        attribute :resource_type
        attribute :url

        attribute :description

        attribute :destination
        attribute :destination_port
        attribute :icmp_type_name
        attribute :protocol
        attribute :source
        attribute :source_port

        # Timestamps
        attribute :created_at, type: :time

        # Links
        attribute :firewall_policy_id, aliases: "firewall_policy", squash: "id"

        # 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?
          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

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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
fog-brightbox-1.10.0 lib/fog/brightbox/models/compute/firewall_rule.rb
fog-brightbox-1.9.1 lib/fog/brightbox/models/compute/firewall_rule.rb
fog-brightbox-1.9.0 lib/fog/brightbox/models/compute/firewall_rule.rb
fog-brightbox-1.8.2 lib/fog/brightbox/models/compute/firewall_rule.rb
fog-brightbox-1.8.1 lib/fog/brightbox/models/compute/firewall_rule.rb
fog-brightbox-1.8.0 lib/fog/brightbox/models/compute/firewall_rule.rb
fog-brightbox-1.7.3 lib/fog/brightbox/models/compute/firewall_rule.rb
fog-brightbox-1.7.2 lib/fog/brightbox/models/compute/firewall_rule.rb
fog-brightbox-1.7.1 lib/fog/brightbox/models/compute/firewall_rule.rb
fog-brightbox-1.7.0 lib/fog/brightbox/models/compute/firewall_rule.rb