From 77942b92f0ee81d3cb43fcb05b202a2ae57d2fe4 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Thu, 8 Aug 2024 06:26:28 +0000 Subject: [PATCH] CodeGen from PR 29866 in Azure/azure-rest-api-specs Merge 3f13787f9cae663aa0438f300dd0320a2adbb27a into 83be071237ba29dd6812350dfc5d531fceb33014 --- .../azure-ai-contentsafety/CHANGELOG.md | 77 +++++++++- .../ContentSafetyClientImpl.java | 136 +++++++++--------- .../models/AnalyzeImageOptions.java | 4 +- .../models/AnalyzeTextOptions.java | 8 +- .../contentsafety/models/ImageCategory.java | 10 +- .../models/TextBlocklistItem.java | 4 +- .../ai/contentsafety/models/TextCategory.java | 10 +- ...OrUpdateBlocklistItemsToTextBlocklist.java | 28 ++++ .../contentsafety/generated/AnalyzeImage.java | 26 ++++ .../contentsafety/generated/AnalyzeText.java | 24 ++++ .../CreateOrUpdateTextBlocklist.java | 23 +++ .../DeleteTextBlocklistByBlocklistName.java | 22 +++ .../GetAllBlockItemsByBlocklistName.java | 24 ++++ .../generated/GetAllTextBlocklists.java | 24 ++++ ...ItemByBlocklistNameAndBlocklistItemId.java | 24 ++++ .../GetTextBlocklistByBlocklistName.java | 23 +++ .../RemoveBlockItemsFromTextBlocklist.java | 25 ++++ ...ateBlocklistItemsToTextBlocklistTests.java | 37 +++++ .../generated/AnalyzeImageTests.java | 35 +++++ .../generated/AnalyzeTextTests.java | 37 +++++ .../ContentSafetyClientTestBase.java | 64 +++++++++ .../CreateOrUpdateTextBlocklistTests.java | 27 ++++ ...leteTextBlocklistByBlocklistNameTests.java | 18 +++ .../GetAllBlockItemsByBlocklistNameTests.java | 32 +++++ .../generated/GetAllTextBlocklistsTests.java | 30 ++++ ...yBlocklistNameAndBlocklistItemIdTests.java | 30 ++++ .../GetTextBlocklistByBlocklistNameTests.java | 27 ++++ ...emoveBlockItemsFromTextBlocklistTests.java | 21 +++ .../azure-ai-contentsafety/tsp-location.yaml | 4 +- 29 files changed, 763 insertions(+), 91 deletions(-) create mode 100644 sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/AddOrUpdateBlocklistItemsToTextBlocklist.java create mode 100644 sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/AnalyzeImage.java create mode 100644 sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/AnalyzeText.java create mode 100644 sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/CreateOrUpdateTextBlocklist.java create mode 100644 sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/DeleteTextBlocklistByBlocklistName.java create mode 100644 sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/GetAllBlockItemsByBlocklistName.java create mode 100644 sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/GetAllTextBlocklists.java create mode 100644 sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/GetBlockItemByBlocklistNameAndBlocklistItemId.java create mode 100644 sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/GetTextBlocklistByBlocklistName.java create mode 100644 sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/RemoveBlockItemsFromTextBlocklist.java create mode 100644 sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/AddOrUpdateBlocklistItemsToTextBlocklistTests.java create mode 100644 sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/AnalyzeImageTests.java create mode 100644 sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/AnalyzeTextTests.java create mode 100644 sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/ContentSafetyClientTestBase.java create mode 100644 sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/CreateOrUpdateTextBlocklistTests.java create mode 100644 sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/DeleteTextBlocklistByBlocklistNameTests.java create mode 100644 sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/GetAllBlockItemsByBlocklistNameTests.java create mode 100644 sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/GetAllTextBlocklistsTests.java create mode 100644 sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/GetBlockItemByBlocklistNameAndBlocklistItemIdTests.java create mode 100644 sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/GetTextBlocklistByBlocklistNameTests.java create mode 100644 sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/RemoveBlockItemsFromTextBlocklistTests.java diff --git a/sdk/contentsafety/azure-ai-contentsafety/CHANGELOG.md b/sdk/contentsafety/azure-ai-contentsafety/CHANGELOG.md index 986880c8ace2..8fbe5dc15d42 100644 --- a/sdk/contentsafety/azure-ai-contentsafety/CHANGELOG.md +++ b/sdk/contentsafety/azure-ai-contentsafety/CHANGELOG.md @@ -4,11 +4,82 @@ ### Features Added -### Breaking Changes +#### `models.AddOrUpdateTextBlocklistItemsResult` was modified -### Bugs Fixed +* `fromJson(com.azure.json.JsonReader)` was added +* `toJson(com.azure.json.JsonWriter)` was added -### Other Changes +#### `BlocklistAsyncClient` was modified + +* `createOrUpdateTextBlocklist(java.lang.String,models.TextBlocklist)` was added + +#### `models.AnalyzeTextResult` was modified + +* `toJson(com.azure.json.JsonWriter)` was added +* `fromJson(com.azure.json.JsonReader)` was added + +#### `models.TextBlocklistMatch` was modified + +* `toJson(com.azure.json.JsonWriter)` was added +* `fromJson(com.azure.json.JsonReader)` was added + +#### `models.AnalyzeImageOptions` was modified + +* `toJson(com.azure.json.JsonWriter)` was added +* `fromJson(com.azure.json.JsonReader)` was added + +#### `models.TextBlocklistItem` was modified + +* `fromJson(com.azure.json.JsonReader)` was added +* `toJson(com.azure.json.JsonWriter)` was added + +#### `models.RemoveTextBlocklistItemsOptions` was modified + +* `fromJson(com.azure.json.JsonReader)` was added +* `toJson(com.azure.json.JsonWriter)` was added + +#### `models.TextBlocklist` was modified + +* `fromJson(com.azure.json.JsonReader)` was added +* `toJson(com.azure.json.JsonWriter)` was added + +#### `models.AnalyzeTextOptions` was modified + +* `fromJson(com.azure.json.JsonReader)` was added +* `toJson(com.azure.json.JsonWriter)` was added + +#### `implementation.JsonMergePatchHelper$TextBlocklistAccessor` was modified + +* `isJsonMergePatch(models.TextBlocklist)` was added + +#### `models.ImageCategoriesAnalysis` was modified + +* `fromJson(com.azure.json.JsonReader)` was added +* `toJson(com.azure.json.JsonWriter)` was added + +#### `models.AnalyzeImageResult` was modified + +* `fromJson(com.azure.json.JsonReader)` was added +* `toJson(com.azure.json.JsonWriter)` was added + +#### `models.AddOrUpdateTextBlocklistItemsOptions` was modified + +* `fromJson(com.azure.json.JsonReader)` was added +* `toJson(com.azure.json.JsonWriter)` was added + +#### `models.ContentSafetyImageData` was modified + +* `fromJson(com.azure.json.JsonReader)` was added +* `toJson(com.azure.json.JsonWriter)` was added + +#### `models.TextCategoriesAnalysis` was modified + +* `toJson(com.azure.json.JsonWriter)` was added +* `fromJson(com.azure.json.JsonReader)` was added + +#### `BlocklistClient` was modified + +* `createOrUpdateTextBlocklist(java.lang.String,models.TextBlocklist)` was added ## 1.0.5 (2024-07-26) diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/implementation/ContentSafetyClientImpl.java b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/implementation/ContentSafetyClientImpl.java index 5c24a16c86a4..af66d0d512d2 100644 --- a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/implementation/ContentSafetyClientImpl.java +++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/implementation/ContentSafetyClientImpl.java @@ -152,65 +152,64 @@ public ContentSafetyClientImpl(HttpPipeline httpPipeline, SerializerAdapter seri @Host("{endpoint}/contentsafety") @ServiceInterface(name = "ContentSafetyClient") public interface ContentSafetyClientService { - @Post("/text:analyze") + @Post("/image:analyze") @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> analyzeText(@HostParam("endpoint") String endpoint, + Mono> analyzeImage(@HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData options, RequestOptions requestOptions, Context context); - @Post("/text:analyze") + @Post("/image:analyze") @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response analyzeTextSync(@HostParam("endpoint") String endpoint, + Response analyzeImageSync(@HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData options, RequestOptions requestOptions, Context context); - @Post("/image:analyze") + @Post("/text:analyze") @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> analyzeImage(@HostParam("endpoint") String endpoint, + Mono> analyzeText(@HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData options, RequestOptions requestOptions, Context context); - @Post("/image:analyze") + @Post("/text:analyze") @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response analyzeImageSync(@HostParam("endpoint") String endpoint, + Response analyzeTextSync(@HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData options, RequestOptions requestOptions, Context context); } /** - * Analyze Text + * Analyze Image * - * A synchronous API for the analysis of potentially harmful text content. Currently, it supports four categories: + * A synchronous API for the analysis of potentially harmful image content. Currently, it supports four categories: * Hate, SelfHarm, Sexual, and Violence. *

