haipa_compute 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/lib/1.0/generated/haipa_compute/haipa_compute.rb +136 -136
  3. data/lib/1.0/generated/haipa_compute/machines.rb +578 -578
  4. data/lib/1.0/generated/haipa_compute/models/agent.rb +87 -87
  5. data/lib/1.0/generated/haipa_compute/models/agent_network.rb +93 -93
  6. data/lib/1.0/generated/haipa_compute/models/machine.rb +125 -125
  7. data/lib/1.0/generated/haipa_compute/models/machine_config.rb +102 -91
  8. data/lib/1.0/generated/haipa_compute/models/machine_network.rb +187 -187
  9. data/lib/1.0/generated/haipa_compute/models/machine_network_config.rb +67 -67
  10. data/lib/1.0/generated/haipa_compute/models/machine_subnet_config.rb +47 -47
  11. data/lib/1.0/generated/haipa_compute/models/network.rb +109 -109
  12. data/lib/1.0/generated/haipa_compute/models/odata_value_ienumerable_machine.rb +56 -56
  13. data/lib/1.0/generated/haipa_compute/models/odata_value_ienumerable_operation.rb +56 -56
  14. data/lib/1.0/generated/haipa_compute/models/odata_value_ienumerable_operation_log.rb +56 -56
  15. data/lib/1.0/generated/haipa_compute/models/operation.rb +123 -123
  16. data/lib/1.0/generated/haipa_compute/models/operation_log.rb +81 -81
  17. data/lib/1.0/generated/haipa_compute/models/subnet.rb +144 -144
  18. data/lib/1.0/generated/haipa_compute/models/virtual_machine.rb +90 -90
  19. data/lib/1.0/generated/haipa_compute/models/virtual_machine_config.rb +111 -111
  20. data/lib/1.0/generated/haipa_compute/models/virtual_machine_cpu_config.rb +47 -47
  21. data/lib/1.0/generated/haipa_compute/models/virtual_machine_disk_config.rb +80 -80
  22. data/lib/1.0/generated/haipa_compute/models/virtual_machine_memory_config.rb +69 -69
  23. data/lib/1.0/generated/haipa_compute/models/virtual_machine_network_adapter.rb +92 -92
  24. data/lib/1.0/generated/haipa_compute/models/virtual_machine_network_adapter_config.rb +69 -69
  25. data/lib/1.0/generated/haipa_compute/models/virtual_machine_provisioning_config.rb +58 -58
  26. data/lib/1.0/generated/haipa_compute/module_definition.rb +9 -9
  27. data/lib/1.0/generated/haipa_compute/networks.rb +415 -415
  28. data/lib/1.0/generated/haipa_compute/operations.rb +347 -347
  29. data/lib/1.0/generated/haipa_compute/subnets.rb +100 -100
  30. data/lib/1.0/generated/haipa_compute.rb +53 -53
  31. data/lib/api_configuration.rb +2 -1
  32. data/lib/version.rb +1 -1
  33. metadata +4 -4
