azure_mgmt_advisor 0.17.0 → 0.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. checksums.yaml +5 -5
  2. data/lib/2016-07-12-preview/generated/azure_mgmt_advisor/advisor_management_client.rb +1 -1
  3. data/lib/2016-07-12-preview/generated/azure_mgmt_advisor/operations.rb +4 -0
  4. data/lib/2016-07-12-preview/generated/azure_mgmt_advisor/recommendations.rb +10 -0
  5. data/lib/2016-07-12-preview/generated/azure_mgmt_advisor/suppressions.rb +8 -0
  6. data/lib/2017-03-31/generated/azure_mgmt_advisor/advisor_management_client.rb +1 -1
  7. data/lib/2017-03-31/generated/azure_mgmt_advisor/operations.rb +4 -0
  8. data/lib/2017-03-31/generated/azure_mgmt_advisor/recommendations.rb +10 -0
  9. data/lib/2017-03-31/generated/azure_mgmt_advisor/suppressions.rb +8 -0
  10. data/lib/2017-04-19/generated/azure_mgmt_advisor/advisor_management_client.rb +1 -1
  11. data/lib/2017-04-19/generated/azure_mgmt_advisor/configurations.rb +10 -0
  12. data/lib/2017-04-19/generated/azure_mgmt_advisor/operations.rb +4 -0
  13. data/lib/2017-04-19/generated/azure_mgmt_advisor/recommendations.rb +10 -0
  14. data/lib/2017-04-19/generated/azure_mgmt_advisor/suppressions.rb +10 -0
  15. data/lib/2020-01-01/generated/azure_mgmt_advisor.rb +56 -0
  16. data/lib/2020-01-01/generated/azure_mgmt_advisor/advisor_management_client.rb +148 -0
  17. data/lib/2020-01-01/generated/azure_mgmt_advisor/configurations.rb +547 -0
  18. data/lib/2020-01-01/generated/azure_mgmt_advisor/models/arm_error_response.rb +48 -0
  19. data/lib/2020-01-01/generated/azure_mgmt_advisor/models/armerror_response_body.rb +59 -0
  20. data/lib/2020-01-01/generated/azure_mgmt_advisor/models/category.rb +19 -0
  21. data/lib/2020-01-01/generated/azure_mgmt_advisor/models/config_data.rb +108 -0
  22. data/lib/2020-01-01/generated/azure_mgmt_advisor/models/configuration_list_result.rb +98 -0
  23. data/lib/2020-01-01/generated/azure_mgmt_advisor/models/cpu_threshold.rb +18 -0
  24. data/lib/2020-01-01/generated/azure_mgmt_advisor/models/digest_config.rb +115 -0
  25. data/lib/2020-01-01/generated/azure_mgmt_advisor/models/digest_config_state.rb +16 -0
  26. data/lib/2020-01-01/generated/azure_mgmt_advisor/models/impact.rb +17 -0
  27. data/lib/2020-01-01/generated/azure_mgmt_advisor/models/metadata_entity.rb +140 -0
  28. data/lib/2020-01-01/generated/azure_mgmt_advisor/models/metadata_entity_list_result.rb +98 -0
  29. data/lib/2020-01-01/generated/azure_mgmt_advisor/models/metadata_supported_value_detail.rb +57 -0
  30. data/lib/2020-01-01/generated/azure_mgmt_advisor/models/operation_display_info.rb +80 -0
  31. data/lib/2020-01-01/generated/azure_mgmt_advisor/models/operation_entity.rb +58 -0
  32. data/lib/2020-01-01/generated/azure_mgmt_advisor/models/operation_entity_list_result.rb +98 -0
  33. data/lib/2020-01-01/generated/azure_mgmt_advisor/models/resource.rb +80 -0
  34. data/lib/2020-01-01/generated/azure_mgmt_advisor/models/resource_metadata.rb +57 -0
  35. data/lib/2020-01-01/generated/azure_mgmt_advisor/models/resource_recommendation_base.rb +225 -0
  36. data/lib/2020-01-01/generated/azure_mgmt_advisor/models/resource_recommendation_base_list_result.rb +99 -0
  37. data/lib/2020-01-01/generated/azure_mgmt_advisor/models/risk.rb +17 -0
  38. data/lib/2020-01-01/generated/azure_mgmt_advisor/models/scenario.rb +15 -0
  39. data/lib/2020-01-01/generated/azure_mgmt_advisor/models/short_description.rb +59 -0
  40. data/lib/2020-01-01/generated/azure_mgmt_advisor/models/suppression_contract.rb +85 -0
  41. data/lib/2020-01-01/generated/azure_mgmt_advisor/models/suppression_contract_list_result.rb +98 -0
  42. data/lib/2020-01-01/generated/azure_mgmt_advisor/module_definition.rb +9 -0
  43. data/lib/2020-01-01/generated/azure_mgmt_advisor/operations.rb +219 -0
  44. data/lib/2020-01-01/generated/azure_mgmt_advisor/recommendation_metadata.rb +318 -0
  45. data/lib/2020-01-01/generated/azure_mgmt_advisor/recommendations.rb +513 -0
  46. data/lib/2020-01-01/generated/azure_mgmt_advisor/suppressions.rb +563 -0
  47. data/lib/azure_mgmt_advisor.rb +2 -1
  48. data/lib/profiles/latest/modules/advisor_profile_module.rb +80 -46
  49. data/lib/version.rb +1 -1
  50. metadata +37 -5
