Sha256: 2c3082b0323df4ee7c59b53b99611770f6c90b4c620b1e818fd2ace51070d81f

Contents?: true

Size: 1.45 KB

Versions: 4

Compression:

Stored size: 1.45 KB

Contents

module Squall
  # OnApp Network
  class Network < Base
    # Returns a list of Networks
    def list
      response = request(:get, '/settings/networks.json')
      response.collect { |network| network['network'] }
    end

    # Edit a Network
    #
    # ==== Params
    #
    # * +id*+ - ID of the network
    # * +options+ - Params for editing the Network
    #
    # ==== Options
    #
    # See #create
    #
    # ==== Example
    #
    #   edit 1, :label => 'mynetwork', :network_group_id => 1, :vlan => 2, :identifier => 'something'
    def edit(id, options = {})
      params.accepts(:label, :network_group_id, :vlan, :identifier).validate!(options)
      response = request(:put, "/settings/networks/#{id}.json", default_params(options))
    end

    # Create a Network
    #
    # ==== Params
    #
    # * +options+ - Params for creating the Network
    #
    # ==== Options
    #
    # * +label*+
    # * +vlan+
    # * +identifier+
    #
    # ==== Example
    #
    #   create :label => 'mynetwork', :network_group_id => 1, :vlan => 2, :identifier => 'something'
    def create(options = {})
      params.accepts(:vlan, :identifier).required(:label).validate!(options)
      response = request(:post, '/settings/networks.json', default_params(options))
      response.first[1]
    end

    # Delete a network
    #
    # ==== Params
    #
    # * +id*+ - ID of the network
    def delete(id)
      request(:delete, "/settings/networks/#{id}.json")
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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