azure_mgmt_traffic_manager 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,52 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure::ARM::TrafficManager
7
+ module Models
8
+ #
9
+ # The list Traffic Manager profiles operation response.
10
+ #
11
+ class ProfileListResult
12
+
13
+ include MsRestAzure
14
+
15
+ # @return [Array<Profile>] Gets the list of Traffic manager profiles.
16
+ attr_accessor :value
17
+
18
+
19
+ #
20
+ # Mapper for ProfileListResult class as Ruby Hash.
21
+ # This will be used for serialization/deserialization.
22
+ #
23
+ def self.mapper()
24
+ {
25
+ required: false,
26
+ serialized_name: 'ProfileListResult',
27
+ type: {
28
+ name: 'Composite',
29
+ class_name: 'ProfileListResult',
30
+ model_properties: {
31
+ value: {
32
+ required: false,
33
+ serialized_name: 'value',
34
+ type: {
35
+ name: 'Sequence',
36
+ element: {
37
+ required: false,
38
+ serialized_name: 'ProfileElementType',
39
+ type: {
40
+ name: 'Composite',
41
+ class_name: 'Profile'
42
+ }
43
+ }
44
+ }
45
+ }
46
+ }
47
+ }
48
+ }
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,87 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure::ARM::TrafficManager
7
+ module Models
8
+ #
9
+ # Class representing a Traffic Manager Name Availability response.
10
+ #
11
+ class TrafficManagerNameAvailability
12
+
13
+ include MsRestAzure
14
+
15
+ # @return [String] The relative name.
16
+ attr_accessor :name
17
+
18
+ # @return [String] Traffic Manager profile resource type.
19
+ attr_accessor :type
20
+
21
+ # @return [Boolean] Describes whether the relative name is available or
22
+ # not.
23
+ attr_accessor :name_available
24
+
25
+ # @return [String] The reason why the name is not available, when
26
+ # applicable.
27
+ attr_accessor :reason
28
+
29
+ # @return [String] Descriptive message that explains why the name is not
30
+ # available, when applicable.
31
+ attr_accessor :message
32
+
33
+
34
+ #
35
+ # Mapper for TrafficManagerNameAvailability class as Ruby Hash.
36
+ # This will be used for serialization/deserialization.
37
+ #
38
+ def self.mapper()
39
+ {
40
+ required: false,
41
+ serialized_name: 'TrafficManagerNameAvailability',
42
+ type: {
43
+ name: 'Composite',
44
+ class_name: 'TrafficManagerNameAvailability',
45
+ model_properties: {
46
+ name: {
47
+ required: false,
48
+ serialized_name: 'name',
49
+ type: {
50
+ name: 'String'
51
+ }
52
+ },
53
+ type: {
54
+ required: false,
55
+ serialized_name: 'type',
56
+ type: {
57
+ name: 'String'
58
+ }
59
+ },
60
+ name_available: {
61
+ required: false,
62
+ serialized_name: 'nameAvailable',
63
+ type: {
64
+ name: 'Boolean'
65
+ }
66
+ },
67
+ reason: {
68
+ required: false,
69
+ serialized_name: 'reason',
70
+ type: {
71
+ name: 'String'
72
+ }
73
+ },
74
+ message: {
75
+ required: false,
76
+ serialized_name: 'message',
77
+ type: {
78
+ name: 'String'
79
+ }
80
+ }
81
+ }
82
+ }
83
+ }
84
+ end
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,8 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure end
7
+ module Azure::ARM end
8
+ module Azure::ARM::TrafficManager end
@@ -0,0 +1,732 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure::ARM::TrafficManager
7
+ #
8
+ # Profiles
9
+ #
10
+ class Profiles
11
+ include Azure::ARM::TrafficManager::Models
12
+ include MsRestAzure
13
+
14
+ #
15
+ # Creates and initializes a new instance of the Profiles 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 TrafficManagerManagementClient
23
+ attr_reader :client
24
+
25
+ #
26
+ # Checks the availability of a Traffic Manager Relative DNS name.
27
+ #
28
+ # @param parameters [CheckTrafficManagerRelativeDnsNameAvailabilityParameters]
29
+ # The Traffic Manager name parameters supplied to the
30
+ # CheckTrafficManagerNameAvailability operation.
31
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
32
+ # will be added to the HTTP request.
33
+ #
34
+ # @return [TrafficManagerNameAvailability] operation results.
35
+ #
36
+ def check_traffic_manager_relative_dns_name_availability(parameters, custom_headers = nil)
37
+ response = check_traffic_manager_relative_dns_name_availability_async(parameters, custom_headers).value!
38
+ response.body unless response.nil?
39
+ end
40
+
41
+ #
42
+ # Checks the availability of a Traffic Manager Relative DNS name.
43
+ #
44
+ # @param parameters [CheckTrafficManagerRelativeDnsNameAvailabilityParameters]
45
+ # The Traffic Manager name parameters supplied to the
46
+ # CheckTrafficManagerNameAvailability operation.
47
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
48
+ # will be added to the HTTP request.
49
+ #
50
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
51
+ #
52
+ def check_traffic_manager_relative_dns_name_availability_with_http_info(parameters, custom_headers = nil)
53
+ check_traffic_manager_relative_dns_name_availability_async(parameters, custom_headers).value!
54
+ end
55
+
56
+ #
57
+ # Checks the availability of a Traffic Manager Relative DNS name.
58
+ #
59
+ # @param parameters [CheckTrafficManagerRelativeDnsNameAvailabilityParameters]
60
+ # The Traffic Manager name parameters supplied to the
61
+ # CheckTrafficManagerNameAvailability operation.
62
+ # @param [Hash{String => String}] A hash of custom headers that will be added
63
+ # to the HTTP request.
64
+ #
65
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
66
+ #
67
+ def check_traffic_manager_relative_dns_name_availability_async(parameters, custom_headers = nil)
68
+ fail ArgumentError, 'parameters is nil' if parameters.nil?
69
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
70
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
71
+
72
+
73
+ request_headers = {}
74
+
75
+ # Set Headers
76
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
77
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
78
+
79
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
80
+
81
+ # Serialize Request
82
+ request_mapper = CheckTrafficManagerRelativeDnsNameAvailabilityParameters.mapper()
83
+ request_content = @client.serialize(request_mapper, parameters, 'parameters')
84
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
85
+
86
+ path_template = '/providers/Microsoft.Network/checkTrafficManagerNameAvailability'
87
+ options = {
88
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
89
+ path_params: {'subscriptionId' => @client.subscription_id},
90
+ query_params: {'api-version' => @client.api_version},
91
+ body: request_content,
92
+ headers: request_headers.merge(custom_headers || {})
93
+ }
94
+
95
+ request_url = @base_url || @client.base_url
96
+
97
+ request = MsRest::HttpOperationRequest.new(request_url, path_template, :post, options)
98
+ promise = request.run_promise do |req|
99
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
100
+ end
101
+
102
+ promise = promise.then do |http_response|
103
+ status_code = http_response.status
104
+ response_content = http_response.body
105
+ unless status_code == 200
106
+ error_model = JSON.load(response_content)
107
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
108
+ end
109
+
110
+ # Create Result
111
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
112
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
113
+ # Deserialize Response
114
+ if status_code == 200
115
+ begin
116
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
117
+ result_mapper = TrafficManagerNameAvailability.mapper()
118
+ result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
119
+ rescue Exception => e
120
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
121
+ end
122
+ end
123
+
124
+ result
125
+ end
126
+
127
+ promise.execute
128
+ end
129
+
130
+ #
131
+ # Lists all Traffic Manager profiles within a resource group.
132
+ #
133
+ # @param resource_group_name [String] The name of the resource group
134
+ # containing the Traffic Manager profiles to be listed.
135
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
136
+ # will be added to the HTTP request.
137
+ #
138
+ # @return [ProfileListResult] operation results.
139
+ #
140
+ def list_all_in_resource_group(resource_group_name, custom_headers = nil)
141
+ response = list_all_in_resource_group_async(resource_group_name, custom_headers).value!
142
+ response.body unless response.nil?
143
+ end
144
+
145
+ #
146
+ # Lists all Traffic Manager profiles within a resource group.
147
+ #
148
+ # @param resource_group_name [String] The name of the resource group
149
+ # containing the Traffic Manager profiles to be listed.
150
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
151
+ # will be added to the HTTP request.
152
+ #
153
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
154
+ #
155
+ def list_all_in_resource_group_with_http_info(resource_group_name, custom_headers = nil)
156
+ list_all_in_resource_group_async(resource_group_name, custom_headers).value!
157
+ end
158
+
159
+ #
160
+ # Lists all Traffic Manager profiles within a resource group.
161
+ #
162
+ # @param resource_group_name [String] The name of the resource group
163
+ # containing the Traffic Manager profiles to be listed.
164
+ # @param [Hash{String => String}] A hash of custom headers that will be added
165
+ # to the HTTP request.
166
+ #
167
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
168
+ #
169
+ def list_all_in_resource_group_async(resource_group_name, custom_headers = nil)
170
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
171
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
172
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
173
+
174
+
175
+ request_headers = {}
176
+
177
+ # Set Headers
178
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
179
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
180
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles'
181
+ options = {
182
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
183
+ path_params: {'resourceGroupName' => resource_group_name,'subscriptionId' => @client.subscription_id},
184
+ query_params: {'api-version' => @client.api_version},
185
+ headers: request_headers.merge(custom_headers || {})
186
+ }
187
+
188
+ request_url = @base_url || @client.base_url
189
+
190
+ request = MsRest::HttpOperationRequest.new(request_url, path_template, :get, options)
191
+ promise = request.run_promise do |req|
192
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
193
+ end
194
+
195
+ promise = promise.then do |http_response|
196
+ status_code = http_response.status
197
+ response_content = http_response.body
198
+ unless status_code == 200
199
+ error_model = JSON.load(response_content)
200
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
201
+ end
202
+
203
+ # Create Result
204
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
205
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
206
+ # Deserialize Response
207
+ if status_code == 200
208
+ begin
209
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
210
+ result_mapper = ProfileListResult.mapper()
211
+ result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
212
+ rescue Exception => e
213
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
214
+ end
215
+ end
216
+
217
+ result
218
+ end
219
+
220
+ promise.execute
221
+ end
222
+
223
+ #
224
+ # Lists all Traffic Manager profiles within a subscription.
225
+ #
226
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
227
+ # will be added to the HTTP request.
228
+ #
229
+ # @return [ProfileListResult] operation results.
230
+ #
231
+ def list_all(custom_headers = nil)
232
+ response = list_all_async(custom_headers).value!
233
+ response.body unless response.nil?
234
+ end
235
+
236
+ #
237
+ # Lists all Traffic Manager profiles within a subscription.
238
+ #
239
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
240
+ # will be added to the HTTP request.
241
+ #
242
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
243
+ #
244
+ def list_all_with_http_info(custom_headers = nil)
245
+ list_all_async(custom_headers).value!
246
+ end
247
+
248
+ #
249
+ # Lists all Traffic Manager profiles within a subscription.
250
+ #
251
+ # @param [Hash{String => String}] A hash of custom headers that will be added
252
+ # to the HTTP request.
253
+ #
254
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
255
+ #
256
+ def list_all_async(custom_headers = nil)
257
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
258
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
259
+
260
+
261
+ request_headers = {}
262
+
263
+ # Set Headers
264
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
265
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
266
+ path_template = '/subscriptions/{subscriptionId}/providers/Microsoft.Network/trafficmanagerprofiles'
267
+ options = {
268
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
269
+ path_params: {'subscriptionId' => @client.subscription_id},
270
+ query_params: {'api-version' => @client.api_version},
271
+ headers: request_headers.merge(custom_headers || {})
272
+ }
273
+
274
+ request_url = @base_url || @client.base_url
275
+
276
+ request = MsRest::HttpOperationRequest.new(request_url, path_template, :get, options)
277
+ promise = request.run_promise do |req|
278
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
279
+ end
280
+
281
+ promise = promise.then do |http_response|
282
+ status_code = http_response.status
283
+ response_content = http_response.body
284
+ unless status_code == 200
285
+ error_model = JSON.load(response_content)
286
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
287
+ end
288
+
289
+ # Create Result
290
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
291
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
292
+ # Deserialize Response
293
+ if status_code == 200
294
+ begin
295
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
296
+ result_mapper = ProfileListResult.mapper()
297
+ result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
298
+ rescue Exception => e
299
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
300
+ end
301
+ end
302
+
303
+ result
304
+ end
305
+
306
+ promise.execute
307
+ end
308
+
309
+ #
310
+ # Gets a Traffic Manager profile.
311
+ #
312
+ # @param resource_group_name [String] The name of the resource group
313
+ # containing the Traffic Manager profile.
314
+ # @param profile_name [String] The name of the Traffic Manager profile.
315
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
316
+ # will be added to the HTTP request.
317
+ #
318
+ # @return [Profile] operation results.
319
+ #
320
+ def get(resource_group_name, profile_name, custom_headers = nil)
321
+ response = get_async(resource_group_name, profile_name, custom_headers).value!
322
+ response.body unless response.nil?
323
+ end
324
+
325
+ #
326
+ # Gets a Traffic Manager profile.
327
+ #
328
+ # @param resource_group_name [String] The name of the resource group
329
+ # containing the Traffic Manager profile.
330
+ # @param profile_name [String] The name of the Traffic Manager profile.
331
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
332
+ # will be added to the HTTP request.
333
+ #
334
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
335
+ #
336
+ def get_with_http_info(resource_group_name, profile_name, custom_headers = nil)
337
+ get_async(resource_group_name, profile_name, custom_headers).value!
338
+ end
339
+
340
+ #
341
+ # Gets a Traffic Manager profile.
342
+ #
343
+ # @param resource_group_name [String] The name of the resource group
344
+ # containing the Traffic Manager profile.
345
+ # @param profile_name [String] The name of the Traffic Manager profile.
346
+ # @param [Hash{String => String}] A hash of custom headers that will be added
347
+ # to the HTTP request.
348
+ #
349
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
350
+ #
351
+ def get_async(resource_group_name, profile_name, custom_headers = nil)
352
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
353
+ fail ArgumentError, 'profile_name is nil' if profile_name.nil?
354
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
355
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
356
+
357
+
358
+ request_headers = {}
359
+
360
+ # Set Headers
361
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
362
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
363
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}'
364
+ options = {
365
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
366
+ path_params: {'resourceGroupName' => resource_group_name,'profileName' => profile_name,'subscriptionId' => @client.subscription_id},
367
+ query_params: {'api-version' => @client.api_version},
368
+ headers: request_headers.merge(custom_headers || {})
369
+ }
370
+
371
+ request_url = @base_url || @client.base_url
372
+
373
+ request = MsRest::HttpOperationRequest.new(request_url, path_template, :get, options)
374
+ promise = request.run_promise do |req|
375
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
376
+ end
377
+
378
+ promise = promise.then do |http_response|
379
+ status_code = http_response.status
380
+ response_content = http_response.body
381
+ unless status_code == 200
382
+ error_model = JSON.load(response_content)
383
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
384
+ end
385
+
386
+ # Create Result
387
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
388
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
389
+ # Deserialize Response
390
+ if status_code == 200
391
+ begin
392
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
393
+ result_mapper = Profile.mapper()
394
+ result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
395
+ rescue Exception => e
396
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
397
+ end
398
+ end
399
+
400
+ result
401
+ end
402
+
403
+ promise.execute
404
+ end
405
+
406
+ #
407
+ # Create or update a Traffic Manager profile.
408
+ #
409
+ # @param resource_group_name [String] The name of the resource group
410
+ # containing the Traffic Manager profile.
411
+ # @param profile_name [String] The name of the Traffic Manager profile.
412
+ # @param parameters [Profile] The Traffic Manager profile parameters supplied
413
+ # to the CreateOrUpdate operation.
414
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
415
+ # will be added to the HTTP request.
416
+ #
417
+ # @return [Profile] operation results.
418
+ #
419
+ def create_or_update(resource_group_name, profile_name, parameters, custom_headers = nil)
420
+ response = create_or_update_async(resource_group_name, profile_name, parameters, custom_headers).value!
421
+ response.body unless response.nil?
422
+ end
423
+
424
+ #
425
+ # Create or update a Traffic Manager profile.
426
+ #
427
+ # @param resource_group_name [String] The name of the resource group
428
+ # containing the Traffic Manager profile.
429
+ # @param profile_name [String] The name of the Traffic Manager profile.
430
+ # @param parameters [Profile] The Traffic Manager profile parameters supplied
431
+ # to the CreateOrUpdate operation.
432
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
433
+ # will be added to the HTTP request.
434
+ #
435
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
436
+ #
437
+ def create_or_update_with_http_info(resource_group_name, profile_name, parameters, custom_headers = nil)
438
+ create_or_update_async(resource_group_name, profile_name, parameters, custom_headers).value!
439
+ end
440
+
441
+ #
442
+ # Create or update a Traffic Manager profile.
443
+ #
444
+ # @param resource_group_name [String] The name of the resource group
445
+ # containing the Traffic Manager profile.
446
+ # @param profile_name [String] The name of the Traffic Manager profile.
447
+ # @param parameters [Profile] The Traffic Manager profile parameters supplied
448
+ # to the CreateOrUpdate operation.
449
+ # @param [Hash{String => String}] A hash of custom headers that will be added
450
+ # to the HTTP request.
451
+ #
452
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
453
+ #
454
+ def create_or_update_async(resource_group_name, profile_name, parameters, custom_headers = nil)
455
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
456
+ fail ArgumentError, 'profile_name is nil' if profile_name.nil?
457
+ fail ArgumentError, 'parameters is nil' if parameters.nil?
458
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
459
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
460
+
461
+
462
+ request_headers = {}
463
+
464
+ # Set Headers
465
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
466
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
467
+
468
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
469
+
470
+ # Serialize Request
471
+ request_mapper = Profile.mapper()
472
+ request_content = @client.serialize(request_mapper, parameters, 'parameters')
473
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
474
+
475
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}'
476
+ options = {
477
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
478
+ path_params: {'resourceGroupName' => resource_group_name,'profileName' => profile_name,'subscriptionId' => @client.subscription_id},
479
+ query_params: {'api-version' => @client.api_version},
480
+ body: request_content,
481
+ headers: request_headers.merge(custom_headers || {})
482
+ }
483
+
484
+ request_url = @base_url || @client.base_url
485
+
486
+ request = MsRest::HttpOperationRequest.new(request_url, path_template, :put, options)
487
+ promise = request.run_promise do |req|
488
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
489
+ end
490
+
491
+ promise = promise.then do |http_response|
492
+ status_code = http_response.status
493
+ response_content = http_response.body
494
+ unless status_code == 200 || status_code == 201
495
+ error_model = JSON.load(response_content)
496
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
497
+ end
498
+
499
+ # Create Result
500
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
501
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
502
+ # Deserialize Response
503
+ if status_code == 200
504
+ begin
505
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
506
+ result_mapper = Profile.mapper()
507
+ result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
508
+ rescue Exception => e
509
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
510
+ end
511
+ end
512
+ # Deserialize Response
513
+ if status_code == 201
514
+ begin
515
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
516
+ result_mapper = Profile.mapper()
517
+ result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
518
+ rescue Exception => e
519
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
520
+ end
521
+ end
522
+
523
+ result
524
+ end
525
+
526
+ promise.execute
527
+ end
528
+
529
+ #
530
+ # Deletes a Traffic Manager profile.
531
+ #
532
+ # @param resource_group_name [String] The name of the resource group
533
+ # containing the Traffic Manager profile to be deleted.
534
+ # @param profile_name [String] The name of the Traffic Manager profile to be
535
+ # deleted.
536
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
537
+ # will be added to the HTTP request.
538
+ #
539
+ #
540
+ def delete(resource_group_name, profile_name, custom_headers = nil)
541
+ response = delete_async(resource_group_name, profile_name, custom_headers).value!
542
+ nil
543
+ end
544
+
545
+ #
546
+ # Deletes a Traffic Manager profile.
547
+ #
548
+ # @param resource_group_name [String] The name of the resource group
549
+ # containing the Traffic Manager profile to be deleted.
550
+ # @param profile_name [String] The name of the Traffic Manager profile to be
551
+ # deleted.
552
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
553
+ # will be added to the HTTP request.
554
+ #
555
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
556
+ #
557
+ def delete_with_http_info(resource_group_name, profile_name, custom_headers = nil)
558
+ delete_async(resource_group_name, profile_name, custom_headers).value!
559
+ end
560
+
561
+ #
562
+ # Deletes a Traffic Manager profile.
563
+ #
564
+ # @param resource_group_name [String] The name of the resource group
565
+ # containing the Traffic Manager profile to be deleted.
566
+ # @param profile_name [String] The name of the Traffic Manager profile to be
567
+ # deleted.
568
+ # @param [Hash{String => String}] A hash of custom headers that will be added
569
+ # to the HTTP request.
570
+ #
571
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
572
+ #
573
+ def delete_async(resource_group_name, profile_name, custom_headers = nil)
574
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
575
+ fail ArgumentError, 'profile_name is nil' if profile_name.nil?
576
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
577
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
578
+
579
+
580
+ request_headers = {}
581
+
582
+ # Set Headers
583
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
584
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
585
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}'
586
+ options = {
587
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
588
+ path_params: {'resourceGroupName' => resource_group_name,'profileName' => profile_name,'subscriptionId' => @client.subscription_id},
589
+ query_params: {'api-version' => @client.api_version},
590
+ headers: request_headers.merge(custom_headers || {})
591
+ }
592
+
593
+ request_url = @base_url || @client.base_url
594
+
595
+ request = MsRest::HttpOperationRequest.new(request_url, path_template, :delete, options)
596
+ promise = request.run_promise do |req|
597
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
598
+ end
599
+
600
+ promise = promise.then do |http_response|
601
+ status_code = http_response.status
602
+ response_content = http_response.body
603
+ unless status_code == 200 || status_code == 204
604
+ error_model = JSON.load(response_content)
605
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
606
+ end
607
+
608
+ # Create Result
609
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
610
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
611
+
612
+ result
613
+ end
614
+
615
+ promise.execute
616
+ end
617
+
618
+ #
619
+ # Update a Traffic Manager profile.
620
+ #
621
+ # @param resource_group_name [String] The name of the resource group
622
+ # containing the Traffic Manager profile.
623
+ # @param profile_name [String] The name of the Traffic Manager profile.
624
+ # @param parameters [Profile] The Traffic Manager profile parameters supplied
625
+ # to the Update operation.
626
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
627
+ # will be added to the HTTP request.
628
+ #
629
+ # @return [Profile] operation results.
630
+ #
631
+ def update(resource_group_name, profile_name, parameters, custom_headers = nil)
632
+ response = update_async(resource_group_name, profile_name, parameters, custom_headers).value!
633
+ response.body unless response.nil?
634
+ end
635
+
636
+ #
637
+ # Update a Traffic Manager profile.
638
+ #
639
+ # @param resource_group_name [String] The name of the resource group
640
+ # containing the Traffic Manager profile.
641
+ # @param profile_name [String] The name of the Traffic Manager profile.
642
+ # @param parameters [Profile] The Traffic Manager profile parameters supplied
643
+ # to the Update operation.
644
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
645
+ # will be added to the HTTP request.
646
+ #
647
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
648
+ #
649
+ def update_with_http_info(resource_group_name, profile_name, parameters, custom_headers = nil)
650
+ update_async(resource_group_name, profile_name, parameters, custom_headers).value!
651
+ end
652
+
653
+ #
654
+ # Update a Traffic Manager profile.
655
+ #
656
+ # @param resource_group_name [String] The name of the resource group
657
+ # containing the Traffic Manager profile.
658
+ # @param profile_name [String] The name of the Traffic Manager profile.
659
+ # @param parameters [Profile] The Traffic Manager profile parameters supplied
660
+ # to the Update operation.
661
+ # @param [Hash{String => String}] A hash of custom headers that will be added
662
+ # to the HTTP request.
663
+ #
664
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
665
+ #
666
+ def update_async(resource_group_name, profile_name, parameters, custom_headers = nil)
667
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
668
+ fail ArgumentError, 'profile_name is nil' if profile_name.nil?
669
+ fail ArgumentError, 'parameters is nil' if parameters.nil?
670
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
671
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
672
+
673
+
674
+ request_headers = {}
675
+
676
+ # Set Headers
677
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
678
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
679
+
680
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
681
+
682
+ # Serialize Request
683
+ request_mapper = Profile.mapper()
684
+ request_content = @client.serialize(request_mapper, parameters, 'parameters')
685
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
686
+
687
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}'
688
+ options = {
689
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
690
+ path_params: {'resourceGroupName' => resource_group_name,'profileName' => profile_name,'subscriptionId' => @client.subscription_id},
691
+ query_params: {'api-version' => @client.api_version},
692
+ body: request_content,
693
+ headers: request_headers.merge(custom_headers || {})
694
+ }
695
+
696
+ request_url = @base_url || @client.base_url
697
+
698
+ request = MsRest::HttpOperationRequest.new(request_url, path_template, :patch, options)
699
+ promise = request.run_promise do |req|
700
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
701
+ end
702
+
703
+ promise = promise.then do |http_response|
704
+ status_code = http_response.status
705
+ response_content = http_response.body
706
+ unless status_code == 200
707
+ error_model = JSON.load(response_content)
708
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
709
+ end
710
+
711
+ # Create Result
712
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
713
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
714
+ # Deserialize Response
715
+ if status_code == 200
716
+ begin
717
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
718
+ result_mapper = Profile.mapper()
719
+ result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
720
+ rescue Exception => e
721
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
722
+ end
723
+ end
724
+
725
+ result
726
+ end
727
+
728
+ promise.execute
729
+ end
730
+
731
+ end
732
+ end