@@ -1,578 +1,578 @@
1
- # encoding: utf-8
2
- # Code generated by Microsoft (R) AutoRest Code Generator.
3
- # Changes may cause incorrect behavior and will be lost if the code is
4
- # regenerated.
5
-
6
- module Haipa::Client::Compute::V1_0
7
- #
8
- # Haipa management API
9
- #
10
- class Machines
11
- include Haipa::Client
12
-
13
- #
14
- # Creates and initializes a new instance of the Machines class.
15
- # @param client service class for accessing basic functionality.
16
- #
17
- def initialize(client)
18
- @client = client
19
- end
20
-
21
- # @return [HaipaCompute] reference to the HaipaCompute
22
- attr_reader :client
23
-
24
- #
25
- # @param select [String] Limits the properties returned in the result.
26
- # @param expand [String] Indicates the related entities to be represented
27
- # inline. The maximum depth is 2.
28
- # @param filter [String] Restricts the set of items returned. The maximum
29
- # number of expressions is 100. The allowed functions are: allfunctions.
30
- # @param orderby [String] Specifies the order in which items are returned. The
31
- # maximum number of expressions is 5.
32
- # @param top [Integer] Limits the number of items returned from a collection.
33
- # @param skip [Integer] Excludes the specified number of items of the queried
34
- # collection from the result.
35
- # @param count [Boolean] Indicates whether the total count of items within a
36
- # collection are returned in the result.
37
- # @param custom_headers [Hash{String => String}] A hash of custom headers that
38
- # will be added to the HTTP request.
39
- #
40
- # @return [ODataValueIEnumerableMachine] operation results.
41
- #
42
- def list(select:nil, expand:nil, filter:nil, orderby:nil, top:nil, skip:nil, count:false, custom_headers:nil)
43
- response = list_async(select:select, expand:expand, filter:filter, orderby:orderby, top:top, skip:skip, count:count, custom_headers:custom_headers).value!
44
- response.body unless response.nil?
45
- end
46
-
47
- #
48
- # @param select [String] Limits the properties returned in the result.
49
- # @param expand [String] Indicates the related entities to be represented
50
- # inline. The maximum depth is 2.
51
- # @param filter [String] Restricts the set of items returned. The maximum
52
- # number of expressions is 100. The allowed functions are: allfunctions.
53
- # @param orderby [String] Specifies the order in which items are returned. The
54
- # maximum number of expressions is 5.
55
- # @param top [Integer] Limits the number of items returned from a collection.
56
- # @param skip [Integer] Excludes the specified number of items of the queried
57
- # collection from the result.
58
- # @param count [Boolean] Indicates whether the total count of items within a
59
- # collection are returned in the result.
60
- # @param custom_headers [Hash{String => String}] A hash of custom headers that
61
- # will be added to the HTTP request.
62
- #
63
- # @return [Haipa::Client::HaipaOperationResponse] HTTP response information.
64
- #
65
- def list_with_http_info(select:nil, expand:nil, filter:nil, orderby:nil, top:nil, skip:nil, count:false, custom_headers:nil)
66
- list_async(select:select, expand:expand, filter:filter, orderby:orderby, top:top, skip:skip, count:count, custom_headers:custom_headers).value!
67
- end
68
-
69
- #
70
- # @param select [String] Limits the properties returned in the result.
71
- # @param expand [String] Indicates the related entities to be represented
72
- # inline. The maximum depth is 2.
73
- # @param filter [String] Restricts the set of items returned. The maximum
74
- # number of expressions is 100. The allowed functions are: allfunctions.
75
- # @param orderby [String] Specifies the order in which items are returned. The
76
- # maximum number of expressions is 5.
77
- # @param top [Integer] Limits the number of items returned from a collection.
78
- # @param skip [Integer] Excludes the specified number of items of the queried
79
- # collection from the result.
80
- # @param count [Boolean] Indicates whether the total count of items within a
81
- # collection are returned in the result.
82
- # @param [Hash{String => String}] A hash of custom headers that will be added
83
- # to the HTTP request.
84
- #
85
- # @return [Concurrent::Promise] Promise object which holds the HTTP response.
86
- #
87
- def list_async(select:nil, expand:nil, filter:nil, orderby:nil, top:nil, skip:nil, count:false, custom_headers:nil)
88
-
89
-
90
- request_headers = {}
91
- request_headers['Content-Type'] = 'application/json; charset=utf-8'
92
-
93
- # Set Headers
94
- request_headers['x-ms-client-request-id'] = SecureRandom.uuid
95
- request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
96
- path_template = 'odata/v1/Machines'
97
-
98
- request_url = @base_url || @client.base_url
99
-
100
- options = {
101
- middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02]],
102
- query_params: {'$select' => select,'$expand' => expand,'$filter' => filter,'$orderby' => orderby,'$top' => top,'$skip' => skip,'$count' => count},
103
- headers: request_headers.merge(custom_headers || {}),
104
- base_url: request_url
105
- }
106
- promise = @client.make_request_async(:get, path_template, options)
107
-
108
- promise = promise.then do |result|
109
- http_response = result.response
110
- status_code = http_response.status
111
- response_content = http_response.body
112
- unless status_code == 200 || status_code == 404
113
- error_model = JSON.load(response_content)
114
- fail Haipa::Client::HaipaOperationError.new(result.request, http_response, error_model)
115
- end
116
-
117
- result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
118
- result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
119
- result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
120
- # Deserialize Response
121
- if status_code == 200
122
- begin
123
- parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
124
- result_mapper = Haipa::Client::Compute::V1_0::Models::ODataValueIEnumerableMachine.mapper()
125
- result.body = @client.deserialize(result_mapper, parsed_response)
126
- rescue Exception => e
127
- fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
128
- end
129
- end
130
-
131
- result
132
- end
133
-
134
- promise.execute
135
- end
136
-
137
- #
138
- # @param config [MachineConfig]
139
- # @param custom_headers [Hash{String => String}] A hash of custom headers that
140
- # will be added to the HTTP request.
141
- #
142
- # @return [Operation] operation results.
143
- #
144
- def update_or_create(config:nil, custom_headers:nil)
145
- response = update_or_create_async(config:config, custom_headers:custom_headers).value!
146
- response.body unless response.nil?
147
- end
148
-
149
- #
150
- # @param config [MachineConfig]
151
- # @param custom_headers [Hash{String => String}] A hash of custom headers that
152
- # will be added to the HTTP request.
153
- #
154
- # @return [Haipa::Client::HaipaOperationResponse] HTTP response information.
155
- #
156
- def update_or_create_with_http_info(config:nil, custom_headers:nil)
157
- update_or_create_async(config:config, custom_headers:custom_headers).value!
158
- end
159
-
160
- #
161
- # @param config [MachineConfig]
162
- # @param [Hash{String => String}] A hash of custom headers that will be added
163
- # to the HTTP request.
164
- #
165
- # @return [Concurrent::Promise] Promise object which holds the HTTP response.
166
- #
167
- def update_or_create_async(config:nil, custom_headers:nil)
168
-
169
-
170
- request_headers = {}
171
- request_headers['Content-Type'] = 'application/json; charset=utf-8'
172
-
173
- # Set Headers
174
- request_headers['x-ms-client-request-id'] = SecureRandom.uuid
175
- request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
176
-
177
- # Serialize Request
178
- request_mapper = Haipa::Client::Compute::V1_0::Models::MachineConfig.mapper()
179
- request_content = @client.serialize(request_mapper, config)
180
- request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
181
-
182
- path_template = 'odata/v1/Machines'
183
-
184
- request_url = @base_url || @client.base_url
185
-
186
- options = {
187
- middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02]],
188
- body: request_content,
189
- headers: request_headers.merge(custom_headers || {}),
190
- base_url: request_url
191
- }
192
- promise = @client.make_request_async(:post, path_template, options)
193
-
194
- promise = promise.then do |result|
195
- http_response = result.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 Haipa::Client::HaipaOperationError.new(result.request, http_response, error_model)
201
- end
202
-
203
- result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
204
- result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
205
- result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-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 = Haipa::Client::Compute::V1_0::Models::Operation.mapper()
211
- result.body = @client.deserialize(result_mapper, parsed_response)
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
- # @param key
225
- # @param select [String] Limits the properties returned in the result.
226
- # @param expand [String] Indicates the related entities to be represented
227
- # inline. The maximum depth is 2.
228
- # @param custom_headers [Hash{String => String}] A hash of custom headers that
229
- # will be added to the HTTP request.
230
- #
231
- # @return [Machine] operation results.
232
- #
233
- def get(key, select:nil, expand:nil, custom_headers:nil)
234
- response = get_async(key, select:select, expand:expand, custom_headers:custom_headers).value!
235
- response.body unless response.nil?
236
- end
237
-
238
- #
239
- # @param key
240
- # @param select [String] Limits the properties returned in the result.
241
- # @param expand [String] Indicates the related entities to be represented
242
- # inline. The maximum depth is 2.
243
- # @param custom_headers [Hash{String => String}] A hash of custom headers that
244
- # will be added to the HTTP request.
245
- #
246
- # @return [Haipa::Client::HaipaOperationResponse] HTTP response information.
247
- #
248
- def get_with_http_info(key, select:nil, expand:nil, custom_headers:nil)
249
- get_async(key, select:select, expand:expand, custom_headers:custom_headers).value!
250
- end
251
-
252
- #
253
- # @param key
254
- # @param select [String] Limits the properties returned in the result.
255
- # @param expand [String] Indicates the related entities to be represented
256
- # inline. The maximum depth is 2.
257
- # @param [Hash{String => String}] A hash of custom headers that will be added
258
- # to the HTTP request.
259
- #
260
- # @return [Concurrent::Promise] Promise object which holds the HTTP response.
261
- #
262
- def get_async(key, select:nil, expand:nil, custom_headers:nil)
263
- fail ArgumentError, 'key is nil' if key.nil?
264
-
265
-
266
- request_headers = {}
267
- request_headers['Content-Type'] = 'application/json; charset=utf-8'
268
-
269
- # Set Headers
270
- request_headers['x-ms-client-request-id'] = SecureRandom.uuid
271
- request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
272
- path_template = 'odata/v1/Machines({key})'
273
-
274
- request_url = @base_url || @client.base_url
275
-
276
- options = {
277
- middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02]],
278
- path_params: {'key' => key},
279
- query_params: {'$select' => select,'$expand' => expand},
280
- headers: request_headers.merge(custom_headers || {}),
281
- base_url: request_url
282
- }
283
- promise = @client.make_request_async(:get, path_template, options)
284
-
285
- promise = promise.then do |result|
286
- http_response = result.response
287
- status_code = http_response.status
288
- response_content = http_response.body
289
- unless status_code == 200 || status_code == 404
290
- error_model = JSON.load(response_content)
291
- fail Haipa::Client::HaipaOperationError.new(result.request, http_response, error_model)
292
- end
293
-
294
- result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
295
- result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
296
- result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
297
- # Deserialize Response
298
- if status_code == 200
299
- begin
300
- parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
301
- result_mapper = Haipa::Client::Compute::V1_0::Models::Machine.mapper()
302
- result.body = @client.deserialize(result_mapper, parsed_response)
303
- rescue Exception => e
304
- fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
305
- end
306
- end
307
-
308
- result
309
- end
310
-
311
- promise.execute
312
- end
313
-
314
- #
315
- # @param key
316
- # @param custom_headers [Hash{String => String}] A hash of custom headers that
317
- # will be added to the HTTP request.
318
- #
319
- # @return [Operation] operation results.
320
- #
321
- def delete(key, custom_headers:nil)
322
- response = delete_async(key, custom_headers:custom_headers).value!
323
- response.body unless response.nil?
324
- end
325
-
326
- #
327
- # @param key
328
- # @param custom_headers [Hash{String => String}] A hash of custom headers that
329
- # will be added to the HTTP request.
330
- #
331
- # @return [Haipa::Client::HaipaOperationResponse] HTTP response information.
332
- #
333
- def delete_with_http_info(key, custom_headers:nil)
334
- delete_async(key, custom_headers:custom_headers).value!
335
- end
336
-
337
- #
338
- # @param key
339
- # @param [Hash{String => String}] A hash of custom headers that will be added
340
- # to the HTTP request.
341
- #
342
- # @return [Concurrent::Promise] Promise object which holds the HTTP response.
343
- #
344
- def delete_async(key, custom_headers:nil)
345
- fail ArgumentError, 'key is nil' if key.nil?
346
-
347
-
348
- request_headers = {}
349
- request_headers['Content-Type'] = 'application/json; charset=utf-8'
350
-
351
- # Set Headers
352
- request_headers['x-ms-client-request-id'] = SecureRandom.uuid
353
- request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
354
- path_template = 'odata/v1/Machines({key})'
355
-
356
- request_url = @base_url || @client.base_url
357
-
358
- options = {
359
- middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02]],
360
- path_params: {'key' => key},
361
- headers: request_headers.merge(custom_headers || {}),
362
- base_url: request_url
363
- }
364
- promise = @client.make_request_async(:delete, path_template, options)
365
-
366
- promise = promise.then do |result|
367
- http_response = result.response
368
- status_code = http_response.status
369
- response_content = http_response.body
370
- unless status_code == 200
371
- error_model = JSON.load(response_content)
372
- fail Haipa::Client::HaipaOperationError.new(result.request, http_response, error_model)
373
- end
374
-
375
- result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
376
- result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
377
- result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
378
- # Deserialize Response
379
- if status_code == 200
380
- begin
381
- parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
382
- result_mapper = Haipa::Client::Compute::V1_0::Models::Operation.mapper()
383
- result.body = @client.deserialize(result_mapper, parsed_response)
384
- rescue Exception => e
385
- fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
386
- end
387
- end
388
-
389
- result
390
- end
391
-
392
- promise.execute
393
- end
394
-
395
- #
396
- # @param key
397
- # @param select [String] Limits the properties returned in the result.
398
- # @param expand [String] Indicates the related entities to be represented
399
- # inline. The maximum depth is 2.
400
- # @param custom_headers [Hash{String => String}] A hash of custom headers that
401
- # will be added to the HTTP request.
402
- #
403
- # @return [Operation] operation results.
404
- #
405
- def start(key, select:nil, expand:nil, custom_headers:nil)
406
- response = start_async(key, select:select, expand:expand, custom_headers:custom_headers).value!
407
- response.body unless response.nil?
408
- end
409
-
410
- #
411
- # @param key
412
- # @param select [String] Limits the properties returned in the result.
413
- # @param expand [String] Indicates the related entities to be represented
414
- # inline. The maximum depth is 2.
415
- # @param custom_headers [Hash{String => String}] A hash of custom headers that
416
- # will be added to the HTTP request.
417
- #
418
- # @return [Haipa::Client::HaipaOperationResponse] HTTP response information.
419
- #
420
- def start_with_http_info(key, select:nil, expand:nil, custom_headers:nil)
421
- start_async(key, select:select, expand:expand, custom_headers:custom_headers).value!
422
- end
423
-
424
- #
425
- # @param key
426
- # @param select [String] Limits the properties returned in the result.
427
- # @param expand [String] Indicates the related entities to be represented
428
- # inline. The maximum depth is 2.
429
- # @param [Hash{String => String}] A hash of custom headers that will be added
430
- # to the HTTP request.
431
- #
432
- # @return [Concurrent::Promise] Promise object which holds the HTTP response.
433
- #
434
- def start_async(key, select:nil, expand:nil, custom_headers:nil)
435
- fail ArgumentError, 'key is nil' if key.nil?
436
-
437
-
438
- request_headers = {}
439
- request_headers['Content-Type'] = 'application/json; charset=utf-8'
440
-
441
- # Set Headers
442
- request_headers['x-ms-client-request-id'] = SecureRandom.uuid
443
- request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
444
- path_template = 'odata/v1/Machines({key})/Start'
445
-
446
- request_url = @base_url || @client.base_url
447
-
448
- options = {
449
- middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02]],
450
- path_params: {'key' => key},
451
- query_params: {'$select' => select,'$expand' => expand},
452
- headers: request_headers.merge(custom_headers || {}),
453
- base_url: request_url
454
- }
455
- promise = @client.make_request_async(:post, path_template, options)
456
-
457
- promise = promise.then do |result|
458
- http_response = result.response
459
- status_code = http_response.status
460
- response_content = http_response.body
461
- unless status_code == 200
462
- error_model = JSON.load(response_content)
463
- fail Haipa::Client::HaipaOperationError.new(result.request, http_response, error_model)
464
- end
465
-
466
- result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
467
- result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
468
- result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
469
- # Deserialize Response
470
- if status_code == 200
471
- begin
472
- parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
473
- result_mapper = Haipa::Client::Compute::V1_0::Models::Operation.mapper()
474
- result.body = @client.deserialize(result_mapper, parsed_response)
475
- rescue Exception => e
476
- fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
477
- end
478
- end
479
-
480
- result
481
- end
482
-
483
- promise.execute
484
- end
485
-
486
- #
487
- # @param key
488
- # @param select [String] Limits the properties returned in the result.
489
- # @param expand [String] Indicates the related entities to be represented
490
- # inline. The maximum depth is 2.
491
- # @param custom_headers [Hash{String => String}] A hash of custom headers that
492
- # will be added to the HTTP request.
493
- #
494
- # @return [Operation] operation results.
495
- #
496
- def stop(key, select:nil, expand:nil, custom_headers:nil)
497
- response = stop_async(key, select:select, expand:expand, custom_headers:custom_headers).value!
498
- response.body unless response.nil?
499
- end
500
-
501
- #
502
- # @param key
503
- # @param select [String] Limits the properties returned in the result.
504
- # @param expand [String] Indicates the related entities to be represented
505
- # inline. The maximum depth is 2.
506
- # @param custom_headers [Hash{String => String}] A hash of custom headers that
507
- # will be added to the HTTP request.
508
- #
509
- # @return [Haipa::Client::HaipaOperationResponse] HTTP response information.
510
- #
511
- def stop_with_http_info(key, select:nil, expand:nil, custom_headers:nil)
512
- stop_async(key, select:select, expand:expand, custom_headers:custom_headers).value!
513
- end
514
-
515
- #
516
- # @param key
517
- # @param select [String] Limits the properties returned in the result.
518
- # @param expand [String] Indicates the related entities to be represented
519
- # inline. The maximum depth is 2.
520
- # @param [Hash{String => String}] A hash of custom headers that will be added
521
- # to the HTTP request.
522
- #
523
- # @return [Concurrent::Promise] Promise object which holds the HTTP response.
524
- #
525
- def stop_async(key, select:nil, expand:nil, custom_headers:nil)
526
- fail ArgumentError, 'key is nil' if key.nil?
527
-
528
-
529
- request_headers = {}
530
- request_headers['Content-Type'] = 'application/json; charset=utf-8'
531
-
532
- # Set Headers
533
- request_headers['x-ms-client-request-id'] = SecureRandom.uuid
534
- request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
535
- path_template = 'odata/v1/Machines({key})/Stop'
536
-
537
- request_url = @base_url || @client.base_url
538
-
539
- options = {
540
- middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02]],
541
- path_params: {'key' => key},
542
- query_params: {'$select' => select,'$expand' => expand},
543
- headers: request_headers.merge(custom_headers || {}),
544
- base_url: request_url
545
- }
546
- promise = @client.make_request_async(:post, path_template, options)
547
-
548
- promise = promise.then do |result|
549
- http_response = result.response
550
- status_code = http_response.status
551
- response_content = http_response.body
552
- unless status_code == 200
553
- error_model = JSON.load(response_content)
554
- fail Haipa::Client::HaipaOperationError.new(result.request, http_response, error_model)
555
- end
556
-
557
- result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
558
- result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
559
- result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
560
- # Deserialize Response
561
- if status_code == 200
562
- begin
563
- parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
564
- result_mapper = Haipa::Client::Compute::V1_0::Models::Operation.mapper()
565
- result.body = @client.deserialize(result_mapper, parsed_response)
566
- rescue Exception => e
567
- fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
568
- end
569
- end
570
-
571
- result
572
- end
573
-
574
- promise.execute
575
- end
576
-
577
- end
578
- end
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator.
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Haipa::Client::Compute::V1_0
7
+ #
8
+ # Haipa management API
9
+ #
10
+ class Machines
11
+ include Haipa::Client
12
+
13
+ #
14
+ # Creates and initializes a new instance of the Machines class.
15
+ # @param client service class for accessing basic functionality.
16
+ #
17
+ def initialize(client)
18
+ @client = client
19
+ end
20
+
21
+ # @return [HaipaCompute] reference to the HaipaCompute
22
+ attr_reader :client
23
+
24
+ #
25
+ # @param select [String] Limits the properties returned in the result.
26
+ # @param expand [String] Indicates the related entities to be represented
27
+ # inline. The maximum depth is 2.
28
+ # @param filter [String] Restricts the set of items returned. The maximum
29
+ # number of expressions is 100. The allowed functions are: allfunctions.
30
+ # @param orderby [String] Specifies the order in which items are returned. The
31
+ # maximum number of expressions is 5.
32
+ # @param top [Integer] Limits the number of items returned from a collection.
33
+ # @param skip [Integer] Excludes the specified number of items of the queried
34
+ # collection from the result.
35
+ # @param count [Boolean] Indicates whether the total count of items within a
36
+ # collection are returned in the result.
37
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
38
+ # will be added to the HTTP request.
39
+ #
40
+ # @return [ODataValueIEnumerableMachine] operation results.
41
+ #
42
+ def list(select:nil, expand:nil, filter:nil, orderby:nil, top:nil, skip:nil, count:false, custom_headers:nil)
43
+ response = list_async(select:select, expand:expand, filter:filter, orderby:orderby, top:top, skip:skip, count:count, custom_headers:custom_headers).value!
44
+ response.body unless response.nil?
45
+ end
46
+
47
+ #
48
+ # @param select [String] Limits the properties returned in the result.
49
+ # @param expand [String] Indicates the related entities to be represented
50
+ # inline. The maximum depth is 2.
51
+ # @param filter [String] Restricts the set of items returned. The maximum
52
+ # number of expressions is 100. The allowed functions are: allfunctions.
53
+ # @param orderby [String] Specifies the order in which items are returned. The
54
+ # maximum number of expressions is 5.
55
+ # @param top [Integer] Limits the number of items returned from a collection.
56
+ # @param skip [Integer] Excludes the specified number of items of the queried
57
+ # collection from the result.
58
+ # @param count [Boolean] Indicates whether the total count of items within a
59
+ # collection are returned in the result.
60
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
61
+ # will be added to the HTTP request.
62
+ #
63
+ # @return [Haipa::Client::HaipaOperationResponse] HTTP response information.
64
+ #
65
+ def list_with_http_info(select:nil, expand:nil, filter:nil, orderby:nil, top:nil, skip:nil, count:false, custom_headers:nil)
66
+ list_async(select:select, expand:expand, filter:filter, orderby:orderby, top:top, skip:skip, count:count, custom_headers:custom_headers).value!
67
+ end
68
+
69
+ #
70
+ # @param select [String] Limits the properties returned in the result.
71
+ # @param expand [String] Indicates the related entities to be represented
72
+ # inline. The maximum depth is 2.
73
+ # @param filter [String] Restricts the set of items returned. The maximum
74
+ # number of expressions is 100. The allowed functions are: allfunctions.
75
+ # @param orderby [String] Specifies the order in which items are returned. The
76
+ # maximum number of expressions is 5.
77
+ # @param top [Integer] Limits the number of items returned from a collection.
78
+ # @param skip [Integer] Excludes the specified number of items of the queried
79
+ # collection from the result.
80
+ # @param count [Boolean] Indicates whether the total count of items within a
81
+ # collection are returned in the result.
82
+ # @param [Hash{String => String}] A hash of custom headers that will be added
83
+ # to the HTTP request.
84
+ #
85
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
86
+ #
87
+ def list_async(select:nil, expand:nil, filter:nil, orderby:nil, top:nil, skip:nil, count:false, custom_headers:nil)
88
+
89
+
90
+ request_headers = {}
91
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
92
+
93
+ # Set Headers
94
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
95
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
96
+ path_template = 'odata/v1/Machines'
97
+
98
+ request_url = @base_url || @client.base_url
99
+
100
+ options = {
101
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02]],
102
+ query_params: {'$select' => select,'$expand' => expand,'$filter' => filter,'$orderby' => orderby,'$top' => top,'$skip' => skip,'$count' => count},
103
+ headers: request_headers.merge(custom_headers || {}),
104
+ base_url: request_url
105
+ }
106
+ promise = @client.make_request_async(:get, path_template, options)
107
+
108
+ promise = promise.then do |result|
109
+ http_response = result.response
110
+ status_code = http_response.status
111
+ response_content = http_response.body
112
+ unless status_code == 200 || status_code == 404
113
+ error_model = JSON.load(response_content)
114
+ fail Haipa::Client::HaipaOperationError.new(result.request, http_response, error_model)
115
+ end
116
+
117
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
118
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
119
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
120
+ # Deserialize Response
121
+ if status_code == 200
122
+ begin
123
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
124
+ result_mapper = Haipa::Client::Compute::V1_0::Models::ODataValueIEnumerableMachine.mapper()
125
+ result.body = @client.deserialize(result_mapper, parsed_response)
126
+ rescue Exception => e
127
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
128
+ end
129
+ end
130
+
131
+ result
132
+ end
133
+
134
+ promise.execute
135
+ end
136
+
137
+ #
138
+ # @param config [MachineConfig]
139
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
140
+ # will be added to the HTTP request.
141
+ #
142
+ # @return [Operation] operation results.
143
+ #
144
+ def update_or_create(config:nil, custom_headers:nil)
145
+ response = update_or_create_async(config:config, custom_headers:custom_headers).value!
146
+ response.body unless response.nil?
147
+ end
148
+
149
+ #
150
+ # @param config [MachineConfig]
151
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
152
+ # will be added to the HTTP request.
153
+ #
154
+ # @return [Haipa::Client::HaipaOperationResponse] HTTP response information.
155
+ #
156
+ def update_or_create_with_http_info(config:nil, custom_headers:nil)
157
+ update_or_create_async(config:config, custom_headers:custom_headers).value!
158
+ end
159
+
160
+ #
161
+ # @param config [MachineConfig]
162
+ # @param [Hash{String => String}] A hash of custom headers that will be added
163
+ # to the HTTP request.
164
+ #
165
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
166
+ #
167
+ def update_or_create_async(config:nil, custom_headers:nil)
168
+
169
+
170
+ request_headers = {}
171
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
172
+
173
+ # Set Headers
174
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
175
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
176
+
177
+ # Serialize Request
178
+ request_mapper = Haipa::Client::Compute::V1_0::Models::MachineConfig.mapper()
179
+ request_content = @client.serialize(request_mapper, config)
180
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
181
+
182
+ path_template = 'odata/v1/Machines'
183
+
184
+ request_url = @base_url || @client.base_url
185
+
186
+ options = {
187
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02]],
188
+ body: request_content,
189
+ headers: request_headers.merge(custom_headers || {}),
190
+ base_url: request_url
191
+ }
192
+ promise = @client.make_request_async(:post, path_template, options)
193
+
194
+ promise = promise.then do |result|
195
+ http_response = result.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 Haipa::Client::HaipaOperationError.new(result.request, http_response, error_model)
201
+ end
202
+
203
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
204
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
205
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-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 = Haipa::Client::Compute::V1_0::Models::Operation.mapper()
211
+ result.body = @client.deserialize(result_mapper, parsed_response)
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
+ # @param key
225
+ # @param select [String] Limits the properties returned in the result.
226
+ # @param expand [String] Indicates the related entities to be represented
227
+ # inline. The maximum depth is 2.
228
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
229
+ # will be added to the HTTP request.
230
+ #
231
+ # @return [Machine] operation results.
232
+ #
233
+ def get(key, select:nil, expand:nil, custom_headers:nil)
234
+ response = get_async(key, select:select, expand:expand, custom_headers:custom_headers).value!
235
+ response.body unless response.nil?
236
+ end
237
+
238
+ #
239
+ # @param key
240
+ # @param select [String] Limits the properties returned in the result.
241
+ # @param expand [String] Indicates the related entities to be represented
242
+ # inline. The maximum depth is 2.
243
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
244
+ # will be added to the HTTP request.
245
+ #
246
+ # @return [Haipa::Client::HaipaOperationResponse] HTTP response information.
247
+ #
248
+ def get_with_http_info(key, select:nil, expand:nil, custom_headers:nil)
249
+ get_async(key, select:select, expand:expand, custom_headers:custom_headers).value!
250
+ end
251
+
252
+ #
253
+ # @param key
254
+ # @param select [String] Limits the properties returned in the result.
255
+ # @param expand [String] Indicates the related entities to be represented
256
+ # inline. The maximum depth is 2.
257
+ # @param [Hash{String => String}] A hash of custom headers that will be added
258
+ # to the HTTP request.
259
+ #
260
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
261
+ #
262
+ def get_async(key, select:nil, expand:nil, custom_headers:nil)
263
+ fail ArgumentError, 'key is nil' if key.nil?
264
+
265
+
266
+ request_headers = {}
267
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
268
+
269
+ # Set Headers
270
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
271
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
272
+ path_template = 'odata/v1/Machines({key})'
273
+
274
+ request_url = @base_url || @client.base_url
275
+
276
+ options = {
277
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02]],
278
+ path_params: {'key' => key},
279
+ query_params: {'$select' => select,'$expand' => expand},
280
+ headers: request_headers.merge(custom_headers || {}),
281
+ base_url: request_url
282
+ }
283
+ promise = @client.make_request_async(:get, path_template, options)
284
+
285
+ promise = promise.then do |result|
286
+ http_response = result.response
287
+ status_code = http_response.status
288
+ response_content = http_response.body
289
+ unless status_code == 200 || status_code == 404
290
+ error_model = JSON.load(response_content)
291
+ fail Haipa::Client::HaipaOperationError.new(result.request, http_response, error_model)
292
+ end
293
+
294
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
295
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
296
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
297
+ # Deserialize Response
298
+ if status_code == 200
299
+ begin
300
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
301
+ result_mapper = Haipa::Client::Compute::V1_0::Models::Machine.mapper()
302
+ result.body = @client.deserialize(result_mapper, parsed_response)
303
+ rescue Exception => e
304
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
305
+ end
306
+ end
307
+
308
+ result
309
+ end
310
+
311
+ promise.execute
312
+ end
313
+
314
+ #
315
+ # @param key
316
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
317
+ # will be added to the HTTP request.
318
+ #
319
+ # @return [Operation] operation results.
320
+ #
321
+ def delete(key, custom_headers:nil)
322
+ response = delete_async(key, custom_headers:custom_headers).value!
323
+ response.body unless response.nil?
324
+ end
325
+
326
+ #
327
+ # @param key
328
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
329
+ # will be added to the HTTP request.
330
+ #
331
+ # @return [Haipa::Client::HaipaOperationResponse] HTTP response information.
332
+ #
333
+ def delete_with_http_info(key, custom_headers:nil)
334
+ delete_async(key, custom_headers:custom_headers).value!
335
+ end
336
+
337
+ #
338
+ # @param key
339
+ # @param [Hash{String => String}] A hash of custom headers that will be added
340
+ # to the HTTP request.
341
+ #
342
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
343
+ #
344
+ def delete_async(key, custom_headers:nil)
345
+ fail ArgumentError, 'key is nil' if key.nil?
346
+
347
+
348
+ request_headers = {}
349
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
350
+
351
+ # Set Headers
352
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
353
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
354
+ path_template = 'odata/v1/Machines({key})'
355
+
356
+ request_url = @base_url || @client.base_url
357
+
358
+ options = {
359
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02]],
360
+ path_params: {'key' => key},
361
+ headers: request_headers.merge(custom_headers || {}),
362
+ base_url: request_url
363
+ }
364
+ promise = @client.make_request_async(:delete, path_template, options)
365
+
366
+ promise = promise.then do |result|
367
+ http_response = result.response
368
+ status_code = http_response.status
369
+ response_content = http_response.body
370
+ unless status_code == 200
371
+ error_model = JSON.load(response_content)
372
+ fail Haipa::Client::HaipaOperationError.new(result.request, http_response, error_model)
373
+ end
374
+
375
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
376
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
377
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
378
+ # Deserialize Response
379
+ if status_code == 200
380
+ begin
381
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
382
+ result_mapper = Haipa::Client::Compute::V1_0::Models::Operation.mapper()
383
+ result.body = @client.deserialize(result_mapper, parsed_response)
384
+ rescue Exception => e
385
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
386
+ end
387
+ end
388
+
389
+ result
390
+ end
391
+
392
+ promise.execute
393
+ end
394
+
395
+ #
396
+ # @param key
397
+ # @param select [String] Limits the properties returned in the result.
398
+ # @param expand [String] Indicates the related entities to be represented
399
+ # inline. The maximum depth is 2.
400
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
401
+ # will be added to the HTTP request.
402
+ #
403
+ # @return [Operation] operation results.
404
+ #
405
+ def start(key, select:nil, expand:nil, custom_headers:nil)
406
+ response = start_async(key, select:select, expand:expand, custom_headers:custom_headers).value!
407
+ response.body unless response.nil?
408
+ end
409
+
410
+ #
411
+ # @param key
412
+ # @param select [String] Limits the properties returned in the result.
413
+ # @param expand [String] Indicates the related entities to be represented
414
+ # inline. The maximum depth is 2.
415
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
416
+ # will be added to the HTTP request.
417
+ #
418
+ # @return [Haipa::Client::HaipaOperationResponse] HTTP response information.
419
+ #
420
+ def start_with_http_info(key, select:nil, expand:nil, custom_headers:nil)
421
+ start_async(key, select:select, expand:expand, custom_headers:custom_headers).value!
422
+ end
423
+
424
+ #
425
+ # @param key
426
+ # @param select [String] Limits the properties returned in the result.
427
+ # @param expand [String] Indicates the related entities to be represented
428
+ # inline. The maximum depth is 2.
429
+ # @param [Hash{String => String}] A hash of custom headers that will be added
430
+ # to the HTTP request.
431
+ #
432
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
433
+ #
434
+ def start_async(key, select:nil, expand:nil, custom_headers:nil)
435
+ fail ArgumentError, 'key is nil' if key.nil?
436
+
437
+
438
+ request_headers = {}
439
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
440
+
441
+ # Set Headers
442
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
443
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
444
+ path_template = 'odata/v1/Machines({key})/Start'
445
+
446
+ request_url = @base_url || @client.base_url
447
+
448
+ options = {
449
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02]],
450
+ path_params: {'key' => key},
451
+ query_params: {'$select' => select,'$expand' => expand},
452
+ headers: request_headers.merge(custom_headers || {}),
453
+ base_url: request_url
454
+ }
455
+ promise = @client.make_request_async(:post, path_template, options)
456
+
457
+ promise = promise.then do |result|
458
+ http_response = result.response
459
+ status_code = http_response.status
460
+ response_content = http_response.body
461
+ unless status_code == 200
462
+ error_model = JSON.load(response_content)
463
+ fail Haipa::Client::HaipaOperationError.new(result.request, http_response, error_model)
464
+ end
465
+
466
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
467
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
468
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
469
+ # Deserialize Response
470
+ if status_code == 200
471
+ begin
472
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
473
+ result_mapper = Haipa::Client::Compute::V1_0::Models::Operation.mapper()
474
+ result.body = @client.deserialize(result_mapper, parsed_response)
475
+ rescue Exception => e
476
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
477
+ end
478
+ end
479
+
480
+ result
481
+ end
482
+
483
+ promise.execute
484
+ end
485
+
486
+ #
487
+ # @param key
488
+ # @param select [String] Limits the properties returned in the result.
489
+ # @param expand [String] Indicates the related entities to be represented
490
+ # inline. The maximum depth is 2.
491
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
492
+ # will be added to the HTTP request.
493
+ #
494
+ # @return [Operation] operation results.
495
+ #
496
+ def stop(key, select:nil, expand:nil, custom_headers:nil)
497
+ response = stop_async(key, select:select, expand:expand, custom_headers:custom_headers).value!
498
+ response.body unless response.nil?
499
+ end
500
+
501
+ #
502
+ # @param key
503
+ # @param select [String] Limits the properties returned in the result.
504
+ # @param expand [String] Indicates the related entities to be represented
505
+ # inline. The maximum depth is 2.
506
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
507
+ # will be added to the HTTP request.
508
+ #
509
+ # @return [Haipa::Client::HaipaOperationResponse] HTTP response information.
510
+ #
511
+ def stop_with_http_info(key, select:nil, expand:nil, custom_headers:nil)
512
+ stop_async(key, select:select, expand:expand, custom_headers:custom_headers).value!
513
+ end
514
+
515
+ #
516
+ # @param key
517
+ # @param select [String] Limits the properties returned in the result.
518
+ # @param expand [String] Indicates the related entities to be represented
519
+ # inline. The maximum depth is 2.
520
+ # @param [Hash{String => String}] A hash of custom headers that will be added
521
+ # to the HTTP request.
522
+ #
523
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
524
+ #
525
+ def stop_async(key, select:nil, expand:nil, custom_headers:nil)
526
+ fail ArgumentError, 'key is nil' if key.nil?
527
+
528
+
529
+ request_headers = {}
530
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
531
+
532
+ # Set Headers
533
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
534
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
535
+ path_template = 'odata/v1/Machines({key})/Stop'
536
+
537
+ request_url = @base_url || @client.base_url
538
+
539
+ options = {
540
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02]],
541
+ path_params: {'key' => key},
542
+ query_params: {'$select' => select,'$expand' => expand},
543
+ headers: request_headers.merge(custom_headers || {}),
544
+ base_url: request_url
545
+ }
546
+ promise = @client.make_request_async(:post, path_template, options)
547
+
548
+ promise = promise.then do |result|
549
+ http_response = result.response
550
+ status_code = http_response.status
551
+ response_content = http_response.body
552
+ unless status_code == 200
553
+ error_model = JSON.load(response_content)
554
+ fail Haipa::Client::HaipaOperationError.new(result.request, http_response, error_model)
555
+ end
556
+
557
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
558
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
559
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
560
+ # Deserialize Response
561
+ if status_code == 200
562
+ begin
563
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
564
+ result_mapper = Haipa::Client::Compute::V1_0::Models::Operation.mapper()
565
+ result.body = @client.deserialize(result_mapper, parsed_response)
566
+ rescue Exception => e
567
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
568
+ end
569
+ end
570
+
571
+ result
572
+ end
573
+
574
+ promise.execute
575
+ end
576
+
577
+ end
578
+ end