diff --git a/services/cognitiveservices/v1.0/contentmoderator/models.go b/services/cognitiveservices/v1.0/contentmoderator/models.go index 9a5792f6237b..079bf4671c05 100644 --- a/services/cognitiveservices/v1.0/contentmoderator/models.go +++ b/services/cognitiveservices/v1.0/contentmoderator/models.go @@ -564,6 +564,7 @@ type Phone struct { // PII personal Identifier Information details. type PII struct { Email *[]Email `json:"Email,omitempty"` + SSN *[]SSN `json:"SSN,omitempty"` IPA *[]IPA `json:"IPA,omitempty"` Phone *[]Phone `json:"Phone,omitempty"` Address *[]Address `json:"Address,omitempty"` @@ -647,6 +648,14 @@ type SetObject struct { Value interface{} `json:"value,omitempty"` } +// SSN detected SSN details. +type SSN struct { + // Text - Detected SSN in the input text content. + Text *string `json:"Text,omitempty"` + // Index - Index(Location) of the SSN in the input text content. + Index *int32 `json:"Index,omitempty"` +} + // Status status properties. type Status struct { // Code - Status code. diff --git a/services/cognitiveservices/v1.0/contentmoderator/textmoderation.go b/services/cognitiveservices/v1.0/contentmoderator/textmoderation.go index c69caeae2f41..0dec98b6bb34 100644 --- a/services/cognitiveservices/v1.0/contentmoderator/textmoderation.go +++ b/services/cognitiveservices/v1.0/contentmoderator/textmoderation.go @@ -21,6 +21,7 @@ import ( "context" "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" + "io" "net/http" ) @@ -53,8 +54,9 @@ func NewTextModerationClient(baseURL AzureRegionBaseURL) TextModerationClient { // href="http://www-01.sil.org/iso639-3/codes.asp">ISO 639-3 code for the predominant language comprising the // submitted text. Over 110 languages supported. // -// textContentType is the content type. textContent is content to screen. -func (client TextModerationClient) DetectLanguage(ctx context.Context, textContentType string, textContent string) (result DetectedLanguage, err error) { +// textContentType is the content type. textContent is content to screen. textContent will be closed upon +// successful return. Callers should ensure closure when receiving an error. +func (client TextModerationClient) DetectLanguage(ctx context.Context, textContentType string, textContent io.ReadCloser) (result DetectedLanguage, err error) { req, err := client.DetectLanguagePreparer(ctx, textContentType, textContent) if err != nil { err = autorest.NewErrorWithError(err, "contentmoderator.TextModerationClient", "DetectLanguage", nil, "Failure preparing request") @@ -77,7 +79,7 @@ func (client TextModerationClient) DetectLanguage(ctx context.Context, textConte } // DetectLanguagePreparer prepares the DetectLanguage request. -func (client TextModerationClient) DetectLanguagePreparer(ctx context.Context, textContentType string, textContent string) (*http.Request, error) { +func (client TextModerationClient) DetectLanguagePreparer(ctx context.Context, textContentType string, textContent io.ReadCloser) (*http.Request, error) { urlParameters := map[string]interface{}{ "baseUrl": client.BaseURL, } @@ -87,7 +89,7 @@ func (client TextModerationClient) DetectLanguagePreparer(ctx context.Context, t autorest.AsPost(), autorest.WithCustomBaseURL("https://{baseUrl}", urlParameters), autorest.WithPath("/contentmoderator/moderate/v1.0/ProcessText/DetectLanguage"), - autorest.WithJSON(textContent), + autorest.WithFile(textContent), autorest.WithHeader("Content-Type", autorest.String(textContentType))) return preparer.Prepare((&http.Request{}).WithContext(ctx)) } @@ -115,9 +117,10 @@ func (client TextModerationClient) DetectLanguageResponder(resp *http.Response) // ScreenText detects profanity in more than 100 languages and match against custom and shared blacklists. // // language is language of the terms. textContentType is the content type. textContent is content to screen. -// autocorrect is autocorrect text. pii is detect personal identifiable information. listID is the list Id. +// textContent will be closed upon successful return. Callers should ensure closure when receiving an +// error.autocorrect is autocorrect text. pii is detect personal identifiable information. listID is the list Id. // classify is classify input. -func (client TextModerationClient) ScreenText(ctx context.Context, language string, textContentType string, textContent string, autocorrect *bool, pii *bool, listID string, classify *bool) (result Screen, err error) { +func (client TextModerationClient) ScreenText(ctx context.Context, language string, textContentType string, textContent io.ReadCloser, autocorrect *bool, pii *bool, listID string, classify *bool) (result Screen, err error) { req, err := client.ScreenTextPreparer(ctx, language, textContentType, textContent, autocorrect, pii, listID, classify) if err != nil { err = autorest.NewErrorWithError(err, "contentmoderator.TextModerationClient", "ScreenText", nil, "Failure preparing request") @@ -140,7 +143,7 @@ func (client TextModerationClient) ScreenText(ctx context.Context, language stri } // ScreenTextPreparer prepares the ScreenText request. -func (client TextModerationClient) ScreenTextPreparer(ctx context.Context, language string, textContentType string, textContent string, autocorrect *bool, pii *bool, listID string, classify *bool) (*http.Request, error) { +func (client TextModerationClient) ScreenTextPreparer(ctx context.Context, language string, textContentType string, textContent io.ReadCloser, autocorrect *bool, pii *bool, listID string, classify *bool) (*http.Request, error) { urlParameters := map[string]interface{}{ "baseUrl": client.BaseURL, } @@ -172,7 +175,7 @@ func (client TextModerationClient) ScreenTextPreparer(ctx context.Context, langu autorest.AsPost(), autorest.WithCustomBaseURL("https://{baseUrl}", urlParameters), autorest.WithPath("/contentmoderator/moderate/v1.0/ProcessText/Screen/"), - autorest.WithJSON(textContent), + autorest.WithFile(textContent), autorest.WithQueryParameters(queryParameters), autorest.WithHeader("Content-Type", autorest.String(textContentType))) return preparer.Prepare((&http.Request{}).WithContext(ctx))