Skip to content
Closed
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

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,14 @@
*/
public enum TextTranslationServiceVersion implements ServiceVersion {
/**
* Enum value 3.0.
* Enum value v3.0.
*/
V3_0("3.0");
V3_0("v3.0"),

/**
* Enum value 2025-05-01-preview.
*/
V2025_05_01_PREVIEW("2025-05-01-preview");

private final String version;

Expand All @@ -35,6 +40,6 @@ public String getVersion() {
* @return The latest {@link TextTranslationServiceVersion}.
*/
public static TextTranslationServiceVersion getLatest() {
return V3_0;
return V2025_05_01_PREVIEW;
}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -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.translation.text.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;

/**
* Reference sentence pair.
*/
@Immutable
public final class ReferenceSentencePair implements JsonSerializable<ReferenceSentencePair> {
/*
* Source reference sentence.
*/
@Generated
private final String referenceTextPairsSource;

/*
* Target reference sentence.
*/
@Generated
private final String referenceTextPairsTarget;

/**
* Creates an instance of ReferenceSentencePair class.
*
* @param referenceTextPairsSource the referenceTextPairsSource value to set.
* @param referenceTextPairsTarget the referenceTextPairsTarget value to set.
*/
@Generated
public ReferenceSentencePair(String referenceTextPairsSource, String referenceTextPairsTarget) {
this.referenceTextPairsSource = referenceTextPairsSource;
this.referenceTextPairsTarget = referenceTextPairsTarget;
}

/**
* Get the referenceTextPairsSource property: Source reference sentence.
*
* @return the referenceTextPairsSource value.
*/
@Generated
public String getReferenceTextPairsSource() {
return this.referenceTextPairsSource;
}

/**
* Get the referenceTextPairsTarget property: Target reference sentence.
*
* @return the referenceTextPairsTarget value.
*/
@Generated
public String getReferenceTextPairsTarget() {
return this.referenceTextPairsTarget;
}

/**
* {@inheritDoc}
*/
@Generated
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("referenceTextPairsSource", this.referenceTextPairsSource);
jsonWriter.writeStringField("referenceTextPairsTarget", this.referenceTextPairsTarget);
return jsonWriter.writeEndObject();
}

/**
* Reads an instance of ReferenceSentencePair from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of ReferenceSentencePair 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 ReferenceSentencePair.
*/
@Generated
public static ReferenceSentencePair fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
String referenceTextPairsSource = null;
String referenceTextPairsTarget = null;
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();

if ("referenceTextPairsSource".equals(fieldName)) {
referenceTextPairsSource = reader.getString();
} else if ("referenceTextPairsTarget".equals(fieldName)) {
referenceTextPairsTarget = reader.getString();
} else {
reader.skipChildren();
}
}
return new ReferenceSentencePair(referenceTextPairsSource, referenceTextPairsTarget);
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) TypeSpec Code Generator.

package com.azure.ai.translation.text.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.annotation.Generated;
import com.azure.json.JsonReader;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;
import java.util.List;

