diff --git a/.gitignore b/.gitignore index 9be466444..a6f274900 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ Gemfile.lock .arcconfig coverage +*/.DS_Store diff --git a/lib/fog/azurerm/models/network/application_gateway.rb b/lib/fog/azurerm/models/network/application_gateway.rb new file mode 100644 index 000000000..138efae12 --- /dev/null +++ b/lib/fog/azurerm/models/network/application_gateway.rb @@ -0,0 +1,456 @@ +module Fog + module Network + class AzureRM + # Application Gateway model class for Network Service + class ApplicationGateway < Fog::Model + identity :name + attribute :id + attribute :location + attribute :resource_group + attribute :provisioning_state + attribute :sku_name + attribute :sku_tier + attribute :sku_capacity + attribute :operational_state + attribute :gateway_ip_configurations + attribute :ssl_certificates + attribute :frontend_ip_configurations + attribute :frontend_ports + attribute :probes + attribute :backend_address_pools + attribute :backend_http_settings_list + attribute :http_listeners + attribute :url_path_maps + attribute :request_routing_rules + + def self.parse(gateway) + gateway_properties = gateway['properties'] + + hash = {} + hash['name'] = gateway['name'] + hash['id'] = gateway['id'] + hash['location'] = gateway['location'] + hash['resource_group'] = gateway['id'].split('/')[4] + unless gateway_properties.nil? + hash['provisioning_state'] = gateway_properties['provisioningState'] + unless gateway_properties['sku'].nil? + hash['sku_name'] = gateway_properties['sku']['name'] + hash['sku_tier'] = gateway_properties['sku']['tier'] + hash['sku_capacity'] = gateway_properties['sku']['capacity'] + end + hash['operational_state'] = gateway_properties['operationalState'] + + hash['gateway_ip_configurations'] = [] + gateway_properties['gatewayIpConfigurations'].each do |ip_configuration| + gateway_ip_configuration = Fog::Network::AzureRM::ApplicationGatewayIPConfiguration.new + hash['gateway_ip_configurations'] << gateway_ip_configuration.merge_attributes(Fog::Network::AzureRM::ApplicationGatewayIPConfiguration.parse(ip_configuration)) + end unless gateway_properties['gatewayIpConfigurations'].nil? + + hash['ssl_certificates'] = [] + gateway_properties['sslCertificates'].each do |certificate| + ssl_certificate = Fog::Network::AzureRM::ApplicationGatewaySslCertificate.new + hash['ssl_certificates'] << ssl_certificate.merge_attributes(Fog::Network::AzureRM::ApplicationGatewaySslCertificate.parse(certificate)) + end unless gateway_properties['sslCertificates'].nil? + + hash['frontend_ip_configurations'] = [] + gateway_properties['frontendIpConfigurations'].each do |frontend_ip_config| + frontend_ip_configuration = Fog::Network::AzureRM::ApplicationGatewayFrontendIPConfiguration.new + hash['frontend_ip_configurations'] << frontend_ip_configuration.merge_attributes(Fog::Network::AzureRM::ApplicationGatewayFrontendIPConfiguration.parse(frontend_ip_config)) + end unless gateway_properties['frontendIpConfigurations'].nil? + + hash['frontend_ports'] = [] + gateway_properties['frontendPorts'].each do |port| + frontend_port = Fog::Network::AzureRM::ApplicationGatewayFrontendPort.new + hash['frontend_ports'] << frontend_port.merge_attributes(Fog::Network::AzureRM::ApplicationGatewayFrontendPort.parse(port)) + end unless gateway_properties['frontendPorts'].nil? + + hash['probes'] = [] + gateway_properties['probes'].each do |probe| + gateway_probe = Fog::Network::AzureRM::ApplicationGatewayProbe.new + hash['probes'] << gateway_probe.merge_attributes(Fog::Network::AzureRM::ApplicationGatewayProbe.parse(probe)) + end unless gateway_properties['probes'].nil? + + hash['backend_address_pools'] = [] + gateway_properties['backendAddressPools'].each do |address| + backend_address_pool = Fog::Network::AzureRM::ApplicationGatewayBackendAddressPool.new + hash['backend_address_pools'] << backend_address_pool.merge_attributes(Fog::Network::AzureRM::ApplicationGatewayBackendAddressPool.parse(address)) + end unless gateway_properties['backendAddressPools'].nil? + + hash['backend_http_settings_list'] = [] + gateway_properties['backendHttpSettingsCollection'].each do |http_setting| + backend_http_setting = Fog::Network::AzureRM::ApplicationGatewayBackendHttpSetting.new + hash['backend_http_settings_list'] << backend_http_setting.merge_attributes(Fog::Network::AzureRM::ApplicationGatewayBackendHttpSetting.parse(http_setting)) + end unless gateway_properties['backendHttpSettingsCollection'].nil? + + hash['http_listeners'] = [] + gateway_properties['httpListeners'].each do |listener| + http_listener = Fog::Network::AzureRM::ApplicationGatewayHttpListener.new + hash['http_listeners'] << http_listener.merge_attributes(Fog::Network::AzureRM::ApplicationGatewayHttpListener.parse(listener)) + end unless gateway_properties['httpListeners'].nil? + + hash['url_path_maps'] = [] + gateway_properties['urlPathMaps'].each do |map| + url_path_map = Fog::Network::AzureRM::ApplicationGatewayUrlPathMap.new + hash['url_path_maps'] << url_path_map.merge_attributes(Fog::Network::AzureRM::ApplicationGatewayUrlPathMap.parse(map)) + end unless gateway_properties['urlPathMaps'].nil? + + hash['request_routing_rules'] = [] + gateway_properties['requestRoutingRules'].each do |rule| + request_routing_rule = Fog::Network::AzureRM::ApplicationGatewayRequestRoutingRule.new + hash['request_routing_rules'] << request_routing_rule.merge_attributes(Fog::Network::AzureRM::ApplicationGatewayRequestRoutingRule.parse(rule)) + end unless gateway_properties['requestRoutingRules'].nil? + end + hash + end + + def save + requires :name, :location, :resource_group, :sku_name, :sku_tier, :sku_capacity, :gateway_ip_configurations, :frontend_ip_configurations, :frontend_ports, :backend_address_pools, :backend_http_settings_list, :http_listeners, :request_routing_rules + + validate_gateway_ip_configurations(gateway_ip_configurations) unless gateway_ip_configurations.nil? + validate_ssl_certificates(ssl_certificates) unless ssl_certificates.nil? + validate_frontend_ip_configurations(frontend_ip_configurations) unless frontend_ip_configurations.nil? + validate_frontend_ports(frontend_ports) unless frontend_ports.nil? + validate_probes(probes) unless probes.nil? + validate_backend_address_pools(backend_address_pools) unless backend_address_pools.nil? + validate_backend_http_settings_list(backend_http_settings_list) unless backend_http_settings_list.nil? + validate_http_listeners(http_listeners) unless http_listeners.nil? + validate_url_path_maps(url_path_maps) unless url_path_maps.nil? + validate_request_routing_rules(request_routing_rules) unless request_routing_rules.nil? + + gateway = service.create_application_gateway(name, location, resource_group, sku_name, sku_tier, sku_capacity, gateway_ip_configurations, ssl_certificates, frontend_ip_configurations, frontend_ports, probes, backend_address_pools, backend_http_settings_list, http_listeners, url_path_maps, request_routing_rules) + merge_attributes(Fog::Network::AzureRM::ApplicationGateway.parse(gateway)) + end + + def validate_gateway_ip_configurations(gateway_ip_configurations) + if gateway_ip_configurations.is_a?(Array) + if gateway_ip_configurations.any? + gateway_ip_configurations.each do |gateway_ip_configuration| + if gateway_ip_configuration.is_a?(Hash) + validate_gateway_ip_configuration_params(gateway_ip_configuration) + else + raise(ArgumentError, ':gateway_ip_configurations must be an Array of Hashes') + end + end + else + raise(ArgumentError, ':gateway_ip_configurations must not be an empty Array') + end + else + raise(ArgumentError, ':gateway_ip_configurations must be an Array') + end + end + + def validate_gateway_ip_configuration_params(gateway_ip_configuration) + required_params = [ + :name, + :subnet_id + ] + missing = required_params.select { |p| p unless gateway_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 + end + + def validate_ssl_certificates(ssl_certificates) + if ssl_certificates.is_a?(Array) + if ssl_certificates.any? + ssl_certificates.each do |ssl_certificate| + if ssl_certificate.is_a?(Hash) + validate_ssl_certificate_params(ssl_certificate) + else + raise(ArgumentError, ':ssl_certificates must be an Array of Hashes') + end + end + else + raise(ArgumentError, ':ssl_certificates must not be an empty Array') + end + else + raise(ArgumentError, ':ssl_certificates must be an Array') + end + end + + def validate_ssl_certificate_params(ssl_certificate) + required_params = [ + :name, + :data, + :password, + :public_cert_data + ] + missing = required_params.select { |p| p unless ssl_certificate.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 + + 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 + + def validate_frontend_ip_configuration_params(frontend_ip_configuration) + required_params = [ + :name, + :public_ip_address_id, + :private_ip_allocation_method, + :private_ip_address + ] + 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 + end + + def validate_frontend_ports(frontend_ports) + if frontend_ports.is_a?(Array) + if frontend_ports.any? + frontend_ports.each do |frontend_port| + if frontend_port.is_a?(Hash) + validate_frontend_port_params(frontend_port) + else + raise(ArgumentError, ':frontend_ports must be an Array of Hashes') + end + end + else + raise(ArgumentError, ':frontend_ports must not be an empty Array') + end + else + raise(ArgumentError, ':frontend_ports must be an Array') + end + end + + def validate_frontend_port_params(frontend_port) + required_params = [ + :name, + :port + ] + missing = required_params.select { |p| p unless frontend_port.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 + + def validate_probes(probes) + if probes.is_a?(Array) + if probes.any? + probes.each do |probe| + if probe.is_a?(Hash) + validate_probe_params(probe) + 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 + + def validate_probe_params(probe) + required_params = [ + :name, + :protocol, + :host, + :path, + :interval, + :timeout, + :unhealthy_threshold + ] + 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 + + def validate_backend_address_pools(backend_address_pools) + if backend_address_pools.is_a?(Array) + if backend_address_pools.any? + backend_address_pools.each do |backend_address_pool| + if backend_address_pool.is_a?(Hash) + validate_backend_address_pool_params(backend_address_pool) + else + raise(ArgumentError, ':backend_address_pools must be an Array of Hashes') + end + end + else + raise(ArgumentError, ':backend_address_pools must not be an empty Array') + end + else + raise(ArgumentError, ':backend_address_pools must be an Array') + end + end + + def validate_backend_address_pool_params(backend_address_pool) + required_params = [ + :name, + :ip_addresses + ] + missing = required_params.select { |p| p unless backend_address_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 + + def validate_backend_http_settings_list(backend_http_settings_list) + if backend_http_settings_list.is_a?(Array) + if backend_http_settings_list.any? + backend_http_settings_list.each do |backend_http_settings| + if backend_http_settings.is_a?(Hash) + validate_backend_http_settings_params(backend_http_settings) + else + raise(ArgumentError, ':backend_http_settings_list must be an Array of Hashes') + end + end + else + raise(ArgumentError, ':backend_http_settings_list must not be an empty Array') + end + else + raise(ArgumentError, ':backend_http_settings_list must be an Array') + end + end + + def validate_backend_http_settings_params(backend_http_settings) + required_params = [ + :name, + :port, + :protocol, + :cookie_based_affinity, + :request_timeout + ] + missing = required_params.select { |p| p unless backend_http_settings.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 + + def validate_http_listeners(http_listeners) + if http_listeners.is_a?(Array) + if http_listeners.any? + http_listeners.each do |http_listener| + if http_listener.is_a?(Hash) + validate_http_listener_params(http_listener) + else + raise(ArgumentError, ':http_listeners must be an Array of Hashes') + end + end + else + raise(ArgumentError, ':http_listeners must not be an empty Array') + end + else + raise(ArgumentError, ':http_listeners must be an Array') + end + end + + def validate_http_listener_params(http_listener) + required_params = [ + :name, + :frontend_ip_config_id, + :frontend_port_id, + :protocol + ] + missing = required_params.select { |p| p unless http_listener.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 + + def validate_url_path_maps(url_path_maps) + if url_path_maps.is_a?(Array) + if url_path_maps.any? + url_path_maps.each do |url_path_map| + if url_path_map.is_a?(Hash) + validate_url_path_map_params(url_path_map) + else + raise(ArgumentError, ':url_path_maps must be an Array of Hashes') + end + end + else + raise(ArgumentError, ':url_path_maps must not be an empty Array') + end + else + raise(ArgumentError, ':url_path_maps must be an Array') + end + end + + def validate_url_path_map_params(url_path_map) + required_params = [ + :name, + :default_backend_address_pool_id, + :default_backend_http_settings_id, + :path_rules + ] + missing = required_params.select { |p| p unless url_path_map.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 + + def validate_request_routing_rules(request_routing_rules) + if request_routing_rules.is_a?(Array) + if request_routing_rules.any? + request_routing_rules.each do |request_routing_rule| + if request_routing_rule.is_a?(Hash) + validate_request_routing_rule_params(request_routing_rule) + else + raise(ArgumentError, ':request_routing_rules must be an Array of Hashes') + end + end + else + raise(ArgumentError, ':request_routing_rules must not be an empty Array') + end + else + raise(ArgumentError, ':request_routing_rules must be an Array') + end + end + + def validate_request_routing_rule_params(request_routing_rule) + required_params = [ + :type, + :http_listener_id + ] + missing = required_params.select { |p| p unless request_routing_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 + + def destroy + service.delete_application_gateway(resource_group, name) + end + end + end + end +end diff --git a/lib/fog/azurerm/models/network/application_gateway_backend_address_pool.rb b/lib/fog/azurerm/models/network/application_gateway_backend_address_pool.rb new file mode 100644 index 000000000..b71101fb4 --- /dev/null +++ b/lib/fog/azurerm/models/network/application_gateway_backend_address_pool.rb @@ -0,0 +1,24 @@ +module Fog + module Network + class AzureRM + # Backend Address Pool model class for Network Service + class ApplicationGatewayBackendAddressPool < Fog::Model + identity :name + attribute :ip_addresses + + def self.parse(backend_address_pool) + hash = {} + unless backend_address_pool['properties'].nil? + backend_addresses = backend_address_pool['properties']['backendAddresses'] + hash['name'] = backend_address_pool['name'] + hash['ip_addresses'] = [] + backend_addresses.each do |ip_address| + hash['ip_addresses'] << ip_address + end unless backend_addresses.nil? + end + hash + end + end + end + end +end diff --git a/lib/fog/azurerm/models/network/application_gateway_backend_http_setting.rb b/lib/fog/azurerm/models/network/application_gateway_backend_http_setting.rb new file mode 100644 index 000000000..06efe04f6 --- /dev/null +++ b/lib/fog/azurerm/models/network/application_gateway_backend_http_setting.rb @@ -0,0 +1,30 @@ +module Fog + module Network + class AzureRM + # Backend Http Settings model class for Network Service + class ApplicationGatewayBackendHttpSetting < Fog::Model + identity :name + attribute :port + attribute :protocol + attribute :cookie_based_affinity + attribute :request_timeout + attribute :probe + + def self.parse(backend_http_setting) + backend_http_setting_properties = backend_http_setting['properties'] + + hash = {} + hash['name'] = backend_http_setting['name'] + unless backend_http_setting_properties.nil? + hash['port'] = backend_http_setting_properties['port'] + hash['protocol'] = backend_http_setting_properties['protocol'] + hash['cookie_based_affinity'] = backend_http_setting_properties['cookieBasedAffinity'] + hash['request_timeout'] = backend_http_setting_properties['requestTimeout'] + hash['probe'] = backend_http_setting_properties['probe'] + hash + end + end + end + end + end +end diff --git a/lib/fog/azurerm/models/network/application_gateway_frontend_ip_configuration.rb b/lib/fog/azurerm/models/network/application_gateway_frontend_ip_configuration.rb new file mode 100644 index 000000000..dd15b4d8b --- /dev/null +++ b/lib/fog/azurerm/models/network/application_gateway_frontend_ip_configuration.rb @@ -0,0 +1,30 @@ +module Fog + module Network + class AzureRM + # Frontend IP Configuration model class for Network Service + class ApplicationGatewayFrontendIPConfiguration < Fog::Model + identity :name + attribute :public_ip_address_id + attribute :private_ip_allocation_method + attribute :private_ip_address + def self.parse(frontend_ip_configuration) + frontend_ip_configuration_properties = frontend_ip_configuration['properties'] + + hash = {} + hash['name'] = frontend_ip_configuration['name'] + unless frontend_ip_configuration_properties.nil? + unless frontend_ip_configuration_properties['publicIPAddress'].nil? + hash['public_ip_address_id'] = frontend_ip_configuration_properties['publicIPAddress']['id'] + end + hash['private_ip_allocation_method'] = frontend_ip_configuration_properties['privateIPAllocationMethod'] + private_ip_address = frontend_ip_configuration_properties['privateIPAddress'] + unless private_ip_address.nil? + hash['private_ip_address'] = private_ip_address + end + end + hash + end + end + end + end +end diff --git a/lib/fog/azurerm/models/network/application_gateway_frontend_port.rb b/lib/fog/azurerm/models/network/application_gateway_frontend_port.rb new file mode 100644 index 000000000..5e06ef2d0 --- /dev/null +++ b/lib/fog/azurerm/models/network/application_gateway_frontend_port.rb @@ -0,0 +1,22 @@ +module Fog + module Network + class AzureRM + # Frontenf Port model class for Network Service + class ApplicationGatewayFrontendPort < Fog::Model + identity :name + attribute :port + + def self.parse(frontend_port) + frontend_port_properties = frontend_port['properties'] + + hash = {} + hash['name'] = frontend_port['name'] + unless frontend_port_properties['port'].nil? + hash['port'] = frontend_port_properties['port'] + end + hash + end + end + end + end +end diff --git a/lib/fog/azurerm/models/network/application_gateway_http_listener.rb b/lib/fog/azurerm/models/network/application_gateway_http_listener.rb new file mode 100644 index 000000000..30a3035e7 --- /dev/null +++ b/lib/fog/azurerm/models/network/application_gateway_http_listener.rb @@ -0,0 +1,37 @@ +module Fog + module Network + class AzureRM + # Http Listener class for Network Service + class ApplicationGatewayHttpListener < Fog::Model + identity :name + attribute :frontend_ip_config_id + attribute :frontend_port_id + attribute :protocol + attribute :host_name + attribute :ssl_certificate_id + attribute :require_server_name_indication + + def self.parse(http_listener) + http_listener_properties = http_listener['properties'] + hash = {} + hash['name'] = http_listener['name'] + unless http_listener_properties.nil? + unless http_listener_properties['frontendIPConfiguration'].nil? + hash['frontend_ip_config_id'] = http_listener_properties['frontendIPConfiguration']['id'] + end + unless http_listener_properties['frontendPort'].nil? + hash['frontend_port_id'] = http_listener_properties['frontendPort']['id'] + end + hash['protocol'] = http_listener_properties['protocol'] + hash['host_name'] = http_listener_properties['hostName'] + unless http_listener_properties['sslCertificate'].nil? + hash['ssl_certificate_id'] = http_listener_properties['sslCertificate']['id'] + hash['require_server_name_indication'] = http_listener_properties['sslCertificate']['requireServerNameIndication'] + end + end + hash + end + end + end + end +end diff --git a/lib/fog/azurerm/models/network/application_gateway_ip_configuration.rb b/lib/fog/azurerm/models/network/application_gateway_ip_configuration.rb new file mode 100644 index 000000000..6641913f0 --- /dev/null +++ b/lib/fog/azurerm/models/network/application_gateway_ip_configuration.rb @@ -0,0 +1,21 @@ +module Fog + module Network + class AzureRM + # GatewayIPConfiguration model class for Network Service + class ApplicationGatewayIPConfiguration < Fog::Model + identity :name + attribute :subnet_id + + def self.parse(gateway_ip_configuration) + hash = {} + hash['name'] = gateway_ip_configuration['name'] + gateway_ip_configuration_prop = gateway_ip_configuration['properties'] + unless gateway_ip_configuration_prop['subnet'].nil? + hash['subnet_id'] = gateway_ip_configuration_prop['subnet']['id'] + end + hash + end + end + end + end +end diff --git a/lib/fog/azurerm/models/network/application_gateway_probe.rb b/lib/fog/azurerm/models/network/application_gateway_probe.rb new file mode 100644 index 000000000..7dfdda31d --- /dev/null +++ b/lib/fog/azurerm/models/network/application_gateway_probe.rb @@ -0,0 +1,32 @@ +module Fog + module Network + class AzureRM + # Probe model class for Network Service + class ApplicationGatewayProbe < Fog::Model + identity :name + attribute :protocol + attribute :host + attribute :path + attribute :interval + attribute :timeout + attribute :unhealthy_threshold + + def self.parse(probe) + probe_properties = probe['properties'] + + hash = {} + hash['name'] = probe['name'] + unless probe_properties.nil? + hash['protocol'] = probe_properties['protocol'] + hash['host'] = probe_properties['host'] + hash['path'] = probe_properties['path'] + hash['interval'] = probe_properties['interval'] + hash['timeout'] = probe_properties['timeout'] + hash['unhealthy_threshold'] = probe_properties['unhealthyThreshold'] + end + hash + end + end + end + end +end diff --git a/lib/fog/azurerm/models/network/application_gateway_request_routing_rule.rb b/lib/fog/azurerm/models/network/application_gateway_request_routing_rule.rb new file mode 100644 index 000000000..496028593 --- /dev/null +++ b/lib/fog/azurerm/models/network/application_gateway_request_routing_rule.rb @@ -0,0 +1,35 @@ +module Fog + module Network + class AzureRM + # Request Routing Rule model class for Network Service + class ApplicationGatewayRequestRoutingRule < Fog::Model + identity :name + attribute :type + attribute :http_listener_id + attribute :backend_address_pool_id + attribute :backend_http_settings_id + attribute :url_path_map + + def self.parse(request_routing_rule) + request_routing_rule_properties = request_routing_rule['properties'] + + hash = {} + hash['name'] = request_routing_rule['name'] + unless request_routing_rule_properties.nil? + hash['type'] = request_routing_rule_properties['ruleType'] + unless request_routing_rule_properties['httpListener'].nil? + hash['http_listener_id'] = request_routing_rule_properties['httpListener']['id'] + end + unless request_routing_rule_properties['backendAddressPool'].nil? + hash['backend_address_pool_id'] = request_routing_rule_properties['backendAddressPool']['id'] + end + unless request_routing_rule_properties['backendHttpSettings'].nil? + hash['backend_http_settings_id'] = request_routing_rule_properties['backendHttpSettings']['id'] + end + end + hash + end + end + end + end +end diff --git a/lib/fog/azurerm/models/network/application_gateway_ssl_certificate.rb b/lib/fog/azurerm/models/network/application_gateway_ssl_certificate.rb new file mode 100644 index 000000000..a94b4c5cd --- /dev/null +++ b/lib/fog/azurerm/models/network/application_gateway_ssl_certificate.rb @@ -0,0 +1,26 @@ +module Fog + module Network + class AzureRM + # SSL Certificate model class for Network Service + class ApplicationGatewaySslCertificate < Fog::Model + identity :name + attribute :data + attribute :password + attribute :public_cert_data + + def self.parse(ssl_certificate) + ssl_certificate_properties = ssl_certificate['properties'] + + hash = {} + hash['name'] = ssl_certificate['name'] + unless ssl_certificate_properties.nil? + hash['data'] = ssl_certificate_properties['data'] + hash['password'] = ssl_certificate_properties['password'] + hash['public_cert_data'] = ssl_certificate_properties['publicCertData'] + end + hash + end + end + end + end +end diff --git a/lib/fog/azurerm/models/network/application_gateway_url_path_map.rb b/lib/fog/azurerm/models/network/application_gateway_url_path_map.rb new file mode 100644 index 000000000..ff3d0dea1 --- /dev/null +++ b/lib/fog/azurerm/models/network/application_gateway_url_path_map.rb @@ -0,0 +1,32 @@ +module Fog + module Network + class AzureRM + # URL Path Map model class for Network Service + class ApplicationGatewayUrlPathMap < Fog::Model + identity :name + attribute :default_backend_address_pool_id + attribute :default_backend_http_settings_id + attribute :path_rules + + def self.parse(url_path_map) + url_path_map_properties = url_path_map['properties'] + + hash = {} + hash['name'] = url_path_map['name'] + unless url_path_map_properties.nil? + hash['default_backend_address_pool_id'] = url_path_map_properties['defaultBackendAddressPool']['id'] + hash['default_backend_http_settings_id'] = url_path_map_properties['defaultBackendHttpSettings']['id'] + + path_rules = url_path_map_properties['pathRules'] + hash['path_rules'] = [] + path_rules.each do |rule| + path_rule = Fog::Network::AzureRM::PathRule.new + hash['path_rules'] << path_rule.merge_attributes(Fog::Network::AzureRM::PathRule.parse(rule)) + end unless path_rules.nil? + end + hash + end + end + end + end +end diff --git a/lib/fog/azurerm/models/network/application_gateways.rb b/lib/fog/azurerm/models/network/application_gateways.rb new file mode 100644 index 000000000..f7937f963 --- /dev/null +++ b/lib/fog/azurerm/models/network/application_gateways.rb @@ -0,0 +1,27 @@ +require 'fog/core/collection' +require 'fog/azurerm/models/network/application_gateway' + +module Fog + module Network + class AzureRM + # Application Gateway collection class for Network Service + class ApplicationGateways < Fog::Collection + model Fog::Network::AzureRM::ApplicationGateway + attribute :resource_group + + def all + requires :resource_group + application_gateways = [] + service.list_application_gateways(resource_group).each do |gateway| + application_gateways << Fog::Network::AzureRM::ApplicationGateway.parse(gateway) + end + load(application_gateways) + end + + def get(identity) + all.find { |f| f.name == identity } + end + end + end + end +end diff --git a/lib/fog/azurerm/models/network/path_rule.rb b/lib/fog/azurerm/models/network/path_rule.rb new file mode 100644 index 000000000..62d7c8099 --- /dev/null +++ b/lib/fog/azurerm/models/network/path_rule.rb @@ -0,0 +1,30 @@ +module Fog + module Network + class AzureRM + # Path Rule model class for Network Service + class PathRule < Fog::Model + attribute :paths + attribute :backend_address_pool_id + attribute :backend_http_settings_id + + def self.parse(path_rule) + paths = path_rule['paths'] + + hash = {} + hash['paths'] = [] + paths.each do |path| + hash['paths'] << path + end unless paths.nil? + + unless path_rule['backendAddressPool'].nil? + hash['backend_address_pool_id'] = path_rule['backendAddressPool']['id'] + end + unless path_rule['backendHttpsettings'].nil? + hash['backend_http_settings_id'] = path_rule['backendHttpsettings']['id'] + end + hash + end + end + end + end +end diff --git a/lib/fog/azurerm/network.rb b/lib/fog/azurerm/network.rb index 7b5fb2bf4..2adce5ab4 100644 --- a/lib/fog/azurerm/network.rb +++ b/lib/fog/azurerm/network.rb @@ -30,6 +30,9 @@ class AzureRM < Fog::Service request :create_network_security_group request :delete_network_security_group request :list_network_security_groups + request :create_application_gateway + request :delete_application_gateway + request :list_application_gateways request :create_traffic_manager_profile request :get_traffic_manager_profile request :delete_traffic_manager_profile @@ -56,6 +59,19 @@ class AzureRM < Fog::Service model :network_security_group collection :network_security_groups model :network_security_rule + model :application_gateway + collection :application_gateways + model :application_gateway_backend_address_pool + model :application_gateway_backend_http_setting + model :application_gateway_frontend_ip_configuration + model :application_gateway_frontend_port + model :application_gateway_ip_configuration + model :application_gateway_http_listener + model :path_rule + model :application_gateway_probe + model :application_gateway_request_routing_rule + model :application_gateway_ssl_certificate + model :application_gateway_url_path_map model :traffic_manager_profile collection :traffic_manager_profiles model :traffic_manager_end_point diff --git a/lib/fog/azurerm/requests/network/create_application_gateway.rb b/lib/fog/azurerm/requests/network/create_application_gateway.rb new file mode 100644 index 000000000..8e36fd6f0 --- /dev/null +++ b/lib/fog/azurerm/requests/network/create_application_gateway.rb @@ -0,0 +1,371 @@ +module Fog + module Network + class AzureRM + # Real class for Network Request + class Real + def create_application_gateway(name, location, resource_group, sku_name, sku_tier, sku_capacity, gateway_ip_configurations, ssl_certificates, frontend_ip_configurations, frontend_ports, probes, backend_address_pools, backend_http_settings_list, http_listeners, url_path_maps, request_routing_rules) + Fog::Logger.debug "Creating Application Gateway: #{name}..." + gateway = define_application_gateway(name, location, sku_name, sku_tier, sku_capacity, gateway_ip_configurations, ssl_certificates, frontend_ip_configurations, frontend_ports, probes, backend_address_pools, backend_http_settings_list, http_listeners, url_path_maps, request_routing_rules) + begin + promise = @network_client.application_gateways.create_or_update(resource_group, name, gateway) + result = promise.value! + Fog::Logger.debug "Application Gateway #{name} created successfully." + Azure::ARM::Network::Models::ApplicationGateway.serialize_object(result.body) + rescue MsRestAzure::AzureOperationError => e + msg = "Exception creating Application Gateway #{name} in Resource Group: #{resource_group}. #{e.body['error']['message']}" + raise msg + end + end + + private + + def define_application_gateway(name, location, sku_name, sku_tier, sku_capacity, gateway_ip_configurations, ssl_certificates, frontend_ip_configurations, frontend_ports, probes, backend_address_pools, backend_http_settings_list, http_listeners, url_path_maps, request_routing_rules) + ag_props = Azure::ARM::Network::Models::ApplicationGatewayPropertiesFormat.new + + if gateway_ip_configurations + gateway_ip_configuration_arr = define_gateway_ip_configuration(gateway_ip_configurations) + ag_props.gateway_ipconfigurations = [] + ag_props.gateway_ipconfigurations = gateway_ip_configuration_arr + end + + if ssl_certificates + ssl_certificate_arr = define_ssl_certificate(ssl_certificates) + ag_props.ssl_certificates = [] + ag_props.ssl_certificates = ssl_certificate_arr + end + + if frontend_ip_configurations + frontend_ip_configuration_arr = define_frontend_ip_configurations(frontend_ip_configurations) + ag_props.frontend_ipconfigurations = [] + ag_props.frontend_ipconfigurations = frontend_ip_configuration_arr + end + + if frontend_ports + frontend_port_arr = define_frontend_ports(frontend_ports) + ag_props.frontend_ports = [] + ag_props.frontend_ports = frontend_port_arr + end + + if probes + probe_arr = define_probes(probes) + ag_props.probes = [] + ag_props.probes = probe_arr + end + + if backend_address_pools + backend_address_pool_arr = define_backend_address_pools(backend_address_pools) + ag_props.backend_address_pools = [] + ag_props.backend_address_pools = backend_address_pool_arr + end + + if backend_http_settings_list + backend_http_setting_arr = define_backend_http_settings(backend_http_settings_list) + ag_props.backend_http_settings_collection = [] + ag_props.backend_http_settings_collection = backend_http_setting_arr + end + + if http_listeners + http_listener_arr = define_http_listeners(http_listeners) + ag_props.http_listeners = [] + ag_props.http_listeners = http_listener_arr + end + + if url_path_maps + url_path_maps_arr = define_url_path_maps(url_path_maps) + ag_props.url_path_maps = [] + ag_props.url_path_maps = url_path_maps_arr + end + + if request_routing_rules + request_routing_rule_arr = define_request_routing_rules(request_routing_rules) + ag_props.request_routing_rules = [] + ag_props.request_routing_rules = request_routing_rule_arr + end + + gateway_sku = Azure::ARM::Network::Models::ApplicationGatewaySku.new + gateway_sku.name = sku_name + gateway_sku.tier = sku_tier + gateway_sku.capacity = sku_capacity + ag_props.sku = gateway_sku + + application_gateway = Azure::ARM::Network::Models::ApplicationGateway.new + application_gateway.name = name + application_gateway.location = location + application_gateway.properties = ag_props + + application_gateway + end + + def define_gateway_ip_configuration(gateway_ip_configurations) + gateway_ip_configuration_arr = [] + gateway_ip_configurations.each do |ip_configuration| + configuration = Azure::ARM::Network::Models::ApplicationGatewayIPConfiguration.new + configuration_prop = Azure::ARM::Network::Models::ApplicationGatewayIPConfigurationPropertiesFormat.new + configuration_prop.provisioning_state = ip_configuration[:provisioning_state] + if ip_configuration[:subnet_id] + subnet = Azure::ARM::Network::Models::Subnet.new + subnet.id = ip_configuration[:subnet_id] + configuration_prop.subnet = subnet + end + + configuration.name = ip_configuration[:name] + configuration.properties = configuration_prop + gateway_ip_configuration_arr.push(configuration) + end + gateway_ip_configuration_arr + end + + def define_ssl_certificate(ssl_certificates) + ssl_certificate_arr = [] + ssl_certificates.each do |ssl_certificate| + certificate = Azure::ARM::Network::Models::ApplicationGatewaySslCertificate.new + certificate_prop = Azure::ARM::Network::Models::ApplicationGatewaySslCertificatePropertiesFormat.new + certificate_prop.data = ssl_certificate[:data] + certificate_prop.password = ssl_certificate[:password] + certificate_prop.public_cert_data = ssl_certificate[:public_cert_data] + + certificate.name = ssl_certificate[:name] + certificate.properties = certificate_prop + ssl_certificate_arr.push(ssl_certificate) + end + ssl_certificate_arr + end + + def define_frontend_ip_configurations(frontend_ip_configurations) + frontend_ip_configuration_arr = [] + frontend_ip_configurations.each do |fic| + frontend_ip_configuration = Azure::ARM::Network::Models::ApplicationGatewayFrontendIPConfiguration.new + frontend_ip_configuration_prop = Azure::ARM::Network::Models::ApplicationGatewayFrontendIPConfigurationPropertiesFormat.new + + frontend_ip_configuration_prop.private_ipaddress = fic[:private_ip_address] + frontend_ip_configuration_prop.private_ipallocation_method = fic[:private_ip_allocation_method] + + unless fic[:public_ip_address_id].nil? + pip = Azure::ARM::Network::Models::PublicIPAddress.new + pip.id = fic[:public_ip_address_id] + frontend_ip_configuration_prop.public_ipaddress = pip + end + + frontend_ip_configuration.name = fic[:name] + frontend_ip_configuration.properties = frontend_ip_configuration_prop + + frontend_ip_configuration_arr.push(frontend_ip_configuration) + end + frontend_ip_configuration_arr + end + + def define_frontend_ports(frontend_ports) + frontend_port_arr = [] + frontend_ports.each do |port| + frontend_port = Azure::ARM::Network::Models::ApplicationGatewayFrontendPort.new + frontend_port_prop = Azure::ARM::Network::Models::ApplicationGatewayFrontendPortPropertiesFormat.new + + frontend_port_prop.port = port[:port] + frontend_port.name = port[:name] + frontend_port.properties = frontend_port_prop + + frontend_port_arr.push(frontend_port) + end + frontend_port_arr + end + + def define_probes(probes) + probe_arr = [] + probes.each do |probe| + ag_probe = Azure::ARM::Network::Models::ApplicationGatewayProbe.new + ag_probe_prop = Azure::ARM::Network::Models::ApplicationGatewayProbePropertiesFormat.new + ag_probe_prop.protocol = probe[:protocol] + ag_probe_prop.host = probe[:host] + ag_probe_prop.path = probe[:path] + ag_probe_prop.interval = probe[:interval] + ag_probe_prop.timeout = probe[:timeout] + ag_probe_prop.unhealthy_threshold = probe[:unhealthy_threshold] + + ag_probe.name = probe[:name] + ag_probe.properties = ag_probe_prop + probe_arr.push(ag_probe) + end + probe_arr + end + + def define_backend_address_pools(backend_address_pools) + backend_address_pool_arr = [] + + backend_address_pools.each do |bap| + backend_pool = Azure::ARM::Network::Models::ApplicationGatewayBackendAddressPool.new + backend_pool_prop = Azure::ARM::Network::Models::ApplicationGatewayBackendAddressPoolPropertiesFormat.new + + backend_addresses1 = bap[:ip_addresses] + + addresses = [] + backend_addresses1.each do |address| + backend_add = Azure::ARM::Network::Models::ApplicationGatewayBackendAddress.new + backend_add.ip_address = address[:ipAddress] + addresses.push(backend_add) + end + backend_pool_prop.backend_addresses = addresses + + backend_pool.name = bap[:name] + backend_pool.properties = backend_pool_prop + backend_address_pool_arr.push(backend_pool) + end + backend_address_pool_arr + end + + def define_backend_http_settings(backend_http_settings_list) + backend_http_setting_arr = [] + + backend_http_settings_list.each do |http_setting| + backend_http_setting = Azure::ARM::Network::Models::ApplicationGatewayBackendHttpSettings.new + backend_http_setting_prop = Azure::ARM::Network::Models::ApplicationGatewayBackendHttpSettingsPropertiesFormat.new + backend_http_setting_prop.port = http_setting[:port] + backend_http_setting_prop.protocol = http_setting[:protocol] + backend_http_setting_prop.cookie_based_affinity = http_setting[:cookie_based_affinity] + backend_http_setting_prop.request_timeout = http_setting[:request_timeout] + if http_setting[:probe] + probe = Azure::ARM::Network::Models::Probe.new + probe.id = http_setting[:probe] + backend_http_setting_prop.probe = probe + end + + backend_http_setting.name = http_setting[:name] + backend_http_setting.properties = backend_http_setting_prop + backend_http_setting_arr.push(backend_http_setting) + end + backend_http_setting_arr + end + + def define_http_listeners(http_listeners) + http_listener_arr = [] + + http_listeners.each do |listener| + http_listener = Azure::ARM::Network::Models::ApplicationGatewayHttpListener.new + http_listener_prop = Azure::ARM::Network::Models::ApplicationGatewayHttpListenerPropertiesFormat.new + + http_listener_prop.protocol = listener[:protocol] + http_listener_prop.host_name = listener[:host_name] + http_listener_prop.require_server_name_indication = listener[:require_server_name_indication] + if listener[:frontend_ip_config_id] + frontend_ip = Azure::ARM::Network::Models::FrontendIPConfiguration.new + frontend_ip.id = listener[:frontend_ip_config_id] + http_listener_prop.frontend_ipconfiguration = frontend_ip + end + if listener[:frontend_port_id] + frontend_port = Azure::ARM::Network::Models::ApplicationGatewayFrontendPort.new + frontend_port.id = listener[:frontend_port_id] + http_listener_prop.frontend_port = frontend_port + end + if listener[:ssl_certificate_id] + ssl_cert = Azure::ARM::Network::Models::ApplicationGatewaySslCertificate.new + ssl_cert.id = listener[:ssl_certificate_id] + http_listener_prop.ssl_certificate = ssl_cert + end + + http_listener.name = listener[:name] + http_listener.properties = http_listener_prop + http_listener_arr.push(http_listener) + end + http_listener_arr + end + + def define_url_path_maps(url_path_maps) + url_path_map_arr = [] + + url_path_maps.each do |map| + url_path_map = Azure::ARM::Network::Models::ApplicationGatewayUrlPathMap.new + url_path_map_prop = Azure::ARM::Network::Models::ApplicationGatewayUrlPathMapPropertiesFormat.new + + if map[:default_backend_address_pool_id] + default_backend_address_pool = Azure::ARM::Network::Models::BackendAddressPool.new + default_backend_address_pool.id = map[:default_backend_address_pool_id] + url_path_map_prop.default_backend_address_pool = default_backend_address_pool + end + if map[:default_backend_http_settings_id] + default_backend_http_setting = Azure::ARM::Network::Models::ApplicationGatewayBackendHttpSettings.new + default_backend_http_setting.id = map[:default_backend_http_settings_id] + url_path_map_prop.default_backend_http_settings = default_backend_http_setting + end + + if map[:path_rules] + path_rules = map[:path_rules] + path_rule_arr = define_path_rules(path_rules) + url_path_map_prop.path_rules = path_rule_arr + end + + url_path_map.name = map[:name] + url_path_map.properties = url_path_map_prop + url_path_map_arr.push(url_path_map) + end + url_path_map_arr + end + + def define_path_rules(path_rules) + path_rule_arr = [] + path_rules.each do |rule| + path_rule = Azure::ARM::Network::Models::ApplicationGatewayPathRule.new + path_rule_prop = Azure::ARM::Network::Models::ApplicationGatewayPathRulePropertiesFormat.new + if rule[:backend_address_pool_id] + backend_address_pool = Azure::ARM::Network::Models::BackendAddressPool.new + backend_address_pool.id = rule[:backend_address_pool_id] + path_rule_prop.backend_address_pool = backend_address_pool + end + if rule[:backend_http_settings_id] + backend_http_setting = Azure::ARM::Network::Models::ApplicationGatewayBackendHttpSettings.new + backend_http_setting.id = rule[:backend_http_settings_id] + path_rule_prop.backend_http_settings = backend_http_setting + end + path_urls = rule[:paths] + + paths = [] + path_urls.each do |url| + paths.push(url) + end + path_rule_prop.paths = paths + + path_rule.name = rule[:name] + path_rule.properties = path_rule_prop + path_rule_arr.push(path_rule) + end + path_rule_arr + end + + def define_request_routing_rules(request_routing_rules) + request_routing_rule_arr = [] + + request_routing_rules.each do |rule| + request_routing_rule = Azure::ARM::Network::Models::ApplicationGatewayRequestRoutingRule.new + request_routing_rule_prop = Azure::ARM::Network::Models::ApplicationGatewayRequestRoutingRulePropertiesFormat.new + + request_routing_rule_prop.rule_type = rule[:type] + if rule[:http_listener_id] + http_listener = Azure::ARM::Network::Models::ApplicationGatewayHttpListener.new + http_listener.id = rule[:http_listener_id] + request_routing_rule_prop.http_listener = http_listener + end + if rule[:backend_address_pool_id] + backend_address_pool = Azure::ARM::Network::Models::BackendAddressPool.new + backend_address_pool.id = rule[:backend_address_pool_id] + request_routing_rule_prop.backend_address_pool = backend_address_pool + end + if rule[:backend_http_settings_id] + backend_http_setting = Azure::ARM::Network::Models::ApplicationGatewayBackendHttpSettings.new + backend_http_setting.id = rule[:backend_http_settings_id] + request_routing_rule_prop.backend_http_settings = backend_http_setting + end + + request_routing_rule.name = rule[:name] + request_routing_rule.properties = request_routing_rule_prop + request_routing_rule_arr.push(request_routing_rule) + end + request_routing_rule_arr + end + end + + # Mock class for Network Request + class Mock + def create_application_gateway(_name, _location, _resource_group, _sku_name, _sku_tier, _sku_capacity, _gateway_ip_configurations, _ssl_certificates, _frontend_ip_configurations, _frontend_ports, _probes, _backend_address_pools, _backend_http_settings_list, _http_listeners, _url_path_maps, _request_routing_rules) + end + end + end + end +end diff --git a/lib/fog/azurerm/requests/network/delete_application_gateway.rb b/lib/fog/azurerm/requests/network/delete_application_gateway.rb new file mode 100644 index 000000000..b002b6872 --- /dev/null +++ b/lib/fog/azurerm/requests/network/delete_application_gateway.rb @@ -0,0 +1,27 @@ +module Fog + module Network + class AzureRM + # Real class for Network Request + class Real + def delete_application_gateway(resource_group, name) + Fog::Logger.debug "Deleting Application_Gateway #{name} from Resource Group #{resource_group}." + begin + promise = @network_client.application_gateways.delete(resource_group, name) + promise.value! + Fog::Logger.debug "Application Gateway #{name} Deleted Successfully." + true + rescue MsRestAzure::AzureOperationError => e + msg = "Exception deleting Application_Gateway #{name} in Resource Group: #{resource_group}. #{e.body['error']['message']}" + raise msg + end + end + end + + # Mock class for Network Request + class Mock + def delete_application_gateway(_resource_group, _name) + end + end + end + end +end diff --git a/lib/fog/azurerm/requests/network/list_application_gateways.rb b/lib/fog/azurerm/requests/network/list_application_gateways.rb new file mode 100644 index 000000000..7996cfe78 --- /dev/null +++ b/lib/fog/azurerm/requests/network/list_application_gateways.rb @@ -0,0 +1,31 @@ +module Fog + module Network + class AzureRM + # Real class for Network Request + class Real + def list_application_gateways(resource_group) + Fog::Logger.debug "Getting list of Application-Gateway from Resource Group #{resource_group}." + begin + promise = @network_client.application_gateways.list(resource_group) + result = promise.value! + Azure::ARM::Network::Models::ApplicationGatewayListResult.serialize_object(result.body)['value'] + rescue MsRestAzure::AzureOperationError => e + msg = "Exception listing Application-Gateway from Resource Group '#{resource_group}'. #{e.body['error']['message']}." + raise msg + end + end + end + + # Mock class for Network Request + class Mock + def list_application_gateways(_resource_group) + ag = Azure::ARM::Network::Models::ApplicationGateway.new + ag.name = 'fogtestgateway' + ag.location = 'East US' + ag.properties = Azure::ARM::Network::Models::ApplicationGatewayPropertiesFormat.new + [ag] + end + end + end + end +end diff --git a/test/api_stub.rb b/test/api_stub.rb index 0e469fb4e..42734b190 100644 --- a/test/api_stub.rb +++ b/test/api_stub.rb @@ -8,6 +8,7 @@ require File.expand_path 'api_stub/models/network/network_interface', __dir__ require File.expand_path 'api_stub/models/network/load_balancer', __dir__ require File.expand_path 'api_stub/models/network/network_security_group', __dir__ +require File.expand_path 'api_stub/models/network/application_gateway', __dir__ require File.expand_path 'api_stub/models/network/traffic_manager_end_point', __dir__ require File.expand_path 'api_stub/models/network/traffic_manager_profile', __dir__ require File.expand_path 'api_stub/models/dns/zone', __dir__ @@ -23,6 +24,7 @@ require File.expand_path 'api_stub/requests/network/network_interface', __dir__ require File.expand_path 'api_stub/requests/network/load_balancer', __dir__ require File.expand_path 'api_stub/requests/network/network_security_group', __dir__ +require File.expand_path 'api_stub/requests/network/application_gateway', __dir__ require File.expand_path 'api_stub/requests/network/traffic_manager_endpoint', __dir__ require File.expand_path 'api_stub/requests/network/traffic_manager_profile', __dir__ require File.expand_path 'api_stub/requests/dns/zone', __dir__ diff --git a/test/api_stub/models/network/application_gateway.rb b/test/api_stub/models/network/application_gateway.rb new file mode 100644 index 000000000..253b2aa38 --- /dev/null +++ b/test/api_stub/models/network/application_gateway.rb @@ -0,0 +1,135 @@ +module ApiStub + module Models + module Network + class ApplicationGateway + def self.create_application_gateway_response + gateway = '{ + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/ag-demoagplat", + "name": "gateway", + "type": "Microsoft.Network/applicationGateways", + "location": "eastus", + "properties": { + "sku": { + "name": "Standard_Medium", + "tier": "Standard", + "capacity": 2 + }, + "gatewayIpConfigurations": [{ + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/gatewayIPConfigurations/ag-GatewayIP", + "properties": { + "subnet": { + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/vnet/subnets/GatewaySubnet" + }, + "provisioningState": "Succeeded" + }, + "name": "ag-GatewayIP" + }], + "sslCertificates": [{ + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/sslCertificates/ssl_certificate", + "properties": { + "publicCertData": "MIIDiDCCAnACCQCwYkR0Mxy+QTANBgkqhkiG9w0BAQUFADCBhTELMAkGA1UEBhMCUEsxDzANBgNVBAgTBlB1bmphYjEPMA0GA1UEBxMGTGFob3JlMQ8wDQYDVQQKEwZDb25maXoxDDAKBgNVBAsTA0RldjEPMA0GA1UEAxMGaGFpZGVyMSQwIgYJKoZIhvcNAQkBFhVoYWlkZXIuYWxpQGNvbmZpei5jb20wHhcNMTYwMzAyMTE0NTM2WhcNMTcwMzAyMTE0NTM2WjCBhTELMAkGA1UEBhMCUEsxDzANBgNVBAgTBlB1bmphYjEPMA0GA1UEBxMGTGFob3JlMQ8wDQYDVQQKEwZDb25maXoxDDAKBgNVBAsTA0RldjEPMA0GA1UEAxMGaGFpZGVyMSQwIgYJKoZIhvcNAQkBFhVoYWlkZXIuYWxpQGNvbmZpei5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCuJrPbvOG+4oXQRamkOALlpdK98m+atJue9zOcCCagY8IJI4quYL13d8VItmrZf7erA+siqpYlWEuk1+lmmUY7T4AWAL8mXeR2vc7hWF601WDUjeVPK19+IcC8emMLOlBpvjXC9nbvADLQuR0PGitfjCqFoG66EOqJmLDNBsyHWmy+qhb8J4WXitruNAJDPe/20h6L23vD6z4tvwBjh4zkrfskGlKCNcAuvG1NI0FAS8261Jvs3lf+8oFyI+oSXGtknrkeQv3PbXyeEe3KO5a/M61Uebo04Uwd4yCvdu6H0sF+YYA4bfFdanuFmrZvf9cZSwknQid+vOdzyGkTHTPFAgMBAAEwDQYJKoZIhvcNAQEFBQADggEBAKtPhYpfvn5OxP+BcChsWaQA4KZQj0THGdiAjHsvfjsgteFvhkzqZBkhKYtsAWV5tB5/GDl+o4c6PQJ2/TXhOJn3pSNaUzrCJIGtKS5DknbqTQxCwVlxyBtPHLAYWqKcPMlH282rw3VY0OYTL96XOgZ/WZjcN6A7ku+uWsNCql443FoWL+N3Gpaab45OyIluFUOH+yc0ToHNlP3iOpI3rVpi2xwmGrSyUKsGUma3nrBq7TWjkDE1E+oJoybaMNZzgXGIPSJC1HYIF1U8GSoFkZpAFxXecD0FinXWDRwUP6K54iti3i6a/Ox73WhwfI4mVCqsOy1WYWtKYhMVe6Kj4Nw=", + "provisioningState": "Succeeded" + }, + "name": "ssl_certificate" + }], + "frontendIpConfigurations": [{ + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/frontendIPConfigurations/frontend_ip_config", + "properties": { + "privateIPAllocationMethod": "Dynamic", + "publicIPAddress": { + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/publicIPAddresses/ag_publicip-672835" + }, + "privateIPAddress": "10.0.1.5", + "provisioningState": "Succeeded" + }, + "name": "frontend_ip_config" + }], + "frontendPorts": [{ + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/frontendPorts/gateway_front_port", + "properties": { + "port": 443, + "provisioningState": "Succeeded" + }, + "name": "gateway_front_port" + }], + "probes": [{ + "name": "", + "id": "/subscriptions//../microsoft.network/applicationGateways//probes/", + "properties": { + "protocol": "", + "host": "", + "path": "", + "interval": "", + "timeout": "", + "unhealthyThreshold": "" + } + }], + "backendAddressPools": [{ + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/backendAddressPools/AG-BackEndAddressPool", + "properties": { + "backendAddresses": [{ + "ipAddress": "10.0.0.4" + }, { + "ipAddress": "10.0.0.5" + }], + "provisioningState": "Succeeded" + }, + "name": "AG-BackEndAddressPool" + }], + "backendHttpSettingsCollection": [{ + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/backendHttpSettingsCollection/gateway_settings", + "properties": { + "port": 80, + "protocol": "Http", + "cookieBasedAffinity": "Enabled", + "requestTimeout": 30, + "provisioningState": "Succeeded" + }, + "name": "gateway_settings" + }], + "httpListeners": [{ + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/httpListeners/gateway_listener", + "properties": { + "frontendIPConfiguration": { + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/ag-demoagplat/frontendIPConfigurations/frontend_ip_config" + }, + "frontendPort": { + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/ag-demoagplat/frontendPorts/gateway_front_port" + }, + "protocol": "Https", + "sslCertificate": { + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/ag-demoagplat/sslCertificates/ssl_certificate" + }, + "requireServerNameIndication": false, + "provisioningState": "Succeeded" + }, + "name": "gateway_listener" + }], + "urlPathMaps": [], + "requestRoutingRules": [{ + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/ag-demoagplat/requestRoutingRules/gateway_request_route_rule", + "properties": { + "ruleType": "Basic", + "backendAddressPool": { + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/ag-demoagplat/backendAddressPools/AG-BackEndAddressPool" + }, + "backendHttpSettings": { + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/ag-demoagplat/backendHttpSettingsCollection/gateway_settings" + }, + "httpListener": { + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/ag-demoagplat/httpListeners/gateway_listener" + }, + "provisioningState": "Succeeded" + }, + "name": "gateway_request_route_rule" + }], + "resourceGuid": "b3db5ebf-10f8-4666-9596-d1459530f64b", + "provisioningState": "Succeeded" + } + }' + JSON.parse(gateway) + end + end + end + end +end diff --git a/test/api_stub/models/resources/resource_group.rb b/test/api_stub/models/resources/resource_group.rb index f4fbdce18..fab2591b8 100644 --- a/test/api_stub/models/resources/resource_group.rb +++ b/test/api_stub/models/resources/resource_group.rb @@ -12,7 +12,7 @@ def self.create_resource_group_response "tagname1": "tagvalue1" }, "properties": { - "provisioningState": "Succeeded" + "provisioning_state": "Succeeded" } }' JSON.load(body) @@ -27,7 +27,7 @@ def self.list_resource_groups_response "tagname1": "tagvalue1" }, "properties": { - "provisioningState": "Succeeded" + "provisioning_state": "Succeeded" } }' JSON.load(body) diff --git a/test/api_stub/requests/network/application_gateway.rb b/test/api_stub/requests/network/application_gateway.rb new file mode 100644 index 000000000..9f7c474f0 --- /dev/null +++ b/test/api_stub/requests/network/application_gateway.rb @@ -0,0 +1,433 @@ +module ApiStub + module Requests + module Network + class ApplicationGateway + def self.create_application_gateway_response + response = '{ + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway", + "name": "gateway", + "type": "Microsoft.Network/applicationGateways", + "location": "eastus", + "properties": { + "sku": { + "name": "Standard_Medium", + "tier": "Standard", + "capacity": 2 + }, + "gatewayIPConfigurations": [ + { + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/gatewayIPConfigurations/ag-GatewayIP", + "properties": { + "subnet": { + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/vnet/subnets/GatewaySubnet" + }, + "provisioningState": "Succeeded" + }, + "name": "ag-GatewayIP" + } + ], + "sslCertificates": [ + { + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/sslCertificates/ssl_certificate", + "properties": { + "publicCertData": "MIIDiDCCAnACCQCwYkR0Mxy+QTANBgkqhkiG9w0BAQUFADCBhTELMAkGA1UEBhMCUEsxDzANBgNVBAgTBlB1bmphYjEPMA0GA1UEBxMGTGFob3JlMQ8wDQYDVQQKEwZDb25maXoxDDAKBgNVBAsTA0RldjEPMA0GA1UEAxMGaGFpZGVyMSQwIgYJKoZIhvcNAQkBFhVoYWlkZXIuYWxpQGNvbmZpei5jb20wHhcNMTYwMzAyMTE0NTM2WhcNMTcwMzAyMTE0NTM2WjCBhTELMAkGA1UEBhMCUEsxDzANBgNVBAgTBlB1bmphYjEPMA0GA1UEBxMGTGFob3JlMQ8wDQYDVQQKEwZDb25maXoxDDAKBgNVBAsTA0RldjEPMA0GA1UEAxMGaGFpZGVyMSQwIgYJKoZIhvcNAQkBFhVoYWlkZXIuYWxpQGNvbmZpei5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCuJrPbvOG+4oXQRamkOALlpdK98m+atJue9zOcCCagY8IJI4quYL13d8VItmrZf7erA+siqpYlWEuk1+lmmUY7T4AWAL8mXeR2vc7hWF601WDUjeVPK19+IcC8emMLOlBpvjXC9nbvADLQuR0PGitfjCqFoG66EOqJmLDNBsyHWmy+qhb8J4WXitruNAJDPe/20h6L23vD6z4tvwBjh4zkrfskGlKCNcAuvG1NI0FAS8261Jvs3lf+8oFyI+oSXGtknrkeQv3PbXyeEe3KO5a/M61Uebo04Uwd4yCvdu6H0sF+YYA4bfFdanuFmrZvf9cZSwknQid+vOdzyGkTHTPFAgMBAAEwDQYJKoZIhvcNAQEFBQADggEBAKtPhYpfvn5OxP+BcChsWaQA4KZQj0THGdiAjHsvfjsgteFvhkzqZBkhKYtsAWV5tB5/GDl+o4c6PQJ2/TXhOJn3pSNaUzrCJIGtKS5DknbqTQxCwVlxyBtPHLAYWqKcPMlH282rw3VY0OYTL96XOgZ/WZjcN6A7ku+uWsNCql443FoWL+N3Gpaab45OyIluFUOH+yc0ToHNlP3iOpI3rVpi2xwmGrSyUKsGUma3nrBq7TWjkDE1E+oJoybaMNZzgXGIPSJC1HYIF1U8GSoFkZpAFxXecD0FinXWDRwUP6K54iti3i6a/Ox73WhwfI4mVCqsOy1WYWtKYhMVe6Kj4Nw=", + "provisioningState": "Succeeded" + }, + "name": "ssl_certificate" + } + ], + "frontendIPConfigurations": [ + { + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/frontendIPConfigurations/frontend_ip_config", + "properties": { + "privateIPAllocationMethod": "Dynamic", + "publicIPAddress": { + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/publicIPAddresses/ag_publicip-672835" + }, + "provisioningState": "Succeeded" + }, + "name": "frontend_ip_config" + } + ], + "frontendPorts": [ + { + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/frontendPorts/gateway_front_port", + "properties": { + "port": 443, + "provisioningState": "Succeeded" + }, + "name": "gateway_front_port" + } + ], + "probes": [], + "backendAddressPools": [ + { + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/backendAddressPools/AG-BackEndAddressPool", + "properties": { + "backendAddresses": [ + { + "ipAddress": "10.0.0.4" + }, + { + "ipAddress": "10.0.0.5" + } + ], + "provisioningState": "Succeeded" + }, + "name": "AG-BackEndAddressPool" + } + ], + "backendHttpSettingsCollection": [ + { + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/backendHttpSettingsCollection/gateway_settings", + "properties": { + "port": 80, + "protocol": "Http", + "cookieBasedAffinity": "Enabled", + "requestTimeout": 30, + "provisioningState": "Succeeded" + }, + "name": "gateway_settings" + } + ], + "httpListeners": [ + { + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/httpListeners/gateway_listener", + "properties": { + "frontendIPConfiguration": { + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/frontendIPConfigurations/frontend_ip_config" + }, + "frontendPort": { + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/frontendPorts/gateway_front_port" + }, + "protocol": "Https", + "sslCertificate": { + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/sslCertificates/ssl_certificate" + }, + "requireServerNameIndication": false, + "provisioningState": "Succeeded" + }, + "name": "gateway_listener" + } + ], + "urlPathMaps": [], + "requestRoutingRules": [ + { + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/requestRoutingRules/gateway_request_route_rule", + "properties": { + "ruleType": "Basic", + "backendAddressPool": { + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/backendAddressPools/AG-BackEndAddressPool" + }, + "backendHttpSettings": { + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/backendHttpSettingsCollection/gateway_settings" + }, + "httpListener": { + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/httpListeners/gateway_listener" + }, + "provisioningState": "Succeeded" + }, + "name": "gateway_request_route_rule" + } + ], + "resourceGuid": "b3db5ebf-10f8-4666-9596-d1459530f64b", + "provisioningState": "Succeeded" + } + }' + result = MsRestAzure::AzureOperationResponse.new(MsRest::HttpOperationRequest.new('', '', ''), Faraday::Response.new) + result.body = Azure::ARM::Network::Models::ApplicationGateway.deserialize_object(JSON.load(response)) + result + end + + def self.list_application_gateway_response + response = '{ + "value": [{ + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway", + "name": "gateway", + "type": "Microsoft.Network/applicationGateways", + "location": "eastus", + "properties": { + "sku": { + "name": "Standard_Medium", + "tier": "Standard", + "capacity": 2 + }, + "gatewayIPConfigurations": [ + { + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/gatewayIPConfigurations/ag-GatewayIP", + "properties": { + "subnet": { + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/vnet/subnets/GatewaySubnet" + }, + "provisioningState": "Succeeded" + }, + "name": "ag-GatewayIP" + } + ], + "sslCertificates": [ + { + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/sslCertificates/ssl_certificate", + "properties": { + "publicCertData": "MIIDiDCCAnACCQCwYkR0Mxy+QTANBgkqhkiG9w0BAQUFADCBhTELMAkGA1UEBhMCUEsxDzANBgNVBAgTBlB1bmphYjEPMA0GA1UEBxMGTGFob3JlMQ8wDQYDVQQKEwZDb25maXoxDDAKBgNVBAsTA0RldjEPMA0GA1UEAxMGaGFpZGVyMSQwIgYJKoZIhvcNAQkBFhVoYWlkZXIuYWxpQGNvbmZpei5jb20wHhcNMTYwMzAyMTE0NTM2WhcNMTcwMzAyMTE0NTM2WjCBhTELMAkGA1UEBhMCUEsxDzANBgNVBAgTBlB1bmphYjEPMA0GA1UEBxMGTGFob3JlMQ8wDQYDVQQKEwZDb25maXoxDDAKBgNVBAsTA0RldjEPMA0GA1UEAxMGaGFpZGVyMSQwIgYJKoZIhvcNAQkBFhVoYWlkZXIuYWxpQGNvbmZpei5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCuJrPbvOG+4oXQRamkOALlpdK98m+atJue9zOcCCagY8IJI4quYL13d8VItmrZf7erA+siqpYlWEuk1+lmmUY7T4AWAL8mXeR2vc7hWF601WDUjeVPK19+IcC8emMLOlBpvjXC9nbvADLQuR0PGitfjCqFoG66EOqJmLDNBsyHWmy+qhb8J4WXitruNAJDPe/20h6L23vD6z4tvwBjh4zkrfskGlKCNcAuvG1NI0FAS8261Jvs3lf+8oFyI+oSXGtknrkeQv3PbXyeEe3KO5a/M61Uebo04Uwd4yCvdu6H0sF+YYA4bfFdanuFmrZvf9cZSwknQid+vOdzyGkTHTPFAgMBAAEwDQYJKoZIhvcNAQEFBQADggEBAKtPhYpfvn5OxP+BcChsWaQA4KZQj0THGdiAjHsvfjsgteFvhkzqZBkhKYtsAWV5tB5/GDl+o4c6PQJ2/TXhOJn3pSNaUzrCJIGtKS5DknbqTQxCwVlxyBtPHLAYWqKcPMlH282rw3VY0OYTL96XOgZ/WZjcN6A7ku+uWsNCql443FoWL+N3Gpaab45OyIluFUOH+yc0ToHNlP3iOpI3rVpi2xwmGrSyUKsGUma3nrBq7TWjkDE1E+oJoybaMNZzgXGIPSJC1HYIF1U8GSoFkZpAFxXecD0FinXWDRwUP6K54iti3i6a/Ox73WhwfI4mVCqsOy1WYWtKYhMVe6Kj4Nw=", + "provisioningState": "Succeeded" + }, + "name": "ssl_certificate" + } + ], + "frontendIPConfigurations": [ + { + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/frontendIPConfigurations/frontend_ip_config", + "properties": { + "privateIPAllocationMethod": "Dynamic", + "publicIPAddress": { + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/publicIPAddresses/ag_publicip-672835" + }, + "provisioningState": "Succeeded" + }, + "name": "frontend_ip_config" + } + ], + "frontendPorts": [ + { + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/frontendPorts/gateway_front_port", + "properties": { + "port": 443, + "provisioningState": "Succeeded" + }, + "name": "gateway_front_port" + } + ], + "probes": [], + "backendAddressPools": [ + { + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/backendAddressPools/AG-BackEndAddressPool", + "properties": { + "backendAddresses": [ + { + "ipAddress": "10.0.0.4" + }, + { + "ipAddress": "10.0.0.5" + } + ], + "provisioningState": "Succeeded" + }, + "name": "AG-BackEndAddressPool" + } + ], + "backendHttpSettingsCollection": [ + { + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/backendHttpSettingsCollection/gateway_settings", + "properties": { + "port": 80, + "protocol": "Http", + "cookieBasedAffinity": "Enabled", + "requestTimeout": 30, + "provisioningState": "Succeeded" + }, + "name": "gateway_settings" + } + ], + "httpListeners": [ + { + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/httpListeners/gateway_listener", + "properties": { + "frontendIPConfiguration": { + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/frontendIPConfigurations/frontend_ip_config" + }, + "frontendPort": { + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/frontendPorts/gateway_front_port" + }, + "protocol": "Https", + "sslCertificate": { + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/sslCertificates/ssl_certificate" + }, + "requireServerNameIndication": false, + "provisioningState": "Succeeded" + }, + "name": "gateway_listener" + } + ], + "urlPathMaps": [], + "requestRoutingRules": [ + { + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/requestRoutingRules/gateway_request_route_rule", + "properties": { + "ruleType": "Basic", + "backendAddressPool": { + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/backendAddressPools/AG-BackEndAddressPool" + }, + "backendHttpSettings": { + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/backendHttpSettingsCollection/gateway_settings" + }, + "httpListener": { + "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/httpListeners/gateway_listener" + }, + "provisioningState": "Succeeded" + }, + "name": "gateway_request_route_rule" + } + ], + "resourceGuid": "b3db5ebf-10f8-4666-9596-d1459530f64b", + "provisioningState": "Succeeded" + } + }] +}' + result = MsRestAzure::AzureOperationResponse.new(MsRest::HttpOperationRequest.new('', '', ''), Faraday::Response.new) + result.body = Azure::ARM::Network::Models::ApplicationGatewayListResult.deserialize_object(JSON.load(response)) + result + end + + def self.delete_application_gateway_response + MsRestAzure::AzureOperationResponse.new(MsRest::HttpOperationRequest.new('', '', ''), Faraday::Response.new) + end + + def self.gateway_ip_configurations + gateway_ip_config = + [ + { + name: 'gatewayIpConfigName', + subnet_id: '/subscriptions/{guid}/resourcegroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/vnet/subnets/subnetName' + } + ] + gateway_ip_config + end + + def self.ssl_certificates + certificates = + [ + { + name: 'certificate', + data: 'data', + password: '123', + public_cert_data: 'MIIDiDCCAnACCQCwYkR0Mxy+QTANBgkqhkiG9w0BAQUFADCBhTELMAkGA1UEBhMCUEsxDzANBgNVBAgTBlB1bmphYjEPMA0GA1UEBxMGTGFob3JlMQ8wDQYDVQQKEwZDb25maXoxDDAKBgNVBAsTA0RldjEPMA0GA1UEAxMGaGFpZGVyMSQwIgYJKoZIhvcNAQkBFhVoYWlkZXIuYWxpQGNvbmZpei5jb20wHhcNMTYwMzAyMTE0NTM2WhcNMTcwMzAyMTE0NTM2WjCBhTELMAkGA1UEBhMCUEsxDzANBgNVBAgTBlB1bmphYjEPMA0GA1UEBxMGTGFob3JlMQ8wDQYDVQQKEwZDb25maXoxDDAKBgNVBAsTA0RldjEPMA0GA1UEAxMGaGFpZGVyMSQwIgYJKoZIhvcNAQkBFhVoYWlkZXIuYWxpQGNvbmZpei5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCuJrPbvOG+4oXQRamkOALlpdK98m+atJue9zOcCCagY8IJI4quYL13d8VItmrZf7erA+siqpYlWEuk1+lmmUY7T4AWAL8mXeR2vc7hWF601WDUjeVPK19+IcC8emMLOlBpvjXC9nbvADLQuR0PGitfjCqFoG66EOqJmLDNBsyHWmy+qhb8J4WXitruNAJDPe/20h6L23vD6z4tvwBjh4zkrfskGlKCNcAuvG1NI0FAS8261Jvs3lf+8oFyI+oSXGtknrkeQv3PbXyeEe3KO5a/M61Uebo04Uwd4yCvdu6H0sF+YYA4bfFdanuFmrZvf9cZSwknQid+vOdzyGkTHTPFAgMBAAEwDQYJKoZIhvcNAQEFBQADggEBAKtPhYpfvn5OxP+BcChsWaQA4KZQj0THGdiAjHsvfjsgteFvhkzqZBkhKYtsAWV5tB5/GDl+o4c6PQJ2/TXhOJn3pSNaUzrCJIGtKS5DknbqTQxCwVlxyBtPHLAYWqKcPMlH282rw3VY0OYTL96XOgZ/WZjcN6A7ku+uWsNCql443FoWL+N3Gpaab45OyIluFUOH+yc0ToHNlP3iOpI3rVpi2xwmGrSyUKsGUma3nrBq7TWjkDE1E+oJoybaMNZzgXGIPSJC1HYIF1U8GSoFkZpAFxXecD0FinXWDRwUP6K54iti3i6a/Ox73WhwfI4mVCqsOy1WYWtKYhMVe6Kj4Nw=' + } + ] + certificates + end + + def self.frontend_ip_configurations + frontend_ip_config = + [ + { + name: 'frontendIpConfig', + private_ip_allocation_method: 'Dynamic', + public_ip_address_id: '/subscriptions/{guid}/resourcegroups/{resourceGroupName}/providers/Microsoft.Network/publicIPAddresses/publicIp', + private_ip_address: '10.0.1.5' + } + ] + frontend_ip_config + end + + def self.frontend_ports + ports = + [ + { + name: 'frontendPort', + port: 443 + } + ] + ports + end + + def self.probes + probes = + [ + { + name: 'probe1', + protocol: 'tcp', + host: 'localhost', + path: '/usr/', + interval: 30, + timeout: 20, + unhealthy_threshold: 20 + } + ] + probes + end + + def self.backend_address_pools + address_pool = + [ + { + name: 'backendAddressPool', + ip_addresses: [ + { + ipAddress: '10.0.1.6' + } + ] + } + ] + address_pool + end + + def self.backend_http_settings_list + http_setting = + [ + { + name: 'gateway_settings', + port: 80, + protocol: 'Http', + cookie_based_affinity: 'Enabled', + request_timeout: '30', + probe: '' + } + ] + http_setting + end + + def self.http_listeners + listener = + [ + { + name: 'gateway_listener', + frontend_ip_config_id: '/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/frontendIPConfigurations/frontend_ip_config', + frontend_port_id: '/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/frontendPorts/gateway_front_port', + protocol: 'Https', + host_name: '', + ssl_certificate_id: '/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/sslCertificates/ssl_certificate', + require_server_name_indication: 'false' + } + ] + listener + end + + def self.url_path_maps + path_map = + [ + { + name: 'map1', + default_backend_address_pool_id: '/subscriptions/########-####-####-####-############/resourceGroups/fogRM-rg/providers/Microsoft.Network/applicationGateways/gateway/backendAddressPools/AG-BackEndAddressPool', + default_backend_http_settings_id: '/subscriptions/########-####-####-####-############/resourceGroups/fogRM-rg/providers/Microsoft.Network/applicationGateways/gateway/backendHttpSettingsCollection/gateway_settings', + path_rules: [ + { + backend_address_pool_id: '/subscriptions/########-####-####-####-############/resourceGroups/fogRM-rg/providers/Microsoft.Network/applicationGateways/gateway/backendAddressPools/AG-BackEndAddressPool', + backend_http_settings_id: '/subscriptions/########-####-####-####-############/resourceGroups/fogRM-rg/providers/Microsoft.Network/applicationGateways/gateway/backendHttpSettingsCollection/gateway_settings', + paths: [ + %w('/usr', '/etc') + ] + } + ] + } + ] + path_map + end + + def self.request_routing_rules + routing_rule = + [ + { + name: 'gateway_request_route_rule', + type: 'Basic', + http_listener_id: '/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/httpListeners/gateway_listener', + backend_address_pool_id: '/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/backendAddressPools/AG-BackEndAddressPool', + backend_http_settings_id: '/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/backendHttpSettingsCollection/gateway_settings', + url_path_map: '' + } + ] + routing_rule + end + end + end + end +end diff --git a/test/api_stub/requests/network/network_interface.rb b/test/api_stub/requests/network/network_interface.rb index 4f586d1f9..af8413d5f 100644 --- a/test/api_stub/requests/network/network_interface.rb +++ b/test/api_stub/requests/network/network_interface.rb @@ -79,7 +79,7 @@ def self.list_network_interfaces_response }, "etag":"W/\"00000000-0000-0000-0000-000000000000\"", "properties":{ - "resourceGuid":"5ED47B81-9F1C-4ACE-97A5-7B8CE08C5002", + "resourceGuid":"5ED47B81-9F1C-4ACE-97A5-7B8CE08C5002", "provisioningState":"Succeeded", "virtualMachine":{ "id":"/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/vm1" diff --git a/test/api_stub/requests/resources/resource_group.rb b/test/api_stub/requests/resources/resource_group.rb index 246a6766c..48b971cff 100644 --- a/test/api_stub/requests/resources/resource_group.rb +++ b/test/api_stub/requests/resources/resource_group.rb @@ -12,7 +12,7 @@ def self.create_resource_group_response "tagname1": "tagvalue1" }, "properties": { - "provisioningState": "Succeeded" + "provisioning_state": "Succeeded" } }' result = MsRestAzure::AzureOperationResponse.new(MsRest::HttpOperationRequest.new('', '', ''), Faraday::Response.new) @@ -30,7 +30,7 @@ def self.list_resource_group_response "tagname1": "tagvalue1" }, "properties": { - "provisioningState": "Succeeded" + "provisioning_state": "Succeeded" } } ], "nextLink": "https://management.azure.com/subscriptions/########-####-####-####-############/resourcegroups?api-version=2015-01-01&$skiptoken=######" diff --git a/test/models/network/test_application_gateway.rb b/test/models/network/test_application_gateway.rb new file mode 100644 index 000000000..7706838b0 --- /dev/null +++ b/test/models/network/test_application_gateway.rb @@ -0,0 +1,61 @@ +require File.expand_path '../../test_helper', __dir__ + +class TestApplicationGateway < Minitest::Test + def setup + @service = Fog::Network::AzureRM.new(credentials) + @gateway = application_gateway(@service) + end + + def test_model_methods + response = ApiStub::Models::Network::ApplicationGateway.create_application_gateway_response + methods = [ + :save, + :destroy + ] + @service.stub :create_application_gateway, response do + methods.each do |method| + assert @gateway.respond_to? method + end + end + end + + def test_model_attributes + response = ApiStub::Models::Network::ApplicationGateway.create_application_gateway_response + attributes = [ + :name, + :location, + :resource_group, + :sku_name, + :sku_tier, + :sku_capacity, + :gateway_ip_configurations, + :ssl_certificates, + :frontend_ip_configurations, + :frontend_ports, + :probes, + :backend_address_pools, + :backend_http_settings_list, + :http_listeners, + :url_path_maps, + :request_routing_rules + ] + @service.stub :create_application_gateway, response do + attributes.each do |attribute| + assert @gateway.respond_to? attribute + end + end + end + + def test_save_method_response + response = ApiStub::Models::Network::ApplicationGateway.create_application_gateway_response + @service.stub :create_application_gateway, response do + assert_instance_of Fog::Network::AzureRM::ApplicationGateway, @gateway.save + end + end + + def test_destroy_method_response + @service.stub :delete_application_gateway, true do + assert @gateway.destroy + end + end +end diff --git a/test/models/network/test_application_gateways.rb b/test/models/network/test_application_gateways.rb new file mode 100644 index 000000000..f91529a67 --- /dev/null +++ b/test/models/network/test_application_gateways.rb @@ -0,0 +1,41 @@ +require File.expand_path '../../test_helper', __dir__ + +class TestApplicationGateways < Minitest::Test + def setup + @service = Fog::Network::AzureRM.new(credentials) + @gateways = Fog::Network::AzureRM::ApplicationGateways.new(resource_group: 'fog-test-rg', service: @service) + end + + def test_collection_methods + methods = [ + :all, + :get + ] + methods.each do |method| + assert @gateways.respond_to? method + end + end + + def test_collection_attributes + assert @gateways.respond_to? :resource_group + end + + def test_all_method_response + response = [ApiStub::Models::Network::ApplicationGateway.create_application_gateway_response] + @service.stub :list_application_gateways, response do + assert_instance_of Fog::Network::AzureRM::ApplicationGateways, @gateways.all + assert @gateways.all.size >= 1 + @gateways.all.each do |application_gateway| + assert_instance_of Fog::Network::AzureRM::ApplicationGateway, application_gateway + end + end + end + + def test_get_method_response + response = [ApiStub::Models::Network::ApplicationGateway.create_application_gateway_response] + @service.stub :list_application_gateways, response do + assert_instance_of Fog::Network::AzureRM::ApplicationGateway, @gateways.get('gateway') + assert @gateways.get('wrong-name').nil?, true + end + end +end diff --git a/test/requests/network/test_create_application_gateway.rb b/test/requests/network/test_create_application_gateway.rb new file mode 100644 index 000000000..19d833b8d --- /dev/null +++ b/test/requests/network/test_create_application_gateway.rb @@ -0,0 +1,61 @@ +require File.expand_path '../../test_helper', __dir__ + +# Test class for Create Application Gateway Request +class TestCreateApplicationGateway < Minitest::Test + def setup + @service = Fog::Network::AzureRM.new(credentials) + client = @service.instance_variable_get(:@network_client) + @gateways = client.application_gateways + @promise = Concurrent::Promise.execute do + end + end + + def test_create_application_gateway_success + mocked_response = ApiStub::Requests::Network::ApplicationGateway.create_application_gateway_response + expected_response = Azure::ARM::Network::Models::ApplicationGateway.serialize_object(mocked_response.body) + @promise.stub :value!, mocked_response do + gateway_ip_configurations = ApiStub::Requests::Network::ApplicationGateway.gateway_ip_configurations + frontend_ip_configurations = ApiStub::Requests::Network::ApplicationGateway.frontend_ip_configurations + frontend_ports = ApiStub::Requests::Network::ApplicationGateway.frontend_ports + backend_address_pools = ApiStub::Requests::Network::ApplicationGateway.backend_address_pools + backend_http_settings_list = ApiStub::Requests::Network::ApplicationGateway.backend_http_settings_list + http_listeners = ApiStub::Requests::Network::ApplicationGateway.http_listeners + request_routing_rules = ApiStub::Requests::Network::ApplicationGateway.request_routing_rules + @gateways.stub :create_or_update, @promise do + assert_equal @service.create_application_gateway('gateway', 'East US', 'fogRM-rg', 'Standard_Medium', 'Standard', 2, gateway_ip_configurations, nil, frontend_ip_configurations, frontend_ports, nil, backend_address_pools, backend_http_settings_list, http_listeners, nil, request_routing_rules), expected_response + end + end + end + + def test_create_application_gateway_argument_error_failure + response = ApiStub::Requests::Network::ApplicationGateway.create_application_gateway_response + @promise.stub :value!, response do + @gateways.stub :create_or_update, @promise do + assert_raises ArgumentError do + @service.create_application_gateway('gateway', 'East US', 'fogRM-rg', 'Standard_Medium', 'Standard', 2) + end + end + end + end + + def test_create_application_gateway_exception_failure + response = -> { fail MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception' }) } + @promise.stub :value!, response do + gateway_ip_configurations = ApiStub::Requests::Network::ApplicationGateway.gateway_ip_configurations + ssl_certificates = ApiStub::Requests::Network::ApplicationGateway.ssl_certificates + frontend_ip_configurations = ApiStub::Requests::Network::ApplicationGateway.frontend_ip_configurations + frontend_ports = ApiStub::Requests::Network::ApplicationGateway.frontend_ports + probes = ApiStub::Requests::Network::ApplicationGateway.probes + backend_address_pools = ApiStub::Requests::Network::ApplicationGateway.backend_address_pools + backend_http_settings_list = ApiStub::Requests::Network::ApplicationGateway.backend_http_settings_list + http_listeners = ApiStub::Requests::Network::ApplicationGateway.http_listeners + url_path_paths = ApiStub::Requests::Network::ApplicationGateway.url_path_maps + request_routing_rules = ApiStub::Requests::Network::ApplicationGateway.request_routing_rules + @gateways.stub :create_or_update, @promise do + assert_raises RuntimeError do + @service.create_application_gateway('gateway', 'East US', 'fogRM-rg', 'Standard_Medium', 'Standard', 2, gateway_ip_configurations, ssl_certificates, frontend_ip_configurations, frontend_ports, probes, backend_address_pools, backend_http_settings_list, http_listeners, url_path_paths, request_routing_rules) + end + end + end + end +end diff --git a/test/requests/network/test_delete_application_gateway.rb b/test/requests/network/test_delete_application_gateway.rb new file mode 100644 index 000000000..db741c97c --- /dev/null +++ b/test/requests/network/test_delete_application_gateway.rb @@ -0,0 +1,30 @@ +require File.expand_path '../../test_helper', __dir__ + +# Test class for Delete Application Gateway Request +class TestDeleteApplicationGateway < Minitest::Test + def setup + @service = Fog::Network::AzureRM.new(credentials) + client = @service.instance_variable_get(:@network_client) + @gateways = client.application_gateways + @promise = Concurrent::Promise.execute do + end + end + + def test_delete_application_gateway_success + response = true + @promise.stub :value!, response do + @gateways.stub :delete, @promise do + assert @service.delete_application_gateway('fogRM-rg', 'gateway'), response + end + end + end + + def test_delete_application_gateway_failure + response = -> { fail MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception' }) } + @promise.stub :value!, response do + @gateways.stub :delete, @promise do + assert_raises(RuntimeError) { @service.delete_application_gateway('fogRM-rg', 'gateway') } + end + end + end +end diff --git a/test/requests/network/test_list_application_gateways.rb b/test/requests/network/test_list_application_gateways.rb new file mode 100644 index 000000000..5d40dbaea --- /dev/null +++ b/test/requests/network/test_list_application_gateways.rb @@ -0,0 +1,31 @@ +require File.expand_path '../../test_helper', __dir__ + +# Test class for List Application Gateway Request +class TestListApplicationGateways < Minitest::Test + def setup + @service = Fog::Network::AzureRM.new(credentials) + client = @service.instance_variable_get(:@network_client) + @gateways = client.application_gateways + @promise = Concurrent::Promise.execute do + end + end + + def test_list_application_gateways_success + mocked_response = ApiStub::Requests::Network::ApplicationGateway.list_application_gateway_response + expected_response = Azure::ARM::Network::Models::ApplicationGatewayListResult.serialize_object(mocked_response.body) + @promise.stub :value!, mocked_response do + @gateways.stub :list, @promise do + assert_equal @service.list_application_gateways('fogRM-rg'), expected_response['value'] + end + end + end + + def test_list_application_gateways_failure + response = -> { fail MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception' }) } + @promise.stub :value!, response do + @gateways.stub :list, @promise do + assert_raises(RuntimeError) { @service.list_application_gateways('fogRM-rg') } + end + end + end +end diff --git a/test/test_helper.rb b/test/test_helper.rb index b7cd49d23..52a52e3c3 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -246,6 +246,124 @@ def network_security_rule(service) ) end +def application_gateway(service) + Fog::Network::AzureRM::ApplicationGateway.new( + name: 'gateway', + location: 'eastus', + resource_group: 'fogRM-rg', + sku_name: 'Standard_Medium', + sku_tier: 'Standard', + sku_capacity: '2', + gateway_ip_configurations: + [ + { + name: 'gatewayIpConfigName', + subnet_id: '/subscriptions/########-####-####-####-############/resourcegroups/fogRM-rg/providers/Microsoft.Network/virtualNetworks/vnet/subnets/subnetName' + } + ], + ssl_certificates: + [ + { + name: 'certificate', + data: 'data', + password: '123', + public_cert_data: 'MIIDiDCCAnACCQCwYkR0Mxy+QTANBgkqhkiG9w0BAQUFADCBhTELMAkGA1UEBhMCUEsxDzANBgNVBAgTBlB1bmphYjEPMA0GA1UEBxMGTGFob3JlMQ8wDQYDVQQKEwZDb25maXoxDDAKBgNVBAsTA0RldjEPMA0GA1UEAxMGaGFpZGVyMSQwIgYJKoZIhvcNAQkBFhVoYWlkZXIuYWxpQGNvbmZpei5jb20wHhcNMTYwMzAyMTE0NTM2WhcNMTcwMzAyMTE0NTM2WjCBhTELMAkGA1UEBhMCUEsxDzANBgNVBAgTBlB1bmphYjEPMA0GA1UEBxMGTGFob3JlMQ8wDQYDVQQKEwZDb25maXoxDDAKBgNVBAsTA0RldjEPMA0GA1UEAxMGaGFpZGVyMSQwIgYJKoZIhvcNAQkBFhVoYWlkZXIuYWxpQGNvbmZpei5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCuJrPbvOG+4oXQRamkOALlpdK98m+atJue9zOcCCagY8IJI4quYL13d8VItmrZf7erA+siqpYlWEuk1+lmmUY7T4AWAL8mXeR2vc7hWF601WDUjeVPK19+IcC8emMLOlBpvjXC9nbvADLQuR0PGitfjCqFoG66EOqJmLDNBsyHWmy+qhb8J4WXitruNAJDPe/20h6L23vD6z4tvwBjh4zkrfskGlKCNcAuvG1NI0FAS8261Jvs3lf+8oFyI+oSXGtknrkeQv3PbXyeEe3KO5a/M61Uebo04Uwd4yCvdu6H0sF+YYA4bfFdanuFmrZvf9cZSwknQid+vOdzyGkTHTPFAgMBAAEwDQYJKoZIhvcNAQEFBQADggEBAKtPhYpfvn5OxP+BcChsWaQA4KZQj0THGdiAjHsvfjsgteFvhkzqZBkhKYtsAWV5tB5/GDl+o4c6PQJ2/TXhOJn3pSNaUzrCJIGtKS5DknbqTQxCwVlxyBtPHLAYWqKcPMlH282rw3VY0OYTL96XOgZ/WZjcN6A7ku+uWsNCql443FoWL+N3Gpaab45OyIluFUOH+yc0ToHNlP3iOpI3rVpi2xwmGrSyUKsGUma3nrBq7TWjkDE1E+oJoybaMNZzgXGIPSJC1HYIF1U8GSoFkZpAFxXecD0FinXWDRwUP6K54iti3i6a/Ox73WhwfI4mVCqsOy1WYWtKYhMVe6Kj4Nw=' + } + ], + frontend_ip_configurations: + [ + { + name: 'frontendIpConfig', + private_ip_allocation_method: 'Dynamic', + public_ip_address_id: '/subscriptions/########-####-####-####-############/resourcegroups/fogRM-rg/providers/Microsoft.Network/publicIPAddresses/publicIp', + private_ip_address: '10.0.1.5' + } + ], + frontend_ports: + [ + { + name: 'frontendPort', + port: 443 + } + ], + probes: + [ + { + name: 'probe1', + protocol: 'tcp', + host: 'localhost', + path: '/usr/', + interval: 30, + timeout: 20, + unhealthy_threshold: 20 + } + ], + backend_address_pools: + [ + { + name: 'backendAddressPool', + ip_addresses: [ + { + ipAddress: '10.0.1.6' + } + ] + } + ], + backend_http_settings_list: + [ + { + name: 'gateway_settings', + port: 80, + protocol: 'Http', + cookie_based_affinity: 'Enabled', + request_timeout: '30', + probe: '' + } + ], + http_listeners: + [ + { + name: 'gateway_listener', + frontend_ip_config_id: '/subscriptions/########-####-####-####-############/resourceGroups/fogRM-rg/providers/Microsoft.Network/applicationGateways/gateway/frontendIPConfigurations/frontend_ip_config', + frontend_port_id: '/subscriptions/########-####-####-####-############/resourceGroups/fogRM-rg/providers/Microsoft.Network/applicationGateways/gateway/frontendPorts/gateway_front_port', + protocol: 'Https', + host_name: '', + ssl_certificate_id: '/subscriptions/########-####-####-####-############/resourceGroups/fogRM-rg/providers/Microsoft.Network/applicationGateways/gateway/sslCertificates/ssl_certificate', + require_server_name_indication: 'false' + } + ], + url_path_maps: + [ + { + name: 'map1', + default_backend_address_pool_id: '/subscriptions/########-####-####-####-############/resourceGroups/fogRM-rg/providers/Microsoft.Network/applicationGateways/gateway/backendAddressPools/AG-BackEndAddressPool', + default_backend_http_settings_id: '/subscriptions/########-####-####-####-############/resourceGroups/fogRM-rg/providers/Microsoft.Network/applicationGateways/gateway/backendHttpSettingsCollection/gateway_settings', + path_rules: [ + { + backend_address_pool_id: '/subscriptions/########-####-####-####-############/resourceGroups/fogRM-rg/providers/Microsoft.Network/applicationGateways/gateway/backendAddressPools/AG-BackEndAddressPool', + backend_http_settings_id: '/subscriptions/########-####-####-####-############/resourceGroups/fogRM-rg/providers/Microsoft.Network/applicationGateways/gateway/backendHttpSettingsCollection/gateway_settings', + paths: [ + %w'/usr','/etc' + ] + } + ] + } + ], + request_routing_rules: + [ + { + name: 'gateway_request_route_rule', + type: 'Basic', + http_listener_id: '/subscriptions/########-####-####-####-############/resourceGroups/fogRM-rg/providers/Microsoft.Network/applicationGateways/gateway/httpListeners/gateway_listener', + backend_address_pool_id: '/subscriptions/########-####-####-####-############/resourceGroups/fogRM-rg/providers/Microsoft.Network/applicationGateways/gateway/backendAddressPools/AG-BackEndAddressPool', + backend_http_settings_id: '/subscriptions/########-####-####-####-############/resourceGroups/fogRM-rg/providers/Microsoft.Network/applicationGateways/gateway/backendHttpSettingsCollection/gateway_settings', + url_path_map: '' + } + ], + service: service + ) +end + def traffic_manager_end_point(service) Fog::Network::AzureRM::TrafficManagerEndPoint.new( name: 'fog-test-end-point',