azure_mgmt_network 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (185) hide show
  1. checksums.yaml +4 -4
  2. data/azure_mgmt_network.gemspec +4 -9
  3. data/lib/azure_mgmt_network.rb +100 -39
  4. data/lib/azure_mgmt_network/application_gateways.rb +175 -401
  5. data/lib/azure_mgmt_network/express_route_circuit_authorizations.rb +429 -0
  6. data/lib/azure_mgmt_network/express_route_circuit_peerings.rb +427 -0
  7. data/lib/azure_mgmt_network/express_route_circuits.rb +911 -0
  8. data/lib/azure_mgmt_network/express_route_service_providers.rb +149 -0
  9. data/lib/azure_mgmt_network/load_balancers.rb +139 -314
  10. data/lib/azure_mgmt_network/local_network_gateways.rb +102 -228
  11. data/lib/azure_mgmt_network/models/address_space.rb +1 -3
  12. data/lib/azure_mgmt_network/models/application_gateway.rb +7 -9
  13. data/lib/azure_mgmt_network/models/application_gateway_backend_address.rb +1 -3
  14. data/lib/azure_mgmt_network/models/application_gateway_backend_address_pool.rb +1 -3
  15. data/lib/azure_mgmt_network/models/application_gateway_backend_address_pool_properties_format.rb +16 -18
  16. data/lib/azure_mgmt_network/models/application_gateway_backend_http_settings.rb +1 -3
  17. data/lib/azure_mgmt_network/models/application_gateway_backend_http_settings_properties_format.rb +32 -8
  18. data/lib/azure_mgmt_network/models/application_gateway_cookie_based_affinity.rb +1 -1
  19. data/lib/azure_mgmt_network/models/{application_gateway_frontend_ip_configuration.rb → application_gateway_frontend_ipconfiguration.rb} +7 -9
  20. data/lib/azure_mgmt_network/models/{application_gateway_frontend_ip_configuration_properties_format.rb → application_gateway_frontend_ipconfiguration_properties_format.rb} +12 -15
  21. data/lib/azure_mgmt_network/models/application_gateway_frontend_port.rb +1 -3
  22. data/lib/azure_mgmt_network/models/application_gateway_frontend_port_properties_format.rb +1 -3
  23. data/lib/azure_mgmt_network/models/application_gateway_http_listener.rb +1 -3
  24. data/lib/azure_mgmt_network/models/application_gateway_http_listener_properties_format.rb +34 -17
  25. data/lib/azure_mgmt_network/models/{application_gateway_ip_configuration.rb → application_gateway_ipconfiguration.rb} +7 -9
  26. data/lib/azure_mgmt_network/models/{application_gateway_ip_configuration_properties_format.rb → application_gateway_ipconfiguration_properties_format.rb} +6 -8
  27. data/lib/azure_mgmt_network/models/application_gateway_list_result.rb +4 -6
  28. data/lib/azure_mgmt_network/models/application_gateway_operational_state.rb +1 -1
  29. data/lib/azure_mgmt_network/models/application_gateway_path_rule.rb +88 -0
  30. data/lib/azure_mgmt_network/models/application_gateway_path_rule_properties_format.rb +101 -0
  31. data/lib/azure_mgmt_network/models/application_gateway_probe.rb +88 -0
  32. data/lib/azure_mgmt_network/models/application_gateway_probe_properties_format.rb +118 -0
  33. data/lib/azure_mgmt_network/models/application_gateway_properties_format.rb +151 -81
  34. data/lib/azure_mgmt_network/models/application_gateway_protocol.rb +1 -1
  35. data/lib/azure_mgmt_network/models/application_gateway_request_routing_rule.rb +1 -3
  36. data/lib/azure_mgmt_network/models/application_gateway_request_routing_rule_properties_format.rb +26 -11
  37. data/lib/azure_mgmt_network/models/application_gateway_request_routing_rule_type.rb +2 -1
  38. data/lib/azure_mgmt_network/models/application_gateway_sku.rb +6 -8
  39. data/lib/azure_mgmt_network/models/application_gateway_sku_name.rb +1 -1
  40. data/lib/azure_mgmt_network/models/application_gateway_ssl_certificate.rb +1 -3
  41. data/lib/azure_mgmt_network/models/application_gateway_ssl_certificate_properties_format.rb +1 -3
  42. data/lib/azure_mgmt_network/models/application_gateway_tier.rb +1 -1
  43. data/lib/azure_mgmt_network/models/application_gateway_url_path_map.rb +88 -0
  44. data/lib/azure_mgmt_network/models/application_gateway_url_path_map_properties_format.rb +122 -0
  45. data/lib/azure_mgmt_network/models/authorization_list_result.rb +87 -0
  46. data/lib/azure_mgmt_network/models/authorization_properties_format.rb +79 -0
  47. data/lib/azure_mgmt_network/models/authorization_use_status.rb +16 -0
  48. data/lib/azure_mgmt_network/models/azure_async_operation_result.rb +5 -7
  49. data/lib/azure_mgmt_network/models/backend_address_pool.rb +1 -3
  50. data/lib/azure_mgmt_network/models/backend_address_pool_properties_format.rb +30 -15
  51. data/lib/azure_mgmt_network/models/connection_reset_shared_key.rb +10 -16
  52. data/lib/azure_mgmt_network/models/connection_shared_key.rb +1 -3
  53. data/lib/azure_mgmt_network/models/{connection_reset_shared_key_properties_format.rb → connection_shared_key_result.rb} +11 -15
  54. data/lib/azure_mgmt_network/models/dhcp_options.rb +1 -3
  55. data/lib/azure_mgmt_network/models/dns_name_availability_result.rb +1 -3
  56. data/lib/azure_mgmt_network/models/error.rb +4 -6
  57. data/lib/azure_mgmt_network/models/error_details.rb +1 -3
  58. data/lib/azure_mgmt_network/models/express_route_circuit.rb +118 -0
  59. data/lib/azure_mgmt_network/models/express_route_circuit_arp_table.rb +65 -0
  60. data/lib/azure_mgmt_network/models/express_route_circuit_authorization.rb +88 -0
  61. data/lib/azure_mgmt_network/models/express_route_circuit_list_result.rb +86 -0
  62. data/lib/azure_mgmt_network/models/express_route_circuit_peering.rb +88 -0
  63. data/lib/azure_mgmt_network/models/express_route_circuit_peering_advertised_public_prefix_state.rb +18 -0
  64. data/lib/azure_mgmt_network/models/express_route_circuit_peering_config.rb +92 -0
  65. data/lib/azure_mgmt_network/models/express_route_circuit_peering_list_result.rb +87 -0
  66. data/lib/azure_mgmt_network/models/express_route_circuit_peering_properties_format.rb +194 -0
  67. data/lib/azure_mgmt_network/models/express_route_circuit_peering_state.rb +16 -0
  68. data/lib/azure_mgmt_network/models/express_route_circuit_peering_type.rb +17 -0
  69. data/lib/azure_mgmt_network/models/express_route_circuit_properties_format.rb +179 -0
  70. data/lib/azure_mgmt_network/models/express_route_circuit_routes_table.rb +89 -0
  71. data/lib/azure_mgmt_network/models/express_route_circuit_service_provider_properties.rb +76 -0
  72. data/lib/azure_mgmt_network/models/express_route_circuit_sku.rb +83 -0
  73. data/lib/azure_mgmt_network/models/express_route_circuit_sku_family.rb +16 -0
  74. data/lib/azure_mgmt_network/models/express_route_circuit_sku_tier.rb +16 -0
  75. data/lib/azure_mgmt_network/models/express_route_circuit_stats.rb +67 -0
  76. data/lib/azure_mgmt_network/models/express_route_circuits_arp_table_list_result.rb +85 -0
  77. data/lib/azure_mgmt_network/models/express_route_circuits_routes_table_list_result.rb +88 -0
  78. data/lib/azure_mgmt_network/models/express_route_circuits_stats_list_result.rb +85 -0
  79. data/lib/azure_mgmt_network/models/express_route_service_provider.rb +92 -0
  80. data/lib/azure_mgmt_network/models/express_route_service_provider_bandwidths_offered.rb +67 -0
  81. data/lib/azure_mgmt_network/models/express_route_service_provider_list_result.rb +86 -0
  82. data/lib/azure_mgmt_network/models/express_route_service_provider_properties_format.rb +97 -0
  83. data/lib/azure_mgmt_network/models/{frontend_ip_configuration.rb → frontend_ipconfiguration.rb} +7 -9
  84. data/lib/azure_mgmt_network/models/{frontend_ip_configuration_properties_format.rb → frontend_ipconfiguration_properties_format.rb} +133 -77
  85. data/lib/azure_mgmt_network/models/inbound_nat_pool.rb +88 -0
  86. data/lib/azure_mgmt_network/models/inbound_nat_pool_properties_format.rb +134 -0
  87. data/lib/azure_mgmt_network/models/inbound_nat_rule.rb +1 -3
  88. data/lib/azure_mgmt_network/models/inbound_nat_rule_properties_format.rb +11 -12
  89. data/lib/azure_mgmt_network/models/{ip_allocation_method.rb → ipallocation_method.rb} +3 -3
  90. data/lib/azure_mgmt_network/models/ipconfiguration.rb +88 -0
  91. data/lib/azure_mgmt_network/models/ipconfiguration_properties_format.rb +113 -0
  92. data/lib/azure_mgmt_network/models/load_balancer.rb +7 -9
  93. data/lib/azure_mgmt_network/models/load_balancer_list_result.rb +4 -6
  94. data/lib/azure_mgmt_network/models/load_balancer_properties_format.rb +103 -35
  95. data/lib/azure_mgmt_network/models/load_balancing_rule.rb +1 -3
  96. data/lib/azure_mgmt_network/models/load_balancing_rule_properties_format.rb +30 -30
  97. data/lib/azure_mgmt_network/models/load_distribution.rb +1 -1
  98. data/lib/azure_mgmt_network/models/local_network_gateway.rb +7 -9
  99. data/lib/azure_mgmt_network/models/local_network_gateway_list_result.rb +4 -6
  100. data/lib/azure_mgmt_network/models/local_network_gateway_properties_format.rb +11 -3
  101. data/lib/azure_mgmt_network/models/network_interface.rb +7 -9
  102. data/lib/azure_mgmt_network/models/network_interface_dns_settings.rb +1 -3
  103. data/lib/azure_mgmt_network/models/{network_interface_ip_configuration.rb → network_interface_ipconfiguration.rb} +7 -9
  104. data/lib/azure_mgmt_network/models/{network_interface_ip_configuration_properties_format.rb → network_interface_ipconfiguration_properties_format.rb} +70 -76
  105. data/lib/azure_mgmt_network/models/network_interface_list_result.rb +4 -6
  106. data/lib/azure_mgmt_network/models/network_interface_properties_format.rb +32 -14
  107. data/lib/azure_mgmt_network/models/{operation_status.rb → network_operation_status.rb} +3 -3
  108. data/lib/azure_mgmt_network/models/network_security_group.rb +7 -9
  109. data/lib/azure_mgmt_network/models/network_security_group_list_result.rb +4 -6
  110. data/lib/azure_mgmt_network/models/network_security_group_properties_format.rb +30 -22
  111. data/lib/azure_mgmt_network/models/outbound_nat_rule.rb +88 -0
  112. data/lib/azure_mgmt_network/models/outbound_nat_rule_properties_format.rb +117 -0
  113. data/lib/azure_mgmt_network/models/probe.rb +1 -3
  114. data/lib/azure_mgmt_network/models/probe_properties_format.rb +25 -26
  115. data/lib/azure_mgmt_network/models/probe_protocol.rb +1 -1
  116. data/lib/azure_mgmt_network/models/processor_architecture.rb +16 -0
  117. data/lib/azure_mgmt_network/models/{public_ip_address.rb → public_ipaddress.rb} +13 -15
  118. data/lib/azure_mgmt_network/models/{public_ip_address_dns_settings.rb → public_ipaddress_dns_settings.rb} +4 -6
  119. data/lib/azure_mgmt_network/models/{public_ip_address_list_result.rb → public_ipaddress_list_result.rb} +10 -12
  120. data/lib/azure_mgmt_network/models/{public_ip_address_properties_format.rb → public_ipaddress_properties_format.rb} +25 -19
  121. data/lib/azure_mgmt_network/models/route.rb +88 -0
  122. data/lib/azure_mgmt_network/models/route_list_result.rb +85 -0
  123. data/lib/azure_mgmt_network/models/route_next_hop_type.rb +19 -0
  124. data/lib/azure_mgmt_network/models/route_properties_format.rb +94 -0
  125. data/lib/azure_mgmt_network/models/route_table.rb +102 -0
  126. data/lib/azure_mgmt_network/models/route_table_list_result.rb +86 -0
  127. data/lib/azure_mgmt_network/models/route_table_properties_format.rb +116 -0
  128. data/lib/azure_mgmt_network/models/security_rule.rb +1 -3
  129. data/lib/azure_mgmt_network/models/security_rule_access.rb +1 -1
  130. data/lib/azure_mgmt_network/models/security_rule_direction.rb +1 -1
  131. data/lib/azure_mgmt_network/models/security_rule_list_result.rb +4 -6
  132. data/lib/azure_mgmt_network/models/security_rule_properties_format.rb +50 -48
  133. data/lib/azure_mgmt_network/models/security_rule_protocol.rb +1 -1
  134. data/lib/azure_mgmt_network/models/service_provider_provisioning_state.rb +18 -0
  135. data/lib/azure_mgmt_network/models/subnet.rb +1 -3
  136. data/lib/azure_mgmt_network/models/subnet_list_result.rb +4 -6
  137. data/lib/azure_mgmt_network/models/subnet_properties_format.rb +28 -13
  138. data/lib/azure_mgmt_network/models/transport_protocol.rb +1 -1
  139. data/lib/azure_mgmt_network/models/usage.rb +7 -5
  140. data/lib/azure_mgmt_network/models/usage_name.rb +1 -3
  141. data/lib/azure_mgmt_network/models/usage_unit.rb +1 -1
  142. data/lib/azure_mgmt_network/models/usages_list_result.rb +4 -6
  143. data/lib/azure_mgmt_network/models/virtual_network.rb +7 -9
  144. data/lib/azure_mgmt_network/models/virtual_network_gateway.rb +7 -9
  145. data/lib/azure_mgmt_network/models/virtual_network_gateway_connection.rb +7 -9
  146. data/lib/azure_mgmt_network/models/virtual_network_gateway_connection_list_result.rb +4 -6
  147. data/lib/azure_mgmt_network/models/virtual_network_gateway_connection_properties_format.rb +74 -6
  148. data/lib/azure_mgmt_network/models/virtual_network_gateway_connection_status.rb +18 -0
  149. data/lib/azure_mgmt_network/models/virtual_network_gateway_connection_type.rb +1 -1
  150. data/lib/azure_mgmt_network/models/{virtual_network_gateway_ip_configuration.rb → virtual_network_gateway_ipconfiguration.rb} +7 -9
  151. data/lib/azure_mgmt_network/models/{virtual_network_gateway_ip_configuration_properties_format.rb → virtual_network_gateway_ipconfiguration_properties_format.rb} +14 -17
  152. data/lib/azure_mgmt_network/models/virtual_network_gateway_list_result.rb +4 -6
  153. data/lib/azure_mgmt_network/models/virtual_network_gateway_properties_format.rb +76 -13
  154. data/lib/azure_mgmt_network/models/virtual_network_gateway_sku.rb +86 -0
  155. data/lib/azure_mgmt_network/models/virtual_network_gateway_sku_name.rb +17 -0
  156. data/lib/azure_mgmt_network/models/virtual_network_gateway_sku_tier.rb +17 -0
  157. data/lib/azure_mgmt_network/models/virtual_network_gateway_type.rb +2 -1
  158. data/lib/azure_mgmt_network/models/virtual_network_list_result.rb +4 -6
  159. data/lib/azure_mgmt_network/models/virtual_network_properties_format.rb +14 -6
  160. data/lib/azure_mgmt_network/models/vpn_client_configuration.rb +125 -0
  161. data/lib/azure_mgmt_network/models/vpn_client_parameters.rb +60 -0
  162. data/lib/azure_mgmt_network/models/vpn_client_revoked_certificate.rb +88 -0
  163. data/lib/azure_mgmt_network/models/vpn_client_revoked_certificate_properties_format.rb +69 -0
  164. data/lib/azure_mgmt_network/models/vpn_client_root_certificate.rb +88 -0
  165. data/lib/azure_mgmt_network/models/vpn_client_root_certificate_properties_format.rb +66 -0
  166. data/lib/azure_mgmt_network/models/vpn_type.rb +1 -1
  167. data/lib/azure_mgmt_network/module_definition.rb +5 -3
  168. data/lib/azure_mgmt_network/network_interfaces.rb +451 -304
  169. data/lib/azure_mgmt_network/{network_resource_provider_client.rb → network_management_client.rb} +61 -57
  170. data/lib/azure_mgmt_network/network_security_groups.rb +139 -314
  171. data/lib/azure_mgmt_network/public_ipaddresses.rb +536 -0
  172. data/lib/azure_mgmt_network/route_tables.rb +532 -0
  173. data/lib/azure_mgmt_network/routes.rb +423 -0
  174. data/lib/azure_mgmt_network/security_rules.rb +102 -232
  175. data/lib/azure_mgmt_network/subnets.rb +104 -233
  176. data/lib/azure_mgmt_network/usages.rb +79 -43
  177. data/lib/azure_mgmt_network/version.rb +5 -3
  178. data/lib/azure_mgmt_network/virtual_network_gateway_connections.rb +262 -467
  179. data/lib/azure_mgmt_network/virtual_network_gateways.rb +204 -280
  180. data/lib/azure_mgmt_network/virtual_networks.rb +139 -314
  181. metadata +92 -106
  182. data/.gitignore +0 -10
  183. data/.travis.yml +0 -3
  184. data/Gemfile +0 -15
  185. data/lib/azure_mgmt_network/public_ip_addresses.rb +0 -711
