Sha256: 94a93189f676a27df97eaabcb5a5c7018c0648ad5aba1f169db4b61abba69548

Contents?: true

Size: 1023 Bytes

Versions: 15

Compression:

Stored size: 1023 Bytes

Contents

require "pp"
module Brightbox
  class FirewallRule < Api
    def self.require_account?; true; end
    attr_writer :attributes

    def self.create(options)
      new(conn.firewall_rules.create(options))
    end

    def self.get(id)
      conn.firewall_rules.get(id)
    end

    def update(params)
      self.class.conn.update_firewall_rule id, params
      reload
      self
    end

    def attributes
      t = @attributes || fog_model.attributes
      t[:sport] = t[:source_port]
      t[:dport] = t[:destination_port]
      t[:firewall_policy] = t[:firewall_policy_id]
      t[:icmp_type] = t[:icmp_type_name]
      t
    end

    def to_row
      attrs = attributes.dup
      %i[protocol source sport destination dport icmp_type].each do |key|
        attrs[key] = attributes[key] || "-"
      end
      attrs
    end

    def ret_val(attributes, key)
      attributes[key] || "-"
    end

    def self.default_field_order
      %i[id protocol source sport destination dport icmp_type description]
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
brightbox-cli-5.0.0.alpha lib/brightbox-cli/firewall_rule.rb
brightbox-cli-4.8.0 lib/brightbox-cli/firewall_rule.rb
brightbox-cli-4.7.0 lib/brightbox-cli/firewall_rule.rb
brightbox-cli-4.6.0 lib/brightbox-cli/firewall_rule.rb
brightbox-cli-4.5.0 lib/brightbox-cli/firewall_rule.rb
brightbox-cli-4.5.0.rc1 lib/brightbox-cli/firewall_rule.rb
brightbox-cli-4.4.0 lib/brightbox-cli/firewall_rule.rb
brightbox-cli-4.3.2 lib/brightbox-cli/firewall_rule.rb
brightbox-cli-4.3.1 lib/brightbox-cli/firewall_rule.rb
brightbox-cli-4.3.0 lib/brightbox-cli/firewall_rule.rb
brightbox-cli-4.2.1 lib/brightbox-cli/firewall_rule.rb
brightbox-cli-4.2.0 lib/brightbox-cli/firewall_rule.rb
brightbox-cli-4.1.0 lib/brightbox-cli/firewall_rule.rb
brightbox-cli-4.0.0 lib/brightbox-cli/firewall_rule.rb
brightbox-cli-4.0.0.rc2 lib/brightbox-cli/firewall_rule.rb