azure_mgmt_reservations 0.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +21 -0
  3. data/lib/2017-11-01/generated/azure_mgmt_reservations.rb +53 -0
  4. data/lib/2017-11-01/generated/azure_mgmt_reservations/models/applied_reservation_list.rb +66 -0
  5. data/lib/2017-11-01/generated/azure_mgmt_reservations/models/applied_reservations.rb +85 -0
  6. data/lib/2017-11-01/generated/azure_mgmt_reservations/models/catalog.rb +166 -0
  7. data/lib/2017-11-01/generated/azure_mgmt_reservations/models/error.rb +48 -0
  8. data/lib/2017-11-01/generated/azure_mgmt_reservations/models/extended_error_info.rb +84 -0
  9. data/lib/2017-11-01/generated/azure_mgmt_reservations/models/extended_status_info.rb +61 -0
  10. data/lib/2017-11-01/generated/azure_mgmt_reservations/models/kind.rb +15 -0
  11. data/lib/2017-11-01/generated/azure_mgmt_reservations/models/merge_request.rb +56 -0
  12. data/lib/2017-11-01/generated/azure_mgmt_reservations/models/operation_display.rb +80 -0
  13. data/lib/2017-11-01/generated/azure_mgmt_reservations/models/operation_list.rb +98 -0
  14. data/lib/2017-11-01/generated/azure_mgmt_reservations/models/operation_response.rb +70 -0
  15. data/lib/2017-11-01/generated/azure_mgmt_reservations/models/patch.rb +66 -0
  16. data/lib/2017-11-01/generated/azure_mgmt_reservations/models/reservation_list.rb +98 -0
  17. data/lib/2017-11-01/generated/azure_mgmt_reservations/models/reservation_merge_properties.rb +70 -0
  18. data/lib/2017-11-01/generated/azure_mgmt_reservations/models/reservation_order_list.rb +98 -0
  19. data/lib/2017-11-01/generated/azure_mgmt_reservations/models/reservation_order_response.rb +187 -0
  20. data/lib/2017-11-01/generated/azure_mgmt_reservations/models/reservation_properties.rb +176 -0
  21. data/lib/2017-11-01/generated/azure_mgmt_reservations/models/reservation_response.rb +137 -0
  22. data/lib/2017-11-01/generated/azure_mgmt_reservations/models/reservation_split_properties.rb +70 -0
  23. data/lib/2017-11-01/generated/azure_mgmt_reservations/models/sku_capability.rb +58 -0
  24. data/lib/2017-11-01/generated/azure_mgmt_reservations/models/sku_name.rb +47 -0
  25. data/lib/2017-11-01/generated/azure_mgmt_reservations/models/sku_restriction.rb +79 -0
  26. data/lib/2017-11-01/generated/azure_mgmt_reservations/models/split_request.rb +69 -0
  27. data/lib/2017-11-01/generated/azure_mgmt_reservations/module_definition.rb +9 -0
  28. data/lib/2017-11-01/generated/azure_mgmt_reservations/operation.rb +228 -0
  29. data/lib/2017-11-01/generated/azure_mgmt_reservations/reservation.rb +1109 -0
  30. data/lib/2017-11-01/generated/azure_mgmt_reservations/reservation_order.rb +332 -0
  31. data/lib/2017-11-01/generated/azure_mgmt_reservations/reservations_management_client.rb +335 -0
  32. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations.rb +58 -0
  33. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/applied_reservation_list.rb +66 -0
  34. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/applied_reservations.rb +85 -0
  35. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/applied_scope_type.rb +16 -0
  36. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/catalog.rb +143 -0
  37. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/error.rb +48 -0
  38. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/error_response_code.rb +69 -0
  39. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/extended_error_info.rb +84 -0
  40. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/extended_status_info.rb +61 -0
  41. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/instance_flexibility.rb +17 -0
  42. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/merge_request.rb +56 -0
  43. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/operation_display.rb +80 -0
  44. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/operation_list.rb +98 -0
  45. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/operation_response.rb +70 -0
  46. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/patch.rb +89 -0
  47. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/reservation_list.rb +98 -0
  48. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/reservation_merge_properties.rb +70 -0
  49. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/reservation_order_list.rb +98 -0
  50. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/reservation_order_response.rb +184 -0
  51. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/reservation_properties.rb +208 -0
  52. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/reservation_response.rb +120 -0
  53. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/reservation_split_properties.rb +70 -0
  54. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/reservation_status_code.rb +23 -0
  55. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/reservation_term.rb +16 -0
  56. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/reserved_resource_type.rb +19 -0
  57. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/sku_name.rb +47 -0
  58. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/sku_property.rb +58 -0
  59. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/sku_restriction.rb +79 -0
  60. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/split_request.rb +69 -0
  61. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/module_definition.rb +9 -0
  62. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/operation.rb +228 -0
  63. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/reservation.rb +1109 -0
  64. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/reservation_order.rb +332 -0
  65. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/reservations_management_client.rb +348 -0
  66. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations.rb +64 -0
  67. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/applied_reservation_list.rb +66 -0
  68. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/applied_reservations.rb +85 -0
  69. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/applied_scope_type.rb +16 -0
  70. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/calculate_price_response.rb +48 -0
  71. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/calculate_price_response_properties.rb +110 -0
  72. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/calculate_price_response_properties_billing_currency_total.rb +59 -0
  73. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/calculate_price_response_properties_pricing_currency_total.rb +59 -0
  74. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/catalog.rb +143 -0
  75. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/error.rb +48 -0
  76. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/error_response_code.rb +69 -0
  77. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/extended_error_info.rb +84 -0
  78. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/extended_status_info.rb +61 -0
  79. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/instance_flexibility.rb +16 -0
  80. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/merge_request.rb +56 -0
  81. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/operation_display.rb +80 -0
  82. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/operation_list.rb +98 -0
  83. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/operation_response.rb +70 -0
  84. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/patch.rb +88 -0
  85. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/purchase_request.rb +159 -0
  86. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/purchase_request_properties_reserved_resource_properties.rb +48 -0
  87. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/reservation_list.rb +98 -0
  88. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/reservation_merge_properties.rb +70 -0
  89. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/reservation_order_list.rb +98 -0
  90. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/reservation_order_response.rb +183 -0
  91. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/reservation_properties.rb +206 -0
  92. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/reservation_response.rb +120 -0
  93. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/reservation_split_properties.rb +70 -0
  94. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/reservation_status_code.rb +23 -0
  95. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/reservation_term.rb +16 -0
  96. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/reserved_resource_type.rb +18 -0
  97. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/sku_name.rb +47 -0
  98. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/sku_property.rb +58 -0
  99. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/sku_restriction.rb +79 -0
  100. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/split_request.rb +69 -0
  101. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/module_definition.rb +9 -0
  102. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/operation.rb +228 -0
  103. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/reservation.rb +1072 -0
  104. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/reservation_order.rb +594 -0
  105. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/reservations_management_client.rb +348 -0
  106. data/lib/azure_mgmt_reservations.rb +8 -0
  107. data/lib/module_definition.rb +7 -0
  108. data/lib/profiles/latest/modules/reservations_profile_module.rb +201 -0
  109. data/lib/profiles/latest/reservations_latest_profile_client.rb +40 -0
  110. data/lib/profiles/latest/reservations_module_definition.rb +8 -0
  111. data/lib/version.rb +7 -0
  112. metadata +227 -0
