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