azure_mgmt_network 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.rspec +3 -0
  4. data/.travis.yml +3 -0
  5. data/Gemfile +15 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +131 -0
  8. data/Rakefile +5 -0
  9. data/azure_mgmt_network.gemspec +39 -0
  10. data/lib/azure_mgmt_network.rb +139 -0
  11. data/lib/azure_mgmt_network/Models/address_space.rb +60 -0
  12. data/lib/azure_mgmt_network/Models/application_gateway.rb +104 -0
  13. data/lib/azure_mgmt_network/Models/application_gateway_backend_address.rb +67 -0
  14. data/lib/azure_mgmt_network/Models/application_gateway_backend_address_pool.rb +90 -0
  15. data/lib/azure_mgmt_network/Models/application_gateway_backend_address_pool_properties_format.rb +121 -0
  16. data/lib/azure_mgmt_network/Models/application_gateway_backend_http_settings.rb +90 -0
  17. data/lib/azure_mgmt_network/Models/application_gateway_backend_http_settings_properties_format.rb +98 -0
  18. data/lib/azure_mgmt_network/Models/application_gateway_cookie_based_affinity.rb +16 -0
  19. data/lib/azure_mgmt_network/Models/application_gateway_frontend_ip_configuration.rb +91 -0
  20. data/lib/azure_mgmt_network/Models/application_gateway_frontend_ip_configuration_properties_format.rb +117 -0
  21. data/lib/azure_mgmt_network/Models/application_gateway_frontend_port.rb +90 -0
  22. data/lib/azure_mgmt_network/Models/application_gateway_frontend_port_properties_format.rb +70 -0
  23. data/lib/azure_mgmt_network/Models/application_gateway_http_listener.rb +90 -0
  24. data/lib/azure_mgmt_network/Models/application_gateway_http_listener_properties_format.rb +124 -0
  25. data/lib/azure_mgmt_network/Models/application_gateway_ip_configuration.rb +90 -0
  26. data/lib/azure_mgmt_network/Models/application_gateway_ip_configuration_properties_format.rb +77 -0
  27. data/lib/azure_mgmt_network/Models/application_gateway_list_result.rb +88 -0
  28. data/lib/azure_mgmt_network/Models/application_gateway_operational_state.rb +18 -0
  29. data/lib/azure_mgmt_network/Models/application_gateway_properties_format.rb +338 -0
  30. data/lib/azure_mgmt_network/Models/application_gateway_protocol.rb +16 -0
  31. data/lib/azure_mgmt_network/Models/application_gateway_request_routing_rule.rb +90 -0
  32. data/lib/azure_mgmt_network/Models/application_gateway_request_routing_rule_properties_format.rb +124 -0
  33. data/lib/azure_mgmt_network/Models/application_gateway_request_routing_rule_type.rb +15 -0
  34. data/lib/azure_mgmt_network/Models/application_gateway_sku.rb +88 -0
  35. data/lib/azure_mgmt_network/Models/application_gateway_sku_name.rb +17 -0
  36. data/lib/azure_mgmt_network/Models/application_gateway_ssl_certificate.rb +90 -0
  37. data/lib/azure_mgmt_network/Models/application_gateway_ssl_certificate_properties_format.rb +87 -0
  38. data/lib/azure_mgmt_network/Models/application_gateway_tier.rb +15 -0
  39. data/lib/azure_mgmt_network/Models/azure_async_operation_result.rb +85 -0
  40. data/lib/azure_mgmt_network/Models/backend_address_pool.rb +90 -0
  41. data/lib/azure_mgmt_network/Models/backend_address_pool_properties_format.rb +120 -0
  42. data/lib/azure_mgmt_network/Models/connection_reset_shared_key.rb +64 -0
  43. data/lib/azure_mgmt_network/Models/connection_reset_shared_key_properties_format.rb +60 -0
  44. data/lib/azure_mgmt_network/Models/connection_shared_key.rb +58 -0
  45. data/lib/azure_mgmt_network/Models/dhcp_options.rb +60 -0
  46. data/lib/azure_mgmt_network/Models/dns_name_availability_result.rb +58 -0
  47. data/lib/azure_mgmt_network/Models/error.rb +114 -0
  48. data/lib/azure_mgmt_network/Models/error_details.rb +76 -0
  49. data/lib/azure_mgmt_network/Models/frontend_ip_configuration.rb +90 -0
  50. data/lib/azure_mgmt_network/Models/frontend_ip_configuration_properties_format.rb +181 -0
  51. data/lib/azure_mgmt_network/Models/inbound_nat_rule.rb +90 -0
  52. data/lib/azure_mgmt_network/Models/inbound_nat_rule_properties_format.rb +163 -0
  53. data/lib/azure_mgmt_network/Models/ip_allocation_method.rb +16 -0
  54. data/lib/azure_mgmt_network/Models/load_balancer.rb +104 -0
  55. data/lib/azure_mgmt_network/Models/load_balancer_list_result.rb +88 -0
  56. data/lib/azure_mgmt_network/Models/load_balancer_properties_format.rb +210 -0
  57. data/lib/azure_mgmt_network/Models/load_balancing_rule.rb +90 -0
  58. data/lib/azure_mgmt_network/Models/load_balancing_rule_properties_format.rb +195 -0
  59. data/lib/azure_mgmt_network/Models/load_distribution.rb +17 -0
  60. data/lib/azure_mgmt_network/Models/local_network_gateway.rb +104 -0
  61. data/lib/azure_mgmt_network/Models/local_network_gateway_list_result.rb +88 -0
  62. data/lib/azure_mgmt_network/Models/local_network_gateway_properties_format.rb +83 -0
  63. data/lib/azure_mgmt_network/Models/network_interface.rb +104 -0
  64. data/lib/azure_mgmt_network/Models/network_interface_dns_settings.rb +89 -0
  65. data/lib/azure_mgmt_network/Models/network_interface_ip_configuration.rb +90 -0
  66. data/lib/azure_mgmt_network/Models/network_interface_ip_configuration_properties_format.rb +179 -0
  67. data/lib/azure_mgmt_network/Models/network_interface_list_result.rb +88 -0
  68. data/lib/azure_mgmt_network/Models/network_interface_properties_format.rb +158 -0
  69. data/lib/azure_mgmt_network/Models/network_security_group.rb +104 -0
  70. data/lib/azure_mgmt_network/Models/network_security_group_list_result.rb +88 -0
  71. data/lib/azure_mgmt_network/Models/network_security_group_properties_format.rb +181 -0
  72. data/lib/azure_mgmt_network/Models/operation_status.rb +17 -0
  73. data/lib/azure_mgmt_network/Models/probe.rb +90 -0
  74. data/lib/azure_mgmt_network/Models/probe_properties_format.rb +157 -0
  75. data/lib/azure_mgmt_network/Models/probe_protocol.rb +16 -0
  76. data/lib/azure_mgmt_network/Models/public_ip_address.rb +104 -0
  77. data/lib/azure_mgmt_network/Models/public_ip_address_dns_settings.rb +85 -0
  78. data/lib/azure_mgmt_network/Models/public_ip_address_list_result.rb +88 -0
  79. data/lib/azure_mgmt_network/Models/public_ip_address_properties_format.rb +126 -0
  80. data/lib/azure_mgmt_network/Models/security_rule.rb +90 -0
  81. data/lib/azure_mgmt_network/Models/security_rule_access.rb +16 -0
  82. data/lib/azure_mgmt_network/Models/security_rule_direction.rb +16 -0
  83. data/lib/azure_mgmt_network/Models/security_rule_list_result.rb +89 -0
  84. data/lib/azure_mgmt_network/Models/security_rule_properties_format.rb +174 -0
  85. data/lib/azure_mgmt_network/Models/security_rule_protocol.rb +17 -0
  86. data/lib/azure_mgmt_network/Models/subnet.rb +90 -0
  87. data/lib/azure_mgmt_network/Models/subnet_list_result.rb +88 -0
  88. data/lib/azure_mgmt_network/Models/subnet_properties_format.rb +115 -0
  89. data/lib/azure_mgmt_network/Models/transport_protocol.rb +16 -0
  90. data/lib/azure_mgmt_network/Models/usage.rb +98 -0
  91. data/lib/azure_mgmt_network/Models/usage_name.rb +68 -0
  92. data/lib/azure_mgmt_network/Models/usage_unit.rb +15 -0
  93. data/lib/azure_mgmt_network/Models/usages_list_result.rb +78 -0
  94. data/lib/azure_mgmt_network/Models/virtual_network.rb +104 -0
  95. data/lib/azure_mgmt_network/Models/virtual_network_gateway.rb +104 -0
  96. data/lib/azure_mgmt_network/Models/virtual_network_gateway_connection.rb +104 -0
  97. data/lib/azure_mgmt_network/Models/virtual_network_gateway_connection_list_result.rb +89 -0
  98. data/lib/azure_mgmt_network/Models/virtual_network_gateway_connection_properties_format.rb +141 -0
  99. data/lib/azure_mgmt_network/Models/virtual_network_gateway_connection_type.rb +18 -0
  100. data/lib/azure_mgmt_network/Models/virtual_network_gateway_ip_configuration.rb +90 -0
  101. data/lib/azure_mgmt_network/Models/virtual_network_gateway_ip_configuration_properties_format.rb +117 -0
  102. data/lib/azure_mgmt_network/Models/virtual_network_gateway_list_result.rb +88 -0
  103. data/lib/azure_mgmt_network/Models/virtual_network_gateway_properties_format.rb +126 -0
  104. data/lib/azure_mgmt_network/Models/virtual_network_gateway_type.rb +15 -0
  105. data/lib/azure_mgmt_network/Models/virtual_network_list_result.rb +88 -0
  106. data/lib/azure_mgmt_network/Models/virtual_network_properties_format.rb +123 -0
  107. data/lib/azure_mgmt_network/Models/vpn_type.rb +16 -0
  108. data/lib/azure_mgmt_network/application_gateways.rb +915 -0
  109. data/lib/azure_mgmt_network/load_balancers.rb +709 -0
  110. data/lib/azure_mgmt_network/local_network_gateways.rb +550 -0
  111. data/lib/azure_mgmt_network/module_definition.rb +6 -0
  112. data/lib/azure_mgmt_network/network_interfaces.rb +709 -0
  113. data/lib/azure_mgmt_network/network_resource_provider_client.rb +195 -0
  114. data/lib/azure_mgmt_network/network_security_groups.rb +718 -0
  115. data/lib/azure_mgmt_network/public_ip_addresses.rb +711 -0
  116. data/lib/azure_mgmt_network/security_rules.rb +563 -0
  117. data/lib/azure_mgmt_network/subnets.rb +552 -0
  118. data/lib/azure_mgmt_network/usages.rb +113 -0
  119. data/lib/azure_mgmt_network/version.rb +6 -0
  120. data/lib/azure_mgmt_network/virtual_network_gateway_connections.rb +945 -0
  121. data/lib/azure_mgmt_network/virtual_network_gateways.rb +686 -0
  122. data/lib/azure_mgmt_network/virtual_networks.rb +707 -0
  123. metadata +311 -0
