Class: CloudControl::API::Network

Inherits:
Core
  • Object
show all
Defined in:
lib/cloudcontrol/api/network.rb

Instance Attribute Summary

Attributes inherited from Core

#client

Instance Method Summary collapse

Methods inherited from Core

#endpoint, #get, #get_simple, #initialize, #log, #org_endpoint, #org_id, #perform, #post, #post_simple, #query_params, #request_query_string, #request_simple_body, #request_xml_body, #simple_params, #single, #xml_params

Constructor Details

This class inherits a constructor from CloudControl::API::Core

Instance Method Details

#aclrule_create(network_id, name, position, inbound, protocol, port, allow) ⇒ Object



59
60
61
62
63
# File 'lib/cloudcontrol/api/network.rb', line 59

def aclrule_create(network_id, name, position, inbound, protocol, port, allow)
  org_endpoint "/network/#{network_id}/aclrule"
  xml_params(schema: "network", tag: "AclRule", name: name, position: position, action: (allow ? "PERMIT" : "DENY"), protocol: protocol, source_ip_range: {}, destination_ip_range: {}, port_range: {type: "EQUAL_TO", port1: port}, type: (inbound ? "OUTSIDE_ACL" : "INSIDE_ACL"))
  post
end

#aclrule_delete(network_id, aclrule_id) ⇒ Object



54
55
56
57
# File 'lib/cloudcontrol/api/network.rb', line 54

def aclrule_delete(network_id, aclrule_id)
  org_endpoint "/network/#{network_id}/aclrule/#{aclrule_id}?delete"
  get
end

#aclrule_list(network_id) ⇒ Object



49
50
51
52
# File 'lib/cloudcontrol/api/network.rb', line 49

def aclrule_list(network_id)
  org_endpoint "/network/#{network_id}/aclrule"
  get
end

#create(name, description = "", datacenter = @client.datacenter) ⇒ Object



8
9
10
11
12
# File 'lib/cloudcontrol/api/network.rb', line 8

def create(name, description="", datacenter=@client.datacenter)
  org_endpoint "/networkWithLocation"
  xml_params(schema: "network", tag: "NewNetworkWithLocation", name: name, description: description, location: datacenter)
  post
end

#listObject



3
4
5
6
# File 'lib/cloudcontrol/api/network.rb', line 3

def list
  org_endpoint '/network'
  get
end

#list_in_location(location_id) ⇒ Object



19
20
21
22
# File 'lib/cloudcontrol/api/network.rb', line 19

def list_in_location(location_id)
  org_endpoint "/networkWithLocation/#{location_id}"
  get
end

#list_with_locationObject



14
15
16
17
# File 'lib/cloudcontrol/api/network.rb', line 14

def list_with_location
  org_endpoint "/networkWithLocation"
  get
end

#natrule_create(network_id, name, source_ip) ⇒ Object

name = “10.147.15.11”, source_ip = “10.147.15.11”



38
39
40
41
42
# File 'lib/cloudcontrol/api/network.rb', line 38

def natrule_create(network_id, name, source_ip)
  org_endpoint "/network/#{network_id}/natrule"
  xml_params(schema: "network", tag: "NatRule", name: name, source_ip: source_ip)
  post
end

#natrule_delete(network_id, natrule_id) ⇒ Object



44
45
46
47
# File 'lib/cloudcontrol/api/network.rb', line 44

def natrule_delete(network_id, natrule_id)
  org_endpoint "/network/#{network_id}/natrule/#{natrule_id}?delete"
  get
end

#natrule_list(network_id) ⇒ Object



32
33
34
35
# File 'lib/cloudcontrol/api/network.rb', line 32

def natrule_list(network_id)
  org_endpoint "/network/#{network_id}/natrule"
  get
end

#show(network_id) ⇒ Object



24
25
26
# File 'lib/cloudcontrol/api/network.rb', line 24

def show(network_id)
  list_with_location.find {|n| n.id == network_id}
end

#show_by_name(name) ⇒ Object



28
29
30
# File 'lib/cloudcontrol/api/network.rb', line 28

def show_by_name(name)
 list_with_location.find {|n| n.name == name}
end