diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/BlocklistAsyncClient.java b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/BlocklistAsyncClient.java new file mode 100644 index 000000000000..0605c32ed4fe --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/BlocklistAsyncClient.java @@ -0,0 +1,561 @@ +// 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; + +import com.azure.ai.contentsafety.implementation.BlocklistClientImpl; +import com.azure.ai.contentsafety.models.AddOrUpdateTextBlocklistItemsOptions; +import com.azure.ai.contentsafety.models.AddOrUpdateTextBlocklistItemsResult; +import com.azure.ai.contentsafety.models.RemoveTextBlocklistItemsOptions; +import com.azure.ai.contentsafety.models.TextBlocklist; +import com.azure.ai.contentsafety.models.TextBlocklistItem; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.FluxUtil; +import java.util.stream.Collectors; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous BlocklistClient type. + */ +@ServiceClient(builder = BlocklistClientBuilder.class, isAsync = true) +public final class BlocklistAsyncClient { + @Generated + private final BlocklistClientImpl serviceClient; + + /** + * Initializes an instance of BlocklistAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + BlocklistAsyncClient(BlocklistClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Add or update BlocklistItems To Text Blocklist + * + * Add or update blocklistItems to a text blocklist. You can add or update at most 100 blocklistItems in one + * request. + *

+ * Request Body Schema + *

+ *
{@code
+     * {
+     *     blocklistItems (Required): [
+     *          (Required){
+     *             blocklistItemId: String (Required)
+     *             description: String (Optional)
+     *             text: String (Required)
+     *         }
+     *     ]
+     * }
+     * }
+ *

+ * Response Body Schema + *

