azure_cognitiveservices_contentmoderator 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +21 -0
  3. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator.rb +93 -0
  4. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/content_moderator_client.rb +167 -0
  5. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/image_moderation.rb +1399 -0
  6. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/list_management_image.rb +637 -0
  7. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/list_management_image_lists.rb +610 -0
  8. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/list_management_term.rb +429 -0
  9. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/list_management_term_lists.rb +618 -0
  10. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/address.rb +58 -0
  11. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/apierror.rb +47 -0
  12. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/azure_region_base_url.rb +27 -0
  13. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/body.rb +70 -0
  14. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/body_metadata.rb +57 -0
  15. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/candidate.rb +57 -0
  16. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/classification.rb +82 -0
  17. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/content.rb +47 -0
  18. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/create_review_body_item.rb +101 -0
  19. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/create_review_body_item_metadata_item.rb +58 -0
  20. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/create_video_reviews_body_item.rb +144 -0
  21. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/create_video_reviews_body_item_metadata_item.rb +58 -0
  22. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/create_video_reviews_body_item_video_frames_item.rb +112 -0
  23. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/create_video_reviews_body_item_video_frames_item_metadata_item.rb +59 -0
  24. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/create_video_reviews_body_item_video_frames_item_reviewer_result_tags_item.rb +60 -0
  25. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/detected_language.rb +69 -0
  26. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/detected_terms.rb +81 -0
  27. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/email.rb +80 -0
  28. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/error.rb +57 -0
  29. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/evaluate.rb +144 -0
  30. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/face.rb +79 -0
  31. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/found_faces.rb +131 -0
  32. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/frame.rb +97 -0
  33. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/frames.rb +66 -0
  34. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/image.rb +89 -0
  35. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/image_additional_info_item.rb +58 -0
  36. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/image_ids.rb +88 -0
  37. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/image_list.rb +80 -0
  38. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/image_list_metadata.rb +57 -0
  39. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/image_url.rb +59 -0
  40. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/ipa.rb +69 -0
  41. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/job.rb +153 -0
  42. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/job_execution_report_details.rb +57 -0
  43. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/job_id.rb +47 -0
  44. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/job_list_result.rb +54 -0
  45. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/key_value_pair.rb +57 -0
  46. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/match.rb +98 -0
  47. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/match_response.rb +100 -0
  48. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/ocr.rb +131 -0
  49. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/phone.rb +69 -0
  50. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/pii.rb +115 -0
  51. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/refresh_index.rb +100 -0
  52. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/refresh_index_advanced_info_item.rb +58 -0
  53. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/review.rb +163 -0
  54. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/score.rb +48 -0
  55. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/screen.rb +165 -0
  56. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/status.rb +68 -0
  57. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/tag.rb +57 -0
  58. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/term_list.rb +80 -0
  59. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/term_list_metadata.rb +57 -0
  60. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/terms.rb +59 -0
  61. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/terms_data.rb +89 -0
  62. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/terms_in_list.rb +46 -0
  63. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/terms_paging.rb +79 -0
  64. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/transcript_moderation_body_item.rb +67 -0
  65. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/transcript_moderation_body_item_terms_item.rb +58 -0
  66. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/video_frame_body_item.rb +98 -0
  67. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/video_frame_body_item_metadata_item.rb +58 -0
  68. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/video_frame_body_item_reviewer_result_tags_item.rb +58 -0
  69. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/module_definition.rb +9 -0
  70. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/reviews.rb +1829 -0
  71. data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/text_moderation.rb +294 -0
  72. data/lib/azure_cognitiveservices_contentmoderator.rb +6 -0
  73. data/lib/module_definition.rb +7 -0
  74. data/lib/profiles/latest/contentmoderator_latest_profile_client.rb +38 -0
  75. data/lib/profiles/latest/contentmoderator_module_definition.rb +8 -0
  76. data/lib/profiles/latest/modules/contentmoderator_profile_module.rb +307 -0
  77. data/lib/version.rb +7 -0
  78. metadata +196 -0
