Class: Azure::CognitiveServices::ContentModerator::V1_0::ListManagementTerm
- Inherits:
-
Object
- Object
- Azure::CognitiveServices::ContentModerator::V1_0::ListManagementTerm
- Includes:
- MsRestAzure
- Defined in:
- lib/1.0/generated/azure_cognitiveservices_contentmoderator/list_management_term.rb
Overview
You use the API to scan your content as it is generated. Content Moderator then processes your content and sends the results along with relevant information either back to your systems or to the built-in review tool. You can use this information to take decisions e.g. take it down, send to human judge, etc.
When using the API, images need to have a minimum of 128 pixels and a maximum file size of 4MB. Text can be at most 1024 characters long. If the content passed to the text API or the image API exceeds the size limits, the API will return an error code that informs about the issue.
Instance Attribute Summary collapse
-
#client ⇒ ContentModeratorClient
readonly
Reference to the ContentModeratorClient.
Instance Method Summary collapse
-
#add_term(list_id, term, language, custom_headers: nil) ⇒ Object
Add a term to the term list with list Id equal to list Id passed.
-
#add_term_async(list_id, term, language, custom_headers: nil) ⇒ Concurrent::Promise
Add a term to the term list with list Id equal to list Id passed.
-
#add_term_with_http_info(list_id, term, language, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
Add a term to the term list with list Id equal to list Id passed.
-
#delete_all_terms(list_id, language, custom_headers: nil) ⇒ String
Deletes all terms from the list with list Id equal to the list Id passed.
-
#delete_all_terms_async(list_id, language, custom_headers: nil) ⇒ Concurrent::Promise
Deletes all terms from the list with list Id equal to the list Id passed.
-
#delete_all_terms_with_http_info(list_id, language, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
Deletes all terms from the list with list Id equal to the list Id passed.
-
#delete_term(list_id, term, language, custom_headers: nil) ⇒ String
Deletes a term from the list with list Id equal to the list Id passed.
-
#delete_term_async(list_id, term, language, custom_headers: nil) ⇒ Concurrent::Promise
Deletes a term from the list with list Id equal to the list Id passed.
-
#delete_term_with_http_info(list_id, term, language, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
Deletes a term from the list with list Id equal to the list Id passed.
-
#get_all_terms(list_id, language, offset: nil, limit: nil, custom_headers: nil) ⇒ Terms
Gets all terms from the list with list Id equal to the list Id passed.
-
#get_all_terms_async(list_id, language, offset: nil, limit: nil, custom_headers: nil) ⇒ Concurrent::Promise
Gets all terms from the list with list Id equal to the list Id passed.
-
#get_all_terms_with_http_info(list_id, language, offset: nil, limit: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
Gets all terms from the list with list Id equal to the list Id passed.
-
#initialize(client) ⇒ ListManagementTerm
constructor
Creates and initializes a new instance of the ListManagementTerm class.
Constructor Details
#initialize(client) ⇒ ListManagementTerm
Creates and initializes a new instance of the ListManagementTerm class.
27 28 29 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/list_management_term.rb', line 27 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ ContentModeratorClient (readonly)
Returns reference to the ContentModeratorClient.
32 33 34 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/list_management_term.rb', line 32 def client @client end |
Instance Method Details
#add_term(list_id, term, language, custom_headers: nil) ⇒ Object
Add a term to the term list with list Id equal to list Id passed.
will be added to the HTTP request.
45 46 47 48 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/list_management_term.rb', line 45 def add_term(list_id, term, language, custom_headers:nil) response = add_term_async(list_id, term, language, custom_headers:custom_headers).value! response.body unless response.nil? end |
#add_term_async(list_id, term, language, custom_headers: nil) ⇒ Concurrent::Promise
Add a term to the term list with list Id equal to list Id passed.
to the HTTP request.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/list_management_term.rb', line 76 def add_term_async(list_id, term, language, custom_headers:nil) fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil? fail ArgumentError, 'list_id is nil' if list_id.nil? fail ArgumentError, 'term is nil' if term.nil? fail ArgumentError, 'language is nil' if language.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = 'contentmoderator/lists/v1.0/termlists/{listId}/terms/{term}' request_url = @base_url || @client.base_url request_url = request_url.gsub('{Endpoint}', @client.endpoint) = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'listId' => list_id,'term' => term}, query_params: {'language' => language}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = @client.make_request_async(:post, path_template, ) promise = promise.then do |result| http_response = result.response status_code = http_response.status response_content = http_response.body unless status_code == 201 error_model = JSON.load(response_content) fail MsRest::HttpOperationError.new(result.request, http_response, error_model) end result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? result end promise.execute end |
#add_term_with_http_info(list_id, term, language, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
Add a term to the term list with list Id equal to list Id passed.
will be added to the HTTP request.
61 62 63 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/list_management_term.rb', line 61 def add_term_with_http_info(list_id, term, language, custom_headers:nil) add_term_async(list_id, term, language, custom_headers:custom_headers).value! end |
#delete_all_terms(list_id, language, custom_headers: nil) ⇒ String
Deletes all terms from the list with list Id equal to the list Id passed.
will be added to the HTTP request.
331 332 333 334 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/list_management_term.rb', line 331 def delete_all_terms(list_id, language, custom_headers:nil) response = delete_all_terms_async(list_id, language, custom_headers:custom_headers).value! response.body unless response.nil? end |
#delete_all_terms_async(list_id, language, custom_headers: nil) ⇒ Concurrent::Promise
Deletes all terms from the list with list Id equal to the list Id passed.
to the HTTP request.
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/list_management_term.rb', line 360 def delete_all_terms_async(list_id, language, custom_headers:nil) fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil? fail ArgumentError, 'list_id is nil' if list_id.nil? fail ArgumentError, 'language is nil' if language.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = 'contentmoderator/lists/v1.0/termlists/{listId}/terms' request_url = @base_url || @client.base_url request_url = request_url.gsub('{Endpoint}', @client.endpoint) = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'listId' => list_id}, query_params: {'language' => language}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = @client.make_request_async(:delete, path_template, ) promise = promise.then do |result| http_response = result.response status_code = http_response.status response_content = http_response.body unless status_code == 204 error_model = JSON.load(response_content) fail MsRest::HttpOperationError.new(result.request, http_response, error_model) end result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? # Deserialize Response if status_code == 204 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = { client_side_validation: true, required: false, serialized_name: 'parsed_response', type: { name: 'String' } } result.body = @client.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e., e.backtrace, result) end end result end promise.execute end |
#delete_all_terms_with_http_info(list_id, language, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
Deletes all terms from the list with list Id equal to the list Id passed.
will be added to the HTTP request.
346 347 348 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/list_management_term.rb', line 346 def delete_all_terms_with_http_info(list_id, language, custom_headers:nil) delete_all_terms_async(list_id, language, custom_headers:custom_headers).value! end |
#delete_term(list_id, term, language, custom_headers: nil) ⇒ String
Deletes a term from the list with list Id equal to the list Id passed.
will be added to the HTTP request.
131 132 133 134 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/list_management_term.rb', line 131 def delete_term(list_id, term, language, custom_headers:nil) response = delete_term_async(list_id, term, language, custom_headers:custom_headers).value! response.body unless response.nil? end |
#delete_term_async(list_id, term, language, custom_headers: nil) ⇒ Concurrent::Promise
Deletes a term from the list with list Id equal to the list Id passed.
to the HTTP request.
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/list_management_term.rb', line 162 def delete_term_async(list_id, term, language, custom_headers:nil) fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil? fail ArgumentError, 'list_id is nil' if list_id.nil? fail ArgumentError, 'term is nil' if term.nil? fail ArgumentError, 'language is nil' if language.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = 'contentmoderator/lists/v1.0/termlists/{listId}/terms/{term}' request_url = @base_url || @client.base_url request_url = request_url.gsub('{Endpoint}', @client.endpoint) = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'listId' => list_id,'term' => term}, query_params: {'language' => language}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = @client.make_request_async(:delete, path_template, ) promise = promise.then do |result| http_response = result.response status_code = http_response.status response_content = http_response.body unless status_code == 204 error_model = JSON.load(response_content) fail MsRest::HttpOperationError.new(result.request, http_response, error_model) end result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? # Deserialize Response if status_code == 204 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = { client_side_validation: true, required: false, serialized_name: 'parsed_response', type: { name: 'String' } } result.body = @client.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e., e.backtrace, result) end end result end promise.execute end |
#delete_term_with_http_info(list_id, term, language, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
Deletes a term from the list with list Id equal to the list Id passed.
will be added to the HTTP request.
147 148 149 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/list_management_term.rb', line 147 def delete_term_with_http_info(list_id, term, language, custom_headers:nil) delete_term_async(list_id, term, language, custom_headers:custom_headers).value! end |
#get_all_terms(list_id, language, offset: nil, limit: nil, custom_headers: nil) ⇒ Terms
Gets all terms from the list with list Id equal to the list Id passed.
will be added to the HTTP request.
235 236 237 238 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/list_management_term.rb', line 235 def get_all_terms(list_id, language, offset:nil, limit:nil, custom_headers:nil) response = get_all_terms_async(list_id, language, offset:offset, limit:limit, custom_headers:custom_headers).value! response.body unless response.nil? end |
#get_all_terms_async(list_id, language, offset: nil, limit: nil, custom_headers: nil) ⇒ Concurrent::Promise
Gets all terms from the list with list Id equal to the list Id passed.
to the HTTP request.
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/list_management_term.rb', line 268 def get_all_terms_async(list_id, language, offset:nil, limit:nil, custom_headers:nil) fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil? fail ArgumentError, 'list_id is nil' if list_id.nil? fail ArgumentError, 'language is nil' if language.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = 'contentmoderator/lists/v1.0/termlists/{listId}/terms' request_url = @base_url || @client.base_url request_url = request_url.gsub('{Endpoint}', @client.endpoint) = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'listId' => list_id}, query_params: {'language' => language,'offset' => offset,'limit' => limit}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = @client.make_request_async(:get, path_template, ) promise = promise.then do |result| http_response = result.response status_code = http_response.status response_content = http_response.body unless status_code == 200 error_model = JSON.load(response_content) fail MsRest::HttpOperationError.new(result.request, http_response, error_model) end result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::Terms.mapper() result.body = @client.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e., e.backtrace, result) end end result end promise.execute end |
#get_all_terms_with_http_info(list_id, language, offset: nil, limit: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse
Gets all terms from the list with list Id equal to the list Id passed.
will be added to the HTTP request.
252 253 254 |
# File 'lib/1.0/generated/azure_cognitiveservices_contentmoderator/list_management_term.rb', line 252 def get_all_terms_with_http_info(list_id, language, offset:nil, limit:nil, custom_headers:nil) get_all_terms_async(list_id, language, offset:offset, limit:limit, custom_headers:custom_headers).value! end |