Skip to content

Commit

Permalink
Document translation of text within an image (#31384)
Browse files Browse the repository at this point in the history
* Adding support for new apiversion that includes translation of image within document translation

* Fixing json formatting

* Fixing formatting issues again

* Fixing TypeSpec validation error

* Updating Readme with the new version

* Fixing the release tag

* Anothe tag fix

* Fixing formatting on client.tsp

* Updating property names

* Updating SDT response property name; removing x-

* Changing the order of parameter definition

---------

Co-authored-by: Weidong Xu <[email protected]>
  • Loading branch information
1 parent b755f17 commit 01791fc
Show file tree
Hide file tree
Showing 21 changed files with 2,327 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import "@azure-tools/typespec-client-generator-core";
using Azure.ClientGenerator.Core;
using TypeSpec.Versioning;

@TypeSpec.Versioning.useDependency(DocumentTranslation.Versions.v2024_05_01)
@TypeSpec.Versioning.useDependency(
DocumentTranslation.Versions.v2024_11_01_preview
)
namespace ClientCustomizations;

@client({
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"title": "Translate a single document",
"operationId": "DocumentTranslationOperations_DocumentTranslate",
"parameters": {
"api-version": "2024-11-01-preview",
"sourceLanguage": "en",
"targetLanguage": "es",
"document": "TXkgdHJhbnNsYXRlZCBkb2N1bWVudA=="
},
"responses": {
"200": {
"headers": {
"x-metered-usage": 739,
"total-image-scans-succeeded": 6,
"total-image-scans-failed": 1
},
"body": "TXkgdHJhbnNsYXRlZCBkb2N1bWVudA=="
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"title": "Submit a document translation request to the Document Translation service",
"operationId": "DocumentTranslationOperations_StartTranslation",
"parameters": {
"api-version": "2024-11-01-preview",
"subscriptionId": "EA19050C-51FC-4B55-84E5-9EA7283601DA",
"resourceGroupName": "TestResourceGroup",
"endpoint": "{endpoint}",
"Ocp-Apim-Subscription-Key": "{API key}",
"body": {
"inputs": [
{
"source": {
"sourceUrl": "https://myblob.blob.core.windows.net/sourceContainer",
"filter": {
"prefix": "pre",
"suffix": ".txt"
},
"language": "en",
"storageSource": "AzureBlob"
},
"targets": [
{
"targetUrl": "https://myblob.blob.core.windows.net/destinationContainer1",
"category": "general",
"language": "fr",
"glossaries": [
{
"glossaryUrl": "https://myblob.blob.core.windows.net/myglossary/en_fr_glossary.xlf",
"storageSource": "AzureBlob",
"format": "XLIFF"
}
],
"storageSource": "AzureBlob"
},
{
"targetUrl": "https://myblob.blob.core.windows.net/destinationContainer2",
"category": "general",
"language": "es",
"storageSource": "AzureBlob"
}
],
"storageType": "Folder"
}
]
}
},
"responses": {
"202": {
"headers": {
"Operation-Location": "https://westus.cognitiveservices.azure.com/translator/document/batches?api-version=2024-05-01/operation/0FA2822F-4C2A-4317-9C20-658C801E0E55"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"title": "Cancel a currently processing or queued translation",
"operationId": "DocumentTranslationOperations_CancelTranslation",
"parameters": {
"api-version": "2024-11-01-preview",
"subscriptionId": "EA19050C-51FC-4B55-84E5-9EA7283601DA",
"resourceGroupName": "TestResourceGroup",
"endpoint": "{endpoint}",
"Ocp-Apim-Subscription-Key": "{API key}",
"id": "727BF148-F327-47A0-9481-ABAE6362F11E"
},
"responses": {
"200": {
"headers": {},
"body": {
"id": "727bf148-f327-47a0-9481-abae6362f11e",
"createdDateTimeUtc": "2020-03-26T00:00:00Z",
"lastActionDateTimeUtc": "2020-03-26T01:00:00Z",
"status": "Succeeded",
"summary": {
"total": 10,
"failed": 1,
"success": 9,
"inProgress": 0,
"notYetStarted": 0,
"cancelled": 0,
"totalCharacterCharged": 0,
"totalImageScansSucceeded": 6,
"totalImageScansFailed": 1
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"title": "Returns the status of a single document in a batch translation request",
"operationId": "DocumentTranslationOperations_GetDocumentStatus",
"parameters": {
"api-version": "2024-11-01-preview",
"subscriptionId": "EA19050C-51FC-4B55-84E5-9EA7283601DA",
"resourceGroupName": "TestResourceGroup",
"endpoint": "{endpoint}",
"Ocp-Apim-Subscription-Key": "{API key}",
"id": "727BF148-F327-47A0-9481-ABAE6362F11E",
"documentId": "727BF148-F327-47A0-9481-ABAE6362F12F"
},
"responses": {
"200": {
"headers": {
"retry-after": "30",
"ETag": "686897696a7c876b7e"
},
"body": {
"path": "https://myblob.blob.core.windows.net/destinationContainer/fr/mydoc.txt",
"sourcePath": "https://myblob.blob.core.windows.net/sourceContainer/fr/mydoc.txt",
"createdDateTimeUtc": "2020-03-26T00:00:00Z",
"lastActionDateTimeUtc": "2020-03-26T01:00:00Z",
"status": "Running",
"to": "fr",
"progress": 0.1,
"id": "273622bd-835c-4946-9798-fd8f19f6bbf2",
"characterCharged": 0,
"totalImageScansSucceeded": 6,
"totalImageScansFailed": 1
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"title": "Returns the status for all documents in a batch document translation request",
"operationId": "DocumentTranslationOperations_GetDocumentsStatus",
"parameters": {
"api-version": "2024-11-01-preview",
"subscriptionId": "EA19050C-51FC-4B55-84E5-9EA7283601DA",
"resourceGroupName": "TestResourceGroup",
"endpoint": "{endpoint}",
"Ocp-Apim-Subscription-Key": "{API key}",
"id": "727BF148-F327-47A0-9481-ABAE6362F11E",
"top": 2,
"skip": 0,
"maxpagesize": 1,
"orderBy": "CreatedDateTimeUtc asc",
"createdDateTimeUtcStart": "2021-03-23T07:03:38.0136316Z",
"createdDateTimeUtcEnd": "2021-03-25T07:03:38.0136316Z",
"statuses": [
"Succeeded"
],
"ids": [
"273622bd-835c-4946-9798-fd8f19f6bbf2",
"511b6a66-a6f8-4640-83e1-48c325e9fa29"
]
},
"responses": {
"200": {
"headers": {
"retry-after": "30",
"ETag": "686897696a7c876b7e"
},
"body": {
"value": [
{
"path": "https://myblob.blob.core.windows.net/destinationContainer/fr/mydoc.txt",
"sourcePath": "https://myblob.blob.core.windows.net/sourceContainer/fr/mydoc.txt",
"createdDateTimeUtc": "2021-03-23T07:03:39.013631Z",
"lastActionDateTimeUtc": "2021-03-23T07:03:41.012452Z",
"status": "Running",
"to": "fr",
"progress": 0.1,
"id": "273622bd-835c-4946-9798-fd8f19f6bbf2",
"characterCharged": 0,
"totalImageScansSucceeded": 6,
"totalImageScansFailed": 1
}
],
"nextLink": "https://westus.cognitiveservices.azure.com/translator/text/batch/v1.0/operation/0FA2822F-4C2A-4317-9C20-658C801E0E55/documents?top=1&skip=1&maxpagesize=1&orderBy=CreatedDateTimeUtc%20asc&createdDateTimeUtcStart=2021-03-23T00:03:38.0136316Z&createdDateTimeUtcEnd=2021-03-25T00:03:38.0136316&statuses=Succeeded&ids=273622BD-835C-4946-9798-FD8F19F6BBF2,511B6A66-A6F8-4640-83E1-48C325E9FA29"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
"title": "Returns a list of supported document formats",
"operationId": "DocumentTranslationOperations_GetSupportedFormats",
"parameters": {
"api-version": "2024-11-01-preview",
"subscriptionId": "EA19050C-51FC-4B55-84E5-9EA7283601DA",
"resourceGroupName": "TestResourceGroup",
"endpoint": "{endpoint}",
"Ocp-Apim-Subscription-Key": "{API key}",
"type": "document"
},
"responses": {
"200": {
"headers": {
"retry-after": "30",
"ETag": "686897696a7c876b7e"
},
"body": {
"value": [
{
"format": "PlainText",
"fileExtensions": [
".txt"
],
"contentTypes": [
"text/plain"
]
},
{
"format": "PortableDocumentFormat",
"fileExtensions": [
".pdf"
],
"contentTypes": [
"application/pdf"
]
},
{
"format": "OpenXmlWord",
"fileExtensions": [
".docx"
],
"contentTypes": [
"application/vnd.openxmlformats-officedocument.wordprocessingml.document"
]
},
{
"format": "OpenXmlPresentation",
"fileExtensions": [
".pptx"
],
"contentTypes": [
"application/vnd.openxmlformats-officedocument.presentationml.presentation"
]
},
{
"format": "OpenXmlSpreadsheet",
"fileExtensions": [
".xlsx"
],
"contentTypes": [
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
]
},
{
"format": "HtmlFile",
"fileExtensions": [
".html",
".htm"
],
"contentTypes": [
"text/html"
]
}
]
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"title": "Returns the status for a batch document translation request",
"operationId": "DocumentTranslationOperations_GetTranslationStatus",
"parameters": {
"api-version": "2024-11-01-preview",
"subscriptionId": "EA19050C-51FC-4B55-84E5-9EA7283601DA",
"resourceGroupName": "TestResourceGroup",
"endpoint": "{endpoint}",
"Ocp-Apim-Subscription-Key": "{API key}",
"id": "727BF148-F327-47A0-9481-ABAE6362F11E"
},
"responses": {
"200": {
"headers": {
"retry-after": "30",
"ETag": "686897696a7c876b7e"
},
"body": {
"id": "727bf148-f327-47a0-9481-abae6362f11e",
"createdDateTimeUtc": "2020-03-26T00:00:00Z",
"lastActionDateTimeUtc": "2020-03-26T01:00:00Z",
"status": "Succeeded",
"summary": {
"total": 10,
"failed": 1,
"success": 9,
"inProgress": 0,
"notYetStarted": 0,
"cancelled": 0,
"totalCharacterCharged": 0,
"totalImageScansSucceeded": 6,
"totalImageScansFailed": 1
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"title": "Returns a list of batch requests submitted and the status for each request",
"operationId": "DocumentTranslationOperations_GetTranslationsStatus",
"parameters": {
"api-version": "2024-11-01-preview",
"subscriptionId": "EA19050C-51FC-4B55-84E5-9EA7283601DA",
"resourceGroupName": "TestResourceGroup",
"endpoint": "{endpoint}",
"Ocp-Apim-Subscription-Key": "{API key}",
"top": 1,
"skip": 0,
"maxpagesize": 10,
"orderBy": "CreatedDateTime asc",
"createdDateTimeUtcStart": "2021-03-23T07:03:38.0136316Z",
"createdDateTimeUtcEnd": "2021-03-25T07:03:38.0136316Z",
"statuses": [
"Succeeded"
],
"ids": [
"273622bd-835c-4946-9798-fd8f19f6bbf2"
]
},
"responses": {
"200": {
"headers": {
"retry-after": "30",
"ETag": "686897696a7c876b7e"
},
"body": {
"value": [
{
"id": "273622bd-835c-4946-9798-fd8f19f6bbf2",
"createdDateTimeUtc": "2021-03-23T07:03:30.013631Z",
"lastActionDateTimeUtc": "2021-03-26T01:00:00Z",
"status": "Succeeded",
"summary": {
"total": 10,
"failed": 1,
"success": 9,
"inProgress": 0,
"notYetStarted": 0,
"cancelled": 0,
"totalCharacterCharged": 1000,
"totalImageScansSucceeded": 6,
"totalImageScansFailed": 1
}
}
],
"nextLink": "https://westus.cognitiveservices.azure.com/translator/text/batch/v1.0/operation/0FA2822F-4C2A-4317-9C20-658C801E0E55/documents?top=1&skip=1&maxpagesize=1&orderBy=CreatedDateTimeUtc%20asc&createdDateTimeUtcStart=2021-03-23T00:03:38.0136316Z&createdDateTimeUtcEnd=2021-03-25T00:03:38.0136316&statuses=Succeeded&ids=273622BD-835C-4946-9798-FD8F19F6BBF2,511B6A66-A6F8-4640-83E1-48C325E9FA29"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,7 @@ namespace DocumentTranslation;
enum Versions {
@useDependency(Azure.Core.Versions.v1_0_Preview_1)
v2024_05_01: "2024-05-01",

@useDependency(Azure.Core.Versions.v1_0_Preview_1)
v2024_11_01_preview: "2024-11-01-preview",
}
Loading

0 comments on commit 01791fc

Please sign in to comment.