Request Body Schema

* *
{@code
      * {
-     *     text: String (Required)
+     *     image (Required): {
+     *         content: byte[] (Optional)
+     *         blobUrl: String (Optional)
+     *     }
      *     categories (Optional): [
      *         String(Hate/SelfHarm/Sexual/Violence) (Optional)
      *     ]
-     *     blocklistNames (Optional): [
-     *         String (Optional)
-     *     ]
-     *     haltOnBlocklistHit: Boolean (Optional)
-     *     outputType: String(FourSeverityLevels/EightSeverityLevels) (Optional)
+     *     outputType: String(FourSeverityLevels) (Optional)
      * }
      * }
* @@ -218,13 +217,6 @@ Response analyzeImageSync(@HostParam("endpoint") String endpoint, * *
{@code
      * {
-     *     blocklistsMatch (Optional): [
-     *          (Optional){
-     *             blocklistName: String (Required)
-     *             blocklistItemId: String (Required)
-     *             blocklistItemText: String (Required)
-     *         }
-     *     ]
      *     categoriesAnalysis (Required): [
      *          (Required){
      *             category: String(Hate/SelfHarm/Sexual/Violence) (Required)
@@ -234,39 +226,38 @@ Response analyzeImageSync(@HostParam("endpoint") String endpoint,
      * }
      * }
* - * @param options The text analysis request. + * @param options The image analysis request. * @param requestOptions The options to configure the HTTP request before HTTP client sends it. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the text analysis response along with {@link Response} on successful completion of {@link Mono}. + * @return the image analysis response along with {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> analyzeTextWithResponseAsync(BinaryData options, RequestOptions requestOptions) { + public Mono> analyzeImageWithResponseAsync(BinaryData options, RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.analyzeText(this.getEndpoint(), + return FluxUtil.withContext(context -> service.analyzeImage(this.getEndpoint(), this.getServiceVersion().getVersion(), accept, options, requestOptions, context)); } /** - * Analyze Text + * Analyze Image * - * A synchronous API for the analysis of potentially harmful text content. Currently, it supports four categories: + * A synchronous API for the analysis of potentially harmful image content. Currently, it supports four categories: * Hate, SelfHarm, Sexual, and Violence. *

Request Body Schema

* *
{@code
      * {
-     *     text: String (Required)
+     *     image (Required): {
+     *         content: byte[] (Optional)
+     *         blobUrl: String (Optional)
+     *     }
      *     categories (Optional): [
      *         String(Hate/SelfHarm/Sexual/Violence) (Optional)
      *     ]
-     *     blocklistNames (Optional): [
-     *         String (Optional)
-     *     ]
-     *     haltOnBlocklistHit: Boolean (Optional)
-     *     outputType: String(FourSeverityLevels/EightSeverityLevels) (Optional)
+     *     outputType: String(FourSeverityLevels) (Optional)
      * }
      * }
* @@ -274,13 +265,6 @@ public Mono> analyzeTextWithResponseAsync(BinaryData option * *
{@code
      * {
-     *     blocklistsMatch (Optional): [
-     *          (Optional){
-     *             blocklistName: String (Required)
-     *             blocklistItemId: String (Required)
-     *             blocklistItemText: String (Required)
-     *         }
-     *     ]
      *     categoriesAnalysis (Required): [
      *          (Required){
      *             category: String(Hate/SelfHarm/Sexual/Violence) (Required)
@@ -290,38 +274,39 @@ public Mono> analyzeTextWithResponseAsync(BinaryData option
      * }
      * }
* - * @param options The text analysis request. + * @param options The image analysis request. * @param requestOptions The options to configure the HTTP request before HTTP client sends it. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the text analysis response along with {@link Response}. + * @return the image analysis response along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response analyzeTextWithResponse(BinaryData options, RequestOptions requestOptions) { + public Response analyzeImageWithResponse(BinaryData options, RequestOptions requestOptions) { final String accept = "application/json"; - return service.analyzeTextSync(this.getEndpoint(), this.getServiceVersion().getVersion(), accept, options, + return service.analyzeImageSync(this.getEndpoint(), this.getServiceVersion().getVersion(), accept, options, requestOptions, Context.NONE); } /** - * Analyze Image + * Analyze Text * - * A synchronous API for the analysis of potentially harmful image content. Currently, it supports four categories: + * A synchronous API for the analysis of potentially harmful text content. Currently, it supports four categories: * Hate, SelfHarm, Sexual, and Violence. *

Request Body Schema

* *
{@code
      * {
-     *     image (Required): {
-     *         content: byte[] (Optional)
-     *         blobUrl: String (Optional)
-     *     }
+     *     text: String (Required)
      *     categories (Optional): [
      *         String(Hate/SelfHarm/Sexual/Violence) (Optional)
      *     ]
-     *     outputType: String(FourSeverityLevels) (Optional)
+     *     blocklistNames (Optional): [
+     *         String (Optional)
+     *     ]
+     *     haltOnBlocklistHit: Boolean (Optional)
+     *     outputType: String(FourSeverityLevels/EightSeverityLevels) (Optional)
      * }
      * }
* @@ -329,6 +314,13 @@ public Response analyzeTextWithResponse(BinaryData options, RequestO * *
{@code
      * {
+     *     blocklistsMatch (Optional): [
+     *          (Optional){
+     *             blocklistName: String (Required)
+     *             blocklistItemId: String (Required)
+     *             blocklistItemText: String (Required)
+     *         }
+     *     ]
      *     categoriesAnalysis (Required): [
      *          (Required){
      *             category: String(Hate/SelfHarm/Sexual/Violence) (Required)
@@ -338,38 +330,39 @@ public Response analyzeTextWithResponse(BinaryData options, RequestO
      * }
      * }
* - * @param options The image analysis request. + * @param options The text analysis request. * @param requestOptions The options to configure the HTTP request before HTTP client sends it. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the image analysis response along with {@link Response} on successful completion of {@link Mono}. + * @return the text analysis response along with {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> analyzeImageWithResponseAsync(BinaryData options, RequestOptions requestOptions) { + public Mono> analyzeTextWithResponseAsync(BinaryData options, RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.analyzeImage(this.getEndpoint(), + return FluxUtil.withContext(context -> service.analyzeText(this.getEndpoint(), this.getServiceVersion().getVersion(), accept, options, requestOptions, context)); } /** - * Analyze Image + * Analyze Text * - * A synchronous API for the analysis of potentially harmful image content. Currently, it supports four categories: + * A synchronous API for the analysis of potentially harmful text content. Currently, it supports four categories: * Hate, SelfHarm, Sexual, and Violence. *

Request Body Schema

* *
{@code
      * {
-     *     image (Required): {
-     *         content: byte[] (Optional)
-     *         blobUrl: String (Optional)
-     *     }
+     *     text: String (Required)
      *     categories (Optional): [
      *         String(Hate/SelfHarm/Sexual/Violence) (Optional)
      *     ]
-     *     outputType: String(FourSeverityLevels) (Optional)
+     *     blocklistNames (Optional): [
+     *         String (Optional)
+     *     ]
+     *     haltOnBlocklistHit: Boolean (Optional)
+     *     outputType: String(FourSeverityLevels/EightSeverityLevels) (Optional)
      * }
      * }
* @@ -377,6 +370,13 @@ public Mono> analyzeImageWithResponseAsync(BinaryData optio * *
{@code
      * {
+     *     blocklistsMatch (Optional): [
+     *          (Optional){
+     *             blocklistName: String (Required)
+     *             blocklistItemId: String (Required)
+     *             blocklistItemText: String (Required)
+     *         }
+     *     ]
      *     categoriesAnalysis (Required): [
      *          (Required){
      *             category: String(Hate/SelfHarm/Sexual/Violence) (Required)
@@ -386,18 +386,18 @@ public Mono> analyzeImageWithResponseAsync(BinaryData optio
      * }
      * }
* - * @param options The image analysis request. + * @param options The text analysis request. * @param requestOptions The options to configure the HTTP request before HTTP client sends it. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the image analysis response along with {@link Response}. + * @return the text analysis response along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response analyzeImageWithResponse(BinaryData options, RequestOptions requestOptions) { + public Response analyzeTextWithResponse(BinaryData options, RequestOptions requestOptions) { final String accept = "application/json"; - return service.analyzeImageSync(this.getEndpoint(), this.getServiceVersion().getVersion(), accept, options, + return service.analyzeTextSync(this.getEndpoint(), this.getServiceVersion().getVersion(), accept, options, requestOptions, Context.NONE); } } diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/AnalyzeImageOptions.java b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/AnalyzeImageOptions.java index 938f82eb5e13..72d04176b574 100644 --- a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/AnalyzeImageOptions.java +++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/AnalyzeImageOptions.java @@ -19,7 +19,7 @@ public final class AnalyzeImageOptions implements JsonSerializable { /* - * The image needs to be analyzed. + * The image to be analyzed. */ @Generated private final ContentSafetyImageData image; @@ -49,7 +49,7 @@ public AnalyzeImageOptions(ContentSafetyImageData image) { } /** - * Get the image property: The image needs to be analyzed. + * Get the image property: The image to be analyzed. * * @return the image value. */ diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/AnalyzeTextOptions.java b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/AnalyzeTextOptions.java index 7db519935292..a9ec9d3c390c 100644 --- a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/AnalyzeTextOptions.java +++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/AnalyzeTextOptions.java @@ -19,8 +19,8 @@ public final class AnalyzeTextOptions implements JsonSerializable { /* - * The text needs to be analyzed. We support a maximum of 10k Unicode characters (Unicode code points) in the text - * of one request. + * The text to be analyzed. We support a maximum of 10k Unicode characters (Unicode code points) in the text of one + * request. */ @Generated private final String text; @@ -63,8 +63,8 @@ public AnalyzeTextOptions(String text) { } /** - * Get the text property: The text needs to be analyzed. We support a maximum of 10k Unicode characters (Unicode - * code points) in the text of one request. + * Get the text property: The text to be analyzed. We support a maximum of 10k Unicode characters (Unicode code + * points) in the text of one request. * * @return the text value. */ diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/ImageCategory.java b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/ImageCategory.java index 67ee0baa0779..e6a2bf07d4ba 100644 --- a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/ImageCategory.java +++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/ImageCategory.java @@ -8,30 +8,30 @@ import java.util.Collection; /** - * Image analyze category. + * The harm category supported in Image content analysis. */ public final class ImageCategory extends ExpandableStringEnum { /** - * Static value Hate for ImageCategory. + * The harm category for Image - Hate. */ @Generated public static final ImageCategory HATE = fromString("Hate"); /** - * Static value SelfHarm for ImageCategory. + * The harm category for Image - SelfHarm. */ @Generated public static final ImageCategory SELF_HARM = fromString("SelfHarm"); /** - * Static value Sexual for ImageCategory. + * The harm category for Image - Sexual. */ @Generated public static final ImageCategory SEXUAL = fromString("Sexual"); /** - * Static value Violence for ImageCategory. + * The harm category for Image - Violence. */ @Generated public static final ImageCategory VIOLENCE = fromString("Violence"); diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/TextBlocklistItem.java b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/TextBlocklistItem.java index 407283f31eec..69d97eaff529 100644 --- a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/TextBlocklistItem.java +++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/TextBlocklistItem.java @@ -30,7 +30,7 @@ public final class TextBlocklistItem implements JsonSerializable { /** - * Static value Hate for TextCategory. + * The harm category for Text - Hate. */ @Generated public static final TextCategory HATE = fromString("Hate"); /** - * Static value SelfHarm for TextCategory. + * The harm category for Text - SelfHarm. */ @Generated public static final TextCategory SELF_HARM = fromString("SelfHarm"); /** - * Static value Sexual for TextCategory. + * The harm category for Text - Sexual. */ @Generated public static final TextCategory SEXUAL = fromString("Sexual"); /** - * Static value Violence for TextCategory. + * The harm category for Text - Violence. */ @Generated public static final TextCategory VIOLENCE = fromString("Violence"); diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/AddOrUpdateBlocklistItemsToTextBlocklist.java b/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/AddOrUpdateBlocklistItemsToTextBlocklist.java new file mode 100644 index 000000000000..c73ceb46a474 --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/AddOrUpdateBlocklistItemsToTextBlocklist.java @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.contentsafety.generated; + +import com.azure.ai.contentsafety.BlocklistClient; +import com.azure.ai.contentsafety.BlocklistClientBuilder; +import com.azure.ai.contentsafety.models.AddOrUpdateTextBlocklistItemsOptions; +import com.azure.ai.contentsafety.models.AddOrUpdateTextBlocklistItemsResult; +import com.azure.ai.contentsafety.models.TextBlocklistItem; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.util.Arrays; + +public class AddOrUpdateBlocklistItemsToTextBlocklist { + public static void main(String[] args) { + BlocklistClient blocklistClient + = new BlocklistClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildClient(); + // BEGIN:com.azure.ai.contentsafety.generated.addorupdateblocklistitems.addorupdateblocklistitemstotextblocklist + AddOrUpdateTextBlocklistItemsResult response + = blocklistClient.addOrUpdateBlocklistItems("TestBlocklist", new AddOrUpdateTextBlocklistItemsOptions( + Arrays.asList(new TextBlocklistItem("hate").setDescription("Hate word")))); + // END:com.azure.ai.contentsafety.generated.addorupdateblocklistitems.addorupdateblocklistitemstotextblocklist + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/AnalyzeImage.java b/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/AnalyzeImage.java new file mode 100644 index 000000000000..f327bbf9950a --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/AnalyzeImage.java @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.contentsafety.generated; + +import com.azure.ai.contentsafety.ContentSafetyClient; +import com.azure.ai.contentsafety.ContentSafetyClientBuilder; +import com.azure.ai.contentsafety.models.AnalyzeImageOptions; +import com.azure.ai.contentsafety.models.AnalyzeImageResult; +import com.azure.ai.contentsafety.models.ContentSafetyImageData; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class AnalyzeImage { + public static void main(String[] args) { + ContentSafetyClient contentSafetyClient + = new ContentSafetyClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildClient(); + // BEGIN:com.azure.ai.contentsafety.generated.analyzeimage.analyzeimage + AnalyzeImageResult response = contentSafetyClient + .analyzeImage(new AnalyzeImageOptions(new ContentSafetyImageData().setContent("Y29udGVudDE=".getBytes()))); + // END:com.azure.ai.contentsafety.generated.analyzeimage.analyzeimage + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/AnalyzeText.java b/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/AnalyzeText.java new file mode 100644 index 000000000000..4ddd4133d603 --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/AnalyzeText.java @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.contentsafety.generated; + +import com.azure.ai.contentsafety.ContentSafetyClient; +import com.azure.ai.contentsafety.ContentSafetyClientBuilder; +import com.azure.ai.contentsafety.models.AnalyzeTextOptions; +import com.azure.ai.contentsafety.models.AnalyzeTextResult; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class AnalyzeText { + public static void main(String[] args) { + ContentSafetyClient contentSafetyClient + = new ContentSafetyClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildClient(); + // BEGIN:com.azure.ai.contentsafety.generated.analyzetext.analyzetext + AnalyzeTextResult response = contentSafetyClient.analyzeText(new AnalyzeTextOptions("This is text example")); + // END:com.azure.ai.contentsafety.generated.analyzetext.analyzetext + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/CreateOrUpdateTextBlocklist.java b/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/CreateOrUpdateTextBlocklist.java new file mode 100644 index 000000000000..f47f39979bfe --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/CreateOrUpdateTextBlocklist.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.contentsafety.generated; + +import com.azure.ai.contentsafety.BlocklistClient; +import com.azure.ai.contentsafety.BlocklistClientBuilder; +import com.azure.ai.contentsafety.models.TextBlocklist; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class CreateOrUpdateTextBlocklist { + public static void main(String[] args) { + BlocklistClient blocklistClient + = new BlocklistClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildClient(); + // BEGIN:com.azure.ai.contentsafety.generated.createorupdatetextblocklist.createorupdatetextblocklist + TextBlocklist response = blocklistClient.createOrUpdateTextBlocklist("TestBlocklist", null); + // END:com.azure.ai.contentsafety.generated.createorupdatetextblocklist.createorupdatetextblocklist + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/DeleteTextBlocklistByBlocklistName.java b/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/DeleteTextBlocklistByBlocklistName.java new file mode 100644 index 000000000000..f1c6528fd62b --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/DeleteTextBlocklistByBlocklistName.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.contentsafety.generated; + +import com.azure.ai.contentsafety.BlocklistClient; +import com.azure.ai.contentsafety.BlocklistClientBuilder; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class DeleteTextBlocklistByBlocklistName { + public static void main(String[] args) { + BlocklistClient blocklistClient + = new BlocklistClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildClient(); + // BEGIN:com.azure.ai.contentsafety.generated.deletetextblocklist.deletetextblocklistbyblocklistname + blocklistClient.deleteTextBlocklist("TestBlocklist"); + // END:com.azure.ai.contentsafety.generated.deletetextblocklist.deletetextblocklistbyblocklistname + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/GetAllBlockItemsByBlocklistName.java b/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/GetAllBlockItemsByBlocklistName.java new file mode 100644 index 000000000000..8ee6c66287dc --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/GetAllBlockItemsByBlocklistName.java @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.contentsafety.generated; + +import com.azure.ai.contentsafety.BlocklistClient; +import com.azure.ai.contentsafety.BlocklistClientBuilder; +import com.azure.ai.contentsafety.models.TextBlocklistItem; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class GetAllBlockItemsByBlocklistName { + public static void main(String[] args) { + BlocklistClient blocklistClient + = new BlocklistClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildClient(); + // BEGIN:com.azure.ai.contentsafety.generated.listtextblocklistitems.getallblockitemsbyblocklistname + PagedIterable response = blocklistClient.listTextBlocklistItems("TestBlocklist", null, null); + // END:com.azure.ai.contentsafety.generated.listtextblocklistitems.getallblockitemsbyblocklistname + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/GetAllTextBlocklists.java b/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/GetAllTextBlocklists.java new file mode 100644 index 000000000000..405390c3e731 --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/GetAllTextBlocklists.java @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.contentsafety.generated; + +import com.azure.ai.contentsafety.BlocklistClient; +import com.azure.ai.contentsafety.BlocklistClientBuilder; +import com.azure.ai.contentsafety.models.TextBlocklist; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class GetAllTextBlocklists { + public static void main(String[] args) { + BlocklistClient blocklistClient + = new BlocklistClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildClient(); + // BEGIN:com.azure.ai.contentsafety.generated.listtextblocklists.getalltextblocklists + PagedIterable response = blocklistClient.listTextBlocklists(); + // END:com.azure.ai.contentsafety.generated.listtextblocklists.getalltextblocklists + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/GetBlockItemByBlocklistNameAndBlocklistItemId.java b/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/GetBlockItemByBlocklistNameAndBlocklistItemId.java new file mode 100644 index 000000000000..53952af80a76 --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/GetBlockItemByBlocklistNameAndBlocklistItemId.java @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.contentsafety.generated; + +import com.azure.ai.contentsafety.BlocklistClient; +import com.azure.ai.contentsafety.BlocklistClientBuilder; +import com.azure.ai.contentsafety.models.TextBlocklistItem; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class GetBlockItemByBlocklistNameAndBlocklistItemId { + public static void main(String[] args) { + BlocklistClient blocklistClient + = new BlocklistClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildClient(); + // BEGIN:com.azure.ai.contentsafety.generated.gettextblocklistitem.getblockitembyblocklistnameandblocklistitemid + TextBlocklistItem response + = blocklistClient.getTextBlocklistItem("TestBlocklist", "9511969e-f1e3-4604-9127-05ee16c509ec"); + // END:com.azure.ai.contentsafety.generated.gettextblocklistitem.getblockitembyblocklistnameandblocklistitemid + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/GetTextBlocklistByBlocklistName.java b/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/GetTextBlocklistByBlocklistName.java new file mode 100644 index 000000000000..dffde09f029c --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/GetTextBlocklistByBlocklistName.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.contentsafety.generated; + +import com.azure.ai.contentsafety.BlocklistClient; +import com.azure.ai.contentsafety.BlocklistClientBuilder; +import com.azure.ai.contentsafety.models.TextBlocklist; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class GetTextBlocklistByBlocklistName { + public static void main(String[] args) { + BlocklistClient blocklistClient + = new BlocklistClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildClient(); + // BEGIN:com.azure.ai.contentsafety.generated.gettextblocklist.gettextblocklistbyblocklistname + TextBlocklist response = blocklistClient.getTextBlocklist("TestBlocklist"); + // END:com.azure.ai.contentsafety.generated.gettextblocklist.gettextblocklistbyblocklistname + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/RemoveBlockItemsFromTextBlocklist.java b/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/RemoveBlockItemsFromTextBlocklist.java new file mode 100644 index 000000000000..a1f3a019d943 --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/RemoveBlockItemsFromTextBlocklist.java @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.contentsafety.generated; + +import com.azure.ai.contentsafety.BlocklistClient; +import com.azure.ai.contentsafety.BlocklistClientBuilder; +import com.azure.ai.contentsafety.models.RemoveTextBlocklistItemsOptions; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.util.Arrays; + +public class RemoveBlockItemsFromTextBlocklist { + public static void main(String[] args) { + BlocklistClient blocklistClient + = new BlocklistClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildClient(); + // BEGIN:com.azure.ai.contentsafety.generated.removeblocklistitems.removeblockitemsfromtextblocklist + blocklistClient.removeBlocklistItems("TestBlocklist", + new RemoveTextBlocklistItemsOptions(Arrays.asList("9511969e-f1e3-4604-9127-05ee16c509ec"))); + // END:com.azure.ai.contentsafety.generated.removeblocklistitems.removeblockitemsfromtextblocklist + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/AddOrUpdateBlocklistItemsToTextBlocklistTests.java b/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/AddOrUpdateBlocklistItemsToTextBlocklistTests.java new file mode 100644 index 000000000000..fd0c7af81753 --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/AddOrUpdateBlocklistItemsToTextBlocklistTests.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.contentsafety.generated; + +import com.azure.ai.contentsafety.models.AddOrUpdateTextBlocklistItemsOptions; +import com.azure.ai.contentsafety.models.AddOrUpdateTextBlocklistItemsResult; +import com.azure.ai.contentsafety.models.TextBlocklistItem; +import java.util.Arrays; +import java.util.List; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class AddOrUpdateBlocklistItemsToTextBlocklistTests extends ContentSafetyClientTestBase { + @Test + @Disabled + public void testAddOrUpdateBlocklistItemsToTextBlocklistTests() { + // method invocation + AddOrUpdateTextBlocklistItemsResult response + = blocklistClient.addOrUpdateBlocklistItems("TestBlocklist", new AddOrUpdateTextBlocklistItemsOptions( + Arrays.asList(new TextBlocklistItem("hate").setDescription("Hate word")))); + + // response assertion + Assertions.assertNotNull(response); + // verify property "blocklistItems" + List responseBlocklistItems = response.getBlocklistItems(); + TextBlocklistItem responseBlocklistItemsFirstItem = responseBlocklistItems.iterator().next(); + Assertions.assertNotNull(responseBlocklistItemsFirstItem); + Assertions.assertEquals("9511969e-f1e3-4604-9127-05ee16c509ec", + responseBlocklistItemsFirstItem.getBlocklistItemId()); + Assertions.assertEquals("Hate word", responseBlocklistItemsFirstItem.getDescription()); + Assertions.assertEquals("hate", responseBlocklistItemsFirstItem.getText()); + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/AnalyzeImageTests.java b/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/AnalyzeImageTests.java new file mode 100644 index 000000000000..a446b0492030 --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/AnalyzeImageTests.java @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.contentsafety.generated; + +import com.azure.ai.contentsafety.models.AnalyzeImageOptions; +import com.azure.ai.contentsafety.models.AnalyzeImageResult; +import com.azure.ai.contentsafety.models.ContentSafetyImageData; +import com.azure.ai.contentsafety.models.ImageCategoriesAnalysis; +import com.azure.ai.contentsafety.models.ImageCategory; +import java.util.List; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class AnalyzeImageTests extends ContentSafetyClientTestBase { + @Test + @Disabled + public void testAnalyzeImageTests() { + // method invocation + AnalyzeImageResult response = contentSafetyClient + .analyzeImage(new AnalyzeImageOptions(new ContentSafetyImageData().setContent("Y29udGVudDE=".getBytes()))); + + // response assertion + Assertions.assertNotNull(response); + // verify property "categoriesAnalysis" + List responseCategoriesAnalysis = response.getCategoriesAnalysis(); + ImageCategoriesAnalysis responseCategoriesAnalysisFirstItem = responseCategoriesAnalysis.iterator().next(); + Assertions.assertNotNull(responseCategoriesAnalysisFirstItem); + Assertions.assertEquals(ImageCategory.HATE, responseCategoriesAnalysisFirstItem.getCategory()); + Assertions.assertEquals(0, responseCategoriesAnalysisFirstItem.getSeverity()); + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/AnalyzeTextTests.java b/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/AnalyzeTextTests.java new file mode 100644 index 000000000000..1337f14af98c --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/AnalyzeTextTests.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.contentsafety.generated; + +import com.azure.ai.contentsafety.models.AnalyzeTextOptions; +import com.azure.ai.contentsafety.models.AnalyzeTextResult; +import com.azure.ai.contentsafety.models.TextBlocklistMatch; +import com.azure.ai.contentsafety.models.TextCategoriesAnalysis; +import com.azure.ai.contentsafety.models.TextCategory; +import java.util.List; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class AnalyzeTextTests extends ContentSafetyClientTestBase { + @Test + @Disabled + public void testAnalyzeTextTests() { + // method invocation + AnalyzeTextResult response = contentSafetyClient.analyzeText(new AnalyzeTextOptions("This is text example")); + + // response assertion + Assertions.assertNotNull(response); + // verify property "blocklistsMatch" + List responseBlocklistsMatch = response.getBlocklistsMatch(); + Assertions.assertEquals(0, responseBlocklistsMatch.size()); + // verify property "categoriesAnalysis" + List responseCategoriesAnalysis = response.getCategoriesAnalysis(); + TextCategoriesAnalysis responseCategoriesAnalysisFirstItem = responseCategoriesAnalysis.iterator().next(); + Assertions.assertNotNull(responseCategoriesAnalysisFirstItem); + Assertions.assertEquals(TextCategory.HATE, responseCategoriesAnalysisFirstItem.getCategory()); + Assertions.assertEquals(0, responseCategoriesAnalysisFirstItem.getSeverity()); + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/ContentSafetyClientTestBase.java b/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/ContentSafetyClientTestBase.java new file mode 100644 index 000000000000..ba5bcb72dfbe --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/ContentSafetyClientTestBase.java @@ -0,0 +1,64 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.contentsafety.generated; + +// The Java test files under 'generated' package are generated for your reference. +// If you wish to modify these files, please copy them out of the 'generated' package, and modify there. +// See https://aka.ms/azsdk/dpg/java/tests for guide on adding a test. + +import com.azure.ai.contentsafety.BlocklistClient; +import com.azure.ai.contentsafety.BlocklistClientBuilder; +import com.azure.ai.contentsafety.ContentSafetyClient; +import com.azure.ai.contentsafety.ContentSafetyClientBuilder; +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.http.policy.HttpLogDetailLevel; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.test.TestMode; +import com.azure.core.test.TestProxyTestBase; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.time.OffsetDateTime; +import reactor.core.publisher.Mono; + +class ContentSafetyClientTestBase extends TestProxyTestBase { + protected ContentSafetyClient contentSafetyClient; + + protected BlocklistClient blocklistClient; + + @Override + protected void beforeTest() { + ContentSafetyClientBuilder contentSafetyClientbuilder = new ContentSafetyClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + contentSafetyClientbuilder.httpClient(interceptorManager.getPlaybackClient()) + .credential(request -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX))); + } else if (getTestMode() == TestMode.RECORD) { + contentSafetyClientbuilder.addPolicy(interceptorManager.getRecordPolicy()) + .credential(new DefaultAzureCredentialBuilder().build()); + } else if (getTestMode() == TestMode.LIVE) { + contentSafetyClientbuilder.credential(new DefaultAzureCredentialBuilder().build()); + } + contentSafetyClient = contentSafetyClientbuilder.buildClient(); + + BlocklistClientBuilder blocklistClientbuilder + = new BlocklistClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + blocklistClientbuilder.httpClient(interceptorManager.getPlaybackClient()) + .credential(request -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX))); + } else if (getTestMode() == TestMode.RECORD) { + blocklistClientbuilder.addPolicy(interceptorManager.getRecordPolicy()) + .credential(new DefaultAzureCredentialBuilder().build()); + } else if (getTestMode() == TestMode.LIVE) { + blocklistClientbuilder.credential(new DefaultAzureCredentialBuilder().build()); + } + blocklistClient = blocklistClientbuilder.buildClient(); + + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/CreateOrUpdateTextBlocklistTests.java b/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/CreateOrUpdateTextBlocklistTests.java new file mode 100644 index 000000000000..ca15af68345b --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/CreateOrUpdateTextBlocklistTests.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.contentsafety.generated; + +import com.azure.ai.contentsafety.models.TextBlocklist; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class CreateOrUpdateTextBlocklistTests extends ContentSafetyClientTestBase { + @Test + @Disabled + public void testCreateOrUpdateTextBlocklistTests() { + // method invocation + TextBlocklist response = blocklistClient.createOrUpdateTextBlocklist("TestBlocklist", null); + + // response assertion + Assertions.assertNotNull(response); + // verify property "name" + Assertions.assertEquals("TestBlocklist", response.getName()); + // verify property "description" + Assertions.assertEquals("Test Blocklist", response.getDescription()); + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/DeleteTextBlocklistByBlocklistNameTests.java b/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/DeleteTextBlocklistByBlocklistNameTests.java new file mode 100644 index 000000000000..715435bc0e75 --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/DeleteTextBlocklistByBlocklistNameTests.java @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.contentsafety.generated; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class DeleteTextBlocklistByBlocklistNameTests extends ContentSafetyClientTestBase { + @Test + @Disabled + public void testDeleteTextBlocklistByBlocklistNameTests() { + // method invocation + blocklistClient.deleteTextBlocklist("TestBlocklist"); + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/GetAllBlockItemsByBlocklistNameTests.java b/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/GetAllBlockItemsByBlocklistNameTests.java new file mode 100644 index 000000000000..9203586bee92 --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/GetAllBlockItemsByBlocklistNameTests.java @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.contentsafety.generated; + +import com.azure.ai.contentsafety.models.TextBlocklistItem; +import com.azure.core.http.rest.PagedIterable; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class GetAllBlockItemsByBlocklistNameTests extends ContentSafetyClientTestBase { + @Test + @Disabled + public void testGetAllBlockItemsByBlocklistNameTests() { + // method invocation + PagedIterable response = blocklistClient.listTextBlocklistItems("TestBlocklist", null, null); + + // response assertion + Assertions.assertEquals(200, response.iterableByPage().iterator().next().getStatusCode()); + TextBlocklistItem firstItem = response.iterator().next(); + Assertions.assertNotNull(firstItem); + // verify property "blocklistItemId" + Assertions.assertEquals("9511969e-f1e3-4604-9127-05ee16c509ec", firstItem.getBlocklistItemId()); + // verify property "description" + Assertions.assertEquals("Hate word", firstItem.getDescription()); + // verify property "text" + Assertions.assertEquals("hate", firstItem.getText()); + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/GetAllTextBlocklistsTests.java b/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/GetAllTextBlocklistsTests.java new file mode 100644 index 000000000000..6a4fe707d129 --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/GetAllTextBlocklistsTests.java @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.contentsafety.generated; + +import com.azure.ai.contentsafety.models.TextBlocklist; +import com.azure.core.http.rest.PagedIterable; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class GetAllTextBlocklistsTests extends ContentSafetyClientTestBase { + @Test + @Disabled + public void testGetAllTextBlocklistsTests() { + // method invocation + PagedIterable response = blocklistClient.listTextBlocklists(); + + // response assertion + Assertions.assertEquals(200, response.iterableByPage().iterator().next().getStatusCode()); + TextBlocklist firstItem = response.iterator().next(); + Assertions.assertNotNull(firstItem); + // verify property "name" + Assertions.assertEquals("TestBlocklist", firstItem.getName()); + // verify property "description" + Assertions.assertEquals("Test Blocklist", firstItem.getDescription()); + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/GetBlockItemByBlocklistNameAndBlocklistItemIdTests.java b/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/GetBlockItemByBlocklistNameAndBlocklistItemIdTests.java new file mode 100644 index 000000000000..9b2dc1496378 --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/GetBlockItemByBlocklistNameAndBlocklistItemIdTests.java @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.contentsafety.generated; + +import com.azure.ai.contentsafety.models.TextBlocklistItem; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class GetBlockItemByBlocklistNameAndBlocklistItemIdTests extends ContentSafetyClientTestBase { + @Test + @Disabled + public void testGetBlockItemByBlocklistNameAndBlocklistItemIdTests() { + // method invocation + TextBlocklistItem response + = blocklistClient.getTextBlocklistItem("TestBlocklist", "9511969e-f1e3-4604-9127-05ee16c509ec"); + + // response assertion + Assertions.assertNotNull(response); + // verify property "blocklistItemId" + Assertions.assertEquals("9511969e-f1e3-4604-9127-05ee16c509ec", response.getBlocklistItemId()); + // verify property "description" + Assertions.assertEquals("Hate word", response.getDescription()); + // verify property "text" + Assertions.assertEquals("hate", response.getText()); + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/GetTextBlocklistByBlocklistNameTests.java b/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/GetTextBlocklistByBlocklistNameTests.java new file mode 100644 index 000000000000..e1d67c5d9515 --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/GetTextBlocklistByBlocklistNameTests.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.contentsafety.generated; + +import com.azure.ai.contentsafety.models.TextBlocklist; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class GetTextBlocklistByBlocklistNameTests extends ContentSafetyClientTestBase { + @Test + @Disabled + public void testGetTextBlocklistByBlocklistNameTests() { + // method invocation + TextBlocklist response = blocklistClient.getTextBlocklist("TestBlocklist"); + + // response assertion + Assertions.assertNotNull(response); + // verify property "name" + Assertions.assertEquals("TestBlocklist", response.getName()); + // verify property "description" + Assertions.assertEquals("Test Blocklist", response.getDescription()); + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/RemoveBlockItemsFromTextBlocklistTests.java b/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/RemoveBlockItemsFromTextBlocklistTests.java new file mode 100644 index 000000000000..d639989619bb --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/RemoveBlockItemsFromTextBlocklistTests.java @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.contentsafety.generated; + +import com.azure.ai.contentsafety.models.RemoveTextBlocklistItemsOptions; +import java.util.Arrays; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class RemoveBlockItemsFromTextBlocklistTests extends ContentSafetyClientTestBase { + @Test + @Disabled + public void testRemoveBlockItemsFromTextBlocklistTests() { + // method invocation + blocklistClient.removeBlocklistItems("TestBlocklist", + new RemoveTextBlocklistItemsOptions(Arrays.asList("9511969e-f1e3-4604-9127-05ee16c509ec"))); + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/tsp-location.yaml b/sdk/contentsafety/azure-ai-contentsafety/tsp-location.yaml index 9ac15f28adb7..5c077612c03f 100644 --- a/sdk/contentsafety/azure-ai-contentsafety/tsp-location.yaml +++ b/sdk/contentsafety/azure-ai-contentsafety/tsp-location.yaml @@ -1,4 +1,4 @@ directory: specification/cognitiveservices/ContentSafety -commit: df3cd3e3d50eec1d1da593750e1ea3a4db3f541d -additionalDirectories: [] +commit: 274e6bec630de1762940d0f33adf105db3e42ebe repo: Azure/azure-rest-api-specs +additionalDirectories: \ No newline at end of file