Sha256: 64bfc31d8186310aa3670196a78abe0e3246b86789a9eaa36a3926c2a7d444a1

Contents?: true

Size: 922 Bytes

Versions: 15

Compression:

Stored size: 922 Bytes

Contents

class Ey::Core::Client::Firewall < Ey::Core::Model
  extend Ey::Core::Associations

  identity :id

  attribute :location
  attribute :name
  attribute :provisioned_id
  attribute :deleted_at, type: :time

  has_one :provider

  has_many :clusters
  has_many :firewall_rules, aliases: "rules"

  def rules
    firewall_rules
  end


  attr_accessor :cluster

  def save!
    requires :name, :provider_id

    params = {
      "url"      => self.collection.url,
      "firewall" => {
        "name"     => self.name,
        "location" => self.location,
      },
      "cluster"  => self.cluster,
      "provider" => self.provider_id,
    }

    if new_record?
      self.connection.requests.new(self.connection.create_firewall(params).body["request"])
    else raise NotImplementedError
    end
  end

  def destroy!
    connection.requests.new(self.connection.destroy_firewall("id" => self.id).body["request"])
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
ey-pro-cli-0.0.17 lib/vendor/core/ey-core/models/firewall.rb
ey-pro-cli-0.0.16 lib/vendor/core/ey-core/models/firewall.rb
ey-pro-cli-0.0.15 lib/vendor/core/ey-core/models/firewall.rb
ey-pro-cli-0.0.14 lib/vendor/core/ey-core/models/firewall.rb
ey-pro-cli-0.0.13 lib/vendor/core/ey-core/models/firewall.rb
ey-pro-cli-0.0.12 lib/vendor/core/ey-core/models/firewall.rb
ey-pro-cli-0.0.11 lib/vendor/core/ey-core/models/firewall.rb
ey-pro-cli-0.0.10 lib/vendor/core/ey-core/models/firewall.rb
ey-pro-cli-0.0.9 lib/vendor/core/ey-core/models/firewall.rb
ey-pro-cli-0.0.8 lib/vendor/core/ey-core/models/firewall.rb
ey-pro-cli-0.0.7 lib/vendor/core/ey-core/models/firewall.rb
ey-pro-cli-0.0.6 lib/vendor/core/ey-core/models/firewall.rb
ey-pro-cli-0.0.5 lib/vendor/core/ey-core/models/firewall.rb
ey-pro-cli-0.0.4 lib/vendor/core/ey-core/models/firewall.rb
ey-pro-cli-0.0.3 lib/vendor/core/ey-core/models/firewall.rb