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,686 @@
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
+ # VirtualNetworkGateways
9
+ #
10
+ class VirtualNetworkGateways
11
+ include Azure::ARM::Network::Models
12
+ include MsRestAzure
13
+
14
+ #
15
+ # Creates and initializes a new instance of the VirtualNetworkGateways 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 Put VirtualNetworkGateway operation creates/updates a virtual network
27
+ # gateway in the specified resource group through Network resource provider.
28
+ # @param resource_group_name [String] The name of the resource group.
29
+ # @param virtual_network_gateway_name [String] The name of the virtual network
30
+ # gateway.
31
+ # @param parameters [VirtualNetworkGateway] Parameters supplied to the Begin
32
+ # Create or update Virtual Network Gateway operation through Network resource
33
+ # provider.
34
+ # @param @client.api_version [String] Client Api Version.
35
+ # @param @client.subscription_id [String] Gets subscription credentials which
36
+ # uniquely identify Microsoft Azure subscription. The subscription ID forms
37
+ # part of the URI for every service call.
38
+ # @param @client.accept_language [String] Gets or sets the preferred language
39
+ # for the response.
40
+ #
41
+ # @return [Concurrent::Promise] promise which provides async access to http
42
+ # response.
43
+ #
44
+ def create_or_update(resource_group_name, virtual_network_gateway_name, parameters, custom_headers = nil)
45
+ # Send request
46
+ promise = begin_create_or_update(resource_group_name, virtual_network_gateway_name, parameters, custom_headers)
47
+
48
+ promise = promise.then do |response|
49
+ # Defining deserialization method.
50
+ deserialize_method = lambda do |parsed_response|
51
+ unless parsed_response.nil?
52
+ parsed_response = VirtualNetworkGateway.deserialize_object(parsed_response)
53
+ end
54
+ end
55
+
56
+ # Waiting for response.
57
+ @client.get_put_operation_result(response, custom_headers, deserialize_method)
58
+ end
59
+
60
+ promise
61
+ end
62
+
63
+ #
64
+ # The Put VirtualNetworkGateway operation creates/updates a virtual network
65
+ # gateway in the specified resource group through Network resource provider.
66
+ # @param resource_group_name [String] The name of the resource group.
67
+ # @param virtual_network_gateway_name [String] The name of the virtual network
68
+ # gateway.
69
+ # @param parameters [VirtualNetworkGateway] Parameters supplied to the Begin
70
+ # Create or update Virtual Network Gateway operation through Network resource
71
+ # provider.
72
+ # @param [Hash{String => String}] The hash of custom headers need to be
73
+ # applied to HTTP request.
74
+ #
75
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
76
+ # response.
77
+ #
78
+ def begin_create_or_update(resource_group_name, virtual_network_gateway_name, parameters, custom_headers = nil)
79
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
80
+ fail ArgumentError, 'virtual_network_gateway_name is nil' if virtual_network_gateway_name.nil?
81
+ fail ArgumentError, 'parameters is nil' if parameters.nil?
82
+ parameters.validate unless parameters.nil?
83
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
84
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
85
+ # Construct URL
86
+ path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualnetworkgateways/{virtualNetworkGatewayName}"
87
+ path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
88
+ path['{virtualNetworkGatewayName}'] = ERB::Util.url_encode(virtual_network_gateway_name) if path.include?('{virtualNetworkGatewayName}')
89
+ path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
90
+ url = URI.join(@client.base_url, path)
91
+ properties = {}
92
+ properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
93
+ unless url.query.nil?
94
+ url.query.split('&').each do |url_item|
95
+ url_items_parts = url_item.split('=')
96
+ properties[url_items_parts[0]] = url_items_parts[1]
97
+ end
98
+ end
99
+ properties.reject!{ |key, value| value.nil? }
100
+ url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
101
+ fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
102
+ corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
103
+ url = URI.parse(corrected_url)
104
+
105
+ connection = Faraday.new(:url => url) do |faraday|
106
+ faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
107
+ faraday.use :cookie_jar
108
+ faraday.adapter Faraday.default_adapter
109
+ end
110
+ request_headers = Hash.new
111
+
112
+ # Set Headers
113
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
114
+ request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
115
+
116
+ unless custom_headers.nil?
117
+ custom_headers.each do |key, value|
118
+ request_headers[key] = value
119
+ end
120
+ end
121
+
122
+ # Serialize Request
123
+ request_headers['Content-Type'] = 'application/json'
124
+ unless parameters.nil?
125
+ parameters = VirtualNetworkGateway.serialize_object(parameters)
126
+ end
127
+ request_content = JSON.generate(parameters, quirks_mode: true)
128
+
129
+ # Send Request
130
+ promise = Concurrent::Promise.new do
131
+ connection.put do |request|
132
+ request.headers = request_headers
133
+ request.body = request_content
134
+ @client.credentials.sign_request(request) unless @client.credentials.nil?
135
+ end
136
+ end
137
+
138
+ promise = promise.then do |http_response|
139
+ status_code = http_response.status
140
+ response_content = http_response.body
141
+ unless (status_code == 201 || status_code == 200)
142
+ error_model = JSON.load(response_content)
143
+ fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
144
+ end
145
+
146
+ # Create Result
147
+ result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
148
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
149
+ # Deserialize Response
150
+ if status_code == 201
151
+ begin
152
+ parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
153
+ unless parsed_response.nil?
154
+ parsed_response = VirtualNetworkGateway.deserialize_object(parsed_response)
155
+ end
156
+ result.body = parsed_response
157
+ rescue Exception => e
158
+ fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
159
+ end
160
+ end
161
+ # Deserialize Response
162
+ if status_code == 200
163
+ begin
164
+ parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
165
+ unless parsed_response.nil?
166
+ parsed_response = VirtualNetworkGateway.deserialize_object(parsed_response)
167
+ end
168
+ result.body = parsed_response
169
+ rescue Exception => e
170
+ fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
171
+ end
172
+ end
173
+
174
+ result
175
+ end
176
+
177
+ promise.execute
178
+ end
179
+
180
+ #
181
+ # The Get VirtualNetworkGateway operation retrieves information about the
182
+ # specified virtual network gateway through Network resource provider.
183
+ # @param resource_group_name [String] The name of the resource group.
184
+ # @param virtual_network_gateway_name [String] The name of the virtual network
185
+ # gateway.
186
+ # @param [Hash{String => String}] The hash of custom headers need to be
187
+ # applied to HTTP request.
188
+ #
189
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
190
+ # response.
191
+ #
192
+ def get(resource_group_name, virtual_network_gateway_name, custom_headers = nil)
193
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
194
+ fail ArgumentError, 'virtual_network_gateway_name is nil' if virtual_network_gateway_name.nil?
195
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
196
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
197
+ # Construct URL
198
+ path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualnetworkgateways/{virtualNetworkGatewayName}"
199
+ path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
200
+ path['{virtualNetworkGatewayName}'] = ERB::Util.url_encode(virtual_network_gateway_name) if path.include?('{virtualNetworkGatewayName}')
201
+ path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
202
+ url = URI.join(@client.base_url, path)
203
+ properties = {}
204
+ properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
205
+ unless url.query.nil?
206
+ url.query.split('&').each do |url_item|
207
+ url_items_parts = url_item.split('=')
208
+ properties[url_items_parts[0]] = url_items_parts[1]
209
+ end
210
+ end
211
+ properties.reject!{ |key, value| value.nil? }
212
+ url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
213
+ fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
214
+ corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
215
+ url = URI.parse(corrected_url)
216
+
217
+ connection = Faraday.new(:url => url) do |faraday|
218
+ faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
219
+ faraday.use :cookie_jar
220
+ faraday.adapter Faraday.default_adapter
221
+ end
222
+ request_headers = Hash.new
223
+
224
+ # Set Headers
225
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
226
+ request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
227
+
228
+ unless custom_headers.nil?
229
+ custom_headers.each do |key, value|
230
+ request_headers[key] = value
231
+ end
232
+ end
233
+
234
+ # Send Request
235
+ promise = Concurrent::Promise.new do
236
+ connection.get do |request|
237
+ request.headers = request_headers
238
+ @client.credentials.sign_request(request) unless @client.credentials.nil?
239
+ end
240
+ end
241
+
242
+ promise = promise.then do |http_response|
243
+ status_code = http_response.status
244
+ response_content = http_response.body
245
+ unless (status_code == 200)
246
+ error_model = JSON.load(response_content)
247
+ fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
248
+ end
249
+
250
+ # Create Result
251
+ result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
252
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
253
+ # Deserialize Response
254
+ if status_code == 200
255
+ begin
256
+ parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
257
+ unless parsed_response.nil?
258
+ parsed_response = VirtualNetworkGateway.deserialize_object(parsed_response)
259
+ end
260
+ result.body = parsed_response
261
+ rescue Exception => e
262
+ fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
263
+ end
264
+ end
265
+
266
+ result
267
+ end
268
+
269
+ promise.execute
270
+ end
271
+
272
+ #
273
+ # The Delete VirtualNetworkGateway operation deletes the specifed virtual
274
+ # network Gateway through Network resource provider.
275
+ # @param resource_group_name [String] The name of the resource group.
276
+ # @param virtual_network_gateway_name [String] The name of the virtual network
277
+ # gateway.
278
+ # @return [Concurrent::Promise] promise which provides async access to http
279
+ # response.
280
+ #
281
+ def delete(resource_group_name, virtual_network_gateway_name, custom_headers = nil)
282
+ # Send request
283
+ promise = begin_delete(resource_group_name, virtual_network_gateway_name, custom_headers)
284
+
285
+ promise = promise.then do |response|
286
+ # Defining deserialization method.
287
+ deserialize_method = lambda do |parsed_response|
288
+ end
289
+
290
+ # Waiting for response.
291
+ @client.get_post_or_delete_operation_result(response, nil, deserialize_method)
292
+ end
293
+
294
+ promise
295
+ end
296
+
297
+ #
298
+ # The Delete VirtualNetworkGateway operation deletes the specifed virtual
299
+ # network Gateway through Network resource provider.
300
+ # @param resource_group_name [String] The name of the resource group.
301
+ # @param virtual_network_gateway_name [String] The name of the virtual network
302
+ # gateway.
303
+ # @param [Hash{String => String}] The hash of custom headers need to be
304
+ # applied to HTTP request.
305
+ #
306
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
307
+ # response.
308
+ #
309
+ def begin_delete(resource_group_name, virtual_network_gateway_name, custom_headers = nil)
310
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
311
+ fail ArgumentError, 'virtual_network_gateway_name is nil' if virtual_network_gateway_name.nil?
312
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
313
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
314
+ # Construct URL
315
+ path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/"
316
+ path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
317
+ path['{virtualNetworkGatewayName}'] = ERB::Util.url_encode(virtual_network_gateway_name) if path.include?('{virtualNetworkGatewayName}')
318
+ path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
319
+ url = URI.join(@client.base_url, path)
320
+ properties = {}
321
+ properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
322
+ unless url.query.nil?
323
+ url.query.split('&').each do |url_item|
324
+ url_items_parts = url_item.split('=')
325
+ properties[url_items_parts[0]] = url_items_parts[1]
326
+ end
327
+ end
328
+ properties.reject!{ |key, value| value.nil? }
329
+ url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
330
+ fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
331
+ corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
332
+ url = URI.parse(corrected_url)
333
+
334
+ connection = Faraday.new(:url => url) do |faraday|
335
+ faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
336
+ faraday.use :cookie_jar
337
+ faraday.adapter Faraday.default_adapter
338
+ end
339
+ request_headers = Hash.new
340
+
341
+ # Set Headers
342
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
343
+ request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
344
+
345
+ unless custom_headers.nil?
346
+ custom_headers.each do |key, value|
347
+ request_headers[key] = value
348
+ end
349
+ end
350
+
351
+ # Send Request
352
+ promise = Concurrent::Promise.new do
353
+ connection.delete do |request|
354
+ request.headers = request_headers
355
+ @client.credentials.sign_request(request) unless @client.credentials.nil?
356
+ end
357
+ end
358
+
359
+ promise = promise.then do |http_response|
360
+ status_code = http_response.status
361
+ response_content = http_response.body
362
+ unless (status_code == 202 || status_code == 200 || status_code == 204)
363
+ fail MsRestAzure::AzureOperationError.new(connection, http_response)
364
+ end
365
+
366
+ # Create Result
367
+ result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
368
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
369
+
370
+ result
371
+ end
372
+
373
+ promise.execute
374
+ end
375
+
376
+ #
377
+ # The List VirtualNetworkGateways opertion retrieves all the virtual network
378
+ # gateways stored.
379
+ # @param resource_group_name [String] The name of the resource group.
380
+ # @param [Hash{String => String}] The hash of custom headers need to be
381
+ # applied to HTTP request.
382
+ #
383
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
384
+ # response.
385
+ #
386
+ def list(resource_group_name, custom_headers = nil)
387
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
388
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
389
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
390
+ # Construct URL
391
+ path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways"
392
+ path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
393
+ path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
394
+ url = URI.join(@client.base_url, path)
395
+ properties = {}
396
+ properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
397
+ unless url.query.nil?
398
+ url.query.split('&').each do |url_item|
399
+ url_items_parts = url_item.split('=')
400
+ properties[url_items_parts[0]] = url_items_parts[1]
401
+ end
402
+ end
403
+ properties.reject!{ |key, value| value.nil? }
404
+ url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
405
+ fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
406
+ corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
407
+ url = URI.parse(corrected_url)
408
+
409
+ connection = Faraday.new(:url => url) do |faraday|
410
+ faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
411
+ faraday.use :cookie_jar
412
+ faraday.adapter Faraday.default_adapter
413
+ end
414
+ request_headers = Hash.new
415
+
416
+ # Set Headers
417
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
418
+ request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
419
+
420
+ unless custom_headers.nil?
421
+ custom_headers.each do |key, value|
422
+ request_headers[key] = value
423
+ end
424
+ end
425
+
426
+ # Send Request
427
+ promise = Concurrent::Promise.new do
428
+ connection.get do |request|
429
+ request.headers = request_headers
430
+ @client.credentials.sign_request(request) unless @client.credentials.nil?
431
+ end
432
+ end
433
+
434
+ promise = promise.then do |http_response|
435
+ status_code = http_response.status
436
+ response_content = http_response.body
437
+ unless (status_code == 200)
438
+ error_model = JSON.load(response_content)
439
+ fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
440
+ end
441
+
442
+ # Create Result
443
+ result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
444
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
445
+ # Deserialize Response
446
+ if status_code == 200
447
+ begin
448
+ parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
449
+ unless parsed_response.nil?
450
+ parsed_response = VirtualNetworkGatewayListResult.deserialize_object(parsed_response)
451
+ end
452
+ result.body = parsed_response
453
+ rescue Exception => e
454
+ fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
455
+ end
456
+ end
457
+
458
+ result
459
+ end
460
+
461
+ promise.execute
462
+ end
463
+
464
+ #
465
+ # The Reset VirtualNetworkGateway operation resets the primary of the virtual
466
+ # network gatewayin the specified resource group through Network resource
467
+ # provider.
468
+ # @param resource_group_name [String] The name of the resource group.
469
+ # @param virtual_network_gateway_name [String] The name of the virtual network
470
+ # gateway.
471
+ # @param parameters [VirtualNetworkGateway] Parameters supplied to the Begin
472
+ # Reset Virtual Network Gateway operation through Network resource provider.
473
+ # @return [Concurrent::Promise] promise which provides async access to http
474
+ # response.
475
+ #
476
+ def reset(resource_group_name, virtual_network_gateway_name, parameters, custom_headers = nil)
477
+ # Send request
478
+ promise = begin_reset(resource_group_name, virtual_network_gateway_name, parameters, custom_headers)
479
+
480
+ promise = promise.then do |response|
481
+ # Defining deserialization method.
482
+ deserialize_method = lambda do |parsed_response|
483
+ unless parsed_response.nil?
484
+ parsed_response = VirtualNetworkGateway.deserialize_object(parsed_response)
485
+ end
486
+ end
487
+
488
+ # Waiting for response.
489
+ @client.get_post_or_delete_operation_result(response, nil, deserialize_method)
490
+ end
491
+
492
+ promise
493
+ end
494
+
495
+ #
496
+ # The Reset VirtualNetworkGateway operation resets the primary of the virtual
497
+ # network gatewayin the specified resource group through Network resource
498
+ # provider.
499
+ # @param resource_group_name [String] The name of the resource group.
500
+ # @param virtual_network_gateway_name [String] The name of the virtual network
501
+ # gateway.
502
+ # @param parameters [VirtualNetworkGateway] Parameters supplied to the Begin
503
+ # Reset Virtual Network Gateway operation through Network resource provider.
504
+ # @param [Hash{String => String}] The hash of custom headers need to be
505
+ # applied to HTTP request.
506
+ #
507
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
508
+ # response.
509
+ #
510
+ def begin_reset(resource_group_name, virtual_network_gateway_name, parameters, custom_headers = nil)
511
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
512
+ fail ArgumentError, 'virtual_network_gateway_name is nil' if virtual_network_gateway_name.nil?
513
+ fail ArgumentError, 'parameters is nil' if parameters.nil?
514
+ parameters.validate unless parameters.nil?
515
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
516
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
517
+ # Construct URL
518
+ path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualnetworkgateways/{virtualNetworkGatewayName}/reset"
519
+ path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
520
+ path['{virtualNetworkGatewayName}'] = ERB::Util.url_encode(virtual_network_gateway_name) if path.include?('{virtualNetworkGatewayName}')
521
+ path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
522
+ url = URI.join(@client.base_url, path)
523
+ properties = {}
524
+ properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
525
+ unless url.query.nil?
526
+ url.query.split('&').each do |url_item|
527
+ url_items_parts = url_item.split('=')
528
+ properties[url_items_parts[0]] = url_items_parts[1]
529
+ end
530
+ end
531
+ properties.reject!{ |key, value| value.nil? }
532
+ url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
533
+ fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
534
+ corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
535
+ url = URI.parse(corrected_url)
536
+
537
+ connection = Faraday.new(:url => url) do |faraday|
538
+ faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
539
+ faraday.use :cookie_jar
540
+ faraday.adapter Faraday.default_adapter
541
+ end
542
+ request_headers = Hash.new
543
+
544
+ # Set Headers
545
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
546
+ request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
547
+
548
+ unless custom_headers.nil?
549
+ custom_headers.each do |key, value|
550
+ request_headers[key] = value
551
+ end
552
+ end
553
+
554
+ # Serialize Request
555
+ request_headers['Content-Type'] = 'application/json'
556
+ unless parameters.nil?
557
+ parameters = VirtualNetworkGateway.serialize_object(parameters)
558
+ end
559
+ request_content = JSON.generate(parameters, quirks_mode: true)
560
+
561
+ # Send Request
562
+ promise = Concurrent::Promise.new do
563
+ connection.post do |request|
564
+ request.headers = request_headers
565
+ request.body = request_content
566
+ @client.credentials.sign_request(request) unless @client.credentials.nil?
567
+ end
568
+ end
569
+
570
+ promise = promise.then do |http_response|
571
+ status_code = http_response.status
572
+ response_content = http_response.body
573
+ unless (status_code == 202 || status_code == 200)
574
+ error_model = JSON.load(response_content)
575
+ fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
576
+ end
577
+
578
+ # Create Result
579
+ result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
580
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
581
+ # Deserialize Response
582
+ if status_code == 200
583
+ begin
584
+ parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
585
+ unless parsed_response.nil?
586
+ parsed_response = VirtualNetworkGateway.deserialize_object(parsed_response)
587
+ end
588
+ result.body = parsed_response
589
+ rescue Exception => e
590
+ fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
591
+ end
592
+ end
593
+
594
+ result
595
+ end
596
+
597
+ promise.execute
598
+ end
599
+
600
+ #
601
+ # The List VirtualNetworkGateways opertion retrieves all the virtual network
602
+ # gateways stored.
603
+ # @param next_page_link [String] The NextLink from the previous successful
604
+ # call to List operation.
605
+ # @param [Hash{String => String}] The hash of custom headers need to be
606
+ # applied to HTTP request.
607
+ #
608
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
609
+ # response.
610
+ #
611
+ def list_next(next_page_link, custom_headers = nil)
612
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
613
+ # Construct URL
614
+ path = "{nextLink}"
615
+ path['{nextLink}'] = next_page_link if path.include?('{nextLink}')
616
+ url = URI.parse(path)
617
+ properties = {}
618
+ unless url.query.nil?
619
+ url.query.split('&').each do |url_item|
620
+ url_items_parts = url_item.split('=')
621
+ properties[url_items_parts[0]] = url_items_parts[1]
622
+ end
623
+ end
624
+ properties.reject!{ |key, value| value.nil? }
625
+ url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
626
+ fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
627
+ corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
628
+ url = URI.parse(corrected_url)
629
+
630
+ connection = Faraday.new(:url => url) do |faraday|
631
+ faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
632
+ faraday.use :cookie_jar
633
+ faraday.adapter Faraday.default_adapter
634
+ end
635
+ request_headers = Hash.new
636
+
637
+ # Set Headers
638
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
639
+ request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
640
+
641
+ unless custom_headers.nil?
642
+ custom_headers.each do |key, value|
643
+ request_headers[key] = value
644
+ end
645
+ end
646
+
647
+ # Send Request
648
+ promise = Concurrent::Promise.new do
649
+ connection.get do |request|
650
+ request.headers = request_headers
651
+ @client.credentials.sign_request(request) unless @client.credentials.nil?
652
+ end
653
+ end
654
+
655
+ promise = promise.then do |http_response|
656
+ status_code = http_response.status
657
+ response_content = http_response.body
658
+ unless (status_code == 200)
659
+ error_model = JSON.load(response_content)
660
+ fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
661
+ end
662
+
663
+ # Create Result
664
+ result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
665
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
666
+ # Deserialize Response
667
+ if status_code == 200
668
+ begin
669
+ parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
670
+ unless parsed_response.nil?
671
+ parsed_response = VirtualNetworkGatewayListResult.deserialize_object(parsed_response)
672
+ end
673
+ result.body = parsed_response
674
+ rescue Exception => e
675
+ fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
676
+ end
677
+ end
678
+
679
+ result
680
+ end
681
+
682
+ promise.execute
683
+ end
684
+
685
+ end
686
+ end