azure_mgmt_reservations 0.20.0

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