Method: Fog::Network::AzureRM::LoadBalancer.parse

Defined in:
lib/fog/azurerm/models/network/load_balancer.rb

.parse(load_balancer) ⇒ Object

Parameters:

  • load_balancer (Object)


19
20
21
22
23
24
25
26
27
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
# File 'lib/fog/azurerm/models/network/load_balancer.rb', line 19

def self.parse(load_balancer)
  hash = {}
  hash['id'] = load_balancer.id
  hash['name'] = load_balancer.name
  hash['location'] = load_balancer.location
  hash['resource_group'] = get_resource_group_from_id(load_balancer.id)
  hash['backend_address_pool_names'] = load_balancer.backend_address_pools.map(&:id) unless load_balancer.backend_address_pools.nil?
  hash['tags'] = load_balancer.tags

  hash['frontend_ip_configurations'] = []
  load_balancer.frontend_ipconfigurations.each do |fic|
    frontend_ip_configuration = Fog::Network::AzureRM::FrontendIPConfiguration.new
    hash['frontend_ip_configurations'] << frontend_ip_configuration.merge_attributes(Fog::Network::AzureRM::FrontendIPConfiguration.parse(fic))
  end unless load_balancer.frontend_ipconfigurations.nil?

  hash['load_balancing_rules'] = []
  load_balancer.load_balancing_rules.each do |lbr|
    load_balancing_rule = Fog::Network::AzureRM::LoadBalangcingRule.new
    hash['load_balancing_rules'] << load_balancing_rule.merge_attributes(Fog::Network::AzureRM::LoadBalangcingRule.parse(lbr))
  end unless load_balancer.load_balancing_rules.nil?

  hash['probes'] = []
  load_balancer.probes.each do |prb|
    prob = Fog::Network::AzureRM::Probe.new
    hash['probes'] << prob.merge_attributes(Fog::Network::AzureRM::Probe.parse(prb))
  end unless load_balancer.probes.nil?

  hash['inbound_nat_rules'] = []
  load_balancer.inbound_nat_rules.each do |inr|
    inbound_nat_rule = Fog::Network::AzureRM::InboundNatRule.new
    hash['inbound_nat_rules'] << inbound_nat_rule.merge_attributes(Fog::Network::AzureRM::InboundNatRule.parse(inr))
  end unless load_balancer.inbound_nat_rules.nil?

  hash['inbound_nat_pools'] = []
  load_balancer.inbound_nat_pools.each do |inp|
    inbound_nat_pool = Fog::Network::AzureRM::InboundNatPool.new
    hash['inbound_nat_pools'] << inbound_nat_pool.merge_attributes(Fog::Network::AzureRM::InboundNatPool.parse(inp))
  end unless load_balancer.inbound_nat_pools.nil?

  hash
end