@@ -1,11 +1,14 @@
1
1
  # encoding: utf-8
2
- # Code generated by Microsoft (R) AutoRest Code Generator 0.11.0.0
2
+ # Code generated by Microsoft (R) AutoRest Code Generator 0.16.0.0
3
3
  # Changes may cause incorrect behavior and will be lost if the code is
4
4
  # regenerated.
5
5
 
6
6
  module Azure::ARM::Network
7
7
  #
8
- # VirtualNetworks
8
+ # The Microsoft Azure Network management API provides a RESTful set of web
9
+ # services that interact with Microsoft Azure Networks service to manage
10
+ # your network resrources. The API has entities that capture the
11
+ # relationship between an end user and the Microsoft Azure Networks service.
9
12
  #
10
13
  class VirtualNetworks
11
14
  include Azure::ARM::Network::Models
@@ -19,11 +22,12 @@ module Azure::ARM::Network
19
22
  @client = client
20
23
  end
21
24
 
22
- # @return reference to the NetworkResourceProviderClient
25
+ # @return reference to the NetworkManagementClient
23
26
  attr_reader :client
24
27
 
25
28
  #
26
29
  # The Delete VirtualNetwork operation deletes the specifed virtual network
30
+ #
27
31
  # @param resource_group_name [String] The name of the resource group.