/**
* Element containing the text for translation.
*/
@Fluent
public final class TranslateBody extends InputTextItem {
/*
* Text to translate.
*/
@Generated
private final String text;

/*
* Specifies the script of the input text.
*/
@Generated
private String script;

/*
* Specifies the language of the input text. Find which languages are available to translate by
* looking up supported languages using the translation scope. If the language parameter isn't
* specified, automatic language detection is applied to determine the source language.
*
* You must use the language parameter rather than autodetection when using the dynamic dictionary feature.
* Note: the dynamic dictionary feature is case-sensitive.
*/
@Generated
private String language;

/*
* Defines whether the text being translated is plain text or HTML text. Any HTML needs to be a well-formed,
* complete element. Possible values are: plain (default) or html.
*/
@Generated
private TextType textType;

/*
* Translation target parameters.
*/
@Generated
private final List<TranslateTarget> targets;

/**
* Creates an instance of TranslateBody class.
*
* @param text the text value to set.
* @param targets the targets value to set.
*/
@Generated
public TranslateBody(String text, List<TranslateTarget> targets) {
super(text);
this.targets = targets;
}

/**
* Get the text property: Text to translate.
*
* @return the text value.
*/
@Generated
public String getText() {
return this.text;
}

/**
* Get the script property: Specifies the script of the input text.
*
* @return the script value.
*/
@Generated
public String getScript() {
return this.script;
}

/**
* Set the script property: Specifies the script of the input text.
*
* @param script the script value to set.
* @return the TranslateBody object itself.
*/
@Generated
public TranslateBody setScript(String script) {
this.script = script;
return this;
}

/**
* Get the language property: Specifies the language of the input text. Find which languages are available to
* translate by
* looking up supported languages using the translation scope. If the language parameter isn't
* specified, automatic language detection is applied to determine the source language.
*
* You must use the language parameter rather than autodetection when using the dynamic dictionary feature.
* Note: the dynamic dictionary feature is case-sensitive.
*
* @return the language value.
*/
@Generated
public String getLanguage() {
return this.language;
}

/**
* Set the language property: Specifies the language of the input text. Find which languages are available to
* translate by
* looking up supported languages using the translation scope. If the language parameter isn't
* specified, automatic language detection is applied to determine the source language.
*
* You must use the language parameter rather than autodetection when using the dynamic dictionary feature.
* Note: the dynamic dictionary feature is case-sensitive.
*
* @param language the language value to set.
* @return the TranslateBody object itself.
*/
@Generated
public TranslateBody setLanguage(String language) {
this.language = language;
return this;
}

/**
* Get the textType property: Defines whether the text being translated is plain text or HTML text. Any HTML needs
* to be a well-formed,
* complete element. Possible values are: plain (default) or html.
*
* @return the textType value.
*/
@Generated
public TextType getTextType() {
return this.textType;
}

/**
* Set the textType property: Defines whether the text being translated is plain text or HTML text. Any HTML needs
* to be a well-formed,
* complete element. Possible values are: plain (default) or html.
*
* @param textType the textType value to set.
* @return the TranslateBody object itself.
*/
@Generated
public TranslateBody setTextType(TextType textType) {
this.textType = textType;
return this;
}

/**
* Get the targets property: Translation target parameters.
*
* @return the targets value.
*/
@Generated
public List<TranslateTarget> getTargets() {
return this.targets;
}

/**
* {@inheritDoc}
*/
@Generated
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("text", getText());
jsonWriter.writeStringField("text", this.text);
jsonWriter.writeArrayField("targets", this.targets, (writer, element) -> writer.writeJson(element));
jsonWriter.writeStringField("script", this.script);
jsonWriter.writeStringField("language", this.language);
jsonWriter.writeStringField("textType", this.textType == null ? null : this.textType.toString());
return jsonWriter.writeEndObject();
}

/**
* Reads an instance of TranslateBody from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of TranslateBody 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 TranslateBody.
*/
@Generated
public static TranslateBody fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
String text = null;
String text = null;
List<TranslateTarget> targets = null;
String script = null;
String language = null;
TextType textType = null;
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();

if ("text".equals(fieldName)) {
text = reader.getString();
} else if ("targets".equals(fieldName)) {
targets = reader.readArray(reader1 -> TranslateTarget.fromJson(reader1));
} else if ("script".equals(fieldName)) {
script = reader.getString();
} else if ("language".equals(fieldName)) {
language = reader.getString();
} else if ("textType".equals(fieldName)) {
textType = TextType.fromString(reader.getString());
} else {
reader.skipChildren();
}
}
TranslateBody deserializedTranslateBody = new TranslateBody(text, text, targets);
deserializedTranslateBody.script = script;
deserializedTranslateBody.language = language;
deserializedTranslateBody.textType = textType;

return deserializedTranslateBody;
});
}
}
Loading