Sha256: b93fb656d45c140ed78492dfc27714e7d1d7ff01e81f6618d3fc1caf24251b25

Contents?: true

Size: 1.82 KB

Versions: 2

Compression:

Stored size: 1.82 KB

Contents

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

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

    # Public: Updates an existing network zone.
    #
    # id      - ID of the network zone
    # options - Options to update the network zone, see `#create`
    #
    # Returns a Hash.
    def edit(id, options = {})
      request(:put, "/network_zones/#{id}.json", query:  { pack: options })
    end

    # Public: Creates a new network zone.
    #
    # options - Options for creating the new network zone:
    #           :label - Label for the network zone
    #
    # Returns a Hash.
    def create(options = {})
      request(:post, "/network_zones.json", query: { pack: options })
    end

    # Public: Deletes an existing network zone.
    #
    # id - ID of the network zone
    #
    # Returns a Hash.
    def delete(id)
      request(:delete, "/network_zones/#{id}.json")
    end

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
squall-1.4.0 lib/squall/network_zone.rb
squall-1.3.1 lib/squall/network_zone.rb