Class: Fog::Network::AzureRM::VirtualNetworkGateway

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

Overview

VirtualNetworkGateway model class for Network Service

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.parse(network_gateway) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/fog/azurerm/models/network/virtual_network_gateway.rb', line 28

def self.parse(network_gateway)
  hash = {}
  hash['id'] = network_gateway.id
  hash['name'] = network_gateway.name
  hash['location'] = network_gateway.location
  hash['resource_group'] = get_resource_group_from_id(network_gateway.id)
  hash['tags'] = network_gateway.tags
  unless network_gateway.sku.nil?
    hash['sku_name'] = network_gateway.sku.name
    hash['sku_tier'] = network_gateway.sku.tier
    hash['sku_capacity'] = network_gateway.sku.capacity
  end
  hash['gateway_type'] = network_gateway.gateway_type
  hash['gateway_default_site'] = network_gateway.gateway_default_site
  hash['vpn_type'] = network_gateway.vpn_type
  hash['enable_bgp'] = network_gateway.enable_bgp
  hash['provisioning_state'] = network_gateway.provisioning_state
  bgp_settings = network_gateway.bgp_settings

  unless bgp_settings.nil?
    hash['asn'] = bgp_settings.asn
    hash['bgp_peering_address'] = bgp_settings.bgp_peering_address
    hash['peer_weight'] = bgp_settings.peer_weight
  end

  hash['ip_configurations'] = []
  network_gateway.ip_configurations.each do |ip_config|
    ip_configuration = Fog::Network::AzureRM::FrontendIPConfiguration.new
    hash['ip_configurations'] << ip_configuration.merge_attributes(Fog::Network::AzureRM::FrontendIPConfiguration.parse(ip_config))
  end unless network_gateway.ip_configurations.nil?

  unless network_gateway.vpn_client_configuration.nil?
    vpn_client_configuration = Fog::Network::AzureRM::VpnClientConfiguration.new
    hash['vpn_client_configuration'] = vpn_client_configuration.merge_attributes(Fog::Network::AzureRM::VpnClientConfiguration.parse(network_gateway.vpn_client_configuration))
  end

  hash
end

Instance Method Details

#destroyObject



74
75
76
# File 'lib/fog/azurerm/models/network/virtual_network_gateway.rb', line 74

def destroy
  service.delete_virtual_network_gateway(resource_group, name)
end

#saveObject



67
68
69
70
71
72
# File 'lib/fog/azurerm/models/network/virtual_network_gateway.rb', line 67

def save
  requires :name, :location, :resource_group, :gateway_type, :enable_bgp
  validate_ip_configurations(ip_configurations) unless ip_configurations.nil?
  network_gateway = service.create_or_update_virtual_network_gateway(virtual_gateway_parameters)
  merge_attributes(Fog::Network::AzureRM::VirtualNetworkGateway.parse(network_gateway))
end