Class: Squall::NetworkZone

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

Overview

OnApp NetworkZone

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) attach(id, network_id)

Attach a network to a network zone.

Parameters:

  • id

    ID of the network zone

  • network_id

    ID of the network

Returns:

  • a Hash.



57
58
59
# File 'lib/squall/network_zone.rb', line 57

def attach(id, network_id)
  request(:post, "/network_zones/#{id}/networks/#{network_id}/attach.json")
end

- (Object) create(options = {})

Creates a new network zone.

Parameters:

  • options (defaults to: {})

    Options for creating the new network zone:

Options Hash (options):

  • :label (Object)

    Label for the network zone

Returns:

  • a Hash.



38
39
40
# File 'lib/squall/network_zone.rb', line 38

def create(options = {})
  request(:post, "/network_zones.json", query: { pack: options })
end

- (Object) delete(id)

Deletes an existing network zone.

Parameters:

  • id

    ID of the network zone

Returns:

  • a Hash.



47
48
49
# File 'lib/squall/network_zone.rb', line 47

def delete(id)
  request(:delete, "/network_zones/#{id}.json")
end

- (Object) detach(id, network_id)

Detach a network from a network zone.

Parameters:

  • id

    ID of the network zone

  • network_id

    ID of the network

Returns:

  • a Hash.



67
68
69
# File 'lib/squall/network_zone.rb', line 67

def detach(id, network_id)
  request(:post, "/network_zones/#{id}/networks/#{network_id}/detach.json")
end

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

Updates an existing network zone.

Parameters:

  • id

    ID of the network zone

  • options (defaults to: {})

    Options to update the network zone, see `#create`

Returns:

  • a Hash.



28
29
30
# File 'lib/squall/network_zone.rb', line 28

def edit(id, options = {})
  request(:put, "/network_zones/#{id}.json", query:  { pack: options })
end

- (Object) list

Lists all network zones.

Returns:

  • an Array.



7
8
9
10
# File 'lib/squall/network_zone.rb', line 7

def list
  response = request(:get, "/network_zones.json")
  response.collect { |i| i['network_group'] }
end

- (Object) show(id)

Get the details for a network zone.

Parameters:

  • id

    ID of the network zone

Returns:

  • a Hash.



17
18
19
20
# File 'lib/squall/network_zone.rb', line 17

def show(id)
  response = request(:get, "/network_zones/#{id}.json")
  response['network_group']
end