28
32
  # @param virtual_network_name [String] The name of the virtual network.
29
33
  # @return [Concurrent::Promise] promise which provides async access to http
@@ -39,7 +43,7 @@ module Azure::ARM::Network
39
43
  end
40
44
 
41
45
  # Waiting for response.
42
- @client.get_post_or_delete_operation_result(response, nil, deserialize_method)
46
+ @client.get_post_or_delete_operation_result(response, deserialize_method)
43
47
  end
44
48
 
45
49
  promise
@@ -47,6 +51,7 @@ module Azure::ARM::Network
47
51
 
48
52
  #
49
53
  # The Delete VirtualNetwork operation deletes the specifed virtual network
54
+ #
50
55
  # @param resource_group_name [String] The name of the resource group.
51
56
  # @param virtual_network_name [String] The name of the virtual network.
52
57
  # @param [Hash{String => String}] The hash of custom headers need to be
@@ -60,60 +65,33 @@ module Azure::ARM::Network
60
65
  fail ArgumentError, 'virtual_network_name is nil' if virtual_network_name.nil?
61
66
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
62
67
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
63
- # Construct URL
64
- path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualnetworks/{virtualNetworkName}"
65
- path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
66
- path['{virtualNetworkName}'] = ERB::Util.url_encode(virtual_network_name) if path.include?('{virtualNetworkName}')
67
- path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
68
- url = URI.join(@client.base_url, path)
69
- properties = {}
70
- properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
71
- unless url.query.nil?
72
- url.query.split('&').each do |url_item|
73
- url_items_parts = url_item.split('=')
74
- properties[url_items_parts[0]] = url_items_parts[1]
75
- end
76
- end
77
- properties.reject!{ |key, value| value.nil? }
78
- url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
79
- fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
80
- corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
81
- url = URI.parse(corrected_url)
82
-
83
- connection = Faraday.new(:url => url) do |faraday|
84
- faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
85
- faraday.use :cookie_jar
86
- faraday.adapter Faraday.default_adapter
87
- end
88
- request_headers = Hash.new
68
+ request_headers = {}
89
69
 
