shieldPromptWithResponse(BinaryData options, RequestOptions requestOptions) {
+ final String contentType = "application/json";
+ final String accept = "application/json";
+ return service.shieldPromptSync(this.getEndpoint(), this.getServiceVersion().getVersion(), contentType, accept,
+ options, requestOptions, Context.NONE);
+ }
+
+ /**
+ * Unified Moderate
+ *
+ * A synchronous API that evaluates input, output, a proposed tool call, or a completed tool result against an
+ * applicable Agent Control Specification policy and returns the enforced content and policy verdict.
+ * Request Body Schema
+ *
+ *
+ * {@code
+ * {
+ * policyId: String (Optional)
+ * targetResourceId: String (Optional)
+ * source: String(input/output/pre_tool_call/post_tool_call) (Required)
+ * content: String (Required)
+ * toolName: String (Optional)
+ * toolCallId: String (Optional)
+ * toolArguments: String (Optional)
+ * toolResultIsError: Boolean (Optional)
+ * toolDurationMs: Double (Optional)
+ * context (Optional): {
+ * agentId: String (Optional)
+ * sessionId: String (Optional)
+ * sequence: Long (Optional)
+ * correlationId: String (Optional)
+ * userId: String (Optional)
+ * tenantId: String (Optional)
+ * extensions: String (Optional)
+ * }
+ * }
+ * }
+ *
+ *
+ * Response Body Schema
+ *
+ *
+ * {@code
+ * {
+ * verdict: String(allowed/blocked) (Required)
+ * reason: String (Optional)
+ * content: String (Optional)
+ * acsVerdict (Required): {
+ * decision: String(allow/deny/transform) (Required)
+ * reason: String (Optional)
+ * message: String (Optional)
+ * warnings (Optional): [
+ * String (Optional)
+ * ]
+ * approval (Optional): {
+ * type: String (Required)
+ * }
+ * transform (Optional): {
+ * path: String (Required)
+ * value: String (Required)
+ * }
+ * evidence (Optional): [
+ * (Optional){
+ * id: String (Optional)
+ * type: String (Optional)
+ * uri: String (Optional)
+ * description: String (Optional)
+ * }
+ * ]
+ * harmResults (Optional): {
+ * String (Required): {
+ * blocked: boolean (Required)
+ * detected: boolean (Required)
+ * severity: String (Optional)
+ * details (Optional): [
+ * (Optional){
+ * detected: boolean (Required)
+ * id: String (Required)
+ * }
+ * ]
+ * url: String (Optional)
+ * license: String (Optional)
+ * }
+ * }
+ * }
+ * }
+ * }
+ *
+ *
+ * @param options The unified moderation 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 enforced result of unified moderation along with {@link Response} on successful completion of
+ * {@link Mono}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> unifiedModerateWithResponseAsync(BinaryData options,
+ RequestOptions requestOptions) {
+ final String contentType = "application/json";
+ final String accept = "application/json";
+ return FluxUtil.withContext(context -> service.unifiedModerate(this.getEndpoint(),
+ this.getServiceVersion().getVersion(), contentType, accept, options, requestOptions, context));
+ }
+
+ /**
+ * Unified Moderate
+ *
+ * A synchronous API that evaluates input, output, a proposed tool call, or a completed tool result against an
+ * applicable Agent Control Specification policy and returns the enforced content and policy verdict.
+ * Request Body Schema
+ *
+ *
+ * {@code
+ * {
+ * policyId: String (Optional)
+ * targetResourceId: String (Optional)
+ * source: String(input/output/pre_tool_call/post_tool_call) (Required)
+ * content: String (Required)
+ * toolName: String (Optional)
+ * toolCallId: String (Optional)
+ * toolArguments: String (Optional)
+ * toolResultIsError: Boolean (Optional)
+ * toolDurationMs: Double (Optional)
+ * context (Optional): {
+ * agentId: String (Optional)
+ * sessionId: String (Optional)
+ * sequence: Long (Optional)
+ * correlationId: String (Optional)
+ * userId: String (Optional)
+ * tenantId: String (Optional)
+ * extensions: String (Optional)
+ * }
+ * }
+ * }
+ *
+ *
+ * Response Body Schema
+ *
+ *
+ * {@code
+ * {
+ * verdict: String(allowed/blocked) (Required)
+ * reason: String (Optional)
+ * content: String (Optional)
+ * acsVerdict (Required): {
+ * decision: String(allow/deny/transform) (Required)
+ * reason: String (Optional)
+ * message: String (Optional)
+ * warnings (Optional): [
+ * String (Optional)
+ * ]
+ * approval (Optional): {
+ * type: String (Required)
+ * }
+ * transform (Optional): {
+ * path: String (Required)
+ * value: String (Required)
+ * }
+ * evidence (Optional): [
+ * (Optional){
+ * id: String (Optional)
+ * type: String (Optional)
+ * uri: String (Optional)
+ * description: String (Optional)
+ * }
+ * ]
+ * harmResults (Optional): {
+ * String (Required): {
+ * blocked: boolean (Required)
+ * detected: boolean (Required)
+ * severity: String (Optional)
+ * details (Optional): [
+ * (Optional){
+ * detected: boolean (Required)
+ * id: String (Required)
+ * }
+ * ]
+ * url: String (Optional)
+ * license: String (Optional)
+ * }
+ * }
+ * }
+ * }
+ * }
+ *
+ *
+ * @param options The unified moderation 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 enforced result of unified moderation along with {@link Response}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response unifiedModerateWithResponse(BinaryData options, RequestOptions requestOptions) {
+ final String contentType = "application/json";
+ final String accept = "application/json";
+ return service.unifiedModerateSync(this.getEndpoint(), this.getServiceVersion().getVersion(), contentType,
+ accept, options, requestOptions, Context.NONE);
+ }
}
diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/implementation/OperationLocationPollingStrategy.java b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/implementation/OperationLocationPollingStrategy.java
new file mode 100644
index 0000000000000..dc39911001d9b
--- /dev/null
+++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/implementation/OperationLocationPollingStrategy.java
@@ -0,0 +1,140 @@
+// 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.core.exception.AzureException;
+import com.azure.core.http.HttpHeader;
+import com.azure.core.http.rest.Response;
+import com.azure.core.util.BinaryData;
+import com.azure.core.util.logging.ClientLogger;
+import com.azure.core.util.polling.LongRunningOperationStatus;
+import com.azure.core.util.polling.OperationResourcePollingStrategy;
+import com.azure.core.util.polling.PollResponse;
+import com.azure.core.util.polling.PollingContext;
+import com.azure.core.util.polling.PollingStrategyOptions;
+import com.azure.core.util.serializer.JsonSerializerProviders;
+import com.azure.core.util.serializer.ObjectSerializer;
+import com.azure.core.util.serializer.TypeReference;
+import java.time.Duration;
+import java.time.OffsetDateTime;
+import reactor.core.publisher.Mono;
+
+// DO NOT modify this helper class
+
+/**
+ * Implements an operation location polling strategy, from Operation-Location.
+ *
+ * @param the type of the response type from a polling call, or BinaryData if raw response body should be kept
+ * @param the type of the final result object to deserialize into, or BinaryData if raw response body should be
+ * kept
+ */
+public final class OperationLocationPollingStrategy extends OperationResourcePollingStrategy {
+
+ private static final ClientLogger LOGGER = new ClientLogger(OperationLocationPollingStrategy.class);
+
+ private final ObjectSerializer serializer;
+ private final String endpoint;
+ private final String propertyName;
+
+ /**
+ * Creates an instance of the operation resource polling strategy.
+ *
+ * @param pollingStrategyOptions options to configure this polling strategy.
+ * @throws NullPointerException if {@code pollingStrategyOptions} is null.
+ */
+ public OperationLocationPollingStrategy(PollingStrategyOptions pollingStrategyOptions) {
+ this(pollingStrategyOptions, null);
+ }
+
+ /**
+ * Creates an instance of the operation resource polling strategy.
+ *
+ * @param pollingStrategyOptions options to configure this polling strategy.
+ * @param propertyName the name of the property to extract final result.
+ * @throws NullPointerException if {@code pollingStrategyOptions} is null.
+ */
+ public OperationLocationPollingStrategy(PollingStrategyOptions pollingStrategyOptions, String propertyName) {
+ super(PollingUtils.OPERATION_LOCATION_HEADER, pollingStrategyOptions);
+ this.propertyName = propertyName;
+ this.endpoint = pollingStrategyOptions.getEndpoint();
+ this.serializer = pollingStrategyOptions.getSerializer() != null
+ ? pollingStrategyOptions.getSerializer()
+ : JsonSerializerProviders.createInstance(true);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Mono> onInitialResponse(Response> response, PollingContext pollingContext,
+ TypeReference pollResponseType) {
+ // Response> is Response
+
+ HttpHeader operationLocationHeader = response.getHeaders().get(PollingUtils.OPERATION_LOCATION_HEADER);
+ if (operationLocationHeader != null) {
+ pollingContext.setData(PollingUtils.OPERATION_LOCATION_HEADER.getCaseSensitiveName(),
+ PollingUtils.getAbsolutePath(operationLocationHeader.getValue(), endpoint, LOGGER));
+ }
+ final String httpMethod = response.getRequest().getHttpMethod().name();
+ pollingContext.setData(PollingUtils.HTTP_METHOD, httpMethod);
+ pollingContext.setData(PollingUtils.REQUEST_URL, response.getRequest().getUrl().toString());
+
+ if (response.getStatusCode() == 200
+ || response.getStatusCode() == 201
+ || response.getStatusCode() == 202
+ || response.getStatusCode() == 204) {
+ final Duration retryAfter
+ = PollingUtils.getRetryAfterFromHeaders(response.getHeaders(), OffsetDateTime::now);
+ final Mono> pollResponseMono
+ = PollingUtils.deserializeResponse((BinaryData) response.getValue(), serializer, pollResponseType)
+ .onErrorResume(exception -> {
+ LOGGER.info("Failed to parse initial response.");
+ return Mono.empty();
+ })
+ .map(value -> new PollResponse<>(LongRunningOperationStatus.IN_PROGRESS, value, retryAfter));
+ return pollResponseMono.switchIfEmpty(
+ Mono.fromSupplier(() -> new PollResponse<>(LongRunningOperationStatus.IN_PROGRESS, null, retryAfter)));
+ } else {
+ return Mono
+ .error(
+ new AzureException(String.format(
+ "Operation failed or cancelled with status code %d,"
+ + ", '%s' header: %s, and response body: %s",
+ response.getStatusCode(), PollingUtils.OPERATION_LOCATION_HEADER, operationLocationHeader,
+ response.getValue())));
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Mono getResult(PollingContext pollingContext, TypeReference resultType) {
+ if (pollingContext.getLatestResponse().getStatus() == LongRunningOperationStatus.FAILED) {
+ return Mono.error(new AzureException("Long running operation failed."));
+ } else if (pollingContext.getLatestResponse().getStatus() == LongRunningOperationStatus.USER_CANCELLED) {
+ return Mono.error(new AzureException("Long running operation cancelled."));
+ }
+ if (propertyName != null) {
+ // take the last poll response body from PollingContext,
+ // and de-serialize the property as final result
+ BinaryData latestResponseBody
+ = BinaryData.fromString(pollingContext.getData(PollingUtils.POLL_RESPONSE_BODY));
+ return PollingUtils
+ .deserializeResponse(latestResponseBody, serializer, PollingUtils.POST_POLL_RESULT_TYPE_REFERENCE)
+ .flatMap(value -> {
+ if (value.get(propertyName) != null) {
+ return BinaryData.fromObjectAsync(value.get(propertyName))
+ .flatMap(result -> PollingUtils.deserializeResponse(result, serializer, resultType));
+ } else {
+ return Mono.error(new AzureException("Cannot get final result"));
+ }
+ })
+ .switchIfEmpty(Mono.error(new AzureException("Cannot get final result")));
+ } else {
+ return super.getResult(pollingContext, resultType);
+ }
+ }
+}
diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/implementation/PollingUtils.java b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/implementation/PollingUtils.java
new file mode 100644
index 0000000000000..411edca19e7b5
--- /dev/null
+++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/implementation/PollingUtils.java
@@ -0,0 +1,151 @@
+// 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.core.http.HttpHeaderName;
+import com.azure.core.http.HttpHeaders;
+import com.azure.core.util.BinaryData;
+import com.azure.core.util.CoreUtils;
+import com.azure.core.util.DateTimeRfc1123;
+import com.azure.core.util.logging.ClientLogger;
+import com.azure.core.util.serializer.ObjectSerializer;
+import com.azure.core.util.serializer.TypeReference;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.time.DateTimeException;
+import java.time.Duration;
+import java.time.OffsetDateTime;
+import java.time.temporal.ChronoUnit;
+import java.util.Map;
+import java.util.function.Function;
+import java.util.function.Supplier;
+import reactor.core.publisher.Mono;
+
+// DO NOT modify this helper class
+
+final class PollingUtils {
+
+ public static final TypeReference