azure_mgmt_cdn 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +3 -0
  3. data/LICENSE.txt +21 -0
  4. data/Rakefile +5 -0
  5. data/azure_mgmt_cdn.gemspec +34 -0
  6. data/lib/azure_mgmt_cdn.rb +77 -0
  7. data/lib/azure_mgmt_cdn/cdn_management_client.rb +87 -0
  8. data/lib/azure_mgmt_cdn/custom_domains.rb +482 -0
  9. data/lib/azure_mgmt_cdn/endpoints.rb +940 -0
  10. data/lib/azure_mgmt_cdn/models/check_name_availability_input.rb +66 -0
  11. data/lib/azure_mgmt_cdn/models/check_name_availability_output.rb +75 -0
  12. data/lib/azure_mgmt_cdn/models/custom_domain.rb +82 -0
  13. data/lib/azure_mgmt_cdn/models/custom_domain_list_result.rb +77 -0
  14. data/lib/azure_mgmt_cdn/models/custom_domain_parameters.rb +62 -0
  15. data/lib/azure_mgmt_cdn/models/custom_domain_properties.rb +84 -0
  16. data/lib/azure_mgmt_cdn/models/custom_domain_properties_parameters.rb +56 -0
  17. data/lib/azure_mgmt_cdn/models/custom_domain_resource_state.rb +17 -0
  18. data/lib/azure_mgmt_cdn/models/deep_created_origin.rb +72 -0
  19. data/lib/azure_mgmt_cdn/models/deep_created_origin_properties.rb +78 -0
  20. data/lib/azure_mgmt_cdn/models/endpoint.rb +95 -0
  21. data/lib/azure_mgmt_cdn/models/endpoint_create_parameters.rb +82 -0
  22. data/lib/azure_mgmt_cdn/models/endpoint_list_result.rb +76 -0
  23. data/lib/azure_mgmt_cdn/models/endpoint_properties.rb +197 -0
  24. data/lib/azure_mgmt_cdn/models/endpoint_properties_create_parameters.rb +160 -0
  25. data/lib/azure_mgmt_cdn/models/endpoint_properties_update_parameters.rb +127 -0
  26. data/lib/azure_mgmt_cdn/models/endpoint_resource_state.rb +20 -0
  27. data/lib/azure_mgmt_cdn/models/endpoint_update_parameters.rb +72 -0
  28. data/lib/azure_mgmt_cdn/models/error_response.rb +65 -0
  29. data/lib/azure_mgmt_cdn/models/load_parameters.rb +58 -0
  30. data/lib/azure_mgmt_cdn/models/operation.rb +71 -0
  31. data/lib/azure_mgmt_cdn/models/operation_display.rb +75 -0
  32. data/lib/azure_mgmt_cdn/models/operation_list_result.rb +77 -0
  33. data/lib/azure_mgmt_cdn/models/origin.rb +83 -0
  34. data/lib/azure_mgmt_cdn/models/origin_list_result.rb +76 -0
  35. data/lib/azure_mgmt_cdn/models/origin_parameters.rb +62 -0
  36. data/lib/azure_mgmt_cdn/models/origin_properties.rb +106 -0
  37. data/lib/azure_mgmt_cdn/models/origin_properties_parameters.rb +78 -0
  38. data/lib/azure_mgmt_cdn/models/origin_resource_state.rb +17 -0
  39. data/lib/azure_mgmt_cdn/models/profile.rb +95 -0
  40. data/lib/azure_mgmt_cdn/models/profile_create_parameters.rb +82 -0
  41. data/lib/azure_mgmt_cdn/models/profile_list_result.rb +76 -0
  42. data/lib/azure_mgmt_cdn/models/profile_properties.rb +90 -0
  43. data/lib/azure_mgmt_cdn/models/profile_properties_create_parameters.rb +63 -0
  44. data/lib/azure_mgmt_cdn/models/profile_resource_state.rb +18 -0
  45. data/lib/azure_mgmt_cdn/models/profile_update_parameters.rb +57 -0
  46. data/lib/azure_mgmt_cdn/models/provisioning_state.rb +17 -0
  47. data/lib/azure_mgmt_cdn/models/purge_parameters.rb +58 -0
  48. data/lib/azure_mgmt_cdn/models/query_string_caching_behavior.rb +18 -0
  49. data/lib/azure_mgmt_cdn/models/sku.rb +60 -0
  50. data/lib/azure_mgmt_cdn/models/sku_name.rb +16 -0
  51. data/lib/azure_mgmt_cdn/models/sso_uri.rb +56 -0
  52. data/lib/azure_mgmt_cdn/models/tracked_resource.rb +85 -0
  53. data/lib/azure_mgmt_cdn/models/validate_custom_domain_input.rb +56 -0
  54. data/lib/azure_mgmt_cdn/models/validate_custom_domain_output.rb +75 -0
  55. data/lib/azure_mgmt_cdn/module_definition.rb +8 -0
  56. data/lib/azure_mgmt_cdn/name_availability.rb +101 -0
  57. data/lib/azure_mgmt_cdn/operations.rb +87 -0
  58. data/lib/azure_mgmt_cdn/origins.rb +533 -0
  59. data/lib/azure_mgmt_cdn/profiles.rb +607 -0
  60. data/lib/azure_mgmt_cdn/version.rb +8 -0
  61. metadata +172 -0
