Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sdk/translation/Azure.AI.Translation.Document/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ try
using Stream fileStream = File.OpenRead(filePath);
var sourceDocument = new MultipartFormFileData(Path.GetFileName(filePath), fileStream, "text/html");
DocumentTranslateContent content = new DocumentTranslateContent(sourceDocument);
var response = await client.DocumentTranslateAsync("hi", content).ConfigureAwait(false);
var response = await client.TranslateAsync("hi", content).ConfigureAwait(false);

var requestString = File.ReadAllText(filePath);
var responseString = Encoding.UTF8.GetString(response.Value.ToArray());
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ try
using Stream fileStream = File.OpenRead(filePath);
var sourceDocument = new MultipartFormFileData(Path.GetFileName(filePath), fileStream, "text/html");
DocumentTranslateContent content = new DocumentTranslateContent(sourceDocument);
var response = await client.DocumentTranslateAsync("hi", content).ConfigureAwait(false);
var response = await client.TranslateAsync("hi", content).ConfigureAwait(false);

var requestString = File.ReadAllText(filePath);
var responseString = Encoding.UTF8.GetString(response.Value.ToArray());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -94,7 +95,7 @@ internal DocumentTranslationClient(ClientDiagnostics clientDiagnostics, HttpPipe
/// <summary> Initializes a new instance of DocumentTranslation. </summary>
/// <param name="apiVersion"> The API version to use for this operation. </param>
/// <exception cref="ArgumentNullException"> <paramref name="apiVersion"/> is null. </exception>
public virtual DocumentTranslationClient GetDocumentTranslationClient(string apiVersion = "2024-05-01")
internal virtual DocumentTranslationClient GetDocumentTranslationClient(string apiVersion = "2024-05-01")
{
Argument.AssertNotNull(apiVersion, nameof(apiVersion));

Expand All @@ -113,9 +114,9 @@ public virtual DocumentTranslationClient GetDocumentTranslationClient(string api
/// <exception cref="RequestFailedException">Service returned a non-success status code. </exception>
public virtual DocumentTranslationOperation StartTranslation(IEnumerable<DocumentTranslationInput> inputs, CancellationToken cancellationToken = default)
{
var request = new StartTranslationDetails(inputs);
var request = new TranslationBatch(inputs);
using DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DocumentTranslationClient)}.{nameof(StartTranslation)}");
var startTranslationDetails = new StartTranslationDetails(inputs);
var startTranslationDetails = new TranslationBatch(inputs);
scope.Start();

try
Expand Down Expand Up @@ -143,9 +144,9 @@ public virtual DocumentTranslationOperation StartTranslation(IEnumerable<Documen
/// <exception cref="RequestFailedException">Service returned a non-success status code. </exception>
public virtual async Task<DocumentTranslationOperation> StartTranslationAsync(IEnumerable<DocumentTranslationInput> inputs, CancellationToken cancellationToken = default)
{
var request = new StartTranslationDetails(inputs);
var request = new TranslationBatch(inputs);
using DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DocumentTranslationClient)}.{nameof(StartTranslation)}");
var startTranslationDetails = new StartTranslationDetails(inputs);
var startTranslationDetails = new TranslationBatch(inputs);
scope.Start();

try
Expand Down Expand Up @@ -174,7 +175,7 @@ public virtual async Task<DocumentTranslationOperation> StartTranslationAsync(IE
public virtual DocumentTranslationOperation StartTranslation(DocumentTranslationInput input, CancellationToken cancellationToken = default)
{
Argument.AssertNotNull(input, nameof(input));
var startTranslationDetails = new StartTranslationDetails(new List<DocumentTranslationInput> { input });
var startTranslationDetails = new TranslationBatch(new List<DocumentTranslationInput> { input });
using DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DocumentTranslationClient)}.{nameof(StartTranslation)}");
scope.Start();

Expand Down Expand Up @@ -204,7 +205,7 @@ public virtual DocumentTranslationOperation StartTranslation(DocumentTranslation
public virtual async Task<DocumentTranslationOperation> StartTranslationAsync(DocumentTranslationInput input, CancellationToken cancellationToken = default)
{
Argument.AssertNotNull(input, nameof(input));
var startTranslationDetails = new StartTranslationDetails(new List<DocumentTranslationInput> { input });
var startTranslationDetails = new TranslationBatch(new List<DocumentTranslationInput> { input });
using DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DocumentTranslationClient)}.{nameof(StartTranslation)}");
scope.Start();

Expand Down Expand Up @@ -614,5 +615,49 @@ public virtual Pageable<BinaryData> GetTranslationsStatus(int? maxCount, int? sk
HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTranslationsStatusNextPageRequest(nextLink, maxCount, skip, maxpagesize, ids, statuses, createdDateTimeUtcStart, createdDateTimeUtcEnd, orderBy, context);
return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "DocumentTranslationClient.GetTranslationStatuses", "value", "nextLink", context);
}

#region supported formats functions nobody wants to see these

/// <summary>
/// Get the list of the glossary formats supported by the Document Translation service.
/// </summary>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual Response<SupportedFileFormats> GetSupportedGlossaryFormats(CancellationToken cancellationToken = default)
{
return GetSupportedFormats(FileFormatType.Glossary, cancellationToken);
}

/// <summary>
/// Get the list of the glossary formats supported by the Document Translation service.
/// </summary>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual async Task<Response<SupportedFileFormats>> GetSupportedGlossaryFormatsAsync(CancellationToken cancellationToken = default)
{
return await GetSupportedFormatsAsync(FileFormatType.Glossary, cancellationToken).ConfigureAwait(false);
}

/// <summary>
/// Get the list of the document formats supported by the Document Translation service.
/// </summary>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual Response<SupportedFileFormats> GetSupportedDocumentFormats(CancellationToken cancellationToken = default)
{
return GetSupportedFormats(FileFormatType.Document, cancellationToken);
}

/// <summary>
/// Get the list of the document formats supported by the Document Translation service.
/// </summary>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual async Task<Response<SupportedFileFormats>> GetSupportedDocumentFormatsAsync(CancellationToken cancellationToken = default)
{
return await GetSupportedFormatsAsync(FileFormatType.Document, cancellationToken).ConfigureAwait(false);
}

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ long charactersCharged
/// <param name="lastModified">Sets the <see cref="TranslationStatusResult.LastModified"/> property.</param>
/// <param name="status">Sets the <see cref="TranslationStatusResult.Status"/> property.</param>
/// <param name="error">Sets the <see cref="TranslationStatusResult.Error"/> property.</param>
/// <param name="total">Sets the <see cref="StatusSummary.Total"/> and the <see cref="TranslationStatusResult.DocumentsTotal"/> properties.</param>
/// <param name="failed">Sets the <see cref="StatusSummary.Failed"/> and the <see cref="TranslationStatusResult.DocumentsFailed"/> properties.</param>
/// <param name="success">Sets the <see cref="StatusSummary.Success"/> and the <see cref="TranslationStatusResult.DocumentsSucceeded"/> properties.</param>
/// <param name="inProgress">Sets the <see cref="StatusSummary.InProgress"/> and the <see cref="TranslationStatusResult.DocumentsInProgress"/> properties.</param>
/// <param name="notYetStarted">Sets the <see cref="StatusSummary.NotYetStarted"/> and the <see cref="TranslationStatusResult.DocumentsNotStarted"/> properties.</param>
/// <param name="canceled">Sets the <see cref="StatusSummary.Cancelled"/> and the <see cref="TranslationStatusResult.DocumentsCanceled"/> properties.</param>
/// <param name="totalCharacterCharged">Sets the <see cref="StatusSummary.TotalCharacterCharged"/> and the <see cref="TranslationStatusResult.TotalCharactersCharged"/> properties.</param>
/// <param name="total">Sets the <see cref="TranslationStatusSummary.Total"/> and the <see cref="TranslationStatusResult.DocumentsTotal"/> properties.</param>
/// <param name="failed">Sets the <see cref="TranslationStatusSummary.Failed"/> and the <see cref="TranslationStatusResult.DocumentsFailed"/> properties.</param>
/// <param name="success">Sets the <see cref="TranslationStatusSummary.Success"/> and the <see cref="TranslationStatusResult.DocumentsSucceeded"/> properties.</param>
/// <param name="inProgress">Sets the <see cref="TranslationStatusSummary.InProgress"/> and the <see cref="TranslationStatusResult.DocumentsInProgress"/> properties.</param>
/// <param name="notYetStarted">Sets the <see cref="TranslationStatusSummary.NotYetStarted"/> and the <see cref="TranslationStatusResult.DocumentsNotStarted"/> properties.</param>
/// <param name="canceled">Sets the <see cref="TranslationStatusSummary.Cancelled"/> and the <see cref="TranslationStatusResult.DocumentsCanceled"/> properties.</param>
/// <param name="totalCharacterCharged">Sets the <see cref="TranslationStatusSummary.TotalCharacterCharged"/> and the <see cref="TranslationStatusResult.TotalCharactersCharged"/> properties.</param>
/// <returns>A new instance of <see cref="Document.TranslationStatusResult"/> for mocking purposes.</returns>
public static TranslationStatusResult TranslationStatusResult(
string id,
Expand All @@ -103,7 +103,7 @@ public static TranslationStatusResult TranslationStatusResult(
long totalCharacterCharged
)
{
StatusSummary newSummary = new StatusSummary(total, failed, success, inProgress, notYetStarted, canceled, totalCharacterCharged);
TranslationStatusSummary newSummary = new TranslationStatusSummary(total, failed, success, inProgress, notYetStarted, canceled, totalCharacterCharged);
JsonElement errorJson = error.ToObjectFromJson<JsonElement>();
return new TranslationStatusResult(id, createdOn, lastModified, status, errorJson, newSummary);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ public virtual Pageable<DocumentStatusResult> GetDocumentStatuses(GetDocumentSta

return _serviceClient.GetDocumentsStatus(
new Guid(Id),
ids: idList,
documentIds: idList,
statuses: statusList,
createdDateTimeUtcStart: options?.CreatedAfter,
createdDateTimeUtcEnd: options?.CreatedBefore,
Expand All @@ -323,7 +323,7 @@ public virtual AsyncPageable<DocumentStatusResult> GetDocumentStatusesAsync(GetD

return _serviceClient.GetDocumentsStatusAsync(
new Guid(Id),
ids: idList,
documentIds: idList,
statuses: statusList,
createdDateTimeUtcStart: options?.CreatedAfter,
createdDateTimeUtcEnd: options?.CreatedBefore,
Expand Down
Loading