Skip to content

Commit 2518659

Browse files
author
SDKAuto
committed
CodeGen from PR 33410 in Azure/azure-rest-api-specs
Merge 7df1a1e7b1103ec1be64d5e741b516165c473784 into c269b7b78cac2808d7acc55124a9653b2e904e4b
1 parent 5992bbb commit 2518659

17 files changed

+1231
-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: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,14 @@
1111
*/
1212
public enum TextTranslationServiceVersion implements ServiceVersion {
1313
/**
14-
* Enum value 3.0.
14+
* Enum value v3.0.
1515
*/
16-
V3_0("3.0");
16+
V3_0("v3.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.
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: 230 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,230 @@
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.JsonToken;
11+
import com.azure.json.JsonWriter;
12+
import java.io.IOException;
13+
import java.util.List;
14+
15+
/**
16+
* Element containing the text for translation.
17+
*/
18+
@Fluent
19+
public final class TranslateBody extends InputTextItem {
20+
/*
21+
* Text to translate.
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 List<TranslateTarget> targets;
55+
56+
/**
57+
* Creates an instance of TranslateBody class.
58+
*
59+
* @param text the text value to set.
60+
* @param targets the targets value to set.
61+
*/
62+
@Generated
63+
public TranslateBody(String text, List<TranslateTarget> targets) {
64+
super(text);
65+
this.targets = targets;
66+
}
67+
68+
/**
69+
* Get the text property: Text to translate.
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 TranslateBody object itself.
93+
*/
94+
@Generated
95+
public TranslateBody 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 TranslateBody object itself.
127+
*/
128+
@Generated
129+
public TranslateBody 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 TranslateBody object itself.
153+
*/
154+
@Generated
155+
public TranslateBody 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 List<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", getText());
178+
jsonWriter.writeStringField("text", this.text);
179+
jsonWriter.writeArrayField("targets", this.targets, (writer, element) -> writer.writeJson(element));
180+
jsonWriter.writeStringField("script", this.script);
181+
jsonWriter.writeStringField("language", this.language);
182+
jsonWriter.writeStringField("textType", this.textType == null ? null : this.textType.toString());
183+
return jsonWriter.writeEndObject();
184+
}
185+
186+
/**
187+
* Reads an instance of TranslateBody from the JsonReader.
188+
*
189+
* @param jsonReader The JsonReader being read.
190+
* @return An instance of TranslateBody if the JsonReader was pointing to an instance of it, or null if it was
191+
* pointing to JSON null.
192+
* @throws IllegalStateException If the deserialized JSON object was missing any required properties.
193+
* @throws IOException If an error occurs while reading the TranslateBody.
194+
*/
195+
@Generated
196+
public static TranslateBody fromJson(JsonReader jsonReader) throws IOException {
197+
return jsonReader.readObject(reader -> {
198+
String text = null;
199+
String text = null;
200+
List<TranslateTarget> targets = null;
201+
String script = null;
202+
String language = null;
203+
TextType textType = null;
204+
while (reader.nextToken() != JsonToken.END_OBJECT) {
205+
String fieldName = reader.getFieldName();
206+
reader.nextToken();
207+
208+
if ("text".equals(fieldName)) {
209+
text = reader.getString();
210+
} else if ("targets".equals(fieldName)) {
211+
targets = reader.readArray(reader1 -> TranslateTarget.fromJson(reader1));
212+
} else if ("script".equals(fieldName)) {
213+
script = reader.getString();
214+
} else if ("language".equals(fieldName)) {
215+
language = reader.getString();
216+
} else if ("textType".equals(fieldName)) {
217+
textType = TextType.fromString(reader.getString());
218+
} else {
219+
reader.skipChildren();
220+
}
221+
}
222+
TranslateBody deserializedTranslateBody = new TranslateBody(text, text, targets);
223+
deserializedTranslateBody.script = script;
224+
deserializedTranslateBody.language = language;
225+
deserializedTranslateBody.textType = textType;
226+
227+
return deserializedTranslateBody;
228+
});
229+
}
230+
}

0 commit comments

Comments
 (0)