90
70
  # Set Headers
91
71
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
92
- request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
93
-
94
- unless custom_headers.nil?
95
- custom_headers.each do |key, value|
96
- request_headers[key] = value
97
- end
98
- end
99
-
100
- # Send Request
101
- promise = Concurrent::Promise.new do
102
- connection.delete do |request|
103
- request.headers = request_headers
104
- @client.credentials.sign_request(request) unless @client.credentials.nil?
105
- end
72
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
73
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualnetworks/{virtualNetworkName}'
74
+ options = {
75
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
76
+ path_params: {'resourceGroupName' => resource_group_name,'virtualNetworkName' => virtual_network_name,'subscriptionId' => @client.subscription_id},
77
+ query_params: {'api-version' => @client.api_version},
78
+ headers: request_headers.merge(custom_headers || {})
79
+ }
80
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :delete, options)
81
+ promise = request.run_promise do |req|
82
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
106
83
  end
107
84
 
108
85
  promise = promise.then do |http_response|
109
86
  status_code = http_response.status
110
87
  response_content = http_response.body
111
- unless (status_code == 200 || status_code == 204 || status_code == 202)
112
- fail MsRestAzure::AzureOperationError.new(connection, http_response)
88
+ unless status_code == 202 || status_code == 204 || status_code == 200
89
+ error_model = JSON.load(response_content)
90
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
113
91
  end
