diff --git a/sdk/contentsafety/azure-ai-contentsafety/CHANGELOG.md b/sdk/contentsafety/azure-ai-contentsafety/CHANGELOG.md index 4062df6618c2..c7739dd5c91d 100644 --- a/sdk/contentsafety/azure-ai-contentsafety/CHANGELOG.md +++ b/sdk/contentsafety/azure-ai-contentsafety/CHANGELOG.md @@ -1,14 +1,105 @@ # Release History -## 1.1.0-beta.1 (Unreleased) +## 1.1.0-beta.1 (2026-07-30) ### Features Added -### Breaking Changes +* `models.ProvenanceDetectOperation` was added -### Bugs Fixed +* `ContentProvenanceClientBuilder` was added -### Other Changes +* `models.DetectOutcome` was added + +* `models.ProvenanceOperationKind` was added + +* `models.OperationState` was added + +* `models.DetectProvenanceResult` was added + +* `ContentProvenanceAsyncClient` was added + +* `models.DetectedProvenance` was added + +* `ContentProvenanceClient` was added + +* `models.DetectedProvenanceType` was added + +* `models.DetectProvenanceOptions` was added + +* `models.ProvenanceContent` was added + +#### `models.AddOrUpdateTextBlocklistItemsResult` was modified + +* `toJson(com.azure.json.JsonWriter)` was added +* `fromJson(com.azure.json.JsonReader)` was added + +#### `BlocklistAsyncClient` was modified + +* `createOrUpdateTextBlocklist(java.lang.String,models.TextBlocklist)` was added + +#### `models.AnalyzeTextResult` was modified + +* `fromJson(com.azure.json.JsonReader)` was added +* `toJson(com.azure.json.JsonWriter)` was added + +#### `models.TextBlocklistMatch` was modified + +* `fromJson(com.azure.json.JsonReader)` was added +* `toJson(com.azure.json.JsonWriter)` was added + +#### `models.AnalyzeImageOptions` was modified + +* `fromJson(com.azure.json.JsonReader)` was added +* `toJson(com.azure.json.JsonWriter)` was added + +#### `models.TextBlocklistItem` was modified + +* `toJson(com.azure.json.JsonWriter)` was added +* `fromJson(com.azure.json.JsonReader)` was added + +#### `models.RemoveTextBlocklistItemsOptions` was modified + +* `fromJson(com.azure.json.JsonReader)` was added +* `toJson(com.azure.json.JsonWriter)` was added + +#### `models.TextBlocklist` was modified + +* `fromJson(com.azure.json.JsonReader)` was added +* `toJson(com.azure.json.JsonWriter)` was added + +#### `models.AnalyzeTextOptions` was modified + +* `toJson(com.azure.json.JsonWriter)` was added +* `fromJson(com.azure.json.JsonReader)` was added + +#### `models.ImageCategoriesAnalysis` was modified + +* `toJson(com.azure.json.JsonWriter)` was added +* `fromJson(com.azure.json.JsonReader)` was added + +#### `models.AnalyzeImageResult` was modified + +* `fromJson(com.azure.json.JsonReader)` was added +* `toJson(com.azure.json.JsonWriter)` was added + +#### `models.AddOrUpdateTextBlocklistItemsOptions` was modified + +* `toJson(com.azure.json.JsonWriter)` was added +* `fromJson(com.azure.json.JsonReader)` was added + +#### `models.ContentSafetyImageData` was modified + +* `toJson(com.azure.json.JsonWriter)` was added +* `fromJson(com.azure.json.JsonReader)` was added + +#### `models.TextCategoriesAnalysis` was modified + +* `fromJson(com.azure.json.JsonReader)` was added +* `toJson(com.azure.json.JsonWriter)` was added + +#### `BlocklistClient` was modified + +* `createOrUpdateTextBlocklist(java.lang.String,models.TextBlocklist)` was added ## 1.0.19 (2026-07-01) diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/ContentProvenanceAsyncClient.java b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/ContentProvenanceAsyncClient.java new file mode 100644 index 000000000000..6c26ce57c1ce --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/ContentProvenanceAsyncClient.java @@ -0,0 +1,201 @@ +// 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.ContentProvenanceClientImpl; +import com.azure.ai.contentsafety.models.DetectProvenanceOptions; +import com.azure.ai.contentsafety.models.DetectProvenanceResult; +import com.azure.ai.contentsafety.models.ProvenanceDetectOperation; +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.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.polling.PollOperationDetails; +import com.azure.core.util.polling.PollerFlux; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ContentProvenanceClient type. + */ +@ServiceClient(builder = ContentProvenanceClientBuilder.class, isAsync = true) +public final class ContentProvenanceAsyncClient { + + @Generated + private final ContentProvenanceClientImpl serviceClient; + + /** + * Initializes an instance of ContentProvenanceAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ContentProvenanceAsyncClient(ContentProvenanceClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Start Content Provenance Detection + * + * Starts an asynchronous Content Provenance Detection operation that inspects the supplied media for + * Microsoft-issued C2PA and imperceptible watermark signals indicating the content was created or modified using + * AI. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     content (Required): {
+     *         uri: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         error (Required): (recursive schema, see error above)
+     *     }
+     *     result (Optional): {
+     *         outcome: String(NoProvenanceDetected/ProvenanceDetected) (Required)
+     *         results (Optional): [
+     *              (Optional){
+     *                 type: String(C2PA/Watermark) (Optional)
+     *                 provider: String (Optional)
+     *                 modelName: String (Optional)
+     *                 timestamp: OffsetDateTime (Optional)
+     *             }
+     *         ]
+     *     }
+     * }
+     * }
+     * 
+ * + * @param options Options describing the media to inspect using Content Provenance Detection. + * @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 PollerFlux} for polling of provides status details for long running operations. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginDetect(BinaryData options, RequestOptions requestOptions) { + return this.serviceClient.beginDetectAsync(options, requestOptions); + } + + /** + * Get Content Provenance Detection Status + * + * Gets the status, result, or error of an asynchronous Content Provenance Detection operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         error (Required): (recursive schema, see error above)
+     *     }
+     *     result (Optional): {
+     *         outcome: String(NoProvenanceDetected/ProvenanceDetected) (Required)
+     *         results (Optional): [
+     *              (Optional){
+     *                 type: String(C2PA/Watermark) (Optional)
+     *                 provider: String (Optional)
+     *                 modelName: String (Optional)
+     *                 timestamp: OffsetDateTime (Optional)
+     *             }
+     *         ]
+     *     }
+     *     kind: String(Detect) (Required)
+     *     createdAt: OffsetDateTime (Optional)
+     *     lastUpdatedAt: OffsetDateTime (Optional)
+     * }
+     * }
+     * 
+ * + * @param operationId The unique ID of the operation. + * @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 content Provenance Detection Status + * + * Gets the status, result, or error of an asynchronous Content Provenance Detection operation along with + * {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getOperationStatusWithResponse(String operationId, + RequestOptions requestOptions) { + return this.serviceClient.getOperationStatusWithResponseAsync(operationId, requestOptions); + } + + /** + * Start Content Provenance Detection + * + * Starts an asynchronous Content Provenance Detection operation that inspects the supplied media for + * Microsoft-issued C2PA and imperceptible watermark signals indicating the content was created or modified using + * AI. + * + * @param options Options describing the media to inspect using Content Provenance Detection. + * @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 {@link PollerFlux} for polling of provides status details for long running operations. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginDetect(DetectProvenanceOptions options) { + // Generated convenience method for beginDetectWithModel + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.beginDetectWithModelAsync(BinaryData.fromObject(options), requestOptions); + } + + /** + * Get Content Provenance Detection Status + * + * Gets the status, result, or error of an asynchronous Content Provenance Detection operation. + * + * @param operationId The unique ID of the operation. + * @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 content Provenance Detection Status + * + * Gets the status, result, or error of an asynchronous Content Provenance Detection operation on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getOperationStatus(String operationId) { + // Generated convenience method for getOperationStatusWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getOperationStatusWithResponse(operationId, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ProvenanceDetectOperation.class)); + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/ContentProvenanceClient.java b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/ContentProvenanceClient.java new file mode 100644 index 000000000000..6aa33377ab64 --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/ContentProvenanceClient.java @@ -0,0 +1,197 @@ +// 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.ContentProvenanceClientImpl; +import com.azure.ai.contentsafety.models.DetectProvenanceOptions; +import com.azure.ai.contentsafety.models.DetectProvenanceResult; +import com.azure.ai.contentsafety.models.ProvenanceDetectOperation; +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.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.polling.PollOperationDetails; +import com.azure.core.util.polling.SyncPoller; + +/** + * Initializes a new instance of the synchronous ContentProvenanceClient type. + */ +@ServiceClient(builder = ContentProvenanceClientBuilder.class) +public final class ContentProvenanceClient { + + @Generated + private final ContentProvenanceClientImpl serviceClient; + + /** + * Initializes an instance of ContentProvenanceClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ContentProvenanceClient(ContentProvenanceClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Start Content Provenance Detection + * + * Starts an asynchronous Content Provenance Detection operation that inspects the supplied media for + * Microsoft-issued C2PA and imperceptible watermark signals indicating the content was created or modified using + * AI. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     content (Required): {
+     *         uri: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         error (Required): (recursive schema, see error above)
+     *     }
+     *     result (Optional): {
+     *         outcome: String(NoProvenanceDetected/ProvenanceDetected) (Required)
+     *         results (Optional): [
+     *              (Optional){
+     *                 type: String(C2PA/Watermark) (Optional)
+     *                 provider: String (Optional)
+     *                 modelName: String (Optional)
+     *                 timestamp: OffsetDateTime (Optional)
+     *             }
+     *         ]
+     *     }
+     * }
+     * }
+     * 
+ * + * @param options Options describing the media to inspect using Content Provenance Detection. + * @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 SyncPoller} for polling of provides status details for long running operations. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginDetect(BinaryData options, RequestOptions requestOptions) { + return this.serviceClient.beginDetect(options, requestOptions); + } + + /** + * Get Content Provenance Detection Status + * + * Gets the status, result, or error of an asynchronous Content Provenance Detection operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         error (Required): (recursive schema, see error above)
+     *     }
+     *     result (Optional): {
+     *         outcome: String(NoProvenanceDetected/ProvenanceDetected) (Required)
+     *         results (Optional): [
+     *              (Optional){
+     *                 type: String(C2PA/Watermark) (Optional)
+     *                 provider: String (Optional)
+     *                 modelName: String (Optional)
+     *                 timestamp: OffsetDateTime (Optional)
+     *             }
+     *         ]
+     *     }
+     *     kind: String(Detect) (Required)
+     *     createdAt: OffsetDateTime (Optional)
+     *     lastUpdatedAt: OffsetDateTime (Optional)
+     * }
+     * }
+     * 
+ * + * @param operationId The unique ID of the operation. + * @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 content Provenance Detection Status + * + * Gets the status, result, or error of an asynchronous Content Provenance Detection operation along with + * {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getOperationStatusWithResponse(String operationId, RequestOptions requestOptions) { + return this.serviceClient.getOperationStatusWithResponse(operationId, requestOptions); + } + + /** + * Start Content Provenance Detection + * + * Starts an asynchronous Content Provenance Detection operation that inspects the supplied media for + * Microsoft-issued C2PA and imperceptible watermark signals indicating the content was created or modified using + * AI. + * + * @param options Options describing the media to inspect using Content Provenance Detection. + * @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 {@link SyncPoller} for polling of provides status details for long running operations. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginDetect(DetectProvenanceOptions options) { + // Generated convenience method for beginDetectWithModel + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.beginDetectWithModel(BinaryData.fromObject(options), requestOptions); + } + + /** + * Get Content Provenance Detection Status + * + * Gets the status, result, or error of an asynchronous Content Provenance Detection operation. + * + * @param operationId The unique ID of the operation. + * @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 content Provenance Detection Status + * + * Gets the status, result, or error of an asynchronous Content Provenance Detection operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ProvenanceDetectOperation getOperationStatus(String operationId) { + // Generated convenience method for getOperationStatusWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getOperationStatusWithResponse(operationId, requestOptions).getValue() + .toObject(ProvenanceDetectOperation.class); + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/ContentProvenanceClientBuilder.java b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/ContentProvenanceClientBuilder.java new file mode 100644 index 000000000000..d9a71105ed30 --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/ContentProvenanceClientBuilder.java @@ -0,0 +1,355 @@ +// 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.ContentProvenanceClientImpl; +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.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 ContentProvenanceClient type. + */ +@ServiceClientBuilder(serviceClients = { ContentProvenanceClient.class, ContentProvenanceAsyncClient.class }) +public final class ContentProvenanceClientBuilder 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 ContentProvenanceClientBuilder. + */ + @Generated + public ContentProvenanceClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ContentProvenanceClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ContentProvenanceClientBuilder pipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ContentProvenanceClientBuilder 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 ContentProvenanceClientBuilder 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 ContentProvenanceClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ContentProvenanceClientBuilder 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 ContentProvenanceClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The TokenCredential used for authentication. + */ + @Generated + private TokenCredential tokenCredential; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ContentProvenanceClientBuilder credential(TokenCredential tokenCredential) { + this.tokenCredential = tokenCredential; + return this; + } + + /* + * The KeyCredential used for authentication. + */ + @Generated + private KeyCredential keyCredential; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ContentProvenanceClientBuilder credential(KeyCredential keyCredential) { + this.keyCredential = keyCredential; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ContentProvenanceClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Service version + */ + @Generated + private ContentSafetyServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the ContentProvenanceClientBuilder. + */ + @Generated + public ContentProvenanceClientBuilder 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 ContentProvenanceClientBuilder. + */ + @Generated + public ContentProvenanceClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of ContentProvenanceClientImpl with the provided parameters. + * + * @return an instance of ContentProvenanceClientImpl. + */ + @Generated + private ContentProvenanceClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + ContentSafetyServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : ContentSafetyServiceVersion.getLatest(); + ContentProvenanceClientImpl client = new ContentProvenanceClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint, localServiceVersion); + return client; + } + + @Generated + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + } + + @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 = CoreUtils.createHttpHeadersFromClientOptions(localClientOptions); + if (headers != null) { + 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(localHttpLogOptions)); + HttpPipeline httpPipeline = new HttpPipelineBuilder().policies(policies.toArray(new HttpPipelinePolicy[0])) + .httpClient(httpClient) + .clientOptions(localClientOptions) + .build(); + return httpPipeline; + } + + /** + * Builds an instance of ContentProvenanceAsyncClient class. + * + * @return an instance of ContentProvenanceAsyncClient. + */ + @Generated + public ContentProvenanceAsyncClient buildAsyncClient() { + return new ContentProvenanceAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of ContentProvenanceClient class. + * + * @return an instance of ContentProvenanceClient. + */ + @Generated + public ContentProvenanceClient buildClient() { + return new ContentProvenanceClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(ContentProvenanceClientBuilder.class); +} 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 index 727d27c55475..e7e96b52ccfc 100644 --- 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 @@ -216,7 +216,7 @@ Response createOrUpdateTextBlocklistSync(@HostParam("endpoint") Stri @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); + RequestOptions requestOptions, Context context); @Delete("/text/blocklists/{blocklistName}") @ExpectedResponses({ 204 }) @@ -226,7 +226,7 @@ Mono> deleteTextBlocklist(@HostParam("endpoint") String endpoint, @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); + RequestOptions requestOptions, Context context); @Get("/text/blocklists/{blocklistName}") @ExpectedResponses({ 200 }) @@ -318,8 +318,8 @@ Response listTextBlocklistsSync(@HostParam("endpoint") String endpoi @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> removeBlocklistItems(@HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, @PathParam("blocklistName") String name, - @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, - @BodyParam("application/json") BinaryData options, RequestOptions requestOptions, Context context); + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData options, + RequestOptions requestOptions, Context context); @Post("/text/blocklists/{blocklistName}:removeBlocklistItems") @ExpectedResponses({ 204 }) @@ -329,8 +329,8 @@ Mono> removeBlocklistItems(@HostParam("endpoint") String endpoint @UnexpectedResponseExceptionType(HttpResponseException.class) Response removeBlocklistItemsSync(@HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, @PathParam("blocklistName") String name, - @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, - @BodyParam("application/json") BinaryData options, RequestOptions requestOptions, Context context); + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData options, + RequestOptions requestOptions, Context context); @Get("{nextLink}") @ExpectedResponses({ 200 }) @@ -587,9 +587,8 @@ public Response createOrUpdateTextBlocklistWithResponse(String name, */ @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)); + this.getServiceVersion().getVersion(), name, requestOptions, context)); } /** @@ -607,8 +606,7 @@ public Mono> deleteTextBlocklistWithResponseAsync(String name, Re */ @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, + return service.deleteTextBlocklistSync(this.getEndpoint(), this.getServiceVersion().getVersion(), name, requestOptions, Context.NONE); } @@ -1128,9 +1126,8 @@ public PagedIterable listTextBlocklists(RequestOptions requestOption public Mono> removeBlocklistItemsWithResponseAsync(String name, BinaryData options, RequestOptions requestOptions) { final String contentType = "application/json"; - final String accept = "application/json"; return FluxUtil.withContext(context -> service.removeBlocklistItems(this.getEndpoint(), - this.getServiceVersion().getVersion(), name, contentType, accept, options, requestOptions, context)); + this.getServiceVersion().getVersion(), name, contentType, options, requestOptions, context)); } /** @@ -1162,9 +1159,8 @@ public Mono> removeBlocklistItemsWithResponseAsync(String name, B public Response removeBlocklistItemsWithResponse(String name, BinaryData options, RequestOptions requestOptions) { final String contentType = "application/json"; - final String accept = "application/json"; return service.removeBlocklistItemsSync(this.getEndpoint(), this.getServiceVersion().getVersion(), name, - contentType, accept, options, requestOptions, Context.NONE); + contentType, options, requestOptions, Context.NONE); } /** diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/implementation/ContentProvenanceClientImpl.java b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/implementation/ContentProvenanceClientImpl.java new file mode 100644 index 000000000000..bed42230f81d --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/implementation/ContentProvenanceClientImpl.java @@ -0,0 +1,690 @@ +// 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.ai.contentsafety.models.DetectProvenanceResult; +import com.azure.core.annotation.BodyParam; +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.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.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.polling.PollOperationDetails; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.PollingStrategyOptions; +import com.azure.core.util.polling.SyncPoller; +import com.azure.core.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; +import com.azure.core.util.serializer.TypeReference; +import java.time.Duration; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the ContentProvenanceClient type. + */ +public final class ContentProvenanceClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ContentProvenanceClientService 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 ContentProvenanceClient client. + * + * @param endpoint Supported Cognitive Services endpoints (protocol and hostname, for example: + * https://<resource-name>.cognitiveservices.azure.com). + * @param serviceVersion Service version. + */ + public ContentProvenanceClientImpl(String endpoint, ContentSafetyServiceVersion serviceVersion) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of ContentProvenanceClient 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 ContentProvenanceClientImpl(HttpPipeline httpPipeline, String endpoint, + ContentSafetyServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of ContentProvenanceClient 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 ContentProvenanceClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, + ContentSafetyServiceVersion serviceVersion) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.serviceVersion = serviceVersion; + this.service + = RestProxy.create(ContentProvenanceClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for ContentProvenanceClient to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}/contentsafety") + @ServiceInterface(name = "ContentProvenanceClient") + public interface ContentProvenanceClientService { + @Post("/provenance:detect") + @ExpectedResponses({ 202 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> detect(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData options, + RequestOptions requestOptions, Context context); + + @Post("/provenance:detect") + @ExpectedResponses({ 202 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response detectSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData options, + RequestOptions requestOptions, Context context); + + @Get("/provenance/operations/{operationId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getOperationStatus(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("operationId") String operationId, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/provenance/operations/{operationId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getOperationStatusSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("operationId") String operationId, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + } + + /** + * Start Content Provenance Detection + * + * Starts an asynchronous Content Provenance Detection operation that inspects the supplied media for + * Microsoft-issued C2PA and imperceptible watermark signals indicating the content was created or modified using + * AI. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     content (Required): {
+     *         uri: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         error (Required): (recursive schema, see error above)
+     *     }
+     *     result (Optional): {
+     *         outcome: String(NoProvenanceDetected/ProvenanceDetected) (Required)
+     *         results (Optional): [
+     *              (Optional){
+     *                 type: String(C2PA/Watermark) (Optional)
+     *                 provider: String (Optional)
+     *                 modelName: String (Optional)
+     *                 timestamp: OffsetDateTime (Optional)
+     *             }
+     *         ]
+     *     }
+     * }
+     * }
+     * 
+ * + * @param options Options describing the media to inspect using Content Provenance Detection. + * @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 provides status details for long running operations along with {@link Response} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> detectWithResponseAsync(BinaryData options, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.detect(this.getEndpoint(), this.getServiceVersion().getVersion(), + contentType, accept, options, requestOptions, context)); + } + + /** + * Start Content Provenance Detection + * + * Starts an asynchronous Content Provenance Detection operation that inspects the supplied media for + * Microsoft-issued C2PA and imperceptible watermark signals indicating the content was created or modified using + * AI. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     content (Required): {
+     *         uri: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         error (Required): (recursive schema, see error above)
+     *     }
+     *     result (Optional): {
+     *         outcome: String(NoProvenanceDetected/ProvenanceDetected) (Required)
+     *         results (Optional): [
+     *              (Optional){
+     *                 type: String(C2PA/Watermark) (Optional)
+     *                 provider: String (Optional)
+     *                 modelName: String (Optional)
+     *                 timestamp: OffsetDateTime (Optional)
+     *             }
+     *         ]
+     *     }
+     * }
+     * }
+     * 
+ * + * @param options Options describing the media to inspect using Content Provenance Detection. + * @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 provides status details for long running operations along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Response detectWithResponse(BinaryData options, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.detectSync(this.getEndpoint(), this.getServiceVersion().getVersion(), contentType, accept, + options, requestOptions, Context.NONE); + } + + /** + * Start Content Provenance Detection + * + * Starts an asynchronous Content Provenance Detection operation that inspects the supplied media for + * Microsoft-issued C2PA and imperceptible watermark signals indicating the content was created or modified using + * AI. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     content (Required): {
+     *         uri: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         error (Required): (recursive schema, see error above)
+     *     }
+     *     result (Optional): {
+     *         outcome: String(NoProvenanceDetected/ProvenanceDetected) (Required)
+     *         results (Optional): [
+     *              (Optional){
+     *                 type: String(C2PA/Watermark) (Optional)
+     *                 provider: String (Optional)
+     *                 modelName: String (Optional)
+     *                 timestamp: OffsetDateTime (Optional)
+     *             }
+     *         ]
+     *     }
+     * }
+     * }
+     * 
+ * + * @param options Options describing the media to inspect using Content Provenance Detection. + * @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 PollerFlux} for polling of provides status details for long running operations. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginDetectWithModelAsync(BinaryData options, + RequestOptions requestOptions) { + return PollerFlux.create(Duration.ofSeconds(1), () -> this.detectWithResponseAsync(options, requestOptions), + new com.azure.ai.contentsafety.implementation.OperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint("{endpoint}/contentsafety".replace("{endpoint}", this.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion()), + "result"), + TypeReference.createInstance(PollOperationDetails.class), + TypeReference.createInstance(DetectProvenanceResult.class)); + } + + /** + * Start Content Provenance Detection + * + * Starts an asynchronous Content Provenance Detection operation that inspects the supplied media for + * Microsoft-issued C2PA and imperceptible watermark signals indicating the content was created or modified using + * AI. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     content (Required): {
+     *         uri: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         error (Required): (recursive schema, see error above)
+     *     }
+     *     result (Optional): {
+     *         outcome: String(NoProvenanceDetected/ProvenanceDetected) (Required)
+     *         results (Optional): [
+     *              (Optional){
+     *                 type: String(C2PA/Watermark) (Optional)
+     *                 provider: String (Optional)
+     *                 modelName: String (Optional)
+     *                 timestamp: OffsetDateTime (Optional)
+     *             }
+     *         ]
+     *     }
+     * }
+     * }
+     * 
+ * + * @param options Options describing the media to inspect using Content Provenance Detection. + * @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 SyncPoller} for polling of provides status details for long running operations. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginDetectWithModel(BinaryData options, + RequestOptions requestOptions) { + return SyncPoller.createPoller(Duration.ofSeconds(1), () -> this.detectWithResponse(options, requestOptions), + new com.azure.ai.contentsafety.implementation.SyncOperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint("{endpoint}/contentsafety".replace("{endpoint}", this.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion()), + "result"), + TypeReference.createInstance(PollOperationDetails.class), + TypeReference.createInstance(DetectProvenanceResult.class)); + } + + /** + * Start Content Provenance Detection + * + * Starts an asynchronous Content Provenance Detection operation that inspects the supplied media for + * Microsoft-issued C2PA and imperceptible watermark signals indicating the content was created or modified using + * AI. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     content (Required): {
+     *         uri: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         error (Required): (recursive schema, see error above)
+     *     }
+     *     result (Optional): {
+     *         outcome: String(NoProvenanceDetected/ProvenanceDetected) (Required)
+     *         results (Optional): [
+     *              (Optional){
+     *                 type: String(C2PA/Watermark) (Optional)
+     *                 provider: String (Optional)
+     *                 modelName: String (Optional)
+     *                 timestamp: OffsetDateTime (Optional)
+     *             }
+     *         ]
+     *     }
+     * }
+     * }
+     * 
+ * + * @param options Options describing the media to inspect using Content Provenance Detection. + * @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 PollerFlux} for polling of provides status details for long running operations. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginDetectAsync(BinaryData options, RequestOptions requestOptions) { + return PollerFlux.create(Duration.ofSeconds(1), () -> this.detectWithResponseAsync(options, requestOptions), + new com.azure.ai.contentsafety.implementation.OperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint("{endpoint}/contentsafety".replace("{endpoint}", this.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion()), + "result"), + TypeReference.createInstance(BinaryData.class), TypeReference.createInstance(BinaryData.class)); + } + + /** + * Start Content Provenance Detection + * + * Starts an asynchronous Content Provenance Detection operation that inspects the supplied media for + * Microsoft-issued C2PA and imperceptible watermark signals indicating the content was created or modified using + * AI. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     content (Required): {
+     *         uri: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         error (Required): (recursive schema, see error above)
+     *     }
+     *     result (Optional): {
+     *         outcome: String(NoProvenanceDetected/ProvenanceDetected) (Required)
+     *         results (Optional): [
+     *              (Optional){
+     *                 type: String(C2PA/Watermark) (Optional)
+     *                 provider: String (Optional)
+     *                 modelName: String (Optional)
+     *                 timestamp: OffsetDateTime (Optional)
+     *             }
+     *         ]
+     *     }
+     * }
+     * }
+     * 
+ * + * @param options Options describing the media to inspect using Content Provenance Detection. + * @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 SyncPoller} for polling of provides status details for long running operations. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginDetect(BinaryData options, RequestOptions requestOptions) { + return SyncPoller.createPoller(Duration.ofSeconds(1), () -> this.detectWithResponse(options, requestOptions), + new com.azure.ai.contentsafety.implementation.SyncOperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint("{endpoint}/contentsafety".replace("{endpoint}", this.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion()), + "result"), + TypeReference.createInstance(BinaryData.class), TypeReference.createInstance(BinaryData.class)); + } + + /** + * Get Content Provenance Detection Status + * + * Gets the status, result, or error of an asynchronous Content Provenance Detection operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         error (Required): (recursive schema, see error above)
+     *     }
+     *     result (Optional): {
+     *         outcome: String(NoProvenanceDetected/ProvenanceDetected) (Required)
+     *         results (Optional): [
+     *              (Optional){
+     *                 type: String(C2PA/Watermark) (Optional)
+     *                 provider: String (Optional)
+     *                 modelName: String (Optional)
+     *                 timestamp: OffsetDateTime (Optional)
+     *             }
+     *         ]
+     *     }
+     *     kind: String(Detect) (Required)
+     *     createdAt: OffsetDateTime (Optional)
+     *     lastUpdatedAt: OffsetDateTime (Optional)
+     * }
+     * }
+     * 
+ * + * @param operationId The unique ID of the operation. + * @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 content Provenance Detection Status + * + * Gets the status, result, or error of an asynchronous Content Provenance Detection operation along with + * {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getOperationStatusWithResponseAsync(String operationId, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.getOperationStatus(this.getEndpoint(), + this.getServiceVersion().getVersion(), operationId, accept, requestOptions, context)); + } + + /** + * Get Content Provenance Detection Status + * + * Gets the status, result, or error of an asynchronous Content Provenance Detection operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         error (Required): (recursive schema, see error above)
+     *     }
+     *     result (Optional): {
+     *         outcome: String(NoProvenanceDetected/ProvenanceDetected) (Required)
+     *         results (Optional): [
+     *              (Optional){
+     *                 type: String(C2PA/Watermark) (Optional)
+     *                 provider: String (Optional)
+     *                 modelName: String (Optional)
+     *                 timestamp: OffsetDateTime (Optional)
+     *             }
+     *         ]
+     *     }
+     *     kind: String(Detect) (Required)
+     *     createdAt: OffsetDateTime (Optional)
+     *     lastUpdatedAt: OffsetDateTime (Optional)
+     * }
+     * }
+     * 
+ * + * @param operationId The unique ID of the operation. + * @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 content Provenance Detection Status + * + * Gets the status, result, or error of an asynchronous Content Provenance Detection operation along with + * {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getOperationStatusWithResponse(String operationId, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getOperationStatusSync(this.getEndpoint(), this.getServiceVersion().getVersion(), operationId, + accept, 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 000000000000..dc39911001d9 --- /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 000000000000..411edca19e7b --- /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> POST_POLL_RESULT_TYPE_REFERENCE + = new TypeReference>() { + }; + + public static final HttpHeaderName OPERATION_LOCATION_HEADER = HttpHeaderName.fromString("Operation-Location"); + + public static final String HTTP_METHOD = "httpMethod"; + public static final String REQUEST_URL = "requestURL"; + public static final String POLL_RESPONSE_BODY = "pollResponseBody"; + + private static final String FORWARD_SLASH = "/"; + + public static String getAbsolutePath(String path, String endpoint, ClientLogger logger) { + try { + URI uri = new URI(path); + if (!uri.isAbsolute()) { + if (CoreUtils.isNullOrEmpty(endpoint)) { + throw logger.logExceptionAsError(new IllegalArgumentException( + "Relative path requires endpoint to be non-null and non-empty to create an absolute path.")); + } + + if (endpoint.endsWith(FORWARD_SLASH) && path.startsWith(FORWARD_SLASH)) { + return endpoint + path.substring(1); + } else if (!endpoint.endsWith(FORWARD_SLASH) && !path.startsWith(FORWARD_SLASH)) { + return endpoint + FORWARD_SLASH + path; + } else { + return endpoint + path; + } + } + } catch (URISyntaxException ex) { + throw logger.logExceptionAsWarning(new IllegalArgumentException("'path' must be a valid URI.", ex)); + } + return path; + } + + public static T deserializeResponseSync(BinaryData binaryData, ObjectSerializer serializer, + TypeReference typeReference) { + T value; + if (binaryData == null) { + value = null; + } else if (typeReference.getJavaClass().isAssignableFrom(BinaryData.class)) { + // T is BinaryData + value = typeReference.getJavaClass().cast(binaryData.toReplayableBinaryData()); + } else { + value = binaryData.toObject(typeReference, serializer); + } + return value; + } + + @SuppressWarnings("unchecked") + public static Mono deserializeResponse(BinaryData binaryData, ObjectSerializer serializer, + TypeReference typeReference) { + Mono value; + if (binaryData == null) { + value = Mono.empty(); + } else if (typeReference.getJavaClass().isAssignableFrom(BinaryData.class)) { + // T is BinaryData + value = (Mono) binaryData.toReplayableBinaryDataAsync(); + } else { + value = binaryData.toObjectAsync(typeReference, serializer); + } + return value; + } + + private static final HttpHeaderName RETRY_AFTER_MS_HEADER = HttpHeaderName.fromString("retry-after-ms"); + private static final HttpHeaderName X_MS_RETRY_AFTER_MS_HEADER = HttpHeaderName.fromString("x-ms-retry-after-ms"); + + public static Duration getRetryAfterFromHeaders(HttpHeaders headers, Supplier nowSupplier) { + // Found 'x-ms-retry-after-ms' header, use a Duration of milliseconds based on the value. + Duration retryDelay = tryGetRetryDelay(headers, X_MS_RETRY_AFTER_MS_HEADER, s -> tryGetDelayMillis(s)); + if (retryDelay != null) { + return retryDelay; + } + + // Found 'retry-after-ms' header, use a Duration of milliseconds based on the value. + retryDelay = tryGetRetryDelay(headers, RETRY_AFTER_MS_HEADER, s -> tryGetDelayMillis(s)); + if (retryDelay != null) { + return retryDelay; + } + + // Found 'Retry-After' header. First, attempt to resolve it as a Duration of seconds. If that fails, then + // attempt to resolve it as an HTTP date (RFC1123). + retryDelay = tryGetRetryDelay(headers, HttpHeaderName.RETRY_AFTER, + headerValue -> tryParseLongOrDateTime(headerValue, nowSupplier)); + + // Either the retry delay will have been found or it'll be null, null indicates no retry after. + return retryDelay; + } + + private static Duration tryGetRetryDelay(HttpHeaders headers, HttpHeaderName headerName, + Function delayParser) { + String headerValue = headers.getValue(headerName); + + return CoreUtils.isNullOrEmpty(headerValue) ? null : delayParser.apply(headerValue); + } + + private static Duration tryParseLongOrDateTime(String value, Supplier nowSupplier) { + long delaySeconds; + try { + OffsetDateTime retryAfter = new DateTimeRfc1123(value).getDateTime(); + + delaySeconds = nowSupplier.get().until(retryAfter, ChronoUnit.SECONDS); + } catch (DateTimeException ex) { + delaySeconds = tryParseLong(value); + } + + return (delaySeconds >= 0) ? Duration.ofSeconds(delaySeconds) : null; + } + + private static long tryParseLong(String value) { + try { + return Long.parseLong(value); + } catch (NumberFormatException ex) { + return -1; + } + } + + private static Duration tryGetDelayMillis(String value) { + long delayMillis = tryParseLong(value); + return (delayMillis >= 0) ? Duration.ofMillis(delayMillis) : null; + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/implementation/SyncOperationLocationPollingStrategy.java b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/implementation/SyncOperationLocationPollingStrategy.java new file mode 100644 index 000000000000..f2b6a87c191b --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/implementation/SyncOperationLocationPollingStrategy.java @@ -0,0 +1,133 @@ +// 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.PollResponse; +import com.azure.core.util.polling.PollingContext; +import com.azure.core.util.polling.PollingStrategyOptions; +import com.azure.core.util.polling.SyncOperationResourcePollingStrategy; +import com.azure.core.util.serializer.JsonSerializerProviders; +import com.azure.core.util.serializer.ObjectSerializer; +import com.azure.core.util.serializer.TypeReference; +import java.io.UncheckedIOException; +import java.time.Duration; +import java.time.OffsetDateTime; +import java.util.Map; + +// DO NOT modify this helper class + +/** + * Implements a synchronous 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 SyncOperationLocationPollingStrategy extends SyncOperationResourcePollingStrategy { + + private static final ClientLogger LOGGER = new ClientLogger(SyncOperationLocationPollingStrategy.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 SyncOperationLocationPollingStrategy(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 SyncOperationLocationPollingStrategy(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 PollResponse 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); + T initialResponseType = null; + try { + initialResponseType = PollingUtils.deserializeResponseSync((BinaryData) response.getValue(), serializer, + pollResponseType); + } catch (UncheckedIOException e) { + LOGGER.info("Failed to parse initial response."); + } + return new PollResponse<>(LongRunningOperationStatus.IN_PROGRESS, initialResponseType, retryAfter); + } + + throw LOGGER.logExceptionAsError(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} + */ + public U getResult(PollingContext pollingContext, TypeReference resultType) { + if (pollingContext.getLatestResponse().getStatus() == LongRunningOperationStatus.FAILED) { + throw LOGGER.logExceptionAsError(new AzureException("Long running operation failed.")); + } else if (pollingContext.getLatestResponse().getStatus() == LongRunningOperationStatus.USER_CANCELLED) { + throw LOGGER.logExceptionAsError(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)); + Map pollResult = PollingUtils.deserializeResponseSync(latestResponseBody, serializer, + PollingUtils.POST_POLL_RESULT_TYPE_REFERENCE); + if (pollResult != null && pollResult.get(propertyName) != null) { + return PollingUtils.deserializeResponseSync(BinaryData.fromObject(pollResult.get(propertyName)), + serializer, resultType); + } else { + throw LOGGER.logExceptionAsError(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/models/DetectOutcome.java b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/DetectOutcome.java new file mode 100644 index 000000000000..724164f74301 --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/DetectOutcome.java @@ -0,0 +1,58 @@ +// 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 java.util.Collection; + +/** + * Top-level outcome of a Content Provenance Detection operation. + */ +public final class DetectOutcome extends ExpandableStringEnum { + + /** + * No supported Microsoft-issued C2PA or imperceptible watermark signal was detected. + * This doesn't necessarily mean the content wasn't AI-generated; it means no supported signal was found. + */ + @Generated + public static final DetectOutcome NO_PROVENANCE_DETECTED = fromString("NoProvenanceDetected"); + + /** + * At least one supported Microsoft-issued C2PA or imperceptible watermark signal was detected. + */ + @Generated + public static final DetectOutcome PROVENANCE_DETECTED = fromString("ProvenanceDetected"); + + /** + * Creates a new instance of DetectOutcome value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public DetectOutcome() { + } + + /** + * Creates or finds a DetectOutcome from its string representation. + * + * @param name a name to look for. + * @return the corresponding DetectOutcome. + */ + @Generated + public static DetectOutcome fromString(String name) { + return fromString(name, DetectOutcome.class); + } + + /** + * Gets known DetectOutcome values. + * + * @return known DetectOutcome values. + */ + @Generated + public static Collection values() { + return values(DetectOutcome.class); + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/DetectProvenanceOptions.java b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/DetectProvenanceOptions.java new file mode 100644 index 000000000000..8c6b71a83563 --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/DetectProvenanceOptions.java @@ -0,0 +1,82 @@ +// 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.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Input describing the media to inspect using Content Provenance Detection. + */ +@Immutable +public final class DetectProvenanceOptions implements JsonSerializable { + + /* + * Source content to inspect. + */ + @Generated + private final ProvenanceContent content; + + /** + * Creates an instance of DetectProvenanceOptions class. + * + * @param content the content value to set. + */ + @Generated + public DetectProvenanceOptions(ProvenanceContent content) { + this.content = content; + } + + /** + * Get the content property: Source content to inspect. + * + * @return the content value. + */ + @Generated + public ProvenanceContent getContent() { + return this.content; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("content", this.content); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DetectProvenanceOptions from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DetectProvenanceOptions if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the DetectProvenanceOptions. + */ + @Generated + public static DetectProvenanceOptions fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ProvenanceContent content = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("content".equals(fieldName)) { + content = ProvenanceContent.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new DetectProvenanceOptions(content); + }); + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/DetectProvenanceResult.java b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/DetectProvenanceResult.java new file mode 100644 index 000000000000..0d146bc3b72c --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/DetectProvenanceResult.java @@ -0,0 +1,105 @@ +// 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.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * Result of a Content Provenance Detection operation. + */ +@Immutable +public final class DetectProvenanceResult implements JsonSerializable { + + /* + * Top-level outcome of the Content Provenance Detection operation. + */ + @Generated + private final DetectOutcome outcome; + + /* + * Detected provenance signals. Empty or omitted when `outcome` is `NoProvenanceDetected`. + */ + @Generated + private List results; + + /** + * Creates an instance of DetectProvenanceResult class. + * + * @param outcome the outcome value to set. + */ + @Generated + private DetectProvenanceResult(DetectOutcome outcome) { + this.outcome = outcome; + } + + /** + * Get the outcome property: Top-level outcome of the Content Provenance Detection operation. + * + * @return the outcome value. + */ + @Generated + public DetectOutcome getOutcome() { + return this.outcome; + } + + /** + * Get the results property: Detected provenance signals. Empty or omitted when `outcome` is `NoProvenanceDetected`. + * + * @return the results value. + */ + @Generated + public List getResults() { + return this.results; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("outcome", this.outcome == null ? null : this.outcome.toString()); + jsonWriter.writeArrayField("results", this.results, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DetectProvenanceResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DetectProvenanceResult if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the DetectProvenanceResult. + */ + @Generated + public static DetectProvenanceResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + DetectOutcome outcome = null; + List results = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("outcome".equals(fieldName)) { + outcome = DetectOutcome.fromString(reader.getString()); + } else if ("results".equals(fieldName)) { + results = reader.readArray(reader1 -> DetectedProvenance.fromJson(reader1)); + } else { + reader.skipChildren(); + } + } + DetectProvenanceResult deserializedDetectProvenanceResult = new DetectProvenanceResult(outcome); + deserializedDetectProvenanceResult.results = results; + return deserializedDetectProvenanceResult; + }); + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/DetectedProvenance.java b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/DetectedProvenance.java new file mode 100644 index 000000000000..7b765dfd3727 --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/DetectedProvenance.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.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.util.CoreUtils; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; + +/** + * A Microsoft-issued provenance signal indicating the media was created or modified using AI. + */ +@Immutable +public final class DetectedProvenance implements JsonSerializable { + + /* + * Detected provenance record type. + */ + @Generated + private DetectedProvenanceType type; + + /* + * Identifier of the Microsoft provider that generated the content. + */ + @Generated + private String provider; + + /* + * Identifier of the generating AI model when available. + */ + @Generated + private String modelName; + + /* + * Generation timestamp recorded in the provenance signal. + */ + @Generated + private OffsetDateTime timestamp; + + /** + * Creates an instance of DetectedProvenance class. + */ + @Generated + private DetectedProvenance() { + } + + /** + * Get the type property: Detected provenance record type. + * + * @return the type value. + */ + @Generated + public DetectedProvenanceType getType() { + return this.type; + } + + /** + * Get the provider property: Identifier of the Microsoft provider that generated the content. + * + * @return the provider value. + */ + @Generated + public String getProvider() { + return this.provider; + } + + /** + * Get the modelName property: Identifier of the generating AI model when available. + * + * @return the modelName value. + */ + @Generated + public String getModelName() { + return this.modelName; + } + + /** + * Get the timestamp property: Generation timestamp recorded in the provenance signal. + * + * @return the timestamp value. + */ + @Generated + public OffsetDateTime getTimestamp() { + return this.timestamp; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + jsonWriter.writeStringField("provider", this.provider); + jsonWriter.writeStringField("modelName", this.modelName); + jsonWriter.writeStringField("timestamp", + this.timestamp == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.timestamp)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DetectedProvenance from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DetectedProvenance if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the DetectedProvenance. + */ + @Generated + public static DetectedProvenance fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + DetectedProvenance deserializedDetectedProvenance = new DetectedProvenance(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("type".equals(fieldName)) { + deserializedDetectedProvenance.type = DetectedProvenanceType.fromString(reader.getString()); + } else if ("provider".equals(fieldName)) { + deserializedDetectedProvenance.provider = reader.getString(); + } else if ("modelName".equals(fieldName)) { + deserializedDetectedProvenance.modelName = reader.getString(); + } else if ("timestamp".equals(fieldName)) { + deserializedDetectedProvenance.timestamp = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else { + reader.skipChildren(); + } + } + return deserializedDetectedProvenance; + }); + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/DetectedProvenanceType.java b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/DetectedProvenanceType.java new file mode 100644 index 000000000000..70e0ea0467af --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/DetectedProvenanceType.java @@ -0,0 +1,57 @@ +// 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 java.util.Collection; + +/** + * Detected provenance record type. + */ +public final class DetectedProvenanceType extends ExpandableStringEnum { + + /** + * Provenance came from a C2PA Content Credential (manifest). + */ + @Generated + public static final DetectedProvenanceType C2PA = fromString("C2PA"); + + /** + * Provenance came from an imperceptible watermark. + */ + @Generated + public static final DetectedProvenanceType WATERMARK = fromString("Watermark"); + + /** + * Creates a new instance of DetectedProvenanceType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public DetectedProvenanceType() { + } + + /** + * Creates or finds a DetectedProvenanceType from its string representation. + * + * @param name a name to look for. + * @return the corresponding DetectedProvenanceType. + */ + @Generated + public static DetectedProvenanceType fromString(String name) { + return fromString(name, DetectedProvenanceType.class); + } + + /** + * Gets known DetectedProvenanceType values. + * + * @return known DetectedProvenanceType values. + */ + @Generated + public static Collection values() { + return values(DetectedProvenanceType.class); + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/OperationState.java b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/OperationState.java new file mode 100644 index 000000000000..2ae83a119d45 --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/OperationState.java @@ -0,0 +1,75 @@ +// 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 java.util.Collection; + +/** + * Enum describing allowed operation states. + */ +public final class OperationState extends ExpandableStringEnum { + + /** + * The operation has not started. + */ + @Generated + public static final OperationState NOT_STARTED = fromString("NotStarted"); + + /** + * The operation is in progress. + */ + @Generated + public static final OperationState RUNNING = fromString("Running"); + + /** + * The operation has completed successfully. + */ + @Generated + public static final OperationState SUCCEEDED = fromString("Succeeded"); + + /** + * The operation has failed. + */ + @Generated + public static final OperationState FAILED = fromString("Failed"); + + /** + * The operation has been canceled by the user. + */ + @Generated + public static final OperationState CANCELED = fromString("Canceled"); + + /** + * Creates a new instance of OperationState value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public OperationState() { + } + + /** + * Creates or finds a OperationState from its string representation. + * + * @param name a name to look for. + * @return the corresponding OperationState. + */ + @Generated + public static OperationState fromString(String name) { + return fromString(name, OperationState.class); + } + + /** + * Gets known OperationState values. + * + * @return known OperationState values. + */ + @Generated + public static Collection values() { + return values(OperationState.class); + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/ProvenanceContent.java b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/ProvenanceContent.java new file mode 100644 index 000000000000..c5746d896ebd --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/ProvenanceContent.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.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Source content descriptor for a Content Provenance Detection operation. + */ +@Immutable +public final class ProvenanceContent implements JsonSerializable { + + /* + * Blob URI of the media to inspect. Media up to 100 MB is supported. Supported formats: image (JPEG, PNG, GIF, + * WebP), audio (MP3, WAV), and video (MP4). + */ + @Generated + private final String uri; + + /** + * Creates an instance of ProvenanceContent class. + * + * @param uri the uri value to set. + */ + @Generated + public ProvenanceContent(String uri) { + this.uri = uri; + } + + /** + * Get the uri property: Blob URI of the media to inspect. Media up to 100 MB is supported. Supported formats: image + * (JPEG, PNG, GIF, WebP), audio (MP3, WAV), and video (MP4). + * + * @return the uri value. + */ + @Generated + public String getUri() { + return this.uri; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("uri", this.uri); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ProvenanceContent from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ProvenanceContent if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ProvenanceContent. + */ + @Generated + public static ProvenanceContent fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String uri = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("uri".equals(fieldName)) { + uri = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new ProvenanceContent(uri); + }); + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/ProvenanceDetectOperation.java b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/ProvenanceDetectOperation.java new file mode 100644 index 000000000000..ac2c4c8f8660 --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/ProvenanceDetectOperation.java @@ -0,0 +1,210 @@ +// 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.azure.core.models.ResponseError; +import com.azure.core.util.CoreUtils; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; + +/** + * Status and result of an asynchronous Content Provenance Detection operation. + */ +@Immutable +public final class ProvenanceDetectOperation implements JsonSerializable { + + /* + * The unique ID of the operation. + */ + @Generated + private String id; + + /* + * The status of the operation + */ + @Generated + private final OperationState status; + + /* + * Error object that describes the error when status is "Failed". + */ + @Generated + private ResponseError error; + + /* + * The result of the operation. + */ + @Generated + private DetectProvenanceResult result; + + /* + * Kind of Content Provenance Detection operation. + */ + @Generated + private ProvenanceOperationKind kind; + + /* + * Date and time (UTC) when the operation was created. + */ + @Generated + private OffsetDateTime createdAt; + + /* + * Date and time (UTC) when the status was last updated. + */ + @Generated + private OffsetDateTime lastUpdatedAt; + + /** + * Creates an instance of ProvenanceDetectOperation class. + * + * @param status the status value to set. + */ + @Generated + private ProvenanceDetectOperation(OperationState status) { + this.status = status; + } + + /** + * Get the id property: The unique ID of the operation. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the status property: The status of the operation. + * + * @return the status value. + */ + @Generated + public OperationState getStatus() { + return this.status; + } + + /** + * Get the error property: Error object that describes the error when status is "Failed". + * + * @return the error value. + */ + @Generated + public ResponseError getError() { + return this.error; + } + + /** + * Get the result property: The result of the operation. + * + * @return the result value. + */ + @Generated + public DetectProvenanceResult getResult() { + return this.result; + } + + /** + * Get the kind property: Kind of Content Provenance Detection operation. + * + * @return the kind value. + */ + @Generated + public ProvenanceOperationKind getKind() { + return this.kind; + } + + /** + * Get the createdAt property: Date and time (UTC) when the operation was created. + * + * @return the createdAt value. + */ + @Generated + public OffsetDateTime getCreatedAt() { + return this.createdAt; + } + + /** + * Get the lastUpdatedAt property: Date and time (UTC) when the status was last updated. + * + * @return the lastUpdatedAt value. + */ + @Generated + public OffsetDateTime getLastUpdatedAt() { + return this.lastUpdatedAt; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("status", this.status == null ? null : this.status.toString()); + jsonWriter.writeJsonField("error", this.error); + jsonWriter.writeJsonField("result", this.result); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ProvenanceDetectOperation from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ProvenanceDetectOperation if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ProvenanceDetectOperation. + */ + @Generated + public static ProvenanceDetectOperation fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + OperationState status = null; + ProvenanceOperationKind kind = null; + ResponseError error = null; + DetectProvenanceResult result = null; + OffsetDateTime createdAt = null; + OffsetDateTime lastUpdatedAt = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("status".equals(fieldName)) { + status = OperationState.fromString(reader.getString()); + } else if ("kind".equals(fieldName)) { + kind = ProvenanceOperationKind.fromString(reader.getString()); + } else if ("error".equals(fieldName)) { + error = ResponseError.fromJson(reader); + } else if ("result".equals(fieldName)) { + result = DetectProvenanceResult.fromJson(reader); + } else if ("createdAt".equals(fieldName)) { + createdAt = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("lastUpdatedAt".equals(fieldName)) { + lastUpdatedAt = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else { + reader.skipChildren(); + } + } + ProvenanceDetectOperation deserializedProvenanceDetectOperation = new ProvenanceDetectOperation(status); + deserializedProvenanceDetectOperation.id = id; + deserializedProvenanceDetectOperation.kind = kind; + deserializedProvenanceDetectOperation.error = error; + deserializedProvenanceDetectOperation.result = result; + deserializedProvenanceDetectOperation.createdAt = createdAt; + deserializedProvenanceDetectOperation.lastUpdatedAt = lastUpdatedAt; + return deserializedProvenanceDetectOperation; + }); + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/ProvenanceOperationKind.java b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/ProvenanceOperationKind.java new file mode 100644 index 000000000000..1442eb52e55b --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/models/ProvenanceOperationKind.java @@ -0,0 +1,51 @@ +// 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 java.util.Collection; + +/** + * Kind of asynchronous Content Provenance Detection operation. + */ +public final class ProvenanceOperationKind extends ExpandableStringEnum { + + /** + * Content Provenance Detection operation. + */ + @Generated + public static final ProvenanceOperationKind DETECT = fromString("Detect"); + + /** + * Creates a new instance of ProvenanceOperationKind value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public ProvenanceOperationKind() { + } + + /** + * Creates or finds a ProvenanceOperationKind from its string representation. + * + * @param name a name to look for. + * @return the corresponding ProvenanceOperationKind. + */ + @Generated + public static ProvenanceOperationKind fromString(String name) { + return fromString(name, ProvenanceOperationKind.class); + } + + /** + * Gets known ProvenanceOperationKind values. + * + * @return known ProvenanceOperationKind values. + */ + @Generated + public static Collection values() { + return values(ProvenanceOperationKind.class); + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/main/resources/META-INF/azure-ai-contentsafety_metadata.json b/sdk/contentsafety/azure-ai-contentsafety/src/main/resources/META-INF/azure-ai-contentsafety_metadata.json index 3ca2edbd21a5..2e6bd25c0767 100644 --- a/sdk/contentsafety/azure-ai-contentsafety/src/main/resources/META-INF/azure-ai-contentsafety_metadata.json +++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/resources/META-INF/azure-ai-contentsafety_metadata.json @@ -1 +1 @@ -{"flavor":"azure","apiVersions":{"ContentSafety":"2023-10-01"},"crossLanguageDefinitions":{"com.azure.ai.contentsafety.BlocklistAsyncClient":"Customizations.BlocklistClient","com.azure.ai.contentsafety.BlocklistAsyncClient.addOrUpdateBlocklistItems":"Customizations.BlocklistClient.addOrUpdateBlocklistItems","com.azure.ai.contentsafety.BlocklistAsyncClient.addOrUpdateBlocklistItemsWithResponse":"Customizations.BlocklistClient.addOrUpdateBlocklistItems","com.azure.ai.contentsafety.BlocklistAsyncClient.createOrUpdateTextBlocklist":"Customizations.BlocklistClient.createOrUpdateTextBlocklist","com.azure.ai.contentsafety.BlocklistAsyncClient.createOrUpdateTextBlocklistWithResponse":"Customizations.BlocklistClient.createOrUpdateTextBlocklist","com.azure.ai.contentsafety.BlocklistAsyncClient.deleteTextBlocklist":"Customizations.BlocklistClient.deleteTextBlocklist","com.azure.ai.contentsafety.BlocklistAsyncClient.deleteTextBlocklistWithResponse":"Customizations.BlocklistClient.deleteTextBlocklist","com.azure.ai.contentsafety.BlocklistAsyncClient.getTextBlocklist":"Customizations.BlocklistClient.getTextBlocklist","com.azure.ai.contentsafety.BlocklistAsyncClient.getTextBlocklistItem":"Customizations.BlocklistClient.getTextBlocklistItem","com.azure.ai.contentsafety.BlocklistAsyncClient.getTextBlocklistItemWithResponse":"Customizations.BlocklistClient.getTextBlocklistItem","com.azure.ai.contentsafety.BlocklistAsyncClient.getTextBlocklistWithResponse":"Customizations.BlocklistClient.getTextBlocklist","com.azure.ai.contentsafety.BlocklistAsyncClient.listTextBlocklistItems":"Customizations.BlocklistClient.listTextBlocklistItems","com.azure.ai.contentsafety.BlocklistAsyncClient.listTextBlocklists":"Customizations.BlocklistClient.listTextBlocklists","com.azure.ai.contentsafety.BlocklistAsyncClient.removeBlocklistItems":"Customizations.BlocklistClient.removeBlocklistItems","com.azure.ai.contentsafety.BlocklistAsyncClient.removeBlocklistItemsWithResponse":"Customizations.BlocklistClient.removeBlocklistItems","com.azure.ai.contentsafety.BlocklistClient":"Customizations.BlocklistClient","com.azure.ai.contentsafety.BlocklistClient.addOrUpdateBlocklistItems":"Customizations.BlocklistClient.addOrUpdateBlocklistItems","com.azure.ai.contentsafety.BlocklistClient.addOrUpdateBlocklistItemsWithResponse":"Customizations.BlocklistClient.addOrUpdateBlocklistItems","com.azure.ai.contentsafety.BlocklistClient.createOrUpdateTextBlocklist":"Customizations.BlocklistClient.createOrUpdateTextBlocklist","com.azure.ai.contentsafety.BlocklistClient.createOrUpdateTextBlocklistWithResponse":"Customizations.BlocklistClient.createOrUpdateTextBlocklist","com.azure.ai.contentsafety.BlocklistClient.deleteTextBlocklist":"Customizations.BlocklistClient.deleteTextBlocklist","com.azure.ai.contentsafety.BlocklistClient.deleteTextBlocklistWithResponse":"Customizations.BlocklistClient.deleteTextBlocklist","com.azure.ai.contentsafety.BlocklistClient.getTextBlocklist":"Customizations.BlocklistClient.getTextBlocklist","com.azure.ai.contentsafety.BlocklistClient.getTextBlocklistItem":"Customizations.BlocklistClient.getTextBlocklistItem","com.azure.ai.contentsafety.BlocklistClient.getTextBlocklistItemWithResponse":"Customizations.BlocklistClient.getTextBlocklistItem","com.azure.ai.contentsafety.BlocklistClient.getTextBlocklistWithResponse":"Customizations.BlocklistClient.getTextBlocklist","com.azure.ai.contentsafety.BlocklistClient.listTextBlocklistItems":"Customizations.BlocklistClient.listTextBlocklistItems","com.azure.ai.contentsafety.BlocklistClient.listTextBlocklists":"Customizations.BlocklistClient.listTextBlocklists","com.azure.ai.contentsafety.BlocklistClient.removeBlocklistItems":"Customizations.BlocklistClient.removeBlocklistItems","com.azure.ai.contentsafety.BlocklistClient.removeBlocklistItemsWithResponse":"Customizations.BlocklistClient.removeBlocklistItems","com.azure.ai.contentsafety.BlocklistClientBuilder":"Customizations.BlocklistClient","com.azure.ai.contentsafety.ContentSafetyAsyncClient":"Customizations.ContentSafetyClient","com.azure.ai.contentsafety.ContentSafetyAsyncClient.analyzeImage":"Customizations.ContentSafetyClient.analyzeImage","com.azure.ai.contentsafety.ContentSafetyAsyncClient.analyzeImageWithResponse":"Customizations.ContentSafetyClient.analyzeImage","com.azure.ai.contentsafety.ContentSafetyAsyncClient.analyzeText":"Customizations.ContentSafetyClient.analyzeText","com.azure.ai.contentsafety.ContentSafetyAsyncClient.analyzeTextWithResponse":"Customizations.ContentSafetyClient.analyzeText","com.azure.ai.contentsafety.ContentSafetyClient":"Customizations.ContentSafetyClient","com.azure.ai.contentsafety.ContentSafetyClient.analyzeImage":"Customizations.ContentSafetyClient.analyzeImage","com.azure.ai.contentsafety.ContentSafetyClient.analyzeImageWithResponse":"Customizations.ContentSafetyClient.analyzeImage","com.azure.ai.contentsafety.ContentSafetyClient.analyzeText":"Customizations.ContentSafetyClient.analyzeText","com.azure.ai.contentsafety.ContentSafetyClient.analyzeTextWithResponse":"Customizations.ContentSafetyClient.analyzeText","com.azure.ai.contentsafety.ContentSafetyClientBuilder":"Customizations.ContentSafetyClient","com.azure.ai.contentsafety.models.AddOrUpdateTextBlocklistItemsOptions":"ContentSafety.AddOrUpdateTextBlocklistItemsOptions","com.azure.ai.contentsafety.models.AddOrUpdateTextBlocklistItemsResult":"ContentSafety.AddOrUpdateTextBlocklistItemsResult","com.azure.ai.contentsafety.models.AnalyzeImageOptions":"ContentSafety.AnalyzeImageOptions","com.azure.ai.contentsafety.models.AnalyzeImageOutputType":"ContentSafety.AnalyzeImageOutputType","com.azure.ai.contentsafety.models.AnalyzeImageResult":"ContentSafety.AnalyzeImageResult","com.azure.ai.contentsafety.models.AnalyzeTextOptions":"ContentSafety.AnalyzeTextOptions","com.azure.ai.contentsafety.models.AnalyzeTextOutputType":"ContentSafety.AnalyzeTextOutputType","com.azure.ai.contentsafety.models.AnalyzeTextResult":"ContentSafety.AnalyzeTextResult","com.azure.ai.contentsafety.models.ContentSafetyImageData":"ContentSafety.ImageData","com.azure.ai.contentsafety.models.ImageCategoriesAnalysis":"ContentSafety.ImageCategoriesAnalysis","com.azure.ai.contentsafety.models.ImageCategory":"ContentSafety.ImageCategory","com.azure.ai.contentsafety.models.RemoveTextBlocklistItemsOptions":"ContentSafety.RemoveTextBlocklistItemsOptions","com.azure.ai.contentsafety.models.TextBlocklist":"ContentSafety.TextBlocklist","com.azure.ai.contentsafety.models.TextBlocklistItem":"ContentSafety.TextBlocklistItem","com.azure.ai.contentsafety.models.TextBlocklistMatch":"ContentSafety.TextBlocklistMatch","com.azure.ai.contentsafety.models.TextCategoriesAnalysis":"ContentSafety.TextCategoriesAnalysis","com.azure.ai.contentsafety.models.TextCategory":"ContentSafety.TextCategory"},"generatedFiles":["src/main/java/com/azure/ai/contentsafety/BlocklistAsyncClient.java","src/main/java/com/azure/ai/contentsafety/BlocklistClient.java","src/main/java/com/azure/ai/contentsafety/BlocklistClientBuilder.java","src/main/java/com/azure/ai/contentsafety/ContentSafetyAsyncClient.java","src/main/java/com/azure/ai/contentsafety/ContentSafetyClient.java","src/main/java/com/azure/ai/contentsafety/ContentSafetyClientBuilder.java","src/main/java/com/azure/ai/contentsafety/ContentSafetyServiceVersion.java","src/main/java/com/azure/ai/contentsafety/ContentSafetyServiceVersion.java","src/main/java/com/azure/ai/contentsafety/implementation/BlocklistClientImpl.java","src/main/java/com/azure/ai/contentsafety/implementation/ContentSafetyClientImpl.java","src/main/java/com/azure/ai/contentsafety/implementation/JsonMergePatchHelper.java","src/main/java/com/azure/ai/contentsafety/implementation/package-info.java","src/main/java/com/azure/ai/contentsafety/models/AddOrUpdateTextBlocklistItemsOptions.java","src/main/java/com/azure/ai/contentsafety/models/AddOrUpdateTextBlocklistItemsResult.java","src/main/java/com/azure/ai/contentsafety/models/AnalyzeImageOptions.java","src/main/java/com/azure/ai/contentsafety/models/AnalyzeImageOutputType.java","src/main/java/com/azure/ai/contentsafety/models/AnalyzeImageResult.java","src/main/java/com/azure/ai/contentsafety/models/AnalyzeTextOptions.java","src/main/java/com/azure/ai/contentsafety/models/AnalyzeTextOutputType.java","src/main/java/com/azure/ai/contentsafety/models/AnalyzeTextResult.java","src/main/java/com/azure/ai/contentsafety/models/ContentSafetyImageData.java","src/main/java/com/azure/ai/contentsafety/models/ImageCategoriesAnalysis.java","src/main/java/com/azure/ai/contentsafety/models/ImageCategory.java","src/main/java/com/azure/ai/contentsafety/models/RemoveTextBlocklistItemsOptions.java","src/main/java/com/azure/ai/contentsafety/models/TextBlocklist.java","src/main/java/com/azure/ai/contentsafety/models/TextBlocklistItem.java","src/main/java/com/azure/ai/contentsafety/models/TextBlocklistMatch.java","src/main/java/com/azure/ai/contentsafety/models/TextCategoriesAnalysis.java","src/main/java/com/azure/ai/contentsafety/models/TextCategory.java","src/main/java/com/azure/ai/contentsafety/models/package-info.java","src/main/java/com/azure/ai/contentsafety/package-info.java","src/main/java/module-info.java"]} \ No newline at end of file +{"flavor":"azure","apiVersions":{"ContentSafety":"2023-10-01"},"crossLanguagePackageId":"ContentSafety","crossLanguageVersion":"ea7c2c2d91e8","crossLanguageDefinitions":{"com.azure.ai.contentsafety.BlocklistAsyncClient":"Customizations.BlocklistClient","com.azure.ai.contentsafety.BlocklistAsyncClient.addOrUpdateBlocklistItems":"Customizations.BlocklistClient.addOrUpdateBlocklistItems","com.azure.ai.contentsafety.BlocklistAsyncClient.addOrUpdateBlocklistItemsWithResponse":"Customizations.BlocklistClient.addOrUpdateBlocklistItems","com.azure.ai.contentsafety.BlocklistAsyncClient.createOrUpdateTextBlocklist":"Customizations.BlocklistClient.createOrUpdateTextBlocklist","com.azure.ai.contentsafety.BlocklistAsyncClient.createOrUpdateTextBlocklistWithResponse":"Customizations.BlocklistClient.createOrUpdateTextBlocklist","com.azure.ai.contentsafety.BlocklistAsyncClient.deleteTextBlocklist":"Customizations.BlocklistClient.deleteTextBlocklist","com.azure.ai.contentsafety.BlocklistAsyncClient.deleteTextBlocklistWithResponse":"Customizations.BlocklistClient.deleteTextBlocklist","com.azure.ai.contentsafety.BlocklistAsyncClient.getTextBlocklist":"Customizations.BlocklistClient.getTextBlocklist","com.azure.ai.contentsafety.BlocklistAsyncClient.getTextBlocklistItem":"Customizations.BlocklistClient.getTextBlocklistItem","com.azure.ai.contentsafety.BlocklistAsyncClient.getTextBlocklistItemWithResponse":"Customizations.BlocklistClient.getTextBlocklistItem","com.azure.ai.contentsafety.BlocklistAsyncClient.getTextBlocklistWithResponse":"Customizations.BlocklistClient.getTextBlocklist","com.azure.ai.contentsafety.BlocklistAsyncClient.listTextBlocklistItems":"Customizations.BlocklistClient.listTextBlocklistItems","com.azure.ai.contentsafety.BlocklistAsyncClient.listTextBlocklists":"Customizations.BlocklistClient.listTextBlocklists","com.azure.ai.contentsafety.BlocklistAsyncClient.removeBlocklistItems":"Customizations.BlocklistClient.removeBlocklistItems","com.azure.ai.contentsafety.BlocklistAsyncClient.removeBlocklistItemsWithResponse":"Customizations.BlocklistClient.removeBlocklistItems","com.azure.ai.contentsafety.BlocklistClient":"Customizations.BlocklistClient","com.azure.ai.contentsafety.BlocklistClient.addOrUpdateBlocklistItems":"Customizations.BlocklistClient.addOrUpdateBlocklistItems","com.azure.ai.contentsafety.BlocklistClient.addOrUpdateBlocklistItemsWithResponse":"Customizations.BlocklistClient.addOrUpdateBlocklistItems","com.azure.ai.contentsafety.BlocklistClient.createOrUpdateTextBlocklist":"Customizations.BlocklistClient.createOrUpdateTextBlocklist","com.azure.ai.contentsafety.BlocklistClient.createOrUpdateTextBlocklistWithResponse":"Customizations.BlocklistClient.createOrUpdateTextBlocklist","com.azure.ai.contentsafety.BlocklistClient.deleteTextBlocklist":"Customizations.BlocklistClient.deleteTextBlocklist","com.azure.ai.contentsafety.BlocklistClient.deleteTextBlocklistWithResponse":"Customizations.BlocklistClient.deleteTextBlocklist","com.azure.ai.contentsafety.BlocklistClient.getTextBlocklist":"Customizations.BlocklistClient.getTextBlocklist","com.azure.ai.contentsafety.BlocklistClient.getTextBlocklistItem":"Customizations.BlocklistClient.getTextBlocklistItem","com.azure.ai.contentsafety.BlocklistClient.getTextBlocklistItemWithResponse":"Customizations.BlocklistClient.getTextBlocklistItem","com.azure.ai.contentsafety.BlocklistClient.getTextBlocklistWithResponse":"Customizations.BlocklistClient.getTextBlocklist","com.azure.ai.contentsafety.BlocklistClient.listTextBlocklistItems":"Customizations.BlocklistClient.listTextBlocklistItems","com.azure.ai.contentsafety.BlocklistClient.listTextBlocklists":"Customizations.BlocklistClient.listTextBlocklists","com.azure.ai.contentsafety.BlocklistClient.removeBlocklistItems":"Customizations.BlocklistClient.removeBlocklistItems","com.azure.ai.contentsafety.BlocklistClient.removeBlocklistItemsWithResponse":"Customizations.BlocklistClient.removeBlocklistItems","com.azure.ai.contentsafety.BlocklistClientBuilder":"Customizations.BlocklistClient","com.azure.ai.contentsafety.ContentProvenanceAsyncClient":"Customizations.ContentProvenanceClient","com.azure.ai.contentsafety.ContentProvenanceAsyncClient.beginDetect":"Customizations.ContentProvenanceClient.detect","com.azure.ai.contentsafety.ContentProvenanceAsyncClient.beginDetectWithModel":"Customizations.ContentProvenanceClient.detect","com.azure.ai.contentsafety.ContentProvenanceAsyncClient.getOperationStatus":"Customizations.ContentProvenanceClient.getOperationStatus","com.azure.ai.contentsafety.ContentProvenanceAsyncClient.getOperationStatusWithResponse":"Customizations.ContentProvenanceClient.getOperationStatus","com.azure.ai.contentsafety.ContentProvenanceClient":"Customizations.ContentProvenanceClient","com.azure.ai.contentsafety.ContentProvenanceClient.beginDetect":"Customizations.ContentProvenanceClient.detect","com.azure.ai.contentsafety.ContentProvenanceClient.beginDetectWithModel":"Customizations.ContentProvenanceClient.detect","com.azure.ai.contentsafety.ContentProvenanceClient.getOperationStatus":"Customizations.ContentProvenanceClient.getOperationStatus","com.azure.ai.contentsafety.ContentProvenanceClient.getOperationStatusWithResponse":"Customizations.ContentProvenanceClient.getOperationStatus","com.azure.ai.contentsafety.ContentProvenanceClientBuilder":"Customizations.ContentProvenanceClient","com.azure.ai.contentsafety.ContentSafetyAsyncClient":"Customizations.ContentSafetyClient","com.azure.ai.contentsafety.ContentSafetyAsyncClient.analyzeImage":"Customizations.ContentSafetyClient.analyzeImage","com.azure.ai.contentsafety.ContentSafetyAsyncClient.analyzeImageWithResponse":"Customizations.ContentSafetyClient.analyzeImage","com.azure.ai.contentsafety.ContentSafetyAsyncClient.analyzeText":"Customizations.ContentSafetyClient.analyzeText","com.azure.ai.contentsafety.ContentSafetyAsyncClient.analyzeTextWithResponse":"Customizations.ContentSafetyClient.analyzeText","com.azure.ai.contentsafety.ContentSafetyClient":"Customizations.ContentSafetyClient","com.azure.ai.contentsafety.ContentSafetyClient.analyzeImage":"Customizations.ContentSafetyClient.analyzeImage","com.azure.ai.contentsafety.ContentSafetyClient.analyzeImageWithResponse":"Customizations.ContentSafetyClient.analyzeImage","com.azure.ai.contentsafety.ContentSafetyClient.analyzeText":"Customizations.ContentSafetyClient.analyzeText","com.azure.ai.contentsafety.ContentSafetyClient.analyzeTextWithResponse":"Customizations.ContentSafetyClient.analyzeText","com.azure.ai.contentsafety.ContentSafetyClientBuilder":"Customizations.ContentSafetyClient","com.azure.ai.contentsafety.models.AddOrUpdateTextBlocklistItemsOptions":"ContentSafety.AddOrUpdateTextBlocklistItemsOptions","com.azure.ai.contentsafety.models.AddOrUpdateTextBlocklistItemsResult":"ContentSafety.AddOrUpdateTextBlocklistItemsResult","com.azure.ai.contentsafety.models.AnalyzeImageOptions":"ContentSafety.AnalyzeImageOptions","com.azure.ai.contentsafety.models.AnalyzeImageOutputType":"ContentSafety.AnalyzeImageOutputType","com.azure.ai.contentsafety.models.AnalyzeImageResult":"ContentSafety.AnalyzeImageResult","com.azure.ai.contentsafety.models.AnalyzeTextOptions":"ContentSafety.AnalyzeTextOptions","com.azure.ai.contentsafety.models.AnalyzeTextOutputType":"ContentSafety.AnalyzeTextOutputType","com.azure.ai.contentsafety.models.AnalyzeTextResult":"ContentSafety.AnalyzeTextResult","com.azure.ai.contentsafety.models.ContentSafetyImageData":"ContentSafety.ImageData","com.azure.ai.contentsafety.models.DetectOutcome":"ContentSafety.DetectOutcome","com.azure.ai.contentsafety.models.DetectProvenanceOptions":"ContentSafety.DetectProvenanceOptions","com.azure.ai.contentsafety.models.DetectProvenanceResult":"ContentSafety.DetectProvenanceResult","com.azure.ai.contentsafety.models.DetectedProvenance":"ContentSafety.DetectedProvenance","com.azure.ai.contentsafety.models.DetectedProvenanceType":"ContentSafety.DetectedProvenanceType","com.azure.ai.contentsafety.models.ImageCategoriesAnalysis":"ContentSafety.ImageCategoriesAnalysis","com.azure.ai.contentsafety.models.ImageCategory":"ContentSafety.ImageCategory","com.azure.ai.contentsafety.models.OperationState":"Azure.Core.Foundations.OperationState","com.azure.ai.contentsafety.models.ProvenanceContent":"ContentSafety.ProvenanceContent","com.azure.ai.contentsafety.models.ProvenanceDetectOperation":"ContentSafety.ProvenanceDetectOperation","com.azure.ai.contentsafety.models.ProvenanceOperationKind":"ContentSafety.ProvenanceOperationKind","com.azure.ai.contentsafety.models.RemoveTextBlocklistItemsOptions":"ContentSafety.RemoveTextBlocklistItemsOptions","com.azure.ai.contentsafety.models.TextBlocklist":"ContentSafety.TextBlocklist","com.azure.ai.contentsafety.models.TextBlocklistItem":"ContentSafety.TextBlocklistItem","com.azure.ai.contentsafety.models.TextBlocklistMatch":"ContentSafety.TextBlocklistMatch","com.azure.ai.contentsafety.models.TextCategoriesAnalysis":"ContentSafety.TextCategoriesAnalysis","com.azure.ai.contentsafety.models.TextCategory":"ContentSafety.TextCategory"},"generatedFiles":["src/main/java/com/azure/ai/contentsafety/BlocklistAsyncClient.java","src/main/java/com/azure/ai/contentsafety/BlocklistClient.java","src/main/java/com/azure/ai/contentsafety/BlocklistClientBuilder.java","src/main/java/com/azure/ai/contentsafety/ContentProvenanceAsyncClient.java","src/main/java/com/azure/ai/contentsafety/ContentProvenanceClient.java","src/main/java/com/azure/ai/contentsafety/ContentProvenanceClientBuilder.java","src/main/java/com/azure/ai/contentsafety/ContentSafetyAsyncClient.java","src/main/java/com/azure/ai/contentsafety/ContentSafetyClient.java","src/main/java/com/azure/ai/contentsafety/ContentSafetyClientBuilder.java","src/main/java/com/azure/ai/contentsafety/ContentSafetyServiceVersion.java","src/main/java/com/azure/ai/contentsafety/ContentSafetyServiceVersion.java","src/main/java/com/azure/ai/contentsafety/ContentSafetyServiceVersion.java","src/main/java/com/azure/ai/contentsafety/implementation/BlocklistClientImpl.java","src/main/java/com/azure/ai/contentsafety/implementation/ContentProvenanceClientImpl.java","src/main/java/com/azure/ai/contentsafety/implementation/ContentSafetyClientImpl.java","src/main/java/com/azure/ai/contentsafety/implementation/JsonMergePatchHelper.java","src/main/java/com/azure/ai/contentsafety/implementation/OperationLocationPollingStrategy.java","src/main/java/com/azure/ai/contentsafety/implementation/PollingUtils.java","src/main/java/com/azure/ai/contentsafety/implementation/SyncOperationLocationPollingStrategy.java","src/main/java/com/azure/ai/contentsafety/implementation/package-info.java","src/main/java/com/azure/ai/contentsafety/models/AddOrUpdateTextBlocklistItemsOptions.java","src/main/java/com/azure/ai/contentsafety/models/AddOrUpdateTextBlocklistItemsResult.java","src/main/java/com/azure/ai/contentsafety/models/AnalyzeImageOptions.java","src/main/java/com/azure/ai/contentsafety/models/AnalyzeImageOutputType.java","src/main/java/com/azure/ai/contentsafety/models/AnalyzeImageResult.java","src/main/java/com/azure/ai/contentsafety/models/AnalyzeTextOptions.java","src/main/java/com/azure/ai/contentsafety/models/AnalyzeTextOutputType.java","src/main/java/com/azure/ai/contentsafety/models/AnalyzeTextResult.java","src/main/java/com/azure/ai/contentsafety/models/ContentSafetyImageData.java","src/main/java/com/azure/ai/contentsafety/models/DetectOutcome.java","src/main/java/com/azure/ai/contentsafety/models/DetectProvenanceOptions.java","src/main/java/com/azure/ai/contentsafety/models/DetectProvenanceResult.java","src/main/java/com/azure/ai/contentsafety/models/DetectedProvenance.java","src/main/java/com/azure/ai/contentsafety/models/DetectedProvenanceType.java","src/main/java/com/azure/ai/contentsafety/models/ImageCategoriesAnalysis.java","src/main/java/com/azure/ai/contentsafety/models/ImageCategory.java","src/main/java/com/azure/ai/contentsafety/models/OperationState.java","src/main/java/com/azure/ai/contentsafety/models/ProvenanceContent.java","src/main/java/com/azure/ai/contentsafety/models/ProvenanceDetectOperation.java","src/main/java/com/azure/ai/contentsafety/models/ProvenanceOperationKind.java","src/main/java/com/azure/ai/contentsafety/models/RemoveTextBlocklistItemsOptions.java","src/main/java/com/azure/ai/contentsafety/models/TextBlocklist.java","src/main/java/com/azure/ai/contentsafety/models/TextBlocklistItem.java","src/main/java/com/azure/ai/contentsafety/models/TextBlocklistMatch.java","src/main/java/com/azure/ai/contentsafety/models/TextCategoriesAnalysis.java","src/main/java/com/azure/ai/contentsafety/models/TextCategory.java","src/main/java/com/azure/ai/contentsafety/models/package-info.java","src/main/java/com/azure/ai/contentsafety/package-info.java","src/main/java/module-info.java"]} \ No newline at end of file diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/AddOrUpdateBlocklistItemsToTextBlocklist.java b/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/AddOrUpdateBlocklistItemsToTextBlocklist.java new file mode 100644 index 000000000000..76634aae6286 --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/AddOrUpdateBlocklistItemsToTextBlocklist.java @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.contentsafety.generated; + +import com.azure.ai.contentsafety.BlocklistClient; +import com.azure.ai.contentsafety.BlocklistClientBuilder; +import com.azure.ai.contentsafety.models.AddOrUpdateTextBlocklistItemsOptions; +import com.azure.ai.contentsafety.models.AddOrUpdateTextBlocklistItemsResult; +import com.azure.ai.contentsafety.models.TextBlocklistItem; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.util.Arrays; + +public class AddOrUpdateBlocklistItemsToTextBlocklist { + public static void main(String[] args) { + BlocklistClient blocklistClient + = new BlocklistClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildClient(); + // BEGIN:com.azure.ai.contentsafety.generated.add-or-update-blocklist-items.add-or-update-blocklist-items-to-text-blocklist + AddOrUpdateTextBlocklistItemsResult response + = blocklistClient.addOrUpdateBlocklistItems("TestBlocklist", new AddOrUpdateTextBlocklistItemsOptions( + Arrays.asList(new TextBlocklistItem("hate").setDescription("Hate word")))); + // END:com.azure.ai.contentsafety.generated.add-or-update-blocklist-items.add-or-update-blocklist-items-to-text-blocklist + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/AnalyzeImage.java b/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/AnalyzeImage.java new file mode 100644 index 000000000000..63e96689a030 --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/AnalyzeImage.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.contentsafety.generated; + +import com.azure.ai.contentsafety.ContentSafetyClient; +import com.azure.ai.contentsafety.ContentSafetyClientBuilder; +import com.azure.ai.contentsafety.models.AnalyzeImageOptions; +import com.azure.ai.contentsafety.models.AnalyzeImageResult; +import com.azure.ai.contentsafety.models.ContentSafetyImageData; +import com.azure.core.util.Configuration; +import com.azure.core.util.BinaryData; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class AnalyzeImage { + public static void main(String[] args) { + ContentSafetyClient contentSafetyClient + = new ContentSafetyClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildClient(); + // BEGIN:com.azure.ai.contentsafety.generated.analyze-image.analyze-image + AnalyzeImageResult response = contentSafetyClient + .analyzeImage(new AnalyzeImageOptions(new ContentSafetyImageData().setContent(BinaryData.fromBytes("Y29udGVudDE=".getBytes())))); + // END:com.azure.ai.contentsafety.generated.analyze-image.analyze-image + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/AnalyzeText.java b/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/AnalyzeText.java new file mode 100644 index 000000000000..91b9a02d14fe --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/AnalyzeText.java @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.contentsafety.generated; + +import com.azure.ai.contentsafety.ContentSafetyClient; +import com.azure.ai.contentsafety.ContentSafetyClientBuilder; +import com.azure.ai.contentsafety.models.AnalyzeTextOptions; +import com.azure.ai.contentsafety.models.AnalyzeTextResult; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class AnalyzeText { + public static void main(String[] args) { + ContentSafetyClient contentSafetyClient + = new ContentSafetyClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildClient(); + // BEGIN:com.azure.ai.contentsafety.generated.analyze-text.analyze-text + AnalyzeTextResult response = contentSafetyClient.analyzeText(new AnalyzeTextOptions("This is text example")); + // END:com.azure.ai.contentsafety.generated.analyze-text.analyze-text + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/CreateOrUpdateTextBlocklist.java b/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/CreateOrUpdateTextBlocklist.java new file mode 100644 index 000000000000..c33d4e2fcdce --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/CreateOrUpdateTextBlocklist.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.contentsafety.generated; + +import com.azure.ai.contentsafety.BlocklistClient; +import com.azure.ai.contentsafety.BlocklistClientBuilder; +import com.azure.ai.contentsafety.models.TextBlocklist; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class CreateOrUpdateTextBlocklist { + public static void main(String[] args) { + BlocklistClient blocklistClient + = new BlocklistClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildClient(); + // BEGIN:com.azure.ai.contentsafety.generated.create-or-update-text-blocklist.create-or-update-text-blocklist + TextBlocklist response = blocklistClient.createOrUpdateTextBlocklist("TestBlocklist", null); + // END:com.azure.ai.contentsafety.generated.create-or-update-text-blocklist.create-or-update-text-blocklist + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/DeleteTextBlocklistByBlocklistName.java b/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/DeleteTextBlocklistByBlocklistName.java new file mode 100644 index 000000000000..56846269e3b0 --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/DeleteTextBlocklistByBlocklistName.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.contentsafety.generated; + +import com.azure.ai.contentsafety.BlocklistClient; +import com.azure.ai.contentsafety.BlocklistClientBuilder; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class DeleteTextBlocklistByBlocklistName { + public static void main(String[] args) { + BlocklistClient blocklistClient + = new BlocklistClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildClient(); + // BEGIN:com.azure.ai.contentsafety.generated.delete-text-blocklist.delete-text-blocklist-by-blocklist-name + blocklistClient.deleteTextBlocklist("TestBlocklist"); + // END:com.azure.ai.contentsafety.generated.delete-text-blocklist.delete-text-blocklist-by-blocklist-name + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/GetAllBlockItemsByBlocklistName.java b/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/GetAllBlockItemsByBlocklistName.java new file mode 100644 index 000000000000..4f23a6e09f93 --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/GetAllBlockItemsByBlocklistName.java @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.contentsafety.generated; + +import com.azure.ai.contentsafety.BlocklistClient; +import com.azure.ai.contentsafety.BlocklistClientBuilder; +import com.azure.ai.contentsafety.models.TextBlocklistItem; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class GetAllBlockItemsByBlocklistName { + public static void main(String[] args) { + BlocklistClient blocklistClient + = new BlocklistClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildClient(); + // BEGIN:com.azure.ai.contentsafety.generated.list-text-blocklist-items.get-all-block-items-by-blocklist-name + PagedIterable response = blocklistClient.listTextBlocklistItems("TestBlocklist", null, null); + // END:com.azure.ai.contentsafety.generated.list-text-blocklist-items.get-all-block-items-by-blocklist-name + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/GetAllTextBlocklists.java b/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/GetAllTextBlocklists.java new file mode 100644 index 000000000000..aadefe9e1c85 --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/GetAllTextBlocklists.java @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.contentsafety.generated; + +import com.azure.ai.contentsafety.BlocklistClient; +import com.azure.ai.contentsafety.BlocklistClientBuilder; +import com.azure.ai.contentsafety.models.TextBlocklist; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class GetAllTextBlocklists { + public static void main(String[] args) { + BlocklistClient blocklistClient + = new BlocklistClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildClient(); + // BEGIN:com.azure.ai.contentsafety.generated.list-text-blocklists.get-all-text-blocklists + PagedIterable response = blocklistClient.listTextBlocklists(); + // END:com.azure.ai.contentsafety.generated.list-text-blocklists.get-all-text-blocklists + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/GetBlockItemByBlocklistNameAndBlocklistItemId.java b/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/GetBlockItemByBlocklistNameAndBlocklistItemId.java new file mode 100644 index 000000000000..73db038fa83e --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/GetBlockItemByBlocklistNameAndBlocklistItemId.java @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.contentsafety.generated; + +import com.azure.ai.contentsafety.BlocklistClient; +import com.azure.ai.contentsafety.BlocklistClientBuilder; +import com.azure.ai.contentsafety.models.TextBlocklistItem; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class GetBlockItemByBlocklistNameAndBlocklistItemId { + public static void main(String[] args) { + BlocklistClient blocklistClient + = new BlocklistClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildClient(); + // BEGIN:com.azure.ai.contentsafety.generated.get-text-blocklist-item.get-block-item-by-blocklist-name-and-blocklist-item-id + TextBlocklistItem response + = blocklistClient.getTextBlocklistItem("TestBlocklist", "9511969e-f1e3-4604-9127-05ee16c509ec"); + // END:com.azure.ai.contentsafety.generated.get-text-blocklist-item.get-block-item-by-blocklist-name-and-blocklist-item-id + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/GetTextBlocklistByBlocklistName.java b/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/GetTextBlocklistByBlocklistName.java new file mode 100644 index 000000000000..d8cf1014aeea --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/GetTextBlocklistByBlocklistName.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.contentsafety.generated; + +import com.azure.ai.contentsafety.BlocklistClient; +import com.azure.ai.contentsafety.BlocklistClientBuilder; +import com.azure.ai.contentsafety.models.TextBlocklist; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class GetTextBlocklistByBlocklistName { + public static void main(String[] args) { + BlocklistClient blocklistClient + = new BlocklistClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildClient(); + // BEGIN:com.azure.ai.contentsafety.generated.get-text-blocklist.get-text-blocklist-by-blocklist-name + TextBlocklist response = blocklistClient.getTextBlocklist("TestBlocklist"); + // END:com.azure.ai.contentsafety.generated.get-text-blocklist.get-text-blocklist-by-blocklist-name + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/RemoveBlockItemsFromTextBlocklist.java b/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/RemoveBlockItemsFromTextBlocklist.java new file mode 100644 index 000000000000..45134c340cf0 --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/samples/java/com/azure/ai/contentsafety/generated/RemoveBlockItemsFromTextBlocklist.java @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.contentsafety.generated; + +import com.azure.ai.contentsafety.BlocklistClient; +import com.azure.ai.contentsafety.BlocklistClientBuilder; +import com.azure.ai.contentsafety.models.RemoveTextBlocklistItemsOptions; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.util.Arrays; + +public class RemoveBlockItemsFromTextBlocklist { + public static void main(String[] args) { + BlocklistClient blocklistClient + = new BlocklistClientBuilder().credential(new DefaultAzureCredentialBuilder().build()) + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildClient(); + // BEGIN:com.azure.ai.contentsafety.generated.remove-blocklist-items.remove-block-items-from-text-blocklist + blocklistClient.removeBlocklistItems("TestBlocklist", + new RemoveTextBlocklistItemsOptions(Arrays.asList("9511969e-f1e3-4604-9127-05ee16c509ec"))); + // END:com.azure.ai.contentsafety.generated.remove-blocklist-items.remove-block-items-from-text-blocklist + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/AddOrUpdateBlocklistItemsToTextBlocklistTests.java b/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/AddOrUpdateBlocklistItemsToTextBlocklistTests.java new file mode 100644 index 000000000000..fd0c7af81753 --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/AddOrUpdateBlocklistItemsToTextBlocklistTests.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.contentsafety.generated; + +import com.azure.ai.contentsafety.models.AddOrUpdateTextBlocklistItemsOptions; +import com.azure.ai.contentsafety.models.AddOrUpdateTextBlocklistItemsResult; +import com.azure.ai.contentsafety.models.TextBlocklistItem; +import java.util.Arrays; +import java.util.List; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class AddOrUpdateBlocklistItemsToTextBlocklistTests extends ContentSafetyClientTestBase { + @Test + @Disabled + public void testAddOrUpdateBlocklistItemsToTextBlocklistTests() { + // method invocation + AddOrUpdateTextBlocklistItemsResult response + = blocklistClient.addOrUpdateBlocklistItems("TestBlocklist", new AddOrUpdateTextBlocklistItemsOptions( + Arrays.asList(new TextBlocklistItem("hate").setDescription("Hate word")))); + + // response assertion + Assertions.assertNotNull(response); + // verify property "blocklistItems" + List responseBlocklistItems = response.getBlocklistItems(); + TextBlocklistItem responseBlocklistItemsFirstItem = responseBlocklistItems.iterator().next(); + Assertions.assertNotNull(responseBlocklistItemsFirstItem); + Assertions.assertEquals("9511969e-f1e3-4604-9127-05ee16c509ec", + responseBlocklistItemsFirstItem.getBlocklistItemId()); + Assertions.assertEquals("Hate word", responseBlocklistItemsFirstItem.getDescription()); + Assertions.assertEquals("hate", responseBlocklistItemsFirstItem.getText()); + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/AnalyzeImageTests.java b/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/AnalyzeImageTests.java new file mode 100644 index 000000000000..6071210d2971 --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/AnalyzeImageTests.java @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.contentsafety.generated; + +import com.azure.core.util.BinaryData; +import com.azure.ai.contentsafety.models.AnalyzeImageOptions; +import com.azure.ai.contentsafety.models.AnalyzeImageResult; +import com.azure.ai.contentsafety.models.ContentSafetyImageData; +import com.azure.ai.contentsafety.models.ImageCategoriesAnalysis; +import com.azure.ai.contentsafety.models.ImageCategory; +import java.util.List; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class AnalyzeImageTests extends ContentSafetyClientTestBase { + @Test + @Disabled + public void testAnalyzeImageTests() { + // method invocation + AnalyzeImageResult response = contentSafetyClient.analyzeImage(new AnalyzeImageOptions( + new ContentSafetyImageData().setContent(BinaryData.fromBytes("Y29udGVudDE=".getBytes())))); + + // response assertion + Assertions.assertNotNull(response); + // verify property "categoriesAnalysis" + List responseCategoriesAnalysis = response.getCategoriesAnalysis(); + ImageCategoriesAnalysis responseCategoriesAnalysisFirstItem = responseCategoriesAnalysis.iterator().next(); + Assertions.assertNotNull(responseCategoriesAnalysisFirstItem); + Assertions.assertEquals(ImageCategory.HATE, responseCategoriesAnalysisFirstItem.getCategory()); + Assertions.assertEquals(0, responseCategoriesAnalysisFirstItem.getSeverity()); + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/AnalyzeTextTests.java b/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/AnalyzeTextTests.java new file mode 100644 index 000000000000..1337f14af98c --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/AnalyzeTextTests.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.contentsafety.generated; + +import com.azure.ai.contentsafety.models.AnalyzeTextOptions; +import com.azure.ai.contentsafety.models.AnalyzeTextResult; +import com.azure.ai.contentsafety.models.TextBlocklistMatch; +import com.azure.ai.contentsafety.models.TextCategoriesAnalysis; +import com.azure.ai.contentsafety.models.TextCategory; +import java.util.List; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class AnalyzeTextTests extends ContentSafetyClientTestBase { + @Test + @Disabled + public void testAnalyzeTextTests() { + // method invocation + AnalyzeTextResult response = contentSafetyClient.analyzeText(new AnalyzeTextOptions("This is text example")); + + // response assertion + Assertions.assertNotNull(response); + // verify property "blocklistsMatch" + List responseBlocklistsMatch = response.getBlocklistsMatch(); + Assertions.assertEquals(0, responseBlocklistsMatch.size()); + // verify property "categoriesAnalysis" + List responseCategoriesAnalysis = response.getCategoriesAnalysis(); + TextCategoriesAnalysis responseCategoriesAnalysisFirstItem = responseCategoriesAnalysis.iterator().next(); + Assertions.assertNotNull(responseCategoriesAnalysisFirstItem); + Assertions.assertEquals(TextCategory.HATE, responseCategoriesAnalysisFirstItem.getCategory()); + Assertions.assertEquals(0, responseCategoriesAnalysisFirstItem.getSeverity()); + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/ContentSafetyClientTestBase.java b/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/ContentSafetyClientTestBase.java new file mode 100644 index 000000000000..df9a7224e2ee --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/ContentSafetyClientTestBase.java @@ -0,0 +1,77 @@ +// 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.ContentProvenanceClient; +import com.azure.ai.contentsafety.ContentProvenanceClientBuilder; +import com.azure.ai.contentsafety.ContentSafetyClient; +import com.azure.ai.contentsafety.ContentSafetyClientBuilder; +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.test.utils.MockTokenCredential; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; + +class ContentSafetyClientTestBase extends TestProxyTestBase { + protected ContentSafetyClient contentSafetyClient; + + protected ContentProvenanceClient contentProvenanceClient; + + protected BlocklistClient blocklistClient; + + @Override + protected void beforeTest() { + ContentSafetyClientBuilder contentSafetyClientbuilder = new ContentSafetyClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + contentSafetyClientbuilder.credential(new MockTokenCredential()); + } 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(); + + ContentProvenanceClientBuilder contentProvenanceClientbuilder = new ContentProvenanceClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + contentProvenanceClientbuilder.credential(new MockTokenCredential()); + } else if (getTestMode() == TestMode.RECORD) { + contentProvenanceClientbuilder.addPolicy(interceptorManager.getRecordPolicy()) + .credential(new DefaultAzureCredentialBuilder().build()); + } else if (getTestMode() == TestMode.LIVE) { + contentProvenanceClientbuilder.credential(new DefaultAzureCredentialBuilder().build()); + } + contentProvenanceClient = contentProvenanceClientbuilder.buildClient(); + + BlocklistClientBuilder blocklistClientbuilder + = new BlocklistClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + blocklistClientbuilder.credential(new MockTokenCredential()); + } else if (getTestMode() == TestMode.RECORD) { + blocklistClientbuilder.addPolicy(interceptorManager.getRecordPolicy()) + .credential(new DefaultAzureCredentialBuilder().build()); + } else if (getTestMode() == TestMode.LIVE) { + blocklistClientbuilder.credential(new DefaultAzureCredentialBuilder().build()); + } + blocklistClient = blocklistClientbuilder.buildClient(); + + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/CreateOrUpdateTextBlocklistTests.java b/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/CreateOrUpdateTextBlocklistTests.java new file mode 100644 index 000000000000..ca15af68345b --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/CreateOrUpdateTextBlocklistTests.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.contentsafety.generated; + +import com.azure.ai.contentsafety.models.TextBlocklist; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class CreateOrUpdateTextBlocklistTests extends ContentSafetyClientTestBase { + @Test + @Disabled + public void testCreateOrUpdateTextBlocklistTests() { + // method invocation + TextBlocklist response = blocklistClient.createOrUpdateTextBlocklist("TestBlocklist", null); + + // response assertion + Assertions.assertNotNull(response); + // verify property "name" + Assertions.assertEquals("TestBlocklist", response.getName()); + // verify property "description" + Assertions.assertEquals("Test Blocklist", response.getDescription()); + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/DeleteTextBlocklistByBlocklistNameTests.java b/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/DeleteTextBlocklistByBlocklistNameTests.java new file mode 100644 index 000000000000..715435bc0e75 --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/DeleteTextBlocklistByBlocklistNameTests.java @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.contentsafety.generated; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class DeleteTextBlocklistByBlocklistNameTests extends ContentSafetyClientTestBase { + @Test + @Disabled + public void testDeleteTextBlocklistByBlocklistNameTests() { + // method invocation + blocklistClient.deleteTextBlocklist("TestBlocklist"); + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/GetAllBlockItemsByBlocklistNameTests.java b/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/GetAllBlockItemsByBlocklistNameTests.java new file mode 100644 index 000000000000..9203586bee92 --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/GetAllBlockItemsByBlocklistNameTests.java @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.contentsafety.generated; + +import com.azure.ai.contentsafety.models.TextBlocklistItem; +import com.azure.core.http.rest.PagedIterable; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class GetAllBlockItemsByBlocklistNameTests extends ContentSafetyClientTestBase { + @Test + @Disabled + public void testGetAllBlockItemsByBlocklistNameTests() { + // method invocation + PagedIterable response = blocklistClient.listTextBlocklistItems("TestBlocklist", null, null); + + // response assertion + Assertions.assertEquals(200, response.iterableByPage().iterator().next().getStatusCode()); + TextBlocklistItem firstItem = response.iterator().next(); + Assertions.assertNotNull(firstItem); + // verify property "blocklistItemId" + Assertions.assertEquals("9511969e-f1e3-4604-9127-05ee16c509ec", firstItem.getBlocklistItemId()); + // verify property "description" + Assertions.assertEquals("Hate word", firstItem.getDescription()); + // verify property "text" + Assertions.assertEquals("hate", firstItem.getText()); + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/GetAllTextBlocklistsTests.java b/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/GetAllTextBlocklistsTests.java new file mode 100644 index 000000000000..6a4fe707d129 --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/GetAllTextBlocklistsTests.java @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.contentsafety.generated; + +import com.azure.ai.contentsafety.models.TextBlocklist; +import com.azure.core.http.rest.PagedIterable; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class GetAllTextBlocklistsTests extends ContentSafetyClientTestBase { + @Test + @Disabled + public void testGetAllTextBlocklistsTests() { + // method invocation + PagedIterable response = blocklistClient.listTextBlocklists(); + + // response assertion + Assertions.assertEquals(200, response.iterableByPage().iterator().next().getStatusCode()); + TextBlocklist firstItem = response.iterator().next(); + Assertions.assertNotNull(firstItem); + // verify property "name" + Assertions.assertEquals("TestBlocklist", firstItem.getName()); + // verify property "description" + Assertions.assertEquals("Test Blocklist", firstItem.getDescription()); + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/GetBlockItemByBlocklistNameAndBlocklistItemIdTests.java b/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/GetBlockItemByBlocklistNameAndBlocklistItemIdTests.java new file mode 100644 index 000000000000..9b2dc1496378 --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/GetBlockItemByBlocklistNameAndBlocklistItemIdTests.java @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.contentsafety.generated; + +import com.azure.ai.contentsafety.models.TextBlocklistItem; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class GetBlockItemByBlocklistNameAndBlocklistItemIdTests extends ContentSafetyClientTestBase { + @Test + @Disabled + public void testGetBlockItemByBlocklistNameAndBlocklistItemIdTests() { + // method invocation + TextBlocklistItem response + = blocklistClient.getTextBlocklistItem("TestBlocklist", "9511969e-f1e3-4604-9127-05ee16c509ec"); + + // response assertion + Assertions.assertNotNull(response); + // verify property "blocklistItemId" + Assertions.assertEquals("9511969e-f1e3-4604-9127-05ee16c509ec", response.getBlocklistItemId()); + // verify property "description" + Assertions.assertEquals("Hate word", response.getDescription()); + // verify property "text" + Assertions.assertEquals("hate", response.getText()); + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/GetTextBlocklistByBlocklistNameTests.java b/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/GetTextBlocklistByBlocklistNameTests.java new file mode 100644 index 000000000000..e1d67c5d9515 --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/GetTextBlocklistByBlocklistNameTests.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.contentsafety.generated; + +import com.azure.ai.contentsafety.models.TextBlocklist; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class GetTextBlocklistByBlocklistNameTests extends ContentSafetyClientTestBase { + @Test + @Disabled + public void testGetTextBlocklistByBlocklistNameTests() { + // method invocation + TextBlocklist response = blocklistClient.getTextBlocklist("TestBlocklist"); + + // response assertion + Assertions.assertNotNull(response); + // verify property "name" + Assertions.assertEquals("TestBlocklist", response.getName()); + // verify property "description" + Assertions.assertEquals("Test Blocklist", response.getDescription()); + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/RemoveBlockItemsFromTextBlocklistTests.java b/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/RemoveBlockItemsFromTextBlocklistTests.java new file mode 100644 index 000000000000..d639989619bb --- /dev/null +++ b/sdk/contentsafety/azure-ai-contentsafety/src/test/java/com/azure/ai/contentsafety/generated/RemoveBlockItemsFromTextBlocklistTests.java @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.contentsafety.generated; + +import com.azure.ai.contentsafety.models.RemoveTextBlocklistItemsOptions; +import java.util.Arrays; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class RemoveBlockItemsFromTextBlocklistTests extends ContentSafetyClientTestBase { + @Test + @Disabled + public void testRemoveBlockItemsFromTextBlocklistTests() { + // method invocation + blocklistClient.removeBlocklistItems("TestBlocklist", + new RemoveTextBlocklistItemsOptions(Arrays.asList("9511969e-f1e3-4604-9127-05ee16c509ec"))); + } +} diff --git a/sdk/contentsafety/azure-ai-contentsafety/tsp-location.yaml b/sdk/contentsafety/azure-ai-contentsafety/tsp-location.yaml index 37865dad0bd4..d092da2dadae 100644 --- a/sdk/contentsafety/azure-ai-contentsafety/tsp-location.yaml +++ b/sdk/contentsafety/azure-ai-contentsafety/tsp-location.yaml @@ -1,4 +1,4 @@ directory: specification/cognitiveservices/ContentSafety -commit: 6267b64842af3d744c5b092a3f3beef49729ad6d -additionalDirectories: [] +commit: 926fc28f53c318fe3cf68eb8be1ea38e658c0879 repo: Azure/azure-rest-api-specs +additionalDirectories: