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,610 @@
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 ListManagementImageLists
29
+ include MsRestAzure
30
+
31
+ #
32
+ # Creates and initializes a new instance of the ListManagementImageLists 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 the details of the image list with list Id equal to list Id passed.
44
+ #
45
+ # @param list_id [String] List Id of the image list.
46
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
47
+ # will be added to the HTTP request.
48
+ #
49
+ # @return [ImageList] operation results.
50
+ #
51
+ def get_details(list_id, custom_headers:nil)
52
+ response = get_details_async(list_id, custom_headers:custom_headers).value!
53
+ response.body unless response.nil?
54
+ end
55
+
56
+ #
57
+ # Returns the details of the image list with list Id equal to list Id passed.
58
+ #
59
+ # @param list_id [String] List Id of the image list.
60
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
61
+ # will be added to the HTTP request.
62
+ #
63
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
64
+ #
65
+ def get_details_with_http_info(list_id, custom_headers:nil)
66
+ get_details_async(list_id, custom_headers:custom_headers).value!
67
+ end
68
+
69
+ #
70
+ # Returns the details of the image list with list Id equal to list Id passed.
71
+ #
72
+ # @param list_id [String] List Id of the image list.
73
+ # @param [Hash{String => String}] A hash of custom headers that will be added
74
+ # to the HTTP request.
75
+ #
76
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
77
+ #
78
+ def get_details_async(list_id, custom_headers:nil)
79
+ fail ArgumentError, '@client.base_url is nil' if @client.base_url.nil?
80
+ fail ArgumentError, 'list_id is nil' if list_id.nil?
81
+
82
+
83
+ request_headers = {}
84
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
85
+
86
+ # Set Headers
87
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
88
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
89
+ path_template = 'contentmoderator/lists/v1.0/imagelists/{listId}'
90
+
91
+ request_url = @base_url || @client.base_url
92
+ request_url = request_url.gsub('{baseUrl}', @client.base_url)
93
+
94
+ options = {
95
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
96
+ path_params: {'listId' => list_id},
97
+ headers: request_headers.merge(custom_headers || {}),
98
+ base_url: request_url
99
+ }
100
+ promise = @client.make_request_async(:get, path_template, options)
101
+
102
+ promise = promise.then do |result|
103
+ http_response = result.response
104
+ status_code = http_response.status
105
+ response_content = http_response.body
106
+ unless status_code == 200
107
+ error_model = JSON.load(response_content)
108
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
109
+ end
110
+
111
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
112
+ # Deserialize Response
113
+ if status_code == 200
114
+ begin
115
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
116
+ result_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::ImageList.mapper()
117
+ result.body = @client.deserialize(result_mapper, parsed_response)
118
+ rescue Exception => e
119
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
120
+ end
121
+ end
122
+
123
+ result
124
+ end
125
+
126
+ promise.execute
127
+ end
128
+
129
+ #
130
+ # Deletes image list with the list Id equal to list Id passed.
131
+ #
132
+ # @param list_id [String] List Id of the image list.
133
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
134
+ # will be added to the HTTP request.
135
+ #
136
+ # @return [String] operation results.
137
+ #
138
+ def delete(list_id, custom_headers:nil)
139
+ response = delete_async(list_id, custom_headers:custom_headers).value!
140
+ response.body unless response.nil?
141
+ end
142
+
143
+ #
144
+ # Deletes image list with the list Id equal to list Id passed.
145
+ #
146
+ # @param list_id [String] List Id of the image list.
147
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
148
+ # will be added to the HTTP request.
149
+ #
150
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
151
+ #
152
+ def delete_with_http_info(list_id, custom_headers:nil)
153
+ delete_async(list_id, custom_headers:custom_headers).value!
154
+ end
155
+
156
+ #
157
+ # Deletes image list with the list Id equal to list Id passed.
158
+ #
159
+ # @param list_id [String] List Id of the image list.
160
+ # @param [Hash{String => String}] A hash of custom headers that will be added
161
+ # to the HTTP request.
162
+ #
163
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
164
+ #
165
+ def delete_async(list_id, custom_headers:nil)
166
+ fail ArgumentError, '@client.base_url is nil' if @client.base_url.nil?
167
+ fail ArgumentError, 'list_id is nil' if list_id.nil?
168
+
169
+
170
+ request_headers = {}
171
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
172
+
173
+ # Set Headers
174
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
175
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
176
+ path_template = 'contentmoderator/lists/v1.0/imagelists/{listId}'
177
+
178
+ request_url = @base_url || @client.base_url
179
+ request_url = request_url.gsub('{baseUrl}', @client.base_url)
180
+
181
+ options = {
182
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
183
+ path_params: {'listId' => list_id},
184
+ headers: request_headers.merge(custom_headers || {}),
185
+ base_url: request_url
186
+ }
187
+ promise = @client.make_request_async(:delete, path_template, options)
188
+
189
+ promise = promise.then do |result|
190
+ http_response = result.response
191
+ status_code = http_response.status
192
+ response_content = http_response.body
193
+ unless status_code == 200
194
+ error_model = JSON.load(response_content)
195
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
196
+ end
197
+
198
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
199
+ # Deserialize Response
200
+ if status_code == 200
201
+ begin
202
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
203
+ result_mapper = {
204
+ client_side_validation: true,
205
+ required: false,
206
+ serialized_name: 'parsed_response',
207
+ type: {
208
+ name: 'String'
209
+ }
210
+ }
211
+ result.body = @client.deserialize(result_mapper, parsed_response)
212
+ rescue Exception => e
213
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
214
+ end
215
+ end
216
+
217
+ result
218
+ end
219
+
220
+ promise.execute
221
+ end
222
+
223
+ #
224
+ # Updates an image list with list Id equal to list Id passed.
225
+ #
226
+ # @param list_id [String] List Id of the image list.
227
+ # @param content_type [String] The content type.
228
+ # @param body [Body] Schema of the body.
229
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
230
+ # will be added to the HTTP request.
231
+ #
232
+ # @return [ImageList] operation results.
233
+ #
234
+ def update(list_id, content_type, body, custom_headers:nil)
235
+ response = update_async(list_id, content_type, body, custom_headers:custom_headers).value!
236
+ response.body unless response.nil?
237
+ end
238
+
239
+ #
240
+ # Updates an image list with list Id equal to list Id passed.
241
+ #
242
+ # @param list_id [String] List Id of the image list.
243
+ # @param content_type [String] The content type.
244
+ # @param body [Body] Schema of the body.
245
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
246
+ # will be added to the HTTP request.
247
+ #
248
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
249
+ #
250
+ def update_with_http_info(list_id, content_type, body, custom_headers:nil)
251
+ update_async(list_id, content_type, body, custom_headers:custom_headers).value!
252
+ end
253
+
254
+ #
255
+ # Updates an image list with list Id equal to list Id passed.
256
+ #
257
+ # @param list_id [String] List Id of the image list.
258
+ # @param content_type [String] The content type.
259
+ # @param body [Body] Schema of the body.
260
+ # @param [Hash{String => String}] A hash of custom headers that will be added
261
+ # to the HTTP request.
262
+ #
263
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
264
+ #
265
+ def update_async(list_id, content_type, body, custom_headers:nil)
266
+ fail ArgumentError, '@client.base_url is nil' if @client.base_url.nil?
267
+ fail ArgumentError, 'list_id is nil' if list_id.nil?
268
+ fail ArgumentError, 'content_type is nil' if content_type.nil?
269
+ fail ArgumentError, 'body is nil' if body.nil?
270
+
271
+
272
+ request_headers = {}
273
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
274
+
275
+ # Set Headers
276
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
277
+ request_headers['Content-Type'] = content_type unless content_type.nil?
278
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
279
+
280
+ # Serialize Request
281
+ request_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::Body.mapper()
282
+ request_content = @client.serialize(request_mapper, body)
283
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
284
+
285
+ path_template = 'contentmoderator/lists/v1.0/imagelists/{listId}'
286
+
287
+ request_url = @base_url || @client.base_url
288
+ request_url = request_url.gsub('{baseUrl}', @client.base_url)
289
+
290
+ options = {
291
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
292
+ path_params: {'listId' => list_id},
293
+ body: request_content,
294
+ headers: request_headers.merge(custom_headers || {}),
295
+ base_url: request_url
296
+ }
297
+ promise = @client.make_request_async(:put, path_template, options)
298
+
299
+ promise = promise.then do |result|
300
+ http_response = result.response
301
+ status_code = http_response.status
302
+ response_content = http_response.body
303
+ unless status_code == 200
304
+ error_model = JSON.load(response_content)
305
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
306
+ end
307
+
308
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
309
+ # Deserialize Response
310
+ if status_code == 200
311
+ begin
312
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
313
+ result_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::ImageList.mapper()
314
+ result.body = @client.deserialize(result_mapper, parsed_response)
315
+ rescue Exception => e
316
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
317
+ end
318
+ end
319
+
320
+ result
321
+ end
322
+
323
+ promise.execute
324
+ end
325
+
326
+ #
327
+ # Creates an image list.
328
+ #
329
+ # @param content_type [String] The content type.
330
+ # @param body [Body] Schema of the body.
331
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
332
+ # will be added to the HTTP request.
333
+ #
334
+ # @return [ImageList] operation results.
335
+ #
336
+ def create(content_type, body, custom_headers:nil)
337
+ response = create_async(content_type, body, custom_headers:custom_headers).value!
338
+ response.body unless response.nil?
339
+ end
340
+
341
+ #
342
+ # Creates an image list.
343
+ #
344
+ # @param content_type [String] The content type.
345
+ # @param body [Body] Schema of the body.
346
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
347
+ # will be added to the HTTP request.
348
+ #
349
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
350
+ #
351
+ def create_with_http_info(content_type, body, custom_headers:nil)
352
+ create_async(content_type, body, custom_headers:custom_headers).value!
353
+ end
354
+
355
+ #
356
+ # Creates an image list.
357
+ #
358
+ # @param content_type [String] The content type.
359
+ # @param body [Body] Schema of the body.
360
+ # @param [Hash{String => String}] A hash of custom headers that will be added
361
+ # to the HTTP request.
362
+ #
363
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
364
+ #
365
+ def create_async(content_type, body, custom_headers:nil)
366
+ fail ArgumentError, '@client.base_url is nil' if @client.base_url.nil?
367
+ fail ArgumentError, 'content_type is nil' if content_type.nil?
368
+ fail ArgumentError, 'body is nil' if body.nil?
369
+
370
+
371
+ request_headers = {}
372
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
373
+
374
+ # Set Headers
375
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
376
+ request_headers['Content-Type'] = content_type unless content_type.nil?
377
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
378
+
379
+ # Serialize Request
380
+ request_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::Body.mapper()
381
+ request_content = @client.serialize(request_mapper, body)
382
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
383
+
384
+ path_template = 'contentmoderator/lists/v1.0/imagelists'
385
+
386
+ request_url = @base_url || @client.base_url
387
+ request_url = request_url.gsub('{baseUrl}', @client.base_url)
388
+
389
+ options = {
390
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
391
+ body: request_content,
392
+ headers: request_headers.merge(custom_headers || {}),
393
+ base_url: request_url
394
+ }
395
+ promise = @client.make_request_async(:post, path_template, options)
396
+
397
+ promise = promise.then do |result|
398
+ http_response = result.response
399
+ status_code = http_response.status
400
+ response_content = http_response.body
401
+ unless status_code == 200
402
+ error_model = JSON.load(response_content)
403
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
404
+ end
405
+
406
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
407
+ # Deserialize Response
408
+ if status_code == 200
409
+ begin
410
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
411
+ result_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::ImageList.mapper()
412
+ result.body = @client.deserialize(result_mapper, parsed_response)
413
+ rescue Exception => e
414
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
415
+ end
416
+ end
417
+
418
+ result
419
+ end
420
+
421
+ promise.execute
422
+ end
423
+
424
+ #
425
+ # Gets all the Image Lists.
426
+ #
427
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
428
+ # will be added to the HTTP request.
429
+ #
430
+ # @return [Array] operation results.
431
+ #
432
+ def get_all_image_lists(custom_headers:nil)
433
+ response = get_all_image_lists_async(custom_headers:custom_headers).value!
434
+ response.body unless response.nil?
435
+ end
436
+
437
+ #
438
+ # Gets all the Image Lists.
439
+ #
440
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
441
+ # will be added to the HTTP request.
442
+ #
443
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
444
+ #
445
+ def get_all_image_lists_with_http_info(custom_headers:nil)
446
+ get_all_image_lists_async(custom_headers:custom_headers).value!
447
+ end
448
+
449
+ #
450
+ # Gets all the Image Lists.
451
+ #
452
+ # @param [Hash{String => String}] A hash of custom headers that will be added
453
+ # to the HTTP request.
454
+ #
455
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
456
+ #
457
+ def get_all_image_lists_async(custom_headers:nil)
458
+ fail ArgumentError, '@client.base_url is nil' if @client.base_url.nil?
459
+
460
+
461
+ request_headers = {}
462
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
463
+
464
+ # Set Headers
465
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
466
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
467
+ path_template = 'contentmoderator/lists/v1.0/imagelists'
468
+
469
+ request_url = @base_url || @client.base_url
470
+ request_url = request_url.gsub('{baseUrl}', @client.base_url)
471
+
472
+ options = {
473
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
474
+ headers: request_headers.merge(custom_headers || {}),
475
+ base_url: request_url
476
+ }
477
+ promise = @client.make_request_async(:get, path_template, options)
478
+
479
+ promise = promise.then do |result|
480
+ http_response = result.response
481
+ status_code = http_response.status
482
+ response_content = http_response.body
483
+ unless status_code == 200
484
+ error_model = JSON.load(response_content)
485
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
486
+ end
487
+
488
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
489
+ # Deserialize Response
490
+ if status_code == 200
491
+ begin
492
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
493
+ result_mapper = {
494
+ client_side_validation: true,
495
+ required: false,
496
+ serialized_name: 'parsed_response',
497
+ type: {
498
+ name: 'Sequence',
499
+ element: {
500
+ client_side_validation: true,
501
+ required: false,
502
+ serialized_name: 'ImageListElementType',
503
+ type: {
504
+ name: 'Composite',
505
+ class_name: 'ImageList'
506
+ }
507
+ }
508
+ }
509
+ }
510
+ result.body = @client.deserialize(result_mapper, parsed_response)
511
+ rescue Exception => e
512
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
513
+ end
514
+ end
515
+
516
+ result
517
+ end
518
+
519
+ promise.execute
520
+ end
521
+
522
+ #
523
+ # Refreshes the index of the list with list Id equal to list Id passed.
524
+ #
525
+ # @param list_id [String] List Id of the image list.
526
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
527
+ # will be added to the HTTP request.
528
+ #
529
+ # @return [RefreshIndex] operation results.
530
+ #
531
+ def refresh_index_method(list_id, custom_headers:nil)
532
+ response = refresh_index_method_async(list_id, custom_headers:custom_headers).value!
533
+ response.body unless response.nil?
534
+ end
535
+
536
+ #
537
+ # Refreshes the index of the list with list Id equal to list Id passed.
538
+ #
539
+ # @param list_id [String] List Id of the image list.
540
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
541
+ # will be added to the HTTP request.
542
+ #
543
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
544
+ #
545
+ def refresh_index_method_with_http_info(list_id, custom_headers:nil)
546
+ refresh_index_method_async(list_id, custom_headers:custom_headers).value!
547
+ end
548
+
549
+ #
550
+ # Refreshes the index of the list with list Id equal to list Id passed.
551
+ #
552
+ # @param list_id [String] List Id of the image list.
553
+ # @param [Hash{String => String}] A hash of custom headers that will be added
554
+ # to the HTTP request.
555
+ #
556
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
557
+ #
558
+ def refresh_index_method_async(list_id, custom_headers:nil)
559
+ fail ArgumentError, '@client.base_url is nil' if @client.base_url.nil?
560
+ fail ArgumentError, 'list_id is nil' if list_id.nil?
561
+
562
+
563
+ request_headers = {}
564
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
565
+
566
+ # Set Headers
567
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
568
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
569
+ path_template = 'contentmoderator/lists/v1.0/imagelists/{listId}/RefreshIndex'
570
+
571
+ request_url = @base_url || @client.base_url
572
+ request_url = request_url.gsub('{baseUrl}', @client.base_url)
573
+
574
+ options = {
575
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
576
+ path_params: {'listId' => list_id},
577
+ headers: request_headers.merge(custom_headers || {}),
578
+ base_url: request_url
579
+ }
580
+ promise = @client.make_request_async(:post, path_template, options)
581
+
582
+ promise = promise.then do |result|
583
+ http_response = result.response
584
+ status_code = http_response.status
585
+ response_content = http_response.body
586
+ unless status_code == 200
587
+ error_model = JSON.load(response_content)
588
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
589
+ end
590
+
591
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
592
+ # Deserialize Response
593
+ if status_code == 200
594
+ begin
595
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
596
+ result_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::RefreshIndex.mapper()
597
+ result.body = @client.deserialize(result_mapper, parsed_response)
598
+ rescue Exception => e
599
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
600
+ end
601
+ end
602
+
603
+ result
604
+ end
605
+
606
+ promise.execute
607
+ end
608
+
609
+ end
610
+ end