114
92
 
115
93
  # Create Result
116
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
94
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
117
95
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
118
96
 
119
97
  result
@@ -125,85 +103,59 @@ module Azure::ARM::Network
125
103
  #
126
104
  # The Get VirtualNetwork operation retrieves information about the specified
127
105
  # virtual network.
106
+ #
128
107
  # @param resource_group_name [String] The name of the resource group.
129
108
  # @param virtual_network_name [String] The name of the virtual network.
109
+ # @param expand [String] expand references resources.
130
110
  # @param [Hash{String => String}] The hash of custom headers need to be
131
111
  # applied to HTTP request.
132
112
  #
133
113
  # @return [Concurrent::Promise] Promise object which allows to get HTTP
134
114
  # response.
135
115
  #
136
- def get(resource_group_name, virtual_network_name, custom_headers = nil)
116
+ def get(resource_group_name, virtual_network_name, expand = nil, custom_headers = nil)
137
117
  fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
138
118
  fail ArgumentError, 'virtual_network_name is nil' if virtual_network_name.nil?
139
119
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
140
120
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
141
- # Construct URL
142
- path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualnetworks/{virtualNetworkName}"
143
- path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
144
- path['{virtualNetworkName}'] = ERB::Util.url_encode(virtual_network_name) if path.include?('{virtualNetworkName}')
145
- path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
146
- url = URI.join(@client.base_url, path)
147
- properties = {}
148
- properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
149
- unless url.query.nil?
150
- url.query.split('&').each do |url_item|
151
- url_items_parts = url_item.split('=')
152
- properties[url_items_parts[0]] = url_items_parts[1]
153
- end
154
- end
155
- properties.reject!{ |key, value| value.nil? }
156
- url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
157
- fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
158
- corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
159
- url = URI.parse(corrected_url)
160
-
161
- connection = Faraday.new(:url => url) do |faraday|
162
- faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
163
- faraday.use :cookie_jar
164
- faraday.adapter Faraday.default_adapter
165
- end
166
- request_headers = Hash.new
121
+ request_headers = {}
167
122
 
168
123
  # Set Headers
169
124
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
170
- request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
171
-
172
- unless custom_headers.nil?
173
- custom_headers.each do |key, value|
174
- request_headers[key] = value
175
- end
176
- end
177
-
178
- # Send Request
179
- promise = Concurrent::Promise.new do
180
- connection.get do |request|
181
- request.headers = request_headers
182
- @client.credentials.sign_request(request) unless @client.credentials.nil?
183
- end
125
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
126
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualnetworks/{virtualNetworkName}'
127
+ options = {
128
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
129
+ path_params: {'resourceGroupName' => resource_group_name,'virtualNetworkName' => virtual_network_name,'subscriptionId' => @client.subscription_id},
130
+ query_params: {'api-version' => @client.api_version,'$expand' => expand},
131
+ headers: request_headers.merge(custom_headers || {})
132
+ }
133
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
134
+ promise = request.run_promise do |req|
135
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
184
136
  end
185
137
 
186
138
  promise = promise.then do |http_response|
187
139
  status_code = http_response.status
188
140
  response_content = http_response.body
189
- unless (status_code == 200)
141
+ unless status_code == 200
190
142
  error_model = JSON.load(response_content)
191
- fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
143
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
192
144
  end
193
145
 
194
146
  # Create Result
195
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
147
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
196
148
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
197
149
  # Deserialize Response
198
150
  if status_code == 200
199
151
  begin
200
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
152
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
201
153
  unless parsed_response.nil?
202
154
  parsed_response = VirtualNetwork.deserialize_object(parsed_response)
203
155
  end
204
156
  result.body = parsed_response
205
157
  rescue Exception => e
206
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
158
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
207
159
  end
208
160
  end
209
161
 
@@ -216,6 +168,7 @@ module Azure::ARM::Network
216
168
  #
217
169
  # The Put VirtualNetwork operation creates/updates a virtual network in the
218
170
  # specified resource group.
171
+ #
219
172
  # @param resource_group_name [String] The name of the resource group.
