Skip to content

Commit

Permalink
[Cognitive Services - Azure AI Content Safety] Address comments of sd…
Browse files Browse the repository at this point in the history
…k languages on GA (Azure#26353)

* Split the client and rename the variables.

* Update JS package-dir config in tspconfig (Azure#26)

* Add projected name.

* add doc.

* add body annotation.

* add

* add projected name.

* update

* Add projected name for python.

* rename to options.

* rename for java

* update

* update

* update files (Azure#35)

* update

* update

---------

Co-authored-by: MinjueWu <597922968@qq.com>
Co-authored-by: zhaiyutong <mo.huainian@163.com>
Co-authored-by: YUTONG_ZHAI <32332316+zhaiyutong@users.noreply.github.com>
Co-authored-by: Yutong Zhai <yutongzhai@microsoft.com>
  • Loading branch information
5 people authored Nov 21, 2023
1 parent 4428e09 commit 164375e
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 3 deletions.
32 changes: 32 additions & 0 deletions specification/cognitiveservices/ContentSafety/client.tsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import "@azure-tools/typespec-client-generator-core";
import "./main.tsp";

using Azure.ClientGenerator.Core;

@TypeSpec.Versioning.useDependency(Azure.Core.Versions.v1_0_Preview_2)
@TypeSpec.Versioning.useDependency(ContentSafety.Versions.v2023_10_01)
namespace Customizations;

@client({
name: "ContentSafetyClient",
service: ContentSafety,
})
interface ContentSafetyClient {
analyzeText is ContentSafety.TextOperations.analyzeText;
analyzeImage is ContentSafety.ImageOperations.analyzeImage;
}

@client({
name: "BlocklistClient",
service: ContentSafety,
})
interface BlocklistClient {
addOrUpdateBlocklistItems is ContentSafety.TextBlocklists.addOrUpdateBlocklistItems;
createOrUpdateTextBlocklist is ContentSafety.TextBlocklists.createOrUpdateTextBlocklist;
deleteTextBlocklist is ContentSafety.TextBlocklists.deleteTextBlocklist;
getTextBlocklist is ContentSafety.TextBlocklists.getTextBlocklist;
getTextBlocklistItem is ContentSafety.TextBlocklists.getTextBlocklistItem;
listTextBlocklistItems is ContentSafety.TextBlocklists.listTextBlocklistItems;
listTextBlocklists is ContentSafety.TextBlocklists.listTextBlocklists;
removeBlocklistItems is ContentSafety.TextBlocklists.removeBlocklistItems;
}
4 changes: 4 additions & 0 deletions specification/cognitiveservices/ContentSafety/models.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,13 @@ model AnalyzeImageOptions {

@doc("The image can be either base64 encoded bytes or a blob URL. You can choose only one of these options. If both are provided, the request will be refused. The maximum image size is 2048 x 2048 pixels and should not exceed 4 MB, while the minimum image size is 50 x 50 pixels.")
@projectedName("csharp", "ContentSafetyImageData")
@projectedName("java", "ContentSafetyImageData")
model ImageData {
@doc("The Base64 encoding of the image.")
content?: bytes;

@doc("The blob url of the image.")
@projectedName("csharp", "BlobUri")
blobUrl?: url;
}

Expand All @@ -137,6 +139,8 @@ model TextBlocklist {
@key("blocklistName")
@visibility("read", "create", "query")
@maxLength(64)
@projectedName("csharp", "Name")
@projectedName("java", "name")
blocklistName: string;

@doc("Text blocklist description.")
Expand Down
29 changes: 27 additions & 2 deletions specification/cognitiveservices/ContentSafety/routes.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ interface TextOperations {
{
@body
@doc("The text analysis request.")
@projectedName("csharp", "options")
@projectedName("python", "options")
@projectedName("java", "options")
body: AnalyzeTextOptions;
},
AnalyzeTextResult
Expand All @@ -35,6 +38,9 @@ interface ImageOperations {
{
@doc("The image analysis request.")
@body
@projectedName("csharp", "options")
@projectedName("python", "options")
@projectedName("java", "options")
body: AnalyzeImageOptions;
},
AnalyzeImageResult
Expand All @@ -46,6 +52,11 @@ interface BlockOps
NoConditionalRequests &
NoClientRequestId> {}

@@projectedName(Azure.Core.Foundations.ResourceBody.resource,
"client",
"options"
);

interface TextBlocklists {
@summary("Get Text Blocklist By blocklistName")
@doc("Returns text blocklist details.")
Expand All @@ -67,15 +78,29 @@ interface TextBlocklists {
@doc("Add or update blocklistItems to a text blocklist. You can add or update at most 100 blocklistItems in one request.")
addOrUpdateBlocklistItems is BlockOps.ResourceAction<
TextBlocklist,
AddOrUpdateTextBlocklistItemsOptions,
{
@doc("Options for adding or updating blocklist items.")
@body
@projectedName("csharp", "options")
@projectedName("python", "options")
@projectedName("java", "options")
body: AddOrUpdateTextBlocklistItemsOptions;
},
AddOrUpdateTextBlocklistItemsResult
>;

@summary("Remove BlocklistItems From Text Blocklist")
@doc("Remove blocklistItems from a text blocklist. You can remove at most 100 BlocklistItems in one request.")
removeBlocklistItems is BlockOps.ResourceAction<
TextBlocklist,
RemoveTextBlocklistItemsOptions,
{
@doc("Options for removing blocklist items.")
@body
@projectedName("csharp", "options")
@projectedName("python", "options")
@projectedName("java", "options")
body: RemoveTextBlocklistItemsOptions;
},
NoContentResponse
>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ options:
clear-output-folder: true
model-namespace: false
"@azure-tools/typespec-ts":
package-dir: "azure-ai-content-safety-rest"
package-dir: "ai-content-safety-rest"
packageDetails:
name: "@azure-rest/ai-content-safety"
version: "1.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@
{
"name": "body",
"in": "body",
"description": "Options for adding or updating blocklist items.",
"required": true,
"schema": {
"$ref": "#/definitions/AddOrUpdateTextBlocklistItemsOptions"
Expand Down Expand Up @@ -369,6 +370,7 @@
{
"name": "body",
"in": "body",
"description": "Options for removing blocklist items.",
"required": true,
"schema": {
"$ref": "#/definitions/RemoveTextBlocklistItemsOptions"
Expand Down

0 comments on commit 164375e

Please sign in to comment.