Skip to content

Commit 5bbbb09

Browse files
author
SDKAuto
committed
CodeGen from PR 34547 in Azure/azure-rest-api-specs
Merge 9afaf7006571ee01ab1280c4af3aabf95ad27da4 into 9f69db7532b6706baedc004f2eda762196a3e1eb
1 parent ac53b7d commit 5bbbb09

17 files changed

+1259
-1434
lines changed

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

Lines changed: 136 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: 136 additions & 373 deletions
Large diffs are not rendered by default.

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
import com.azure.core.client.traits.ConfigurationTrait;
1111
import com.azure.core.client.traits.EndpointTrait;
1212
import com.azure.core.client.traits.HttpTrait;
13-
import com.azure.core.client.traits.KeyCredentialTrait;
14-
import com.azure.core.client.traits.TokenCredentialTrait;
1513
import com.azure.core.credential.KeyCredential;
1614
import com.azure.core.credential.TokenCredential;
1715
import com.azure.core.http.HttpClient;
@@ -51,8 +49,7 @@
5149
*/
5250
@ServiceClientBuilder(serviceClients = { TextTranslationClient.class, TextTranslationAsyncClient.class })
5351
public final class TextTranslationClientBuilder implements HttpTrait<TextTranslationClientBuilder>,
54-
ConfigurationTrait<TextTranslationClientBuilder>, EndpointTrait<TextTranslationClientBuilder>,
55-
KeyCredentialTrait<TextTranslationClientBuilder>, TokenCredentialTrait<TextTranslationClientBuilder> {
52+
ConfigurationTrait<TextTranslationClientBuilder>, EndpointTrait<TextTranslationClientBuilder> {
5653

5754
@Generated
5855
private static final String SDK_NAME = "name";

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

0 commit comments

Comments
 (0)