220
173
  # @param virtual_network_name [String] The name of the virtual network.
221
174
  # @param parameters [VirtualNetwork] Parameters supplied to the create/update
@@ -243,7 +196,7 @@ module Azure::ARM::Network
243
196
  end
244
197
 
245
198
  # Waiting for response.
246
- @client.get_put_operation_result(response, custom_headers, deserialize_method)
199
+ @client.get_put_operation_result(response, deserialize_method)
247
200
  end
248
201
 
249
202
  promise
@@ -252,6 +205,7 @@ module Azure::ARM::Network
252
205
  #
253
206
  # The Put VirtualNetwork operation creates/updates a virtual network in the
254
207
  # specified resource group.
208
+ #
255
209
  # @param resource_group_name [String] The name of the resource group.
256
210
  # @param virtual_network_name [String] The name of the virtual network.
257
211
  # @param parameters [VirtualNetwork] Parameters supplied to the create/update
@@ -269,92 +223,64 @@ module Azure::ARM::Network
269
223
  parameters.validate unless parameters.nil?
270
224
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
271
225
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
272
- # Construct URL
273
- path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualnetworks/{virtualNetworkName}"
274
- path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
275
- path['{virtualNetworkName}'] = ERB::Util.url_encode(virtual_network_name) if path.include?('{virtualNetworkName}')
276
- path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
277
- url = URI.join(@client.base_url, path)
278
- properties = {}
279
- properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
280
- unless url.query.nil?
281
- url.query.split('&').each do |url_item|
282
- url_items_parts = url_item.split('=')
283
- properties[url_items_parts[0]] = url_items_parts[1]
284
- end
285
- end
286
- properties.reject!{ |key, value| value.nil? }
287
- url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
288
- fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
289
- corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
290
- url = URI.parse(corrected_url)
291
-
292
- connection = Faraday.new(:url => url) do |faraday|
293
- faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
294
- faraday.use :cookie_jar
295
- faraday.adapter Faraday.default_adapter
296
- end
297
- request_headers = Hash.new
226
+ request_headers = {}
298
227
 
299
228
  # Set Headers
300
229
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
301
- request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
302
-
303
- unless custom_headers.nil?
304
- custom_headers.each do |key, value|
305
- request_headers[key] = value
306
- end
307
- end
230
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
308
231
 
309
232
  # Serialize Request
310
- request_headers['Content-Type'] = 'application/json'
233
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
311
234
  unless parameters.nil?
312
235
  parameters = VirtualNetwork.serialize_object(parameters)
313
236
  end
314
237
  request_content = JSON.generate(parameters, quirks_mode: true)
315
-
316
- # Send Request
317
- promise = Concurrent::Promise.new do
318
- connection.put do |request|
319
- request.headers = request_headers
320
- request.body = request_content
321
- @client.credentials.sign_request(request) unless @client.credentials.nil?
322
- end
238
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualnetworks/{virtualNetworkName}'
239
+ options = {
240
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
241
+ path_params: {'resourceGroupName' => resource_group_name,'virtualNetworkName' => virtual_network_name,'subscriptionId' => @client.subscription_id},
242
+ query_params: {'api-version' => @client.api_version},
243
+ body: request_content,
244
+ headers: request_headers.merge(custom_headers || {})
245
+ }
246
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :put, options)
247
+ promise = request.run_promise do |req|
248
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
323
249
  end
324
250
 
325
251
  promise = promise.then do |http_response|
326
252
  status_code = http_response.status
327
253
  response_content = http_response.body
328
- unless (status_code == 200 || status_code == 201)
254
+ unless status_code == 200 || status_code == 201
329
255
  error_model = JSON.load(response_content)
330
- fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
256
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
331
257
  end
332
258
 
333
259
  # Create Result
334
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
260
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
335
261
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
336
262
  # Deserialize Response
337
263
  if status_code == 200
338
264
  begin
339
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
265
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
340
266
  unless parsed_response.nil?
341
267
  parsed_response = VirtualNetwork.deserialize_object(parsed_response)
342
268
  end
343
269
  result.body = parsed_response
344
270
  rescue Exception => e
345
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
271
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
346
272
  end
347
273
  end
348
274
  # Deserialize Response
349
275
  if status_code == 201
350
276
  begin
351
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
277
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
352
278
  unless parsed_response.nil?
353
279
  parsed_response = VirtualNetwork.deserialize_object(parsed_response)
354
280
  end
355
281
  result.body = parsed_response
356
282
  rescue Exception => e
357
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
283
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
358
284
  end
359
285
  end
360
286
 
@@ -366,6 +292,7 @@ module Azure::ARM::Network
366
292
 
367
293
  #
368
294
  # The list VirtualNetwork returns all Virtual Networks in a subscription
295
+ #
369
296
  # @param [Hash{String => String}] The hash of custom headers need to be
370
297
  # applied to HTTP request.
371
298
  #
@@ -375,70 +302,44 @@ module Azure::ARM::Network
375
302
  def list_all(custom_headers = nil)
