Sha256: df6f753c5891b070ce91238a2c22ec1c67671cef9745680ef5bfb2312f23a97f

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

# -*- encoding: utf-8 -*-
module Simplenet
  module Client
    class Firewall < Base
      def initialize(url)
        @url     = url
        @fullurl = "#{url}/firewalls"
      end

      def create(zone_id, name, mac)
        simplenet_post(@fullurl, {"name" => name, "zone_id" => zone_id, "mac" => mac})
      end

      def enable(uuid)
        simplenet_post("#{@fullurl}/enable", {"id" => uuid})
      end

      def disable(uuid)
        simplenet_post("#{@fullurl}/disable", {"id" => uuid})
      end

      def sync(uuid)
        simplenet_post("#{@fullurl}/sync", {"id" => uuid})
      end

      def attach_anycast(uuid, anycast_id)
        simplenet_post("#{@fullurl}/#{uuid}/anycasts", {
          :anycast_id => anycast_id
        })
      rescue Simplenet::Exception::EntityNotFoundError
        msg = "Ip not found on simplestack. Is the anycast created already?"
        raise Simplenet::Exception::EntityNotFoundError.new(msg)
      end

      def detach_anycast(uuid, anycast_id)
        simplenet_delete("#{@fullurl}/#{uuid}/anycasts/#{anycast_id}")
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
simplenet-client-0.2.0 ./lib/simplenet/client/firewall.rb