@@ -0,0 +1,429 @@
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::CognitiveServices::ContentModerator::V1_0
7
+ #
8
+ # You use the API to scan your content as it is generated. Content Moderator
9
+ # then processes your content and sends the results along with relevant
10
+ # information either back to your systems or to the built-in review tool. You
11
+ # can use this information to take decisions e.g. take it down, send to human
12
+ # judge, etc.
13
+ #
14
+ # When using the API, images need to have a minimum of 128 pixels and a
15
+ # maximum file size of 4MB.
16
+ # Text can be at most 1024 characters long.
17
+ # If the content passed to the text API or the image API exceeds the size
18
+ # limits, the API will return an error code that informs about the issue.
19
+ #
20
+ # This API is currently available in:
21
+ #
22
+ # * West US - westus.api.cognitive.microsoft.com
23
+ # * East US 2 - eastus2.api.cognitive.microsoft.com
24
+ # * West Central US - westcentralus.api.cognitive.microsoft.com
25
+ # * West Europe - westeurope.api.cognitive.microsoft.com
26
+ # * Southeast Asia - southeastasia.api.cognitive.microsoft.com .
27
+ #
28
+ class ListManagementTerm
29
+ include MsRestAzure
30
+
31
+ #
32
+ # Creates and initializes a new instance of the ListManagementTerm class.
33
+ # @param client service class for accessing basic functionality.
34
+ #
35
+ def initialize(client)
36
+ @client = client
37
+ end
38
+
39
+ # @return [ContentModeratorClient] reference to the ContentModeratorClient
40
+ attr_reader :client
41
+
42
+ #
43
+ # Add a term to the term list with list Id equal to list Id passed.
44
+ #
45
+ # @param list_id [String] List Id of the image list.
46
+ # @param term [String] Term to be deleted
47
+ # @param language [String] Language of the terms.
48
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
49
+ # will be added to the HTTP request.
50
+ #
51
+ # @return [Object] operation results.
52
+ #
53
+ def add_term(list_id, term, language, custom_headers:nil)
54
+ response = add_term_async(list_id, term, language, custom_headers:custom_headers).value!
55
+ response.body unless response.nil?
56
+ end
57
+
58
+ #
59
+ # Add a term to the term list with list Id equal to list Id passed.
60
+ #
61
+ # @param list_id [String] List Id of the image list.
62
+ # @param term [String] Term to be deleted
63
+ # @param language [String] Language of the terms.
64
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
65
+ # will be added to the HTTP request.
66
+ #
67
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
68
+ #
69
+ def add_term_with_http_info(list_id, term, language, custom_headers:nil)
70
+ add_term_async(list_id, term, language, custom_headers:custom_headers).value!
71
+ end
72
+
73
+ #
74
+ # Add a term to the term list with list Id equal to list Id passed.
75
+ #
76
+ # @param list_id [String] List Id of the image list.
77
+ # @param term [String] Term to be deleted
78
+ # @param language [String] Language of the terms.
79
+ # @param [Hash{String => String}] A hash of custom headers that will be added
80
+ # to the HTTP request.
81
+ #
82
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
83
+ #
84
+ def add_term_async(list_id, term, language, custom_headers:nil)
85
+ fail ArgumentError, '@client.base_url is nil' if @client.base_url.nil?
86
+ fail ArgumentError, 'list_id is nil' if list_id.nil?
87
+ fail ArgumentError, 'term is nil' if term.nil?
88
+ fail ArgumentError, 'language is nil' if language.nil?
89
+
90
+
91
+ request_headers = {}
92
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
93
+
94
+ # Set Headers
95
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
96
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
97
+ path_template = 'contentmoderator/lists/v1.0/termlists/{listId}/terms/{term}'
98
+
99
+ request_url = @base_url || @client.base_url
100
+ request_url = request_url.gsub('{baseUrl}', @client.base_url)
101
+
102
+ options = {
103
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
104
+ path_params: {'listId' => list_id,'term' => term},
105
+ query_params: {'language' => language},
106
+ headers: request_headers.merge(custom_headers || {}),
107
+ base_url: request_url
108
+ }
109
+ promise = @client.make_request_async(:post, path_template, options)
110
+
111
+ promise = promise.then do |result|
112
+ http_response = result.response
113
+ status_code = http_response.status
114
+ response_content = http_response.body
115
+ unless status_code == 201
116
+ error_model = JSON.load(response_content)
117
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
118
+ end
119
+
120
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
121
+
122
+ result
123
+ end
124
+
125
+ promise.execute
126
+ end
127
+
128
+ #
129
+ # Deletes a term from the list with list Id equal to the list Id passed.
130
+ #
131
+ # @param list_id [String] List Id of the image list.
132
+ # @param term [String] Term to be deleted
133
+ # @param language [String] Language of the terms.
134
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
135
+ # will be added to the HTTP request.
136
+ #
137
+ # @return [String] operation results.
138
+ #
139
+ def delete_term(list_id, term, language, custom_headers:nil)
140
+ response = delete_term_async(list_id, term, language, custom_headers:custom_headers).value!
141
+ response.body unless response.nil?
142
+ end
143
+
144
+ #
145
+ # Deletes a term from the list with list Id equal to the list Id passed.
146
+ #
147
+ # @param list_id [String] List Id of the image list.
148
+ # @param term [String] Term to be deleted
149
+ # @param language [String] Language of the terms.
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 delete_term_with_http_info(list_id, term, language, custom_headers:nil)
156
+ delete_term_async(list_id, term, language, custom_headers:custom_headers).value!
157
+ end
158
+
159
+ #
160
+ # Deletes a term from the list with list Id equal to the list Id passed.
161
+ #
162
+ # @param list_id [String] List Id of the image list.
163
+ # @param term [String] Term to be deleted
164
+ # @param language [String] Language of the terms.
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 delete_term_async(list_id, term, language, custom_headers:nil)
171
+ fail ArgumentError, '@client.base_url is nil' if @client.base_url.nil?
172
+ fail ArgumentError, 'list_id is nil' if list_id.nil?
173
+ fail ArgumentError, 'term is nil' if term.nil?
174
+ fail ArgumentError, 'language is nil' if language.nil?
175
+
176
+
177
+ request_headers = {}
178
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
179
+
180
+ # Set Headers
181
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
182
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
183
+ path_template = 'contentmoderator/lists/v1.0/termlists/{listId}/terms/{term}'
184
+
185
+ request_url = @base_url || @client.base_url
186
+ request_url = request_url.gsub('{baseUrl}', @client.base_url)
187
+
188
+ options = {
189
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
190
+ path_params: {'listId' => list_id,'term' => term},
191
+ query_params: {'language' => language},
192
+ headers: request_headers.merge(custom_headers || {}),
193
+ base_url: request_url
194
+ }
195
+ promise = @client.make_request_async(:delete, path_template, options)
196
+
197
+ promise = promise.then do |result|
198
+ http_response = result.response
199
+ status_code = http_response.status
200
+ response_content = http_response.body
201
+ unless status_code == 204
202
+ error_model = JSON.load(response_content)
203
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
204
+ end
205
+
206
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
207
+ # Deserialize Response
208
+ if status_code == 204
209
+ begin
210
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
211
+ result_mapper = {
212
+ client_side_validation: true,
213
+ required: false,
214
+ serialized_name: 'parsed_response',
215
+ type: {
216
+ name: 'String'
217
+ }
218
+ }
219
+ result.body = @client.deserialize(result_mapper, parsed_response)
220
+ rescue Exception => e
221
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
222
+ end
223
+ end
224
+
225
+ result
226
+ end
227
+
228
+ promise.execute
229
+ end
230
+
231
+ #
232
+ # Gets all terms from the list with list Id equal to the list Id passed.
233
+ #
234
+ # @param list_id [String] List Id of the image list.
235
+ # @param language [String] Language of the terms.
236
+ # @param offset [Integer] The pagination start index.
237
+ # @param limit [Integer] The max limit.
238
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
239
+ # will be added to the HTTP request.
240
+ #
241
+ # @return [Terms] operation results.
242
+ #
243
+ def get_all_terms(list_id, language, offset:nil, limit:nil, custom_headers:nil)
244
+ response = get_all_terms_async(list_id, language, offset:offset, limit:limit, custom_headers:custom_headers).value!
245
+ response.body unless response.nil?
246
+ end
247
+
248
+ #
249
+ # Gets all terms from the list with list Id equal to the list Id passed.
250
+ #
251
+ # @param list_id [String] List Id of the image list.
252
+ # @param language [String] Language of the terms.
253
+ # @param offset [Integer] The pagination start index.
254
+ # @param limit [Integer] The max limit.
255
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
256
+ # will be added to the HTTP request.
257
+ #
258
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
259
+ #
260
+ def get_all_terms_with_http_info(list_id, language, offset:nil, limit:nil, custom_headers:nil)
261
+ get_all_terms_async(list_id, language, offset:offset, limit:limit, custom_headers:custom_headers).value!
262
+ end
263
+
264
+ #
265
+ # Gets all terms from the list with list Id equal to the list Id passed.
266
+ #
267
+ # @param list_id [String] List Id of the image list.
268
+ # @param language [String] Language of the terms.
269
+ # @param offset [Integer] The pagination start index.
270
+ # @param limit [Integer] The max limit.
271
+ # @param [Hash{String => String}] A hash of custom headers that will be added
272
+ # to the HTTP request.
273
+ #
274
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
275
+ #
276
+ def get_all_terms_async(list_id, language, offset:nil, limit:nil, custom_headers:nil)
277
+ fail ArgumentError, '@client.base_url is nil' if @client.base_url.nil?
278
+ fail ArgumentError, 'list_id is nil' if list_id.nil?
279
+ fail ArgumentError, 'language is nil' if language.nil?
280
+
281
+
282
+ request_headers = {}
283
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
284
+
285
+ # Set Headers
286
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
287
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
288
+ path_template = 'contentmoderator/lists/v1.0/termlists/{listId}/terms'
289
+
290
+ request_url = @base_url || @client.base_url
291
+ request_url = request_url.gsub('{baseUrl}', @client.base_url)
292
+
293
+ options = {
294
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
295
+ path_params: {'listId' => list_id},
296
+ query_params: {'language' => language,'offset' => offset,'limit' => limit},
297
+ headers: request_headers.merge(custom_headers || {}),
298
+ base_url: request_url
299
+ }
300
+ promise = @client.make_request_async(:get, path_template, options)
301
+
302
+ promise = promise.then do |result|
303
+ http_response = result.response
304
+ status_code = http_response.status
305
+ response_content = http_response.body
306
+ unless status_code == 200
307
+ error_model = JSON.load(response_content)
308
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
309
+ end
310
+
311
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
312
+ # Deserialize Response
313
+ if status_code == 200
314
+ begin
315
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
316
+ result_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::Terms.mapper()
317
+ result.body = @client.deserialize(result_mapper, parsed_response)
318
+ rescue Exception => e
319
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
320
+ end
321
+ end
322
+
323
+ result
324
+ end
325
+
326
+ promise.execute
327
+ end
328
+
329
+ #
330
+ # Deletes all terms from the list with list Id equal to the list Id passed.
331
+ #
332
+ # @param list_id [String] List Id of the image list.
333
+ # @param language [String] Language of the terms.
334
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
335
+ # will be added to the HTTP request.
336
+ #
337
+ # @return [String] operation results.
338
+ #
339
+ def delete_all_terms(list_id, language, custom_headers:nil)
340
+ response = delete_all_terms_async(list_id, language, custom_headers:custom_headers).value!
341
+ response.body unless response.nil?
342
+ end
343
+
344
+ #
345
+ # Deletes all terms from the list with list Id equal to the list Id passed.
346
+ #
347
+ # @param list_id [String] List Id of the image list.
348
+ # @param language [String] Language of the terms.
349
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
350
+ # will be added to the HTTP request.
351
+ #
352
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
353
+ #
354
+ def delete_all_terms_with_http_info(list_id, language, custom_headers:nil)
355
+ delete_all_terms_async(list_id, language, custom_headers:custom_headers).value!
356
+ end
357
+
358
+ #
359
+ # Deletes all terms from the list with list Id equal to the list Id passed.
360
+ #
361
+ # @param list_id [String] List Id of the image list.
362
+ # @param language [String] Language of the terms.
363
+ # @param [Hash{String => String}] A hash of custom headers that will be added
364
+ # to the HTTP request.
365
+ #
366
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
367
+ #
368
+ def delete_all_terms_async(list_id, language, custom_headers:nil)
369
+ fail ArgumentError, '@client.base_url is nil' if @client.base_url.nil?
370
+ fail ArgumentError, 'list_id is nil' if list_id.nil?
371
+ fail ArgumentError, 'language is nil' if language.nil?
372
+
373
+
374
+ request_headers = {}
375
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
376
+
377
+ # Set Headers
378
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
379
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
380
+ path_template = 'contentmoderator/lists/v1.0/termlists/{listId}/terms'
381
+
382
+ request_url = @base_url || @client.base_url
383
+ request_url = request_url.gsub('{baseUrl}', @client.base_url)
384
+
385
+ options = {
386
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
387
+ path_params: {'listId' => list_id},
388
+ query_params: {'language' => language},
389
+ headers: request_headers.merge(custom_headers || {}),
390
+ base_url: request_url
391
+ }
392
+ promise = @client.make_request_async(:delete, path_template, options)
393
+
394
+ promise = promise.then do |result|
395
+ http_response = result.response
396
+ status_code = http_response.status
397
+ response_content = http_response.body
398
+ unless status_code == 204
399
+ error_model = JSON.load(response_content)
400
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
401
+ end
402
+
403
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
404
+ # Deserialize Response
405
+ if status_code == 204
406
+ begin
407
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
408
+ result_mapper = {
409
+ client_side_validation: true,
410
+ required: false,
411
+ serialized_name: 'parsed_response',
412
+ type: {
413
+ name: 'String'
414
+ }
415
+ }
416
+ result.body = @client.deserialize(result_mapper, parsed_response)
417
+ rescue Exception => e
418
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
419
+ end
420
+ end
421
+
422
+ result
423
+ end
424
+
425
+ promise.execute
426
+ end
427
+
428
+ end
429
+ end
@@ -0,0 +1,618 @@
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::CognitiveServices::ContentModerator::V1_0
7
+ #
8
+ # You use the API to scan your content as it is generated. Content Moderator
9
+ # then processes your content and sends the results along with relevant
10
+ # information either back to your systems or to the built-in review tool. You
11
+ # can use this information to take decisions e.g. take it down, send to human
12
+ # judge, etc.
13
+ #
14
+ # When using the API, images need to have a minimum of 128 pixels and a
15
+ # maximum file size of 4MB.
16
+ # Text can be at most 1024 characters long.
17
+ # If the content passed to the text API or the image API exceeds the size
18
+ # limits, the API will return an error code that informs about the issue.
19
+ #
20
+ # This API is currently available in:
21
+ #
22
+ # * West US - westus.api.cognitive.microsoft.com
23
+ # * East US 2 - eastus2.api.cognitive.microsoft.com
24
+ # * West Central US - westcentralus.api.cognitive.microsoft.com
25
+ # * West Europe - westeurope.api.cognitive.microsoft.com
26
+ # * Southeast Asia - southeastasia.api.cognitive.microsoft.com .
27
+ #
28
+ class ListManagementTermLists
29
+ include MsRestAzure
30
+
31
+ #
32
+ # Creates and initializes a new instance of the ListManagementTermLists class.
33
+ # @param client service class for accessing basic functionality.
34
+ #
35
+ def initialize(client)
36
+ @client = client
37
+ end
38
+
39
+ # @return [ContentModeratorClient] reference to the ContentModeratorClient
40
+ attr_reader :client
41
+
42
+ #
43
+ # Returns list Id details of the term list with list Id equal to list Id
44
+ # passed.
45
+ #
46
+ # @param list_id [String] List Id of the image list.
47
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
48
+ # will be added to the HTTP request.
49
+ #
50
+ # @return [TermList] operation results.
51
+ #
52
+ def get_details(list_id, custom_headers:nil)
53
+ response = get_details_async(list_id, custom_headers:custom_headers).value!
54
+ response.body unless response.nil?
55
+ end
56
+
57
+ #
58
+ # Returns list Id details of the term list with list Id equal to list Id
59
+ # passed.
60
+ #
61
+ # @param list_id [String] List Id of the image list.
62
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
63
+ # will be added to the HTTP request.
64
+ #
65
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
66
+ #
67
+ def get_details_with_http_info(list_id, custom_headers:nil)
68
+ get_details_async(list_id, custom_headers:custom_headers).value!
69
+ end
70
+
71
+ #
72
+ # Returns list Id details of the term list with list Id equal to list Id
73
+ # passed.
74
+ #
75
+ # @param list_id [String] List Id of the image list.
76
+ # @param [Hash{String => String}] A hash of custom headers that will be added
77
+ # to the HTTP request.
78
+ #
79
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
80
+ #
81
+ def get_details_async(list_id, custom_headers:nil)
82
+ fail ArgumentError, '@client.base_url is nil' if @client.base_url.nil?
83
+ fail ArgumentError, 'list_id is nil' if list_id.nil?
84
+
85
+
86
+ request_headers = {}
87
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
88
+
89
+ # Set Headers
90
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
91
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
92
+ path_template = 'contentmoderator/lists/v1.0/termlists/{listId}'
93
+
94
+ request_url = @base_url || @client.base_url
95
+ request_url = request_url.gsub('{baseUrl}', @client.base_url)
96
+
97
+ options = {
98
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
99
+ path_params: {'listId' => list_id},
100
+ headers: request_headers.merge(custom_headers || {}),
101
+ base_url: request_url
102
+ }
103
+ promise = @client.make_request_async(:get, path_template, options)
104
+
105
+ promise = promise.then do |result|
106
+ http_response = result.response
107
+ status_code = http_response.status
108
+ response_content = http_response.body
109
+ unless status_code == 200
110
+ error_model = JSON.load(response_content)
111
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
112
+ end
113
+
114
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
115
+ # Deserialize Response
116
+ if status_code == 200
117
+ begin
118
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
119
+ result_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::TermList.mapper()
120
+ result.body = @client.deserialize(result_mapper, parsed_response)
121
+ rescue Exception => e
122
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
123
+ end
124
+ end
125
+
126
+ result
127
+ end
128
+
129
+ promise.execute
130
+ end
131
+
132
+ #
133
+ # Deletes term list with the list Id equal to list Id passed.
134
+ #
135
+ # @param list_id [String] List Id of the image list.
136
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
137
+ # will be added to the HTTP request.
138
+ #
139
+ # @return [String] operation results.
140
+ #
141
+ def delete(list_id, custom_headers:nil)
142
+ response = delete_async(list_id, custom_headers:custom_headers).value!
143
+ response.body unless response.nil?
144
+ end
145
+
146
+ #
147
+ # Deletes term list with the list Id equal to list Id passed.
148
+ #
149
+ # @param list_id [String] List Id of the image list.
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 delete_with_http_info(list_id, custom_headers:nil)
156
+ delete_async(list_id, custom_headers:custom_headers).value!
157
+ end
158
+
159
+ #
160
+ # Deletes term list with the list Id equal to list Id passed.
161
+ #
162
+ # @param list_id [String] List Id of the image list.
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 delete_async(list_id, custom_headers:nil)
169
+ fail ArgumentError, '@client.base_url is nil' if @client.base_url.nil?
170
+ fail ArgumentError, 'list_id is nil' if list_id.nil?
171
+
172
+
173
+ request_headers = {}
174
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
175
+
176
+ # Set Headers
177
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
178
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
179
+ path_template = 'contentmoderator/lists/v1.0/termlists/{listId}'
180
+
181
+ request_url = @base_url || @client.base_url
182
+ request_url = request_url.gsub('{baseUrl}', @client.base_url)
183
+
184
+ options = {
185
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
186
+ path_params: {'listId' => list_id},
187
+ headers: request_headers.merge(custom_headers || {}),
188
+ base_url: request_url
189
+ }
190
+ promise = @client.make_request_async(:delete, 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
+ # Deserialize Response
203
+ if status_code == 200
204
+ begin
205
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
206
+ result_mapper = {
207
+ client_side_validation: true,
208
+ required: false,
209
+ serialized_name: 'parsed_response',
210
+ type: {
211
+ name: 'String'
212
+ }
213
+ }
214
+ result.body = @client.deserialize(result_mapper, parsed_response)
215
+ rescue Exception => e
216
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
217
+ end
218
+ end
219
+
220
+ result
221
+ end
222
+
223
+ promise.execute
224
+ end
225
+
226
+ #
227
+ # Updates an Term List.
228
+ #
229
+ # @param list_id [String] List Id of the image list.
230
+ # @param content_type [String] The content type.
231
+ # @param body [Body] Schema of the body.
232
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
233
+ # will be added to the HTTP request.
234
+ #
235
+ # @return [TermList] operation results.
236
+ #
237
+ def update(list_id, content_type, body, custom_headers:nil)
238
+ response = update_async(list_id, content_type, body, custom_headers:custom_headers).value!
239
+ response.body unless response.nil?
240
+ end
241
+
242
+ #
243
+ # Updates an Term List.
244
+ #
245
+ # @param list_id [String] List Id of the image list.
246
+ # @param content_type [String] The content type.
247
+ # @param body [Body] Schema of the body.
248
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
249
+ # will be added to the HTTP request.
250
+ #
251
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
252
+ #
253
+ def update_with_http_info(list_id, content_type, body, custom_headers:nil)
254
+ update_async(list_id, content_type, body, custom_headers:custom_headers).value!
255
+ end
256
+
257
+ #
258
+ # Updates an Term List.
259
+ #
260
+ # @param list_id [String] List Id of the image list.
261
+ # @param content_type [String] The content type.
262
+ # @param body [Body] Schema of the body.
263
+ # @param [Hash{String => String}] A hash of custom headers that will be added
264
+ # to the HTTP request.
265
+ #
266
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
267
+ #
268
+ def update_async(list_id, content_type, body, custom_headers:nil)
269
+ fail ArgumentError, '@client.base_url is nil' if @client.base_url.nil?
270
+ fail ArgumentError, 'list_id is nil' if list_id.nil?
271
+ fail ArgumentError, 'content_type is nil' if content_type.nil?
272
+ fail ArgumentError, 'body is nil' if body.nil?
273
+
274
+
275
+ request_headers = {}
276
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
277
+
278
+ # Set Headers
279
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
280
+ request_headers['Content-Type'] = content_type unless content_type.nil?
281
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
282
+
283
+ # Serialize Request
284
+ request_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::Body.mapper()
285
+ request_content = @client.serialize(request_mapper, body)
286
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
287
+
288
+ path_template = 'contentmoderator/lists/v1.0/termlists/{listId}'
289
+
290
+ request_url = @base_url || @client.base_url
291
+ request_url = request_url.gsub('{baseUrl}', @client.base_url)
292
+
293
+ options = {
294
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
295
+ path_params: {'listId' => list_id},
296
+ body: request_content,
297
+ headers: request_headers.merge(custom_headers || {}),
298
+ base_url: request_url
299
+ }
300
+ promise = @client.make_request_async(:put, path_template, options)
301
+
302
+ promise = promise.then do |result|
303
+ http_response = result.response
304
+ status_code = http_response.status
305
+ response_content = http_response.body
306
+ unless status_code == 200
307
+ error_model = JSON.load(response_content)
308
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
309
+ end
310
+
311
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
312
+ # Deserialize Response
313
+ if status_code == 200
314
+ begin
315
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
316
+ result_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::TermList.mapper()
317
+ result.body = @client.deserialize(result_mapper, parsed_response)
318
+ rescue Exception => e
319
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
320
+ end
321
+ end
322
+
323
+ result
324
+ end
325
+
326
+ promise.execute
327
+ end
328
+
329
+ #
330
+ # Creates a Term List
331
+ #
332
+ # @param content_type [String] The content type.
333
+ # @param body [Body] Schema of the body.
334
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
335
+ # will be added to the HTTP request.
336
+ #
337
+ # @return [TermList] operation results.
338
+ #
339
+ def create(content_type, body, custom_headers:nil)
340
+ response = create_async(content_type, body, custom_headers:custom_headers).value!
341
+ response.body unless response.nil?
342
+ end
343
+
344
+ #
345
+ # Creates a Term List
346
+ #
347
+ # @param content_type [String] The content type.
348
+ # @param body [Body] Schema of the body.
349
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
350
+ # will be added to the HTTP request.
351
+ #
352
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
353
+ #
354
+ def create_with_http_info(content_type, body, custom_headers:nil)
355
+ create_async(content_type, body, custom_headers:custom_headers).value!
356
+ end
357
+
358
+ #
359
+ # Creates a Term List
360
+ #
361
+ # @param content_type [String] The content type.
362
+ # @param body [Body] Schema of the body.
363
+ # @param [Hash{String => String}] A hash of custom headers that will be added
364
+ # to the HTTP request.
365
+ #
366
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
367
+ #
368
+ def create_async(content_type, body, custom_headers:nil)
369
+ fail ArgumentError, '@client.base_url is nil' if @client.base_url.nil?
370
+ fail ArgumentError, 'content_type is nil' if content_type.nil?
371
+ fail ArgumentError, 'body is nil' if body.nil?
372
+
373
+
374
+ request_headers = {}
375
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
376
+
377
+ # Set Headers
378
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
379
+ request_headers['Content-Type'] = content_type unless content_type.nil?
380
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
381
+
382
+ # Serialize Request
383
+ request_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::Body.mapper()
384
+ request_content = @client.serialize(request_mapper, body)
385
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
386
+
387
+ path_template = 'contentmoderator/lists/v1.0/termlists'
388
+
389
+ request_url = @base_url || @client.base_url
390
+ request_url = request_url.gsub('{baseUrl}', @client.base_url)
391
+
392
+ options = {
393
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
394
+ body: request_content,
395
+ headers: request_headers.merge(custom_headers || {}),
396
+ base_url: request_url
397
+ }
398
+ promise = @client.make_request_async(:post, path_template, options)
399
+
400
+ promise = promise.then do |result|
401
+ http_response = result.response
402
+ status_code = http_response.status
403
+ response_content = http_response.body
404
+ unless status_code == 200
405
+ error_model = JSON.load(response_content)
406
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
407
+ end
408
+
409
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
410
+ # Deserialize Response
411
+ if status_code == 200
412
+ begin
413
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
414
+ result_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::TermList.mapper()
415
+ result.body = @client.deserialize(result_mapper, parsed_response)
416
+ rescue Exception => e
417
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
418
+ end
419
+ end
420
+
421
+ result
422
+ end
423
+
424
+ promise.execute
425
+ end
426
+
427
+ #
428
+ # gets all the Term Lists
429
+ #
430
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
431
+ # will be added to the HTTP request.
432
+ #
433
+ # @return [Array] operation results.
434
+ #
435
+ def get_all_term_lists(custom_headers:nil)
436
+ response = get_all_term_lists_async(custom_headers:custom_headers).value!
437
+ response.body unless response.nil?
438
+ end
439
+
440
+ #
441
+ # gets all the Term Lists
442
+ #
443
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
444
+ # will be added to the HTTP request.
445
+ #
446
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
447
+ #
448
+ def get_all_term_lists_with_http_info(custom_headers:nil)
449
+ get_all_term_lists_async(custom_headers:custom_headers).value!
450
+ end
451
+
452
+ #
453
+ # gets all the Term Lists
454
+ #
455
+ # @param [Hash{String => String}] A hash of custom headers that will be added
456
+ # to the HTTP request.
457
+ #
458
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
459
+ #
460
+ def get_all_term_lists_async(custom_headers:nil)
461
+ fail ArgumentError, '@client.base_url is nil' if @client.base_url.nil?
462
+
463
+
464
+ request_headers = {}
465
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
466
+
467
+ # Set Headers
468
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
469
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
470
+ path_template = 'contentmoderator/lists/v1.0/termlists'
471
+
472
+ request_url = @base_url || @client.base_url
473
+ request_url = request_url.gsub('{baseUrl}', @client.base_url)
474
+
475
+ options = {
476
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
477
+ headers: request_headers.merge(custom_headers || {}),
478
+ base_url: request_url
479
+ }
480
+ promise = @client.make_request_async(:get, path_template, options)
481
+
482
+ promise = promise.then do |result|
483
+ http_response = result.response
484
+ status_code = http_response.status
485
+ response_content = http_response.body
486
+ unless status_code == 200
487
+ error_model = JSON.load(response_content)
488
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
489
+ end
490
+
491
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
492
+ # Deserialize Response
493
+ if status_code == 200
494
+ begin
495
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
496
+ result_mapper = {
497
+ client_side_validation: true,
498
+ required: false,
499
+ serialized_name: 'parsed_response',
500
+ type: {
501
+ name: 'Sequence',
502
+ element: {
503
+ client_side_validation: true,
504
+ required: false,
505
+ serialized_name: 'TermListElementType',
506
+ type: {
507
+ name: 'Composite',
508
+ class_name: 'TermList'
509
+ }
510
+ }
511
+ }
512
+ }
513
+ result.body = @client.deserialize(result_mapper, parsed_response)
514
+ rescue Exception => e
515
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
516
+ end
517
+ end
518
+
519
+ result
520
+ end
521
+
522
+ promise.execute
523
+ end
524
+
525
+ #
526
+ # Refreshes the index of the list with list Id equal to list ID passed.
527
+ #
528
+ # @param list_id [String] List Id of the image list.
529
+ # @param language [String] Language of the terms.
530
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
531
+ # will be added to the HTTP request.
532
+ #
533
+ # @return [RefreshIndex] operation results.
534
+ #
535
+ def refresh_index_method(list_id, language, custom_headers:nil)
536
+ response = refresh_index_method_async(list_id, language, custom_headers:custom_headers).value!
537
+ response.body unless response.nil?
538
+ end
539
+
540
+ #
541
+ # Refreshes the index of the list with list Id equal to list ID passed.
542
+ #
543
+ # @param list_id [String] List Id of the image list.
544
+ # @param language [String] Language of the terms.
545
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
546
+ # will be added to the HTTP request.
547
+ #
548
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
549
+ #
550
+ def refresh_index_method_with_http_info(list_id, language, custom_headers:nil)
551
+ refresh_index_method_async(list_id, language, custom_headers:custom_headers).value!
552
+ end
553
+
554
+ #
555
+ # Refreshes the index of the list with list Id equal to list ID passed.
556
+ #
557
+ # @param list_id [String] List Id of the image list.
558
+ # @param language [String] Language of the terms.
559
+ # @param [Hash{String => String}] A hash of custom headers that will be added
560
+ # to the HTTP request.
561
+ #
562
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
563
+ #
564
+ def refresh_index_method_async(list_id, language, custom_headers:nil)
565
+ fail ArgumentError, '@client.base_url is nil' if @client.base_url.nil?
566
+ fail ArgumentError, 'list_id is nil' if list_id.nil?
567
+ fail ArgumentError, 'language is nil' if language.nil?
568
+
569
+
570
+ request_headers = {}
571
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
572
+
573
+ # Set Headers
574
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
575
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
576
+ path_template = 'contentmoderator/lists/v1.0/termlists/{listId}/RefreshIndex'
577
+
578
+ request_url = @base_url || @client.base_url
579
+ request_url = request_url.gsub('{baseUrl}', @client.base_url)
580
+
581
+ options = {
582
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
583
+ path_params: {'listId' => list_id},
584
+ query_params: {'language' => language},
585
+ headers: request_headers.merge(custom_headers || {}),
586
+ base_url: request_url
587
+ }
588
+ promise = @client.make_request_async(:post, path_template, options)
589
+
590
+ promise = promise.then do |result|
591
+ http_response = result.response
592
+ status_code = http_response.status
593
+ response_content = http_response.body
594
+ unless status_code == 200
595
+ error_model = JSON.load(response_content)
596
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
597
+ end
598
+
599
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
600
+ # Deserialize Response
601
+ if status_code == 200
602
+ begin
603
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
604
+ result_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::RefreshIndex.mapper()
605
+ result.body = @client.deserialize(result_mapper, parsed_response)
606
+ rescue Exception => e
607
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
608
+ end
609
+ end
610
+
611
+ result
612
+ end
613
+
614
+ promise.execute
615
+ end
616
+
617
+ end
618
+ end