376
303
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
377
304
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
378
- # Construct URL
379
- path = "/subscriptions/{subscriptionId}/providers/Microsoft.Network/virtualnetworks"
380
- path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
381
- url = URI.join(@client.base_url, path)
382
- properties = {}
383
- properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
384
- unless url.query.nil?
385
- url.query.split('&').each do |url_item|
386
- url_items_parts = url_item.split('=')
387
- properties[url_items_parts[0]] = url_items_parts[1]
388
- end
389
- end
390
- properties.reject!{ |key, value| value.nil? }
391
- url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
392
- fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
393
- corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
394
- url = URI.parse(corrected_url)
395
-
396
- connection = Faraday.new(:url => url) do |faraday|
397
- faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
398
- faraday.use :cookie_jar
399
- faraday.adapter Faraday.default_adapter
400
- end
401
- request_headers = Hash.new
305
+ request_headers = {}
402
306
 
403
307
  # Set Headers
404
308
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
405
- request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
406
-
407
- unless custom_headers.nil?
408
- custom_headers.each do |key, value|
409
- request_headers[key] = value
410
- end
411
- end
412
-
413
- # Send Request
414
- promise = Concurrent::Promise.new do
415
- connection.get do |request|
416
- request.headers = request_headers
417
- @client.credentials.sign_request(request) unless @client.credentials.nil?
418
- end
309
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
310
+ path_template = '/subscriptions/{subscriptionId}/providers/Microsoft.Network/virtualnetworks'
311
+ options = {
312
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
313
+ path_params: {'subscriptionId' => @client.subscription_id},
314
+ query_params: {'api-version' => @client.api_version},
315
+ headers: request_headers.merge(custom_headers || {})
316
+ }
317
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
318
+ promise = request.run_promise do |req|
319
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
419
320
  end
420
321
 
421
322
  promise = promise.then do |http_response|
422
323
  status_code = http_response.status
423
324
  response_content = http_response.body
424
- unless (status_code == 200)
325
+ unless status_code == 200
425
326
  error_model = JSON.load(response_content)
426
- fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
327
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
427
328
  end
428
329
 
429
330
  # Create Result
430
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
331
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
431
332
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
432
333
  # Deserialize Response
433
334
  if status_code == 200
434
335
  begin
435
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
336
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
436
337
  unless parsed_response.nil?
437
338
  parsed_response = VirtualNetworkListResult.deserialize_object(parsed_response)
438
339
  end
439
340
  result.body = parsed_response
440
341
  rescue Exception => e
441
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
342
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
442
343
  end
443
344
  end
444
345
 
@@ -450,6 +351,7 @@ module Azure::ARM::Network
450
351
 
451
352
  #
452
353
  # The list VirtualNetwork returns all Virtual Networks in a resource group
354
+ #
453
355
  # @param resource_group_name [String] The name of the resource group.
454
356
  # @param [Hash{String => String}] The hash of custom headers need to be
455
357
  # applied to HTTP request.
@@ -461,71 +363,44 @@ module Azure::ARM::Network
461
363
  fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
462
364
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
463
365
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
464
- # Construct URL
465
- path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualnetworks"
466
- path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
467
- path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
468
- url = URI.join(@client.base_url, path)
469
- properties = {}
470
- properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
471
- unless url.query.nil?
472
- url.query.split('&').each do |url_item|
473
- url_items_parts = url_item.split('=')
474
- properties[url_items_parts[0]] = url_items_parts[1]
475
- end
476
- end
477
- properties.reject!{ |key, value| value.nil? }
478
- url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
479
- fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
480
- corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
481
- url = URI.parse(corrected_url)
482
-
483
- connection = Faraday.new(:url => url) do |faraday|
484
- faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
485
- faraday.use :cookie_jar
486
- faraday.adapter Faraday.default_adapter
487
- end
488
- request_headers = Hash.new
366
+ request_headers = {}
489
367
 
490
368
  # Set Headers
491
369
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
492
- request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
493
-
494
- unless custom_headers.nil?
495
- custom_headers.each do |key, value|
496
- request_headers[key] = value
497
- end
498
- end
499
-
500
- # Send Request
501
- promise = Concurrent::Promise.new do
502
- connection.get do |request|
503
- request.headers = request_headers
504
- @client.credentials.sign_request(request) unless @client.credentials.nil?
505
- end
370
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
371
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualnetworks'
372
+ options = {
373
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
374
+ path_params: {'resourceGroupName' => resource_group_name,'subscriptionId' => @client.subscription_id},
375
+ query_params: {'api-version' => @client.api_version},
376
+ headers: request_headers.merge(custom_headers || {})
377
+ }
378
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
379
+ promise = request.run_promise do |req|
380
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
506
381
  end
507
382
 
508
383
  promise = promise.then do |http_response|
509
384
  status_code = http_response.status
510
385
  response_content = http_response.body
511
- unless (status_code == 200)
386
+ unless status_code == 200
512
387
  error_model = JSON.load(response_content)
513
- fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
388
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
514
389
  end
515
390
 
516
391
  # Create Result
517
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
392
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
518
393
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
519
394
  # Deserialize Response
520
395
  if status_code == 200
521
396
  begin
522
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
397
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
523
398
  unless parsed_response.nil?
524
399
  parsed_response = VirtualNetworkListResult.deserialize_object(parsed_response)
525
400
  end
526
401
  result.body = parsed_response
527
402
  rescue Exception => e
528
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
403
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
529
404
  end
530
405
  end
531
406
 
@@ -537,6 +412,7 @@ module Azure::ARM::Network
537
412
 
538
413
  #
539
414
  # The list VirtualNetwork returns all Virtual Networks in a subscription
415
+ #
540
416
  # @param next_page_link [String] The NextLink from the previous successful
541
417
  # call to List operation.
542
418
  # @param [Hash{String => String}] The hash of custom headers need to be
