diff --git a/specification/cognitiveservices/ContentSafety/models.tsp b/specification/cognitiveservices/ContentSafety/models.tsp index b77017314c13..dfe70b289456 100644 --- a/specification/cognitiveservices/ContentSafety/models.tsp +++ b/specification/cognitiveservices/ContentSafety/models.tsp @@ -40,6 +40,32 @@ enum AnalyzeImageOutputType { FourSeverityLevels, } +@added(ContentSafety.Versions.v2024_01_30_Preview) +@doc("The type of batch results storage mode.") +enum BatchResultsStorageMode { + @doc("Merge each result into one file.") + CollectiveResultFile, + + @doc("Store each result in a single file.") + IndividualResultFiles, +} + +@added(ContentSafety.Versions.v2024_01_30_Preview) +@doc("The type of batch analysis task status.") +enum BatchTaskStatus { + @doc("The task has not started yet.") + NotStarted, + + @doc("The task is in progress.") + Running, + + @doc("The task has failed.") + Failed, + + @doc("The task has been succeeded.") + Succeeded, +} + @added(ContentSafety.Versions.v2024_01_30_Preview) enum ModelStatus { created, @@ -213,6 +239,51 @@ model ImageCategoriesAnalysis { severity?: int32; } +@added(ContentSafety.Versions.v2024_01_30_Preview) +@doc("The image batch analysis request.") +model BatchAnalyzeImagesOptions { + @doc("The URL of the Azure Storage Blob containing all the images to be analyzed in the batch task.") + imagesBlobFolderUrl: url; + + @doc("The URL of the Azure Storage Blob where the batch task results will be written.") + analysisResultsBlobFolderUrl: url; + + @doc("The storage mode for the batch task results, either 'CollectiveResultFile' or 'IndividualResultFiles'.") + resultsStorageMode?: BatchResultsStorageMode = BatchResultsStorageMode.CollectiveResultFile; + + @doc("The categories will be analyzed. If they are not assigned, a default set of analysis results for the categories will be returned.") + categories?: ImageCategory[]; + + @doc("This refers to the type of image analysis output. If no value is assigned, the default value will be \"FourSeverityLevels\".") + outputType?: AnalyzeImageOutputType = AnalyzeImageOutputType.FourSeverityLevels; + + @doc("The incidents to detect.") + incidents?: IncidentOptions; +} + +@added(ContentSafety.Versions.v2024_01_30_Preview) +@doc("Image batch analyze task.") +@resource("image/batchAnalyzeTasks") +model ImageBatchTaskDetail { + @doc("The id of image batch analysis task.") + @key("taskId") + @visibility("read") + @maxLength(64) + taskId: string; + + @doc("The status of the batch image analysis task.") + status: BatchTaskStatus; + + @doc("The progress of the batch image analysis task, represented as a percentage (0-100).") + progressPercentage: float64; + + @doc("The timestamp of when batch image analysis task was created.") + taskCreatedTime: utcDateTime; + + @doc("Return error detail when the task failed.") + error?: Azure.Core.Foundations.Error; +} + @doc("Text Blocklist.") @resource("text/blocklists") model TextBlocklist { diff --git a/specification/cognitiveservices/ContentSafety/routes.tsp b/specification/cognitiveservices/ContentSafety/routes.tsp index 16b36381a21a..4e222d6359e9 100644 --- a/specification/cognitiveservices/ContentSafety/routes.tsp +++ b/specification/cognitiveservices/ContentSafety/routes.tsp @@ -81,6 +81,41 @@ interface ImageOperations { >; } +interface ImageBatchOperations { + @added(ContentSafety.Versions.v2024_01_30_Preview) + @summary("Start Batch Analyze Images") + @doc("An asynchronous API for the batch analysis of potentially harmful image content. Currently, it supports four categories: Hate, SelfHarm, Sexual, and Violence.") + @route("/image:batchAnalyze") + batchAnalyzeImage is ImageLongRunningRpcOperation< + { + @body + @doc("The image batch analysis request.") + body: BatchAnalyzeImagesOptions; + }, + ImageBatchTaskDetail + >; + + @added(ContentSafety.Versions.v2024_01_30_Preview) + @summary("Get Batch Analyze Status") + @doc("Check the status of a batch image analysis task.") + getBatchTaskStatus is Azure.Core.ResourceRead; +} + +@doc("Long running RPC operation template") +op ImageLongRunningRpcOperation< + TParams extends TypeSpec.Reflection.Model, + TResponse extends TypeSpec.Reflection.Model +> is Azure.Core.Foundations.Operation< + TParams, + Azure.Core.Foundations.AcceptedResponse & TResponse, + Azure.Core.Foundations.ErrorResponse +>; + +interface BatchOps + extends Azure.Core.ResourceOperations {} + interface BlockOps extends Azure.Core.ResourceOperations