Sha256: 1908065e4f4cb65fa942d02533048e823666c923b216c2b1de8782db0e22b67e

Contents?: true

Size: 1.77 KB

Versions: 4

Compression:

Stored size: 1.77 KB

Contents

module Squall
  # OnApp NetworkZone
  class NetworkZone < Base
    # Returns a list of network zones
    def list
      response = request(:get, "/network_zones.json")
      response.collect { |i| i['network_group'] }
    end

    # Get the details for a network zone
    #
    # ==== Params
    #
    # * +id*+ - ID of the network zone
    def show(id)
      response = request(:get, "/network_zones/#{id}.json")
      response['network_group']
    end

    # Updates an existing network zone
    #
    # ==== Params
    #
    # * +id*+ - ID of the network zone
    #
    # ==== Options
    #
    # See #create
    def edit(id, options = {})
      params.required(:label).validate!(options)
      response = request(:put, "/network_zones/#{id}.json", :query => {:pack => options})
    end

    # Creates a new network zone
    #
    # ==== Options
    #
    # * +label*+ - Label for the network zone
    def create(options = {})
      params.required(:label).validate!(options)
      response = request(:post, "/network_zones.json", :query => {:pack => options})
    end

    # Deletes an existing network zone
    #
    # ==== Params
    #
    # * +id*+ - ID of the network zone
    def delete(id)
      request(:delete, "/network_zones/#{id}.json")
    end

    # Attach a network to a network zone
    #
    # ==== Params
    #
    # * +id*+ - ID of the network zone
    # * +network_id+ - ID of the network
    def attach(id, network_id)
      request(:post, "/network_zones/#{id}/networks/#{network_id}/attach.json")
    end

    # Detach a network from a network zone
    #
    # ==== Params
    #
    # * +id*+ - ID of the network zone
    # * +network_id+ - ID of the network
    def detach(id, network_id)
      request(:post, "/network_zones/#{id}/networks/#{network_id}/detach.json")
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
squall-1.3.0 lib/squall/network_zone.rb
squall-1.2.1beta1 lib/squall/network_zone.rb
squall-1.2.0beta1 lib/squall/network_zone.rb
squall-1.1.0 lib/squall/network_zone.rb