@@ -547,69 +423,43 @@ module Azure::ARM::Network
547
423
  #
548
424
  def list_all_next(next_page_link, custom_headers = nil)
549
425
  fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
550
- # Construct URL
551
- path = "{nextLink}"
552
- path['{nextLink}'] = next_page_link if path.include?('{nextLink}')
553
- url = URI.parse(path)
554
- properties = {}
555
- unless url.query.nil?
556
- url.query.split('&').each do |url_item|
557
- url_items_parts = url_item.split('=')
558
- properties[url_items_parts[0]] = url_items_parts[1]
559
- end
560
- end
561
- properties.reject!{ |key, value| value.nil? }
562
- url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
563
- fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
564
- corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
565
- url = URI.parse(corrected_url)
566
-
567
- connection = Faraday.new(:url => url) do |faraday|
568
- faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
569
- faraday.use :cookie_jar
570
- faraday.adapter Faraday.default_adapter
571
- end
572
- request_headers = Hash.new
426
+ request_headers = {}
573
427
 
574
428
  # Set Headers
575
429
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
576
- request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
577
-
578
- unless custom_headers.nil?
579
- custom_headers.each do |key, value|
580
- request_headers[key] = value
581
- end
582
- end
583
-
584
- # Send Request
585
- promise = Concurrent::Promise.new do
586
- connection.get do |request|
587
- request.headers = request_headers
588
- @client.credentials.sign_request(request) unless @client.credentials.nil?
589
- end
430
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
431
+ path_template = '{nextLink}'
432
+ options = {
433
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
434
+ skip_encoding_path_params: {'nextLink' => next_page_link},
435
+ headers: request_headers.merge(custom_headers || {})
436
+ }
437
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
438
+ promise = request.run_promise do |req|
439
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
590
440
  end
591
441
 
592
442
  promise = promise.then do |http_response|
593
443
  status_code = http_response.status
594
444
  response_content = http_response.body
595
- unless (status_code == 200)
445
+ unless status_code == 200
596
446
  error_model = JSON.load(response_content)
597
- fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
447
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
598
448
  end
599
449
 
600
450
  # Create Result
601
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
451
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
602
452
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
603
453
  # Deserialize Response
604
454
  if status_code == 200
605
455
  begin
606
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
456
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
607
457
  unless parsed_response.nil?
608
458
  parsed_response = VirtualNetworkListResult.deserialize_object(parsed_response)
609
459
  end
610
460
  result.body = parsed_response
611
461
  rescue Exception => e
612
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
462
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
613
463
  end
614
464
  end
615
465
 
@@ -621,6 +471,7 @@ module Azure::ARM::Network
621
471
 
622
472
  #
623
473
  # The list VirtualNetwork returns all Virtual Networks in a resource group
474
+ #
624
475
  # @param next_page_link [String] The NextLink from the previous successful
625
476
  # call to List operation.
626
477
  # @param [Hash{String => String}] The hash of custom headers need to be
@@ -631,69 +482,43 @@ module Azure::ARM::Network
631
482
  #
632
483
  def list_next(next_page_link, custom_headers = nil)
633
484
  fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
634
- # Construct URL
635
- path = "{nextLink}"
636
- path['{nextLink}'] = next_page_link if path.include?('{nextLink}')
637
- url = URI.parse(path)
638
- properties = {}
639
- unless url.query.nil?
640
- url.query.split('&').each do |url_item|
641
- url_items_parts = url_item.split('=')
642
- properties[url_items_parts[0]] = url_items_parts[1]
643
- end
644
- end
645
- properties.reject!{ |key, value| value.nil? }
646
- url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
647
- fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
648
- corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
649
- url = URI.parse(corrected_url)
650
-
651
- connection = Faraday.new(:url => url) do |faraday|
652
- faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
653
- faraday.use :cookie_jar
654
- faraday.adapter Faraday.default_adapter
655
- end
656
- request_headers = Hash.new
485
+ request_headers = {}
657
486
 
658
487
  # Set Headers
659
488
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
660
- request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
661
-
662
- unless custom_headers.nil?
663
- custom_headers.each do |key, value|
664
- request_headers[key] = value
665
- end
666
- end
667
-
668
- # Send Request
669
- promise = Concurrent::Promise.new do
670
- connection.get do |request|
671
- request.headers = request_headers
672
- @client.credentials.sign_request(request) unless @client.credentials.nil?
673
- end
489
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
490
+ path_template = '{nextLink}'
491
+ options = {
492
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
493
+ skip_encoding_path_params: {'nextLink' => next_page_link},
494
+ headers: request_headers.merge(custom_headers || {})
495
+ }
496
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
497
+ promise = request.run_promise do |req|
498
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
674
499
  end
675
500
 
676
501
  promise = promise.then do |http_response|
677
502
  status_code = http_response.status
678
503
  response_content = http_response.body
679
- unless (status_code == 200)
504
+ unless status_code == 200
680
505
  error_model = JSON.load(response_content)
681
- fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
506
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
682
507
  end
683
508
 
684
509
  # Create Result
685
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
510
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
686
511
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
687
512
  # Deserialize Response
688
513
  if status_code == 200
689
514
  begin
690
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
515
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
691
516
  unless parsed_response.nil?
692
517
  parsed_response = VirtualNetworkListResult.deserialize_object(parsed_response)
693
518
  end
694
519
  result.body = parsed_response
695
520
  rescue Exception => e
696
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
521
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
697
522
  end
698
523
  end
699
524