Class: Fog::Network::AzureRM::LoadBalancer
- Inherits:
-
Model
- Object
- Model
- Fog::Network::AzureRM::LoadBalancer
- Defined in:
- lib/fog/azurerm/models/network/load_balancer.rb
Overview
LoadBalancer model class for Network Service
Class Method Summary collapse
Instance Method Summary collapse
- #destroy ⇒ Object
- #save ⇒ Object
- #validate_frontend_ip_configuration_params(frontend_ip_configuration) ⇒ Object
- #validate_frontend_ip_configurations(frontend_ip_configurations) ⇒ Object
- #validate_inbound_nat_pool_params(inbound_nat_pool) ⇒ Object
- #validate_inbound_nat_pools(inbound_nat_pools) ⇒ Object
- #validate_inbound_nat_rule_params(inbound_nat_rule) ⇒ Object
- #validate_inbound_nat_rules(inbound_nat_rules) ⇒ Object
- #validate_load_balancing_rule_params(load_balancing_rule) ⇒ Object
- #validate_load_balancing_rules(load_balancing_rules) ⇒ Object
- #validate_probe_params(probe) ⇒ Object
- #validate_probes(probes) ⇒ Object
Class Method Details
.parse(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. 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 |
Instance Method Details
#destroy ⇒ Object
243 244 245 |
# File 'lib/fog/azurerm/models/network/load_balancer.rb', line 243 def destroy service.delete_load_balancer(resource_group, name) end |
#save ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/fog/azurerm/models/network/load_balancer.rb', line 61 def save requires :name, :location, :resource_group validate_frontend_ip_configurations(frontend_ip_configurations) unless frontend_ip_configurations.nil? validate_load_balancing_rules(load_balancing_rules) unless load_balancing_rules.nil? validate_probes(probes) unless probes.nil? validate_inbound_nat_rules(inbound_nat_rules) unless inbound_nat_rules.nil? validate_inbound_nat_pools(inbound_nat_pools) unless inbound_nat_pools.nil? load_balancer = service.create_load_balancer(name, location, resource_group, frontend_ip_configurations, backend_address_pool_names, load_balancing_rules, probes, inbound_nat_rules, inbound_nat_pools, ) merge_attributes(Fog::Network::AzureRM::LoadBalancer.parse(load_balancer)) end |
#validate_frontend_ip_configuration_params(frontend_ip_configuration) ⇒ Object
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
# File 'lib/fog/azurerm/models/network/load_balancer.rb', line 227 def validate_frontend_ip_configuration_params(frontend_ip_configuration) required_params = [ :name, :private_ipallocation_method ] missing = required_params.select { |p| p unless frontend_ip_configuration.key?(p) } if missing.length == 1 raise(ArgumentError, "#{missing.first} is required for this operation") elsif missing.any? raise(ArgumentError, "#{missing[0...-1].join(', ')} and #{missing[-1]} are required for this operation") end unless frontend_ip_configuration.key?(:subnet_id) || frontend_ip_configuration.key?(:public_ipaddress_id) raise(ArgumentError, 'subnet_id and public_id can not be empty at the same time.') end end |
#validate_frontend_ip_configurations(frontend_ip_configurations) ⇒ Object
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
# File 'lib/fog/azurerm/models/network/load_balancer.rb', line 209 def validate_frontend_ip_configurations(frontend_ip_configurations) if frontend_ip_configurations.is_a?(Array) if frontend_ip_configurations.any? frontend_ip_configurations.each do |frontend_ip_configuration| if frontend_ip_configuration.is_a?(Hash) validate_frontend_ip_configuration_params(frontend_ip_configuration) else raise(ArgumentError, ':frontend_ip_configurations must be an Array of Hashes') end end else raise(ArgumentError, ':frontend_ip_configurations must not be an empty Array') end else raise(ArgumentError, ':frontend_ip_configurations must be an Array') end end |
#validate_inbound_nat_pool_params(inbound_nat_pool) ⇒ Object
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'lib/fog/azurerm/models/network/load_balancer.rb', line 193 def validate_inbound_nat_pool_params(inbound_nat_pool) required_params = [ :name, :protocol, :frontend_port_range_start, :frontend_port_range_end, :backend_port ] missing = required_params.select { |p| p unless inbound_nat_pool.key?(p) } if missing.length == 1 raise(ArgumentError, "#{missing.first} is required for this operation") elsif missing.any? raise(ArgumentError, "#{missing[0...-1].join(', ')} and #{missing[-1]} are required for this operation") end end |
#validate_inbound_nat_pools(inbound_nat_pools) ⇒ Object
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
# File 'lib/fog/azurerm/models/network/load_balancer.rb', line 175 def validate_inbound_nat_pools(inbound_nat_pools) if inbound_nat_pools.is_a?(Array) if inbound_nat_pools.any? inbound_nat_pools.each do |inp| if inp.is_a?(Hash) validate_inbound_nat_pool_params(inp) else raise(ArgumentError, ':inbound_nat_pools must be an Array of Hashes') end end else raise(ArgumentError, ':inbound_nat_pools must not be an empty Array') end else raise(ArgumentError, ':inbound_nat_pools must be an Array') end end |
#validate_inbound_nat_rule_params(inbound_nat_rule) ⇒ Object
160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/fog/azurerm/models/network/load_balancer.rb', line 160 def validate_inbound_nat_rule_params(inbound_nat_rule) required_params = [ :name, :protocol, :frontend_port, :backend_port ] missing = required_params.select { |p| p unless inbound_nat_rule.key?(p) } if missing.length == 1 raise(ArgumentError, "#{missing.first} is required for this operation") elsif missing.any? raise(ArgumentError, "#{missing[0...-1].join(', ')} and #{missing[-1]} are required for this operation") end end |
#validate_inbound_nat_rules(inbound_nat_rules) ⇒ Object
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/fog/azurerm/models/network/load_balancer.rb', line 142 def validate_inbound_nat_rules(inbound_nat_rules) if inbound_nat_rules.is_a?(Array) if inbound_nat_rules.any? inbound_nat_rules.each do |inr| if inr.is_a?(Hash) validate_inbound_nat_rule_params(inr) else raise(ArgumentError, ':inbound_nat_rules must be an Array of Hashes') end end else raise(ArgumentError, ':inbound_nat_rules must not be an empty Array') end else raise(ArgumentError, ':inbound_nat_rules must be an Array') end end |
#validate_load_balancing_rule_params(load_balancing_rule) ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/fog/azurerm/models/network/load_balancer.rb', line 93 def validate_load_balancing_rule_params(load_balancing_rule) required_params = [ :name, :protocol, :frontend_port, :backend_port ] missing = required_params.select { |p| p unless load_balancing_rule.key?(p) } if missing.length == 1 raise(ArgumentError, "#{missing.first} is required for this operation") elsif missing.any? raise(ArgumentError, "#{missing[0...-1].join(', ')} and #{missing[-1]} are required for this operation") end end |
#validate_load_balancing_rules(load_balancing_rules) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/fog/azurerm/models/network/load_balancer.rb', line 75 def validate_load_balancing_rules(load_balancing_rules) if load_balancing_rules.is_a?(Array) if load_balancing_rules.any? load_balancing_rules.each do |lbr| if lbr.is_a?(Hash) validate_load_balancing_rule_params(lbr) else raise(ArgumentError, ':load_balancing_rules must be an Array of Hashes') end end else raise(ArgumentError, ':load_balancing_rules must not be an empty Array') end else raise(ArgumentError, ':load_balancing_rules must be an Array') end end |
#validate_probe_params(probe) ⇒ Object
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/fog/azurerm/models/network/load_balancer.rb', line 126 def validate_probe_params(probe) required_params = [ :name, :port, :request_path, :interval_in_seconds, :number_of_probes ] missing = required_params.select { |p| p unless probe.key?(p) } if missing.length == 1 raise(ArgumentError, "#{missing.first} is required for this operation") elsif missing.any? raise(ArgumentError, "#{missing[0...-1].join(', ')} and #{missing[-1]} are required for this operation") end end |
#validate_probes(probes) ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/fog/azurerm/models/network/load_balancer.rb', line 108 def validate_probes(probes) if probes.is_a?(Array) if probes.any? probes.each do |prb| if prb.is_a?(Hash) validate_probe_params(prb) else raise(ArgumentError, ':probes must be an Array of Hashes') end end else raise(ArgumentError, ':probes must not be an empty Array') end else raise(ArgumentError, ':probes must be an Array') end end |