Class: Squall::IpAddress

Inherits:
Base
  • Object
show all
Defined in:
lib/squall/ip_address.rb

Overview

OnApp IpAddress

Instance Attribute Summary

Attributes inherited from Base

#result, #success

Instance Method Summary (collapse)

Methods inherited from Base

#check_config, #default_params, #key_for_class, #request

Instance Method Details

- (Object) create(network_id, options = {})

Creates a new IpAddress

Parameters:

  • network_id

    ID of the network

  • options (defaults to: {})

    Params for the new ip address

Options Hash (options):

  • :address (Object)

    IP address

  • :broadcast (Object)

    A logical address at which all devices connected to a multiple-access

  • :disallowed_primary (Object)

    Set to '1' to prevent this address being used as primary

  • :gateway (Object)

    Gateway address

  • :netmask (Object)

    Network mask

  • :network_address (Object)

    IP address of network

Returns:

  • a Hash.



30
31
32
# File 'lib/squall/ip_address.rb', line 30

def create(network_id, options = {})
  request(:post, "/settings/networks/#{network_id}/ip_addresses.json", default_params(options))
end

- (Object) delete(network_id, id)

Deletes an existing ip address.

Parameters:

  • network_id

    ID of the network

  • id

    ID of the ip address

Returns:

  • a Hash.



51
52
53
# File 'lib/squall/ip_address.rb', line 51

def delete(network_id, id)
  request(:delete, "/settings/networks/#{network_id}/ip_addresses/#{id}.json")
end

- (Object) edit(network_id, id, options = {})

Updates an existing ip address.

Parameters:

  • network_id

    ID of the network

  • id

    ID of the ip address

  • options (defaults to: {})

    Params for updating the ip address, see `#create`

Returns:

  • a Hash.



41
42
43
# File 'lib/squall/ip_address.rb', line 41

def edit(network_id, id, options = {})
  request(:put, "/settings/networks/#{network_id}/ip_addresses/#{id}.json", default_params(options))
end

- (Object) list(network_id)

Lists IP addresses for a network.

Parameters:

  • network_id

    ID of the network

Returns:

  • an Array.



9
10
11
12
# File 'lib/squall/ip_address.rb', line 9

def list(network_id)
  response = request(:get, "/settings/networks/#{network_id}/ip_addresses.json")
  response.collect { |ip| ip['ip_address'] }
end