@@ -0,0 +1,707 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator 0.11.0.0
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure::ARM::Network
7
+ #
8
+ # VirtualNetworks
9
+ #
10
+ class VirtualNetworks
11
+ include Azure::ARM::Network::Models
12
+ include MsRestAzure
13
+
14
+ #
15
+ # Creates and initializes a new instance of the VirtualNetworks class.
16
+ # @param client service class for accessing basic functionality.
17
+ #
18
+ def initialize(client)
19
+ @client = client
20
+ end
21
+
22
+ # @return reference to the NetworkResourceProviderClient
23
+ attr_reader :client
24
+
25
+ #
26
+ # The Delete VirtualNetwork operation deletes the specifed virtual network
27
+ # @param resource_group_name [String] The name of the resource group.
28
+ # @param virtual_network_name [String] The name of the virtual network.
29
+ # @return [Concurrent::Promise] promise which provides async access to http
30
+ # response.
31
+ #
32
+ def delete(resource_group_name, virtual_network_name, custom_headers = nil)
33
+ # Send request
34
+ promise = begin_delete(resource_group_name, virtual_network_name, custom_headers)
35
+
36
+ promise = promise.then do |response|
37
+ # Defining deserialization method.
38
+ deserialize_method = lambda do |parsed_response|
39
+ end
40
+
41
+ # Waiting for response.
42
+ @client.get_post_or_delete_operation_result(response, nil, deserialize_method)
43
+ end
44
+
45
+ promise
46
+ end
47
+
48
+ #
49
+ # The Delete VirtualNetwork operation deletes the specifed virtual network
50
+ # @param resource_group_name [String] The name of the resource group.
51
+ # @param virtual_network_name [String] The name of the virtual network.
52
+ # @param [Hash{String => String}] The hash of custom headers need to be
53
+ # applied to HTTP request.
54
+ #
55
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
56
+ # response.
57
+ #
58
+ def begin_delete(resource_group_name, virtual_network_name, custom_headers = nil)
59
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
60
+ fail ArgumentError, 'virtual_network_name is nil' if virtual_network_name.nil?
61
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
62
+ 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
89
+
90
+ # Set Headers
91
+ 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
106
+ end
107
+
108
+ promise = promise.then do |http_response|
109
+ status_code = http_response.status
110
+ response_content = http_response.body
111
+ unless (status_code == 200 || status_code == 204 || status_code == 202)
112
+ fail MsRestAzure::AzureOperationError.new(connection, http_response)
113
+ end
114
+
115
+ # Create Result
116
+ result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
117
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
118
+
119
+ result
120
+ end
121
+
122
+ promise.execute
123
+ end
124
+
125
+ #
126
+ # The Get VirtualNetwork operation retrieves information about the specified
127
+ # virtual network.
128
+ # @param resource_group_name [String] The name of the resource group.
129
+ # @param virtual_network_name [String] The name of the virtual network.
130
+ # @param [Hash{String => String}] The hash of custom headers need to be
131
+ # applied to HTTP request.
132
+ #
133
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
134
+ # response.
135
+ #
136
+ def get(resource_group_name, virtual_network_name, custom_headers = nil)
137
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
138
+ fail ArgumentError, 'virtual_network_name is nil' if virtual_network_name.nil?
139
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
140
+ 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
167
+
168
+ # Set Headers
169
+ 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
184
+ end
185
+
186
+ promise = promise.then do |http_response|
187
+ status_code = http_response.status
188
+ response_content = http_response.body
189
+ unless (status_code == 200)
190
+ error_model = JSON.load(response_content)
191
+ fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
192
+ end
193
+
194
+ # Create Result
195
+ result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
196
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
197
+ # Deserialize Response
198
+ if status_code == 200
199
+ begin
200
+ parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
201
+ unless parsed_response.nil?
202
+ parsed_response = VirtualNetwork.deserialize_object(parsed_response)
203
+ end
204
+ result.body = parsed_response
205
+ rescue Exception => e
206
+ fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
207
+ end
208
+ end
209
+
210
+ result
211
+ end
212
+
213
+ promise.execute
214
+ end
215
+
216
+ #
217
+ # The Put VirtualNetwork operation creates/updates a virtual network in the
218
+ # specified resource group.
219
+ # @param resource_group_name [String] The name of the resource group.
220
+ # @param virtual_network_name [String] The name of the virtual network.
221
+ # @param parameters [VirtualNetwork] Parameters supplied to the create/update
222
+ # Virtual Network operation
223
+ # @param @client.api_version [String] Client Api Version.
224
+ # @param @client.subscription_id [String] Gets subscription credentials which
225
+ # uniquely identify Microsoft Azure subscription. The subscription ID forms
226
+ # part of the URI for every service call.
227
+ # @param @client.accept_language [String] Gets or sets the preferred language
228
+ # for the response.
229
+ #
230
+ # @return [Concurrent::Promise] promise which provides async access to http
231
+ # response.
232
+ #
233
+ def create_or_update(resource_group_name, virtual_network_name, parameters, custom_headers = nil)
234
+ # Send request
235
+ promise = begin_create_or_update(resource_group_name, virtual_network_name, parameters, custom_headers)
236
+
237
+ promise = promise.then do |response|
238
+ # Defining deserialization method.
239
+ deserialize_method = lambda do |parsed_response|
240
+ unless parsed_response.nil?
241
+ parsed_response = VirtualNetwork.deserialize_object(parsed_response)
242
+ end
243
+ end
244
+
245
+ # Waiting for response.
246
+ @client.get_put_operation_result(response, custom_headers, deserialize_method)
247
+ end
248
+
249
+ promise
250
+ end
251
+
252
+ #
253
+ # The Put VirtualNetwork operation creates/updates a virtual network in the
254
+ # specified resource group.
255
+ # @param resource_group_name [String] The name of the resource group.
256
+ # @param virtual_network_name [String] The name of the virtual network.
257
+ # @param parameters [VirtualNetwork] Parameters supplied to the create/update
258
+ # Virtual Network operation
259
+ # @param [Hash{String => String}] The hash of custom headers need to be
260
+ # applied to HTTP request.
261
+ #
262
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
263
+ # response.
264
+ #
265
+ def begin_create_or_update(resource_group_name, virtual_network_name, parameters, custom_headers = nil)
266
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
267
+ fail ArgumentError, 'virtual_network_name is nil' if virtual_network_name.nil?
268
+ fail ArgumentError, 'parameters is nil' if parameters.nil?
269
+ parameters.validate unless parameters.nil?
270
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
271
+ 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
298
+
299
+ # Set Headers
300
+ 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
308
+
309
+ # Serialize Request
310
+ request_headers['Content-Type'] = 'application/json'
311
+ unless parameters.nil?
312
+ parameters = VirtualNetwork.serialize_object(parameters)
313
+ end
314
+ 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
323
+ end
324
+
325
+ promise = promise.then do |http_response|
326
+ status_code = http_response.status
327
+ response_content = http_response.body
328
+ unless (status_code == 200 || status_code == 201)
329
+ error_model = JSON.load(response_content)
330
+ fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
331
+ end
332
+
333
+ # Create Result
334
+ result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
335
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
336
+ # Deserialize Response
337
+ if status_code == 200
338
+ begin
339
+ parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
340
+ unless parsed_response.nil?
341
+ parsed_response = VirtualNetwork.deserialize_object(parsed_response)
342
+ end
343
+ result.body = parsed_response
344
+ rescue Exception => e
345
+ fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
346
+ end
347
+ end
348
+ # Deserialize Response
349
+ if status_code == 201
350
+ begin
351
+ parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
352
+ unless parsed_response.nil?
353
+ parsed_response = VirtualNetwork.deserialize_object(parsed_response)
354
+ end
355
+ result.body = parsed_response
356
+ rescue Exception => e
357
+ fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
358
+ end
359
+ end
360
+
361
+ result
362
+ end
363
+
364
+ promise.execute
365
+ end
366
+
367
+ #
368
+ # The list VirtualNetwork returns all Virtual Networks in a subscription
369
+ # @param [Hash{String => String}] The hash of custom headers need to be
370
+ # applied to HTTP request.
371
+ #
372
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
373
+ # response.
374
+ #
375
+ def list_all(custom_headers = nil)
376
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
377
+ 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
402
+
403
+ # Set Headers
404
+ 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
419
+ end
420
+
421
+ promise = promise.then do |http_response|
422
+ status_code = http_response.status
423
+ response_content = http_response.body
424
+ unless (status_code == 200)
425
+ error_model = JSON.load(response_content)
426
+ fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
427
+ end
428
+
429
+ # Create Result
430
+ result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
431
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
432
+ # Deserialize Response
433
+ if status_code == 200
434
+ begin
435
+ parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
436
+ unless parsed_response.nil?
437
+ parsed_response = VirtualNetworkListResult.deserialize_object(parsed_response)
438
+ end
439
+ result.body = parsed_response
440
+ rescue Exception => e
441
+ fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
442
+ end
443
+ end
444
+
445
+ result
446
+ end
447
+
448
+ promise.execute
449
+ end
450
+
451
+ #
452
+ # The list VirtualNetwork returns all Virtual Networks in a resource group
453
+ # @param resource_group_name [String] The name of the resource group.
454
+ # @param [Hash{String => String}] The hash of custom headers need to be
455
+ # applied to HTTP request.
456
+ #
457
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
458
+ # response.
459
+ #
460
+ def list(resource_group_name, custom_headers = nil)
461
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
462
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
463
+ 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
489
+
490
+ # Set Headers
491
+ 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
506
+ end
507
+
508
+ promise = promise.then do |http_response|
509
+ status_code = http_response.status
510
+ response_content = http_response.body
511
+ unless (status_code == 200)
512
+ error_model = JSON.load(response_content)
513
+ fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
514
+ end
515
+
516
+ # Create Result
517
+ result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
518
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
519
+ # Deserialize Response
520
+ if status_code == 200
521
+ begin
522
+ parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
523
+ unless parsed_response.nil?
524
+ parsed_response = VirtualNetworkListResult.deserialize_object(parsed_response)
525
+ end
526
+ result.body = parsed_response
527
+ rescue Exception => e
528
+ fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
529
+ end
530
+ end
531
+
532
+ result
533
+ end
534
+
535
+ promise.execute
536
+ end
537
+
538
+ #
539
+ # The list VirtualNetwork returns all Virtual Networks in a subscription
540
+ # @param next_page_link [String] The NextLink from the previous successful
541
+ # call to List operation.
542
+ # @param [Hash{String => String}] The hash of custom headers need to be
543
+ # applied to HTTP request.
544
+ #
545
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
546
+ # response.
547
+ #
548
+ def list_all_next(next_page_link, custom_headers = nil)
549
+ 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
573
+
574
+ # Set Headers
575
+ 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
590
+ end
591
+
592
+ promise = promise.then do |http_response|
593
+ status_code = http_response.status
594
+ response_content = http_response.body
595
+ unless (status_code == 200)
596
+ error_model = JSON.load(response_content)
597
+ fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
598
+ end
599
+
600
+ # Create Result
601
+ result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
602
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
603
+ # Deserialize Response
604
+ if status_code == 200
605
+ begin
606
+ parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
607
+ unless parsed_response.nil?
608
+ parsed_response = VirtualNetworkListResult.deserialize_object(parsed_response)
609
+ end
610
+ result.body = parsed_response
611
+ rescue Exception => e
612
+ fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
613
+ end
614
+ end
615
+
616
+ result
617
+ end
618
+
619
+ promise.execute
620
+ end
621
+
622
+ #
623
+ # The list VirtualNetwork returns all Virtual Networks in a resource group
624
+ # @param next_page_link [String] The NextLink from the previous successful
625
+ # call to List operation.
626
+ # @param [Hash{String => String}] The hash of custom headers need to be
627
+ # applied to HTTP request.
628
+ #
629
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
630
+ # response.
631
+ #
632
+ def list_next(next_page_link, custom_headers = nil)
633
+ 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
657
+
658
+ # Set Headers
659
+ 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
674
+ end
675
+
676
+ promise = promise.then do |http_response|
677
+ status_code = http_response.status
678
+ response_content = http_response.body
679
+ unless (status_code == 200)
680
+ error_model = JSON.load(response_content)
681
+ fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
682
+ end
683
+
684
+ # Create Result
685
+ result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
686
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
687
+ # Deserialize Response
688
+ if status_code == 200
689
+ begin
690
+ parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
691
+ unless parsed_response.nil?
692
+ parsed_response = VirtualNetworkListResult.deserialize_object(parsed_response)
693
+ end
694
+ result.body = parsed_response
695
+ rescue Exception => e
696
+ fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
697
+ end
698
+ end
699
+
700
+ result
701
+ end
702
+
703
+ promise.execute
704
+ end
705
+
706
+ end
707
+ end