@@ -0,0 +1,533 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator 0.16.0.0
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure::ARM::CDN
7
+ #
8
+ # Use these APIs to manage Azure CDN resources through the Azure Resource
9
+ # Manager. You must make sure that requests made to these resources are
10
+ # secure. For more information, see <a
11
+ # href="https://msdn.microsoft.com/en-us/library/azure/dn790557.aspx">Authenticating
12
+ # Azure Resource Manager requests.</a>
13
+ #
14
+ class Origins
15
+ include Azure::ARM::CDN::Models
16
+ include MsRestAzure
17
+
18
+ #
19
+ # Creates and initializes a new instance of the Origins class.
20
+ # @param client service class for accessing basic functionality.
21
+ #
22
+ def initialize(client)
23
+ @client = client
24
+ end
25
+
26
+ # @return reference to the CdnManagementClient
27
+ attr_reader :client
28
+
29
+ #
30
+ # Lists the existing CDN Origins within an Endpoint
31
+ #
32
+ # @param endpoint_name [String] Name of the endpoint within the CDN profile
33
+ # @param profile_name [String] Name of the CDN profile within the resource
34
+ # group
35
+ # @param resource_group_name [String] Name of the resource group within the
36
+ # Azure subscription
37
+ # @param [Hash{String => String}] The hash of custom headers need to be
38
+ # applied to HTTP request.
39
+ #
40
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
41
+ # response.
42
+ #
43
+ def list_by_endpoint(endpoint_name, profile_name, resource_group_name, custom_headers = nil)
44
+ fail ArgumentError, 'endpoint_name is nil' if endpoint_name.nil?
45
+ fail ArgumentError, 'profile_name is nil' if profile_name.nil?
46
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
47
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
48
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
49
+ request_headers = {}
50
+
51
+ # Set Headers
52
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
53
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
54
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/origins'
55
+ options = {
56
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
57
+ path_params: {'endpointName' => endpoint_name,'profileName' => profile_name,'resourceGroupName' => resource_group_name,'subscriptionId' => @client.subscription_id},
58
+ query_params: {'api-version' => @client.api_version},
59
+ headers: request_headers.merge(custom_headers || {})
60
+ }
61
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
62
+ promise = request.run_promise do |req|
63
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
64
+ end
65
+
66
+ promise = promise.then do |http_response|
67
+ status_code = http_response.status
68
+ response_content = http_response.body
69
+ unless status_code == 200
70
+ error_model = JSON.load(response_content)
71
+ fail MsRest::HttpOperationError.new(request, http_response, error_model)
72
+ end
73
+
74
+ # Create Result
75
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
76
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
77
+ # Deserialize Response
78
+ if status_code == 200
79
+ begin
80
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
81
+ unless parsed_response.nil?
82
+ parsed_response = OriginListResult.deserialize_object(parsed_response)
83
+ end
84
+ result.body = parsed_response
85
+ rescue Exception => e
86
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
87
+ end
88
+ end
89
+
90
+ result
91
+ end
92
+
93
+ promise.execute
94
+ end
95
+
96
+ #
97
+ # Gets an existing CDN Origin within an Endpoint
98
+ #
99
+ # @param origin_name [String] Name of the origin, an arbitrary value but it
100
+ # needs to be unique under endpoint
101
+ # @param endpoint_name [String] Name of the endpoint within the CDN profile
102
+ # @param profile_name [String] Name of the CDN profile within the resource
103
+ # group
104
+ # @param resource_group_name [String] Name of the resource group within the
105
+ # Azure subscription
106
+ # @param [Hash{String => String}] The hash of custom headers need to be
107
+ # applied to HTTP request.
108
+ #
109
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
110
+ # response.
111
+ #
112
+ def get(origin_name, endpoint_name, profile_name, resource_group_name, custom_headers = nil)
113
+ fail ArgumentError, 'origin_name is nil' if origin_name.nil?
114
+ fail ArgumentError, 'endpoint_name is nil' if endpoint_name.nil?
115
+ fail ArgumentError, 'profile_name is nil' if profile_name.nil?
116
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
117
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
118
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
119
+ request_headers = {}
120
+
121
+ # Set Headers
122
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
123
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
124
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/origins/{originName}'
125
+ options = {
126
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
127
+ path_params: {'originName' => origin_name,'endpointName' => endpoint_name,'profileName' => profile_name,'resourceGroupName' => resource_group_name,'subscriptionId' => @client.subscription_id},
128
+ query_params: {'api-version' => @client.api_version},
129
+ headers: request_headers.merge(custom_headers || {})
130
+ }
131
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
132
+ promise = request.run_promise do |req|
133
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
134
+ end
135
+
136
+ promise = promise.then do |http_response|
137
+ status_code = http_response.status
138
+ response_content = http_response.body
139
+ unless status_code == 200
140
+ error_model = JSON.load(response_content)
141
+ fail MsRest::HttpOperationError.new(request, http_response, error_model)
142
+ end
143
+
144
+ # Create Result
145
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
146
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
147
+ # Deserialize Response
148
+ if status_code == 200
149
+ begin
150
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
151
+ unless parsed_response.nil?
152
+ parsed_response = Origin.deserialize_object(parsed_response)
153
+ end
154
+ result.body = parsed_response
155
+ rescue Exception => e
156
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
157
+ end
158
+ end
159
+
160
+ result
161
+ end
162
+
163
+ promise.execute
164
+ end
165
+
166
+ #
167
+ # Creates a new CDN Origin within an Endpoint
168
+ #
169
+ # @param origin_name [String] Name of the origin, an arbitrary value but it
170
+ # needs to be unique under endpoint
171
+ # @param origin_properties [OriginParameters] Origin properties
172
+ # @param endpoint_name [String] Name of the endpoint within the CDN profile
173
+ # @param profile_name [String] Name of the CDN profile within the resource
174
+ # group
175
+ # @param resource_group_name [String] Name of the resource group within the
176
+ # Azure subscription
177
+ # @param @client.subscription_id [String] Azure Subscription ID
178
+ # @param @client.api_version [String] Version of the API to be used with the
179
+ # client request, current version is 2015-06-01
180
+ # @param @client.accept_language [String] Gets or sets the preferred language
181
+ # for the response.
182
+ #
183
+ # @return [Concurrent::Promise] promise which provides async access to http
184
+ # response.
185
+ #
186
+ def create(origin_name, origin_properties, endpoint_name, profile_name, resource_group_name, custom_headers = nil)
187
+ # Send request
188
+ promise = begin_create(origin_name, origin_properties, endpoint_name, profile_name, resource_group_name, custom_headers)
189
+
190
+ promise = promise.then do |response|
191
+ # Defining deserialization method.
192
+ deserialize_method = lambda do |parsed_response|
193
+ unless parsed_response.nil?
194
+ parsed_response = Origin.deserialize_object(parsed_response)
195
+ end
196
+ end
197
+
198
+ # Waiting for response.
199
+ @client.get_put_operation_result(response, deserialize_method)
200
+ end
201
+
202
+ promise
203
+ end
204
+
205
+ #
206
+ # Creates a new CDN Origin within an Endpoint
207
+ #
208
+ # @param origin_name [String] Name of the origin, an arbitrary value but it
209
+ # needs to be unique under endpoint
210
+ # @param origin_properties [OriginParameters] Origin properties
211
+ # @param endpoint_name [String] Name of the endpoint within the CDN profile
212
+ # @param profile_name [String] Name of the CDN profile within the resource
213
+ # group
214
+ # @param resource_group_name [String] Name of the resource group within the
215
+ # Azure subscription
216
+ # @param [Hash{String => String}] The hash of custom headers need to be
217
+ # applied to HTTP request.
218
+ #
219
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
220
+ # response.
221
+ #
222
+ def begin_create(origin_name, origin_properties, endpoint_name, profile_name, resource_group_name, custom_headers = nil)
223
+ fail ArgumentError, 'origin_name is nil' if origin_name.nil?
224
+ fail ArgumentError, 'origin_properties is nil' if origin_properties.nil?
225
+ origin_properties.validate unless origin_properties.nil?
226
+ fail ArgumentError, 'endpoint_name is nil' if endpoint_name.nil?
227
+ fail ArgumentError, 'profile_name is nil' if profile_name.nil?
228
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
229
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
230
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
231
+ request_headers = {}
232
+
233
+ # Set Headers
234
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
235
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
236
+
237
+ # Serialize Request
238
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
239
+ unless origin_properties.nil?
240
+ origin_properties = OriginParameters.serialize_object(origin_properties)
241
+ end
242
+ request_content = JSON.generate(origin_properties, quirks_mode: true)
243
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/origins/{originName}'
244
+ options = {
245
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
246
+ path_params: {'originName' => origin_name,'endpointName' => endpoint_name,'profileName' => profile_name,'resourceGroupName' => resource_group_name,'subscriptionId' => @client.subscription_id},
247
+ query_params: {'api-version' => @client.api_version},
248
+ body: request_content,
249
+ headers: request_headers.merge(custom_headers || {})
250
+ }
251
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :put, options)
252
+ promise = request.run_promise do |req|
253
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
254
+ end
255
+
256
+ promise = promise.then do |http_response|
257
+ status_code = http_response.status
258
+ response_content = http_response.body
259
+ unless status_code == 201 || status_code == 202
260
+ error_model = JSON.load(response_content)
261
+ fail MsRest::HttpOperationError.new(request, http_response, error_model)
262
+ end
263
+
264
+ # Create Result
265
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
266
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
267
+ # Deserialize Response
268
+ if status_code == 201
269
+ begin
270
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
271
+ unless parsed_response.nil?
272
+ parsed_response = Origin.deserialize_object(parsed_response)
273
+ end
274
+ result.body = parsed_response
275
+ rescue Exception => e
276
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
277
+ end
278
+ end
279
+ # Deserialize Response
280
+ if status_code == 202
281
+ begin
282
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
283
+ unless parsed_response.nil?
284
+ parsed_response = Origin.deserialize_object(parsed_response)
285
+ end
286
+ result.body = parsed_response
287
+ rescue Exception => e
288
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
289
+ end
290
+ end
291
+
292
+ result
293
+ end
294
+
295
+ promise.execute
296
+ end
297
+
298
+ #
299
+ # Updates an existing CDN Origin within an Endpoint
300
+ #
301
+ # @param origin_name [String] Name of the origin, an arbitrary value but it
302
+ # needs to be unique under endpoint
303
+ # @param origin_properties [OriginParameters] Origin properties
304
+ # @param endpoint_name [String] Name of the endpoint within the CDN profile
305
+ # @param profile_name [String] Name of the CDN profile within the resource
306
+ # group
307
+ # @param resource_group_name [String] Name of the resource group within the
308
+ # Azure subscription
309
+ # @param @client.subscription_id [String] Azure Subscription ID
310
+ # @param @client.api_version [String] Version of the API to be used with the
311
+ # client request, current version is 2015-06-01
312
+ # @param @client.accept_language [String] Gets or sets the preferred language
313
+ # for the response.
314
+ #
315
+ # @return [Concurrent::Promise] promise which provides async access to http
316
+ # response.
317
+ #
318
+ def update(origin_name, origin_properties, endpoint_name, profile_name, resource_group_name, custom_headers = nil)
319
+ # Send request
320
+ promise = begin_update(origin_name, origin_properties, endpoint_name, profile_name, resource_group_name, custom_headers)
321
+
322
+ promise = promise.then do |response|
323
+ # Defining deserialization method.
324
+ deserialize_method = lambda do |parsed_response|
325
+ unless parsed_response.nil?
326
+ parsed_response = Origin.deserialize_object(parsed_response)
327
+ end
328
+ end
329
+
330
+ # Waiting for response.
331
+ @client.get_put_operation_result(response, deserialize_method)
332
+ end
333
+
334
+ promise
335
+ end
336
+
337
+ #
338
+ # Updates an existing CDN Origin within an Endpoint
339
+ #
340
+ # @param origin_name [String] Name of the origin, an arbitrary value but it
341
+ # needs to be unique under endpoint
342
+ # @param origin_properties [OriginParameters] Origin properties
343
+ # @param endpoint_name [String] Name of the endpoint within the CDN profile
344
+ # @param profile_name [String] Name of the CDN profile within the resource
345
+ # group
346
+ # @param resource_group_name [String] Name of the resource group within the
347
+ # Azure subscription
348
+ # @param [Hash{String => String}] The hash of custom headers need to be
349
+ # applied to HTTP request.
350
+ #
351
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
352
+ # response.
353
+ #
354
+ def begin_update(origin_name, origin_properties, endpoint_name, profile_name, resource_group_name, custom_headers = nil)
355
+ fail ArgumentError, 'origin_name is nil' if origin_name.nil?
356
+ fail ArgumentError, 'origin_properties is nil' if origin_properties.nil?
357
+ origin_properties.validate unless origin_properties.nil?
358
+ fail ArgumentError, 'endpoint_name is nil' if endpoint_name.nil?
359
+ fail ArgumentError, 'profile_name is nil' if profile_name.nil?
360
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
361
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
362
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
363
+ request_headers = {}
364
+
365
+ # Set Headers
366
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
367
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
368
+
369
+ # Serialize Request
370
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
371
+ unless origin_properties.nil?
372
+ origin_properties = OriginParameters.serialize_object(origin_properties)
373
+ end
374
+ request_content = JSON.generate(origin_properties, quirks_mode: true)
375
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/origins/{originName}'
376
+ options = {
377
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
378
+ path_params: {'originName' => origin_name,'endpointName' => endpoint_name,'profileName' => profile_name,'resourceGroupName' => resource_group_name,'subscriptionId' => @client.subscription_id},
379
+ query_params: {'api-version' => @client.api_version},
380
+ body: request_content,
381
+ headers: request_headers.merge(custom_headers || {})
382
+ }
383
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :patch, options)
384
+ promise = request.run_promise do |req|
385
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
386
+ end
387
+
388
+ promise = promise.then do |http_response|
389
+ status_code = http_response.status
390
+ response_content = http_response.body
391
+ unless status_code == 200 || status_code == 202
392
+ error_model = JSON.load(response_content)
393
+ fail MsRest::HttpOperationError.new(request, http_response, error_model)
394
+ end
395
+
396
+ # Create Result
397
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
398
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
399
+ # Deserialize Response
400
+ if status_code == 200
401
+ begin
402
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
403
+ unless parsed_response.nil?
404
+ parsed_response = Origin.deserialize_object(parsed_response)
405
+ end
406
+ result.body = parsed_response
407
+ rescue Exception => e
408
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
409
+ end
410
+ end
411
+ # Deserialize Response
412
+ if status_code == 202
413
+ begin
414
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
415
+ unless parsed_response.nil?
416
+ parsed_response = Origin.deserialize_object(parsed_response)
417
+ end
418
+ result.body = parsed_response
419
+ rescue Exception => e
420
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
421
+ end
422
+ end
423
+
424
+ result
425
+ end
426
+
427
+ promise.execute
428
+ end
429
+
430
+ #
431
+ # Deletes an existing CDN Origin within an Endpoint
432
+ #
433
+ # @param origin_name [String] Name of the origin, an arbitrary value but it
434
+ # needs to be unique under endpoint
435
+ # @param endpoint_name [String] Name of the endpoint within the CDN profile
436
+ # @param profile_name [String] Name of the CDN profile within the resource
437
+ # group
438
+ # @param resource_group_name [String] Name of the resource group within the
439
+ # Azure subscription
440
+ # @return [Concurrent::Promise] promise which provides async access to http
441
+ # response.
442
+ #
443
+ def delete_if_exists(origin_name, endpoint_name, profile_name, resource_group_name, custom_headers = nil)
444
+ # Send request
445
+ promise = begin_delete_if_exists(origin_name, endpoint_name, profile_name, resource_group_name, custom_headers)
446
+
447
+ promise = promise.then do |response|
448
+ # Defining deserialization method.
449
+ deserialize_method = lambda do |parsed_response|
450
+ unless parsed_response.nil?
451
+ parsed_response = Origin.deserialize_object(parsed_response)
452
+ end
453
+ end
454
+
455
+ # Waiting for response.
456
+ @client.get_post_or_delete_operation_result(response, deserialize_method)
457
+ end
458
+
459
+ promise
460
+ end
461
+
462
+ #
463
+ # Deletes an existing CDN Origin within an Endpoint
464
+ #
465
+ # @param origin_name [String] Name of the origin, an arbitrary value but it
466
+ # needs to be unique under endpoint
467
+ # @param endpoint_name [String] Name of the endpoint within the CDN profile
468
+ # @param profile_name [String] Name of the CDN profile within the resource
469
+ # group
470
+ # @param resource_group_name [String] Name of the resource group within the
471
+ # Azure subscription
472
+ # @param [Hash{String => String}] The hash of custom headers need to be
473
+ # applied to HTTP request.
474
+ #
475
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
476
+ # response.
477
+ #
478
+ def begin_delete_if_exists(origin_name, endpoint_name, profile_name, resource_group_name, custom_headers = nil)
479
+ fail ArgumentError, 'origin_name is nil' if origin_name.nil?
480
+ fail ArgumentError, 'endpoint_name is nil' if endpoint_name.nil?
481
+ fail ArgumentError, 'profile_name is nil' if profile_name.nil?
482
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
483
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
484
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
485
+ request_headers = {}
486
+
487
+ # Set Headers
488
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
489
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
490
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/origins/{originName}'
491
+ options = {
492
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
493
+ path_params: {'originName' => origin_name,'endpointName' => endpoint_name,'profileName' => profile_name,'resourceGroupName' => resource_group_name,'subscriptionId' => @client.subscription_id},
494
+ query_params: {'api-version' => @client.api_version},
495
+ headers: request_headers.merge(custom_headers || {})
496
+ }
497
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :delete, options)
498
+ promise = request.run_promise do |req|
499
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
500
+ end
501
+
502
+ promise = promise.then do |http_response|
503
+ status_code = http_response.status
504
+ response_content = http_response.body
505
+ unless status_code == 202 || status_code == 204
506
+ error_model = JSON.load(response_content)
507
+ fail MsRest::HttpOperationError.new(request, http_response, error_model)
508
+ end
509
+
510
+ # Create Result
511
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
512
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
513
+ # Deserialize Response
514
+ if status_code == 202
515
+ begin
516
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
517
+ unless parsed_response.nil?
518
+ parsed_response = Origin.deserialize_object(parsed_response)
519
+ end
520
+ result.body = parsed_response
521
+ rescue Exception => e
522
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
523
+ end
524
+ end
525
+
526
+ result
527
+ end
528
+
529
+ promise.execute
530
+ end
531
+
532
+ end
533
+ end