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,709 @@
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
+ # LoadBalancers
9
+ #
10
+ class LoadBalancers
11
+ include Azure::ARM::Network::Models
12
+ include MsRestAzure
13
+
14
+ #
15
+ # Creates and initializes a new instance of the LoadBalancers 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 loadbalancer operation deletes the specified loadbalancer.
27
+ # @param resource_group_name [String] The name of the resource group.
28
+ # @param load_balancer_name [String] The name of the loadBalancer.
29
+ # @return [Concurrent::Promise] promise which provides async access to http
30
+ # response.
31
+ #
32
+ def delete(resource_group_name, load_balancer_name, custom_headers = nil)
33
+ # Send request
34
+ promise = begin_delete(resource_group_name, load_balancer_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 loadbalancer operation deletes the specified loadbalancer.
50
+ # @param resource_group_name [String] The name of the resource group.
51
+ # @param load_balancer_name [String] The name of the loadBalancer.
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, load_balancer_name, custom_headers = nil)
59
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
60
+ fail ArgumentError, 'load_balancer_name is nil' if load_balancer_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/loadBalancers/{loadBalancerName}"
65
+ path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
66
+ path['{loadBalancerName}'] = ERB::Util.url_encode(load_balancer_name) if path.include?('{loadBalancerName}')
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 ntework interface operation retreives information about the
127
+ # specified network interface.
128
+ # @param resource_group_name [String] The name of the resource group.
129
+ # @param load_balancer_name [String] The name of the loadBalancer.
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, load_balancer_name, custom_headers = nil)
137
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
138
+ fail ArgumentError, 'load_balancer_name is nil' if load_balancer_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/loadBalancers/{loadBalancerName}"
143
+ path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
144
+ path['{loadBalancerName}'] = ERB::Util.url_encode(load_balancer_name) if path.include?('{loadBalancerName}')
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 = LoadBalancer.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 LoadBalancer operation creates/updates a LoadBalancer
218
+ # @param resource_group_name [String] The name of the resource group.
219
+ # @param load_balancer_name [String] The name of the loadBalancer.
220
+ # @param parameters [LoadBalancer] Parameters supplied to the create/delete
221
+ # LoadBalancer operation
222
+ # @param @client.api_version [String] Client Api Version.
223
+ # @param @client.subscription_id [String] Gets subscription credentials which
224
+ # uniquely identify Microsoft Azure subscription. The subscription ID forms
225
+ # part of the URI for every service call.
226
+ # @param @client.accept_language [String] Gets or sets the preferred language
227
+ # for the response.
228
+ #
229
+ # @return [Concurrent::Promise] promise which provides async access to http
230
+ # response.
231
+ #
232
+ def create_or_update(resource_group_name, load_balancer_name, parameters, custom_headers = nil)
233
+ # Send request
234
+ promise = begin_create_or_update(resource_group_name, load_balancer_name, parameters, custom_headers)
235
+
236
+ promise = promise.then do |response|
237
+ # Defining deserialization method.
238
+ deserialize_method = lambda do |parsed_response|
239
+ unless parsed_response.nil?
240
+ parsed_response = LoadBalancer.deserialize_object(parsed_response)
241
+ end
242
+ end
243
+
244
+ # Waiting for response.
245
+ @client.get_put_operation_result(response, custom_headers, deserialize_method)
246
+ end
247
+
248
+ promise
249
+ end
250
+
251
+ #
252
+ # The Put LoadBalancer operation creates/updates a LoadBalancer
253
+ # @param resource_group_name [String] The name of the resource group.
254
+ # @param load_balancer_name [String] The name of the loadBalancer.
255
+ # @param parameters [LoadBalancer] Parameters supplied to the create/delete
256
+ # LoadBalancer operation
257
+ # @param [Hash{String => String}] The hash of custom headers need to be
258
+ # applied to HTTP request.
259
+ #
260
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
261
+ # response.
262
+ #
263
+ def begin_create_or_update(resource_group_name, load_balancer_name, parameters, custom_headers = nil)
264
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
265
+ fail ArgumentError, 'load_balancer_name is nil' if load_balancer_name.nil?
266
+ fail ArgumentError, 'parameters is nil' if parameters.nil?
267
+ parameters.validate unless parameters.nil?
268
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
269
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
270
+ # Construct URL
271
+ path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}"
272
+ path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
273
+ path['{loadBalancerName}'] = ERB::Util.url_encode(load_balancer_name) if path.include?('{loadBalancerName}')
274
+ path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
275
+ url = URI.join(@client.base_url, path)
276
+ properties = {}
277
+ properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
278
+ unless url.query.nil?
279
+ url.query.split('&').each do |url_item|
280
+ url_items_parts = url_item.split('=')
281
+ properties[url_items_parts[0]] = url_items_parts[1]
282
+ end
283
+ end
284
+ properties.reject!{ |key, value| value.nil? }
285
+ url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
286
+ fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
287
+ corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
288
+ url = URI.parse(corrected_url)
289
+
290
+ connection = Faraday.new(:url => url) do |faraday|
291
+ faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
292
+ faraday.use :cookie_jar
293
+ faraday.adapter Faraday.default_adapter
294
+ end
295
+ request_headers = Hash.new
296
+
297
+ # Set Headers
298
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
299
+ request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
300
+
301
+ unless custom_headers.nil?
302
+ custom_headers.each do |key, value|
303
+ request_headers[key] = value
304
+ end
305
+ end
306
+
307
+ # Serialize Request
308
+ request_headers['Content-Type'] = 'application/json'
309
+ unless parameters.nil?
310
+ parameters = LoadBalancer.serialize_object(parameters)
311
+ end
312
+ request_content = JSON.generate(parameters, quirks_mode: true)
313
+
314
+ # Send Request
315
+ promise = Concurrent::Promise.new do
316
+ connection.put do |request|
317
+ request.headers = request_headers
318
+ request.body = request_content
319
+ @client.credentials.sign_request(request) unless @client.credentials.nil?
320
+ end
321
+ end
322
+
323
+ promise = promise.then do |http_response|
324
+ status_code = http_response.status
325
+ response_content = http_response.body
326
+ unless (status_code == 201 || status_code == 200)
327
+ error_model = JSON.load(response_content)
328
+ fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
329
+ end
330
+
331
+ # Create Result
332
+ result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
333
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
334
+ # Deserialize Response
335
+ if status_code == 201
336
+ begin
337
+ parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
338
+ unless parsed_response.nil?
339
+ parsed_response = LoadBalancer.deserialize_object(parsed_response)
340
+ end
341
+ result.body = parsed_response
342
+ rescue Exception => e
343
+ fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
344
+ end
345
+ end
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 = LoadBalancer.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
+
359
+ result
360
+ end
361
+
362
+ promise.execute
363
+ end
364
+
365
+ #
366
+ # The List loadBalancer opertion retrieves all the loadbalancers in a
367
+ # subscription.
368
+ # @param [Hash{String => String}] The hash of custom headers need to be
369
+ # applied to HTTP request.
370
+ #
371
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
372
+ # response.
373
+ #
374
+ def list_all(custom_headers = nil)
375
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
376
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
377
+ # Construct URL
378
+ path = "/subscriptions/{subscriptionId}/providers/Microsoft.Network/loadBalancers"
379
+ path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
380
+ url = URI.join(@client.base_url, path)
381
+ properties = {}
382
+ properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
383
+ unless url.query.nil?
384
+ url.query.split('&').each do |url_item|
385
+ url_items_parts = url_item.split('=')
386
+ properties[url_items_parts[0]] = url_items_parts[1]
387
+ end
388
+ end
389
+ properties.reject!{ |key, value| value.nil? }
390
+ url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
391
+ fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
392
+ corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
393
+ url = URI.parse(corrected_url)
394
+
395
+ connection = Faraday.new(:url => url) do |faraday|
396
+ faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
397
+ faraday.use :cookie_jar
398
+ faraday.adapter Faraday.default_adapter
399
+ end
400
+ request_headers = Hash.new
401
+
402
+ # Set Headers
403
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
404
+ request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
405
+
406
+ unless custom_headers.nil?
407
+ custom_headers.each do |key, value|
408
+ request_headers[key] = value
409
+ end
410
+ end
411
+
412
+ # Send Request
413
+ promise = Concurrent::Promise.new do
414
+ connection.get do |request|
415
+ request.headers = request_headers
416
+ @client.credentials.sign_request(request) unless @client.credentials.nil?
417
+ end
418
+ end
419
+
420
+ promise = promise.then do |http_response|
421
+ status_code = http_response.status
422
+ response_content = http_response.body
423
+ unless (status_code == 200)
424
+ error_model = JSON.load(response_content)
425
+ fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
426
+ end
427
+
428
+ # Create Result
429
+ result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
430
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
431
+ # Deserialize Response
432
+ if status_code == 200
433
+ begin
434
+ parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
435
+ unless parsed_response.nil?
436
+ parsed_response = LoadBalancerListResult.deserialize_object(parsed_response)
437
+ end
438
+ result.body = parsed_response
439
+ rescue Exception => e
440
+ fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
441
+ end
442
+ end
443
+
444
+ result
445
+ end
446
+
447
+ promise.execute
448
+ end
449
+
450
+ #
451
+ # The List loadBalancer opertion retrieves all the loadbalancers in a resource
452
+ # 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/loadBalancers"
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 = LoadBalancerListResult.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 loadBalancer opertion retrieves all the loadbalancers in a
540
+ # subscription.
541
+ # @param next_page_link [String] The NextLink from the previous successful
542
+ # call to List operation.
543
+ # @param [Hash{String => String}] The hash of custom headers need to be
544
+ # applied to HTTP request.
545
+ #
546
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
547
+ # response.
548
+ #
549
+ def list_all_next(next_page_link, custom_headers = nil)
550
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
551
+ # Construct URL
552
+ path = "{nextLink}"
553
+ path['{nextLink}'] = next_page_link if path.include?('{nextLink}')
554
+ url = URI.parse(path)
555
+ properties = {}
556
+ unless url.query.nil?
557
+ url.query.split('&').each do |url_item|
558
+ url_items_parts = url_item.split('=')
559
+ properties[url_items_parts[0]] = url_items_parts[1]
560
+ end
561
+ end
562
+ properties.reject!{ |key, value| value.nil? }
563
+ url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
564
+ fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
565
+ corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
566
+ url = URI.parse(corrected_url)
567
+
568
+ connection = Faraday.new(:url => url) do |faraday|
569
+ faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
570
+ faraday.use :cookie_jar
571
+ faraday.adapter Faraday.default_adapter
572
+ end
573
+ request_headers = Hash.new
574
+
575
+ # Set Headers
576
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
577
+ request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
578
+
579
+ unless custom_headers.nil?
580
+ custom_headers.each do |key, value|
581
+ request_headers[key] = value
582
+ end
583
+ end
584
+
585
+ # Send Request
586
+ promise = Concurrent::Promise.new do
587
+ connection.get do |request|
588
+ request.headers = request_headers
589
+ @client.credentials.sign_request(request) unless @client.credentials.nil?
590
+ end
591
+ end
592
+
593
+ promise = promise.then do |http_response|
594
+ status_code = http_response.status
595
+ response_content = http_response.body
596
+ unless (status_code == 200)
597
+ error_model = JSON.load(response_content)
598
+ fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
599
+ end
600
+
601
+ # Create Result
602
+ result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
603
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
604
+ # Deserialize Response
605
+ if status_code == 200
606
+ begin
607
+ parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
608
+ unless parsed_response.nil?
609
+ parsed_response = LoadBalancerListResult.deserialize_object(parsed_response)
610
+ end
611
+ result.body = parsed_response
612
+ rescue Exception => e
613
+ fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
614
+ end
615
+ end
616
+
617
+ result
618
+ end
619
+
620
+ promise.execute
621
+ end
622
+
623
+ #
624
+ # The List loadBalancer opertion retrieves all the loadbalancers in a resource
625
+ # group.
626
+ # @param next_page_link [String] The NextLink from the previous successful
627
+ # call to List operation.
628
+ # @param [Hash{String => String}] The hash of custom headers need to be
629
+ # applied to HTTP request.
630
+ #
631
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
632
+ # response.
633
+ #
634
+ def list_next(next_page_link, custom_headers = nil)
635
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
636
+ # Construct URL
637
+ path = "{nextLink}"
638
+ path['{nextLink}'] = next_page_link if path.include?('{nextLink}')
639
+ url = URI.parse(path)
640
+ properties = {}
641
+ unless url.query.nil?
642
+ url.query.split('&').each do |url_item|
643
+ url_items_parts = url_item.split('=')
644
+ properties[url_items_parts[0]] = url_items_parts[1]
645
+ end
646
+ end
647
+ properties.reject!{ |key, value| value.nil? }
648
+ url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
649
+ fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
650
+ corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
651
+ url = URI.parse(corrected_url)
652
+
653
+ connection = Faraday.new(:url => url) do |faraday|
654
+ faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
655
+ faraday.use :cookie_jar
656
+ faraday.adapter Faraday.default_adapter
657
+ end
658
+ request_headers = Hash.new
659
+
660
+ # Set Headers
661
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
662
+ request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
663
+
664
+ unless custom_headers.nil?
665
+ custom_headers.each do |key, value|
666
+ request_headers[key] = value
667
+ end
668
+ end
669
+
670
+ # Send Request
671
+ promise = Concurrent::Promise.new do
672
+ connection.get do |request|
673
+ request.headers = request_headers
674
+ @client.credentials.sign_request(request) unless @client.credentials.nil?
675
+ end
676
+ end
677
+
678
+ promise = promise.then do |http_response|
679
+ status_code = http_response.status
680
+ response_content = http_response.body
681
+ unless (status_code == 200)
682
+ error_model = JSON.load(response_content)
683
+ fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
684
+ end
685
+
686
+ # Create Result
687
+ result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
688
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
689
+ # Deserialize Response
690
+ if status_code == 200
691
+ begin
692
+ parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
693
+ unless parsed_response.nil?
694
+ parsed_response = LoadBalancerListResult.deserialize_object(parsed_response)
695
+ end
696
+ result.body = parsed_response
697
+ rescue Exception => e
698
+ fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
699
+ end
700
+ end
701
+
702
+ result
703
+ end
704
+
705
+ promise.execute
706
+ end
707
+
708
+ end
709
+ end