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.
- checksums.yaml +7 -0
- data/LICENSE.txt +21 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator.rb +93 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/content_moderator_client.rb +167 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/image_moderation.rb +1399 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/list_management_image.rb +637 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/list_management_image_lists.rb +610 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/list_management_term.rb +429 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/list_management_term_lists.rb +618 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/address.rb +58 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/apierror.rb +47 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/azure_region_base_url.rb +27 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/body.rb +70 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/body_metadata.rb +57 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/candidate.rb +57 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/classification.rb +82 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/content.rb +47 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/create_review_body_item.rb +101 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/create_review_body_item_metadata_item.rb +58 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/create_video_reviews_body_item.rb +144 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/create_video_reviews_body_item_metadata_item.rb +58 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/create_video_reviews_body_item_video_frames_item.rb +112 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/create_video_reviews_body_item_video_frames_item_metadata_item.rb +59 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/create_video_reviews_body_item_video_frames_item_reviewer_result_tags_item.rb +60 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/detected_language.rb +69 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/detected_terms.rb +81 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/email.rb +80 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/error.rb +57 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/evaluate.rb +144 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/face.rb +79 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/found_faces.rb +131 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/frame.rb +97 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/frames.rb +66 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/image.rb +89 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/image_additional_info_item.rb +58 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/image_ids.rb +88 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/image_list.rb +80 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/image_list_metadata.rb +57 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/image_url.rb +59 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/ipa.rb +69 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/job.rb +153 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/job_execution_report_details.rb +57 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/job_id.rb +47 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/job_list_result.rb +54 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/key_value_pair.rb +57 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/match.rb +98 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/match_response.rb +100 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/ocr.rb +131 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/phone.rb +69 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/pii.rb +115 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/refresh_index.rb +100 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/refresh_index_advanced_info_item.rb +58 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/review.rb +163 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/score.rb +48 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/screen.rb +165 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/status.rb +68 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/tag.rb +57 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/term_list.rb +80 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/term_list_metadata.rb +57 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/terms.rb +59 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/terms_data.rb +89 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/terms_in_list.rb +46 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/terms_paging.rb +79 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/transcript_moderation_body_item.rb +67 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/transcript_moderation_body_item_terms_item.rb +58 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/video_frame_body_item.rb +98 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/video_frame_body_item_metadata_item.rb +58 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/models/video_frame_body_item_reviewer_result_tags_item.rb +58 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/module_definition.rb +9 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/reviews.rb +1829 -0
- data/lib/1.0/generated/azure_cognitiveservices_contentmoderator/text_moderation.rb +294 -0
- data/lib/azure_cognitiveservices_contentmoderator.rb +6 -0
- data/lib/module_definition.rb +7 -0
- data/lib/profiles/latest/contentmoderator_latest_profile_client.rb +38 -0
- data/lib/profiles/latest/contentmoderator_module_definition.rb +8 -0
- data/lib/profiles/latest/modules/contentmoderator_profile_module.rb +307 -0
- data/lib/version.rb +7 -0
- metadata +196 -0
|
@@ -0,0 +1,637 @@
|
|
|
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 ListManagementImage
|
|
29
|
+
include MsRestAzure
|
|
30
|
+
|
|
31
|
+
#
|
|
32
|
+
# Creates and initializes a new instance of the ListManagementImage 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 an image to the list with list Id equal to list Id passed.
|
|
44
|
+
#
|
|
45
|
+
# @param list_id [String] List Id of the image list.
|
|
46
|
+
# @param tag [Integer] Tag for the image.
|
|
47
|
+
# @param label [String] The image label.
|
|
48
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
|
49
|
+
# will be added to the HTTP request.
|
|
50
|
+
#
|
|
51
|
+
# @return [Image] operation results.
|
|
52
|
+
#
|
|
53
|
+
def add_image(list_id, tag:nil, label:nil, custom_headers:nil)
|
|
54
|
+
response = add_image_async(list_id, tag:tag, label:label, custom_headers:custom_headers).value!
|
|
55
|
+
response.body unless response.nil?
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
#
|
|
59
|
+
# Add an image to the list with list Id equal to list Id passed.
|
|
60
|
+
#
|
|
61
|
+
# @param list_id [String] List Id of the image list.
|
|
62
|
+
# @param tag [Integer] Tag for the image.
|
|
63
|
+
# @param label [String] The image label.
|
|
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_image_with_http_info(list_id, tag:nil, label:nil, custom_headers:nil)
|
|
70
|
+
add_image_async(list_id, tag:tag, label:label, custom_headers:custom_headers).value!
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
#
|
|
74
|
+
# Add an image to the list with list Id equal to list Id passed.
|
|
75
|
+
#
|
|
76
|
+
# @param list_id [String] List Id of the image list.
|
|
77
|
+
# @param tag [Integer] Tag for the image.
|
|
78
|
+
# @param label [String] The image label.
|
|
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_image_async(list_id, tag:nil, label:nil, 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
|
+
|
|
88
|
+
|
|
89
|
+
request_headers = {}
|
|
90
|
+
request_headers['Content-Type'] = 'application/json; charset=utf-8'
|
|
91
|
+
|
|
92
|
+
# Set Headers
|
|
93
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
|
94
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
|
95
|
+
path_template = 'contentmoderator/lists/v1.0/imagelists/{listId}/images'
|
|
96
|
+
|
|
97
|
+
request_url = @base_url || @client.base_url
|
|
98
|
+
request_url = request_url.gsub('{baseUrl}', @client.base_url)
|
|
99
|
+
|
|
100
|
+
options = {
|
|
101
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
|
102
|
+
path_params: {'listId' => list_id},
|
|
103
|
+
query_params: {'tag' => tag,'label' => label},
|
|
104
|
+
headers: request_headers.merge(custom_headers || {}),
|
|
105
|
+
base_url: request_url
|
|
106
|
+
}
|
|
107
|
+
promise = @client.make_request_async(:post, path_template, options)
|
|
108
|
+
|
|
109
|
+
promise = promise.then do |result|
|
|
110
|
+
http_response = result.response
|
|
111
|
+
status_code = http_response.status
|
|
112
|
+
response_content = http_response.body
|
|
113
|
+
unless status_code == 200
|
|
114
|
+
error_model = JSON.load(response_content)
|
|
115
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
|
119
|
+
# Deserialize Response
|
|
120
|
+
if status_code == 200
|
|
121
|
+
begin
|
|
122
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
|
123
|
+
result_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::Image.mapper()
|
|
124
|
+
result.body = @client.deserialize(result_mapper, parsed_response)
|
|
125
|
+
rescue Exception => e
|
|
126
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
result
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
promise.execute
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
#
|
|
137
|
+
# Deletes all images from the list with list Id equal to list Id passed.
|
|
138
|
+
#
|
|
139
|
+
# @param list_id [String] List Id of the image list.
|
|
140
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
|
141
|
+
# will be added to the HTTP request.
|
|
142
|
+
#
|
|
143
|
+
# @return [String] operation results.
|
|
144
|
+
#
|
|
145
|
+
def delete_all_images(list_id, custom_headers:nil)
|
|
146
|
+
response = delete_all_images_async(list_id, custom_headers:custom_headers).value!
|
|
147
|
+
response.body unless response.nil?
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
#
|
|
151
|
+
# Deletes all images from the list with list Id equal to list Id passed.
|
|
152
|
+
#
|
|
153
|
+
# @param list_id [String] List Id of the image list.
|
|
154
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
|
155
|
+
# will be added to the HTTP request.
|
|
156
|
+
#
|
|
157
|
+
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
|
158
|
+
#
|
|
159
|
+
def delete_all_images_with_http_info(list_id, custom_headers:nil)
|
|
160
|
+
delete_all_images_async(list_id, custom_headers:custom_headers).value!
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
#
|
|
164
|
+
# Deletes all images from the list with list Id equal to list Id passed.
|
|
165
|
+
#
|
|
166
|
+
# @param list_id [String] List Id of the image list.
|
|
167
|
+
# @param [Hash{String => String}] A hash of custom headers that will be added
|
|
168
|
+
# to the HTTP request.
|
|
169
|
+
#
|
|
170
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
|
171
|
+
#
|
|
172
|
+
def delete_all_images_async(list_id, custom_headers:nil)
|
|
173
|
+
fail ArgumentError, '@client.base_url is nil' if @client.base_url.nil?
|
|
174
|
+
fail ArgumentError, 'list_id is nil' if list_id.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/imagelists/{listId}/images'
|
|
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},
|
|
191
|
+
headers: request_headers.merge(custom_headers || {}),
|
|
192
|
+
base_url: request_url
|
|
193
|
+
}
|
|
194
|
+
promise = @client.make_request_async(:delete, path_template, options)
|
|
195
|
+
|
|
196
|
+
promise = promise.then do |result|
|
|
197
|
+
http_response = result.response
|
|
198
|
+
status_code = http_response.status
|
|
199
|
+
response_content = http_response.body
|
|
200
|
+
unless status_code == 200
|
|
201
|
+
error_model = JSON.load(response_content)
|
|
202
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
|
206
|
+
# Deserialize Response
|
|
207
|
+
if status_code == 200
|
|
208
|
+
begin
|
|
209
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
|
210
|
+
result_mapper = {
|
|
211
|
+
client_side_validation: true,
|
|
212
|
+
required: false,
|
|
213
|
+
serialized_name: 'parsed_response',
|
|
214
|
+
type: {
|
|
215
|
+
name: 'String'
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
result.body = @client.deserialize(result_mapper, parsed_response)
|
|
219
|
+
rescue Exception => e
|
|
220
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
|
221
|
+
end
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
result
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
promise.execute
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
#
|
|
231
|
+
# Gets all image Ids from the list with list Id equal to list Id passed.
|
|
232
|
+
#
|
|
233
|
+
# @param list_id [String] List Id of the image list.
|
|
234
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
|
235
|
+
# will be added to the HTTP request.
|
|
236
|
+
#
|
|
237
|
+
# @return [ImageIds] operation results.
|
|
238
|
+
#
|
|
239
|
+
def get_all_image_ids(list_id, custom_headers:nil)
|
|
240
|
+
response = get_all_image_ids_async(list_id, custom_headers:custom_headers).value!
|
|
241
|
+
response.body unless response.nil?
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
#
|
|
245
|
+
# Gets all image Ids from the list with list Id equal to list Id passed.
|
|
246
|
+
#
|
|
247
|
+
# @param list_id [String] List Id of the image list.
|
|
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 get_all_image_ids_with_http_info(list_id, custom_headers:nil)
|
|
254
|
+
get_all_image_ids_async(list_id, custom_headers:custom_headers).value!
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
#
|
|
258
|
+
# Gets all image Ids from the list with list Id equal to list Id passed.
|
|
259
|
+
#
|
|
260
|
+
# @param list_id [String] List Id of the image list.
|
|
261
|
+
# @param [Hash{String => String}] A hash of custom headers that will be added
|
|
262
|
+
# to the HTTP request.
|
|
263
|
+
#
|
|
264
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
|
265
|
+
#
|
|
266
|
+
def get_all_image_ids_async(list_id, custom_headers:nil)
|
|
267
|
+
fail ArgumentError, '@client.base_url is nil' if @client.base_url.nil?
|
|
268
|
+
fail ArgumentError, 'list_id is nil' if list_id.nil?
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
request_headers = {}
|
|
272
|
+
request_headers['Content-Type'] = 'application/json; charset=utf-8'
|
|
273
|
+
|
|
274
|
+
# Set Headers
|
|
275
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
|
276
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
|
277
|
+
path_template = 'contentmoderator/lists/v1.0/imagelists/{listId}/images'
|
|
278
|
+
|
|
279
|
+
request_url = @base_url || @client.base_url
|
|
280
|
+
request_url = request_url.gsub('{baseUrl}', @client.base_url)
|
|
281
|
+
|
|
282
|
+
options = {
|
|
283
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
|
284
|
+
path_params: {'listId' => list_id},
|
|
285
|
+
headers: request_headers.merge(custom_headers || {}),
|
|
286
|
+
base_url: request_url
|
|
287
|
+
}
|
|
288
|
+
promise = @client.make_request_async(:get, path_template, options)
|
|
289
|
+
|
|
290
|
+
promise = promise.then do |result|
|
|
291
|
+
http_response = result.response
|
|
292
|
+
status_code = http_response.status
|
|
293
|
+
response_content = http_response.body
|
|
294
|
+
unless status_code == 200
|
|
295
|
+
error_model = JSON.load(response_content)
|
|
296
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
|
297
|
+
end
|
|
298
|
+
|
|
299
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
|
300
|
+
# Deserialize Response
|
|
301
|
+
if status_code == 200
|
|
302
|
+
begin
|
|
303
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
|
304
|
+
result_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::ImageIds.mapper()
|
|
305
|
+
result.body = @client.deserialize(result_mapper, parsed_response)
|
|
306
|
+
rescue Exception => e
|
|
307
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
|
308
|
+
end
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
result
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
promise.execute
|
|
315
|
+
end
|
|
316
|
+
|
|
317
|
+
#
|
|
318
|
+
# Deletes an image from the list with list Id and image Id passed.
|
|
319
|
+
#
|
|
320
|
+
# @param list_id [String] List Id of the image list.
|
|
321
|
+
# @param image_id [String] Id of the image.
|
|
322
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
|
323
|
+
# will be added to the HTTP request.
|
|
324
|
+
#
|
|
325
|
+
# @return [String] operation results.
|
|
326
|
+
#
|
|
327
|
+
def delete_image(list_id, image_id, custom_headers:nil)
|
|
328
|
+
response = delete_image_async(list_id, image_id, custom_headers:custom_headers).value!
|
|
329
|
+
response.body unless response.nil?
|
|
330
|
+
end
|
|
331
|
+
|
|
332
|
+
#
|
|
333
|
+
# Deletes an image from the list with list Id and image Id passed.
|
|
334
|
+
#
|
|
335
|
+
# @param list_id [String] List Id of the image list.
|
|
336
|
+
# @param image_id [String] Id of the image.
|
|
337
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
|
338
|
+
# will be added to the HTTP request.
|
|
339
|
+
#
|
|
340
|
+
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
|
341
|
+
#
|
|
342
|
+
def delete_image_with_http_info(list_id, image_id, custom_headers:nil)
|
|
343
|
+
delete_image_async(list_id, image_id, custom_headers:custom_headers).value!
|
|
344
|
+
end
|
|
345
|
+
|
|
346
|
+
#
|
|
347
|
+
# Deletes an image from the list with list Id and image Id passed.
|
|
348
|
+
#
|
|
349
|
+
# @param list_id [String] List Id of the image list.
|
|
350
|
+
# @param image_id [String] Id of the image.
|
|
351
|
+
# @param [Hash{String => String}] A hash of custom headers that will be added
|
|
352
|
+
# to the HTTP request.
|
|
353
|
+
#
|
|
354
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
|
355
|
+
#
|
|
356
|
+
def delete_image_async(list_id, image_id, custom_headers:nil)
|
|
357
|
+
fail ArgumentError, '@client.base_url is nil' if @client.base_url.nil?
|
|
358
|
+
fail ArgumentError, 'list_id is nil' if list_id.nil?
|
|
359
|
+
fail ArgumentError, 'image_id is nil' if image_id.nil?
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
request_headers = {}
|
|
363
|
+
request_headers['Content-Type'] = 'application/json; charset=utf-8'
|
|
364
|
+
|
|
365
|
+
# Set Headers
|
|
366
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
|
367
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
|
368
|
+
path_template = 'contentmoderator/lists/v1.0/imagelists/{listId}/images/{ImageId}'
|
|
369
|
+
|
|
370
|
+
request_url = @base_url || @client.base_url
|
|
371
|
+
request_url = request_url.gsub('{baseUrl}', @client.base_url)
|
|
372
|
+
|
|
373
|
+
options = {
|
|
374
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
|
375
|
+
path_params: {'listId' => list_id,'ImageId' => image_id},
|
|
376
|
+
headers: request_headers.merge(custom_headers || {}),
|
|
377
|
+
base_url: request_url
|
|
378
|
+
}
|
|
379
|
+
promise = @client.make_request_async(:delete, path_template, options)
|
|
380
|
+
|
|
381
|
+
promise = promise.then do |result|
|
|
382
|
+
http_response = result.response
|
|
383
|
+
status_code = http_response.status
|
|
384
|
+
response_content = http_response.body
|
|
385
|
+
unless status_code == 200
|
|
386
|
+
error_model = JSON.load(response_content)
|
|
387
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
|
388
|
+
end
|
|
389
|
+
|
|
390
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
|
391
|
+
# Deserialize Response
|
|
392
|
+
if status_code == 200
|
|
393
|
+
begin
|
|
394
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
|
395
|
+
result_mapper = {
|
|
396
|
+
client_side_validation: true,
|
|
397
|
+
required: false,
|
|
398
|
+
serialized_name: 'parsed_response',
|
|
399
|
+
type: {
|
|
400
|
+
name: 'String'
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
result.body = @client.deserialize(result_mapper, parsed_response)
|
|
404
|
+
rescue Exception => e
|
|
405
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
|
406
|
+
end
|
|
407
|
+
end
|
|
408
|
+
|
|
409
|
+
result
|
|
410
|
+
end
|
|
411
|
+
|
|
412
|
+
promise.execute
|
|
413
|
+
end
|
|
414
|
+
|
|
415
|
+
#
|
|
416
|
+
# Add an image to the list with list Id equal to list Id passed.
|
|
417
|
+
#
|
|
418
|
+
# @param list_id [String] List Id of the image list.
|
|
419
|
+
# @param content_type [String] The content type.
|
|
420
|
+
# @param image_url [ImageUrl] The image url.
|
|
421
|
+
# @param tag [Integer] Tag for the image.
|
|
422
|
+
# @param label [String] The image label.
|
|
423
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
|
424
|
+
# will be added to the HTTP request.
|
|
425
|
+
#
|
|
426
|
+
# @return [Image] operation results.
|
|
427
|
+
#
|
|
428
|
+
def add_image_url_input(list_id, content_type, image_url, tag:nil, label:nil, custom_headers:nil)
|
|
429
|
+
response = add_image_url_input_async(list_id, content_type, image_url, tag:tag, label:label, custom_headers:custom_headers).value!
|
|
430
|
+
response.body unless response.nil?
|
|
431
|
+
end
|
|
432
|
+
|
|
433
|
+
#
|
|
434
|
+
# Add an image to the list with list Id equal to list Id passed.
|
|
435
|
+
#
|
|
436
|
+
# @param list_id [String] List Id of the image list.
|
|
437
|
+
# @param content_type [String] The content type.
|
|
438
|
+
# @param image_url [ImageUrl] The image url.
|
|
439
|
+
# @param tag [Integer] Tag for the image.
|
|
440
|
+
# @param label [String] The image label.
|
|
441
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
|
442
|
+
# will be added to the HTTP request.
|
|
443
|
+
#
|
|
444
|
+
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
|
445
|
+
#
|
|
446
|
+
def add_image_url_input_with_http_info(list_id, content_type, image_url, tag:nil, label:nil, custom_headers:nil)
|
|
447
|
+
add_image_url_input_async(list_id, content_type, image_url, tag:tag, label:label, custom_headers:custom_headers).value!
|
|
448
|
+
end
|
|
449
|
+
|
|
450
|
+
#
|
|
451
|
+
# Add an image to the list with list Id equal to list Id passed.
|
|
452
|
+
#
|
|
453
|
+
# @param list_id [String] List Id of the image list.
|
|
454
|
+
# @param content_type [String] The content type.
|
|
455
|
+
# @param image_url [ImageUrl] The image url.
|
|
456
|
+
# @param tag [Integer] Tag for the image.
|
|
457
|
+
# @param label [String] The image label.
|
|
458
|
+
# @param [Hash{String => String}] A hash of custom headers that will be added
|
|
459
|
+
# to the HTTP request.
|
|
460
|
+
#
|
|
461
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
|
462
|
+
#
|
|
463
|
+
def add_image_url_input_async(list_id, content_type, image_url, tag:nil, label:nil, custom_headers:nil)
|
|
464
|
+
fail ArgumentError, '@client.base_url is nil' if @client.base_url.nil?
|
|
465
|
+
fail ArgumentError, 'list_id is nil' if list_id.nil?
|
|
466
|
+
fail ArgumentError, 'content_type is nil' if content_type.nil?
|
|
467
|
+
fail ArgumentError, 'image_url is nil' if image_url.nil?
|
|
468
|
+
|
|
469
|
+
|
|
470
|
+
request_headers = {}
|
|
471
|
+
request_headers['Content-Type'] = 'application/json; charset=utf-8'
|
|
472
|
+
|
|
473
|
+
# Set Headers
|
|
474
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
|
475
|
+
request_headers['Content-Type'] = content_type unless content_type.nil?
|
|
476
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
|
477
|
+
|
|
478
|
+
# Serialize Request
|
|
479
|
+
request_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::ImageUrl.mapper()
|
|
480
|
+
request_content = @client.serialize(request_mapper, image_url)
|
|
481
|
+
request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
|
|
482
|
+
|
|
483
|
+
path_template = 'contentmoderator/lists/v1.0/imagelists/{listId}/images'
|
|
484
|
+
|
|
485
|
+
request_url = @base_url || @client.base_url
|
|
486
|
+
request_url = request_url.gsub('{baseUrl}', @client.base_url)
|
|
487
|
+
|
|
488
|
+
options = {
|
|
489
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
|
490
|
+
path_params: {'listId' => list_id},
|
|
491
|
+
query_params: {'tag' => tag,'label' => label},
|
|
492
|
+
body: request_content,
|
|
493
|
+
headers: request_headers.merge(custom_headers || {}),
|
|
494
|
+
base_url: request_url
|
|
495
|
+
}
|
|
496
|
+
promise = @client.make_request_async(:post, path_template, options)
|
|
497
|
+
|
|
498
|
+
promise = promise.then do |result|
|
|
499
|
+
http_response = result.response
|
|
500
|
+
status_code = http_response.status
|
|
501
|
+
response_content = http_response.body
|
|
502
|
+
unless status_code == 200
|
|
503
|
+
error_model = JSON.load(response_content)
|
|
504
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
|
505
|
+
end
|
|
506
|
+
|
|
507
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
|
508
|
+
# Deserialize Response
|
|
509
|
+
if status_code == 200
|
|
510
|
+
begin
|
|
511
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
|
512
|
+
result_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::Image.mapper()
|
|
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
|
+
# Add an image to the list with list Id equal to list Id passed.
|
|
527
|
+
#
|
|
528
|
+
# @param list_id [String] List Id of the image list.
|
|
529
|
+
# @param image_stream The image file.
|
|
530
|
+
# @param tag [Integer] Tag for the image.
|
|
531
|
+
# @param label [String] The image label.
|
|
532
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
|
533
|
+
# will be added to the HTTP request.
|
|
534
|
+
#
|
|
535
|
+
# @return [Image] operation results.
|
|
536
|
+
#
|
|
537
|
+
def add_image_file_input(list_id, image_stream, tag:nil, label:nil, custom_headers:nil)
|
|
538
|
+
response = add_image_file_input_async(list_id, image_stream, tag:tag, label:label, custom_headers:custom_headers).value!
|
|
539
|
+
response.body unless response.nil?
|
|
540
|
+
end
|
|
541
|
+
|
|
542
|
+
#
|
|
543
|
+
# Add an image to the list with list Id equal to list Id passed.
|
|
544
|
+
#
|
|
545
|
+
# @param list_id [String] List Id of the image list.
|
|
546
|
+
# @param image_stream The image file.
|
|
547
|
+
# @param tag [Integer] Tag for the image.
|
|
548
|
+
# @param label [String] The image label.
|
|
549
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
|
550
|
+
# will be added to the HTTP request.
|
|
551
|
+
#
|
|
552
|
+
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
|
553
|
+
#
|
|
554
|
+
def add_image_file_input_with_http_info(list_id, image_stream, tag:nil, label:nil, custom_headers:nil)
|
|
555
|
+
add_image_file_input_async(list_id, image_stream, tag:tag, label:label, custom_headers:custom_headers).value!
|
|
556
|
+
end
|
|
557
|
+
|
|
558
|
+
#
|
|
559
|
+
# Add an image to the list with list Id equal to list Id passed.
|
|
560
|
+
#
|
|
561
|
+
# @param list_id [String] List Id of the image list.
|
|
562
|
+
# @param image_stream The image file.
|
|
563
|
+
# @param tag [Integer] Tag for the image.
|
|
564
|
+
# @param label [String] The image label.
|
|
565
|
+
# @param [Hash{String => String}] A hash of custom headers that will be added
|
|
566
|
+
# to the HTTP request.
|
|
567
|
+
#
|
|
568
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
|
569
|
+
#
|
|
570
|
+
def add_image_file_input_async(list_id, image_stream, tag:nil, label:nil, custom_headers:nil)
|
|
571
|
+
fail ArgumentError, '@client.base_url is nil' if @client.base_url.nil?
|
|
572
|
+
fail ArgumentError, 'list_id is nil' if list_id.nil?
|
|
573
|
+
fail ArgumentError, 'image_stream is nil' if image_stream.nil?
|
|
574
|
+
|
|
575
|
+
|
|
576
|
+
request_headers = {}
|
|
577
|
+
request_headers['Content-Type'] = 'image/gif'
|
|
578
|
+
|
|
579
|
+
# Set Headers
|
|
580
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
|
581
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
|
582
|
+
|
|
583
|
+
# Serialize Request
|
|
584
|
+
request_mapper = {
|
|
585
|
+
client_side_validation: true,
|
|
586
|
+
required: true,
|
|
587
|
+
serialized_name: 'ImageStream',
|
|
588
|
+
type: {
|
|
589
|
+
name: 'Stream'
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
request_content = @client.serialize(request_mapper, image_stream)
|
|
593
|
+
|
|
594
|
+
path_template = 'contentmoderator/lists/v1.0/imagelists/{listId}/images'
|
|
595
|
+
|
|
596
|
+
request_url = @base_url || @client.base_url
|
|
597
|
+
request_url = request_url.gsub('{baseUrl}', @client.base_url)
|
|
598
|
+
|
|
599
|
+
options = {
|
|
600
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
|
601
|
+
path_params: {'listId' => list_id},
|
|
602
|
+
query_params: {'tag' => tag,'label' => label},
|
|
603
|
+
body: request_content,
|
|
604
|
+
headers: request_headers.merge(custom_headers || {}),
|
|
605
|
+
base_url: request_url
|
|
606
|
+
}
|
|
607
|
+
promise = @client.make_request_async(:post, path_template, options)
|
|
608
|
+
|
|
609
|
+
promise = promise.then do |result|
|
|
610
|
+
http_response = result.response
|
|
611
|
+
status_code = http_response.status
|
|
612
|
+
response_content = http_response.body
|
|
613
|
+
unless status_code == 200
|
|
614
|
+
error_model = JSON.load(response_content)
|
|
615
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
|
616
|
+
end
|
|
617
|
+
|
|
618
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
|
619
|
+
# Deserialize Response
|
|
620
|
+
if status_code == 200
|
|
621
|
+
begin
|
|
622
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
|
623
|
+
result_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::Image.mapper()
|
|
624
|
+
result.body = @client.deserialize(result_mapper, parsed_response)
|
|
625
|
+
rescue Exception => e
|
|
626
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
|
627
|
+
end
|
|
628
|
+
end
|
|
629
|
+
|
|
630
|
+
result
|
|
631
|
+
end
|
|
632
|
+
|
|
633
|
+
promise.execute
|
|
634
|
+
end
|
|
635
|
+
|
|
636
|
+
end
|
|
637
|
+
end
|