@@ -0,0 +1,594 @@
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 Azure::Reservations::Mgmt::V2019_04_01_preview
7
+ #
8
+ # This API describe Azure Reservation
9
+ #
10
+ class ReservationOrder
11
+ include MsRestAzure
12
+
13
+ #
14
+ # Creates and initializes a new instance of the ReservationOrder class.
15
+ # @param client service class for accessing basic functionality.
16
+ #
17
+ def initialize(client)
18
+ @client = client
19
+ end
20
+
21
+ # @return [ReservationsManagementClient] reference to the ReservationsManagementClient
22
+ attr_reader :client
23
+
24
+ #
25
+ # Calculate price for a `ReservationOrder`.
26
+ #
27
+ # Calculate price for placing a `ReservationOrder`.
28
+ #
29
+ # @param body [PurchaseRequest] Information needed for calculate or purchase
30
+ # reservation
31
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
32
+ # will be added to the HTTP request.
33
+ #
34
+ # @return [CalculatePriceResponse] operation results.
35
+ #
36
+ def calculate(body, custom_headers:nil)
37
+ response = calculate_async(body, custom_headers:custom_headers).value!
38
+ response.body unless response.nil?
39
+ end
40
+
41
+ #
42
+ # Calculate price for a `ReservationOrder`.
43
+ #
44
+ # Calculate price for placing a `ReservationOrder`.
45
+ #
46
+ # @param body [PurchaseRequest] Information needed for calculate or purchase
47
+ # reservation
48
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
49
+ # will be added to the HTTP request.
50
+ #
51
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
52
+ #
53
+ def calculate_with_http_info(body, custom_headers:nil)
54
+ calculate_async(body, custom_headers:custom_headers).value!
55
+ end
56
+
57
+ #
58
+ # Calculate price for a `ReservationOrder`.
59
+ #
60
+ # Calculate price for placing a `ReservationOrder`.
61
+ #
62
+ # @param body [PurchaseRequest] Information needed for calculate or purchase
63
+ # reservation
64
+ # @param [Hash{String => String}] A hash of custom headers that will be added
65
+ # to the HTTP request.
66
+ #
67
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
68
+ #
69
+ def calculate_async(body, custom_headers:nil)
70
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
71
+ fail ArgumentError, 'body is nil' if body.nil?
72
+
73
+
74
+ request_headers = {}
75
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
76
+
77
+ # Set Headers
78
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
79
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
80
+
81
+ # Serialize Request
82
+ request_mapper = Azure::Reservations::Mgmt::V2019_04_01_preview::Models::PurchaseRequest.mapper()
83
+ request_content = @client.serialize(request_mapper, body)
84
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
85
+
86
+ path_template = 'providers/Microsoft.Capacity/calculatePrice'
87
+
88
+ request_url = @base_url || @client.base_url
89
+
90
+ options = {
91
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
92
+ query_params: {'api-version' => @client.api_version},
93
+ body: request_content,
94
+ headers: request_headers.merge(custom_headers || {}),
95
+ base_url: request_url
96
+ }
97
+ promise = @client.make_request_async(:post, path_template, options)
98
+
99
+ promise = promise.then do |result|
100
+ http_response = result.response
101
+ status_code = http_response.status
102
+ response_content = http_response.body
103
+ unless status_code == 200
104
+ error_model = JSON.load(response_content)
105
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
106
+ end
107
+
108
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
109
+ # Deserialize Response
110
+ if status_code == 200
111
+ begin
112
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
113
+ result_mapper = Azure::Reservations::Mgmt::V2019_04_01_preview::Models::CalculatePriceResponse.mapper()
114
+ result.body = @client.deserialize(result_mapper, parsed_response)
115
+ rescue Exception => e
116
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
117
+ end
118
+ end
119
+
120
+ result
121
+ end
122
+
123
+ promise.execute
124
+ end
125
+
126
+ #
127
+ # Get all `ReservationOrder`s.
128
+ #
129
+ # List of all the `ReservationOrder`s that the user has access to in the
130
+ # current tenant.
131
+ #
132
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
133
+ # will be added to the HTTP request.
134
+ #
135
+ # @return [Array<ReservationOrderResponse>] operation results.
136
+ #
137
+ def list(custom_headers:nil)
138
+ first_page = list_as_lazy(custom_headers:custom_headers)
139
+ first_page.get_all_items
140
+ end
141
+
142
+ #
143
+ # Get all `ReservationOrder`s.
144
+ #
145
+ # List of all the `ReservationOrder`s that the user has access to in the
146
+ # current tenant.
147
+ #
148
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
149
+ # will be added to the HTTP request.
150
+ #
151
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
152
+ #
153
+ def list_with_http_info(custom_headers:nil)
154
+ list_async(custom_headers:custom_headers).value!
155
+ end
156
+
157
+ #
158
+ # Get all `ReservationOrder`s.
159
+ #
160
+ # List of all the `ReservationOrder`s that the user has access to in the
161
+ # current tenant.
162
+ #
163
+ # @param [Hash{String => String}] A hash of custom headers that will be added
164
+ # to the HTTP request.
165
+ #
166
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
167
+ #
168
+ def list_async(custom_headers:nil)
169
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
170
+
171
+
172
+ request_headers = {}
173
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
174
+
175
+ # Set Headers
176
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
177
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
178
+ path_template = 'providers/Microsoft.Capacity/reservationOrders'
179
+
180
+ request_url = @base_url || @client.base_url
181
+
182
+ options = {
183
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
184
+ query_params: {'api-version' => @client.api_version},
185
+ headers: request_headers.merge(custom_headers || {}),
186
+ base_url: request_url
187
+ }
188
+ promise = @client.make_request_async(:get, path_template, options)
189
+
190
+ promise = promise.then do |result|
191
+ http_response = result.response
192
+ status_code = http_response.status
193
+ response_content = http_response.body
194
+ unless status_code == 200
195
+ error_model = JSON.load(response_content)
196
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
197
+ end
198
+
199
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
200
+ # Deserialize Response
201
+ if status_code == 200
202
+ begin
203
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
204
+ result_mapper = Azure::Reservations::Mgmt::V2019_04_01_preview::Models::ReservationOrderList.mapper()
205
+ result.body = @client.deserialize(result_mapper, parsed_response)
206
+ rescue Exception => e
207
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
208
+ end
209
+ end
210
+
211
+ result
212
+ end
213
+
214
+ promise.execute
215
+ end
216
+
217
+ #
218
+ # Purchase `ReservationOrder`
219
+ #
220
+ # Purchase `ReservationOrder` and create resource under the specified URI.
221
+ #
222
+ # @param reservation_order_id [String] Order Id of the reservation
223
+ # @param body [PurchaseRequest] Information needed for calculate or purchase
224
+ # reservation
225
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
226
+ # will be added to the HTTP request.
227
+ #
228
+ # @return [ReservationOrderResponse] operation results.
229
+ #
230
+ def purchase(reservation_order_id, body, custom_headers:nil)
231
+ response = purchase_async(reservation_order_id, body, custom_headers:custom_headers).value!
232
+ response.body unless response.nil?
233
+ end
234
+
235
+ #
236
+ # @param reservation_order_id [String] Order Id of the reservation
237
+ # @param body [PurchaseRequest] Information needed for calculate or purchase
238
+ # reservation
239
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
240
+ # will be added to the HTTP request.
241
+ #
242
+ # @return [Concurrent::Promise] promise which provides async access to http
243
+ # response.
244
+ #
245
+ def purchase_async(reservation_order_id, body, custom_headers:nil)
246
+ # Send request
247
+ promise = begin_purchase_async(reservation_order_id, body, custom_headers:custom_headers)
248
+
249
+ promise = promise.then do |response|
250
+ # Defining deserialization method.
251
+ deserialize_method = lambda do |parsed_response|
252
+ result_mapper = Azure::Reservations::Mgmt::V2019_04_01_preview::Models::ReservationOrderResponse.mapper()
253
+ parsed_response = @client.deserialize(result_mapper, parsed_response)
254
+ end
255
+
256
+ # Waiting for response.
257
+ @client.get_long_running_operation_result(response, deserialize_method)
258
+ end
259
+
260
+ promise
261
+ end
262
+
263
+ #
264
+ # Get a specific `ReservationOrder`.
265
+ #
266
+ # Get the details of the `ReservationOrder`.
267
+ #
268
+ # @param reservation_order_id [String] Order Id of the reservation
269
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
270
+ # will be added to the HTTP request.
271
+ #
272
+ # @return [ReservationOrderResponse] operation results.
273
+ #
274
+ def get(reservation_order_id, custom_headers:nil)
275
+ response = get_async(reservation_order_id, custom_headers:custom_headers).value!
276
+ response.body unless response.nil?
277
+ end
278
+
279
+ #
280
+ # Get a specific `ReservationOrder`.
281
+ #
282
+ # Get the details of the `ReservationOrder`.
283
+ #
284
+ # @param reservation_order_id [String] Order Id of the reservation
285
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
286
+ # will be added to the HTTP request.
287
+ #
288
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
289
+ #
290
+ def get_with_http_info(reservation_order_id, custom_headers:nil)
291
+ get_async(reservation_order_id, custom_headers:custom_headers).value!
292
+ end
293
+
294
+ #
295
+ # Get a specific `ReservationOrder`.
296
+ #
297
+ # Get the details of the `ReservationOrder`.
298
+ #
299
+ # @param reservation_order_id [String] Order Id of the reservation
300
+ # @param [Hash{String => String}] A hash of custom headers that will be added
301
+ # to the HTTP request.
302
+ #
303
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
304
+ #
305
+ def get_async(reservation_order_id, custom_headers:nil)
306
+ fail ArgumentError, 'reservation_order_id is nil' if reservation_order_id.nil?
307
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
308
+
309
+
310
+ request_headers = {}
311
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
312
+
313
+ # Set Headers
314
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
315
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
316
+ path_template = 'providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}'
317
+
318
+ request_url = @base_url || @client.base_url
319
+
320
+ options = {
321
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
322
+ path_params: {'reservationOrderId' => reservation_order_id},
323
+ query_params: {'api-version' => @client.api_version},
324
+ headers: request_headers.merge(custom_headers || {}),
325
+ base_url: request_url
326
+ }
327
+ promise = @client.make_request_async(:get, path_template, options)
328
+
329
+ promise = promise.then do |result|
330
+ http_response = result.response
331
+ status_code = http_response.status
332
+ response_content = http_response.body
333
+ unless status_code == 200
334
+ error_model = JSON.load(response_content)
335
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
336
+ end
337
+
338
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
339
+ # Deserialize Response
340
+ if status_code == 200
341
+ begin
342
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
343
+ result_mapper = Azure::Reservations::Mgmt::V2019_04_01_preview::Models::ReservationOrderResponse.mapper()
344
+ result.body = @client.deserialize(result_mapper, parsed_response)
345
+ rescue Exception => e
346
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
347
+ end
348
+ end
349
+
350
+ result
351
+ end
352
+
353
+ promise.execute
354
+ end
355
+
356
+ #
357
+ # Purchase `ReservationOrder`
358
+ #
359
+ # Purchase `ReservationOrder` and create resource under the specified URI.
360
+ #
361
+ # @param reservation_order_id [String] Order Id of the reservation
362
+ # @param body [PurchaseRequest] Information needed for calculate or purchase
363
+ # reservation
364
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
365
+ # will be added to the HTTP request.
366
+ #
367
+ # @return [ReservationOrderResponse] operation results.
368
+ #
369
+ def begin_purchase(reservation_order_id, body, custom_headers:nil)
370
+ response = begin_purchase_async(reservation_order_id, body, custom_headers:custom_headers).value!
371
+ response.body unless response.nil?
372
+ end
373
+
374
+ #
375
+ # Purchase `ReservationOrder`
376
+ #
377
+ # Purchase `ReservationOrder` and create resource under the specified URI.
378
+ #
379
+ # @param reservation_order_id [String] Order Id of the reservation
380
+ # @param body [PurchaseRequest] Information needed for calculate or purchase
381
+ # reservation
382
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
383
+ # will be added to the HTTP request.
384
+ #
385
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
386
+ #
387
+ def begin_purchase_with_http_info(reservation_order_id, body, custom_headers:nil)
388
+ begin_purchase_async(reservation_order_id, body, custom_headers:custom_headers).value!
389
+ end
390
+
391
+ #
392
+ # Purchase `ReservationOrder`
393
+ #
394
+ # Purchase `ReservationOrder` and create resource under the specified URI.
395
+ #
396
+ # @param reservation_order_id [String] Order Id of the reservation
397
+ # @param body [PurchaseRequest] Information needed for calculate or purchase
398
+ # reservation
399
+ # @param [Hash{String => String}] A hash of custom headers that will be added
400
+ # to the HTTP request.
401
+ #
402
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
403
+ #
404
+ def begin_purchase_async(reservation_order_id, body, custom_headers:nil)
405
+ fail ArgumentError, 'reservation_order_id is nil' if reservation_order_id.nil?
406
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
407
+ fail ArgumentError, 'body is nil' if body.nil?
408
+
409
+
410
+ request_headers = {}
411
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
412
+
413
+ # Set Headers
414
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
415
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
416
+
417
+ # Serialize Request
418
+ request_mapper = Azure::Reservations::Mgmt::V2019_04_01_preview::Models::PurchaseRequest.mapper()
419
+ request_content = @client.serialize(request_mapper, body)
420
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
421
+
422
+ path_template = 'providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}'
423
+
424
+ request_url = @base_url || @client.base_url
425
+
426
+ options = {
427
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
428
+ path_params: {'reservationOrderId' => reservation_order_id},
429
+ query_params: {'api-version' => @client.api_version},
430
+ body: request_content,
431
+ headers: request_headers.merge(custom_headers || {}),
432
+ base_url: request_url
433
+ }
434
+ promise = @client.make_request_async(:put, path_template, options)
435
+
436
+ promise = promise.then do |result|
437
+ http_response = result.response
438
+ status_code = http_response.status
439
+ response_content = http_response.body
440
+ unless status_code == 200 || status_code == 202
441
+ error_model = JSON.load(response_content)
442
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
443
+ end
444
+
445
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
446
+ # Deserialize Response
447
+ if status_code == 200
448
+ begin
449
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
450
+ result_mapper = Azure::Reservations::Mgmt::V2019_04_01_preview::Models::ReservationOrderResponse.mapper()
451
+ result.body = @client.deserialize(result_mapper, parsed_response)
452
+ rescue Exception => e
453
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
454
+ end
455
+ end
456
+ # Deserialize Response
457
+ if status_code == 202
458
+ begin
459
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
460
+ result_mapper = Azure::Reservations::Mgmt::V2019_04_01_preview::Models::ReservationOrderResponse.mapper()
461
+ result.body = @client.deserialize(result_mapper, parsed_response)
462
+ rescue Exception => e
463
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
464
+ end
465
+ end
466
+
467
+ result
468
+ end
469
+
470
+ promise.execute
471
+ end
472
+
473
+ #
474
+ # Get all `ReservationOrder`s.
475
+ #
476
+ # List of all the `ReservationOrder`s that the user has access to in the
477
+ # current tenant.
478
+ #
479
+ # @param next_page_link [String] The NextLink from the previous successful call
480
+ # to List operation.
481
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
482
+ # will be added to the HTTP request.
483
+ #
484
+ # @return [ReservationOrderList] operation results.
485
+ #
486
+ def list_next(next_page_link, custom_headers:nil)
487
+ response = list_next_async(next_page_link, custom_headers:custom_headers).value!
488
+ response.body unless response.nil?
489
+ end
490
+
491
+ #
492
+ # Get all `ReservationOrder`s.
493
+ #
494
+ # List of all the `ReservationOrder`s that the user has access to in the
495
+ # current tenant.
496
+ #
497
+ # @param next_page_link [String] The NextLink from the previous successful call
498
+ # to List operation.
499
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
500
+ # will be added to the HTTP request.
501
+ #
502
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
503
+ #
504
+ def list_next_with_http_info(next_page_link, custom_headers:nil)
505
+ list_next_async(next_page_link, custom_headers:custom_headers).value!
506
+ end
507
+
508
+ #
509
+ # Get all `ReservationOrder`s.
510
+ #
511
+ # List of all the `ReservationOrder`s that the user has access to in the
512
+ # current tenant.
513
+ #
514
+ # @param next_page_link [String] The NextLink from the previous successful call
515
+ # to List operation.
516
+ # @param [Hash{String => String}] A hash of custom headers that will be added
517
+ # to the HTTP request.
518
+ #
519
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
520
+ #
521
+ def list_next_async(next_page_link, custom_headers:nil)
522
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
523
+
524
+
525
+ request_headers = {}
526
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
527
+
528
+ # Set Headers
529
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
530
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
531
+ path_template = '{nextLink}'
532
+
533
+ request_url = @base_url || @client.base_url
534
+
535
+ options = {
536
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
537
+ skip_encoding_path_params: {'nextLink' => next_page_link},
538
+ headers: request_headers.merge(custom_headers || {}),
539
+ base_url: request_url
540
+ }
541
+ promise = @client.make_request_async(:get, path_template, options)
542
+
543
+ promise = promise.then do |result|
544
+ http_response = result.response
545
+ status_code = http_response.status
546
+ response_content = http_response.body
547
+ unless status_code == 200
548
+ error_model = JSON.load(response_content)
549
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
550
+ end
551
+
552
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
553
+ # Deserialize Response
554
+ if status_code == 200
555
+ begin
556
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
557
+ result_mapper = Azure::Reservations::Mgmt::V2019_04_01_preview::Models::ReservationOrderList.mapper()
558
+ result.body = @client.deserialize(result_mapper, parsed_response)
559
+ rescue Exception => e
560
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
561
+ end
562
+ end
563
+
564
+ result
565
+ end
566
+
567
+ promise.execute
568
+ end
569
+
570
+ #
571
+ # Get all `ReservationOrder`s.
572
+ #
573
+ # List of all the `ReservationOrder`s that the user has access to in the
574
+ # current tenant.
575
+ #
576
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
577
+ # will be added to the HTTP request.
578
+ #
579
+ # @return [ReservationOrderList] which provide lazy access to pages of the
580
+ # response.
581
+ #
582
+ def list_as_lazy(custom_headers:nil)
583
+ response = list_async(custom_headers:custom_headers).value!
584
+ unless response.nil?
585
+ page = response.body
586
+ page.next_method = Proc.new do |next_page_link|
587
+ list_next_async(next_page_link, custom_headers:custom_headers)
588
+ end
589
+ page
590
+ end
591
+ end
592
+
593
+ end
594
+ end