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
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: d6d8a0122c16f1a1134f99027d735d2d4605e121
|
|
4
|
+
data.tar.gz: 125bc9a94a68f8ccef1eb14f894ad32eb5c73512
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 98bcc457e923a53af5a99c632916b7cf44e243097f6daf7fb07ed6730ff709ef69aef7c6e45d8c872a031bc5b374c9b1f38134aca8cffe91e939ab25e1a85aa1
|
|
7
|
+
data.tar.gz: d915f63330ead8bc4b178cf3299bb65c5bd4a2d7d1ef97403cafa38aced232472182ec8dafcc1c42deda2240c9423a0a48a073d0927722e5f1649308b310c055
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015 Microsoft Corporation
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,93 @@
|
|
|
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
|
+
require 'uri'
|
|
7
|
+
require 'cgi'
|
|
8
|
+
require 'date'
|
|
9
|
+
require 'json'
|
|
10
|
+
require 'base64'
|
|
11
|
+
require 'erb'
|
|
12
|
+
require 'securerandom'
|
|
13
|
+
require 'time'
|
|
14
|
+
require 'timeliness'
|
|
15
|
+
require 'faraday'
|
|
16
|
+
require 'faraday-cookie_jar'
|
|
17
|
+
require 'concurrent'
|
|
18
|
+
require 'ms_rest'
|
|
19
|
+
require '1.0/generated/azure_cognitiveservices_contentmoderator/module_definition'
|
|
20
|
+
require 'ms_rest_azure'
|
|
21
|
+
|
|
22
|
+
module Azure::CognitiveServices::ContentModerator::V1_0
|
|
23
|
+
autoload :ImageModeration, '1.0/generated/azure_cognitiveservices_contentmoderator/image_moderation.rb'
|
|
24
|
+
autoload :TextModeration, '1.0/generated/azure_cognitiveservices_contentmoderator/text_moderation.rb'
|
|
25
|
+
autoload :ListManagementImageLists, '1.0/generated/azure_cognitiveservices_contentmoderator/list_management_image_lists.rb'
|
|
26
|
+
autoload :ListManagementTermLists, '1.0/generated/azure_cognitiveservices_contentmoderator/list_management_term_lists.rb'
|
|
27
|
+
autoload :ListManagementImage, '1.0/generated/azure_cognitiveservices_contentmoderator/list_management_image.rb'
|
|
28
|
+
autoload :ListManagementTerm, '1.0/generated/azure_cognitiveservices_contentmoderator/list_management_term.rb'
|
|
29
|
+
autoload :Reviews, '1.0/generated/azure_cognitiveservices_contentmoderator/reviews.rb'
|
|
30
|
+
autoload :ContentModeratorClient, '1.0/generated/azure_cognitiveservices_contentmoderator/content_moderator_client.rb'
|
|
31
|
+
|
|
32
|
+
module Models
|
|
33
|
+
autoload :Image, '1.0/generated/azure_cognitiveservices_contentmoderator/models/image.rb'
|
|
34
|
+
autoload :KeyValuePair, '1.0/generated/azure_cognitiveservices_contentmoderator/models/key_value_pair.rb'
|
|
35
|
+
autoload :ImageIds, '1.0/generated/azure_cognitiveservices_contentmoderator/models/image_ids.rb'
|
|
36
|
+
autoload :Frame, '1.0/generated/azure_cognitiveservices_contentmoderator/models/frame.rb'
|
|
37
|
+
autoload :TermsInList, '1.0/generated/azure_cognitiveservices_contentmoderator/models/terms_in_list.rb'
|
|
38
|
+
autoload :Score, '1.0/generated/azure_cognitiveservices_contentmoderator/models/score.rb'
|
|
39
|
+
autoload :TermsData, '1.0/generated/azure_cognitiveservices_contentmoderator/models/terms_data.rb'
|
|
40
|
+
autoload :Status, '1.0/generated/azure_cognitiveservices_contentmoderator/models/status.rb'
|
|
41
|
+
autoload :TermsPaging, '1.0/generated/azure_cognitiveservices_contentmoderator/models/terms_paging.rb'
|
|
42
|
+
autoload :IPA, '1.0/generated/azure_cognitiveservices_contentmoderator/models/ipa.rb'
|
|
43
|
+
autoload :Terms, '1.0/generated/azure_cognitiveservices_contentmoderator/models/terms.rb'
|
|
44
|
+
autoload :Address, '1.0/generated/azure_cognitiveservices_contentmoderator/models/address.rb'
|
|
45
|
+
autoload :Review, '1.0/generated/azure_cognitiveservices_contentmoderator/models/review.rb'
|
|
46
|
+
autoload :DetectedTerms, '1.0/generated/azure_cognitiveservices_contentmoderator/models/detected_terms.rb'
|
|
47
|
+
autoload :JobExecutionReportDetails, '1.0/generated/azure_cognitiveservices_contentmoderator/models/job_execution_report_details.rb'
|
|
48
|
+
autoload :Face, '1.0/generated/azure_cognitiveservices_contentmoderator/models/face.rb'
|
|
49
|
+
autoload :Job, '1.0/generated/azure_cognitiveservices_contentmoderator/models/job.rb'
|
|
50
|
+
autoload :Candidate, '1.0/generated/azure_cognitiveservices_contentmoderator/models/candidate.rb'
|
|
51
|
+
autoload :JobListResult, '1.0/generated/azure_cognitiveservices_contentmoderator/models/job_list_result.rb'
|
|
52
|
+
autoload :Evaluate, '1.0/generated/azure_cognitiveservices_contentmoderator/models/evaluate.rb'
|
|
53
|
+
autoload :JobId, '1.0/generated/azure_cognitiveservices_contentmoderator/models/job_id.rb'
|
|
54
|
+
autoload :MatchResponse, '1.0/generated/azure_cognitiveservices_contentmoderator/models/match_response.rb'
|
|
55
|
+
autoload :Error, '1.0/generated/azure_cognitiveservices_contentmoderator/models/error.rb'
|
|
56
|
+
autoload :ImageListMetadata, '1.0/generated/azure_cognitiveservices_contentmoderator/models/image_list_metadata.rb'
|
|
57
|
+
autoload :APIError, '1.0/generated/azure_cognitiveservices_contentmoderator/models/apierror.rb'
|
|
58
|
+
autoload :TermListMetadata, '1.0/generated/azure_cognitiveservices_contentmoderator/models/term_list_metadata.rb'
|
|
59
|
+
autoload :TranscriptModerationBodyItemTermsItem, '1.0/generated/azure_cognitiveservices_contentmoderator/models/transcript_moderation_body_item_terms_item.rb'
|
|
60
|
+
autoload :RefreshIndexAdvancedInfoItem, '1.0/generated/azure_cognitiveservices_contentmoderator/models/refresh_index_advanced_info_item.rb'
|
|
61
|
+
autoload :TranscriptModerationBodyItem, '1.0/generated/azure_cognitiveservices_contentmoderator/models/transcript_moderation_body_item.rb'
|
|
62
|
+
autoload :ImageAdditionalInfoItem, '1.0/generated/azure_cognitiveservices_contentmoderator/models/image_additional_info_item.rb'
|
|
63
|
+
autoload :CreateVideoReviewsBodyItemVideoFramesItemReviewerResultTagsItem, '1.0/generated/azure_cognitiveservices_contentmoderator/models/create_video_reviews_body_item_video_frames_item_reviewer_result_tags_item.rb'
|
|
64
|
+
autoload :Frames, '1.0/generated/azure_cognitiveservices_contentmoderator/models/frames.rb'
|
|
65
|
+
autoload :CreateVideoReviewsBodyItemVideoFramesItemMetadataItem, '1.0/generated/azure_cognitiveservices_contentmoderator/models/create_video_reviews_body_item_video_frames_item_metadata_item.rb'
|
|
66
|
+
autoload :Email, '1.0/generated/azure_cognitiveservices_contentmoderator/models/email.rb'
|
|
67
|
+
autoload :CreateVideoReviewsBodyItemVideoFramesItem, '1.0/generated/azure_cognitiveservices_contentmoderator/models/create_video_reviews_body_item_video_frames_item.rb'
|
|
68
|
+
autoload :PII, '1.0/generated/azure_cognitiveservices_contentmoderator/models/pii.rb'
|
|
69
|
+
autoload :CreateVideoReviewsBodyItemMetadataItem, '1.0/generated/azure_cognitiveservices_contentmoderator/models/create_video_reviews_body_item_metadata_item.rb'
|
|
70
|
+
autoload :FoundFaces, '1.0/generated/azure_cognitiveservices_contentmoderator/models/found_faces.rb'
|
|
71
|
+
autoload :CreateVideoReviewsBodyItem, '1.0/generated/azure_cognitiveservices_contentmoderator/models/create_video_reviews_body_item.rb'
|
|
72
|
+
autoload :Match, '1.0/generated/azure_cognitiveservices_contentmoderator/models/match.rb'
|
|
73
|
+
autoload :BodyMetadata, '1.0/generated/azure_cognitiveservices_contentmoderator/models/body_metadata.rb'
|
|
74
|
+
autoload :ImageList, '1.0/generated/azure_cognitiveservices_contentmoderator/models/image_list.rb'
|
|
75
|
+
autoload :Body, '1.0/generated/azure_cognitiveservices_contentmoderator/models/body.rb'
|
|
76
|
+
autoload :RefreshIndex, '1.0/generated/azure_cognitiveservices_contentmoderator/models/refresh_index.rb'
|
|
77
|
+
autoload :ImageUrl, '1.0/generated/azure_cognitiveservices_contentmoderator/models/image_url.rb'
|
|
78
|
+
autoload :Classification, '1.0/generated/azure_cognitiveservices_contentmoderator/models/classification.rb'
|
|
79
|
+
autoload :VideoFrameBodyItemReviewerResultTagsItem, '1.0/generated/azure_cognitiveservices_contentmoderator/models/video_frame_body_item_reviewer_result_tags_item.rb'
|
|
80
|
+
autoload :Screen, '1.0/generated/azure_cognitiveservices_contentmoderator/models/screen.rb'
|
|
81
|
+
autoload :VideoFrameBodyItemMetadataItem, '1.0/generated/azure_cognitiveservices_contentmoderator/models/video_frame_body_item_metadata_item.rb'
|
|
82
|
+
autoload :DetectedLanguage, '1.0/generated/azure_cognitiveservices_contentmoderator/models/detected_language.rb'
|
|
83
|
+
autoload :VideoFrameBodyItem, '1.0/generated/azure_cognitiveservices_contentmoderator/models/video_frame_body_item.rb'
|
|
84
|
+
autoload :Tag, '1.0/generated/azure_cognitiveservices_contentmoderator/models/tag.rb'
|
|
85
|
+
autoload :CreateReviewBodyItemMetadataItem, '1.0/generated/azure_cognitiveservices_contentmoderator/models/create_review_body_item_metadata_item.rb'
|
|
86
|
+
autoload :OCR, '1.0/generated/azure_cognitiveservices_contentmoderator/models/ocr.rb'
|
|
87
|
+
autoload :CreateReviewBodyItem, '1.0/generated/azure_cognitiveservices_contentmoderator/models/create_review_body_item.rb'
|
|
88
|
+
autoload :Phone, '1.0/generated/azure_cognitiveservices_contentmoderator/models/phone.rb'
|
|
89
|
+
autoload :Content, '1.0/generated/azure_cognitiveservices_contentmoderator/models/content.rb'
|
|
90
|
+
autoload :TermList, '1.0/generated/azure_cognitiveservices_contentmoderator/models/term_list.rb'
|
|
91
|
+
autoload :AzureRegionBaseUrl, '1.0/generated/azure_cognitiveservices_contentmoderator/models/azure_region_base_url.rb'
|
|
92
|
+
end
|
|
93
|
+
end
|
|
@@ -0,0 +1,167 @@
|
|
|
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
|
+
# A service client - single point of access to the REST API.
|
|
9
|
+
#
|
|
10
|
+
class ContentModeratorClient < MsRestAzure::AzureServiceClient
|
|
11
|
+
include MsRestAzure
|
|
12
|
+
include MsRestAzure::Serialization
|
|
13
|
+
|
|
14
|
+
# @return [String] the base URI of the service.
|
|
15
|
+
attr_reader :base_url
|
|
16
|
+
|
|
17
|
+
# @return Credentials needed for the client to connect to Azure.
|
|
18
|
+
attr_reader :credentials1
|
|
19
|
+
|
|
20
|
+
# @return [AzureRegionBaseUrl] Supported Azure regions for Content
|
|
21
|
+
# Moderator endpoints. Possible values include:
|
|
22
|
+
# 'westus.api.cognitive.microsoft.com',
|
|
23
|
+
# 'westus2.api.cognitive.microsoft.com',
|
|
24
|
+
# 'eastus.api.cognitive.microsoft.com',
|
|
25
|
+
# 'eastus2.api.cognitive.microsoft.com',
|
|
26
|
+
# 'westcentralus.api.cognitive.microsoft.com',
|
|
27
|
+
# 'southcentralus.api.cognitive.microsoft.com',
|
|
28
|
+
# 'westeurope.api.cognitive.microsoft.com',
|
|
29
|
+
# 'northeurope.api.cognitive.microsoft.com',
|
|
30
|
+
# 'southeastasia.api.cognitive.microsoft.com',
|
|
31
|
+
# 'eastasia.api.cognitive.microsoft.com',
|
|
32
|
+
# 'australiaeast.api.cognitive.microsoft.com',
|
|
33
|
+
# 'brazilsouth.api.cognitive.microsoft.com',
|
|
34
|
+
# 'contentmoderatortest.azure-api.net'
|
|
35
|
+
attr_accessor :base_url
|
|
36
|
+
|
|
37
|
+
# @return Subscription credentials which uniquely identify client
|
|
38
|
+
# subscription.
|
|
39
|
+
attr_accessor :credentials
|
|
40
|
+
|
|
41
|
+
# @return [String] Gets or sets the preferred language for the response.
|
|
42
|
+
attr_accessor :accept_language
|
|
43
|
+
|
|
44
|
+
# @return [Integer] Gets or sets the retry timeout in seconds for Long
|
|
45
|
+
# Running Operations. Default value is 30.
|
|
46
|
+
attr_accessor :long_running_operation_retry_timeout
|
|
47
|
+
|
|
48
|
+
# @return [Boolean] When set to true a unique x-ms-client-request-id value
|
|
49
|
+
# is generated and included in each request. Default is true.
|
|
50
|
+
attr_accessor :generate_client_request_id
|
|
51
|
+
|
|
52
|
+
# @return [ImageModeration] image_moderation
|
|
53
|
+
attr_reader :image_moderation
|
|
54
|
+
|
|
55
|
+
# @return [TextModeration] text_moderation
|
|
56
|
+
attr_reader :text_moderation
|
|
57
|
+
|
|
58
|
+
# @return [ListManagementImageLists] list_management_image_lists
|
|
59
|
+
attr_reader :list_management_image_lists
|
|
60
|
+
|
|
61
|
+
# @return [ListManagementTermLists] list_management_term_lists
|
|
62
|
+
attr_reader :list_management_term_lists
|
|
63
|
+
|
|
64
|
+
# @return [ListManagementImage] list_management_image
|
|
65
|
+
attr_reader :list_management_image
|
|
66
|
+
|
|
67
|
+
# @return [ListManagementTerm] list_management_term
|
|
68
|
+
attr_reader :list_management_term
|
|
69
|
+
|
|
70
|
+
# @return [Reviews] reviews
|
|
71
|
+
attr_reader :reviews
|
|
72
|
+
|
|
73
|
+
#
|
|
74
|
+
# Creates initializes a new instance of the ContentModeratorClient class.
|
|
75
|
+
# @param credentials [MsRest::ServiceClientCredentials] credentials to authorize HTTP requests made by the service client.
|
|
76
|
+
# @param options [Array] filters to be applied to the HTTP requests.
|
|
77
|
+
#
|
|
78
|
+
def initialize(credentials = nil, options = nil)
|
|
79
|
+
super(credentials, options)
|
|
80
|
+
@base_url = 'https://{baseUrl}/'
|
|
81
|
+
|
|
82
|
+
fail ArgumentError, 'invalid type of credentials input parameter' unless credentials.is_a?(MsRest::ServiceClientCredentials) unless credentials.nil?
|
|
83
|
+
@credentials = credentials
|
|
84
|
+
|
|
85
|
+
@image_moderation = ImageModeration.new(self)
|
|
86
|
+
@text_moderation = TextModeration.new(self)
|
|
87
|
+
@list_management_image_lists = ListManagementImageLists.new(self)
|
|
88
|
+
@list_management_term_lists = ListManagementTermLists.new(self)
|
|
89
|
+
@list_management_image = ListManagementImage.new(self)
|
|
90
|
+
@list_management_term = ListManagementTerm.new(self)
|
|
91
|
+
@reviews = Reviews.new(self)
|
|
92
|
+
@accept_language = 'en-US'
|
|
93
|
+
@long_running_operation_retry_timeout = 30
|
|
94
|
+
@generate_client_request_id = true
|
|
95
|
+
add_telemetry
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
#
|
|
99
|
+
# Makes a request and returns the body of the response.
|
|
100
|
+
# @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete.
|
|
101
|
+
# @param path [String] the path, relative to {base_url}.
|
|
102
|
+
# @param options [Hash{String=>String}] specifying any request options like :body.
|
|
103
|
+
# @return [Hash{String=>String}] containing the body of the response.
|
|
104
|
+
# Example:
|
|
105
|
+
#
|
|
106
|
+
# request_content = "{'location':'westus','tags':{'tag1':'val1','tag2':'val2'}}"
|
|
107
|
+
# path = "/path"
|
|
108
|
+
# options = {
|
|
109
|
+
# body: request_content,
|
|
110
|
+
# query_params: {'api-version' => '2016-02-01'}
|
|
111
|
+
# }
|
|
112
|
+
# result = @client.make_request(:put, path, options)
|
|
113
|
+
#
|
|
114
|
+
def make_request(method, path, options = {})
|
|
115
|
+
result = make_request_with_http_info(method, path, options)
|
|
116
|
+
result.body unless result.nil?
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
#
|
|
120
|
+
# Makes a request and returns the operation response.
|
|
121
|
+
# @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete.
|
|
122
|
+
# @param path [String] the path, relative to {base_url}.
|
|
123
|
+
# @param options [Hash{String=>String}] specifying any request options like :body.
|
|
124
|
+
# @return [MsRestAzure::AzureOperationResponse] Operation response containing the request, response and status.
|
|
125
|
+
#
|
|
126
|
+
def make_request_with_http_info(method, path, options = {})
|
|
127
|
+
result = make_request_async(method, path, options).value!
|
|
128
|
+
result.body = result.response.body.to_s.empty? ? nil : JSON.load(result.response.body)
|
|
129
|
+
result
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
#
|
|
133
|
+
# Makes a request asynchronously.
|
|
134
|
+
# @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete.
|
|
135
|
+
# @param path [String] the path, relative to {base_url}.
|
|
136
|
+
# @param options [Hash{String=>String}] specifying any request options like :body.
|
|
137
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
|
138
|
+
#
|
|
139
|
+
def make_request_async(method, path, options = {})
|
|
140
|
+
fail ArgumentError, 'method is nil' if method.nil?
|
|
141
|
+
fail ArgumentError, 'path is nil' if path.nil?
|
|
142
|
+
|
|
143
|
+
request_url = options[:base_url] || @base_url
|
|
144
|
+
if(!options[:headers].nil? && !options[:headers]['Content-Type'].nil?)
|
|
145
|
+
@request_headers['Content-Type'] = options[:headers]['Content-Type']
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
request_headers = @request_headers
|
|
149
|
+
request_headers.merge!({'accept-language' => @accept_language}) unless @accept_language.nil?
|
|
150
|
+
options.merge!({headers: request_headers.merge(options[:headers] || {})})
|
|
151
|
+
options.merge!({credentials: @credentials}) unless @credentials.nil?
|
|
152
|
+
|
|
153
|
+
super(request_url, method, path, options)
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
private
|
|
158
|
+
#
|
|
159
|
+
# Adds telemetry information.
|
|
160
|
+
#
|
|
161
|
+
def add_telemetry
|
|
162
|
+
sdk_information = 'azure_cognitiveservices_contentmoderator'
|
|
163
|
+
sdk_information = "#{sdk_information}/0.16.0"
|
|
164
|
+
add_user_agent_information(sdk_information)
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
end
|
|
@@ -0,0 +1,1399 @@
|
|
|
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 ImageModeration
|
|
29
|
+
include MsRestAzure
|
|
30
|
+
|
|
31
|
+
#
|
|
32
|
+
# Creates and initializes a new instance of the ImageModeration 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 list of faces found.
|
|
44
|
+
#
|
|
45
|
+
# @param cache_image [Boolean] Whether to retain the submitted image for future
|
|
46
|
+
# use; defaults to false if omitted.
|
|
47
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
|
48
|
+
# will be added to the HTTP request.
|
|
49
|
+
#
|
|
50
|
+
# @return [FoundFaces] operation results.
|
|
51
|
+
#
|
|
52
|
+
def find_faces(cache_image:nil, custom_headers:nil)
|
|
53
|
+
response = find_faces_async(cache_image:cache_image, custom_headers:custom_headers).value!
|
|
54
|
+
response.body unless response.nil?
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
#
|
|
58
|
+
# Returns the list of faces found.
|
|
59
|
+
#
|
|
60
|
+
# @param cache_image [Boolean] Whether to retain the submitted image for future
|
|
61
|
+
# use; defaults to false if omitted.
|
|
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 find_faces_with_http_info(cache_image:nil, custom_headers:nil)
|
|
68
|
+
find_faces_async(cache_image:cache_image, custom_headers:custom_headers).value!
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
#
|
|
72
|
+
# Returns the list of faces found.
|
|
73
|
+
#
|
|
74
|
+
# @param cache_image [Boolean] Whether to retain the submitted image for future
|
|
75
|
+
# use; defaults to false if omitted.
|
|
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 find_faces_async(cache_image:nil, custom_headers:nil)
|
|
82
|
+
fail ArgumentError, '@client.base_url is nil' if @client.base_url.nil?
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
request_headers = {}
|
|
86
|
+
request_headers['Content-Type'] = 'application/json; charset=utf-8'
|
|
87
|
+
|
|
88
|
+
# Set Headers
|
|
89
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
|
90
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
|
91
|
+
path_template = 'contentmoderator/moderate/v1.0/ProcessImage/FindFaces'
|
|
92
|
+
|
|
93
|
+
request_url = @base_url || @client.base_url
|
|
94
|
+
request_url = request_url.gsub('{baseUrl}', @client.base_url)
|
|
95
|
+
|
|
96
|
+
options = {
|
|
97
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
|
98
|
+
query_params: {'CacheImage' => cache_image},
|
|
99
|
+
headers: request_headers.merge(custom_headers || {}),
|
|
100
|
+
base_url: request_url
|
|
101
|
+
}
|
|
102
|
+
promise = @client.make_request_async(:post, path_template, options)
|
|
103
|
+
|
|
104
|
+
promise = promise.then do |result|
|
|
105
|
+
http_response = result.response
|
|
106
|
+
status_code = http_response.status
|
|
107
|
+
response_content = http_response.body
|
|
108
|
+
unless status_code == 200
|
|
109
|
+
error_model = JSON.load(response_content)
|
|
110
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
|
114
|
+
# Deserialize Response
|
|
115
|
+
if status_code == 200
|
|
116
|
+
begin
|
|
117
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
|
118
|
+
result_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::FoundFaces.mapper()
|
|
119
|
+
result.body = @client.deserialize(result_mapper, parsed_response)
|
|
120
|
+
rescue Exception => e
|
|
121
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
result
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
promise.execute
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
#
|
|
132
|
+
# Returns any text found in the image for the language specified. If no
|
|
133
|
+
# language is specified in input then the detection defaults to English.
|
|
134
|
+
#
|
|
135
|
+
# @param language [String] Language of the terms.
|
|
136
|
+
# @param cache_image [Boolean] Whether to retain the submitted image for future
|
|
137
|
+
# use; defaults to false if omitted.
|
|
138
|
+
# @param enhanced [Boolean] When set to True, the image goes through additional
|
|
139
|
+
# processing to come with additional candidates.
|
|
140
|
+
#
|
|
141
|
+
# image/tiff is not supported when enhanced is set to true
|
|
142
|
+
#
|
|
143
|
+
# Note: This impacts the response time.
|
|
144
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
|
145
|
+
# will be added to the HTTP request.
|
|
146
|
+
#
|
|
147
|
+
# @return [OCR] operation results.
|
|
148
|
+
#
|
|
149
|
+
def ocrmethod(language, cache_image:nil, enhanced:false, custom_headers:nil)
|
|
150
|
+
response = ocrmethod_async(language, cache_image:cache_image, enhanced:enhanced, custom_headers:custom_headers).value!
|
|
151
|
+
response.body unless response.nil?
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
#
|
|
155
|
+
# Returns any text found in the image for the language specified. If no
|
|
156
|
+
# language is specified in input then the detection defaults to English.
|
|
157
|
+
#
|
|
158
|
+
# @param language [String] Language of the terms.
|
|
159
|
+
# @param cache_image [Boolean] Whether to retain the submitted image for future
|
|
160
|
+
# use; defaults to false if omitted.
|
|
161
|
+
# @param enhanced [Boolean] When set to True, the image goes through additional
|
|
162
|
+
# processing to come with additional candidates.
|
|
163
|
+
#
|
|
164
|
+
# image/tiff is not supported when enhanced is set to true
|
|
165
|
+
#
|
|
166
|
+
# Note: This impacts the response time.
|
|
167
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
|
168
|
+
# will be added to the HTTP request.
|
|
169
|
+
#
|
|
170
|
+
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
|
171
|
+
#
|
|
172
|
+
def ocrmethod_with_http_info(language, cache_image:nil, enhanced:false, custom_headers:nil)
|
|
173
|
+
ocrmethod_async(language, cache_image:cache_image, enhanced:enhanced, custom_headers:custom_headers).value!
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
#
|
|
177
|
+
# Returns any text found in the image for the language specified. If no
|
|
178
|
+
# language is specified in input then the detection defaults to English.
|
|
179
|
+
#
|
|
180
|
+
# @param language [String] Language of the terms.
|
|
181
|
+
# @param cache_image [Boolean] Whether to retain the submitted image for future
|
|
182
|
+
# use; defaults to false if omitted.
|
|
183
|
+
# @param enhanced [Boolean] When set to True, the image goes through additional
|
|
184
|
+
# processing to come with additional candidates.
|
|
185
|
+
#
|
|
186
|
+
# image/tiff is not supported when enhanced is set to true
|
|
187
|
+
#
|
|
188
|
+
# Note: This impacts the response time.
|
|
189
|
+
# @param [Hash{String => String}] A hash of custom headers that will be added
|
|
190
|
+
# to the HTTP request.
|
|
191
|
+
#
|
|
192
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
|
193
|
+
#
|
|
194
|
+
def ocrmethod_async(language, cache_image:nil, enhanced:false, custom_headers:nil)
|
|
195
|
+
fail ArgumentError, '@client.base_url is nil' if @client.base_url.nil?
|
|
196
|
+
fail ArgumentError, 'language is nil' if language.nil?
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
request_headers = {}
|
|
200
|
+
request_headers['Content-Type'] = 'application/json; charset=utf-8'
|
|
201
|
+
|
|
202
|
+
# Set Headers
|
|
203
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
|
204
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
|
205
|
+
path_template = 'contentmoderator/moderate/v1.0/ProcessImage/OCR'
|
|
206
|
+
|
|
207
|
+
request_url = @base_url || @client.base_url
|
|
208
|
+
request_url = request_url.gsub('{baseUrl}', @client.base_url)
|
|
209
|
+
|
|
210
|
+
options = {
|
|
211
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
|
212
|
+
query_params: {'language' => language,'CacheImage' => cache_image,'enhanced' => enhanced},
|
|
213
|
+
headers: request_headers.merge(custom_headers || {}),
|
|
214
|
+
base_url: request_url
|
|
215
|
+
}
|
|
216
|
+
promise = @client.make_request_async(:post, path_template, options)
|
|
217
|
+
|
|
218
|
+
promise = promise.then do |result|
|
|
219
|
+
http_response = result.response
|
|
220
|
+
status_code = http_response.status
|
|
221
|
+
response_content = http_response.body
|
|
222
|
+
unless status_code == 200
|
|
223
|
+
error_model = JSON.load(response_content)
|
|
224
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
|
228
|
+
# Deserialize Response
|
|
229
|
+
if status_code == 200
|
|
230
|
+
begin
|
|
231
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
|
232
|
+
result_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::OCR.mapper()
|
|
233
|
+
result.body = @client.deserialize(result_mapper, parsed_response)
|
|
234
|
+
rescue Exception => e
|
|
235
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
|
236
|
+
end
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
result
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
promise.execute
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
#
|
|
246
|
+
# Returns probabilities of the image containing racy or adult content.
|
|
247
|
+
#
|
|
248
|
+
# @param cache_image [Boolean] Whether to retain the submitted image for future
|
|
249
|
+
# use; defaults to false if omitted.
|
|
250
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
|
251
|
+
# will be added to the HTTP request.
|
|
252
|
+
#
|
|
253
|
+
# @return [Evaluate] operation results.
|
|
254
|
+
#
|
|
255
|
+
def evaluate_method(cache_image:nil, custom_headers:nil)
|
|
256
|
+
response = evaluate_method_async(cache_image:cache_image, custom_headers:custom_headers).value!
|
|
257
|
+
response.body unless response.nil?
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
#
|
|
261
|
+
# Returns probabilities of the image containing racy or adult content.
|
|
262
|
+
#
|
|
263
|
+
# @param cache_image [Boolean] Whether to retain the submitted image for future
|
|
264
|
+
# use; defaults to false if omitted.
|
|
265
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
|
266
|
+
# will be added to the HTTP request.
|
|
267
|
+
#
|
|
268
|
+
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
|
269
|
+
#
|
|
270
|
+
def evaluate_method_with_http_info(cache_image:nil, custom_headers:nil)
|
|
271
|
+
evaluate_method_async(cache_image:cache_image, custom_headers:custom_headers).value!
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
#
|
|
275
|
+
# Returns probabilities of the image containing racy or adult content.
|
|
276
|
+
#
|
|
277
|
+
# @param cache_image [Boolean] Whether to retain the submitted image for future
|
|
278
|
+
# use; defaults to false if omitted.
|
|
279
|
+
# @param [Hash{String => String}] A hash of custom headers that will be added
|
|
280
|
+
# to the HTTP request.
|
|
281
|
+
#
|
|
282
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
|
283
|
+
#
|
|
284
|
+
def evaluate_method_async(cache_image:nil, custom_headers:nil)
|
|
285
|
+
fail ArgumentError, '@client.base_url is nil' if @client.base_url.nil?
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
request_headers = {}
|
|
289
|
+
request_headers['Content-Type'] = 'application/json; charset=utf-8'
|
|
290
|
+
|
|
291
|
+
# Set Headers
|
|
292
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
|
293
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
|
294
|
+
path_template = 'contentmoderator/moderate/v1.0/ProcessImage/Evaluate'
|
|
295
|
+
|
|
296
|
+
request_url = @base_url || @client.base_url
|
|
297
|
+
request_url = request_url.gsub('{baseUrl}', @client.base_url)
|
|
298
|
+
|
|
299
|
+
options = {
|
|
300
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
|
301
|
+
query_params: {'CacheImage' => cache_image},
|
|
302
|
+
headers: request_headers.merge(custom_headers || {}),
|
|
303
|
+
base_url: request_url
|
|
304
|
+
}
|
|
305
|
+
promise = @client.make_request_async(:post, path_template, options)
|
|
306
|
+
|
|
307
|
+
promise = promise.then do |result|
|
|
308
|
+
http_response = result.response
|
|
309
|
+
status_code = http_response.status
|
|
310
|
+
response_content = http_response.body
|
|
311
|
+
unless status_code == 200
|
|
312
|
+
error_model = JSON.load(response_content)
|
|
313
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
|
314
|
+
end
|
|
315
|
+
|
|
316
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
|
317
|
+
# Deserialize Response
|
|
318
|
+
if status_code == 200
|
|
319
|
+
begin
|
|
320
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
|
321
|
+
result_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::Evaluate.mapper()
|
|
322
|
+
result.body = @client.deserialize(result_mapper, parsed_response)
|
|
323
|
+
rescue Exception => e
|
|
324
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
|
325
|
+
end
|
|
326
|
+
end
|
|
327
|
+
|
|
328
|
+
result
|
|
329
|
+
end
|
|
330
|
+
|
|
331
|
+
promise.execute
|
|
332
|
+
end
|
|
333
|
+
|
|
334
|
+
#
|
|
335
|
+
# Fuzzily match an image against one of your custom Image Lists. You can create
|
|
336
|
+
# and manage your custom image lists using <a
|
|
337
|
+
# href="/docs/services/578ff44d2703741568569ab9/operations/578ff7b12703741568569abe">this</a>
|
|
338
|
+
# API.
|
|
339
|
+
#
|
|
340
|
+
# Returns ID and tags of matching image.<br/>
|
|
341
|
+
# <br/>
|
|
342
|
+
# Note: Refresh Index must be run on the corresponding Image List before
|
|
343
|
+
# additions and removals are reflected in the response.
|
|
344
|
+
#
|
|
345
|
+
# @param list_id [String] The list Id.
|
|
346
|
+
# @param cache_image [Boolean] Whether to retain the submitted image for future
|
|
347
|
+
# use; defaults to false if omitted.
|
|
348
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
|
349
|
+
# will be added to the HTTP request.
|
|
350
|
+
#
|
|
351
|
+
# @return [MatchResponse] operation results.
|
|
352
|
+
#
|
|
353
|
+
def match_method(list_id:nil, cache_image:nil, custom_headers:nil)
|
|
354
|
+
response = match_method_async(list_id:list_id, cache_image:cache_image, custom_headers:custom_headers).value!
|
|
355
|
+
response.body unless response.nil?
|
|
356
|
+
end
|
|
357
|
+
|
|
358
|
+
#
|
|
359
|
+
# Fuzzily match an image against one of your custom Image Lists. You can create
|
|
360
|
+
# and manage your custom image lists using <a
|
|
361
|
+
# href="/docs/services/578ff44d2703741568569ab9/operations/578ff7b12703741568569abe">this</a>
|
|
362
|
+
# API.
|
|
363
|
+
#
|
|
364
|
+
# Returns ID and tags of matching image.<br/>
|
|
365
|
+
# <br/>
|
|
366
|
+
# Note: Refresh Index must be run on the corresponding Image List before
|
|
367
|
+
# additions and removals are reflected in the response.
|
|
368
|
+
#
|
|
369
|
+
# @param list_id [String] The list Id.
|
|
370
|
+
# @param cache_image [Boolean] Whether to retain the submitted image for future
|
|
371
|
+
# use; defaults to false if omitted.
|
|
372
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
|
373
|
+
# will be added to the HTTP request.
|
|
374
|
+
#
|
|
375
|
+
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
|
376
|
+
#
|
|
377
|
+
def match_method_with_http_info(list_id:nil, cache_image:nil, custom_headers:nil)
|
|
378
|
+
match_method_async(list_id:list_id, cache_image:cache_image, custom_headers:custom_headers).value!
|
|
379
|
+
end
|
|
380
|
+
|
|
381
|
+
#
|
|
382
|
+
# Fuzzily match an image against one of your custom Image Lists. You can create
|
|
383
|
+
# and manage your custom image lists using <a
|
|
384
|
+
# href="/docs/services/578ff44d2703741568569ab9/operations/578ff7b12703741568569abe">this</a>
|
|
385
|
+
# API.
|
|
386
|
+
#
|
|
387
|
+
# Returns ID and tags of matching image.<br/>
|
|
388
|
+
# <br/>
|
|
389
|
+
# Note: Refresh Index must be run on the corresponding Image List before
|
|
390
|
+
# additions and removals are reflected in the response.
|
|
391
|
+
#
|
|
392
|
+
# @param list_id [String] The list Id.
|
|
393
|
+
# @param cache_image [Boolean] Whether to retain the submitted image for future
|
|
394
|
+
# use; defaults to false if omitted.
|
|
395
|
+
# @param [Hash{String => String}] A hash of custom headers that will be added
|
|
396
|
+
# to the HTTP request.
|
|
397
|
+
#
|
|
398
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
|
399
|
+
#
|
|
400
|
+
def match_method_async(list_id:nil, cache_image:nil, custom_headers:nil)
|
|
401
|
+
fail ArgumentError, '@client.base_url is nil' if @client.base_url.nil?
|
|
402
|
+
|
|
403
|
+
|
|
404
|
+
request_headers = {}
|
|
405
|
+
request_headers['Content-Type'] = 'application/json; charset=utf-8'
|
|
406
|
+
|
|
407
|
+
# Set Headers
|
|
408
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
|
409
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
|
410
|
+
path_template = 'contentmoderator/moderate/v1.0/ProcessImage/Match'
|
|
411
|
+
|
|
412
|
+
request_url = @base_url || @client.base_url
|
|
413
|
+
request_url = request_url.gsub('{baseUrl}', @client.base_url)
|
|
414
|
+
|
|
415
|
+
options = {
|
|
416
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
|
417
|
+
query_params: {'listId' => list_id,'CacheImage' => cache_image},
|
|
418
|
+
headers: request_headers.merge(custom_headers || {}),
|
|
419
|
+
base_url: request_url
|
|
420
|
+
}
|
|
421
|
+
promise = @client.make_request_async(:post, path_template, options)
|
|
422
|
+
|
|
423
|
+
promise = promise.then do |result|
|
|
424
|
+
http_response = result.response
|
|
425
|
+
status_code = http_response.status
|
|
426
|
+
response_content = http_response.body
|
|
427
|
+
unless status_code == 200
|
|
428
|
+
error_model = JSON.load(response_content)
|
|
429
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
|
430
|
+
end
|
|
431
|
+
|
|
432
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
|
433
|
+
# Deserialize Response
|
|
434
|
+
if status_code == 200
|
|
435
|
+
begin
|
|
436
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
|
437
|
+
result_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::MatchResponse.mapper()
|
|
438
|
+
result.body = @client.deserialize(result_mapper, parsed_response)
|
|
439
|
+
rescue Exception => e
|
|
440
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
|
441
|
+
end
|
|
442
|
+
end
|
|
443
|
+
|
|
444
|
+
result
|
|
445
|
+
end
|
|
446
|
+
|
|
447
|
+
promise.execute
|
|
448
|
+
end
|
|
449
|
+
|
|
450
|
+
#
|
|
451
|
+
# Returns the list of faces found.
|
|
452
|
+
#
|
|
453
|
+
# @param image_stream The image file.
|
|
454
|
+
# @param cache_image [Boolean] Whether to retain the submitted image for future
|
|
455
|
+
# use; defaults to false if omitted.
|
|
456
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
|
457
|
+
# will be added to the HTTP request.
|
|
458
|
+
#
|
|
459
|
+
# @return [FoundFaces] operation results.
|
|
460
|
+
#
|
|
461
|
+
def find_faces_file_input(image_stream, cache_image:nil, custom_headers:nil)
|
|
462
|
+
response = find_faces_file_input_async(image_stream, cache_image:cache_image, custom_headers:custom_headers).value!
|
|
463
|
+
response.body unless response.nil?
|
|
464
|
+
end
|
|
465
|
+
|
|
466
|
+
#
|
|
467
|
+
# Returns the list of faces found.
|
|
468
|
+
#
|
|
469
|
+
# @param image_stream The image file.
|
|
470
|
+
# @param cache_image [Boolean] Whether to retain the submitted image for future
|
|
471
|
+
# use; defaults to false if omitted.
|
|
472
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
|
473
|
+
# will be added to the HTTP request.
|
|
474
|
+
#
|
|
475
|
+
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
|
476
|
+
#
|
|
477
|
+
def find_faces_file_input_with_http_info(image_stream, cache_image:nil, custom_headers:nil)
|
|
478
|
+
find_faces_file_input_async(image_stream, cache_image:cache_image, custom_headers:custom_headers).value!
|
|
479
|
+
end
|
|
480
|
+
|
|
481
|
+
#
|
|
482
|
+
# Returns the list of faces found.
|
|
483
|
+
#
|
|
484
|
+
# @param image_stream The image file.
|
|
485
|
+
# @param cache_image [Boolean] Whether to retain the submitted image for future
|
|
486
|
+
# use; defaults to false if omitted.
|
|
487
|
+
# @param [Hash{String => String}] A hash of custom headers that will be added
|
|
488
|
+
# to the HTTP request.
|
|
489
|
+
#
|
|
490
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
|
491
|
+
#
|
|
492
|
+
def find_faces_file_input_async(image_stream, cache_image:nil, custom_headers:nil)
|
|
493
|
+
fail ArgumentError, '@client.base_url is nil' if @client.base_url.nil?
|
|
494
|
+
fail ArgumentError, 'image_stream is nil' if image_stream.nil?
|
|
495
|
+
|
|
496
|
+
|
|
497
|
+
request_headers = {}
|
|
498
|
+
request_headers['Content-Type'] = 'image/gif'
|
|
499
|
+
|
|
500
|
+
# Set Headers
|
|
501
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
|
502
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
|
503
|
+
|
|
504
|
+
# Serialize Request
|
|
505
|
+
request_mapper = {
|
|
506
|
+
client_side_validation: true,
|
|
507
|
+
required: true,
|
|
508
|
+
serialized_name: 'ImageStream',
|
|
509
|
+
type: {
|
|
510
|
+
name: 'Stream'
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
request_content = @client.serialize(request_mapper, image_stream)
|
|
514
|
+
|
|
515
|
+
path_template = 'contentmoderator/moderate/v1.0/ProcessImage/FindFaces'
|
|
516
|
+
|
|
517
|
+
request_url = @base_url || @client.base_url
|
|
518
|
+
request_url = request_url.gsub('{baseUrl}', @client.base_url)
|
|
519
|
+
|
|
520
|
+
options = {
|
|
521
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
|
522
|
+
query_params: {'CacheImage' => cache_image},
|
|
523
|
+
body: request_content,
|
|
524
|
+
headers: request_headers.merge(custom_headers || {}),
|
|
525
|
+
base_url: request_url
|
|
526
|
+
}
|
|
527
|
+
promise = @client.make_request_async(:post, path_template, options)
|
|
528
|
+
|
|
529
|
+
promise = promise.then do |result|
|
|
530
|
+
http_response = result.response
|
|
531
|
+
status_code = http_response.status
|
|
532
|
+
response_content = http_response.body
|
|
533
|
+
unless status_code == 200
|
|
534
|
+
error_model = JSON.load(response_content)
|
|
535
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
|
536
|
+
end
|
|
537
|
+
|
|
538
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
|
539
|
+
# Deserialize Response
|
|
540
|
+
if status_code == 200
|
|
541
|
+
begin
|
|
542
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
|
543
|
+
result_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::FoundFaces.mapper()
|
|
544
|
+
result.body = @client.deserialize(result_mapper, parsed_response)
|
|
545
|
+
rescue Exception => e
|
|
546
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
|
547
|
+
end
|
|
548
|
+
end
|
|
549
|
+
|
|
550
|
+
result
|
|
551
|
+
end
|
|
552
|
+
|
|
553
|
+
promise.execute
|
|
554
|
+
end
|
|
555
|
+
|
|
556
|
+
#
|
|
557
|
+
# Returns the list of faces found.
|
|
558
|
+
#
|
|
559
|
+
# @param content_type [String] The content type.
|
|
560
|
+
# @param image_url [ImageUrl] The image url.
|
|
561
|
+
# @param cache_image [Boolean] Whether to retain the submitted image for future
|
|
562
|
+
# use; defaults to false if omitted.
|
|
563
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
|
564
|
+
# will be added to the HTTP request.
|
|
565
|
+
#
|
|
566
|
+
# @return [FoundFaces] operation results.
|
|
567
|
+
#
|
|
568
|
+
def find_faces_url_input(content_type, image_url, cache_image:nil, custom_headers:nil)
|
|
569
|
+
response = find_faces_url_input_async(content_type, image_url, cache_image:cache_image, custom_headers:custom_headers).value!
|
|
570
|
+
response.body unless response.nil?
|
|
571
|
+
end
|
|
572
|
+
|
|
573
|
+
#
|
|
574
|
+
# Returns the list of faces found.
|
|
575
|
+
#
|
|
576
|
+
# @param content_type [String] The content type.
|
|
577
|
+
# @param image_url [ImageUrl] The image url.
|
|
578
|
+
# @param cache_image [Boolean] Whether to retain the submitted image for future
|
|
579
|
+
# use; defaults to false if omitted.
|
|
580
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
|
581
|
+
# will be added to the HTTP request.
|
|
582
|
+
#
|
|
583
|
+
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
|
584
|
+
#
|
|
585
|
+
def find_faces_url_input_with_http_info(content_type, image_url, cache_image:nil, custom_headers:nil)
|
|
586
|
+
find_faces_url_input_async(content_type, image_url, cache_image:cache_image, custom_headers:custom_headers).value!
|
|
587
|
+
end
|
|
588
|
+
|
|
589
|
+
#
|
|
590
|
+
# Returns the list of faces found.
|
|
591
|
+
#
|
|
592
|
+
# @param content_type [String] The content type.
|
|
593
|
+
# @param image_url [ImageUrl] The image url.
|
|
594
|
+
# @param cache_image [Boolean] Whether to retain the submitted image for future
|
|
595
|
+
# use; defaults to false if omitted.
|
|
596
|
+
# @param [Hash{String => String}] A hash of custom headers that will be added
|
|
597
|
+
# to the HTTP request.
|
|
598
|
+
#
|
|
599
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
|
600
|
+
#
|
|
601
|
+
def find_faces_url_input_async(content_type, image_url, cache_image:nil, custom_headers:nil)
|
|
602
|
+
fail ArgumentError, '@client.base_url is nil' if @client.base_url.nil?
|
|
603
|
+
fail ArgumentError, 'content_type is nil' if content_type.nil?
|
|
604
|
+
fail ArgumentError, 'image_url is nil' if image_url.nil?
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
request_headers = {}
|
|
608
|
+
request_headers['Content-Type'] = 'application/json; charset=utf-8'
|
|
609
|
+
|
|
610
|
+
# Set Headers
|
|
611
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
|
612
|
+
request_headers['Content-Type'] = content_type unless content_type.nil?
|
|
613
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
|
614
|
+
|
|
615
|
+
# Serialize Request
|
|
616
|
+
request_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::ImageUrl.mapper()
|
|
617
|
+
request_content = @client.serialize(request_mapper, image_url)
|
|
618
|
+
request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
|
|
619
|
+
|
|
620
|
+
path_template = 'contentmoderator/moderate/v1.0/ProcessImage/FindFaces'
|
|
621
|
+
|
|
622
|
+
request_url = @base_url || @client.base_url
|
|
623
|
+
request_url = request_url.gsub('{baseUrl}', @client.base_url)
|
|
624
|
+
|
|
625
|
+
options = {
|
|
626
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
|
627
|
+
query_params: {'CacheImage' => cache_image},
|
|
628
|
+
body: request_content,
|
|
629
|
+
headers: request_headers.merge(custom_headers || {}),
|
|
630
|
+
base_url: request_url
|
|
631
|
+
}
|
|
632
|
+
promise = @client.make_request_async(:post, path_template, options)
|
|
633
|
+
|
|
634
|
+
promise = promise.then do |result|
|
|
635
|
+
http_response = result.response
|
|
636
|
+
status_code = http_response.status
|
|
637
|
+
response_content = http_response.body
|
|
638
|
+
unless status_code == 200
|
|
639
|
+
error_model = JSON.load(response_content)
|
|
640
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
|
641
|
+
end
|
|
642
|
+
|
|
643
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
|
644
|
+
# Deserialize Response
|
|
645
|
+
if status_code == 200
|
|
646
|
+
begin
|
|
647
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
|
648
|
+
result_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::FoundFaces.mapper()
|
|
649
|
+
result.body = @client.deserialize(result_mapper, parsed_response)
|
|
650
|
+
rescue Exception => e
|
|
651
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
|
652
|
+
end
|
|
653
|
+
end
|
|
654
|
+
|
|
655
|
+
result
|
|
656
|
+
end
|
|
657
|
+
|
|
658
|
+
promise.execute
|
|
659
|
+
end
|
|
660
|
+
|
|
661
|
+
#
|
|
662
|
+
# Returns any text found in the image for the language specified. If no
|
|
663
|
+
# language is specified in input then the detection defaults to English.
|
|
664
|
+
#
|
|
665
|
+
# @param language [String] Language of the terms.
|
|
666
|
+
# @param content_type [String] The content type.
|
|
667
|
+
# @param image_url [ImageUrl] The image url.
|
|
668
|
+
# @param cache_image [Boolean] Whether to retain the submitted image for future
|
|
669
|
+
# use; defaults to false if omitted.
|
|
670
|
+
# @param enhanced [Boolean] When set to True, the image goes through additional
|
|
671
|
+
# processing to come with additional candidates.
|
|
672
|
+
#
|
|
673
|
+
# image/tiff is not supported when enhanced is set to true
|
|
674
|
+
#
|
|
675
|
+
# Note: This impacts the response time.
|
|
676
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
|
677
|
+
# will be added to the HTTP request.
|
|
678
|
+
#
|
|
679
|
+
# @return [OCR] operation results.
|
|
680
|
+
#
|
|
681
|
+
def ocrurl_input(language, content_type, image_url, cache_image:nil, enhanced:false, custom_headers:nil)
|
|
682
|
+
response = ocrurl_input_async(language, content_type, image_url, cache_image:cache_image, enhanced:enhanced, custom_headers:custom_headers).value!
|
|
683
|
+
response.body unless response.nil?
|
|
684
|
+
end
|
|
685
|
+
|
|
686
|
+
#
|
|
687
|
+
# Returns any text found in the image for the language specified. If no
|
|
688
|
+
# language is specified in input then the detection defaults to English.
|
|
689
|
+
#
|
|
690
|
+
# @param language [String] Language of the terms.
|
|
691
|
+
# @param content_type [String] The content type.
|
|
692
|
+
# @param image_url [ImageUrl] The image url.
|
|
693
|
+
# @param cache_image [Boolean] Whether to retain the submitted image for future
|
|
694
|
+
# use; defaults to false if omitted.
|
|
695
|
+
# @param enhanced [Boolean] When set to True, the image goes through additional
|
|
696
|
+
# processing to come with additional candidates.
|
|
697
|
+
#
|
|
698
|
+
# image/tiff is not supported when enhanced is set to true
|
|
699
|
+
#
|
|
700
|
+
# Note: This impacts the response time.
|
|
701
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
|
702
|
+
# will be added to the HTTP request.
|
|
703
|
+
#
|
|
704
|
+
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
|
705
|
+
#
|
|
706
|
+
def ocrurl_input_with_http_info(language, content_type, image_url, cache_image:nil, enhanced:false, custom_headers:nil)
|
|
707
|
+
ocrurl_input_async(language, content_type, image_url, cache_image:cache_image, enhanced:enhanced, custom_headers:custom_headers).value!
|
|
708
|
+
end
|
|
709
|
+
|
|
710
|
+
#
|
|
711
|
+
# Returns any text found in the image for the language specified. If no
|
|
712
|
+
# language is specified in input then the detection defaults to English.
|
|
713
|
+
#
|
|
714
|
+
# @param language [String] Language of the terms.
|
|
715
|
+
# @param content_type [String] The content type.
|
|
716
|
+
# @param image_url [ImageUrl] The image url.
|
|
717
|
+
# @param cache_image [Boolean] Whether to retain the submitted image for future
|
|
718
|
+
# use; defaults to false if omitted.
|
|
719
|
+
# @param enhanced [Boolean] When set to True, the image goes through additional
|
|
720
|
+
# processing to come with additional candidates.
|
|
721
|
+
#
|
|
722
|
+
# image/tiff is not supported when enhanced is set to true
|
|
723
|
+
#
|
|
724
|
+
# Note: This impacts the response time.
|
|
725
|
+
# @param [Hash{String => String}] A hash of custom headers that will be added
|
|
726
|
+
# to the HTTP request.
|
|
727
|
+
#
|
|
728
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
|
729
|
+
#
|
|
730
|
+
def ocrurl_input_async(language, content_type, image_url, cache_image:nil, enhanced:false, custom_headers:nil)
|
|
731
|
+
fail ArgumentError, '@client.base_url is nil' if @client.base_url.nil?
|
|
732
|
+
fail ArgumentError, 'language is nil' if language.nil?
|
|
733
|
+
fail ArgumentError, 'content_type is nil' if content_type.nil?
|
|
734
|
+
fail ArgumentError, 'image_url is nil' if image_url.nil?
|
|
735
|
+
|
|
736
|
+
|
|
737
|
+
request_headers = {}
|
|
738
|
+
request_headers['Content-Type'] = 'application/json; charset=utf-8'
|
|
739
|
+
|
|
740
|
+
# Set Headers
|
|
741
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
|
742
|
+
request_headers['Content-Type'] = content_type unless content_type.nil?
|
|
743
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
|
744
|
+
|
|
745
|
+
# Serialize Request
|
|
746
|
+
request_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::ImageUrl.mapper()
|
|
747
|
+
request_content = @client.serialize(request_mapper, image_url)
|
|
748
|
+
request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
|
|
749
|
+
|
|
750
|
+
path_template = 'contentmoderator/moderate/v1.0/ProcessImage/OCR'
|
|
751
|
+
|
|
752
|
+
request_url = @base_url || @client.base_url
|
|
753
|
+
request_url = request_url.gsub('{baseUrl}', @client.base_url)
|
|
754
|
+
|
|
755
|
+
options = {
|
|
756
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
|
757
|
+
query_params: {'language' => language,'CacheImage' => cache_image,'enhanced' => enhanced},
|
|
758
|
+
body: request_content,
|
|
759
|
+
headers: request_headers.merge(custom_headers || {}),
|
|
760
|
+
base_url: request_url
|
|
761
|
+
}
|
|
762
|
+
promise = @client.make_request_async(:post, path_template, options)
|
|
763
|
+
|
|
764
|
+
promise = promise.then do |result|
|
|
765
|
+
http_response = result.response
|
|
766
|
+
status_code = http_response.status
|
|
767
|
+
response_content = http_response.body
|
|
768
|
+
unless status_code == 200
|
|
769
|
+
error_model = JSON.load(response_content)
|
|
770
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
|
771
|
+
end
|
|
772
|
+
|
|
773
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
|
774
|
+
# Deserialize Response
|
|
775
|
+
if status_code == 200
|
|
776
|
+
begin
|
|
777
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
|
778
|
+
result_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::OCR.mapper()
|
|
779
|
+
result.body = @client.deserialize(result_mapper, parsed_response)
|
|
780
|
+
rescue Exception => e
|
|
781
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
|
782
|
+
end
|
|
783
|
+
end
|
|
784
|
+
|
|
785
|
+
result
|
|
786
|
+
end
|
|
787
|
+
|
|
788
|
+
promise.execute
|
|
789
|
+
end
|
|
790
|
+
|
|
791
|
+
#
|
|
792
|
+
# Returns any text found in the image for the language specified. If no
|
|
793
|
+
# language is specified in input then the detection defaults to English.
|
|
794
|
+
#
|
|
795
|
+
# @param language [String] Language of the terms.
|
|
796
|
+
# @param image_stream The image file.
|
|
797
|
+
# @param cache_image [Boolean] Whether to retain the submitted image for future
|
|
798
|
+
# use; defaults to false if omitted.
|
|
799
|
+
# @param enhanced [Boolean] When set to True, the image goes through additional
|
|
800
|
+
# processing to come with additional candidates.
|
|
801
|
+
#
|
|
802
|
+
# image/tiff is not supported when enhanced is set to true
|
|
803
|
+
#
|
|
804
|
+
# Note: This impacts the response time.
|
|
805
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
|
806
|
+
# will be added to the HTTP request.
|
|
807
|
+
#
|
|
808
|
+
# @return [OCR] operation results.
|
|
809
|
+
#
|
|
810
|
+
def ocrfile_input(language, image_stream, cache_image:nil, enhanced:false, custom_headers:nil)
|
|
811
|
+
response = ocrfile_input_async(language, image_stream, cache_image:cache_image, enhanced:enhanced, custom_headers:custom_headers).value!
|
|
812
|
+
response.body unless response.nil?
|
|
813
|
+
end
|
|
814
|
+
|
|
815
|
+
#
|
|
816
|
+
# Returns any text found in the image for the language specified. If no
|
|
817
|
+
# language is specified in input then the detection defaults to English.
|
|
818
|
+
#
|
|
819
|
+
# @param language [String] Language of the terms.
|
|
820
|
+
# @param image_stream The image file.
|
|
821
|
+
# @param cache_image [Boolean] Whether to retain the submitted image for future
|
|
822
|
+
# use; defaults to false if omitted.
|
|
823
|
+
# @param enhanced [Boolean] When set to True, the image goes through additional
|
|
824
|
+
# processing to come with additional candidates.
|
|
825
|
+
#
|
|
826
|
+
# image/tiff is not supported when enhanced is set to true
|
|
827
|
+
#
|
|
828
|
+
# Note: This impacts the response time.
|
|
829
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
|
830
|
+
# will be added to the HTTP request.
|
|
831
|
+
#
|
|
832
|
+
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
|
833
|
+
#
|
|
834
|
+
def ocrfile_input_with_http_info(language, image_stream, cache_image:nil, enhanced:false, custom_headers:nil)
|
|
835
|
+
ocrfile_input_async(language, image_stream, cache_image:cache_image, enhanced:enhanced, custom_headers:custom_headers).value!
|
|
836
|
+
end
|
|
837
|
+
|
|
838
|
+
#
|
|
839
|
+
# Returns any text found in the image for the language specified. If no
|
|
840
|
+
# language is specified in input then the detection defaults to English.
|
|
841
|
+
#
|
|
842
|
+
# @param language [String] Language of the terms.
|
|
843
|
+
# @param image_stream The image file.
|
|
844
|
+
# @param cache_image [Boolean] Whether to retain the submitted image for future
|
|
845
|
+
# use; defaults to false if omitted.
|
|
846
|
+
# @param enhanced [Boolean] When set to True, the image goes through additional
|
|
847
|
+
# processing to come with additional candidates.
|
|
848
|
+
#
|
|
849
|
+
# image/tiff is not supported when enhanced is set to true
|
|
850
|
+
#
|
|
851
|
+
# Note: This impacts the response time.
|
|
852
|
+
# @param [Hash{String => String}] A hash of custom headers that will be added
|
|
853
|
+
# to the HTTP request.
|
|
854
|
+
#
|
|
855
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
|
856
|
+
#
|
|
857
|
+
def ocrfile_input_async(language, image_stream, cache_image:nil, enhanced:false, custom_headers:nil)
|
|
858
|
+
fail ArgumentError, '@client.base_url is nil' if @client.base_url.nil?
|
|
859
|
+
fail ArgumentError, 'language is nil' if language.nil?
|
|
860
|
+
fail ArgumentError, 'image_stream is nil' if image_stream.nil?
|
|
861
|
+
|
|
862
|
+
|
|
863
|
+
request_headers = {}
|
|
864
|
+
request_headers['Content-Type'] = 'image/gif'
|
|
865
|
+
|
|
866
|
+
# Set Headers
|
|
867
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
|
868
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
|
869
|
+
|
|
870
|
+
# Serialize Request
|
|
871
|
+
request_mapper = {
|
|
872
|
+
client_side_validation: true,
|
|
873
|
+
required: true,
|
|
874
|
+
serialized_name: 'ImageStream',
|
|
875
|
+
type: {
|
|
876
|
+
name: 'Stream'
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
request_content = @client.serialize(request_mapper, image_stream)
|
|
880
|
+
|
|
881
|
+
path_template = 'contentmoderator/moderate/v1.0/ProcessImage/OCR'
|
|
882
|
+
|
|
883
|
+
request_url = @base_url || @client.base_url
|
|
884
|
+
request_url = request_url.gsub('{baseUrl}', @client.base_url)
|
|
885
|
+
|
|
886
|
+
options = {
|
|
887
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
|
888
|
+
query_params: {'language' => language,'CacheImage' => cache_image,'enhanced' => enhanced},
|
|
889
|
+
body: request_content,
|
|
890
|
+
headers: request_headers.merge(custom_headers || {}),
|
|
891
|
+
base_url: request_url
|
|
892
|
+
}
|
|
893
|
+
promise = @client.make_request_async(:post, path_template, options)
|
|
894
|
+
|
|
895
|
+
promise = promise.then do |result|
|
|
896
|
+
http_response = result.response
|
|
897
|
+
status_code = http_response.status
|
|
898
|
+
response_content = http_response.body
|
|
899
|
+
unless status_code == 200
|
|
900
|
+
error_model = JSON.load(response_content)
|
|
901
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
|
902
|
+
end
|
|
903
|
+
|
|
904
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
|
905
|
+
# Deserialize Response
|
|
906
|
+
if status_code == 200
|
|
907
|
+
begin
|
|
908
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
|
909
|
+
result_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::OCR.mapper()
|
|
910
|
+
result.body = @client.deserialize(result_mapper, parsed_response)
|
|
911
|
+
rescue Exception => e
|
|
912
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
|
913
|
+
end
|
|
914
|
+
end
|
|
915
|
+
|
|
916
|
+
result
|
|
917
|
+
end
|
|
918
|
+
|
|
919
|
+
promise.execute
|
|
920
|
+
end
|
|
921
|
+
|
|
922
|
+
#
|
|
923
|
+
# Returns probabilities of the image containing racy or adult content.
|
|
924
|
+
#
|
|
925
|
+
# @param image_stream The image file.
|
|
926
|
+
# @param cache_image [Boolean] Whether to retain the submitted image for future
|
|
927
|
+
# use; defaults to false if omitted.
|
|
928
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
|
929
|
+
# will be added to the HTTP request.
|
|
930
|
+
#
|
|
931
|
+
# @return [Evaluate] operation results.
|
|
932
|
+
#
|
|
933
|
+
def evaluate_file_input(image_stream, cache_image:nil, custom_headers:nil)
|
|
934
|
+
response = evaluate_file_input_async(image_stream, cache_image:cache_image, custom_headers:custom_headers).value!
|
|
935
|
+
response.body unless response.nil?
|
|
936
|
+
end
|
|
937
|
+
|
|
938
|
+
#
|
|
939
|
+
# Returns probabilities of the image containing racy or adult content.
|
|
940
|
+
#
|
|
941
|
+
# @param image_stream The image file.
|
|
942
|
+
# @param cache_image [Boolean] Whether to retain the submitted image for future
|
|
943
|
+
# use; defaults to false if omitted.
|
|
944
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
|
945
|
+
# will be added to the HTTP request.
|
|
946
|
+
#
|
|
947
|
+
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
|
948
|
+
#
|
|
949
|
+
def evaluate_file_input_with_http_info(image_stream, cache_image:nil, custom_headers:nil)
|
|
950
|
+
evaluate_file_input_async(image_stream, cache_image:cache_image, custom_headers:custom_headers).value!
|
|
951
|
+
end
|
|
952
|
+
|
|
953
|
+
#
|
|
954
|
+
# Returns probabilities of the image containing racy or adult content.
|
|
955
|
+
#
|
|
956
|
+
# @param image_stream The image file.
|
|
957
|
+
# @param cache_image [Boolean] Whether to retain the submitted image for future
|
|
958
|
+
# use; defaults to false if omitted.
|
|
959
|
+
# @param [Hash{String => String}] A hash of custom headers that will be added
|
|
960
|
+
# to the HTTP request.
|
|
961
|
+
#
|
|
962
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
|
963
|
+
#
|
|
964
|
+
def evaluate_file_input_async(image_stream, cache_image:nil, custom_headers:nil)
|
|
965
|
+
fail ArgumentError, '@client.base_url is nil' if @client.base_url.nil?
|
|
966
|
+
fail ArgumentError, 'image_stream is nil' if image_stream.nil?
|
|
967
|
+
|
|
968
|
+
|
|
969
|
+
request_headers = {}
|
|
970
|
+
request_headers['Content-Type'] = 'image/gif'
|
|
971
|
+
|
|
972
|
+
# Set Headers
|
|
973
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
|
974
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
|
975
|
+
|
|
976
|
+
# Serialize Request
|
|
977
|
+
request_mapper = {
|
|
978
|
+
client_side_validation: true,
|
|
979
|
+
required: true,
|
|
980
|
+
serialized_name: 'ImageStream',
|
|
981
|
+
type: {
|
|
982
|
+
name: 'Stream'
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
request_content = @client.serialize(request_mapper, image_stream)
|
|
986
|
+
|
|
987
|
+
path_template = 'contentmoderator/moderate/v1.0/ProcessImage/Evaluate'
|
|
988
|
+
|
|
989
|
+
request_url = @base_url || @client.base_url
|
|
990
|
+
request_url = request_url.gsub('{baseUrl}', @client.base_url)
|
|
991
|
+
|
|
992
|
+
options = {
|
|
993
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
|
994
|
+
query_params: {'CacheImage' => cache_image},
|
|
995
|
+
body: request_content,
|
|
996
|
+
headers: request_headers.merge(custom_headers || {}),
|
|
997
|
+
base_url: request_url
|
|
998
|
+
}
|
|
999
|
+
promise = @client.make_request_async(:post, path_template, options)
|
|
1000
|
+
|
|
1001
|
+
promise = promise.then do |result|
|
|
1002
|
+
http_response = result.response
|
|
1003
|
+
status_code = http_response.status
|
|
1004
|
+
response_content = http_response.body
|
|
1005
|
+
unless status_code == 200
|
|
1006
|
+
error_model = JSON.load(response_content)
|
|
1007
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
|
1008
|
+
end
|
|
1009
|
+
|
|
1010
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
|
1011
|
+
# Deserialize Response
|
|
1012
|
+
if status_code == 200
|
|
1013
|
+
begin
|
|
1014
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
|
1015
|
+
result_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::Evaluate.mapper()
|
|
1016
|
+
result.body = @client.deserialize(result_mapper, parsed_response)
|
|
1017
|
+
rescue Exception => e
|
|
1018
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
|
1019
|
+
end
|
|
1020
|
+
end
|
|
1021
|
+
|
|
1022
|
+
result
|
|
1023
|
+
end
|
|
1024
|
+
|
|
1025
|
+
promise.execute
|
|
1026
|
+
end
|
|
1027
|
+
|
|
1028
|
+
#
|
|
1029
|
+
# Returns probabilities of the image containing racy or adult content.
|
|
1030
|
+
#
|
|
1031
|
+
# @param content_type [String] The content type.
|
|
1032
|
+
# @param image_url [ImageUrl] The image url.
|
|
1033
|
+
# @param cache_image [Boolean] Whether to retain the submitted image for future
|
|
1034
|
+
# use; defaults to false if omitted.
|
|
1035
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
|
1036
|
+
# will be added to the HTTP request.
|
|
1037
|
+
#
|
|
1038
|
+
# @return [Evaluate] operation results.
|
|
1039
|
+
#
|
|
1040
|
+
def evaluate_url_input(content_type, image_url, cache_image:nil, custom_headers:nil)
|
|
1041
|
+
response = evaluate_url_input_async(content_type, image_url, cache_image:cache_image, custom_headers:custom_headers).value!
|
|
1042
|
+
response.body unless response.nil?
|
|
1043
|
+
end
|
|
1044
|
+
|
|
1045
|
+
#
|
|
1046
|
+
# Returns probabilities of the image containing racy or adult content.
|
|
1047
|
+
#
|
|
1048
|
+
# @param content_type [String] The content type.
|
|
1049
|
+
# @param image_url [ImageUrl] The image url.
|
|
1050
|
+
# @param cache_image [Boolean] Whether to retain the submitted image for future
|
|
1051
|
+
# use; defaults to false if omitted.
|
|
1052
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
|
1053
|
+
# will be added to the HTTP request.
|
|
1054
|
+
#
|
|
1055
|
+
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
|
1056
|
+
#
|
|
1057
|
+
def evaluate_url_input_with_http_info(content_type, image_url, cache_image:nil, custom_headers:nil)
|
|
1058
|
+
evaluate_url_input_async(content_type, image_url, cache_image:cache_image, custom_headers:custom_headers).value!
|
|
1059
|
+
end
|
|
1060
|
+
|
|
1061
|
+
#
|
|
1062
|
+
# Returns probabilities of the image containing racy or adult content.
|
|
1063
|
+
#
|
|
1064
|
+
# @param content_type [String] The content type.
|
|
1065
|
+
# @param image_url [ImageUrl] The image url.
|
|
1066
|
+
# @param cache_image [Boolean] Whether to retain the submitted image for future
|
|
1067
|
+
# use; defaults to false if omitted.
|
|
1068
|
+
# @param [Hash{String => String}] A hash of custom headers that will be added
|
|
1069
|
+
# to the HTTP request.
|
|
1070
|
+
#
|
|
1071
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
|
1072
|
+
#
|
|
1073
|
+
def evaluate_url_input_async(content_type, image_url, cache_image:nil, custom_headers:nil)
|
|
1074
|
+
fail ArgumentError, '@client.base_url is nil' if @client.base_url.nil?
|
|
1075
|
+
fail ArgumentError, 'content_type is nil' if content_type.nil?
|
|
1076
|
+
fail ArgumentError, 'image_url is nil' if image_url.nil?
|
|
1077
|
+
|
|
1078
|
+
|
|
1079
|
+
request_headers = {}
|
|
1080
|
+
request_headers['Content-Type'] = 'application/json; charset=utf-8'
|
|
1081
|
+
|
|
1082
|
+
# Set Headers
|
|
1083
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
|
1084
|
+
request_headers['Content-Type'] = content_type unless content_type.nil?
|
|
1085
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
|
1086
|
+
|
|
1087
|
+
# Serialize Request
|
|
1088
|
+
request_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::ImageUrl.mapper()
|
|
1089
|
+
request_content = @client.serialize(request_mapper, image_url)
|
|
1090
|
+
request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
|
|
1091
|
+
|
|
1092
|
+
path_template = 'contentmoderator/moderate/v1.0/ProcessImage/Evaluate'
|
|
1093
|
+
|
|
1094
|
+
request_url = @base_url || @client.base_url
|
|
1095
|
+
request_url = request_url.gsub('{baseUrl}', @client.base_url)
|
|
1096
|
+
|
|
1097
|
+
options = {
|
|
1098
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
|
1099
|
+
query_params: {'CacheImage' => cache_image},
|
|
1100
|
+
body: request_content,
|
|
1101
|
+
headers: request_headers.merge(custom_headers || {}),
|
|
1102
|
+
base_url: request_url
|
|
1103
|
+
}
|
|
1104
|
+
promise = @client.make_request_async(:post, path_template, options)
|
|
1105
|
+
|
|
1106
|
+
promise = promise.then do |result|
|
|
1107
|
+
http_response = result.response
|
|
1108
|
+
status_code = http_response.status
|
|
1109
|
+
response_content = http_response.body
|
|
1110
|
+
unless status_code == 200
|
|
1111
|
+
error_model = JSON.load(response_content)
|
|
1112
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
|
1113
|
+
end
|
|
1114
|
+
|
|
1115
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
|
1116
|
+
# Deserialize Response
|
|
1117
|
+
if status_code == 200
|
|
1118
|
+
begin
|
|
1119
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
|
1120
|
+
result_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::Evaluate.mapper()
|
|
1121
|
+
result.body = @client.deserialize(result_mapper, parsed_response)
|
|
1122
|
+
rescue Exception => e
|
|
1123
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
|
1124
|
+
end
|
|
1125
|
+
end
|
|
1126
|
+
|
|
1127
|
+
result
|
|
1128
|
+
end
|
|
1129
|
+
|
|
1130
|
+
promise.execute
|
|
1131
|
+
end
|
|
1132
|
+
|
|
1133
|
+
#
|
|
1134
|
+
# Fuzzily match an image against one of your custom Image Lists. You can create
|
|
1135
|
+
# and manage your custom image lists using <a
|
|
1136
|
+
# href="/docs/services/578ff44d2703741568569ab9/operations/578ff7b12703741568569abe">this</a>
|
|
1137
|
+
# API.
|
|
1138
|
+
#
|
|
1139
|
+
# Returns ID and tags of matching image.<br/>
|
|
1140
|
+
# <br/>
|
|
1141
|
+
# Note: Refresh Index must be run on the corresponding Image List before
|
|
1142
|
+
# additions and removals are reflected in the response.
|
|
1143
|
+
#
|
|
1144
|
+
# @param content_type [String] The content type.
|
|
1145
|
+
# @param image_url [ImageUrl] The image url.
|
|
1146
|
+
# @param list_id [String] The list Id.
|
|
1147
|
+
# @param cache_image [Boolean] Whether to retain the submitted image for future
|
|
1148
|
+
# use; defaults to false if omitted.
|
|
1149
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
|
1150
|
+
# will be added to the HTTP request.
|
|
1151
|
+
#
|
|
1152
|
+
# @return [MatchResponse] operation results.
|
|
1153
|
+
#
|
|
1154
|
+
def match_url_input(content_type, image_url, list_id:nil, cache_image:nil, custom_headers:nil)
|
|
1155
|
+
response = match_url_input_async(content_type, image_url, list_id:list_id, cache_image:cache_image, custom_headers:custom_headers).value!
|
|
1156
|
+
response.body unless response.nil?
|
|
1157
|
+
end
|
|
1158
|
+
|
|
1159
|
+
#
|
|
1160
|
+
# Fuzzily match an image against one of your custom Image Lists. You can create
|
|
1161
|
+
# and manage your custom image lists using <a
|
|
1162
|
+
# href="/docs/services/578ff44d2703741568569ab9/operations/578ff7b12703741568569abe">this</a>
|
|
1163
|
+
# API.
|
|
1164
|
+
#
|
|
1165
|
+
# Returns ID and tags of matching image.<br/>
|
|
1166
|
+
# <br/>
|
|
1167
|
+
# Note: Refresh Index must be run on the corresponding Image List before
|
|
1168
|
+
# additions and removals are reflected in the response.
|
|
1169
|
+
#
|
|
1170
|
+
# @param content_type [String] The content type.
|
|
1171
|
+
# @param image_url [ImageUrl] The image url.
|
|
1172
|
+
# @param list_id [String] The list Id.
|
|
1173
|
+
# @param cache_image [Boolean] Whether to retain the submitted image for future
|
|
1174
|
+
# use; defaults to false if omitted.
|
|
1175
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
|
1176
|
+
# will be added to the HTTP request.
|
|
1177
|
+
#
|
|
1178
|
+
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
|
1179
|
+
#
|
|
1180
|
+
def match_url_input_with_http_info(content_type, image_url, list_id:nil, cache_image:nil, custom_headers:nil)
|
|
1181
|
+
match_url_input_async(content_type, image_url, list_id:list_id, cache_image:cache_image, custom_headers:custom_headers).value!
|
|
1182
|
+
end
|
|
1183
|
+
|
|
1184
|
+
#
|
|
1185
|
+
# Fuzzily match an image against one of your custom Image Lists. You can create
|
|
1186
|
+
# and manage your custom image lists using <a
|
|
1187
|
+
# href="/docs/services/578ff44d2703741568569ab9/operations/578ff7b12703741568569abe">this</a>
|
|
1188
|
+
# API.
|
|
1189
|
+
#
|
|
1190
|
+
# Returns ID and tags of matching image.<br/>
|
|
1191
|
+
# <br/>
|
|
1192
|
+
# Note: Refresh Index must be run on the corresponding Image List before
|
|
1193
|
+
# additions and removals are reflected in the response.
|
|
1194
|
+
#
|
|
1195
|
+
# @param content_type [String] The content type.
|
|
1196
|
+
# @param image_url [ImageUrl] The image url.
|
|
1197
|
+
# @param list_id [String] The list Id.
|
|
1198
|
+
# @param cache_image [Boolean] Whether to retain the submitted image for future
|
|
1199
|
+
# use; defaults to false if omitted.
|
|
1200
|
+
# @param [Hash{String => String}] A hash of custom headers that will be added
|
|
1201
|
+
# to the HTTP request.
|
|
1202
|
+
#
|
|
1203
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
|
1204
|
+
#
|
|
1205
|
+
def match_url_input_async(content_type, image_url, list_id:nil, cache_image:nil, custom_headers:nil)
|
|
1206
|
+
fail ArgumentError, '@client.base_url is nil' if @client.base_url.nil?
|
|
1207
|
+
fail ArgumentError, 'content_type is nil' if content_type.nil?
|
|
1208
|
+
fail ArgumentError, 'image_url is nil' if image_url.nil?
|
|
1209
|
+
|
|
1210
|
+
|
|
1211
|
+
request_headers = {}
|
|
1212
|
+
request_headers['Content-Type'] = 'application/json; charset=utf-8'
|
|
1213
|
+
|
|
1214
|
+
# Set Headers
|
|
1215
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
|
1216
|
+
request_headers['Content-Type'] = content_type unless content_type.nil?
|
|
1217
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
|
1218
|
+
|
|
1219
|
+
# Serialize Request
|
|
1220
|
+
request_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::ImageUrl.mapper()
|
|
1221
|
+
request_content = @client.serialize(request_mapper, image_url)
|
|
1222
|
+
request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
|
|
1223
|
+
|
|
1224
|
+
path_template = 'contentmoderator/moderate/v1.0/ProcessImage/Match'
|
|
1225
|
+
|
|
1226
|
+
request_url = @base_url || @client.base_url
|
|
1227
|
+
request_url = request_url.gsub('{baseUrl}', @client.base_url)
|
|
1228
|
+
|
|
1229
|
+
options = {
|
|
1230
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
|
1231
|
+
query_params: {'listId' => list_id,'CacheImage' => cache_image},
|
|
1232
|
+
body: request_content,
|
|
1233
|
+
headers: request_headers.merge(custom_headers || {}),
|
|
1234
|
+
base_url: request_url
|
|
1235
|
+
}
|
|
1236
|
+
promise = @client.make_request_async(:post, path_template, options)
|
|
1237
|
+
|
|
1238
|
+
promise = promise.then do |result|
|
|
1239
|
+
http_response = result.response
|
|
1240
|
+
status_code = http_response.status
|
|
1241
|
+
response_content = http_response.body
|
|
1242
|
+
unless status_code == 200
|
|
1243
|
+
error_model = JSON.load(response_content)
|
|
1244
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
|
1245
|
+
end
|
|
1246
|
+
|
|
1247
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
|
1248
|
+
# Deserialize Response
|
|
1249
|
+
if status_code == 200
|
|
1250
|
+
begin
|
|
1251
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
|
1252
|
+
result_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::MatchResponse.mapper()
|
|
1253
|
+
result.body = @client.deserialize(result_mapper, parsed_response)
|
|
1254
|
+
rescue Exception => e
|
|
1255
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
|
1256
|
+
end
|
|
1257
|
+
end
|
|
1258
|
+
|
|
1259
|
+
result
|
|
1260
|
+
end
|
|
1261
|
+
|
|
1262
|
+
promise.execute
|
|
1263
|
+
end
|
|
1264
|
+
|
|
1265
|
+
#
|
|
1266
|
+
# Fuzzily match an image against one of your custom Image Lists. You can create
|
|
1267
|
+
# and manage your custom image lists using <a
|
|
1268
|
+
# href="/docs/services/578ff44d2703741568569ab9/operations/578ff7b12703741568569abe">this</a>
|
|
1269
|
+
# API.
|
|
1270
|
+
#
|
|
1271
|
+
# Returns ID and tags of matching image.<br/>
|
|
1272
|
+
# <br/>
|
|
1273
|
+
# Note: Refresh Index must be run on the corresponding Image List before
|
|
1274
|
+
# additions and removals are reflected in the response.
|
|
1275
|
+
#
|
|
1276
|
+
# @param image_stream The image file.
|
|
1277
|
+
# @param list_id [String] The list Id.
|
|
1278
|
+
# @param cache_image [Boolean] Whether to retain the submitted image for future
|
|
1279
|
+
# use; defaults to false if omitted.
|
|
1280
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
|
1281
|
+
# will be added to the HTTP request.
|
|
1282
|
+
#
|
|
1283
|
+
# @return [MatchResponse] operation results.
|
|
1284
|
+
#
|
|
1285
|
+
def match_file_input(image_stream, list_id:nil, cache_image:nil, custom_headers:nil)
|
|
1286
|
+
response = match_file_input_async(image_stream, list_id:list_id, cache_image:cache_image, custom_headers:custom_headers).value!
|
|
1287
|
+
response.body unless response.nil?
|
|
1288
|
+
end
|
|
1289
|
+
|
|
1290
|
+
#
|
|
1291
|
+
# Fuzzily match an image against one of your custom Image Lists. You can create
|
|
1292
|
+
# and manage your custom image lists using <a
|
|
1293
|
+
# href="/docs/services/578ff44d2703741568569ab9/operations/578ff7b12703741568569abe">this</a>
|
|
1294
|
+
# API.
|
|
1295
|
+
#
|
|
1296
|
+
# Returns ID and tags of matching image.<br/>
|
|
1297
|
+
# <br/>
|
|
1298
|
+
# Note: Refresh Index must be run on the corresponding Image List before
|
|
1299
|
+
# additions and removals are reflected in the response.
|
|
1300
|
+
#
|
|
1301
|
+
# @param image_stream The image file.
|
|
1302
|
+
# @param list_id [String] The list Id.
|
|
1303
|
+
# @param cache_image [Boolean] Whether to retain the submitted image for future
|
|
1304
|
+
# use; defaults to false if omitted.
|
|
1305
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
|
1306
|
+
# will be added to the HTTP request.
|
|
1307
|
+
#
|
|
1308
|
+
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
|
1309
|
+
#
|
|
1310
|
+
def match_file_input_with_http_info(image_stream, list_id:nil, cache_image:nil, custom_headers:nil)
|
|
1311
|
+
match_file_input_async(image_stream, list_id:list_id, cache_image:cache_image, custom_headers:custom_headers).value!
|
|
1312
|
+
end
|
|
1313
|
+
|
|
1314
|
+
#
|
|
1315
|
+
# Fuzzily match an image against one of your custom Image Lists. You can create
|
|
1316
|
+
# and manage your custom image lists using <a
|
|
1317
|
+
# href="/docs/services/578ff44d2703741568569ab9/operations/578ff7b12703741568569abe">this</a>
|
|
1318
|
+
# API.
|
|
1319
|
+
#
|
|
1320
|
+
# Returns ID and tags of matching image.<br/>
|
|
1321
|
+
# <br/>
|
|
1322
|
+
# Note: Refresh Index must be run on the corresponding Image List before
|
|
1323
|
+
# additions and removals are reflected in the response.
|
|
1324
|
+
#
|
|
1325
|
+
# @param image_stream The image file.
|
|
1326
|
+
# @param list_id [String] The list Id.
|
|
1327
|
+
# @param cache_image [Boolean] Whether to retain the submitted image for future
|
|
1328
|
+
# use; defaults to false if omitted.
|
|
1329
|
+
# @param [Hash{String => String}] A hash of custom headers that will be added
|
|
1330
|
+
# to the HTTP request.
|
|
1331
|
+
#
|
|
1332
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
|
1333
|
+
#
|
|
1334
|
+
def match_file_input_async(image_stream, list_id:nil, cache_image:nil, custom_headers:nil)
|
|
1335
|
+
fail ArgumentError, '@client.base_url is nil' if @client.base_url.nil?
|
|
1336
|
+
fail ArgumentError, 'image_stream is nil' if image_stream.nil?
|
|
1337
|
+
|
|
1338
|
+
|
|
1339
|
+
request_headers = {}
|
|
1340
|
+
request_headers['Content-Type'] = 'image/gif'
|
|
1341
|
+
|
|
1342
|
+
# Set Headers
|
|
1343
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
|
1344
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
|
1345
|
+
|
|
1346
|
+
# Serialize Request
|
|
1347
|
+
request_mapper = {
|
|
1348
|
+
client_side_validation: true,
|
|
1349
|
+
required: true,
|
|
1350
|
+
serialized_name: 'ImageStream',
|
|
1351
|
+
type: {
|
|
1352
|
+
name: 'Stream'
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
request_content = @client.serialize(request_mapper, image_stream)
|
|
1356
|
+
|
|
1357
|
+
path_template = 'contentmoderator/moderate/v1.0/ProcessImage/Match'
|
|
1358
|
+
|
|
1359
|
+
request_url = @base_url || @client.base_url
|
|
1360
|
+
request_url = request_url.gsub('{baseUrl}', @client.base_url)
|
|
1361
|
+
|
|
1362
|
+
options = {
|
|
1363
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
|
1364
|
+
query_params: {'listId' => list_id,'CacheImage' => cache_image},
|
|
1365
|
+
body: request_content,
|
|
1366
|
+
headers: request_headers.merge(custom_headers || {}),
|
|
1367
|
+
base_url: request_url
|
|
1368
|
+
}
|
|
1369
|
+
promise = @client.make_request_async(:post, path_template, options)
|
|
1370
|
+
|
|
1371
|
+
promise = promise.then do |result|
|
|
1372
|
+
http_response = result.response
|
|
1373
|
+
status_code = http_response.status
|
|
1374
|
+
response_content = http_response.body
|
|
1375
|
+
unless status_code == 200
|
|
1376
|
+
error_model = JSON.load(response_content)
|
|
1377
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
|
1378
|
+
end
|
|
1379
|
+
|
|
1380
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
|
1381
|
+
# Deserialize Response
|
|
1382
|
+
if status_code == 200
|
|
1383
|
+
begin
|
|
1384
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
|
1385
|
+
result_mapper = Azure::CognitiveServices::ContentModerator::V1_0::Models::MatchResponse.mapper()
|
|
1386
|
+
result.body = @client.deserialize(result_mapper, parsed_response)
|
|
1387
|
+
rescue Exception => e
|
|
1388
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
|
1389
|
+
end
|
|
1390
|
+
end
|
|
1391
|
+
|
|
1392
|
+
result
|
|
1393
|
+
end
|
|
1394
|
+
|
|
1395
|
+
promise.execute
|
|
1396
|
+
end
|
|
1397
|
+
|
|
1398
|
+
end
|
|
1399
|
+
end
|