@@ -0,0 +1,318 @@
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::Advisor::Mgmt::V2020_01_01
7
+ #
8
+ # REST APIs for Azure Advisor
9
+ #
10
+ class RecommendationMetadata
11
+ include MsRestAzure
12
+
13
+ #
14
+ # Creates and initializes a new instance of the RecommendationMetadata class.
15
+ # @param client service class for accessing basic functionality.
16
+ #
17
+ def initialize(client)
18
+ @client = client
19
+ end
20
+
21
+ # @return [AdvisorManagementClient] reference to the AdvisorManagementClient
22
+ attr_reader :client
23
+
24
+ #
25
+ # Gets the metadata entity.
26
+ #
27
+ # @param name [String] Name of metadata entity.
28
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
29
+ # will be added to the HTTP request.
30
+ #
31
+ # @return [Object] operation results.
32
+ #
33
+ def get(name, custom_headers:nil)
34
+ response = get_async(name, custom_headers:custom_headers).value!
35
+ response.body unless response.nil?
36
+ end
37
+
38
+ #
39
+ # Gets the metadata entity.
40
+ #
41
+ # @param name [String] Name of metadata entity.
42
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
43
+ # will be added to the HTTP request.
44
+ #
45
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
46
+ #
47
+ def get_with_http_info(name, custom_headers:nil)
48
+ get_async(name, custom_headers:custom_headers).value!
49
+ end
50
+
51
+ #
52
+ # Gets the metadata entity.
53
+ #
54
+ # @param name [String] Name of metadata entity.
55
+ # @param [Hash{String => String}] A hash of custom headers that will be added
56
+ # to the HTTP request.
57
+ #
58
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
59
+ #
60
+ def get_async(name, custom_headers:nil)
61
+ fail ArgumentError, 'name is nil' if name.nil?
62
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
63
+
64
+
65
+ request_headers = {}
66
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
67
+
68
+ # Set Headers
69
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
70
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
71
+ path_template = 'providers/Microsoft.Advisor/metadata/{name}'
72
+
73
+ request_url = @base_url || @client.base_url
74
+
75
+ options = {
76
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
77
+ path_params: {'name' => name},
78
+ query_params: {'api-version' => @client.api_version},
79
+ headers: request_headers.merge(custom_headers || {}),
80
+ base_url: request_url
81
+ }
82
+ promise = @client.make_request_async(:get, path_template, options)
83
+
84
+ promise = promise.then do |result|
85
+ http_response = result.response
86
+ status_code = http_response.status
87
+ response_content = http_response.body
88
+ unless status_code == 200 || status_code == 404
89
+ error_model = JSON.load(response_content)
90
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
91
+ end
92
+
93
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
94
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
95
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
96
+ # Deserialize Response
97
+ if status_code == 200
98
+ begin
99
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
100
+ result_mapper = Azure::Advisor::Mgmt::V2020_01_01::Models::MetadataEntity.mapper()
101
+ result.body = @client.deserialize(result_mapper, parsed_response)
102
+ rescue Exception => e
103
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
104
+ end
105
+ end
106
+ # Deserialize Response
107
+ if status_code == 404
108
+ begin
109
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
110
+ result_mapper = Azure::Advisor::Mgmt::V2020_01_01::Models::ARMErrorResponseBody.mapper()
111
+ result.body = @client.deserialize(result_mapper, parsed_response)
112
+ rescue Exception => e
113
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
114
+ end
115
+ end
116
+
117
+ result
118
+ end
119
+
120
+ promise.execute
121
+ end
122
+
123
+ #
124
+ # Gets the list of metadata entities.
125
+ #
126
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
127
+ # will be added to the HTTP request.
128
+ #
129
+ # @return [Array<MetadataEntity>] operation results.
130
+ #
131
+ def list(custom_headers:nil)
132
+ first_page = list_as_lazy(custom_headers:custom_headers)
133
+ first_page.get_all_items
134
+ end
135
+
136
+ #
137
+ # Gets the list of metadata entities.
138
+ #
139
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
140
+ # will be added to the HTTP request.
141
+ #
142
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
143
+ #
144
+ def list_with_http_info(custom_headers:nil)
145
+ list_async(custom_headers:custom_headers).value!
146
+ end
147
+
148
+ #
149
+ # Gets the list of metadata entities.
150
+ #
151
+ # @param [Hash{String => String}] A hash of custom headers that will be added
152
+ # to the HTTP request.
153
+ #
154
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
155
+ #
156
+ def list_async(custom_headers:nil)
157
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
158
+
159
+
160
+ request_headers = {}
161
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
162
+
163
+ # Set Headers
164
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
165
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
166
+ path_template = 'providers/Microsoft.Advisor/metadata'
167
+
168
+ request_url = @base_url || @client.base_url
169
+
170
+ options = {
171
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
172
+ query_params: {'api-version' => @client.api_version},
173
+ headers: request_headers.merge(custom_headers || {}),
174
+ base_url: request_url
175
+ }
176
+ promise = @client.make_request_async(:get, path_template, options)
177
+
178
+ promise = promise.then do |result|
179
+ http_response = result.response
180
+ status_code = http_response.status
181
+ response_content = http_response.body
182
+ unless status_code == 200
183
+ error_model = JSON.load(response_content)
184
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
185
+ end
186
+
187
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
188
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
189
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
190
+ # Deserialize Response
191
+ if status_code == 200
192
+ begin
193
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
194
+ result_mapper = Azure::Advisor::Mgmt::V2020_01_01::Models::MetadataEntityListResult.mapper()
195
+ result.body = @client.deserialize(result_mapper, parsed_response)
196
+ rescue Exception => e
197
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
198
+ end
199
+ end
200
+
201
+ result
202
+ end
203
+
204
+ promise.execute
205
+ end
206
+
207
+ #
208
+ # Gets the list of metadata entities.
209
+ #
210
+ # @param next_page_link [String] The NextLink from the previous successful call
211
+ # to List operation.
212
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
213
+ # will be added to the HTTP request.
214
+ #
215
+ # @return [MetadataEntityListResult] operation results.
216
+ #
217
+ def list_next(next_page_link, custom_headers:nil)
218
+ response = list_next_async(next_page_link, custom_headers:custom_headers).value!
219
+ response.body unless response.nil?
220
+ end
221
+
222
+ #
223
+ # Gets the list of metadata entities.
224
+ #
225
+ # @param next_page_link [String] The NextLink from the previous successful call
226
+ # to List operation.
227
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
228
+ # will be added to the HTTP request.
229
+ #
230
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
231
+ #
232
+ def list_next_with_http_info(next_page_link, custom_headers:nil)
233
+ list_next_async(next_page_link, custom_headers:custom_headers).value!
234
+ end
235
+
236
+ #
237
+ # Gets the list of metadata entities.
238
+ #
239
+ # @param next_page_link [String] The NextLink from the previous successful call
240
+ # to List operation.
241
+ # @param [Hash{String => String}] A hash of custom headers that will be added
242
+ # to the HTTP request.
243
+ #
244
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
245
+ #
246
+ def list_next_async(next_page_link, custom_headers:nil)
247
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
248
+
249
+
250
+ request_headers = {}
251
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
252
+
253
+ # Set Headers
254
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
255
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
256
+ path_template = '{nextLink}'
257
+
258
+ request_url = @base_url || @client.base_url
259
+
260
+ options = {
261
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
262
+ skip_encoding_path_params: {'nextLink' => next_page_link},
263
+ headers: request_headers.merge(custom_headers || {}),
264
+ base_url: request_url
265
+ }
266
+ promise = @client.make_request_async(:get, path_template, options)
267
+
268
+ promise = promise.then do |result|
269
+ http_response = result.response
270
+ status_code = http_response.status
271
+ response_content = http_response.body
272
+ unless status_code == 200
273
+ error_model = JSON.load(response_content)
274
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
275
+ end
276
+
277
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
278
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
279
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
280
+ # Deserialize Response
281
+ if status_code == 200
282
+ begin
283
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
284
+ result_mapper = Azure::Advisor::Mgmt::V2020_01_01::Models::MetadataEntityListResult.mapper()
285
+ result.body = @client.deserialize(result_mapper, parsed_response)
286
+ rescue Exception => e
287
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
288
+ end
289
+ end
290
+
291
+ result
292
+ end
293
+
294
+ promise.execute
295
+ end
296
+
297
+ #
298
+ # Gets the list of metadata entities.
299
+ #
300
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
301
+ # will be added to the HTTP request.
302
+ #
303
+ # @return [MetadataEntityListResult] which provide lazy access to pages of the
304
+ # response.
305
+ #
306
+ def list_as_lazy(custom_headers:nil)
307
+ response = list_async(custom_headers:custom_headers).value!
308
+ unless response.nil?
309
+ page = response.body
310
+ page.next_method = Proc.new do |next_page_link|
311
+ list_next_async(next_page_link, custom_headers:custom_headers)
312
+ end
313
+ page
314
+ end
315
+ end
316
+
317
+ end
318
+ end
@@ -0,0 +1,513 @@
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::Advisor::Mgmt::V2020_01_01
7
+ #
8
+ # REST APIs for Azure Advisor
9
+ #
10
+ class Recommendations
11
+ include MsRestAzure
12
+
13
+ #
14
+ # Creates and initializes a new instance of the Recommendations class.
15
+ # @param client service class for accessing basic functionality.
16
+ #
17
+ def initialize(client)
18
+ @client = client
19
+ end
20
+
21
+ # @return [AdvisorManagementClient] reference to the AdvisorManagementClient
22
+ attr_reader :client
23
+
24
+ #
25
+ # Initiates the recommendation generation or computation process for a
26
+ # subscription. This operation is asynchronous. The generated recommendations
27
+ # are stored in a cache in the Advisor service.
28
+ #
29
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
30
+ # will be added to the HTTP request.
31
+ #
32
+ #
33
+ def generate(custom_headers:nil)
34
+ response = generate_async(custom_headers:custom_headers).value!
35
+ nil
36
+ end
37
+
38
+ #
39
+ # Initiates the recommendation generation or computation process for a
40
+ # subscription. This operation is asynchronous. The generated recommendations
41
+ # are stored in a cache in the Advisor service.
42
+ #
43
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
44
+ # will be added to the HTTP request.
45
+ #
46
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
47
+ #
48
+ def generate_with_http_info(custom_headers:nil)
49
+ generate_async(custom_headers:custom_headers).value!
50
+ end
51
+
52
+ #
53
+ # Initiates the recommendation generation or computation process for a
54
+ # subscription. This operation is asynchronous. The generated recommendations
55
+ # are stored in a cache in the Advisor service.
56
+ #
57
+ # @param [Hash{String => String}] A hash of custom headers that will be added
58
+ # to the HTTP request.
59
+ #
60
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
61
+ #
62
+ def generate_async(custom_headers:nil)
63
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
64
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
65
+
66
+
67
+ request_headers = {}
68
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
69
+
70
+ # Set Headers
71
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
72
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
73
+ path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.Advisor/generateRecommendations'
74
+
75
+ request_url = @base_url || @client.base_url
76
+
77
+ options = {
78
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
79
+ path_params: {'subscriptionId' => @client.subscription_id},
80
+ query_params: {'api-version' => @client.api_version},
81
+ headers: request_headers.merge(custom_headers || {}),
82
+ base_url: request_url
83
+ }
84
+ promise = @client.make_request_async(:post, path_template, options)
85
+
86
+ promise = promise.then do |result|
87
+ http_response = result.response
88
+ status_code = http_response.status
89
+ response_content = http_response.body
90
+ unless status_code == 202
91
+ error_model = JSON.load(response_content)
92
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
93
+ end
94
+
95
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
96
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
97
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
98
+
99
+ result
100
+ end
101
+
102
+ promise.execute
103
+ end
104
+
105
+ #
106
+ # Retrieves the status of the recommendation computation or generation process.
107
+ # Invoke this API after calling the generation recommendation. The URI of this
108
+ # API is returned in the Location field of the response header.
109
+ #
110
+ # @param operation_id The operation ID, which can be found from the Location
111
+ # field in the generate recommendation response header.
112
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
113
+ # will be added to the HTTP request.
114
+ #
115
+ #
116
+ def get_generate_status(operation_id, custom_headers:nil)
117
+ response = get_generate_status_async(operation_id, custom_headers:custom_headers).value!
118
+ nil
119
+ end
120
+
121
+ #
122
+ # Retrieves the status of the recommendation computation or generation process.
123
+ # Invoke this API after calling the generation recommendation. The URI of this
124
+ # API is returned in the Location field of the response header.
125
+ #
126
+ # @param operation_id The operation ID, which can be found from the Location
127
+ # field in the generate recommendation response header.
128
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
129
+ # will be added to the HTTP request.
130
+ #
131
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
132
+ #
133
+ def get_generate_status_with_http_info(operation_id, custom_headers:nil)
134
+ get_generate_status_async(operation_id, custom_headers:custom_headers).value!
135
+ end
136
+
137
+ #
138
+ # Retrieves the status of the recommendation computation or generation process.
139
+ # Invoke this API after calling the generation recommendation. The URI of this
140
+ # API is returned in the Location field of the response header.
141
+ #
142
+ # @param operation_id The operation ID, which can be found from the Location
143
+ # field in the generate recommendation response header.
144
+ # @param [Hash{String => String}] A hash of custom headers that will be added
145
+ # to the HTTP request.
146
+ #
147
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
148
+ #
149
+ def get_generate_status_async(operation_id, custom_headers:nil)
150
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
151
+ fail ArgumentError, 'operation_id is nil' if operation_id.nil?
152
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
153
+
154
+
155
+ request_headers = {}
156
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
157
+
158
+ # Set Headers
159
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
160
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
161
+ path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.Advisor/generateRecommendations/{operationId}'
162
+
163
+ request_url = @base_url || @client.base_url
164
+
165
+ options = {
166
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
167
+ path_params: {'subscriptionId' => @client.subscription_id,'operationId' => operation_id},
168
+ query_params: {'api-version' => @client.api_version},
169
+ headers: request_headers.merge(custom_headers || {}),
170
+ base_url: request_url
171
+ }
172
+ promise = @client.make_request_async(:get, path_template, options)
173
+
174
+ promise = promise.then do |result|
175
+ http_response = result.response
176
+ status_code = http_response.status
177
+ response_content = http_response.body
178
+ unless status_code == 202 || status_code == 204
179
+ error_model = JSON.load(response_content)
180
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
181
+ end
182
+
183
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
184
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
185
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
186
+
187
+ result
188
+ end
189
+
190
+ promise.execute
191
+ end
192
+
193
+ #
194
+ # Obtains cached recommendations for a subscription. The recommendations are
195
+ # generated or computed by invoking generateRecommendations.
196
+ #
197
+ # @param filter [String] The filter to apply to the recommendations.
198
+ # @param top [Integer] The number of recommendations per page if a paged
199
+ # version of this API is being used.
200
+ # @param skip_token [String] The page-continuation token to use with a paged
201
+ # version of this API.
202
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
203
+ # will be added to the HTTP request.
204
+ #
205
+ # @return [Array<ResourceRecommendationBase>] operation results.
206
+ #
207
+ def list(filter:nil, top:nil, skip_token:nil, custom_headers:nil)
208
+ first_page = list_as_lazy(filter:filter, top:top, skip_token:skip_token, custom_headers:custom_headers)
209
+ first_page.get_all_items
210
+ end
211
+
212
+ #
213
+ # Obtains cached recommendations for a subscription. The recommendations are
214
+ # generated or computed by invoking generateRecommendations.
215
+ #
216
+ # @param filter [String] The filter to apply to the recommendations.
217
+ # @param top [Integer] The number of recommendations per page if a paged
218
+ # version of this API is being used.
219
+ # @param skip_token [String] The page-continuation token to use with a paged
220
+ # version of this API.
221
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
222
+ # will be added to the HTTP request.
223
+ #
224
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
225
+ #
226
+ def list_with_http_info(filter:nil, top:nil, skip_token:nil, custom_headers:nil)
227
+ list_async(filter:filter, top:top, skip_token:skip_token, custom_headers:custom_headers).value!
228
+ end
229
+
230
+ #
231
+ # Obtains cached recommendations for a subscription. The recommendations are
232
+ # generated or computed by invoking generateRecommendations.
233
+ #
234
+ # @param filter [String] The filter to apply to the recommendations.
235
+ # @param top [Integer] The number of recommendations per page if a paged
236
+ # version of this API is being used.
237
+ # @param skip_token [String] The page-continuation token to use with a paged
238
+ # version of this API.
239
+ # @param [Hash{String => String}] A hash of custom headers that will be added
240
+ # to the HTTP request.
241
+ #
242
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
243
+ #
244
+ def list_async(filter:nil, top:nil, skip_token:nil, custom_headers:nil)
245
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
246
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
247
+
248
+
249
+ request_headers = {}
250
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
251
+
252
+ # Set Headers
253
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
254
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
255
+ path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.Advisor/recommendations'
256
+
257
+ request_url = @base_url || @client.base_url
258
+
259
+ options = {
260
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
261
+ path_params: {'subscriptionId' => @client.subscription_id},
262
+ query_params: {'api-version' => @client.api_version,'$filter' => filter,'$top' => top,'$skipToken' => skip_token},
263
+ headers: request_headers.merge(custom_headers || {}),
264
+ base_url: request_url
265
+ }
266
+ promise = @client.make_request_async(:get, path_template, options)
267
+
268
+ promise = promise.then do |result|
269
+ http_response = result.response
270
+ status_code = http_response.status
271
+ response_content = http_response.body
272
+ unless status_code == 200
273
+ error_model = JSON.load(response_content)
274
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
275
+ end
276
+
277
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
278
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
279
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
280
+ # Deserialize Response
281
+ if status_code == 200
282
+ begin
283
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
284
+ result_mapper = Azure::Advisor::Mgmt::V2020_01_01::Models::ResourceRecommendationBaseListResult.mapper()
285
+ result.body = @client.deserialize(result_mapper, parsed_response)
286
+ rescue Exception => e
287
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
288
+ end
289
+ end
290
+
291
+ result
292
+ end
293
+
294
+ promise.execute
295
+ end
296
+
297
+ #
298
+ # Obtains details of a cached recommendation.
299
+ #
300
+ # @param resource_uri [String] The fully qualified Azure Resource Manager
301
+ # identifier of the resource to which the recommendation applies.
302
+ # @param recommendation_id [String] The recommendation ID.
303
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
304
+ # will be added to the HTTP request.
305
+ #
306
+ # @return [ResourceRecommendationBase] operation results.
307
+ #
308
+ def get(resource_uri, recommendation_id, custom_headers:nil)
309
+ response = get_async(resource_uri, recommendation_id, custom_headers:custom_headers).value!
310
+ response.body unless response.nil?
311
+ end
312
+
313
+ #
314
+ # Obtains details of a cached recommendation.
315
+ #
316
+ # @param resource_uri [String] The fully qualified Azure Resource Manager
317
+ # identifier of the resource to which the recommendation applies.
318
+ # @param recommendation_id [String] The recommendation ID.
319
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
320
+ # will be added to the HTTP request.
321
+ #
322
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
323
+ #
324
+ def get_with_http_info(resource_uri, recommendation_id, custom_headers:nil)
325
+ get_async(resource_uri, recommendation_id, custom_headers:custom_headers).value!
326
+ end
327
+
328
+ #
329
+ # Obtains details of a cached recommendation.
330
+ #
331
+ # @param resource_uri [String] The fully qualified Azure Resource Manager
332
+ # identifier of the resource to which the recommendation applies.
333
+ # @param recommendation_id [String] The recommendation ID.
334
+ # @param [Hash{String => String}] A hash of custom headers that will be added
335
+ # to the HTTP request.
336
+ #
337
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
338
+ #
339
+ def get_async(resource_uri, recommendation_id, custom_headers:nil)
340
+ fail ArgumentError, 'resource_uri is nil' if resource_uri.nil?
341
+ fail ArgumentError, 'recommendation_id is nil' if recommendation_id.nil?
342
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
343
+
344
+
345
+ request_headers = {}
346
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
347
+
348
+ # Set Headers
349
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
350
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
351
+ path_template = '{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}'
352
+
353
+ request_url = @base_url || @client.base_url
354
+
355
+ options = {
356
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
357
+ path_params: {'resourceUri' => resource_uri,'recommendationId' => recommendation_id},
358
+ query_params: {'api-version' => @client.api_version},
359
+ headers: request_headers.merge(custom_headers || {}),
360
+ base_url: request_url
361
+ }
362
+ promise = @client.make_request_async(:get, path_template, options)
363
+
364
+ promise = promise.then do |result|
365
+ http_response = result.response
366
+ status_code = http_response.status
367
+ response_content = http_response.body
368
+ unless status_code == 200
369
+ error_model = JSON.load(response_content)
370
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
371
+ end
372
+
373
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
374
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
375
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
376
+ # Deserialize Response
377
+ if status_code == 200
378
+ begin
379
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
380
+ result_mapper = Azure::Advisor::Mgmt::V2020_01_01::Models::ResourceRecommendationBase.mapper()
381
+ result.body = @client.deserialize(result_mapper, parsed_response)
382
+ rescue Exception => e
383
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
384
+ end
385
+ end
386
+
387
+ result
388
+ end
389
+
390
+ promise.execute
391
+ end
392
+
393
+ #
394
+ # Obtains cached recommendations for a subscription. The recommendations are
395
+ # generated or computed by invoking generateRecommendations.
396
+ #
397
+ # @param next_page_link [String] The NextLink from the previous successful call
398
+ # to List operation.
399
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
400
+ # will be added to the HTTP request.
401
+ #
402
+ # @return [ResourceRecommendationBaseListResult] operation results.
403
+ #
404
+ def list_next(next_page_link, custom_headers:nil)
405
+ response = list_next_async(next_page_link, custom_headers:custom_headers).value!
406
+ response.body unless response.nil?
407
+ end
408
+
409
+ #
410
+ # Obtains cached recommendations for a subscription. The recommendations are
411
+ # generated or computed by invoking generateRecommendations.
412
+ #
413
+ # @param next_page_link [String] The NextLink from the previous successful call
414
+ # to List operation.
415
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
416
+ # will be added to the HTTP request.
417
+ #
418
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
419
+ #
420
+ def list_next_with_http_info(next_page_link, custom_headers:nil)
421
+ list_next_async(next_page_link, custom_headers:custom_headers).value!
422
+ end
423
+
424
+ #
425
+ # Obtains cached recommendations for a subscription. The recommendations are
426
+ # generated or computed by invoking generateRecommendations.
427
+ #
428
+ # @param next_page_link [String] The NextLink from the previous successful call
429
+ # to List operation.
430
+ # @param [Hash{String => String}] A hash of custom headers that will be added
431
+ # to the HTTP request.
432
+ #
433
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
434
+ #
435
+ def list_next_async(next_page_link, custom_headers:nil)
436
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
437
+
438
+
439
+ request_headers = {}
440
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
441
+
442
+ # Set Headers
443
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
444
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
445
+ path_template = '{nextLink}'
446
+
447
+ request_url = @base_url || @client.base_url
448
+
449
+ options = {
450
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
451
+ skip_encoding_path_params: {'nextLink' => next_page_link},
452
+ headers: request_headers.merge(custom_headers || {}),
453
+ base_url: request_url
454
+ }
455
+ promise = @client.make_request_async(:get, 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 MsRestAzure::AzureOperationError.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 = Azure::Advisor::Mgmt::V2020_01_01::Models::ResourceRecommendationBaseListResult.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
+ # Obtains cached recommendations for a subscription. The recommendations are
488
+ # generated or computed by invoking generateRecommendations.
489
+ #
490
+ # @param filter [String] The filter to apply to the recommendations.
491
+ # @param top [Integer] The number of recommendations per page if a paged
492
+ # version of this API is being used.
493
+ # @param skip_token [String] The page-continuation token to use with a paged
494
+ # version of this API.
495
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
496
+ # will be added to the HTTP request.
497
+ #
498
+ # @return [ResourceRecommendationBaseListResult] which provide lazy access to
499
+ # pages of the response.
500
+ #
501
+ def list_as_lazy(filter:nil, top:nil, skip_token:nil, custom_headers:nil)
502
+ response = list_async(filter:filter, top:top, skip_token:skip_token, custom_headers:custom_headers).value!
503
+ unless response.nil?
504
+ page = response.body
505
+ page.next_method = Proc.new do |next_page_link|
506
+ list_next_async(next_page_link, custom_headers:custom_headers)
507
+ end
508
+ page
509
+ end
510
+ end
511
+
512
+ end
513
+ end