Skip to content

Commit 2c71e57

Browse files
author
SDKAuto
committed
CodeGen from PR 33410 in Azure/azure-rest-api-specs
Merge 114af2dc013164292d8f5eaeb6d13b9a5785bea2 into ef851ba96b020132a9ddf2d3c74af5aaacc023dd
1 parent 657700b commit 2c71e57

18 files changed

+1228
-1421
lines changed

sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/TextTranslationAsyncClient.java

Lines changed: 89 additions & 348 deletions
Large diffs are not rendered by default.

sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/TextTranslationClient.java

Lines changed: 89 additions & 373 deletions
Large diffs are not rendered by default.

sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/TextTranslationServiceVersion.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ public enum TextTranslationServiceVersion implements ServiceVersion {
1313
/**
1414
* Enum value 3.0.
1515
*/
16-
V3_0("3.0");
16+
V3_0("3.0"),
17+
18+
/**
19+
* Enum value 2025-05-01-preview.
20+
*/
21+
V2025_05_01_PREVIEW("2025-05-01-preview");
1722

1823
private final String version;
1924

@@ -35,6 +40,6 @@ public String getVersion() {
3540
* @return The latest {@link TextTranslationServiceVersion}.
3641
*/
3742
public static TextTranslationServiceVersion getLatest() {
38-
return V3_0;
43+
return V2025_05_01_PREVIEW;
3944
}
4045
}

sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/implementation/TextTranslationClientImpl.java

Lines changed: 55 additions & 629 deletions
Large diffs are not rendered by default.

sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/InputTextItem.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* Element containing the text for translation.
1616
*/
1717
@Immutable
18-
public class InputTextItem implements JsonSerializable<InputTextItem> {
18+
public final class InputTextItem implements JsonSerializable<InputTextItem> {
1919

2020
/*
2121
* Text to translate.
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
// Code generated by Microsoft (R) TypeSpec Code Generator.
4+
5+
package com.azure.ai.translation.text.models;
6+
7+
import com.azure.core.annotation.Generated;
8+
import com.azure.core.annotation.Immutable;
9+
import com.azure.json.JsonReader;
10+
import com.azure.json.JsonSerializable;
11+
import com.azure.json.JsonToken;
12+
import com.azure.json.JsonWriter;
13+
import java.io.IOException;
14+
15+
/**
16+
* Reference sentence pair.
17+
*/
18+
@Immutable
19+
public final class ReferenceSentencePair implements JsonSerializable<ReferenceSentencePair> {
20+
/*
21+
* Source reference sentence.
22+
*/
23+
@Generated
24+
private final String referenceTextPairsSource;
25+
26+
/*
27+
* Target reference sentence.
28+
*/
29+
@Generated
30+
private final String referenceTextPairsTarget;
31+
32+
/**
33+
* Creates an instance of ReferenceSentencePair class.
34+
*
35+
* @param referenceTextPairsSource the referenceTextPairsSource value to set.
36+
* @param referenceTextPairsTarget the referenceTextPairsTarget value to set.
37+
*/
38+
@Generated
39+
public ReferenceSentencePair(String referenceTextPairsSource, String referenceTextPairsTarget) {
40+
this.referenceTextPairsSource = referenceTextPairsSource;
41+
this.referenceTextPairsTarget = referenceTextPairsTarget;
42+
}
43+
44+
/**
45+
* Get the referenceTextPairsSource property: Source reference sentence.
46+
*
47+
* @return the referenceTextPairsSource value.
48+
*/
49+
@Generated
50+
public String getReferenceTextPairsSource() {
51+
return this.referenceTextPairsSource;
52+
}
53+
54+
/**
55+
* Get the referenceTextPairsTarget property: Target reference sentence.
56+
*
57+
* @return the referenceTextPairsTarget value.
58+
*/
59+
@Generated
60+
public String getReferenceTextPairsTarget() {
61+
return this.referenceTextPairsTarget;
62+
}
63+
64+
/**
65+
* {@inheritDoc}
66+
*/
67+
@Generated
68+
@Override
69+
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
70+
jsonWriter.writeStartObject();
71+
jsonWriter.writeStringField("referenceTextPairsSource", this.referenceTextPairsSource);
72+
jsonWriter.writeStringField("referenceTextPairsTarget", this.referenceTextPairsTarget);
73+
return jsonWriter.writeEndObject();
74+
}
75+
76+
/**
77+
* Reads an instance of ReferenceSentencePair from the JsonReader.
78+
*
79+
* @param jsonReader The JsonReader being read.
80+
* @return An instance of ReferenceSentencePair if the JsonReader was pointing to an instance of it, or null if it
81+
* was pointing to JSON null.
82+
* @throws IllegalStateException If the deserialized JSON object was missing any required properties.
83+
* @throws IOException If an error occurs while reading the ReferenceSentencePair.
84+
*/
85+
@Generated
86+
public static ReferenceSentencePair fromJson(JsonReader jsonReader) throws IOException {
87+
return jsonReader.readObject(reader -> {
88+
String referenceTextPairsSource = null;
89+
String referenceTextPairsTarget = null;
90+
while (reader.nextToken() != JsonToken.END_OBJECT) {
91+
String fieldName = reader.getFieldName();
92+
reader.nextToken();
93+
94+
if ("referenceTextPairsSource".equals(fieldName)) {
95+
referenceTextPairsSource = reader.getString();
96+
} else if ("referenceTextPairsTarget".equals(fieldName)) {
97+
referenceTextPairsTarget = reader.getString();
98+
} else {
99+
reader.skipChildren();
100+
}
101+
}
102+
return new ReferenceSentencePair(referenceTextPairsSource, referenceTextPairsTarget);
103+
});
104+
}
105+
}
Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
// Code generated by Microsoft (R) TypeSpec Code Generator.
4+
5+
package com.azure.ai.translation.text.models;
6+
7+
import com.azure.core.annotation.Fluent;
8+
import com.azure.core.annotation.Generated;
9+
import com.azure.json.JsonReader;
10+
import com.azure.json.JsonSerializable;
11+
import com.azure.json.JsonToken;
12+
import com.azure.json.JsonWriter;
13+
import java.io.IOException;
14+
15+
/**
16+
* Request body parameters for the translate API.
17+
*/
18+
@Fluent
19+
public final class TranslateBodyDetails implements JsonSerializable<TranslateBodyDetails> {
20+
/*
21+
* Specifies the text string to be translated in the translate API.
22+
*/
23+
@Generated
24+
private final String text;
25+
26+
/*
27+
* Specifies the script of the input text.
28+
*/
29+
@Generated
30+
private String script;
31+
32+
/*
33+
* Specifies the language of the input text. Find which languages are available to translate by
34+
* looking up supported languages using the translation scope. If the language parameter isn't
35+
* specified, automatic language detection is applied to determine the source language.
36+
*
37+
* You must use the language parameter rather than autodetection when using the dynamic dictionary feature.
38+
* Note: the dynamic dictionary feature is case-sensitive.
39+
*/
40+
@Generated
41+
private String language;
42+
43+
/*
44+
* Defines whether the text being translated is plain text or HTML text. Any HTML needs to be a well-formed,
45+
* complete element. Possible values are: plain (default) or html.
46+
*/
47+
@Generated
48+
private TextType textType;
49+
50+
/*
51+
* Translation target parameters.
52+
*/
53+
@Generated
54+
private final TranslateTarget targets;
55+
56+
/**
57+
* Creates an instance of TranslateBodyDetails class.
58+
*
59+
* @param text the text value to set.
60+
* @param targets the targets value to set.
61+
*/
62+
@Generated
63+
public TranslateBodyDetails(String text, TranslateTarget targets) {
64+
this.text = text;
65+
this.targets = targets;
66+
}
67+
68+
/**
69+
* Get the text property: Specifies the text string to be translated in the translate API.
70+
*
71+
* @return the text value.
72+
*/
73+
@Generated
74+
public String getText() {
75+
return this.text;
76+
}
77+
78+
/**
79+
* Get the script property: Specifies the script of the input text.
80+
*
81+
* @return the script value.
82+
*/
83+
@Generated
84+
public String getScript() {
85+
return this.script;
86+
}
87+
88+
/**
89+
* Set the script property: Specifies the script of the input text.
90+
*
91+
* @param script the script value to set.
92+
* @return the TranslateBodyDetails object itself.
93+
*/
94+
@Generated
95+
public TranslateBodyDetails setScript(String script) {
96+
this.script = script;
97+
return this;
98+
}
99+
100+
/**
101+
* Get the language property: Specifies the language of the input text. Find which languages are available to
102+
* translate by
103+
* looking up supported languages using the translation scope. If the language parameter isn't
104+
* specified, automatic language detection is applied to determine the source language.
105+
*
106+
* You must use the language parameter rather than autodetection when using the dynamic dictionary feature.
107+
* Note: the dynamic dictionary feature is case-sensitive.
108+
*
109+
* @return the language value.
110+
*/
111+
@Generated
112+
public String getLanguage() {
113+
return this.language;
114+
}
115+
116+
/**
117+
* Set the language property: Specifies the language of the input text. Find which languages are available to
118+
* translate by
119+
* looking up supported languages using the translation scope. If the language parameter isn't
120+
* specified, automatic language detection is applied to determine the source language.
121+
*
122+
* You must use the language parameter rather than autodetection when using the dynamic dictionary feature.
123+
* Note: the dynamic dictionary feature is case-sensitive.
124+
*
125+
* @param language the language value to set.
126+
* @return the TranslateBodyDetails object itself.
127+
*/
128+
@Generated
129+
public TranslateBodyDetails setLanguage(String language) {
130+
this.language = language;
131+
return this;
132+
}
133+
134+
/**
135+
* Get the textType property: Defines whether the text being translated is plain text or HTML text. Any HTML needs
136+
* to be a well-formed,
137+
* complete element. Possible values are: plain (default) or html.
138+
*
139+
* @return the textType value.
140+
*/
141+
@Generated
142+
public TextType getTextType() {
143+
return this.textType;
144+
}
145+
146+
/**
147+
* Set the textType property: Defines whether the text being translated is plain text or HTML text. Any HTML needs
148+
* to be a well-formed,
149+
* complete element. Possible values are: plain (default) or html.
150+
*
151+
* @param textType the textType value to set.
152+
* @return the TranslateBodyDetails object itself.
153+
*/
154+
@Generated
155+
public TranslateBodyDetails setTextType(TextType textType) {
156+
this.textType = textType;
157+
return this;
158+
}
159+
160+
/**
161+
* Get the targets property: Translation target parameters.
162+
*
163+
* @return the targets value.
164+
*/
165+
@Generated
166+
public TranslateTarget getTargets() {
167+
return this.targets;
168+
}
169+
170+
/**
171+
* {@inheritDoc}
172+
*/
173+
@Generated
174+
@Override
175+
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
176+
jsonWriter.writeStartObject();
177+
jsonWriter.writeStringField("text", this.text);
178+
jsonWriter.writeJsonField("targets", this.targets);
179+
jsonWriter.writeStringField("script", this.script);
180+
jsonWriter.writeStringField("language", this.language);
181+
jsonWriter.writeStringField("textType", this.textType == null ? null : this.textType.toString());
182+
return jsonWriter.writeEndObject();
183+
}
184+
185+
/**
186+
* Reads an instance of TranslateBodyDetails from the JsonReader.
187+
*
188+
* @param jsonReader The JsonReader being read.
189+
* @return An instance of TranslateBodyDetails if the JsonReader was pointing to an instance of it, or null if it
190+
* was pointing to JSON null.
191+
* @throws IllegalStateException If the deserialized JSON object was missing any required properties.
192+
* @throws IOException If an error occurs while reading the TranslateBodyDetails.
193+
*/
194+
@Generated
195+
public static TranslateBodyDetails fromJson(JsonReader jsonReader) throws IOException {
196+
return jsonReader.readObject(reader -> {
197+
String text = null;
198+
TranslateTarget targets = null;
199+
String script = null;
200+
String language = null;
201+
TextType textType = null;
202+
while (reader.nextToken() != JsonToken.END_OBJECT) {
203+
String fieldName = reader.getFieldName();
204+
reader.nextToken();
205+
206+
if ("text".equals(fieldName)) {
207+
text = reader.getString();
208+
} else if ("targets".equals(fieldName)) {
209+
targets = TranslateTarget.fromJson(reader);
210+
} else if ("script".equals(fieldName)) {
211+
script = reader.getString();
212+
} else if ("language".equals(fieldName)) {
213+
language = reader.getString();
214+
} else if ("textType".equals(fieldName)) {
215+
textType = TextType.fromString(reader.getString());
216+
} else {
217+
reader.skipChildren();
218+
}
219+
}
220+
TranslateBodyDetails deserializedTranslateBodyDetails = new TranslateBodyDetails(text, targets);
221+
deserializedTranslateBodyDetails.script = script;
222+
deserializedTranslateBodyDetails.language = language;
223+
deserializedTranslateBodyDetails.textType = textType;
224+
225+
return deserializedTranslateBodyDetails;
226+
});
227+
}
228+
}

0 commit comments

Comments
 (0)