+ *
{@code
+     * {
+     *     blocklistItems (Required): [
+     *          (Required){
+     *             blocklistItemId: String (Required)
+     *             description: String (Optional)
+     *             text: String (Required)
+     *         }
+     *     ]
+     * }
+     * }
+ * + * @param name Text blocklist name. + * @param options Options for adding or updating blocklist items. + * @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 response of adding blocklistItems to the text blocklist along with {@link Response} on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> addOrUpdateBlocklistItemsWithResponse(String name, BinaryData options, + RequestOptions requestOptions) { + return this.serviceClient.addOrUpdateBlocklistItemsWithResponseAsync(name, options, requestOptions); + } + + /** + * Create Or Update Text Blocklist + * + * Updates a text blocklist. If the blocklistName does not exist, a new blocklist will be created. + *

+ * Request Body Schema + *

+ *
{@code
+     * {
+     *     blocklistName: String (Required)
+     *     description: String (Optional)
+     * }
+     * }
+ *

+ * Response Body Schema + *

+ *
{@code
+     * {
+     *     blocklistName: String (Required)
+     *     description: String (Optional)
+     * }
+     * }
+ * + * @param name Text blocklist name. + * @param options The resource instance. + * @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 text Blocklist along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createOrUpdateTextBlocklistWithResponse(String name, BinaryData options, + RequestOptions requestOptions) { + // Convenience API is not generated, as operation 'createOrUpdateTextBlocklist' is + // 'application/merge-patch+json' + return this.serviceClient.createOrUpdateTextBlocklistWithResponseAsync(name, options, requestOptions); + } + + /** + * Delete Text Blocklist By blocklistName + * + * Deletes a text blocklist. + * + * @param name Text blocklist name. + * @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 {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteTextBlocklistWithResponse(String name, RequestOptions requestOptions) { + return this.serviceClient.deleteTextBlocklistWithResponseAsync(name, requestOptions); + } + + /** + * Get Text Blocklist By blocklistName + * + * Returns text blocklist details. + *

+ * Response Body Schema + *

+ *
{@code
+     * {
+     *     blocklistName: String (Required)
+     *     description: String (Optional)
+     * }
+     * }
+ * + * @param name Text blocklist name. + * @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 text Blocklist along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getTextBlocklistWithResponse(String name, RequestOptions requestOptions) { + return this.serviceClient.getTextBlocklistWithResponseAsync(name, requestOptions); + } + + /** + * Get BlocklistItem By blocklistName And blocklistItemId + * + * Get blocklistItem by blocklistName and blocklistItemId from a text blocklist. + *

+ * Response Body Schema + *

+ *
{@code
+     * {
+     *     blocklistItemId: String (Required)
+     *     description: String (Optional)
+     *     text: String (Required)
+     * }
+     * }
+ * + * @param name Text blocklist name. + * @param blocklistItemId The service will generate a BlocklistItemId, which will be a UUID. + * @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 blocklistItem by blocklistName and blocklistItemId from a text blocklist along with {@link Response} on + * successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getTextBlocklistItemWithResponse(String name, String blocklistItemId, + RequestOptions requestOptions) { + return this.serviceClient.getTextBlocklistItemWithResponseAsync(name, blocklistItemId, requestOptions); + } + + /** + * Get All BlocklistItems By blocklistName + * + * Get all blocklistItems in a text blocklist. + *

+ * Query Parameters + *

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
topIntegerNoThe number of result items to return.
skipIntegerNoThe number of result items to skip.
maxpagesizeIntegerNoThe maximum number of result items per page.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

+ * Response Body Schema + *

+ *
{@code
+     * {
+     *     blocklistItemId: String (Required)
+     *     description: String (Optional)
+     *     text: String (Required)
+     * }
+     * }
+ * + * @param name Text blocklist name. + * @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 all blocklistItems in a text blocklist as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listTextBlocklistItems(String name, RequestOptions requestOptions) { + return this.serviceClient.listTextBlocklistItemsAsync(name, requestOptions); + } + + /** + * Get All Text Blocklists + * + * Get all text blocklists details. + *

+ * Response Body Schema + *

+ *
{@code
+     * {
+     *     blocklistName: String (Required)
+     *     description: String (Optional)
+     * }
+     * }
+ * + * @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 all text blocklists details as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listTextBlocklists(RequestOptions requestOptions) { + return this.serviceClient.listTextBlocklistsAsync(requestOptions); + } + + /** + * Remove BlocklistItems From Text Blocklist + * + * Remove blocklistItems from a text blocklist. You can remove at most 100 BlocklistItems in one request. + *

+ * Request Body Schema + *

+ *
{@code
+     * {
+     *     blocklistItemIds (Required): [
+     *         String (Required)
+     *     ]
+     * }
+     * }
+ * + * @param name Text blocklist name. + * @param options Options for removing blocklist items. + * @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 {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> removeBlocklistItemsWithResponse(String name, BinaryData options, + RequestOptions requestOptions) { + return this.serviceClient.removeBlocklistItemsWithResponseAsync(name, options, requestOptions); + } + + /** + * Add or update BlocklistItems To Text Blocklist + * + * Add or update blocklistItems to a text blocklist. You can add or update at most 100 blocklistItems in one + * request. + * + * @param name Text blocklist name. + * @param options Options for adding or updating blocklist items. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @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. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of adding blocklistItems to the text blocklist on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono addOrUpdateBlocklistItems(String name, + AddOrUpdateTextBlocklistItemsOptions options) { + // Generated convenience method for addOrUpdateBlocklistItemsWithResponse + RequestOptions requestOptions = new RequestOptions(); + return addOrUpdateBlocklistItemsWithResponse(name, BinaryData.fromObject(options), requestOptions) + .flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(AddOrUpdateTextBlocklistItemsResult.class)); + } + + /** + * Delete Text Blocklist By blocklistName + * + * Deletes a text blocklist. + * + * @param name Text blocklist name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @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. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono deleteTextBlocklist(String name) { + // Generated convenience method for deleteTextBlocklistWithResponse + RequestOptions requestOptions = new RequestOptions(); + return deleteTextBlocklistWithResponse(name, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Get Text Blocklist By blocklistName + * + * Returns text blocklist details. + * + * @param name Text blocklist name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @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. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return text Blocklist on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getTextBlocklist(String name) { + // Generated convenience method for getTextBlocklistWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getTextBlocklistWithResponse(name, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(TextBlocklist.class)); + } + + /** + * Get BlocklistItem By blocklistName And blocklistItemId + * + * Get blocklistItem by blocklistName and blocklistItemId from a text blocklist. + * + * @param name Text blocklist name. + * @param blocklistItemId The service will generate a BlocklistItemId, which will be a UUID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @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. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return blocklistItem by blocklistName and blocklistItemId from a text blocklist on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getTextBlocklistItem(String name, String blocklistItemId) { + // Generated convenience method for getTextBlocklistItemWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getTextBlocklistItemWithResponse(name, blocklistItemId, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(TextBlocklistItem.class)); + } + + /** + * Get All BlocklistItems By blocklistName + * + * Get all blocklistItems in a text blocklist. + * + * @param name Text blocklist name. + * @param top The number of result items to return. + * @param skip The number of result items to skip. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @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. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return all blocklistItems in a text blocklist as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listTextBlocklistItems(String name, Integer top, Integer skip) { + // Generated convenience method for listTextBlocklistItems + RequestOptions requestOptions = new RequestOptions(); + if (top != null) { + requestOptions.addQueryParam("top", String.valueOf(top), false); + } + if (skip != null) { + requestOptions.addQueryParam("skip", String.valueOf(skip), false); + } + PagedFlux pagedFluxResponse = listTextBlocklistItems(name, requestOptions); + return PagedFlux.create(() -> (continuationToken, pageSize) -> { + Flux> flux = (continuationToken == null) ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationToken).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue().stream() + .map(protocolMethodData -> protocolMethodData.toObject(TextBlocklistItem.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * Get All BlocklistItems By blocklistName + * + * Get all blocklistItems in a text blocklist. + * + * @param name Text blocklist name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @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. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return all blocklistItems in a text blocklist as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listTextBlocklistItems(String name) { + // Generated convenience method for listTextBlocklistItems + RequestOptions requestOptions = new RequestOptions(); + PagedFlux pagedFluxResponse = listTextBlocklistItems(name, requestOptions); + return PagedFlux.create(() -> (continuationToken, pageSize) -> { + Flux> flux = (continuationToken == null) ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationToken).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue().stream() + .map(protocolMethodData -> protocolMethodData.toObject(TextBlocklistItem.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * Get All Text Blocklists + * + * Get all text blocklists details. + * + * @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. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return all text blocklists details as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listTextBlocklists() { + // Generated convenience method for listTextBlocklists + RequestOptions requestOptions = new RequestOptions(); + PagedFlux pagedFluxResponse = listTextBlocklists(requestOptions); + return PagedFlux.create(() -> (continuationToken, pageSize) -> { + Flux> flux = (continuationToken == null) ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationToken).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue().stream() + .map(protocolMethodData -> protocolMethodData.toObject(TextBlocklist.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * Remove BlocklistItems From Text Blocklist + * + * Remove blocklistItems from a text blocklist. You can remove at most 100 BlocklistItems in one request. + * + * @param name Text blocklist name. + * @param options Options for removing blocklist items. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @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. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono removeBlocklistItems(String name, RemoveTextBlocklistItemsOptions options) { + // Generated convenience method for removeBlocklistItemsWithResponse + RequestOptions requestOptions = new RequestOptions(); + return removeBlocklistItemsWithResponse(name, BinaryData.fromObject(options), requestOptions) + .flatMap(FluxUtil::toMono); + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/BlocklistClient.java b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/BlocklistClient.java new file mode 100644 index 000000000000..c25ebe544f6f --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/BlocklistClient.java @@ -0,0 +1,520 @@ +// 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; + +import com.azure.ai.contentsafety.implementation.BlocklistClientImpl; +import com.azure.ai.contentsafety.models.AddOrUpdateTextBlocklistItemsOptions; +import com.azure.ai.contentsafety.models.AddOrUpdateTextBlocklistItemsResult; +import com.azure.ai.contentsafety.models.RemoveTextBlocklistItemsOptions; +import com.azure.ai.contentsafety.models.TextBlocklist; +import com.azure.ai.contentsafety.models.TextBlocklistItem; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; + +/** + * Initializes a new instance of the synchronous BlocklistClient type. + */ +@ServiceClient(builder = BlocklistClientBuilder.class) +public final class BlocklistClient { + @Generated + private final BlocklistClientImpl serviceClient; + + /** + * Initializes an instance of BlocklistClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + BlocklistClient(BlocklistClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Add or update BlocklistItems To Text Blocklist + * + * Add or update blocklistItems to a text blocklist. You can add or update at most 100 blocklistItems in one + * request. + *

+ * Request Body Schema + *

+ *
{@code
+     * {
+     *     blocklistItems (Required): [
+     *          (Required){
+     *             blocklistItemId: String (Required)
+     *             description: String (Optional)
+     *             text: String (Required)
+     *         }
+     *     ]
+     * }
+     * }
+ *

+ * Response Body Schema + *

+ *
{@code
+     * {
+     *     blocklistItems (Required): [
+     *          (Required){
+     *             blocklistItemId: String (Required)
+     *             description: String (Optional)
+     *             text: String (Required)
+     *         }
+     *     ]
+     * }
+     * }
+ * + * @param name Text blocklist name. + * @param options Options for adding or updating blocklist items. + * @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 response of adding blocklistItems to the text blocklist along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response addOrUpdateBlocklistItemsWithResponse(String name, BinaryData options, + RequestOptions requestOptions) { + return this.serviceClient.addOrUpdateBlocklistItemsWithResponse(name, options, requestOptions); + } + + /** + * Create Or Update Text Blocklist + * + * Updates a text blocklist. If the blocklistName does not exist, a new blocklist will be created. + *

+ * Request Body Schema + *

+ *
{@code
+     * {
+     *     blocklistName: String (Required)
+     *     description: String (Optional)
+     * }
+     * }
+ *

+ * Response Body Schema + *

+ *
{@code
+     * {
+     *     blocklistName: String (Required)
+     *     description: String (Optional)
+     * }
+     * }
+ * + * @param name Text blocklist name. + * @param options The resource instance. + * @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 text Blocklist along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createOrUpdateTextBlocklistWithResponse(String name, BinaryData options, + RequestOptions requestOptions) { + // Convenience API is not generated, as operation 'createOrUpdateTextBlocklist' is + // 'application/merge-patch+json' + return this.serviceClient.createOrUpdateTextBlocklistWithResponse(name, options, requestOptions); + } + + /** + * Delete Text Blocklist By blocklistName + * + * Deletes a text blocklist. + * + * @param name Text blocklist name. + * @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 {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteTextBlocklistWithResponse(String name, RequestOptions requestOptions) { + return this.serviceClient.deleteTextBlocklistWithResponse(name, requestOptions); + } + + /** + * Get Text Blocklist By blocklistName + * + * Returns text blocklist details. + *

+ * Response Body Schema + *

+ *
{@code
+     * {
+     *     blocklistName: String (Required)
+     *     description: String (Optional)
+     * }
+     * }
+ * + * @param name Text blocklist name. + * @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 text Blocklist along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getTextBlocklistWithResponse(String name, RequestOptions requestOptions) { + return this.serviceClient.getTextBlocklistWithResponse(name, requestOptions); + } + + /** + * Get BlocklistItem By blocklistName And blocklistItemId + * + * Get blocklistItem by blocklistName and blocklistItemId from a text blocklist. + *

+ * Response Body Schema + *

+ *
{@code
+     * {
+     *     blocklistItemId: String (Required)
+     *     description: String (Optional)
+     *     text: String (Required)
+     * }
+     * }
+ * + * @param name Text blocklist name. + * @param blocklistItemId The service will generate a BlocklistItemId, which will be a UUID. + * @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 blocklistItem by blocklistName and blocklistItemId from a text blocklist along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getTextBlocklistItemWithResponse(String name, String blocklistItemId, + RequestOptions requestOptions) { + return this.serviceClient.getTextBlocklistItemWithResponse(name, blocklistItemId, requestOptions); + } + + /** + * Get All BlocklistItems By blocklistName + * + * Get all blocklistItems in a text blocklist. + *

+ * Query Parameters + *

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
topIntegerNoThe number of result items to return.
skipIntegerNoThe number of result items to skip.
maxpagesizeIntegerNoThe maximum number of result items per page.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

+ * Response Body Schema + *

+ *
{@code
+     * {
+     *     blocklistItemId: String (Required)
+     *     description: String (Optional)
+     *     text: String (Required)
+     * }
+     * }
+ * + * @param name Text blocklist name. + * @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 all blocklistItems in a text blocklist as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listTextBlocklistItems(String name, RequestOptions requestOptions) { + return this.serviceClient.listTextBlocklistItems(name, requestOptions); + } + + /** + * Get All Text Blocklists + * + * Get all text blocklists details. + *

+ * Response Body Schema + *

+ *
{@code
+     * {
+     *     blocklistName: String (Required)
+     *     description: String (Optional)
+     * }
+     * }
+ * + * @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 all text blocklists details as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listTextBlocklists(RequestOptions requestOptions) { + return this.serviceClient.listTextBlocklists(requestOptions); + } + + /** + * Remove BlocklistItems From Text Blocklist + * + * Remove blocklistItems from a text blocklist. You can remove at most 100 BlocklistItems in one request. + *

+ * Request Body Schema + *

+ *
{@code
+     * {
+     *     blocklistItemIds (Required): [
+     *         String (Required)
+     *     ]
+     * }
+     * }
+ * + * @param name Text blocklist name. + * @param options Options for removing blocklist items. + * @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 {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response removeBlocklistItemsWithResponse(String name, BinaryData options, + RequestOptions requestOptions) { + return this.serviceClient.removeBlocklistItemsWithResponse(name, options, requestOptions); + } + + /** + * Add or update BlocklistItems To Text Blocklist + * + * Add or update blocklistItems to a text blocklist. You can add or update at most 100 blocklistItems in one + * request. + * + * @param name Text blocklist name. + * @param options Options for adding or updating blocklist items. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @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. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of adding blocklistItems to the text blocklist. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public AddOrUpdateTextBlocklistItemsResult addOrUpdateBlocklistItems(String name, + AddOrUpdateTextBlocklistItemsOptions options) { + // Generated convenience method for addOrUpdateBlocklistItemsWithResponse + RequestOptions requestOptions = new RequestOptions(); + return addOrUpdateBlocklistItemsWithResponse(name, BinaryData.fromObject(options), requestOptions).getValue() + .toObject(AddOrUpdateTextBlocklistItemsResult.class); + } + + /** + * Delete Text Blocklist By blocklistName + * + * Deletes a text blocklist. + * + * @param name Text blocklist name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @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. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void deleteTextBlocklist(String name) { + // Generated convenience method for deleteTextBlocklistWithResponse + RequestOptions requestOptions = new RequestOptions(); + deleteTextBlocklistWithResponse(name, requestOptions).getValue(); + } + + /** + * Get Text Blocklist By blocklistName + * + * Returns text blocklist details. + * + * @param name Text blocklist name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @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. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return text Blocklist. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public TextBlocklist getTextBlocklist(String name) { + // Generated convenience method for getTextBlocklistWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getTextBlocklistWithResponse(name, requestOptions).getValue().toObject(TextBlocklist.class); + } + + /** + * Get BlocklistItem By blocklistName And blocklistItemId + * + * Get blocklistItem by blocklistName and blocklistItemId from a text blocklist. + * + * @param name Text blocklist name. + * @param blocklistItemId The service will generate a BlocklistItemId, which will be a UUID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @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. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return blocklistItem by blocklistName and blocklistItemId from a text blocklist. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public TextBlocklistItem getTextBlocklistItem(String name, String blocklistItemId) { + // Generated convenience method for getTextBlocklistItemWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getTextBlocklistItemWithResponse(name, blocklistItemId, requestOptions).getValue() + .toObject(TextBlocklistItem.class); + } + + /** + * Get All BlocklistItems By blocklistName + * + * Get all blocklistItems in a text blocklist. + * + * @param name Text blocklist name. + * @param top The number of result items to return. + * @param skip The number of result items to skip. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @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. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return all blocklistItems in a text blocklist as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listTextBlocklistItems(String name, Integer top, Integer skip) { + // Generated convenience method for listTextBlocklistItems + RequestOptions requestOptions = new RequestOptions(); + if (top != null) { + requestOptions.addQueryParam("top", String.valueOf(top), false); + } + if (skip != null) { + requestOptions.addQueryParam("skip", String.valueOf(skip), false); + } + return serviceClient.listTextBlocklistItems(name, requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(TextBlocklistItem.class)); + } + + /** + * Get All BlocklistItems By blocklistName + * + * Get all blocklistItems in a text blocklist. + * + * @param name Text blocklist name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @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. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return all blocklistItems in a text blocklist as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listTextBlocklistItems(String name) { + // Generated convenience method for listTextBlocklistItems + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.listTextBlocklistItems(name, requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(TextBlocklistItem.class)); + } + + /** + * Get All Text Blocklists + * + * Get all text blocklists details. + * + * @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. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return all text blocklists details as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listTextBlocklists() { + // Generated convenience method for listTextBlocklists + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.listTextBlocklists(requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(TextBlocklist.class)); + } + + /** + * Remove BlocklistItems From Text Blocklist + * + * Remove blocklistItems from a text blocklist. You can remove at most 100 BlocklistItems in one request. + * + * @param name Text blocklist name. + * @param options Options for removing blocklist items. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @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. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void removeBlocklistItems(String name, RemoveTextBlocklistItemsOptions options) { + // Generated convenience method for removeBlocklistItemsWithResponse + RequestOptions requestOptions = new RequestOptions(); + removeBlocklistItemsWithResponse(name, BinaryData.fromObject(options), requestOptions).getValue(); + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/BlocklistClientBuilder.java b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/BlocklistClientBuilder.java new file mode 100644 index 000000000000..78c3bba6e606 --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/BlocklistClientBuilder.java @@ -0,0 +1,346 @@ +// 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; + +import com.azure.ai.contentsafety.implementation.BlocklistClientImpl; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ServiceClientBuilder; +import com.azure.core.client.traits.ConfigurationTrait; +import com.azure.core.client.traits.EndpointTrait; +import com.azure.core.client.traits.HttpTrait; +import com.azure.core.client.traits.KeyCredentialTrait; +import com.azure.core.client.traits.TokenCredentialTrait; +import com.azure.core.credential.KeyCredential; +import com.azure.core.credential.TokenCredential; +import com.azure.core.http.HttpClient; +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.HttpPipelinePosition; +import com.azure.core.http.policy.AddDatePolicy; +import com.azure.core.http.policy.AddHeadersFromContextPolicy; +import com.azure.core.http.policy.AddHeadersPolicy; +import com.azure.core.http.policy.BearerTokenAuthenticationPolicy; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.http.policy.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpPipelinePolicy; +import com.azure.core.http.policy.HttpPolicyProviders; +import com.azure.core.http.policy.KeyCredentialPolicy; +import com.azure.core.http.policy.RequestIdPolicy; +import com.azure.core.http.policy.RetryOptions; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.util.ClientOptions; +import com.azure.core.util.Configuration; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.builder.ClientBuilderUtil; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.serializer.JacksonAdapter; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the BlocklistClient type. + */ +@ServiceClientBuilder(serviceClients = { BlocklistClient.class, BlocklistAsyncClient.class }) +public final class BlocklistClientBuilder implements HttpTrait, + ConfigurationTrait, TokenCredentialTrait, + KeyCredentialTrait, EndpointTrait { + @Generated + private static final String SDK_NAME = "name"; + + @Generated + private static final String SDK_VERSION = "version"; + + @Generated + private static final String[] DEFAULT_SCOPES = new String[] { "https://cognitiveservices.azure.com/.default" }; + + @Generated + private static final Map PROPERTIES = CoreUtils.getProperties("azure-ai-contentsafety.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the BlocklistClientBuilder. + */ + @Generated + public BlocklistClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BlocklistClientBuilder pipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.info("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BlocklistClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BlocklistClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The client options such as application ID and custom headers to set on a request. + */ + @Generated + private ClientOptions clientOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BlocklistClientBuilder clientOptions(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Generated + private RetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BlocklistClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BlocklistClientBuilder addPolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Generated + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BlocklistClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The TokenCredential used for authentication. + */ + @Generated + private TokenCredential tokenCredential; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BlocklistClientBuilder credential(TokenCredential tokenCredential) { + this.tokenCredential = tokenCredential; + return this; + } + + /* + * The KeyCredential used for authentication. + */ + @Generated + private KeyCredential keyCredential; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BlocklistClientBuilder credential(KeyCredential keyCredential) { + this.keyCredential = keyCredential; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BlocklistClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Service version + */ + @Generated + private ContentSafetyServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the BlocklistClientBuilder. + */ + @Generated + public BlocklistClientBuilder serviceVersion(ContentSafetyServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + return this; + } + + /* + * The retry policy that will attempt to retry failed requests, if applicable. + */ + @Generated + private RetryPolicy retryPolicy; + + /** + * Sets The retry policy that will attempt to retry failed requests, if applicable. + * + * @param retryPolicy the retryPolicy value. + * @return the BlocklistClientBuilder. + */ + @Generated + public BlocklistClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of BlocklistClientImpl with the provided parameters. + * + * @return an instance of BlocklistClientImpl. + */ + @Generated + private BlocklistClientImpl buildInnerClient() { + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + ContentSafetyServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : ContentSafetyServiceVersion.getLatest(); + BlocklistClientImpl client = new BlocklistClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint, localServiceVersion); + return client; + } + + @Generated + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + ClientOptions localClientOptions = this.clientOptions == null ? new ClientOptions() : this.clientOptions; + List policies = new ArrayList<>(); + String clientName = PROPERTIES.getOrDefault(SDK_NAME, "UnknownName"); + String clientVersion = PROPERTIES.getOrDefault(SDK_VERSION, "UnknownVersion"); + String applicationId = CoreUtils.getApplicationId(localClientOptions, localHttpLogOptions); + policies.add(new UserAgentPolicy(applicationId, clientName, clientVersion, buildConfiguration)); + policies.add(new RequestIdPolicy()); + policies.add(new AddHeadersFromContextPolicy()); + HttpHeaders headers = new HttpHeaders(); + localClientOptions.getHeaders() + .forEach(header -> headers.set(HttpHeaderName.fromString(header.getName()), header.getValue())); + if (headers.getSize() > 0) { + policies.add(new AddHeadersPolicy(headers)); + } + this.pipelinePolicies.stream().filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) + .forEach(p -> policies.add(p)); + HttpPolicyProviders.addBeforeRetryPolicies(policies); + policies.add(ClientBuilderUtil.validateAndGetRetryPolicy(retryPolicy, retryOptions, new RetryPolicy())); + policies.add(new AddDatePolicy()); + if (keyCredential != null) { + policies.add(new KeyCredentialPolicy("Ocp-Apim-Subscription-Key", keyCredential)); + } + if (tokenCredential != null) { + policies.add(new BearerTokenAuthenticationPolicy(tokenCredential, DEFAULT_SCOPES)); + } + this.pipelinePolicies.stream().filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) + .forEach(p -> policies.add(p)); + HttpPolicyProviders.addAfterRetryPolicies(policies); + policies.add(new HttpLoggingPolicy(httpLogOptions)); + HttpPipeline httpPipeline = new HttpPipelineBuilder().policies(policies.toArray(new HttpPipelinePolicy[0])) + .httpClient(httpClient).clientOptions(localClientOptions).build(); + return httpPipeline; + } + + /** + * Builds an instance of BlocklistAsyncClient class. + * + * @return an instance of BlocklistAsyncClient. + */ + @Generated + public BlocklistAsyncClient buildAsyncClient() { + return new BlocklistAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of BlocklistClient class. + * + * @return an instance of BlocklistClient. + */ + @Generated + public BlocklistClient buildClient() { + return new BlocklistClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(BlocklistClientBuilder.class); +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/ContentSafetyAsyncClient.java b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/ContentSafetyAsyncClient.java index f8d2ca6abb07..0658678a7f7e 100644 --- a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/ContentSafetyAsyncClient.java +++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/ContentSafetyAsyncClient.java @@ -5,15 +5,10 @@ package com.azure.ai.contentsafety; import com.azure.ai.contentsafety.implementation.ContentSafetyClientImpl; -import com.azure.ai.contentsafety.models.AddBlockItemsOptions; -import com.azure.ai.contentsafety.models.AddBlockItemsResult; import com.azure.ai.contentsafety.models.AnalyzeImageOptions; import com.azure.ai.contentsafety.models.AnalyzeImageResult; import com.azure.ai.contentsafety.models.AnalyzeTextOptions; import com.azure.ai.contentsafety.models.AnalyzeTextResult; -import com.azure.ai.contentsafety.models.RemoveBlockItemsOptions; -import com.azure.ai.contentsafety.models.TextBlockItem; -import com.azure.ai.contentsafety.models.TextBlocklist; import com.azure.core.annotation.Generated; import com.azure.core.annotation.ReturnType; import com.azure.core.annotation.ServiceClient; @@ -22,25 +17,23 @@ import com.azure.core.exception.HttpResponseException; import com.azure.core.exception.ResourceModifiedException; import com.azure.core.exception.ResourceNotFoundException; -import com.azure.core.http.rest.PagedFlux; -import com.azure.core.http.rest.PagedResponse; -import com.azure.core.http.rest.PagedResponseBase; import com.azure.core.http.rest.RequestOptions; import com.azure.core.http.rest.Response; import com.azure.core.util.BinaryData; import com.azure.core.util.FluxUtil; -import java.util.stream.Collectors; -import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; -/** Initializes a new instance of the asynchronous ContentSafetyClient type. */ +/** + * Initializes a new instance of the asynchronous ContentSafetyClient type. + */ @ServiceClient(builder = ContentSafetyClientBuilder.class, isAsync = true) public final class ContentSafetyAsyncClient { - @Generated private final ContentSafetyClientImpl serviceClient; + @Generated + private final ContentSafetyClientImpl serviceClient; /** * Initializes an instance of ContentSafetyAsyncClient class. - * + * * @param serviceClient the service client implementation. */ @Generated @@ -50,12 +43,12 @@ public final class ContentSafetyAsyncClient { /** * Analyze Text - * - *

A sync API for harmful content analysis for text. Currently, we support four categories: Hate, SelfHarm, - * Sexual, Violence. - * - *

Request Body Schema - * + * + * 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
      * {
      *     text: String (Required)
@@ -65,55 +58,53 @@ public final class ContentSafetyAsyncClient {
      *     blocklistNames (Optional): [
      *         String (Optional)
      *     ]
-     *     breakByBlocklists: Boolean (Optional)
+     *     haltOnBlocklistHit: Boolean (Optional)
+     *     outputType: String(FourSeverityLevels/EightSeverityLevels) (Optional)
      * }
      * }
- * - *

Response Body Schema - * + *

+ * Response Body Schema + *

*
{@code
      * {
-     *     blocklistsMatchResults (Optional): [
+     *     blocklistsMatch (Optional): [
      *          (Optional){
      *             blocklistName: String (Required)
-     *             blockItemId: String (Required)
-     *             blockItemText: String (Required)
-     *             offset: int (Required)
-     *             length: int (Required)
+     *             blocklistItemId: String (Required)
+     *             blocklistItemText: String (Required)
+     *         }
+     *     ]
+     *     categoriesAnalysis (Required): [
+     *          (Required){
+     *             category: String(Hate/SelfHarm/Sexual/Violence) (Required)
+     *             severity: Integer (Optional)
      *         }
      *     ]
-     *     hateResult (Optional): {
-     *         category: String(Hate/SelfHarm/Sexual/Violence) (Required)
-     *         severity: int (Required)
-     *     }
-     *     selfHarmResult (Optional): (recursive schema, see selfHarmResult above)
-     *     sexualResult (Optional): (recursive schema, see sexualResult above)
-     *     violenceResult (Optional): (recursive schema, see violenceResult above)
      * }
      * }
- * - * @param body The request of text analysis. + * + * @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 analysis response of the text 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}. */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> analyzeTextWithResponse(BinaryData body, RequestOptions requestOptions) { - return this.serviceClient.analyzeTextWithResponseAsync(body, requestOptions); + public Mono> analyzeTextWithResponse(BinaryData options, RequestOptions requestOptions) { + return this.serviceClient.analyzeTextWithResponseAsync(options, requestOptions); } /** * Analyze Image - * - *

A sync API for harmful content analysis for image. Currently, we support four categories: Hate, SelfHarm, - * Sexual, Violence. - * - *

Request Body Schema - * + * + * 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
      * {
      *     image (Required): {
@@ -123,613 +114,82 @@ public Mono> analyzeTextWithResponse(BinaryData body, Reque
      *     categories (Optional): [
      *         String(Hate/SelfHarm/Sexual/Violence) (Optional)
      *     ]
+     *     outputType: String(FourSeverityLevels) (Optional)
      * }
      * }
- * - *

Response Body Schema - * - *

{@code
-     * {
-     *     hateResult (Optional): {
-     *         category: String(Hate/SelfHarm/Sexual/Violence) (Required)
-     *         severity: int (Required)
-     *     }
-     *     selfHarmResult (Optional): (recursive schema, see selfHarmResult above)
-     *     sexualResult (Optional): (recursive schema, see sexualResult above)
-     *     violenceResult (Optional): (recursive schema, see violenceResult above)
-     * }
-     * }
- * - * @param body The analysis request of the image. - * @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 analysis response of the image along with {@link Response} on successful completion of {@link Mono}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> analyzeImageWithResponse(BinaryData body, RequestOptions requestOptions) { - return this.serviceClient.analyzeImageWithResponseAsync(body, requestOptions); - } - - /** - * Get Text Blocklist By blocklistName - * - *

Returns text blocklist details. - * - *

Response Body Schema - * + *

+ * Response Body Schema + *

*
{@code
      * {
-     *     blocklistName: String (Required)
-     *     description: String (Optional)
-     * }
-     * }
- * - * @param blocklistName Text blocklist name. - * @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 text Blocklist along with {@link Response} on successful completion of {@link Mono}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getTextBlocklistWithResponse( - String blocklistName, RequestOptions requestOptions) { - return this.serviceClient.getTextBlocklistWithResponseAsync(blocklistName, requestOptions); - } - - /** - * Create Or Update Text Blocklist - * - *

Updates a text blocklist, if blocklistName does not exist, create a new blocklist. - * - *

Request Body Schema - * - *

{@code
-     * {
-     *     blocklistName: String (Required)
-     *     description: String (Optional)
-     * }
-     * }
- * - *

Response Body Schema - * - *

{@code
-     * {
-     *     blocklistName: String (Required)
-     *     description: String (Optional)
-     * }
-     * }
- * - * @param blocklistName Text blocklist name. - * @param resource The resource instance. - * @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 text Blocklist along with {@link Response} on successful completion of {@link Mono}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createOrUpdateTextBlocklistWithResponse( - String blocklistName, BinaryData resource, RequestOptions requestOptions) { - // Convenience API is not generated, as operation 'createOrUpdateTextBlocklist' is - // 'application/merge-patch+json' - return this.serviceClient.createOrUpdateTextBlocklistWithResponseAsync(blocklistName, resource, requestOptions); - } - - /** - * Delete Text Blocklist By blocklistName - * - *

Deletes a text blocklist. - * - * @param blocklistName Text blocklist name. - * @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 {@link Response} on successful completion of {@link Mono}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> deleteTextBlocklistWithResponse(String blocklistName, RequestOptions requestOptions) { - return this.serviceClient.deleteTextBlocklistWithResponseAsync(blocklistName, requestOptions); - } - - /** - * Get All Text Blocklists - * - *

Get all text blocklists details. - * - *

Response Body Schema - * - *

{@code
-     * {
-     *     blocklistName: String (Required)
-     *     description: String (Optional)
-     * }
-     * }
- * - * @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 all text blocklists details as paginated response with {@link PagedFlux}. - */ - @Generated - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux listTextBlocklists(RequestOptions requestOptions) { - return this.serviceClient.listTextBlocklistsAsync(requestOptions); - } - - /** - * Add BlockItems To Text Blocklist - * - *

Add blockItems to a text blocklist. You can add at most 100 BlockItems in one request. - * - *

Request Body Schema - * - *

{@code
-     * {
-     *     blockItems (Required): [
+     *     categoriesAnalysis (Required): [
      *          (Required){
-     *             description: String (Optional)
-     *             text: String (Required)
-     *         }
-     *     ]
-     * }
-     * }
- * - *

Response Body Schema - * - *

{@code
-     * {
-     *     value (Optional): [
-     *          (Optional){
-     *             blockItemId: String (Required)
-     *             description: String (Optional)
-     *             text: String (Required)
+     *             category: String(Hate/SelfHarm/Sexual/Violence) (Required)
+     *             severity: Integer (Optional)
      *         }
      *     ]
      * }
      * }
- * - * @param blocklistName Text blocklist name. - * @param addBlockItemsOptions The request of adding blockItems to text blocklist. - * @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 response of adding blockItems to text blocklist along with {@link Response} on successful completion - * of {@link Mono}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> addBlockItemsWithResponse( - String blocklistName, BinaryData addBlockItemsOptions, RequestOptions requestOptions) { - return this.serviceClient.addBlockItemsWithResponseAsync(blocklistName, addBlockItemsOptions, requestOptions); - } - - /** - * Remove BlockItems From Text Blocklist - * - *

Remove blockItems from a text blocklist. You can remove at most 100 BlockItems in one request. - * - *

Request Body Schema - * - *

{@code
-     * {
-     *     blockItemIds (Required): [
-     *         String (Required)
-     *     ]
-     * }
-     * }
- * - * @param blocklistName Text blocklist name. - * @param removeBlockItemsOptions The request of removing blockItems from text blocklist. - * @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 {@link Response} on successful completion of {@link Mono}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> removeBlockItemsWithResponse( - String blocklistName, BinaryData removeBlockItemsOptions, RequestOptions requestOptions) { - return this.serviceClient.removeBlockItemsWithResponseAsync( - blocklistName, removeBlockItemsOptions, requestOptions); - } - - /** - * Get BlockItem By blocklistName And blockItemId - * - *

Get blockItem By blockItemId from a text blocklist. - * - *

Response Body Schema - * - *

{@code
-     * {
-     *     blockItemId: String (Required)
-     *     description: String (Optional)
-     *     text: String (Required)
-     * }
-     * }
- * - * @param blocklistName Text blocklist name. - * @param blockItemId Block Item Id. It will be uuid. + * + * @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 blockItem By blockItemId from a text blocklist 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}. */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getTextBlocklistItemWithResponse( - String blocklistName, String blockItemId, RequestOptions requestOptions) { - return this.serviceClient.getTextBlocklistItemWithResponseAsync(blocklistName, blockItemId, requestOptions); - } - - /** - * Get All BlockItems By blocklistName - * - *

Get all blockItems in a text blocklist. - * - *

Query Parameters - * - * - * - * - * - * - * - *
Query Parameters
NameTypeRequiredDescription
topIntegerNoThe number of result items to return.
skipIntegerNoThe number of result items to skip.
maxpagesizeIntegerNoThe maximum number of result items per page.
- * - * You can add these to a request with {@link RequestOptions#addQueryParam} - * - *

Response Body Schema - * - *

{@code
-     * {
-     *     blockItemId: String (Required)
-     *     description: String (Optional)
-     *     text: String (Required)
-     * }
-     * }
- * - * @param blocklistName Text blocklist name. - * @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 all blockItems in a text blocklist as paginated response with {@link PagedFlux}. - */ - @Generated - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux listTextBlocklistItems(String blocklistName, RequestOptions requestOptions) { - return this.serviceClient.listTextBlocklistItemsAsync(blocklistName, requestOptions); + public Mono> analyzeImageWithResponse(BinaryData options, RequestOptions requestOptions) { + return this.serviceClient.analyzeImageWithResponseAsync(options, requestOptions); } /** * Analyze Text - * - *

A sync API for harmful content analysis for text. Currently, we support four categories: Hate, SelfHarm, - * Sexual, Violence. - * - * @param body The request of text analysis. + * + * A synchronous API for the analysis of potentially harmful text content. Currently, it supports four categories: + * Hate, SelfHarm, Sexual, and Violence. + * + * @param options The text analysis request. * @throws IllegalArgumentException thrown if parameters fail the validation. * @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. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the analysis response of the text on successful completion of {@link Mono}. + * @return the text analysis response on successful completion of {@link Mono}. */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono analyzeText(AnalyzeTextOptions body) { + public Mono analyzeText(AnalyzeTextOptions options) { // Generated convenience method for analyzeTextWithResponse RequestOptions requestOptions = new RequestOptions(); - return analyzeTextWithResponse(BinaryData.fromObject(body), requestOptions) - .flatMap(FluxUtil::toMono) - .map(protocolMethodData -> protocolMethodData.toObject(AnalyzeTextResult.class)); + return analyzeTextWithResponse(BinaryData.fromObject(options), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(AnalyzeTextResult.class)); } /** * Analyze Image - * - *

A sync API for harmful content analysis for image. Currently, we support four categories: Hate, SelfHarm, - * Sexual, Violence. - * - * @param body The analysis request of the image. + * + * A synchronous API for the analysis of potentially harmful image content. Currently, it supports four categories: + * Hate, SelfHarm, Sexual, and Violence. + * + * @param options The image analysis request. * @throws IllegalArgumentException thrown if parameters fail the validation. * @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. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the analysis response of the image on successful completion of {@link Mono}. + * @return the image analysis response on successful completion of {@link Mono}. */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono analyzeImage(AnalyzeImageOptions body) { + public Mono analyzeImage(AnalyzeImageOptions options) { // Generated convenience method for analyzeImageWithResponse RequestOptions requestOptions = new RequestOptions(); - return analyzeImageWithResponse(BinaryData.fromObject(body), requestOptions) - .flatMap(FluxUtil::toMono) - .map(protocolMethodData -> protocolMethodData.toObject(AnalyzeImageResult.class)); - } - - /** - * Get Text Blocklist By blocklistName - * - *

Returns text blocklist details. - * - * @param blocklistName Text blocklist name. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @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. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return text Blocklist on successful completion of {@link Mono}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getTextBlocklist(String blocklistName) { - // Generated convenience method for getTextBlocklistWithResponse - RequestOptions requestOptions = new RequestOptions(); - return getTextBlocklistWithResponse(blocklistName, requestOptions) - .flatMap(FluxUtil::toMono) - .map(protocolMethodData -> protocolMethodData.toObject(TextBlocklist.class)); - } - - /** - * Delete Text Blocklist By blocklistName - * - *

Deletes a text blocklist. - * - * @param blocklistName Text blocklist name. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @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. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono deleteTextBlocklist(String blocklistName) { - // Generated convenience method for deleteTextBlocklistWithResponse - RequestOptions requestOptions = new RequestOptions(); - return deleteTextBlocklistWithResponse(blocklistName, requestOptions).flatMap(FluxUtil::toMono); - } - - /** - * Get All Text Blocklists - * - *

Get all text blocklists details. - * - * @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. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return all text blocklists details as paginated response with {@link PagedFlux}. - */ - @Generated - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux listTextBlocklists() { - // Generated convenience method for listTextBlocklists - RequestOptions requestOptions = new RequestOptions(); - PagedFlux pagedFluxResponse = listTextBlocklists(requestOptions); - return PagedFlux.create( - () -> - (continuationToken, pageSize) -> { - Flux> flux = - (continuationToken == null) - ? pagedFluxResponse.byPage().take(1) - : pagedFluxResponse.byPage(continuationToken).take(1); - return flux.map( - pagedResponse -> - new PagedResponseBase( - pagedResponse.getRequest(), - pagedResponse.getStatusCode(), - pagedResponse.getHeaders(), - pagedResponse.getValue().stream() - .map( - protocolMethodData -> - protocolMethodData.toObject( - TextBlocklist.class)) - .collect(Collectors.toList()), - pagedResponse.getContinuationToken(), - null)); - }); - } - - /** - * Add BlockItems To Text Blocklist - * - *

Add blockItems to a text blocklist. You can add at most 100 BlockItems in one request. - * - * @param blocklistName Text blocklist name. - * @param addBlockItemsOptions The request of adding blockItems to text blocklist. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @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. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response of adding blockItems to text blocklist on successful completion of {@link Mono}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono addBlockItems(String blocklistName, AddBlockItemsOptions addBlockItemsOptions) { - // Generated convenience method for addBlockItemsWithResponse - RequestOptions requestOptions = new RequestOptions(); - return addBlockItemsWithResponse(blocklistName, BinaryData.fromObject(addBlockItemsOptions), requestOptions) - .flatMap(FluxUtil::toMono) - .map(protocolMethodData -> protocolMethodData.toObject(AddBlockItemsResult.class)); - } - - /** - * Remove BlockItems From Text Blocklist - * - *

Remove blockItems from a text blocklist. You can remove at most 100 BlockItems in one request. - * - * @param blocklistName Text blocklist name. - * @param removeBlockItemsOptions The request of removing blockItems from text blocklist. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @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. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono removeBlockItems(String blocklistName, RemoveBlockItemsOptions removeBlockItemsOptions) { - // Generated convenience method for removeBlockItemsWithResponse - RequestOptions requestOptions = new RequestOptions(); - return removeBlockItemsWithResponse( - blocklistName, BinaryData.fromObject(removeBlockItemsOptions), requestOptions) - .flatMap(FluxUtil::toMono); - } - - /** - * Get BlockItem By blocklistName And blockItemId - * - *

Get blockItem By blockItemId from a text blocklist. - * - * @param blocklistName Text blocklist name. - * @param blockItemId Block Item Id. It will be uuid. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @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. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return blockItem By blockItemId from a text blocklist on successful completion of {@link Mono}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getTextBlocklistItem(String blocklistName, String blockItemId) { - // Generated convenience method for getTextBlocklistItemWithResponse - RequestOptions requestOptions = new RequestOptions(); - return getTextBlocklistItemWithResponse(blocklistName, blockItemId, requestOptions) - .flatMap(FluxUtil::toMono) - .map(protocolMethodData -> protocolMethodData.toObject(TextBlockItem.class)); - } - - /** - * Get All BlockItems By blocklistName - * - *

Get all blockItems in a text blocklist. - * - * @param blocklistName Text blocklist name. - * @param top The number of result items to return. - * @param skip The number of result items to skip. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @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. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return all blockItems in a text blocklist as paginated response with {@link PagedFlux}. - */ - @Generated - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux listTextBlocklistItems(String blocklistName, Integer top, Integer skip) { - // Generated convenience method for listTextBlocklistItems - RequestOptions requestOptions = new RequestOptions(); - if (top != null) { - requestOptions.addQueryParam("top", String.valueOf(top), false); - } - if (skip != null) { - requestOptions.addQueryParam("skip", String.valueOf(skip), false); - } - PagedFlux pagedFluxResponse = listTextBlocklistItems(blocklistName, requestOptions); - return PagedFlux.create( - () -> - (continuationToken, pageSize) -> { - Flux> flux = - (continuationToken == null) - ? pagedFluxResponse.byPage().take(1) - : pagedFluxResponse.byPage(continuationToken).take(1); - return flux.map( - pagedResponse -> - new PagedResponseBase( - pagedResponse.getRequest(), - pagedResponse.getStatusCode(), - pagedResponse.getHeaders(), - pagedResponse.getValue().stream() - .map( - protocolMethodData -> - protocolMethodData.toObject( - TextBlockItem.class)) - .collect(Collectors.toList()), - pagedResponse.getContinuationToken(), - null)); - }); - } - - /** - * Get All BlockItems By blocklistName - * - *

Get all blockItems in a text blocklist. - * - * @param blocklistName Text blocklist name. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @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. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return all blockItems in a text blocklist as paginated response with {@link PagedFlux}. - */ - @Generated - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux listTextBlocklistItems(String blocklistName) { - // Generated convenience method for listTextBlocklistItems - RequestOptions requestOptions = new RequestOptions(); - PagedFlux pagedFluxResponse = listTextBlocklistItems(blocklistName, requestOptions); - return PagedFlux.create( - () -> - (continuationToken, pageSize) -> { - Flux> flux = - (continuationToken == null) - ? pagedFluxResponse.byPage().take(1) - : pagedFluxResponse.byPage(continuationToken).take(1); - return flux.map( - pagedResponse -> - new PagedResponseBase( - pagedResponse.getRequest(), - pagedResponse.getStatusCode(), - pagedResponse.getHeaders(), - pagedResponse.getValue().stream() - .map( - protocolMethodData -> - protocolMethodData.toObject( - TextBlockItem.class)) - .collect(Collectors.toList()), - pagedResponse.getContinuationToken(), - null)); - }); + return analyzeImageWithResponse(BinaryData.fromObject(options), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(AnalyzeImageResult.class)); } } diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/ContentSafetyClient.java b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/ContentSafetyClient.java index 9b124aecf597..e390531a7bbd 100644 --- a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/ContentSafetyClient.java +++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/ContentSafetyClient.java @@ -5,15 +5,10 @@ package com.azure.ai.contentsafety; import com.azure.ai.contentsafety.implementation.ContentSafetyClientImpl; -import com.azure.ai.contentsafety.models.AddBlockItemsOptions; -import com.azure.ai.contentsafety.models.AddBlockItemsResult; import com.azure.ai.contentsafety.models.AnalyzeImageOptions; import com.azure.ai.contentsafety.models.AnalyzeImageResult; import com.azure.ai.contentsafety.models.AnalyzeTextOptions; import com.azure.ai.contentsafety.models.AnalyzeTextResult; -import com.azure.ai.contentsafety.models.RemoveBlockItemsOptions; -import com.azure.ai.contentsafety.models.TextBlockItem; -import com.azure.ai.contentsafety.models.TextBlocklist; import com.azure.core.annotation.Generated; import com.azure.core.annotation.ReturnType; import com.azure.core.annotation.ServiceClient; @@ -22,19 +17,21 @@ import com.azure.core.exception.HttpResponseException; import com.azure.core.exception.ResourceModifiedException; import com.azure.core.exception.ResourceNotFoundException; -import com.azure.core.http.rest.PagedIterable; import com.azure.core.http.rest.RequestOptions; import com.azure.core.http.rest.Response; import com.azure.core.util.BinaryData; -/** Initializes a new instance of the synchronous ContentSafetyClient type. */ +/** + * Initializes a new instance of the synchronous ContentSafetyClient type. + */ @ServiceClient(builder = ContentSafetyClientBuilder.class) public final class ContentSafetyClient { - @Generated private final ContentSafetyClientImpl serviceClient; + @Generated + private final ContentSafetyClientImpl serviceClient; /** * Initializes an instance of ContentSafetyClient class. - * + * * @param serviceClient the service client implementation. */ @Generated @@ -44,12 +41,12 @@ public final class ContentSafetyClient { /** * Analyze Text - * - *

A sync API for harmful content analysis for text. Currently, we support four categories: Hate, SelfHarm, - * Sexual, Violence. - * - *

Request Body Schema - * + * + * 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
      * {
      *     text: String (Required)
@@ -59,55 +56,53 @@ public final class ContentSafetyClient {
      *     blocklistNames (Optional): [
      *         String (Optional)
      *     ]
-     *     breakByBlocklists: Boolean (Optional)
+     *     haltOnBlocklistHit: Boolean (Optional)
+     *     outputType: String(FourSeverityLevels/EightSeverityLevels) (Optional)
      * }
      * }
- * - *

Response Body Schema - * + *

+ * Response Body Schema + *

*
{@code
      * {
-     *     blocklistsMatchResults (Optional): [
+     *     blocklistsMatch (Optional): [
      *          (Optional){
      *             blocklistName: String (Required)
-     *             blockItemId: String (Required)
-     *             blockItemText: String (Required)
-     *             offset: int (Required)
-     *             length: int (Required)
+     *             blocklistItemId: String (Required)
+     *             blocklistItemText: String (Required)
+     *         }
+     *     ]
+     *     categoriesAnalysis (Required): [
+     *          (Required){
+     *             category: String(Hate/SelfHarm/Sexual/Violence) (Required)
+     *             severity: Integer (Optional)
      *         }
      *     ]
-     *     hateResult (Optional): {
-     *         category: String(Hate/SelfHarm/Sexual/Violence) (Required)
-     *         severity: int (Required)
-     *     }
-     *     selfHarmResult (Optional): (recursive schema, see selfHarmResult above)
-     *     sexualResult (Optional): (recursive schema, see sexualResult above)
-     *     violenceResult (Optional): (recursive schema, see violenceResult above)
      * }
      * }
- * - * @param body The request of text analysis. + * + * @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 analysis response of the text along with {@link Response}. + * @return the text analysis response along with {@link Response}. */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Response analyzeTextWithResponse(BinaryData body, RequestOptions requestOptions) { - return this.serviceClient.analyzeTextWithResponse(body, requestOptions); + public Response analyzeTextWithResponse(BinaryData options, RequestOptions requestOptions) { + return this.serviceClient.analyzeTextWithResponse(options, requestOptions); } /** * Analyze Image - * - *

A sync API for harmful content analysis for image. Currently, we support four categories: Hate, SelfHarm, - * Sexual, Violence. - * - *

Request Body Schema - * + * + * 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
      * {
      *     image (Required): {
@@ -117,544 +112,82 @@ public Response analyzeTextWithResponse(BinaryData body, RequestOpti
      *     categories (Optional): [
      *         String(Hate/SelfHarm/Sexual/Violence) (Optional)
      *     ]
+     *     outputType: String(FourSeverityLevels) (Optional)
      * }
      * }
- * - *

Response Body Schema - * - *

{@code
-     * {
-     *     hateResult (Optional): {
-     *         category: String(Hate/SelfHarm/Sexual/Violence) (Required)
-     *         severity: int (Required)
-     *     }
-     *     selfHarmResult (Optional): (recursive schema, see selfHarmResult above)
-     *     sexualResult (Optional): (recursive schema, see sexualResult above)
-     *     violenceResult (Optional): (recursive schema, see violenceResult above)
-     * }
-     * }
- * - * @param body The analysis request of the image. - * @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 analysis response of the image along with {@link Response}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Response analyzeImageWithResponse(BinaryData body, RequestOptions requestOptions) { - return this.serviceClient.analyzeImageWithResponse(body, requestOptions); - } - - /** - * Get Text Blocklist By blocklistName - * - *

Returns text blocklist details. - * - *

Response Body Schema - * + *

+ * Response Body Schema + *

*
{@code
      * {
-     *     blocklistName: String (Required)
-     *     description: String (Optional)
-     * }
-     * }
- * - * @param blocklistName Text blocklist name. - * @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 text Blocklist along with {@link Response}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Response getTextBlocklistWithResponse(String blocklistName, RequestOptions requestOptions) { - return this.serviceClient.getTextBlocklistWithResponse(blocklistName, requestOptions); - } - - /** - * Create Or Update Text Blocklist - * - *

Updates a text blocklist, if blocklistName does not exist, create a new blocklist. - * - *

Request Body Schema - * - *

{@code
-     * {
-     *     blocklistName: String (Required)
-     *     description: String (Optional)
-     * }
-     * }
- * - *

Response Body Schema - * - *

{@code
-     * {
-     *     blocklistName: String (Required)
-     *     description: String (Optional)
-     * }
-     * }
- * - * @param blocklistName Text blocklist name. - * @param resource The resource instance. - * @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 text Blocklist along with {@link Response}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Response createOrUpdateTextBlocklistWithResponse( - String blocklistName, BinaryData resource, RequestOptions requestOptions) { - // Convenience API is not generated, as operation 'createOrUpdateTextBlocklist' is - // 'application/merge-patch+json' - return this.serviceClient.createOrUpdateTextBlocklistWithResponse(blocklistName, resource, requestOptions); - } - - /** - * Delete Text Blocklist By blocklistName - * - *

Deletes a text blocklist. - * - * @param blocklistName Text blocklist name. - * @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 {@link Response}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Response deleteTextBlocklistWithResponse(String blocklistName, RequestOptions requestOptions) { - return this.serviceClient.deleteTextBlocklistWithResponse(blocklistName, requestOptions); - } - - /** - * Get All Text Blocklists - * - *

Get all text blocklists details. - * - *

Response Body Schema - * - *

{@code
-     * {
-     *     blocklistName: String (Required)
-     *     description: String (Optional)
-     * }
-     * }
- * - * @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 all text blocklists details as paginated response with {@link PagedIterable}. - */ - @Generated - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable listTextBlocklists(RequestOptions requestOptions) { - return this.serviceClient.listTextBlocklists(requestOptions); - } - - /** - * Add BlockItems To Text Blocklist - * - *

Add blockItems to a text blocklist. You can add at most 100 BlockItems in one request. - * - *

Request Body Schema - * - *

{@code
-     * {
-     *     blockItems (Required): [
+     *     categoriesAnalysis (Required): [
      *          (Required){
-     *             description: String (Optional)
-     *             text: String (Required)
-     *         }
-     *     ]
-     * }
-     * }
- * - *

Response Body Schema - * - *

{@code
-     * {
-     *     value (Optional): [
-     *          (Optional){
-     *             blockItemId: String (Required)
-     *             description: String (Optional)
-     *             text: String (Required)
+     *             category: String(Hate/SelfHarm/Sexual/Violence) (Required)
+     *             severity: Integer (Optional)
      *         }
      *     ]
      * }
      * }
- * - * @param blocklistName Text blocklist name. - * @param addBlockItemsOptions The request of adding blockItems to text blocklist. - * @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 response of adding blockItems to text blocklist along with {@link Response}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Response addBlockItemsWithResponse( - String blocklistName, BinaryData addBlockItemsOptions, RequestOptions requestOptions) { - return this.serviceClient.addBlockItemsWithResponse(blocklistName, addBlockItemsOptions, requestOptions); - } - - /** - * Remove BlockItems From Text Blocklist - * - *

Remove blockItems from a text blocklist. You can remove at most 100 BlockItems in one request. - * - *

Request Body Schema - * - *

{@code
-     * {
-     *     blockItemIds (Required): [
-     *         String (Required)
-     *     ]
-     * }
-     * }
- * - * @param blocklistName Text blocklist name. - * @param removeBlockItemsOptions The request of removing blockItems from text blocklist. - * @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 {@link Response}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Response removeBlockItemsWithResponse( - String blocklistName, BinaryData removeBlockItemsOptions, RequestOptions requestOptions) { - return this.serviceClient.removeBlockItemsWithResponse(blocklistName, removeBlockItemsOptions, requestOptions); - } - - /** - * Get BlockItem By blocklistName And blockItemId - * - *

Get blockItem By blockItemId from a text blocklist. - * - *

Response Body Schema - * - *

{@code
-     * {
-     *     blockItemId: String (Required)
-     *     description: String (Optional)
-     *     text: String (Required)
-     * }
-     * }
- * - * @param blocklistName Text blocklist name. - * @param blockItemId Block Item Id. It will be uuid. + * + * @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 blockItem By blockItemId from a text blocklist along with {@link Response}. + * @return the image analysis response along with {@link Response}. */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Response getTextBlocklistItemWithResponse( - String blocklistName, String blockItemId, RequestOptions requestOptions) { - return this.serviceClient.getTextBlocklistItemWithResponse(blocklistName, blockItemId, requestOptions); - } - - /** - * Get All BlockItems By blocklistName - * - *

Get all blockItems in a text blocklist. - * - *

Query Parameters - * - * - * - * - * - * - * - *
Query Parameters
NameTypeRequiredDescription
topIntegerNoThe number of result items to return.
skipIntegerNoThe number of result items to skip.
maxpagesizeIntegerNoThe maximum number of result items per page.
- * - * You can add these to a request with {@link RequestOptions#addQueryParam} - * - *

Response Body Schema - * - *

{@code
-     * {
-     *     blockItemId: String (Required)
-     *     description: String (Optional)
-     *     text: String (Required)
-     * }
-     * }
- * - * @param blocklistName Text blocklist name. - * @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 all blockItems in a text blocklist as paginated response with {@link PagedIterable}. - */ - @Generated - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable listTextBlocklistItems(String blocklistName, RequestOptions requestOptions) { - return this.serviceClient.listTextBlocklistItems(blocklistName, requestOptions); + public Response analyzeImageWithResponse(BinaryData options, RequestOptions requestOptions) { + return this.serviceClient.analyzeImageWithResponse(options, requestOptions); } /** * Analyze Text - * - *

A sync API for harmful content analysis for text. Currently, we support four categories: Hate, SelfHarm, - * Sexual, Violence. - * - * @param body The request of text analysis. + * + * A synchronous API for the analysis of potentially harmful text content. Currently, it supports four categories: + * Hate, SelfHarm, Sexual, and Violence. + * + * @param options The text analysis request. * @throws IllegalArgumentException thrown if parameters fail the validation. * @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. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the analysis response of the text. + * @return the text analysis response. */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public AnalyzeTextResult analyzeText(AnalyzeTextOptions body) { + public AnalyzeTextResult analyzeText(AnalyzeTextOptions options) { // Generated convenience method for analyzeTextWithResponse RequestOptions requestOptions = new RequestOptions(); - return analyzeTextWithResponse(BinaryData.fromObject(body), requestOptions) - .getValue() - .toObject(AnalyzeTextResult.class); + return analyzeTextWithResponse(BinaryData.fromObject(options), requestOptions).getValue() + .toObject(AnalyzeTextResult.class); } /** * Analyze Image - * - *

A sync API for harmful content analysis for image. Currently, we support four categories: Hate, SelfHarm, - * Sexual, Violence. - * - * @param body The analysis request of the image. + * + * A synchronous API for the analysis of potentially harmful image content. Currently, it supports four categories: + * Hate, SelfHarm, Sexual, and Violence. + * + * @param options The image analysis request. * @throws IllegalArgumentException thrown if parameters fail the validation. * @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. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the analysis response of the image. + * @return the image analysis response. */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public AnalyzeImageResult analyzeImage(AnalyzeImageOptions body) { + public AnalyzeImageResult analyzeImage(AnalyzeImageOptions options) { // Generated convenience method for analyzeImageWithResponse RequestOptions requestOptions = new RequestOptions(); - return analyzeImageWithResponse(BinaryData.fromObject(body), requestOptions) - .getValue() - .toObject(AnalyzeImageResult.class); - } - - /** - * Get Text Blocklist By blocklistName - * - *

Returns text blocklist details. - * - * @param blocklistName Text blocklist name. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @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. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return text Blocklist. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public TextBlocklist getTextBlocklist(String blocklistName) { - // Generated convenience method for getTextBlocklistWithResponse - RequestOptions requestOptions = new RequestOptions(); - return getTextBlocklistWithResponse(blocklistName, requestOptions).getValue().toObject(TextBlocklist.class); - } - - /** - * Delete Text Blocklist By blocklistName - * - *

Deletes a text blocklist. - * - * @param blocklistName Text blocklist name. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @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. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public void deleteTextBlocklist(String blocklistName) { - // Generated convenience method for deleteTextBlocklistWithResponse - RequestOptions requestOptions = new RequestOptions(); - deleteTextBlocklistWithResponse(blocklistName, requestOptions).getValue(); - } - - /** - * Get All Text Blocklists - * - *

Get all text blocklists details. - * - * @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. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return all text blocklists details as paginated response with {@link PagedIterable}. - */ - @Generated - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable listTextBlocklists() { - // Generated convenience method for listTextBlocklists - RequestOptions requestOptions = new RequestOptions(); - return serviceClient - .listTextBlocklists(requestOptions) - .mapPage(bodyItemValue -> bodyItemValue.toObject(TextBlocklist.class)); - } - - /** - * Add BlockItems To Text Blocklist - * - *

Add blockItems to a text blocklist. You can add at most 100 BlockItems in one request. - * - * @param blocklistName Text blocklist name. - * @param addBlockItemsOptions The request of adding blockItems to text blocklist. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @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. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response of adding blockItems to text blocklist. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public AddBlockItemsResult addBlockItems(String blocklistName, AddBlockItemsOptions addBlockItemsOptions) { - // Generated convenience method for addBlockItemsWithResponse - RequestOptions requestOptions = new RequestOptions(); - return addBlockItemsWithResponse(blocklistName, BinaryData.fromObject(addBlockItemsOptions), requestOptions) - .getValue() - .toObject(AddBlockItemsResult.class); - } - - /** - * Remove BlockItems From Text Blocklist - * - *

Remove blockItems from a text blocklist. You can remove at most 100 BlockItems in one request. - * - * @param blocklistName Text blocklist name. - * @param removeBlockItemsOptions The request of removing blockItems from text blocklist. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @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. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public void removeBlockItems(String blocklistName, RemoveBlockItemsOptions removeBlockItemsOptions) { - // Generated convenience method for removeBlockItemsWithResponse - RequestOptions requestOptions = new RequestOptions(); - removeBlockItemsWithResponse(blocklistName, BinaryData.fromObject(removeBlockItemsOptions), requestOptions) - .getValue(); - } - - /** - * Get BlockItem By blocklistName And blockItemId - * - *

Get blockItem By blockItemId from a text blocklist. - * - * @param blocklistName Text blocklist name. - * @param blockItemId Block Item Id. It will be uuid. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @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. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return blockItem By blockItemId from a text blocklist. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public TextBlockItem getTextBlocklistItem(String blocklistName, String blockItemId) { - // Generated convenience method for getTextBlocklistItemWithResponse - RequestOptions requestOptions = new RequestOptions(); - return getTextBlocklistItemWithResponse(blocklistName, blockItemId, requestOptions) - .getValue() - .toObject(TextBlockItem.class); - } - - /** - * Get All BlockItems By blocklistName - * - *

Get all blockItems in a text blocklist. - * - * @param blocklistName Text blocklist name. - * @param top The number of result items to return. - * @param skip The number of result items to skip. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @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. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return all blockItems in a text blocklist as paginated response with {@link PagedIterable}. - */ - @Generated - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable listTextBlocklistItems(String blocklistName, Integer top, Integer skip) { - // Generated convenience method for listTextBlocklistItems - RequestOptions requestOptions = new RequestOptions(); - if (top != null) { - requestOptions.addQueryParam("top", String.valueOf(top), false); - } - if (skip != null) { - requestOptions.addQueryParam("skip", String.valueOf(skip), false); - } - return serviceClient - .listTextBlocklistItems(blocklistName, requestOptions) - .mapPage(bodyItemValue -> bodyItemValue.toObject(TextBlockItem.class)); - } - - /** - * Get All BlockItems By blocklistName - * - *

Get all blockItems in a text blocklist. - * - * @param blocklistName Text blocklist name. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @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. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return all blockItems in a text blocklist as paginated response with {@link PagedIterable}. - */ - @Generated - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable listTextBlocklistItems(String blocklistName) { - // Generated convenience method for listTextBlocklistItems - RequestOptions requestOptions = new RequestOptions(); - return serviceClient - .listTextBlocklistItems(blocklistName, requestOptions) - .mapPage(bodyItemValue -> bodyItemValue.toObject(TextBlockItem.class)); + return analyzeImageWithResponse(BinaryData.fromObject(options), requestOptions).getValue() + .toObject(AnalyzeImageResult.class); } } diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/ContentSafetyClientBuilder.java b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/ContentSafetyClientBuilder.java index cd00472d7e55..84f9b4935406 100644 --- a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/ContentSafetyClientBuilder.java +++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/ContentSafetyClientBuilder.java @@ -11,7 +11,9 @@ import com.azure.core.client.traits.EndpointTrait; import com.azure.core.client.traits.HttpTrait; import com.azure.core.client.traits.KeyCredentialTrait; +import com.azure.core.client.traits.TokenCredentialTrait; import com.azure.core.credential.KeyCredential; +import com.azure.core.credential.TokenCredential; import com.azure.core.http.HttpClient; import com.azure.core.http.HttpHeaderName; import com.azure.core.http.HttpHeaders; @@ -21,6 +23,7 @@ import com.azure.core.http.policy.AddDatePolicy; import com.azure.core.http.policy.AddHeadersFromContextPolicy; import com.azure.core.http.policy.AddHeadersPolicy; +import com.azure.core.http.policy.BearerTokenAuthenticationPolicy; import com.azure.core.http.policy.HttpLogOptions; import com.azure.core.http.policy.HttpLoggingPolicy; import com.azure.core.http.policy.HttpPipelinePolicy; @@ -41,23 +44,31 @@ import java.util.Map; import java.util.Objects; -/** A builder for creating a new instance of the ContentSafetyClient type. */ -@ServiceClientBuilder(serviceClients = {ContentSafetyClient.class, ContentSafetyAsyncClient.class}) -public final class ContentSafetyClientBuilder - implements HttpTrait, - ConfigurationTrait, - KeyCredentialTrait, - EndpointTrait { - @Generated private static final String SDK_NAME = "name"; +/** + * A builder for creating a new instance of the ContentSafetyClient type. + */ +@ServiceClientBuilder(serviceClients = { ContentSafetyClient.class, ContentSafetyAsyncClient.class }) +public final class ContentSafetyClientBuilder implements HttpTrait, + ConfigurationTrait, TokenCredentialTrait, + KeyCredentialTrait, EndpointTrait { + @Generated + private static final String SDK_NAME = "name"; + + @Generated + private static final String SDK_VERSION = "version"; - @Generated private static final String SDK_VERSION = "version"; + @Generated + private static final String[] DEFAULT_SCOPES = new String[] { "https://cognitiveservices.azure.com/.default" }; @Generated private static final Map PROPERTIES = CoreUtils.getProperties("azure-ai-contentsafety.properties"); - @Generated private final List pipelinePolicies; + @Generated + private final List pipelinePolicies; - /** Create an instance of the ContentSafetyClientBuilder. */ + /** + * Create an instance of the ContentSafetyClientBuilder. + */ @Generated public ContentSafetyClientBuilder() { this.pipelinePolicies = new ArrayList<>(); @@ -66,9 +77,12 @@ public ContentSafetyClientBuilder() { /* * The HTTP pipeline to send requests through. */ - @Generated private HttpPipeline pipeline; + @Generated + private HttpPipeline pipeline; - /** {@inheritDoc}. */ + /** + * {@inheritDoc}. + */ @Generated @Override public ContentSafetyClientBuilder pipeline(HttpPipeline pipeline) { @@ -82,9 +96,12 @@ public ContentSafetyClientBuilder pipeline(HttpPipeline pipeline) { /* * The HTTP client used to send the request. */ - @Generated private HttpClient httpClient; + @Generated + private HttpClient httpClient; - /** {@inheritDoc}. */ + /** + * {@inheritDoc}. + */ @Generated @Override public ContentSafetyClientBuilder httpClient(HttpClient httpClient) { @@ -95,9 +112,12 @@ public ContentSafetyClientBuilder httpClient(HttpClient httpClient) { /* * The logging configuration for HTTP requests and responses. */ - @Generated private HttpLogOptions httpLogOptions; + @Generated + private HttpLogOptions httpLogOptions; - /** {@inheritDoc}. */ + /** + * {@inheritDoc}. + */ @Generated @Override public ContentSafetyClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { @@ -108,9 +128,12 @@ public ContentSafetyClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) /* * The client options such as application ID and custom headers to set on a request. */ - @Generated private ClientOptions clientOptions; + @Generated + private ClientOptions clientOptions; - /** {@inheritDoc}. */ + /** + * {@inheritDoc}. + */ @Generated @Override public ContentSafetyClientBuilder clientOptions(ClientOptions clientOptions) { @@ -121,9 +144,12 @@ public ContentSafetyClientBuilder clientOptions(ClientOptions clientOptions) { /* * The retry options to configure retry policy for failed requests. */ - @Generated private RetryOptions retryOptions; + @Generated + private RetryOptions retryOptions; - /** {@inheritDoc}. */ + /** + * {@inheritDoc}. + */ @Generated @Override public ContentSafetyClientBuilder retryOptions(RetryOptions retryOptions) { @@ -131,7 +157,9 @@ public ContentSafetyClientBuilder retryOptions(RetryOptions retryOptions) { return this; } - /** {@inheritDoc}. */ + /** + * {@inheritDoc}. + */ @Generated @Override public ContentSafetyClientBuilder addPolicy(HttpPipelinePolicy customPolicy) { @@ -143,9 +171,12 @@ public ContentSafetyClientBuilder addPolicy(HttpPipelinePolicy customPolicy) { /* * The configuration store that is used during construction of the service client. */ - @Generated private Configuration configuration; + @Generated + private Configuration configuration; - /** {@inheritDoc}. */ + /** + * {@inheritDoc}. + */ @Generated @Override public ContentSafetyClientBuilder configuration(Configuration configuration) { @@ -153,12 +184,31 @@ public ContentSafetyClientBuilder configuration(Configuration configuration) { return this; } + /* + * The TokenCredential used for authentication. + */ + @Generated + private TokenCredential tokenCredential; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ContentSafetyClientBuilder credential(TokenCredential tokenCredential) { + this.tokenCredential = tokenCredential; + return this; + } + /* * The KeyCredential used for authentication. */ - @Generated private KeyCredential keyCredential; + @Generated + private KeyCredential keyCredential; - /** {@inheritDoc}. */ + /** + * {@inheritDoc}. + */ @Generated @Override public ContentSafetyClientBuilder credential(KeyCredential keyCredential) { @@ -169,9 +219,12 @@ public ContentSafetyClientBuilder credential(KeyCredential keyCredential) { /* * The service endpoint */ - @Generated private String endpoint; + @Generated + private String endpoint; - /** {@inheritDoc}. */ + /** + * {@inheritDoc}. + */ @Generated @Override public ContentSafetyClientBuilder endpoint(String endpoint) { @@ -182,11 +235,12 @@ public ContentSafetyClientBuilder endpoint(String endpoint) { /* * Service version */ - @Generated private ContentSafetyServiceVersion serviceVersion; + @Generated + private ContentSafetyServiceVersion serviceVersion; /** * Sets Service version. - * + * * @param serviceVersion the serviceVersion value. * @return the ContentSafetyClientBuilder. */ @@ -199,11 +253,12 @@ public ContentSafetyClientBuilder serviceVersion(ContentSafetyServiceVersion ser /* * The retry policy that will attempt to retry failed requests, if applicable. */ - @Generated private RetryPolicy retryPolicy; + @Generated + private RetryPolicy retryPolicy; /** * Sets The retry policy that will attempt to retry failed requests, if applicable. - * + * * @param retryPolicy the retryPolicy value. * @return the ContentSafetyClientBuilder. */ @@ -215,27 +270,23 @@ public ContentSafetyClientBuilder retryPolicy(RetryPolicy retryPolicy) { /** * Builds an instance of ContentSafetyClientImpl with the provided parameters. - * + * * @return an instance of ContentSafetyClientImpl. */ @Generated private ContentSafetyClientImpl buildInnerClient() { HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); - ContentSafetyServiceVersion localServiceVersion = - (serviceVersion != null) ? serviceVersion : ContentSafetyServiceVersion.getLatest(); - ContentSafetyClientImpl client = - new ContentSafetyClientImpl( - localPipeline, - JacksonAdapter.createDefaultSerializerAdapter(), - this.endpoint, - localServiceVersion); + ContentSafetyServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : ContentSafetyServiceVersion.getLatest(); + ContentSafetyClientImpl client = new ContentSafetyClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint, localServiceVersion); return client; } @Generated private HttpPipeline createHttpPipeline() { - Configuration buildConfiguration = - (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; ClientOptions localClientOptions = this.clientOptions == null ? new ClientOptions() : this.clientOptions; List policies = new ArrayList<>(); @@ -246,38 +297,34 @@ private HttpPipeline createHttpPipeline() { policies.add(new RequestIdPolicy()); policies.add(new AddHeadersFromContextPolicy()); HttpHeaders headers = new HttpHeaders(); - localClientOptions - .getHeaders() - .forEach(header -> headers.set(HttpHeaderName.fromString(header.getName()), header.getValue())); + localClientOptions.getHeaders() + .forEach(header -> headers.set(HttpHeaderName.fromString(header.getName()), header.getValue())); if (headers.getSize() > 0) { policies.add(new AddHeadersPolicy(headers)); } - this.pipelinePolicies.stream() - .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) - .forEach(p -> policies.add(p)); + this.pipelinePolicies.stream().filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) + .forEach(p -> policies.add(p)); HttpPolicyProviders.addBeforeRetryPolicies(policies); policies.add(ClientBuilderUtil.validateAndGetRetryPolicy(retryPolicy, retryOptions, new RetryPolicy())); policies.add(new AddDatePolicy()); if (keyCredential != null) { policies.add(new KeyCredentialPolicy("Ocp-Apim-Subscription-Key", keyCredential)); } - this.pipelinePolicies.stream() - .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) - .forEach(p -> policies.add(p)); + if (tokenCredential != null) { + policies.add(new BearerTokenAuthenticationPolicy(tokenCredential, DEFAULT_SCOPES)); + } + this.pipelinePolicies.stream().filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) + .forEach(p -> policies.add(p)); HttpPolicyProviders.addAfterRetryPolicies(policies); policies.add(new HttpLoggingPolicy(httpLogOptions)); - HttpPipeline httpPipeline = - new HttpPipelineBuilder() - .policies(policies.toArray(new HttpPipelinePolicy[0])) - .httpClient(httpClient) - .clientOptions(localClientOptions) - .build(); + HttpPipeline httpPipeline = new HttpPipelineBuilder().policies(policies.toArray(new HttpPipelinePolicy[0])) + .httpClient(httpClient).clientOptions(localClientOptions).build(); return httpPipeline; } /** * Builds an instance of ContentSafetyAsyncClient class. - * + * * @return an instance of ContentSafetyAsyncClient. */ @Generated @@ -287,7 +334,7 @@ public ContentSafetyAsyncClient buildAsyncClient() { /** * Builds an instance of ContentSafetyClient class. - * + * * @return an instance of ContentSafetyClient. */ @Generated diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/ContentSafetyServiceVersion.java b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/ContentSafetyServiceVersion.java index de967742593d..17bdff7f6bf8 100644 --- a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/ContentSafetyServiceVersion.java +++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/ContentSafetyServiceVersion.java @@ -6,10 +6,14 @@ import com.azure.core.util.ServiceVersion; -/** Service version of ContentSafetyClient. */ +/** + * Service version of ContentSafetyClient. + */ public enum ContentSafetyServiceVersion implements ServiceVersion { - /** Enum value 2023-04-30-preview. */ - V2023_04_30_PREVIEW("2023-04-30-preview"); + /** + * Enum value 2023-10-01. + */ + V2023_10_01("2023-10-01"); private final String version; @@ -17,7 +21,9 @@ public enum ContentSafetyServiceVersion implements ServiceVersion { this.version = version; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public String getVersion() { return this.version; @@ -25,10 +31,10 @@ public String getVersion() { /** * Gets the latest service version supported by this client library. - * + * * @return The latest {@link ContentSafetyServiceVersion}. */ public static ContentSafetyServiceVersion getLatest() { - return V2023_04_30_PREVIEW; + return V2023_10_01; } } diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/implementation/BlocklistClientImpl.java b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/implementation/BlocklistClientImpl.java new file mode 100644 index 000000000000..eedb893f17d2 --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/implementation/BlocklistClientImpl.java @@ -0,0 +1,1362 @@ +// 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.implementation; + +import com.azure.ai.contentsafety.ContentSafetyServiceVersion; +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.Delete; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Patch; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Post; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.UrlBuilder; +import com.azure.core.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the BlocklistClient type. + */ +public final class BlocklistClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final BlocklistClientService service; + + /** + * Supported Cognitive Services endpoints (protocol and hostname, for example: + * https://<resource-name>.cognitiveservices.azure.com). + */ + private final String endpoint; + + /** + * Gets Supported Cognitive Services endpoints (protocol and hostname, for example: + * https://<resource-name>.cognitiveservices.azure.com). + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Service version. + */ + private final ContentSafetyServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public ContentSafetyServiceVersion getServiceVersion() { + return this.serviceVersion; + } + + /** + * The HTTP pipeline to send requests through. + */ + private final HttpPipeline httpPipeline; + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + public HttpPipeline getHttpPipeline() { + return this.httpPipeline; + } + + /** + * The serializer to serialize an object into a string. + */ + private final SerializerAdapter serializerAdapter; + + /** + * Gets The serializer to serialize an object into a string. + * + * @return the serializerAdapter value. + */ + public SerializerAdapter getSerializerAdapter() { + return this.serializerAdapter; + } + + /** + * Initializes an instance of BlocklistClient client. + * + * @param endpoint Supported Cognitive Services endpoints (protocol and hostname, for example: + * https://<resource-name>.cognitiveservices.azure.com). + * @param serviceVersion Service version. + */ + public BlocklistClientImpl(String endpoint, ContentSafetyServiceVersion serviceVersion) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of BlocklistClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Supported Cognitive Services endpoints (protocol and hostname, for example: + * https://<resource-name>.cognitiveservices.azure.com). + * @param serviceVersion Service version. + */ + public BlocklistClientImpl(HttpPipeline httpPipeline, String endpoint, ContentSafetyServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of BlocklistClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param endpoint Supported Cognitive Services endpoints (protocol and hostname, for example: + * https://<resource-name>.cognitiveservices.azure.com). + * @param serviceVersion Service version. + */ + public BlocklistClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, + ContentSafetyServiceVersion serviceVersion) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.serviceVersion = serviceVersion; + this.service = RestProxy.create(BlocklistClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for BlocklistClient to be used by the proxy service to perform REST + * calls. + */ + @Host("{endpoint}/contentsafety") + @ServiceInterface(name = "BlocklistClient") + public interface BlocklistClientService { + @Post("/text/blocklists/{blocklistName}:addOrUpdateBlocklistItems") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> addOrUpdateBlocklistItems(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("blocklistName") String name, + @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData options, + RequestOptions requestOptions, Context context); + + @Post("/text/blocklists/{blocklistName}:addOrUpdateBlocklistItems") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response addOrUpdateBlocklistItemsSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("blocklistName") String name, + @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData options, + RequestOptions requestOptions, Context context); + + @Patch("/text/blocklists/{blocklistName}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> createOrUpdateTextBlocklist(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("blocklistName") String name, + @HeaderParam("Content-Type") String contentType, @HeaderParam("accept") String accept, + @BodyParam("application/merge-patch+json") BinaryData options, RequestOptions requestOptions, + Context context); + + @Patch("/text/blocklists/{blocklistName}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response createOrUpdateTextBlocklistSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("blocklistName") String name, + @HeaderParam("Content-Type") String contentType, @HeaderParam("accept") String accept, + @BodyParam("application/merge-patch+json") BinaryData options, RequestOptions requestOptions, + Context context); + + @Delete("/text/blocklists/{blocklistName}") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> deleteTextBlocklist(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("blocklistName") String name, + @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + + @Delete("/text/blocklists/{blocklistName}") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response deleteTextBlocklistSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("blocklistName") String name, + @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/text/blocklists/{blocklistName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getTextBlocklist(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("blocklistName") String name, + @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/text/blocklists/{blocklistName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getTextBlocklistSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("blocklistName") String name, + @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/text/blocklists/{blocklistName}/blocklistItems/{blocklistItemId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getTextBlocklistItem(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("blocklistName") String name, + @PathParam("blocklistItemId") String blocklistItemId, @HeaderParam("accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/text/blocklists/{blocklistName}/blocklistItems/{blocklistItemId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getTextBlocklistItemSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("blocklistName") String name, + @PathParam("blocklistItemId") String blocklistItemId, @HeaderParam("accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/text/blocklists/{blocklistName}/blocklistItems") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listTextBlocklistItems(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("blocklistName") String name, + @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/text/blocklists/{blocklistName}/blocklistItems") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listTextBlocklistItemsSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("blocklistName") String name, + @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/text/blocklists") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listTextBlocklists(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/text/blocklists") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listTextBlocklistsSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("accept") String accept, + RequestOptions requestOptions, Context context); + + @Post("/text/blocklists/{blocklistName}:removeBlocklistItems") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> removeBlocklistItems(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("blocklistName") String name, + @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData options, + RequestOptions requestOptions, Context context); + + @Post("/text/blocklists/{blocklistName}:removeBlocklistItems") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response removeBlocklistItemsSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("blocklistName") String name, + @HeaderParam("accept") String accept, @BodyParam("application/json") BinaryData options, + RequestOptions requestOptions, Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listTextBlocklistItemsNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") String endpoint, + @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listTextBlocklistItemsNextSync( + @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") String endpoint, + @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listTextBlocklistsNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") String endpoint, + @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listTextBlocklistsNextSync(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("accept") String accept, RequestOptions requestOptions, + Context context); + } + + /** + * Add or update BlocklistItems To Text Blocklist + * + * Add or update blocklistItems to a text blocklist. You can add or update at most 100 blocklistItems in one + * request. + *

+ * Request Body Schema + *

+ *
{@code
+     * {
+     *     blocklistItems (Required): [
+     *          (Required){
+     *             blocklistItemId: String (Required)
+     *             description: String (Optional)
+     *             text: String (Required)
+     *         }
+     *     ]
+     * }
+     * }
+ *

+ * Response Body Schema + *

+ *
{@code
+     * {
+     *     blocklistItems (Required): [
+     *          (Required){
+     *             blocklistItemId: String (Required)
+     *             description: String (Optional)
+     *             text: String (Required)
+     *         }
+     *     ]
+     * }
+     * }
+ * + * @param name Text blocklist name. + * @param options Options for adding or updating blocklist items. + * @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 response of adding blocklistItems to the text blocklist along with {@link Response} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> addOrUpdateBlocklistItemsWithResponseAsync(String name, BinaryData options, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.addOrUpdateBlocklistItems(this.getEndpoint(), + this.getServiceVersion().getVersion(), name, accept, options, requestOptions, context)); + } + + /** + * Add or update BlocklistItems To Text Blocklist + * + * Add or update blocklistItems to a text blocklist. You can add or update at most 100 blocklistItems in one + * request. + *

+ * Request Body Schema + *

+ *
{@code
+     * {
+     *     blocklistItems (Required): [
+     *          (Required){
+     *             blocklistItemId: String (Required)
+     *             description: String (Optional)
+     *             text: String (Required)
+     *         }
+     *     ]
+     * }
+     * }
+ *

+ * Response Body Schema + *

+ *
{@code
+     * {
+     *     blocklistItems (Required): [
+     *          (Required){
+     *             blocklistItemId: String (Required)
+     *             description: String (Optional)
+     *             text: String (Required)
+     *         }
+     *     ]
+     * }
+     * }
+ * + * @param name Text blocklist name. + * @param options Options for adding or updating blocklist items. + * @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 response of adding blocklistItems to the text blocklist along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response addOrUpdateBlocklistItemsWithResponse(String name, BinaryData options, + RequestOptions requestOptions) { + final String accept = "application/json"; + return service.addOrUpdateBlocklistItemsSync(this.getEndpoint(), this.getServiceVersion().getVersion(), name, + accept, options, requestOptions, Context.NONE); + } + + /** + * Create Or Update Text Blocklist + * + * Updates a text blocklist. If the blocklistName does not exist, a new blocklist will be created. + *

+ * Request Body Schema + *

+ *
{@code
+     * {
+     *     blocklistName: String (Required)
+     *     description: String (Optional)
+     * }
+     * }
+ *

+ * Response Body Schema + *

+ *
{@code
+     * {
+     *     blocklistName: String (Required)
+     *     description: String (Optional)
+     * }
+     * }
+ * + * @param name Text blocklist name. + * @param options The resource instance. + * @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 text Blocklist along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createOrUpdateTextBlocklistWithResponseAsync(String name, BinaryData options, + RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.createOrUpdateTextBlocklist(this.getEndpoint(), + this.getServiceVersion().getVersion(), name, contentType, accept, options, requestOptions, context)); + } + + /** + * Create Or Update Text Blocklist + * + * Updates a text blocklist. If the blocklistName does not exist, a new blocklist will be created. + *

+ * Request Body Schema + *

+ *
{@code
+     * {
+     *     blocklistName: String (Required)
+     *     description: String (Optional)
+     * }
+     * }
+ *

+ * Response Body Schema + *

+ *
{@code
+     * {
+     *     blocklistName: String (Required)
+     *     description: String (Optional)
+     * }
+     * }
+ * + * @param name Text blocklist name. + * @param options The resource instance. + * @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 text Blocklist along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createOrUpdateTextBlocklistWithResponse(String name, BinaryData options, + RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + final String accept = "application/json"; + return service.createOrUpdateTextBlocklistSync(this.getEndpoint(), this.getServiceVersion().getVersion(), name, + contentType, accept, options, requestOptions, Context.NONE); + } + + /** + * Delete Text Blocklist By blocklistName + * + * Deletes a text blocklist. + * + * @param name Text blocklist name. + * @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 {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteTextBlocklistWithResponseAsync(String name, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.deleteTextBlocklist(this.getEndpoint(), + this.getServiceVersion().getVersion(), name, accept, requestOptions, context)); + } + + /** + * Delete Text Blocklist By blocklistName + * + * Deletes a text blocklist. + * + * @param name Text blocklist name. + * @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 {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteTextBlocklistWithResponse(String name, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.deleteTextBlocklistSync(this.getEndpoint(), this.getServiceVersion().getVersion(), name, accept, + requestOptions, Context.NONE); + } + + /** + * Get Text Blocklist By blocklistName + * + * Returns text blocklist details. + *

+ * Response Body Schema + *

+ *
{@code
+     * {
+     *     blocklistName: String (Required)
+     *     description: String (Optional)
+     * }
+     * }
+ * + * @param name Text blocklist name. + * @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 text Blocklist along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getTextBlocklistWithResponseAsync(String name, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.getTextBlocklist(this.getEndpoint(), + this.getServiceVersion().getVersion(), name, accept, requestOptions, context)); + } + + /** + * Get Text Blocklist By blocklistName + * + * Returns text blocklist details. + *

+ * Response Body Schema + *

+ *
{@code
+     * {
+     *     blocklistName: String (Required)
+     *     description: String (Optional)
+     * }
+     * }
+ * + * @param name Text blocklist name. + * @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 text Blocklist along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getTextBlocklistWithResponse(String name, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getTextBlocklistSync(this.getEndpoint(), this.getServiceVersion().getVersion(), name, accept, + requestOptions, Context.NONE); + } + + /** + * Get BlocklistItem By blocklistName And blocklistItemId + * + * Get blocklistItem by blocklistName and blocklistItemId from a text blocklist. + *

+ * Response Body Schema + *

+ *
{@code
+     * {
+     *     blocklistItemId: String (Required)
+     *     description: String (Optional)
+     *     text: String (Required)
+     * }
+     * }
+ * + * @param name Text blocklist name. + * @param blocklistItemId The service will generate a BlocklistItemId, which will be a UUID. + * @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 blocklistItem by blocklistName and blocklistItemId from a text blocklist along with {@link Response} on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getTextBlocklistItemWithResponseAsync(String name, String blocklistItemId, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.getTextBlocklistItem(this.getEndpoint(), + this.getServiceVersion().getVersion(), name, blocklistItemId, accept, requestOptions, context)); + } + + /** + * Get BlocklistItem By blocklistName And blocklistItemId + * + * Get blocklistItem by blocklistName and blocklistItemId from a text blocklist. + *

+ * Response Body Schema + *

+ *
{@code
+     * {
+     *     blocklistItemId: String (Required)
+     *     description: String (Optional)
+     *     text: String (Required)
+     * }
+     * }
+ * + * @param name Text blocklist name. + * @param blocklistItemId The service will generate a BlocklistItemId, which will be a UUID. + * @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 blocklistItem by blocklistName and blocklistItemId from a text blocklist along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getTextBlocklistItemWithResponse(String name, String blocklistItemId, + RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getTextBlocklistItemSync(this.getEndpoint(), this.getServiceVersion().getVersion(), name, + blocklistItemId, accept, requestOptions, Context.NONE); + } + + /** + * Get All BlocklistItems By blocklistName + * + * Get all blocklistItems in a text blocklist. + *

+ * Query Parameters + *

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
topIntegerNoThe number of result items to return.
skipIntegerNoThe number of result items to skip.
maxpagesizeIntegerNoThe maximum number of result items per page.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

+ * Response Body Schema + *

+ *
{@code
+     * {
+     *     blocklistItemId: String (Required)
+     *     description: String (Optional)
+     *     text: String (Required)
+     * }
+     * }
+ * + * @param name Text blocklist name. + * @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 all blocklistItems in a text blocklist along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listTextBlocklistItemsSinglePageAsync(String name, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listTextBlocklistItems(this.getEndpoint(), + this.getServiceVersion().getVersion(), name, accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * Get All BlocklistItems By blocklistName + * + * Get all blocklistItems in a text blocklist. + *

+ * Query Parameters + *

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
topIntegerNoThe number of result items to return.
skipIntegerNoThe number of result items to skip.
maxpagesizeIntegerNoThe maximum number of result items per page.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

+ * Response Body Schema + *

+ *
{@code
+     * {
+     *     blocklistItemId: String (Required)
+     *     description: String (Optional)
+     *     text: String (Required)
+     * }
+     * }
+ * + * @param name Text blocklist name. + * @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 all blocklistItems in a text blocklist as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listTextBlocklistItemsAsync(String name, RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedFlux<>((pageSize) -> { + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listTextBlocklistItemsSinglePageAsync(name, requestOptionsLocal); + }, (nextLink, pageSize) -> { + RequestOptions requestOptionsLocal = new RequestOptions(); + requestOptionsLocal.setContext(requestOptionsForNextPage.getContext()); + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listTextBlocklistItemsNextSinglePageAsync(nextLink, requestOptionsLocal); + }); + } + + /** + * Get All BlocklistItems By blocklistName + * + * Get all blocklistItems in a text blocklist. + *

+ * Query Parameters + *

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
topIntegerNoThe number of result items to return.
skipIntegerNoThe number of result items to skip.
maxpagesizeIntegerNoThe maximum number of result items per page.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

+ * Response Body Schema + *

+ *
{@code
+     * {
+     *     blocklistItemId: String (Required)
+     *     description: String (Optional)
+     *     text: String (Required)
+     * }
+     * }
+ * + * @param name Text blocklist name. + * @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 all blocklistItems in a text blocklist along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listTextBlocklistItemsSinglePage(String name, RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = service.listTextBlocklistItemsSync(this.getEndpoint(), + this.getServiceVersion().getVersion(), name, accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + /** + * Get All BlocklistItems By blocklistName + * + * Get all blocklistItems in a text blocklist. + *

+ * Query Parameters + *

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
topIntegerNoThe number of result items to return.
skipIntegerNoThe number of result items to skip.
maxpagesizeIntegerNoThe maximum number of result items per page.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

+ * Response Body Schema + *

+ *
{@code
+     * {
+     *     blocklistItemId: String (Required)
+     *     description: String (Optional)
+     *     text: String (Required)
+     * }
+     * }
+ * + * @param name Text blocklist name. + * @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 all blocklistItems in a text blocklist as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listTextBlocklistItems(String name, RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedIterable<>((pageSize) -> { + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listTextBlocklistItemsSinglePage(name, requestOptionsLocal); + }, (nextLink, pageSize) -> { + RequestOptions requestOptionsLocal = new RequestOptions(); + requestOptionsLocal.setContext(requestOptionsForNextPage.getContext()); + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listTextBlocklistItemsNextSinglePage(nextLink, requestOptionsLocal); + }); + } + + /** + * Get All Text Blocklists + * + * Get all text blocklists details. + *

+ * Response Body Schema + *

+ *
{@code
+     * {
+     *     blocklistName: String (Required)
+     *     description: String (Optional)
+     * }
+     * }
+ * + * @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 all text blocklists details along with {@link PagedResponse} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listTextBlocklistsSinglePageAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listTextBlocklists(this.getEndpoint(), + this.getServiceVersion().getVersion(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * Get All Text Blocklists + * + * Get all text blocklists details. + *

+ * Response Body Schema + *

+ *
{@code
+     * {
+     *     blocklistName: String (Required)
+     *     description: String (Optional)
+     * }
+     * }
+ * + * @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 all text blocklists details as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listTextBlocklistsAsync(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedFlux<>(() -> listTextBlocklistsSinglePageAsync(requestOptions), + nextLink -> listTextBlocklistsNextSinglePageAsync(nextLink, requestOptionsForNextPage)); + } + + /** + * Get All Text Blocklists + * + * Get all text blocklists details. + *

+ * Response Body Schema + *

+ *
{@code
+     * {
+     *     blocklistName: String (Required)
+     *     description: String (Optional)
+     * }
+     * }
+ * + * @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 all text blocklists details along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listTextBlocklistsSinglePage(RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = service.listTextBlocklistsSync(this.getEndpoint(), + this.getServiceVersion().getVersion(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + /** + * Get All Text Blocklists + * + * Get all text blocklists details. + *

+ * Response Body Schema + *

+ *
{@code
+     * {
+     *     blocklistName: String (Required)
+     *     description: String (Optional)
+     * }
+     * }
+ * + * @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 all text blocklists details as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listTextBlocklists(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedIterable<>(() -> listTextBlocklistsSinglePage(requestOptions), + nextLink -> listTextBlocklistsNextSinglePage(nextLink, requestOptionsForNextPage)); + } + + /** + * Remove BlocklistItems From Text Blocklist + * + * Remove blocklistItems from a text blocklist. You can remove at most 100 BlocklistItems in one request. + *

+ * Request Body Schema + *

+ *
{@code
+     * {
+     *     blocklistItemIds (Required): [
+     *         String (Required)
+     *     ]
+     * }
+     * }
+ * + * @param name Text blocklist name. + * @param options Options for removing blocklist items. + * @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 {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> removeBlocklistItemsWithResponseAsync(String name, BinaryData options, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.removeBlocklistItems(this.getEndpoint(), + this.getServiceVersion().getVersion(), name, accept, options, requestOptions, context)); + } + + /** + * Remove BlocklistItems From Text Blocklist + * + * Remove blocklistItems from a text blocklist. You can remove at most 100 BlocklistItems in one request. + *

+ * Request Body Schema + *

+ *
{@code
+     * {
+     *     blocklistItemIds (Required): [
+     *         String (Required)
+     *     ]
+     * }
+     * }
+ * + * @param name Text blocklist name. + * @param options Options for removing blocklist items. + * @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 {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response removeBlocklistItemsWithResponse(String name, BinaryData options, + RequestOptions requestOptions) { + final String accept = "application/json"; + return service.removeBlocklistItemsSync(this.getEndpoint(), this.getServiceVersion().getVersion(), name, accept, + options, requestOptions, Context.NONE); + } + + /** + * Get All BlocklistItems By blocklistName + * + * Get the next page of items. + *

+ * Response Body Schema + *

+ *
{@code
+     * {
+     *     blocklistItemId: String (Required)
+     *     description: String (Optional)
+     *     text: String (Required)
+     * }
+     * }
+ * + * @param nextLink The URL to get the next list of items + * + * The nextLink parameter. + * @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 paged collection of TextBlocklistItem items along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listTextBlocklistItemsNextSinglePageAsync(String nextLink, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listTextBlocklistItemsNext(nextLink, this.getEndpoint(), accept, + requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * Get All BlocklistItems By blocklistName + * + * Get the next page of items. + *

+ * Response Body Schema + *

+ *
{@code
+     * {
+     *     blocklistItemId: String (Required)
+     *     description: String (Optional)
+     *     text: String (Required)
+     * }
+     * }
+ * + * @param nextLink The URL to get the next list of items + * + * The nextLink parameter. + * @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 paged collection of TextBlocklistItem items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listTextBlocklistItemsNextSinglePage(String nextLink, + RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = service.listTextBlocklistItemsNextSync(nextLink, this.getEndpoint(), accept, + requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + /** + * Get All Text Blocklists + * + * Get the next page of items. + *

+ * Response Body Schema + *

+ *
{@code
+     * {
+     *     blocklistName: String (Required)
+     *     description: String (Optional)
+     * }
+     * }
+ * + * @param nextLink The URL to get the next list of items + * + * The nextLink parameter. + * @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 paged collection of TextBlocklist items along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listTextBlocklistsNextSinglePageAsync(String nextLink, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.listTextBlocklistsNext(nextLink, this.getEndpoint(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * Get All Text Blocklists + * + * Get the next page of items. + *

+ * Response Body Schema + *

+ *
{@code
+     * {
+     *     blocklistName: String (Required)
+     *     description: String (Optional)
+     * }
+     * }
+ * + * @param nextLink The URL to get the next list of items + * + * The nextLink parameter. + * @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 paged collection of TextBlocklist items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listTextBlocklistsNextSinglePage(String nextLink, RequestOptions requestOptions) { + final String accept = "application/json"; + Response res + = service.listTextBlocklistsNextSync(nextLink, this.getEndpoint(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + private List getValues(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + List values = (List) obj.get(path); + return values.stream().map(BinaryData::fromObject).collect(Collectors.toList()); + } catch (RuntimeException e) { + return null; + } + } + + private String getNextLink(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + return (String) obj.get(path); + } catch (RuntimeException e) { + return null; + } + } +} 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 84603c9cf974..74de26118073 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 @@ -6,14 +6,10 @@ import com.azure.ai.contentsafety.ContentSafetyServiceVersion; import com.azure.core.annotation.BodyParam; -import com.azure.core.annotation.Delete; import com.azure.core.annotation.ExpectedResponses; -import com.azure.core.annotation.Get; import com.azure.core.annotation.HeaderParam; import com.azure.core.annotation.Host; import com.azure.core.annotation.HostParam; -import com.azure.core.annotation.Patch; -import com.azure.core.annotation.PathParam; import com.azure.core.annotation.Post; import com.azure.core.annotation.QueryParam; import com.azure.core.annotation.ReturnType; @@ -28,27 +24,23 @@ import com.azure.core.http.HttpPipelineBuilder; import com.azure.core.http.policy.RetryPolicy; import com.azure.core.http.policy.UserAgentPolicy; -import com.azure.core.http.rest.PagedFlux; -import com.azure.core.http.rest.PagedIterable; -import com.azure.core.http.rest.PagedResponse; -import com.azure.core.http.rest.PagedResponseBase; import com.azure.core.http.rest.RequestOptions; import com.azure.core.http.rest.Response; import com.azure.core.http.rest.RestProxy; import com.azure.core.util.BinaryData; import com.azure.core.util.Context; import com.azure.core.util.FluxUtil; -import com.azure.core.util.UrlBuilder; import com.azure.core.util.serializer.JacksonAdapter; import com.azure.core.util.serializer.SerializerAdapter; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; import reactor.core.publisher.Mono; -/** Initializes a new instance of the ContentSafetyClient type. */ +/** + * Initializes a new instance of the ContentSafetyClient type. + */ public final class ContentSafetyClientImpl { - /** The proxy service used to perform REST calls. */ + /** + * The proxy service used to perform REST calls. + */ private final ContentSafetyClientService service; /** @@ -60,43 +52,49 @@ public final class ContentSafetyClientImpl { /** * Gets Supported Cognitive Services endpoints (protocol and hostname, for example: * https://<resource-name>.cognitiveservices.azure.com). - * + * * @return the endpoint value. */ public String getEndpoint() { return this.endpoint; } - /** Service version. */ + /** + * Service version. + */ private final ContentSafetyServiceVersion serviceVersion; /** * Gets Service version. - * + * * @return the serviceVersion value. */ public ContentSafetyServiceVersion getServiceVersion() { return this.serviceVersion; } - /** The HTTP pipeline to send requests through. */ + /** + * The HTTP pipeline to send requests through. + */ private final HttpPipeline httpPipeline; /** * Gets The HTTP pipeline to send requests through. - * + * * @return the httpPipeline value. */ public HttpPipeline getHttpPipeline() { return this.httpPipeline; } - /** The serializer to serialize an object into a string. */ + /** + * The serializer to serialize an object into a string. + */ private final SerializerAdapter serializerAdapter; /** * Gets The serializer to serialize an object into a string. - * + * * @return the serializerAdapter value. */ public SerializerAdapter getSerializerAdapter() { @@ -105,52 +103,46 @@ public SerializerAdapter getSerializerAdapter() { /** * Initializes an instance of ContentSafetyClient client. - * + * * @param endpoint Supported Cognitive Services endpoints (protocol and hostname, for example: - * https://<resource-name>.cognitiveservices.azure.com). + * https://<resource-name>.cognitiveservices.azure.com). * @param serviceVersion Service version. */ public ContentSafetyClientImpl(String endpoint, ContentSafetyServiceVersion serviceVersion) { - this( - new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter(), - endpoint, - serviceVersion); + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); } /** * Initializes an instance of ContentSafetyClient client. - * + * * @param httpPipeline The HTTP pipeline to send requests through. * @param endpoint Supported Cognitive Services endpoints (protocol and hostname, for example: - * https://<resource-name>.cognitiveservices.azure.com). + * https://<resource-name>.cognitiveservices.azure.com). * @param serviceVersion Service version. */ - public ContentSafetyClientImpl( - HttpPipeline httpPipeline, String endpoint, ContentSafetyServiceVersion serviceVersion) { + public ContentSafetyClientImpl(HttpPipeline httpPipeline, String endpoint, + ContentSafetyServiceVersion serviceVersion) { this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); } /** * Initializes an instance of ContentSafetyClient client. - * + * * @param httpPipeline The HTTP pipeline to send requests through. * @param serializerAdapter The serializer to serialize an object into a string. * @param endpoint Supported Cognitive Services endpoints (protocol and hostname, for example: - * https://<resource-name>.cognitiveservices.azure.com). + * https://<resource-name>.cognitiveservices.azure.com). * @param serviceVersion Service version. */ - public ContentSafetyClientImpl( - HttpPipeline httpPipeline, - SerializerAdapter serializerAdapter, - String endpoint, - ContentSafetyServiceVersion serviceVersion) { + public ContentSafetyClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, + ContentSafetyServiceVersion serviceVersion) { this.httpPipeline = httpPipeline; this.serializerAdapter = serializerAdapter; this.endpoint = endpoint; this.serviceVersion = serviceVersion; - this.service = - RestProxy.create(ContentSafetyClientService.class, this.httpPipeline, this.getSerializerAdapter()); + this.service + = RestProxy.create(ContentSafetyClientService.class, this.httpPipeline, this.getSerializerAdapter()); } /** @@ -161,498 +153,54 @@ public ContentSafetyClientImpl( @ServiceInterface(name = "ContentSafetyClient") public interface ContentSafetyClientService { @Post("/text:analyze") - @ExpectedResponses({200}) - @UnexpectedResponseExceptionType( - value = ClientAuthenticationException.class, - code = {401}) - @UnexpectedResponseExceptionType( - value = ResourceNotFoundException.class, - code = {404}) - @UnexpectedResponseExceptionType( - value = ResourceModifiedException.class, - code = {409}) + @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, - @QueryParam("api-version") String apiVersion, - @HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, - Context context); + 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("/text:analyze") - @ExpectedResponses({200}) - @UnexpectedResponseExceptionType( - value = ClientAuthenticationException.class, - code = {401}) - @UnexpectedResponseExceptionType( - value = ResourceNotFoundException.class, - code = {404}) - @UnexpectedResponseExceptionType( - value = ResourceModifiedException.class, - code = {409}) + @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, - @QueryParam("api-version") String apiVersion, - @HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, - Context context); + Response analyzeTextSync(@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") - @ExpectedResponses({200}) - @UnexpectedResponseExceptionType( - value = ClientAuthenticationException.class, - code = {401}) - @UnexpectedResponseExceptionType( - value = ResourceNotFoundException.class, - code = {404}) - @UnexpectedResponseExceptionType( - value = ResourceModifiedException.class, - code = {409}) + @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, - @QueryParam("api-version") String apiVersion, - @HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, - Context context); + 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("/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 analyzeImageSync( - @HostParam("endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, - @HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, - Context context); - - @Get("/text/blocklists/{blocklistName}") - @ExpectedResponses({200}) - @UnexpectedResponseExceptionType( - value = ClientAuthenticationException.class, - code = {401}) - @UnexpectedResponseExceptionType( - value = ResourceNotFoundException.class, - code = {404}) - @UnexpectedResponseExceptionType( - value = ResourceModifiedException.class, - code = {409}) - @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getTextBlocklist( - @HostParam("endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, - @PathParam("blocklistName") String blocklistName, - @HeaderParam("accept") String accept, - RequestOptions requestOptions, - Context context); - - @Get("/text/blocklists/{blocklistName}") - @ExpectedResponses({200}) - @UnexpectedResponseExceptionType( - value = ClientAuthenticationException.class, - code = {401}) - @UnexpectedResponseExceptionType( - value = ResourceNotFoundException.class, - code = {404}) - @UnexpectedResponseExceptionType( - value = ResourceModifiedException.class, - code = {409}) - @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getTextBlocklistSync( - @HostParam("endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, - @PathParam("blocklistName") String blocklistName, - @HeaderParam("accept") String accept, - RequestOptions requestOptions, - Context context); - - @Patch("/text/blocklists/{blocklistName}") - @ExpectedResponses({200, 201}) - @UnexpectedResponseExceptionType( - value = ClientAuthenticationException.class, - code = {401}) - @UnexpectedResponseExceptionType( - value = ResourceNotFoundException.class, - code = {404}) - @UnexpectedResponseExceptionType( - value = ResourceModifiedException.class, - code = {409}) - @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> createOrUpdateTextBlocklist( - @HostParam("endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, - @PathParam("blocklistName") String blocklistName, - @HeaderParam("Content-Type") String contentType, - @HeaderParam("accept") String accept, - @BodyParam("application/merge-patch+json") BinaryData resource, - RequestOptions requestOptions, - Context context); - - @Patch("/text/blocklists/{blocklistName}") - @ExpectedResponses({200, 201}) - @UnexpectedResponseExceptionType( - value = ClientAuthenticationException.class, - code = {401}) - @UnexpectedResponseExceptionType( - value = ResourceNotFoundException.class, - code = {404}) - @UnexpectedResponseExceptionType( - value = ResourceModifiedException.class, - code = {409}) - @UnexpectedResponseExceptionType(HttpResponseException.class) - Response createOrUpdateTextBlocklistSync( - @HostParam("endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, - @PathParam("blocklistName") String blocklistName, - @HeaderParam("Content-Type") String contentType, - @HeaderParam("accept") String accept, - @BodyParam("application/merge-patch+json") BinaryData resource, - RequestOptions requestOptions, - Context context); - - @Delete("/text/blocklists/{blocklistName}") - @ExpectedResponses({204}) - @UnexpectedResponseExceptionType( - value = ClientAuthenticationException.class, - code = {401}) - @UnexpectedResponseExceptionType( - value = ResourceNotFoundException.class, - code = {404}) - @UnexpectedResponseExceptionType( - value = ResourceModifiedException.class, - code = {409}) - @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> deleteTextBlocklist( - @HostParam("endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, - @PathParam("blocklistName") String blocklistName, - @HeaderParam("accept") String accept, - RequestOptions requestOptions, - Context context); - - @Delete("/text/blocklists/{blocklistName}") - @ExpectedResponses({204}) - @UnexpectedResponseExceptionType( - value = ClientAuthenticationException.class, - code = {401}) - @UnexpectedResponseExceptionType( - value = ResourceNotFoundException.class, - code = {404}) - @UnexpectedResponseExceptionType( - value = ResourceModifiedException.class, - code = {409}) - @UnexpectedResponseExceptionType(HttpResponseException.class) - Response deleteTextBlocklistSync( - @HostParam("endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, - @PathParam("blocklistName") String blocklistName, - @HeaderParam("accept") String accept, - RequestOptions requestOptions, - Context context); - - @Get("/text/blocklists") - @ExpectedResponses({200}) - @UnexpectedResponseExceptionType( - value = ClientAuthenticationException.class, - code = {401}) - @UnexpectedResponseExceptionType( - value = ResourceNotFoundException.class, - code = {404}) - @UnexpectedResponseExceptionType( - value = ResourceModifiedException.class, - code = {409}) - @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> listTextBlocklists( - @HostParam("endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, - @HeaderParam("accept") String accept, - RequestOptions requestOptions, - Context context); - - @Get("/text/blocklists") - @ExpectedResponses({200}) - @UnexpectedResponseExceptionType( - value = ClientAuthenticationException.class, - code = {401}) - @UnexpectedResponseExceptionType( - value = ResourceNotFoundException.class, - code = {404}) - @UnexpectedResponseExceptionType( - value = ResourceModifiedException.class, - code = {409}) - @UnexpectedResponseExceptionType(HttpResponseException.class) - Response listTextBlocklistsSync( - @HostParam("endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, - @HeaderParam("accept") String accept, - RequestOptions requestOptions, - Context context); - - @Post("/text/blocklists/{blocklistName}:addBlockItems") - @ExpectedResponses({200}) - @UnexpectedResponseExceptionType( - value = ClientAuthenticationException.class, - code = {401}) - @UnexpectedResponseExceptionType( - value = ResourceNotFoundException.class, - code = {404}) - @UnexpectedResponseExceptionType( - value = ResourceModifiedException.class, - code = {409}) - @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> addBlockItems( - @HostParam("endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, - @PathParam("blocklistName") String blocklistName, - @HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData addBlockItemsOptions, - RequestOptions requestOptions, - Context context); - - @Post("/text/blocklists/{blocklistName}:addBlockItems") - @ExpectedResponses({200}) - @UnexpectedResponseExceptionType( - value = ClientAuthenticationException.class, - code = {401}) - @UnexpectedResponseExceptionType( - value = ResourceNotFoundException.class, - code = {404}) - @UnexpectedResponseExceptionType( - value = ResourceModifiedException.class, - code = {409}) - @UnexpectedResponseExceptionType(HttpResponseException.class) - Response addBlockItemsSync( - @HostParam("endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, - @PathParam("blocklistName") String blocklistName, - @HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData addBlockItemsOptions, - RequestOptions requestOptions, - Context context); - - @Post("/text/blocklists/{blocklistName}:removeBlockItems") - @ExpectedResponses({204}) - @UnexpectedResponseExceptionType( - value = ClientAuthenticationException.class, - code = {401}) - @UnexpectedResponseExceptionType( - value = ResourceNotFoundException.class, - code = {404}) - @UnexpectedResponseExceptionType( - value = ResourceModifiedException.class, - code = {409}) - @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> removeBlockItems( - @HostParam("endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, - @PathParam("blocklistName") String blocklistName, - @HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData removeBlockItemsOptions, - RequestOptions requestOptions, - Context context); - - @Post("/text/blocklists/{blocklistName}:removeBlockItems") - @ExpectedResponses({204}) - @UnexpectedResponseExceptionType( - value = ClientAuthenticationException.class, - code = {401}) - @UnexpectedResponseExceptionType( - value = ResourceNotFoundException.class, - code = {404}) - @UnexpectedResponseExceptionType( - value = ResourceModifiedException.class, - code = {409}) - @UnexpectedResponseExceptionType(HttpResponseException.class) - Response removeBlockItemsSync( - @HostParam("endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, - @PathParam("blocklistName") String blocklistName, - @HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData removeBlockItemsOptions, - RequestOptions requestOptions, - Context context); - - @Get("/text/blocklists/{blocklistName}/blockItems/{blockItemId}") - @ExpectedResponses({200}) - @UnexpectedResponseExceptionType( - value = ClientAuthenticationException.class, - code = {401}) - @UnexpectedResponseExceptionType( - value = ResourceNotFoundException.class, - code = {404}) - @UnexpectedResponseExceptionType( - value = ResourceModifiedException.class, - code = {409}) - @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getTextBlocklistItem( - @HostParam("endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, - @PathParam("blocklistName") String blocklistName, - @PathParam("blockItemId") String blockItemId, - @HeaderParam("accept") String accept, - RequestOptions requestOptions, - Context context); - - @Get("/text/blocklists/{blocklistName}/blockItems/{blockItemId}") - @ExpectedResponses({200}) - @UnexpectedResponseExceptionType( - value = ClientAuthenticationException.class, - code = {401}) - @UnexpectedResponseExceptionType( - value = ResourceNotFoundException.class, - code = {404}) - @UnexpectedResponseExceptionType( - value = ResourceModifiedException.class, - code = {409}) - @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getTextBlocklistItemSync( - @HostParam("endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, - @PathParam("blocklistName") String blocklistName, - @PathParam("blockItemId") String blockItemId, - @HeaderParam("accept") String accept, - RequestOptions requestOptions, - Context context); - - @Get("/text/blocklists/{blocklistName}/blockItems") - @ExpectedResponses({200}) - @UnexpectedResponseExceptionType( - value = ClientAuthenticationException.class, - code = {401}) - @UnexpectedResponseExceptionType( - value = ResourceNotFoundException.class, - code = {404}) - @UnexpectedResponseExceptionType( - value = ResourceModifiedException.class, - code = {409}) - @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> listTextBlocklistItems( - @HostParam("endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, - @PathParam("blocklistName") String blocklistName, - @HeaderParam("accept") String accept, - RequestOptions requestOptions, - Context context); - - @Get("/text/blocklists/{blocklistName}/blockItems") - @ExpectedResponses({200}) - @UnexpectedResponseExceptionType( - value = ClientAuthenticationException.class, - code = {401}) - @UnexpectedResponseExceptionType( - value = ResourceNotFoundException.class, - code = {404}) - @UnexpectedResponseExceptionType( - value = ResourceModifiedException.class, - code = {409}) - @UnexpectedResponseExceptionType(HttpResponseException.class) - Response listTextBlocklistItemsSync( - @HostParam("endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, - @PathParam("blocklistName") String blocklistName, - @HeaderParam("accept") String accept, - RequestOptions requestOptions, - Context context); - - @Get("{nextLink}") - @ExpectedResponses({200}) - @UnexpectedResponseExceptionType( - value = ClientAuthenticationException.class, - code = {401}) - @UnexpectedResponseExceptionType( - value = ResourceNotFoundException.class, - code = {404}) - @UnexpectedResponseExceptionType( - value = ResourceModifiedException.class, - code = {409}) - @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> listTextBlocklistsNext( - @PathParam(value = "nextLink", encoded = true) String nextLink, - @HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, - RequestOptions requestOptions, - Context context); - - @Get("{nextLink}") - @ExpectedResponses({200}) - @UnexpectedResponseExceptionType( - value = ClientAuthenticationException.class, - code = {401}) - @UnexpectedResponseExceptionType( - value = ResourceNotFoundException.class, - code = {404}) - @UnexpectedResponseExceptionType( - value = ResourceModifiedException.class, - code = {409}) - @UnexpectedResponseExceptionType(HttpResponseException.class) - Response listTextBlocklistsNextSync( - @PathParam(value = "nextLink", encoded = true) String nextLink, - @HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, - RequestOptions requestOptions, - Context context); - - @Get("{nextLink}") - @ExpectedResponses({200}) - @UnexpectedResponseExceptionType( - value = ClientAuthenticationException.class, - code = {401}) - @UnexpectedResponseExceptionType( - value = ResourceNotFoundException.class, - code = {404}) - @UnexpectedResponseExceptionType( - value = ResourceModifiedException.class, - code = {409}) + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> listTextBlocklistItemsNext( - @PathParam(value = "nextLink", encoded = true) String nextLink, - @HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, - RequestOptions requestOptions, - Context context); - - @Get("{nextLink}") - @ExpectedResponses({200}) - @UnexpectedResponseExceptionType( - value = ClientAuthenticationException.class, - code = {401}) - @UnexpectedResponseExceptionType( - value = ResourceNotFoundException.class, - code = {404}) - @UnexpectedResponseExceptionType( - value = ResourceModifiedException.class, - code = {409}) - @UnexpectedResponseExceptionType(HttpResponseException.class) - Response listTextBlocklistItemsNextSync( - @PathParam(value = "nextLink", encoded = true) String nextLink, - @HostParam("endpoint") String endpoint, - @HeaderParam("accept") String accept, - RequestOptions requestOptions, - Context context); + Response analyzeImageSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("accept") String accept, + @BodyParam("application/json") BinaryData options, RequestOptions requestOptions, Context context); } /** * Analyze Text - * - *

A sync API for harmful content analysis for text. Currently, we support four categories: Hate, SelfHarm, - * Sexual, Violence. - * - *

Request Body Schema - * + * + * 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
      * {
      *     text: String (Required)
@@ -662,63 +210,54 @@ Response listTextBlocklistItemsNextSync(
      *     blocklistNames (Optional): [
      *         String (Optional)
      *     ]
-     *     breakByBlocklists: Boolean (Optional)
+     *     haltOnBlocklistHit: Boolean (Optional)
+     *     outputType: String(FourSeverityLevels/EightSeverityLevels) (Optional)
      * }
      * }
- * - *

Response Body Schema - * + *

+ * Response Body Schema + *

*
{@code
      * {
-     *     blocklistsMatchResults (Optional): [
+     *     blocklistsMatch (Optional): [
      *          (Optional){
      *             blocklistName: String (Required)
-     *             blockItemId: String (Required)
-     *             blockItemText: String (Required)
-     *             offset: int (Required)
-     *             length: int (Required)
+     *             blocklistItemId: String (Required)
+     *             blocklistItemText: String (Required)
+     *         }
+     *     ]
+     *     categoriesAnalysis (Required): [
+     *          (Required){
+     *             category: String(Hate/SelfHarm/Sexual/Violence) (Required)
+     *             severity: Integer (Optional)
      *         }
      *     ]
-     *     hateResult (Optional): {
-     *         category: String(Hate/SelfHarm/Sexual/Violence) (Required)
-     *         severity: int (Required)
-     *     }
-     *     selfHarmResult (Optional): (recursive schema, see selfHarmResult above)
-     *     sexualResult (Optional): (recursive schema, see sexualResult above)
-     *     violenceResult (Optional): (recursive schema, see violenceResult above)
      * }
      * }
- * - * @param body The request of text analysis. + * + * @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 analysis response of the text 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> analyzeTextWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + public Mono> analyzeTextWithResponseAsync(BinaryData options, RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext( - context -> - service.analyzeText( - this.getEndpoint(), - this.getServiceVersion().getVersion(), - accept, - body, - requestOptions, - context)); + return FluxUtil.withContext(context -> service.analyzeText(this.getEndpoint(), + this.getServiceVersion().getVersion(), accept, options, requestOptions, context)); } /** * Analyze Text - * - *

A sync API for harmful content analysis for text. Currently, we support four categories: Hate, SelfHarm, - * Sexual, Violence. - * - *

Request Body Schema - * + * + * 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
      * {
      *     text: String (Required)
@@ -728,56 +267,54 @@ public Mono> analyzeTextWithResponseAsync(BinaryData body,
      *     blocklistNames (Optional): [
      *         String (Optional)
      *     ]
-     *     breakByBlocklists: Boolean (Optional)
+     *     haltOnBlocklistHit: Boolean (Optional)
+     *     outputType: String(FourSeverityLevels/EightSeverityLevels) (Optional)
      * }
      * }
- * - *

Response Body Schema - * + *

+ * Response Body Schema + *

*
{@code
      * {
-     *     blocklistsMatchResults (Optional): [
+     *     blocklistsMatch (Optional): [
      *          (Optional){
      *             blocklistName: String (Required)
-     *             blockItemId: String (Required)
-     *             blockItemText: String (Required)
-     *             offset: int (Required)
-     *             length: int (Required)
+     *             blocklistItemId: String (Required)
+     *             blocklistItemText: String (Required)
+     *         }
+     *     ]
+     *     categoriesAnalysis (Required): [
+     *          (Required){
+     *             category: String(Hate/SelfHarm/Sexual/Violence) (Required)
+     *             severity: Integer (Optional)
      *         }
      *     ]
-     *     hateResult (Optional): {
-     *         category: String(Hate/SelfHarm/Sexual/Violence) (Required)
-     *         severity: int (Required)
-     *     }
-     *     selfHarmResult (Optional): (recursive schema, see selfHarmResult above)
-     *     sexualResult (Optional): (recursive schema, see sexualResult above)
-     *     violenceResult (Optional): (recursive schema, see violenceResult above)
      * }
      * }
- * - * @param body The request of text analysis. + * + * @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 analysis response of the text along with {@link Response}. + * @return the text analysis response along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response analyzeTextWithResponse(BinaryData body, RequestOptions requestOptions) { + public Response analyzeTextWithResponse(BinaryData options, RequestOptions requestOptions) { final String accept = "application/json"; - return service.analyzeTextSync( - this.getEndpoint(), this.getServiceVersion().getVersion(), accept, body, requestOptions, Context.NONE); + return service.analyzeTextSync(this.getEndpoint(), this.getServiceVersion().getVersion(), accept, options, + requestOptions, Context.NONE); } /** * Analyze Image - * - *

A sync API for harmful content analysis for image. Currently, we support four categories: Hate, SelfHarm, - * Sexual, Violence. - * - *

Request Body Schema - * + * + * 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
      * {
      *     image (Required): {
@@ -787,53 +324,46 @@ public Response analyzeTextWithResponse(BinaryData body, RequestOpti
      *     categories (Optional): [
      *         String(Hate/SelfHarm/Sexual/Violence) (Optional)
      *     ]
+     *     outputType: String(FourSeverityLevels) (Optional)
      * }
      * }
- * - *

Response Body Schema - * + *

+ * Response Body Schema + *

*
{@code
      * {
-     *     hateResult (Optional): {
-     *         category: String(Hate/SelfHarm/Sexual/Violence) (Required)
-     *         severity: int (Required)
-     *     }
-     *     selfHarmResult (Optional): (recursive schema, see selfHarmResult above)
-     *     sexualResult (Optional): (recursive schema, see sexualResult above)
-     *     violenceResult (Optional): (recursive schema, see violenceResult above)
+     *     categoriesAnalysis (Required): [
+     *          (Required){
+     *             category: String(Hate/SelfHarm/Sexual/Violence) (Required)
+     *             severity: Integer (Optional)
+     *         }
+     *     ]
      * }
      * }
- * - * @param body The analysis request of the image. + * + * @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 analysis response of the image 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> analyzeImageWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + public Mono> analyzeImageWithResponseAsync(BinaryData options, RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext( - context -> - service.analyzeImage( - this.getEndpoint(), - this.getServiceVersion().getVersion(), - accept, - body, - requestOptions, - context)); + return FluxUtil.withContext(context -> service.analyzeImage(this.getEndpoint(), + this.getServiceVersion().getVersion(), accept, options, requestOptions, context)); } /** * Analyze Image - * - *

A sync API for harmful content analysis for image. Currently, we support four categories: Hate, SelfHarm, - * Sexual, Violence. - * - *

Request Body Schema - * + * + * 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
      * {
      *     image (Required): {
@@ -843,1115 +373,35 @@ public Mono> analyzeImageWithResponseAsync(BinaryData body,
      *     categories (Optional): [
      *         String(Hate/SelfHarm/Sexual/Violence) (Optional)
      *     ]
+     *     outputType: String(FourSeverityLevels) (Optional)
      * }
      * }
- * - *

Response Body Schema - * - *

{@code
-     * {
-     *     hateResult (Optional): {
-     *         category: String(Hate/SelfHarm/Sexual/Violence) (Required)
-     *         severity: int (Required)
-     *     }
-     *     selfHarmResult (Optional): (recursive schema, see selfHarmResult above)
-     *     sexualResult (Optional): (recursive schema, see sexualResult above)
-     *     violenceResult (Optional): (recursive schema, see violenceResult above)
-     * }
-     * }
- * - * @param body The analysis request of the image. - * @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 analysis response of the image along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response analyzeImageWithResponse(BinaryData body, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.analyzeImageSync( - this.getEndpoint(), this.getServiceVersion().getVersion(), accept, body, requestOptions, Context.NONE); - } - - /** - * Get Text Blocklist By blocklistName - * - *

Returns text blocklist details. - * - *

Response Body Schema - * - *

{@code
-     * {
-     *     blocklistName: String (Required)
-     *     description: String (Optional)
-     * }
-     * }
- * - * @param blocklistName Text blocklist name. - * @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 text Blocklist along with {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getTextBlocklistWithResponseAsync( - String blocklistName, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext( - context -> - service.getTextBlocklist( - this.getEndpoint(), - this.getServiceVersion().getVersion(), - blocklistName, - accept, - requestOptions, - context)); - } - - /** - * Get Text Blocklist By blocklistName - * - *

Returns text blocklist details. - * - *

Response Body Schema - * - *

{@code
-     * {
-     *     blocklistName: String (Required)
-     *     description: String (Optional)
-     * }
-     * }
- * - * @param blocklistName Text blocklist name. - * @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 text Blocklist along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response getTextBlocklistWithResponse(String blocklistName, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.getTextBlocklistSync( - this.getEndpoint(), - this.getServiceVersion().getVersion(), - blocklistName, - accept, - requestOptions, - Context.NONE); - } - - /** - * Create Or Update Text Blocklist - * - *

Updates a text blocklist, if blocklistName does not exist, create a new blocklist. - * - *

Request Body Schema - * - *

{@code
-     * {
-     *     blocklistName: String (Required)
-     *     description: String (Optional)
-     * }
-     * }
- * - *

Response Body Schema - * - *

{@code
-     * {
-     *     blocklistName: String (Required)
-     *     description: String (Optional)
-     * }
-     * }
- * - * @param blocklistName Text blocklist name. - * @param resource The resource instance. - * @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 text Blocklist along with {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createOrUpdateTextBlocklistWithResponseAsync( - String blocklistName, BinaryData resource, RequestOptions requestOptions) { - final String contentType = "application/merge-patch+json"; - final String accept = "application/json"; - return FluxUtil.withContext( - context -> - service.createOrUpdateTextBlocklist( - this.getEndpoint(), - this.getServiceVersion().getVersion(), - blocklistName, - contentType, - accept, - resource, - requestOptions, - context)); - } - - /** - * Create Or Update Text Blocklist - * - *

Updates a text blocklist, if blocklistName does not exist, create a new blocklist. - * - *

Request Body Schema - * - *

{@code
-     * {
-     *     blocklistName: String (Required)
-     *     description: String (Optional)
-     * }
-     * }
- * - *

Response Body Schema - * - *

{@code
-     * {
-     *     blocklistName: String (Required)
-     *     description: String (Optional)
-     * }
-     * }
- * - * @param blocklistName Text blocklist name. - * @param resource The resource instance. - * @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 text Blocklist along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response createOrUpdateTextBlocklistWithResponse( - String blocklistName, BinaryData resource, RequestOptions requestOptions) { - final String contentType = "application/merge-patch+json"; - final String accept = "application/json"; - return service.createOrUpdateTextBlocklistSync( - this.getEndpoint(), - this.getServiceVersion().getVersion(), - blocklistName, - contentType, - accept, - resource, - requestOptions, - Context.NONE); - } - - /** - * Delete Text Blocklist By blocklistName - * - *

Deletes a text blocklist. - * - * @param blocklistName Text blocklist name. - * @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 {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> deleteTextBlocklistWithResponseAsync( - String blocklistName, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext( - context -> - service.deleteTextBlocklist( - this.getEndpoint(), - this.getServiceVersion().getVersion(), - blocklistName, - accept, - requestOptions, - context)); - } - - /** - * Delete Text Blocklist By blocklistName - * - *

Deletes a text blocklist. - * - * @param blocklistName Text blocklist name. - * @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 {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response deleteTextBlocklistWithResponse(String blocklistName, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.deleteTextBlocklistSync( - this.getEndpoint(), - this.getServiceVersion().getVersion(), - blocklistName, - accept, - requestOptions, - Context.NONE); - } - - /** - * Get All Text Blocklists - * - *

Get all text blocklists details. - * - *

Response Body Schema - * - *

{@code
-     * {
-     *     blocklistName: String (Required)
-     *     description: String (Optional)
-     * }
-     * }
- * - * @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 all text blocklists details along with {@link PagedResponse} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - private Mono> listTextBlocklistsSinglePageAsync(RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext( - context -> - service.listTextBlocklists( - this.getEndpoint(), - this.getServiceVersion().getVersion(), - accept, - requestOptions, - context)) - .map( - res -> - new PagedResponseBase<>( - res.getRequest(), - res.getStatusCode(), - res.getHeaders(), - getValues(res.getValue(), "value"), - getNextLink(res.getValue(), "nextLink"), - null)); - } - - /** - * Get All Text Blocklists - * - *

Get all text blocklists details. - * - *

Response Body Schema - * - *

{@code
-     * {
-     *     blocklistName: String (Required)
-     *     description: String (Optional)
-     * }
-     * }
- * - * @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 all text blocklists details as paginated response with {@link PagedFlux}. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux listTextBlocklistsAsync(RequestOptions requestOptions) { - RequestOptions requestOptionsForNextPage = new RequestOptions(); - requestOptionsForNextPage.setContext( - requestOptions != null && requestOptions.getContext() != null - ? requestOptions.getContext() - : Context.NONE); - return new PagedFlux<>( - () -> listTextBlocklistsSinglePageAsync(requestOptions), - nextLink -> listTextBlocklistsNextSinglePageAsync(nextLink, requestOptionsForNextPage)); - } - - /** - * Get All Text Blocklists - * - *

Get all text blocklists details. - * - *

Response Body Schema - * - *

{@code
-     * {
-     *     blocklistName: String (Required)
-     *     description: String (Optional)
-     * }
-     * }
- * - * @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 all text blocklists details along with {@link PagedResponse}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - private PagedResponse listTextBlocklistsSinglePage(RequestOptions requestOptions) { - final String accept = "application/json"; - Response res = - service.listTextBlocklistsSync( - this.getEndpoint(), - this.getServiceVersion().getVersion(), - accept, - requestOptions, - Context.NONE); - return new PagedResponseBase<>( - res.getRequest(), - res.getStatusCode(), - res.getHeaders(), - getValues(res.getValue(), "value"), - getNextLink(res.getValue(), "nextLink"), - null); - } - - /** - * Get All Text Blocklists - * - *

Get all text blocklists details. - * - *

Response Body Schema - * + *

+ * Response Body Schema + *

*
{@code
      * {
-     *     blocklistName: String (Required)
-     *     description: String (Optional)
-     * }
-     * }
- * - * @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 all text blocklists details as paginated response with {@link PagedIterable}. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable listTextBlocklists(RequestOptions requestOptions) { - RequestOptions requestOptionsForNextPage = new RequestOptions(); - requestOptionsForNextPage.setContext( - requestOptions != null && requestOptions.getContext() != null - ? requestOptions.getContext() - : Context.NONE); - return new PagedIterable<>( - () -> listTextBlocklistsSinglePage(requestOptions), - nextLink -> listTextBlocklistsNextSinglePage(nextLink, requestOptionsForNextPage)); - } - - /** - * Add BlockItems To Text Blocklist - * - *

Add blockItems to a text blocklist. You can add at most 100 BlockItems in one request. - * - *

Request Body Schema - * - *

{@code
-     * {
-     *     blockItems (Required): [
-     *          (Required){
-     *             description: String (Optional)
-     *             text: String (Required)
-     *         }
-     *     ]
-     * }
-     * }
- * - *

Response Body Schema - * - *

{@code
-     * {
-     *     value (Optional): [
-     *          (Optional){
-     *             blockItemId: String (Required)
-     *             description: String (Optional)
-     *             text: String (Required)
-     *         }
-     *     ]
-     * }
-     * }
- * - * @param blocklistName Text blocklist name. - * @param addBlockItemsOptions The request of adding blockItems to text blocklist. - * @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 response of adding blockItems to text blocklist along with {@link Response} on successful completion - * of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> addBlockItemsWithResponseAsync( - String blocklistName, BinaryData addBlockItemsOptions, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext( - context -> - service.addBlockItems( - this.getEndpoint(), - this.getServiceVersion().getVersion(), - blocklistName, - accept, - addBlockItemsOptions, - requestOptions, - context)); - } - - /** - * Add BlockItems To Text Blocklist - * - *

Add blockItems to a text blocklist. You can add at most 100 BlockItems in one request. - * - *

Request Body Schema - * - *

{@code
-     * {
-     *     blockItems (Required): [
+     *     categoriesAnalysis (Required): [
      *          (Required){
-     *             description: String (Optional)
-     *             text: String (Required)
-     *         }
-     *     ]
-     * }
-     * }
- * - *

Response Body Schema - * - *

{@code
-     * {
-     *     value (Optional): [
-     *          (Optional){
-     *             blockItemId: String (Required)
-     *             description: String (Optional)
-     *             text: String (Required)
+     *             category: String(Hate/SelfHarm/Sexual/Violence) (Required)
+     *             severity: Integer (Optional)
      *         }
      *     ]
      * }
      * }
- * - * @param blocklistName Text blocklist name. - * @param addBlockItemsOptions The request of adding blockItems to text blocklist. - * @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 response of adding blockItems to text blocklist along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response addBlockItemsWithResponse( - String blocklistName, BinaryData addBlockItemsOptions, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.addBlockItemsSync( - this.getEndpoint(), - this.getServiceVersion().getVersion(), - blocklistName, - accept, - addBlockItemsOptions, - requestOptions, - Context.NONE); - } - - /** - * Remove BlockItems From Text Blocklist - * - *

Remove blockItems from a text blocklist. You can remove at most 100 BlockItems in one request. - * - *

Request Body Schema - * - *

{@code
-     * {
-     *     blockItemIds (Required): [
-     *         String (Required)
-     *     ]
-     * }
-     * }
- * - * @param blocklistName Text blocklist name. - * @param removeBlockItemsOptions The request of removing blockItems from text blocklist. - * @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 {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> removeBlockItemsWithResponseAsync( - String blocklistName, BinaryData removeBlockItemsOptions, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext( - context -> - service.removeBlockItems( - this.getEndpoint(), - this.getServiceVersion().getVersion(), - blocklistName, - accept, - removeBlockItemsOptions, - requestOptions, - context)); - } - - /** - * Remove BlockItems From Text Blocklist - * - *

Remove blockItems from a text blocklist. You can remove at most 100 BlockItems in one request. - * - *

Request Body Schema - * - *

{@code
-     * {
-     *     blockItemIds (Required): [
-     *         String (Required)
-     *     ]
-     * }
-     * }
- * - * @param blocklistName Text blocklist name. - * @param removeBlockItemsOptions The request of removing blockItems from text blocklist. - * @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 {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response removeBlockItemsWithResponse( - String blocklistName, BinaryData removeBlockItemsOptions, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.removeBlockItemsSync( - this.getEndpoint(), - this.getServiceVersion().getVersion(), - blocklistName, - accept, - removeBlockItemsOptions, - requestOptions, - Context.NONE); - } - - /** - * Get BlockItem By blocklistName And blockItemId - * - *

Get blockItem By blockItemId from a text blocklist. - * - *

Response Body Schema - * - *

{@code
-     * {
-     *     blockItemId: String (Required)
-     *     description: String (Optional)
-     *     text: String (Required)
-     * }
-     * }
- * - * @param blocklistName Text blocklist name. - * @param blockItemId Block Item Id. It will be uuid. - * @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 blockItem By blockItemId from a text blocklist along with {@link Response} on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getTextBlocklistItemWithResponseAsync( - String blocklistName, String blockItemId, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext( - context -> - service.getTextBlocklistItem( - this.getEndpoint(), - this.getServiceVersion().getVersion(), - blocklistName, - blockItemId, - accept, - requestOptions, - context)); - } - - /** - * Get BlockItem By blocklistName And blockItemId - * - *

Get blockItem By blockItemId from a text blocklist. - * - *

Response Body Schema - * - *

{@code
-     * {
-     *     blockItemId: String (Required)
-     *     description: String (Optional)
-     *     text: String (Required)
-     * }
-     * }
- * - * @param blocklistName Text blocklist name. - * @param blockItemId Block Item Id. It will be uuid. + * + * @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 blockItem By blockItemId from a text blocklist along with {@link Response}. + * @return the image analysis response along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response getTextBlocklistItemWithResponse( - String blocklistName, String blockItemId, RequestOptions requestOptions) { + public Response analyzeImageWithResponse(BinaryData options, RequestOptions requestOptions) { final String accept = "application/json"; - return service.getTextBlocklistItemSync( - this.getEndpoint(), - this.getServiceVersion().getVersion(), - blocklistName, - blockItemId, - accept, - requestOptions, - Context.NONE); - } - - /** - * Get All BlockItems By blocklistName - * - *

Get all blockItems in a text blocklist. - * - *

Query Parameters - * - * - * - * - * - * - * - *
Query Parameters
NameTypeRequiredDescription
topIntegerNoThe number of result items to return.
skipIntegerNoThe number of result items to skip.
maxpagesizeIntegerNoThe maximum number of result items per page.
- * - * You can add these to a request with {@link RequestOptions#addQueryParam} - * - *

Response Body Schema - * - *

{@code
-     * {
-     *     blockItemId: String (Required)
-     *     description: String (Optional)
-     *     text: String (Required)
-     * }
-     * }
- * - * @param blocklistName Text blocklist name. - * @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 all blockItems in a text blocklist along with {@link PagedResponse} on successful completion of {@link - * Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - private Mono> listTextBlocklistItemsSinglePageAsync( - String blocklistName, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext( - context -> - service.listTextBlocklistItems( - this.getEndpoint(), - this.getServiceVersion().getVersion(), - blocklistName, - accept, - requestOptions, - context)) - .map( - res -> - new PagedResponseBase<>( - res.getRequest(), - res.getStatusCode(), - res.getHeaders(), - getValues(res.getValue(), "value"), - getNextLink(res.getValue(), "nextLink"), - null)); - } - - /** - * Get All BlockItems By blocklistName - * - *

Get all blockItems in a text blocklist. - * - *

Query Parameters - * - * - * - * - * - * - * - *
Query Parameters
NameTypeRequiredDescription
topIntegerNoThe number of result items to return.
skipIntegerNoThe number of result items to skip.
maxpagesizeIntegerNoThe maximum number of result items per page.
- * - * You can add these to a request with {@link RequestOptions#addQueryParam} - * - *

Response Body Schema - * - *

{@code
-     * {
-     *     blockItemId: String (Required)
-     *     description: String (Optional)
-     *     text: String (Required)
-     * }
-     * }
- * - * @param blocklistName Text blocklist name. - * @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 all blockItems in a text blocklist as paginated response with {@link PagedFlux}. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux listTextBlocklistItemsAsync(String blocklistName, RequestOptions requestOptions) { - RequestOptions requestOptionsForNextPage = new RequestOptions(); - requestOptionsForNextPage.setContext( - requestOptions != null && requestOptions.getContext() != null - ? requestOptions.getContext() - : Context.NONE); - return new PagedFlux<>( - (pageSize) -> { - RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; - if (pageSize != null) { - requestOptionsLocal.addRequestCallback( - requestLocal -> { - UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); - urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); - requestLocal.setUrl(urlBuilder.toString()); - }); - } - return listTextBlocklistItemsSinglePageAsync(blocklistName, requestOptionsLocal); - }, - (nextLink, pageSize) -> { - RequestOptions requestOptionsLocal = new RequestOptions(); - requestOptionsLocal.setContext(requestOptionsForNextPage.getContext()); - if (pageSize != null) { - requestOptionsLocal.addRequestCallback( - requestLocal -> { - UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); - urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); - requestLocal.setUrl(urlBuilder.toString()); - }); - } - return listTextBlocklistItemsNextSinglePageAsync(nextLink, requestOptionsLocal); - }); - } - - /** - * Get All BlockItems By blocklistName - * - *

Get all blockItems in a text blocklist. - * - *

Query Parameters - * - * - * - * - * - * - * - *
Query Parameters
NameTypeRequiredDescription
topIntegerNoThe number of result items to return.
skipIntegerNoThe number of result items to skip.
maxpagesizeIntegerNoThe maximum number of result items per page.
- * - * You can add these to a request with {@link RequestOptions#addQueryParam} - * - *

Response Body Schema - * - *

{@code
-     * {
-     *     blockItemId: String (Required)
-     *     description: String (Optional)
-     *     text: String (Required)
-     * }
-     * }
- * - * @param blocklistName Text blocklist name. - * @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 all blockItems in a text blocklist along with {@link PagedResponse}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - private PagedResponse listTextBlocklistItemsSinglePage( - String blocklistName, RequestOptions requestOptions) { - final String accept = "application/json"; - Response res = - service.listTextBlocklistItemsSync( - this.getEndpoint(), - this.getServiceVersion().getVersion(), - blocklistName, - accept, - requestOptions, - Context.NONE); - return new PagedResponseBase<>( - res.getRequest(), - res.getStatusCode(), - res.getHeaders(), - getValues(res.getValue(), "value"), - getNextLink(res.getValue(), "nextLink"), - null); - } - - /** - * Get All BlockItems By blocklistName - * - *

Get all blockItems in a text blocklist. - * - *

Query Parameters - * - * - * - * - * - * - * - *
Query Parameters
NameTypeRequiredDescription
topIntegerNoThe number of result items to return.
skipIntegerNoThe number of result items to skip.
maxpagesizeIntegerNoThe maximum number of result items per page.
- * - * You can add these to a request with {@link RequestOptions#addQueryParam} - * - *

Response Body Schema - * - *

{@code
-     * {
-     *     blockItemId: String (Required)
-     *     description: String (Optional)
-     *     text: String (Required)
-     * }
-     * }
- * - * @param blocklistName Text blocklist name. - * @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 all blockItems in a text blocklist as paginated response with {@link PagedIterable}. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable listTextBlocklistItems(String blocklistName, RequestOptions requestOptions) { - RequestOptions requestOptionsForNextPage = new RequestOptions(); - requestOptionsForNextPage.setContext( - requestOptions != null && requestOptions.getContext() != null - ? requestOptions.getContext() - : Context.NONE); - return new PagedIterable<>( - (pageSize) -> { - RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; - if (pageSize != null) { - requestOptionsLocal.addRequestCallback( - requestLocal -> { - UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); - urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); - requestLocal.setUrl(urlBuilder.toString()); - }); - } - return listTextBlocklistItemsSinglePage(blocklistName, requestOptionsLocal); - }, - (nextLink, pageSize) -> { - RequestOptions requestOptionsLocal = new RequestOptions(); - requestOptionsLocal.setContext(requestOptionsForNextPage.getContext()); - if (pageSize != null) { - requestOptionsLocal.addRequestCallback( - requestLocal -> { - UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); - urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); - requestLocal.setUrl(urlBuilder.toString()); - }); - } - return listTextBlocklistItemsNextSinglePage(nextLink, requestOptionsLocal); - }); - } - - /** - * Get All Text Blocklists - * - *

Get the next page of items. - * - *

Response Body Schema - * - *

{@code
-     * {
-     *     blocklistName: String (Required)
-     *     description: String (Optional)
-     * }
-     * }
- * - * @param nextLink The URL to get the next list of items - *

The nextLink parameter. - * @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 paged collection of TextBlocklist items along with {@link PagedResponse} on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - private Mono> listTextBlocklistsNextSinglePageAsync( - String nextLink, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext( - context -> - service.listTextBlocklistsNext( - nextLink, this.getEndpoint(), accept, requestOptions, context)) - .map( - res -> - new PagedResponseBase<>( - res.getRequest(), - res.getStatusCode(), - res.getHeaders(), - getValues(res.getValue(), "value"), - getNextLink(res.getValue(), "nextLink"), - null)); - } - - /** - * Get All Text Blocklists - * - *

Get the next page of items. - * - *

Response Body Schema - * - *

{@code
-     * {
-     *     blocklistName: String (Required)
-     *     description: String (Optional)
-     * }
-     * }
- * - * @param nextLink The URL to get the next list of items - *

The nextLink parameter. - * @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 paged collection of TextBlocklist items along with {@link PagedResponse}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - private PagedResponse listTextBlocklistsNextSinglePage(String nextLink, RequestOptions requestOptions) { - final String accept = "application/json"; - Response res = - service.listTextBlocklistsNextSync(nextLink, this.getEndpoint(), accept, requestOptions, Context.NONE); - return new PagedResponseBase<>( - res.getRequest(), - res.getStatusCode(), - res.getHeaders(), - getValues(res.getValue(), "value"), - getNextLink(res.getValue(), "nextLink"), - null); - } - - /** - * Get All BlockItems By blocklistName - * - *

Get the next page of items. - * - *

Response Body Schema - * - *

{@code
-     * {
-     *     blockItemId: String (Required)
-     *     description: String (Optional)
-     *     text: String (Required)
-     * }
-     * }
- * - * @param nextLink The URL to get the next list of items - *

The nextLink parameter. - * @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 paged collection of TextBlockItem items along with {@link PagedResponse} on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - private Mono> listTextBlocklistItemsNextSinglePageAsync( - String nextLink, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext( - context -> - service.listTextBlocklistItemsNext( - nextLink, this.getEndpoint(), accept, requestOptions, context)) - .map( - res -> - new PagedResponseBase<>( - res.getRequest(), - res.getStatusCode(), - res.getHeaders(), - getValues(res.getValue(), "value"), - getNextLink(res.getValue(), "nextLink"), - null)); - } - - /** - * Get All BlockItems By blocklistName - * - *

Get the next page of items. - * - *

Response Body Schema - * - *

{@code
-     * {
-     *     blockItemId: String (Required)
-     *     description: String (Optional)
-     *     text: String (Required)
-     * }
-     * }
- * - * @param nextLink The URL to get the next list of items - *

The nextLink parameter. - * @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 paged collection of TextBlockItem items along with {@link PagedResponse}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - private PagedResponse listTextBlocklistItemsNextSinglePage( - String nextLink, RequestOptions requestOptions) { - final String accept = "application/json"; - Response res = - service.listTextBlocklistItemsNextSync( - nextLink, this.getEndpoint(), accept, requestOptions, Context.NONE); - return new PagedResponseBase<>( - res.getRequest(), - res.getStatusCode(), - res.getHeaders(), - getValues(res.getValue(), "value"), - getNextLink(res.getValue(), "nextLink"), - null); - } - - private List getValues(BinaryData binaryData, String path) { - try { - Map obj = binaryData.toObject(Map.class); - List values = (List) obj.get(path); - return values.stream().map(BinaryData::fromObject).collect(Collectors.toList()); - } catch (RuntimeException e) { - return null; - } - } - - private String getNextLink(BinaryData binaryData, String path) { - try { - Map obj = binaryData.toObject(Map.class); - return (String) obj.get(path); - } catch (RuntimeException e) { - return null; - } + return service.analyzeImageSync(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/implementation/package-info.java b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/implementation/package-info.java index a19f389f978a..b48e0629b95f 100644 --- a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/implementation/package-info.java +++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/implementation/package-info.java @@ -2,5 +2,8 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -/** Package containing the implementations for ContentSafety. Analyze harmful content. */ +/** + * Package containing the implementations for ContentSafety. + * Analyze harmful content. + */ package com.azure.ai.contentsafety.implementation; diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/AddOrUpdateTextBlocklistItemsOptions.java b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/AddOrUpdateTextBlocklistItemsOptions.java new file mode 100644 index 000000000000..df169b7c4f0f --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/AddOrUpdateTextBlocklistItemsOptions.java @@ -0,0 +1,46 @@ +// 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.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** + * The request to add blocklistItems to a text blocklist. + */ +@Immutable +public final class AddOrUpdateTextBlocklistItemsOptions { + /* + * Array of blocklistItems to add. + */ + @Generated + @JsonProperty(value = "blocklistItems") + private List blocklistItems; + + /** + * Creates an instance of AddOrUpdateTextBlocklistItemsOptions class. + * + * @param blocklistItems the blocklistItems value to set. + */ + @Generated + @JsonCreator + public AddOrUpdateTextBlocklistItemsOptions( + @JsonProperty(value = "blocklistItems") List blocklistItems) { + this.blocklistItems = blocklistItems; + } + + /** + * Get the blocklistItems property: Array of blocklistItems to add. + * + * @return the blocklistItems value. + */ + @Generated + public List getBlocklistItems() { + return this.blocklistItems; + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/AddOrUpdateTextBlocklistItemsResult.java b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/AddOrUpdateTextBlocklistItemsResult.java new file mode 100644 index 000000000000..ad6d4f28e2a3 --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/AddOrUpdateTextBlocklistItemsResult.java @@ -0,0 +1,46 @@ +// 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.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** + * The response of adding blocklistItems to the text blocklist. + */ +@Immutable +public final class AddOrUpdateTextBlocklistItemsResult { + /* + * Array of blocklistItems have been added. + */ + @Generated + @JsonProperty(value = "blocklistItems") + private List blocklistItems; + + /** + * Creates an instance of AddOrUpdateTextBlocklistItemsResult class. + * + * @param blocklistItems the blocklistItems value to set. + */ + @Generated + @JsonCreator + private AddOrUpdateTextBlocklistItemsResult( + @JsonProperty(value = "blocklistItems") List blocklistItems) { + this.blocklistItems = blocklistItems; + } + + /** + * Get the blocklistItems property: Array of blocklistItems have been added. + * + * @return the blocklistItems value. + */ + @Generated + public List getBlocklistItems() { + return this.blocklistItems; + } +} 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 1bae3af92367..61b1c3f8b6b9 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 @@ -10,7 +10,9 @@ import com.fasterxml.jackson.annotation.JsonProperty; import java.util.List; -/** The analysis request of the image. */ +/** + * The image analysis request. + */ @Fluent public final class AnalyzeImageOptions { /* @@ -18,41 +20,49 @@ public final class AnalyzeImageOptions { */ @Generated @JsonProperty(value = "image") - private ImageData image; + private ContentSafetyImageData image; /* - * The categories will be analyzed. If not assigned, a default set of the categories' analysis results will be - * returned. + * The categories will be analyzed. If they are not assigned, a default set of analysis results for the categories + * will be returned. */ @Generated @JsonProperty(value = "categories") private List categories; + /* + * This refers to the type of image analysis output. If no value is assigned, the default value will be + * "FourSeverityLevels". + */ + @Generated + @JsonProperty(value = "outputType") + private AnalyzeImageOutputType outputType; + /** * Creates an instance of AnalyzeImageOptions class. - * + * * @param image the image value to set. */ @Generated @JsonCreator - public AnalyzeImageOptions(@JsonProperty(value = "image") ImageData image) { + public AnalyzeImageOptions(@JsonProperty(value = "image") ContentSafetyImageData image) { this.image = image; } /** * Get the image property: The image needs to be analyzed. - * + * * @return the image value. */ @Generated - public ImageData getImage() { + public ContentSafetyImageData getImage() { return this.image; } /** - * Get the categories property: The categories will be analyzed. If not assigned, a default set of the categories' - * analysis results will be returned. - * + * Get the categories property: The categories will be analyzed. If they are not assigned, a default set of + * analysis results for the categories will be returned. + * * @return the categories value. */ @Generated @@ -61,9 +71,9 @@ public List getCategories() { } /** - * Set the categories property: The categories will be analyzed. If not assigned, a default set of the categories' - * analysis results will be returned. - * + * Set the categories property: The categories will be analyzed. If they are not assigned, a default set of + * analysis results for the categories will be returned. + * * @param categories the categories value to set. * @return the AnalyzeImageOptions object itself. */ @@ -72,4 +82,28 @@ public AnalyzeImageOptions setCategories(List categories) { this.categories = categories; return this; } + + /** + * Get the outputType property: This refers to the type of image analysis output. If no value is assigned, the + * default value will be "FourSeverityLevels". + * + * @return the outputType value. + */ + @Generated + public AnalyzeImageOutputType getOutputType() { + return this.outputType; + } + + /** + * Set the outputType property: This refers to the type of image analysis output. If no value is assigned, the + * default value will be "FourSeverityLevels". + * + * @param outputType the outputType value to set. + * @return the AnalyzeImageOptions object itself. + */ + @Generated + public AnalyzeImageOptions setOutputType(AnalyzeImageOutputType outputType) { + this.outputType = outputType; + return this; + } } diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/AnalyzeImageOutputType.java b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/AnalyzeImageOutputType.java new file mode 100644 index 000000000000..09002f6de13d --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/AnalyzeImageOutputType.java @@ -0,0 +1,53 @@ +// 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.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** + * The type of image analysis output. + */ +public final class AnalyzeImageOutputType extends ExpandableStringEnum { + /** + * Output severities in four levels, the value could be 0,2,4,6. + */ + @Generated + public static final AnalyzeImageOutputType FOUR_SEVERITY_LEVELS = fromString("FourSeverityLevels"); + + /** + * Creates a new instance of AnalyzeImageOutputType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public AnalyzeImageOutputType() { + } + + /** + * Creates or finds a AnalyzeImageOutputType from its string representation. + * + * @param name a name to look for. + * @return the corresponding AnalyzeImageOutputType. + */ + @Generated + @JsonCreator + public static AnalyzeImageOutputType fromString(String name) { + return fromString(name, AnalyzeImageOutputType.class); + } + + /** + * Gets known AnalyzeImageOutputType values. + * + * @return known AnalyzeImageOutputType values. + */ + @Generated + public static Collection values() { + return values(AnalyzeImageOutputType.class); + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/AnalyzeImageResult.java b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/AnalyzeImageResult.java index d33e2980c04d..24d94f048cbf 100644 --- a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/AnalyzeImageResult.java +++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/AnalyzeImageResult.java @@ -6,80 +6,41 @@ import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; -/** The analysis response of the image. */ +/** + * The image analysis response. + */ @Immutable public final class AnalyzeImageResult { /* - * Analysis result for Hate category. + * Analysis result for categories. */ @Generated - @JsonProperty(value = "hateResult") - private ImageAnalyzeSeverityResult hateResult; - - /* - * Analysis result for SelfHarm category. - */ - @Generated - @JsonProperty(value = "selfHarmResult") - private ImageAnalyzeSeverityResult selfHarmResult; - - /* - * Analysis result for Sexual category. - */ - @Generated - @JsonProperty(value = "sexualResult") - private ImageAnalyzeSeverityResult sexualResult; - - /* - * Analysis result for Violence category. - */ - @Generated - @JsonProperty(value = "violenceResult") - private ImageAnalyzeSeverityResult violenceResult; - - /** Creates an instance of AnalyzeImageResult class. */ - @Generated - private AnalyzeImageResult() {} - - /** - * Get the hateResult property: Analysis result for Hate category. - * - * @return the hateResult value. - */ - @Generated - public ImageAnalyzeSeverityResult getHateResult() { - return this.hateResult; - } - - /** - * Get the selfHarmResult property: Analysis result for SelfHarm category. - * - * @return the selfHarmResult value. - */ - @Generated - public ImageAnalyzeSeverityResult getSelfHarmResult() { - return this.selfHarmResult; - } + @JsonProperty(value = "categoriesAnalysis") + private List categoriesAnalysis; /** - * Get the sexualResult property: Analysis result for Sexual category. - * - * @return the sexualResult value. + * Creates an instance of AnalyzeImageResult class. + * + * @param categoriesAnalysis the categoriesAnalysis value to set. */ @Generated - public ImageAnalyzeSeverityResult getSexualResult() { - return this.sexualResult; + @JsonCreator + private AnalyzeImageResult( + @JsonProperty(value = "categoriesAnalysis") List categoriesAnalysis) { + this.categoriesAnalysis = categoriesAnalysis; } /** - * Get the violenceResult property: Analysis result for Violence category. - * - * @return the violenceResult value. + * Get the categoriesAnalysis property: Analysis result for categories. + * + * @return the categoriesAnalysis value. */ @Generated - public ImageAnalyzeSeverityResult getViolenceResult() { - return this.violenceResult; + public List getCategoriesAnalysis() { + return this.categoriesAnalysis; } } 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 a6e28b8434de..3c6c79d1d017 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 @@ -10,19 +10,22 @@ import com.fasterxml.jackson.annotation.JsonProperty; import java.util.List; -/** The analysis request of the text. */ +/** + * The text analysis request. + */ @Fluent public final class AnalyzeTextOptions { /* - * The text needs to be scanned. We support at most 1000 characters (unicode code points) in text of one request. + * The text needs to be analyzed. We support a maximum of 10k Unicode characters (Unicode code points) in the text + * of one request. */ @Generated @JsonProperty(value = "text") private String text; /* - * The categories will be analyzed. If not assigned, a default set of the categories' analysis results will be - * returned. + * The categories will be analyzed. If they are not assigned, a default set of analysis results for the categories + * will be returned. */ @Generated @JsonProperty(value = "categories") @@ -40,12 +43,20 @@ public final class AnalyzeTextOptions { * When set to false, all analyses of harmful content will be performed, whether or not blocklists are hit. */ @Generated - @JsonProperty(value = "breakByBlocklists") - private Boolean breakByBlocklists; + @JsonProperty(value = "haltOnBlocklistHit") + private Boolean haltOnBlocklistHit; + + /* + * This refers to the type of text analysis output. If no value is assigned, the default value will be + * "FourSeverityLevels". + */ + @Generated + @JsonProperty(value = "outputType") + private AnalyzeTextOutputType outputType; /** * Creates an instance of AnalyzeTextOptions class. - * + * * @param text the text value to set. */ @Generated @@ -55,9 +66,9 @@ public AnalyzeTextOptions(@JsonProperty(value = "text") String text) { } /** - * Get the text property: The text needs to be scanned. We support at most 1000 characters (unicode code points) in - * text of one request. - * + * 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. + * * @return the text value. */ @Generated @@ -66,9 +77,9 @@ public String getText() { } /** - * Get the categories property: The categories will be analyzed. If not assigned, a default set of the categories' - * analysis results will be returned. - * + * Get the categories property: The categories will be analyzed. If they are not assigned, a default set of + * analysis results for the categories will be returned. + * * @return the categories value. */ @Generated @@ -77,9 +88,9 @@ public List getCategories() { } /** - * Set the categories property: The categories will be analyzed. If not assigned, a default set of the categories' - * analysis results will be returned. - * + * Set the categories property: The categories will be analyzed. If they are not assigned, a default set of + * analysis results for the categories will be returned. + * * @param categories the categories value to set. * @return the AnalyzeTextOptions object itself. */ @@ -91,7 +102,7 @@ public AnalyzeTextOptions setCategories(List categories) { /** * Get the blocklistNames property: The names of blocklists. - * + * * @return the blocklistNames value. */ @Generated @@ -101,7 +112,7 @@ public List getBlocklistNames() { /** * Set the blocklistNames property: The names of blocklists. - * + * * @param blocklistNames the blocklistNames value to set. * @return the AnalyzeTextOptions object itself. */ @@ -112,28 +123,52 @@ public AnalyzeTextOptions setBlocklistNames(List blocklistNames) { } /** - * Get the breakByBlocklists property: When set to true, further analyses of harmful content will not be performed + * Get the haltOnBlocklistHit property: When set to true, further analyses of harmful content will not be performed * in cases where blocklists are hit. When set to false, all analyses of harmful content will be performed, whether * or not blocklists are hit. - * - * @return the breakByBlocklists value. + * + * @return the haltOnBlocklistHit value. */ @Generated - public Boolean isBreakByBlocklists() { - return this.breakByBlocklists; + public Boolean isHaltOnBlocklistHit() { + return this.haltOnBlocklistHit; } /** - * Set the breakByBlocklists property: When set to true, further analyses of harmful content will not be performed + * Set the haltOnBlocklistHit property: When set to true, further analyses of harmful content will not be performed * in cases where blocklists are hit. When set to false, all analyses of harmful content will be performed, whether * or not blocklists are hit. - * - * @param breakByBlocklists the breakByBlocklists value to set. + * + * @param haltOnBlocklistHit the haltOnBlocklistHit value to set. + * @return the AnalyzeTextOptions object itself. + */ + @Generated + public AnalyzeTextOptions setHaltOnBlocklistHit(Boolean haltOnBlocklistHit) { + this.haltOnBlocklistHit = haltOnBlocklistHit; + return this; + } + + /** + * Get the outputType property: This refers to the type of text analysis output. If no value is assigned, the + * default value will be "FourSeverityLevels". + * + * @return the outputType value. + */ + @Generated + public AnalyzeTextOutputType getOutputType() { + return this.outputType; + } + + /** + * Set the outputType property: This refers to the type of text analysis output. If no value is assigned, the + * default value will be "FourSeverityLevels". + * + * @param outputType the outputType value to set. * @return the AnalyzeTextOptions object itself. */ @Generated - public AnalyzeTextOptions setBreakByBlocklists(Boolean breakByBlocklists) { - this.breakByBlocklists = breakByBlocklists; + public AnalyzeTextOptions setOutputType(AnalyzeTextOutputType outputType) { + this.outputType = outputType; return this; } } diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/AnalyzeTextOutputType.java b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/AnalyzeTextOutputType.java new file mode 100644 index 000000000000..db52a43240db --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/AnalyzeTextOutputType.java @@ -0,0 +1,59 @@ +// 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.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** + * The type of text analysis output. + */ +public final class AnalyzeTextOutputType extends ExpandableStringEnum { + /** + * Output severities in four levels, the value could be 0,2,4,6. + */ + @Generated + public static final AnalyzeTextOutputType FOUR_SEVERITY_LEVELS = fromString("FourSeverityLevels"); + + /** + * Output severities in eight levels, the value could be 0,1,2,3,4,5,6,7. + */ + @Generated + public static final AnalyzeTextOutputType EIGHT_SEVERITY_LEVELS = fromString("EightSeverityLevels"); + + /** + * Creates a new instance of AnalyzeTextOutputType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public AnalyzeTextOutputType() { + } + + /** + * Creates or finds a AnalyzeTextOutputType from its string representation. + * + * @param name a name to look for. + * @return the corresponding AnalyzeTextOutputType. + */ + @Generated + @JsonCreator + public static AnalyzeTextOutputType fromString(String name) { + return fromString(name, AnalyzeTextOutputType.class); + } + + /** + * Gets known AnalyzeTextOutputType values. + * + * @return known AnalyzeTextOutputType values. + */ + @Generated + public static Collection values() { + return values(AnalyzeTextOutputType.class); + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/AnalyzeTextResult.java b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/AnalyzeTextResult.java index e0ae7ea8e2d2..112cf8e0df37 100644 --- a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/AnalyzeTextResult.java +++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/AnalyzeTextResult.java @@ -6,98 +6,58 @@ import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import java.util.List; -/** The analysis response of the text. */ +/** + * The text analysis response. + */ @Immutable public final class AnalyzeTextResult { /* - * The details of blocklist match. + * The blocklist match details. */ @Generated - @JsonProperty(value = "blocklistsMatchResults") - private List blocklistsMatchResults; + @JsonProperty(value = "blocklistsMatch") + private List blocklistsMatch; /* - * Analysis result for Hate category. + * Analysis result for categories. */ @Generated - @JsonProperty(value = "hateResult") - private TextAnalyzeSeverityResult hateResult; - - /* - * Analysis result for SelfHarm category. - */ - @Generated - @JsonProperty(value = "selfHarmResult") - private TextAnalyzeSeverityResult selfHarmResult; - - /* - * Analysis result for Sexual category. - */ - @Generated - @JsonProperty(value = "sexualResult") - private TextAnalyzeSeverityResult sexualResult; - - /* - * Analysis result for Violence category. - */ - @Generated - @JsonProperty(value = "violenceResult") - private TextAnalyzeSeverityResult violenceResult; - - /** Creates an instance of AnalyzeTextResult class. */ - @Generated - private AnalyzeTextResult() {} - - /** - * Get the blocklistsMatchResults property: The details of blocklist match. - * - * @return the blocklistsMatchResults value. - */ - @Generated - public List getBlocklistsMatchResults() { - return this.blocklistsMatchResults; - } - - /** - * Get the hateResult property: Analysis result for Hate category. - * - * @return the hateResult value. - */ - @Generated - public TextAnalyzeSeverityResult getHateResult() { - return this.hateResult; - } + @JsonProperty(value = "categoriesAnalysis") + private List categoriesAnalysis; /** - * Get the selfHarmResult property: Analysis result for SelfHarm category. - * - * @return the selfHarmResult value. + * Creates an instance of AnalyzeTextResult class. + * + * @param categoriesAnalysis the categoriesAnalysis value to set. */ @Generated - public TextAnalyzeSeverityResult getSelfHarmResult() { - return this.selfHarmResult; + @JsonCreator + private AnalyzeTextResult( + @JsonProperty(value = "categoriesAnalysis") List categoriesAnalysis) { + this.categoriesAnalysis = categoriesAnalysis; } /** - * Get the sexualResult property: Analysis result for Sexual category. - * - * @return the sexualResult value. + * Get the blocklistsMatch property: The blocklist match details. + * + * @return the blocklistsMatch value. */ @Generated - public TextAnalyzeSeverityResult getSexualResult() { - return this.sexualResult; + public List getBlocklistsMatch() { + return this.blocklistsMatch; } /** - * Get the violenceResult property: Analysis result for Violence category. - * - * @return the violenceResult value. + * Get the categoriesAnalysis property: Analysis result for categories. + * + * @return the categoriesAnalysis value. */ @Generated - public TextAnalyzeSeverityResult getViolenceResult() { - return this.violenceResult; + public List getCategoriesAnalysis() { + return this.categoriesAnalysis; } } diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/ContentSafetyImageData.java b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/ContentSafetyImageData.java new file mode 100644 index 000000000000..9f15173c6ec7 --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/ContentSafetyImageData.java @@ -0,0 +1,83 @@ +// 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.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.CoreUtils; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The image can be either base64 encoded bytes or a blob URL. You can choose only one of these options. If both are + * provided, the request will be refused. The maximum image size is 2048 x 2048 pixels and should not exceed 4 MB, + * while the minimum image size is 50 x 50 pixels. + */ +@Fluent +public final class ContentSafetyImageData { + /* + * The Base64 encoding of the image. + */ + @Generated + @JsonProperty(value = "content") + private byte[] content; + + /* + * The blob url of the image. + */ + @Generated + @JsonProperty(value = "blobUrl") + private String blobUrl; + + /** + * Creates an instance of ContentSafetyImageData class. + */ + @Generated + public ContentSafetyImageData() { + } + + /** + * Get the content property: The Base64 encoding of the image. + * + * @return the content value. + */ + @Generated + public byte[] getContent() { + return CoreUtils.clone(this.content); + } + + /** + * Set the content property: The Base64 encoding of the image. + * + * @param content the content value to set. + * @return the ContentSafetyImageData object itself. + */ + @Generated + public ContentSafetyImageData setContent(byte[] content) { + this.content = CoreUtils.clone(content); + return this; + } + + /** + * Get the blobUrl property: The blob url of the image. + * + * @return the blobUrl value. + */ + @Generated + public String getBlobUrl() { + return this.blobUrl; + } + + /** + * Set the blobUrl property: The blob url of the image. + * + * @param blobUrl the blobUrl value to set. + * @return the ContentSafetyImageData object itself. + */ + @Generated + public ContentSafetyImageData setBlobUrl(String blobUrl) { + this.blobUrl = blobUrl; + return this; + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/ImageCategoriesAnalysis.java b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/ImageCategoriesAnalysis.java new file mode 100644 index 000000000000..baad34ba088d --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/ImageCategoriesAnalysis.java @@ -0,0 +1,65 @@ +// 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.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Image analysis result. + */ +@Immutable +public final class ImageCategoriesAnalysis { + /* + * The image analysis category. + */ + @Generated + @JsonProperty(value = "category") + private ImageCategory category; + + /* + * The value increases with the severity of the input content. The value of this field is determined by the output + * type specified in the request. The output type could be ‘FourSeverityLevels’, and the output value can be 0, 2, + * 4, 6. + */ + @Generated + @JsonProperty(value = "severity") + private Integer severity; + + /** + * Creates an instance of ImageCategoriesAnalysis class. + * + * @param category the category value to set. + */ + @Generated + @JsonCreator + private ImageCategoriesAnalysis(@JsonProperty(value = "category") ImageCategory category) { + this.category = category; + } + + /** + * Get the category property: The image analysis category. + * + * @return the category value. + */ + @Generated + public ImageCategory getCategory() { + return this.category; + } + + /** + * Get the severity property: The value increases with the severity of the input content. The value of this field + * is determined by the output type specified in the request. The output type could be ‘FourSeverityLevels’, and + * the output value can be 0, 2, 4, 6. + * + * @return the severity value. + */ + @Generated + public Integer getSeverity() { + return this.severity; + } +} 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 792251b15473..32b86edd2256 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 @@ -9,32 +9,47 @@ import com.fasterxml.jackson.annotation.JsonCreator; import java.util.Collection; -/** Image analyze category. */ +/** + * Image analyze category. + */ public final class ImageCategory extends ExpandableStringEnum { - /** Static value Hate for ImageCategory. */ - @Generated public static final ImageCategory HATE = fromString("Hate"); + /** + * Static value Hate for ImageCategory. + */ + @Generated + public static final ImageCategory HATE = fromString("Hate"); - /** Static value SelfHarm for ImageCategory. */ - @Generated public static final ImageCategory SELF_HARM = fromString("SelfHarm"); + /** + * Static value SelfHarm for ImageCategory. + */ + @Generated + public static final ImageCategory SELF_HARM = fromString("SelfHarm"); - /** Static value Sexual for ImageCategory. */ - @Generated public static final ImageCategory SEXUAL = fromString("Sexual"); + /** + * Static value Sexual for ImageCategory. + */ + @Generated + public static final ImageCategory SEXUAL = fromString("Sexual"); - /** Static value Violence for ImageCategory. */ - @Generated public static final ImageCategory VIOLENCE = fromString("Violence"); + /** + * Static value Violence for ImageCategory. + */ + @Generated + public static final ImageCategory VIOLENCE = fromString("Violence"); /** * Creates a new instance of ImageCategory value. - * + * * @deprecated Use the {@link #fromString(String)} factory method. */ @Generated @Deprecated - public ImageCategory() {} + public ImageCategory() { + } /** * Creates or finds a ImageCategory from its string representation. - * + * * @param name a name to look for. * @return the corresponding ImageCategory. */ @@ -46,7 +61,7 @@ public static ImageCategory fromString(String name) { /** * Gets known ImageCategory values. - * + * * @return known ImageCategory values. */ @Generated diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/RemoveTextBlocklistItemsOptions.java b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/RemoveTextBlocklistItemsOptions.java new file mode 100644 index 000000000000..a21d56810db7 --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/RemoveTextBlocklistItemsOptions.java @@ -0,0 +1,45 @@ +// 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.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** + * The request to remove blocklistItems from a text blocklist. + */ +@Immutable +public final class RemoveTextBlocklistItemsOptions { + /* + * Array of blocklistItemIds to remove. + */ + @Generated + @JsonProperty(value = "blocklistItemIds") + private List blocklistItemIds; + + /** + * Creates an instance of RemoveTextBlocklistItemsOptions class. + * + * @param blocklistItemIds the blocklistItemIds value to set. + */ + @Generated + @JsonCreator + public RemoveTextBlocklistItemsOptions(@JsonProperty(value = "blocklistItemIds") List blocklistItemIds) { + this.blocklistItemIds = blocklistItemIds; + } + + /** + * Get the blocklistItemIds property: Array of blocklistItemIds to remove. + * + * @return the blocklistItemIds value. + */ + @Generated + public List getBlocklistItemIds() { + return this.blocklistItemIds; + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/TextBlocklist.java b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/TextBlocklist.java index d21e672989cb..1437e8998831 100644 --- a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/TextBlocklist.java +++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/TextBlocklist.java @@ -8,7 +8,9 @@ import com.azure.core.annotation.Generated; import com.fasterxml.jackson.annotation.JsonProperty; -/** Text Blocklist. */ +/** + * Text Blocklist. + */ @Fluent public final class TextBlocklist { /* @@ -16,7 +18,7 @@ public final class TextBlocklist { */ @Generated @JsonProperty(value = "blocklistName", access = JsonProperty.Access.WRITE_ONLY) - private String blocklistName; + private String name; /* * Text blocklist description. @@ -25,23 +27,26 @@ public final class TextBlocklist { @JsonProperty(value = "description") private String description; - /** Creates an instance of TextBlocklist class. */ + /** + * Creates an instance of TextBlocklist class. + */ @Generated - public TextBlocklist() {} + public TextBlocklist() { + } /** - * Get the blocklistName property: Text blocklist name. - * - * @return the blocklistName value. + * Get the name property: Text blocklist name. + * + * @return the name value. */ @Generated - public String getBlocklistName() { - return this.blocklistName; + public String getName() { + return this.name; } /** * Get the description property: Text blocklist description. - * + * * @return the description value. */ @Generated @@ -51,7 +56,7 @@ public String getDescription() { /** * Set the description property: Text blocklist description. - * + * * @param description the description value to set. * @return the TextBlocklist object itself. */ 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 new file mode 100644 index 000000000000..9eef5bf215a4 --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/TextBlocklistItem.java @@ -0,0 +1,90 @@ +// 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.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Item in a TextBlocklist. + */ +@Fluent +public final class TextBlocklistItem { + /* + * The service will generate a BlocklistItemId, which will be a UUID. + */ + @Generated + @JsonProperty(value = "blocklistItemId", access = JsonProperty.Access.WRITE_ONLY) + private String blocklistItemId; + + /* + * BlocklistItem description. + */ + @Generated + @JsonProperty(value = "description") + private String description; + + /* + * BlocklistItem content. + */ + @Generated + @JsonProperty(value = "text") + private String text; + + /** + * Creates an instance of TextBlocklistItem class. + * + * @param text the text value to set. + */ + @Generated + @JsonCreator + public TextBlocklistItem(@JsonProperty(value = "text") String text) { + this.text = text; + } + + /** + * Get the blocklistItemId property: The service will generate a BlocklistItemId, which will be a UUID. + * + * @return the blocklistItemId value. + */ + @Generated + public String getBlocklistItemId() { + return this.blocklistItemId; + } + + /** + * Get the description property: BlocklistItem description. + * + * @return the description value. + */ + @Generated + public String getDescription() { + return this.description; + } + + /** + * Set the description property: BlocklistItem description. + * + * @param description the description value to set. + * @return the TextBlocklistItem object itself. + */ + @Generated + public TextBlocklistItem setDescription(String description) { + this.description = description; + return this; + } + + /** + * Get the text property: BlocklistItem content. + * + * @return the text value. + */ + @Generated + public String getText() { + return this.text; + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/TextBlocklistMatch.java b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/TextBlocklistMatch.java new file mode 100644 index 000000000000..5e0ddbceea51 --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/TextBlocklistMatch.java @@ -0,0 +1,84 @@ +// 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.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The result of blocklist match. + */ +@Immutable +public final class TextBlocklistMatch { + /* + * The name of the matched blocklist. + */ + @Generated + @JsonProperty(value = "blocklistName") + private String blocklistName; + + /* + * The ID of the matched item. + */ + @Generated + @JsonProperty(value = "blocklistItemId") + private String blocklistItemId; + + /* + * The content of the matched item. + */ + @Generated + @JsonProperty(value = "blocklistItemText") + private String blocklistItemText; + + /** + * Creates an instance of TextBlocklistMatch class. + * + * @param blocklistName the blocklistName value to set. + * @param blocklistItemId the blocklistItemId value to set. + * @param blocklistItemText the blocklistItemText value to set. + */ + @Generated + @JsonCreator + private TextBlocklistMatch(@JsonProperty(value = "blocklistName") String blocklistName, + @JsonProperty(value = "blocklistItemId") String blocklistItemId, + @JsonProperty(value = "blocklistItemText") String blocklistItemText) { + this.blocklistName = blocklistName; + this.blocklistItemId = blocklistItemId; + this.blocklistItemText = blocklistItemText; + } + + /** + * Get the blocklistName property: The name of the matched blocklist. + * + * @return the blocklistName value. + */ + @Generated + public String getBlocklistName() { + return this.blocklistName; + } + + /** + * Get the blocklistItemId property: The ID of the matched item. + * + * @return the blocklistItemId value. + */ + @Generated + public String getBlocklistItemId() { + return this.blocklistItemId; + } + + /** + * Get the blocklistItemText property: The content of the matched item. + * + * @return the blocklistItemText value. + */ + @Generated + public String getBlocklistItemText() { + return this.blocklistItemText; + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/TextCategoriesAnalysis.java b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/TextCategoriesAnalysis.java new file mode 100644 index 000000000000..f8c39e09cafb --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/TextCategoriesAnalysis.java @@ -0,0 +1,65 @@ +// 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.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Text analysis result. + */ +@Immutable +public final class TextCategoriesAnalysis { + /* + * The text analysis category. + */ + @Generated + @JsonProperty(value = "category") + private TextCategory category; + + /* + * The value increases with the severity of the input content. The value of this field is determined by the output + * type specified in the request. The output type could be ‘FourSeverityLevels’ or ‘EightSeverity Levels’, and the + * output value can be 0, 2, 4, 6 or 0, 1, 2, 3, 4, 5, 6, or 7. + */ + @Generated + @JsonProperty(value = "severity") + private Integer severity; + + /** + * Creates an instance of TextCategoriesAnalysis class. + * + * @param category the category value to set. + */ + @Generated + @JsonCreator + private TextCategoriesAnalysis(@JsonProperty(value = "category") TextCategory category) { + this.category = category; + } + + /** + * Get the category property: The text analysis category. + * + * @return the category value. + */ + @Generated + public TextCategory getCategory() { + return this.category; + } + + /** + * Get the severity property: The value increases with the severity of the input content. The value of this field + * is determined by the output type specified in the request. The output type could be ‘FourSeverityLevels’ or + * ‘EightSeverity Levels’, and the output value can be 0, 2, 4, 6 or 0, 1, 2, 3, 4, 5, 6, or 7. + * + * @return the severity value. + */ + @Generated + public Integer getSeverity() { + return this.severity; + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/TextCategory.java b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/TextCategory.java index fd8ced41ef28..a606f0edec5d 100644 --- a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/TextCategory.java +++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/TextCategory.java @@ -9,32 +9,47 @@ import com.fasterxml.jackson.annotation.JsonCreator; import java.util.Collection; -/** Text analyze category. */ +/** + * Text analyze category. + */ public final class TextCategory extends ExpandableStringEnum { - /** Static value Hate for TextCategory. */ - @Generated public static final TextCategory HATE = fromString("Hate"); + /** + * Static value Hate for TextCategory. + */ + @Generated + public static final TextCategory HATE = fromString("Hate"); - /** Static value SelfHarm for TextCategory. */ - @Generated public static final TextCategory SELF_HARM = fromString("SelfHarm"); + /** + * Static value SelfHarm for TextCategory. + */ + @Generated + public static final TextCategory SELF_HARM = fromString("SelfHarm"); - /** Static value Sexual for TextCategory. */ - @Generated public static final TextCategory SEXUAL = fromString("Sexual"); + /** + * Static value Sexual for TextCategory. + */ + @Generated + public static final TextCategory SEXUAL = fromString("Sexual"); - /** Static value Violence for TextCategory. */ - @Generated public static final TextCategory VIOLENCE = fromString("Violence"); + /** + * Static value Violence for TextCategory. + */ + @Generated + public static final TextCategory VIOLENCE = fromString("Violence"); /** * Creates a new instance of TextCategory value. - * + * * @deprecated Use the {@link #fromString(String)} factory method. */ @Generated @Deprecated - public TextCategory() {} + public TextCategory() { + } /** * Creates or finds a TextCategory from its string representation. - * + * * @param name a name to look for. * @return the corresponding TextCategory. */ @@ -46,7 +61,7 @@ public static TextCategory fromString(String name) { /** * Gets known TextCategory values. - * + * * @return known TextCategory values. */ @Generated diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/package-info.java b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/package-info.java index adead5a08b8e..10331a42b4a7 100644 --- a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/package-info.java +++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/package-info.java @@ -2,5 +2,8 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -/** Package containing the data models for ContentSafety. Analyze harmful content. */ +/** + * Package containing the data models for ContentSafety. + * Analyze harmful content. + */ package com.azure.ai.contentsafety.models; diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/package-info.java b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/package-info.java index 9cdb8adab125..75196581fd89 100644 --- a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/package-info.java +++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/package-info.java @@ -2,5 +2,8 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -/** Package containing the classes for ContentSafety. Analyze harmful content. */ +/** + * Package containing the classes for ContentSafety. + * Analyze harmful content. + */ package com.azure.ai.contentsafety; diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/module-info.java b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/module-info.java index 829e3d2e2013..e93265d61ae9 100644 --- a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/module-info.java +++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/module-info.java @@ -8,7 +8,5 @@ exports com.azure.ai.contentsafety; exports com.azure.ai.contentsafety.models; - opens com.azure.ai.contentsafety.models to - com.azure.core, - com.fasterxml.jackson.databind; + opens com.azure.ai.contentsafety.models to com.azure.core, com.fasterxml.jackson.databind; } 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/tsp-location.yaml b/sdk/contentsafety/azure-ai-contentsafety/tsp-location.yaml index 36893b3adfe0..bf217408cb41 100644 --- a/sdk/contentsafety/azure-ai-contentsafety/tsp-location.yaml +++ b/sdk/contentsafety/azure-ai-contentsafety/tsp-location.yaml @@ -1,5 +1,5 @@ -directory: specification/cognitiveservices/ContentSafety repo: Azure/azure-rest-api-specs -commit: b253e331e2f0365f698e88eb3058a4f69bcc502a +commit: 4539708e7024bad1fcf4854bb1d852f856e2813a additionalDirectories: [] +directory: specification/cognitiveservices/ContentSafety