Class: Fog::Network::AzureRM::Subnet

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/azurerm/models/network/subnet.rb

Overview

Subnet model for Network Service

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.parse(subnet) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/fog/azurerm/models/network/subnet.rb', line 15

def self.parse(subnet)
  subnet_hash = {}
  subnet_hash['id'] = subnet.id
  subnet_hash['name'] = subnet.name
  subnet_hash['resource_group'] = get_resource_group_from_id(subnet.id)
  subnet_hash['virtual_network_name'] = get_virtual_network_from_id(subnet.id)
  subnet_hash['address_prefix'] = subnet.address_prefix
  subnet_hash['network_security_group_id'] = nil
  subnet_hash['network_security_group_id'] = subnet.network_security_group.id unless subnet.network_security_group.nil?
  subnet_hash['route_table_id'] = nil
  subnet_hash['route_table_id'] = subnet.route_table.id unless subnet.route_table.nil?
  subnet_hash['ip_configurations_ids'] = subnet.ip_configurations.map(&:id) unless subnet.ip_configurations.nil?
  subnet_hash
end

Instance Method Details

#attach_network_security_group(network_security_group_id) ⇒ Object



36
37
38
39
# File 'lib/fog/azurerm/models/network/subnet.rb', line 36

def attach_network_security_group(network_security_group_id)
  subnet = service.attach_network_security_group_to_subnet(resource_group, name, virtual_network_name, address_prefix, route_table_id, network_security_group_id)
  merge_attributes(Fog::Network::AzureRM::Subnet.parse(subnet))
end

#attach_route_table(route_table_id) ⇒ Object



46
47
48
49
# File 'lib/fog/azurerm/models/network/subnet.rb', line 46

def attach_route_table(route_table_id)
  subnet = service.attach_route_table_to_subnet(resource_group, name, virtual_network_name, address_prefix, network_security_group_id, route_table_id)
  merge_attributes(Fog::Network::AzureRM::Subnet.parse(subnet))
end

#destroyObject



60
61
62
# File 'lib/fog/azurerm/models/network/subnet.rb', line 60

def destroy
  service.delete_subnet(resource_group, name, virtual_network_name)
end

#detach_network_security_groupObject



41
42
43
44
# File 'lib/fog/azurerm/models/network/subnet.rb', line 41

def detach_network_security_group
  subnet = service.detach_network_security_group_from_subnet(resource_group, name, virtual_network_name, address_prefix, route_table_id)
  merge_attributes(Fog::Network::AzureRM::Subnet.parse(subnet))
end

#detach_route_tableObject



51
52
53
54
# File 'lib/fog/azurerm/models/network/subnet.rb', line 51

def detach_route_table
  subnet = service.detach_route_table_from_subnet(resource_group, name, virtual_network_name, address_prefix, network_security_group_id)
  merge_attributes(Fog::Network::AzureRM::Subnet.parse(subnet))
end

#get_available_ipaddresses_count(express_route_enabled) ⇒ Object



56
57
58
# File 'lib/fog/azurerm/models/network/subnet.rb', line 56

def get_available_ipaddresses_count(express_route_enabled)
  service.get_available_ipaddresses_count(name, address_prefix, ip_configurations_ids, express_route_enabled)
end

#saveObject



30
31
32
33
34
# File 'lib/fog/azurerm/models/network/subnet.rb', line 30

def save
  requires :name, :resource_group, :virtual_network_name, :address_prefix
  subnet = service.create_subnet(resource_group, name, virtual_network_name, address_prefix, network_security_group_id, route_table_id)
  merge_attributes(Fog::Network::AzureRM::Subnet.parse(subnet))
end