Skip to content

Commit 5de90a4

Browse files
[codegen] update to latest spec (#1265)
Co-authored-by: Laura Trotta <laura.trotta@elastic.co>
1 parent d58de52 commit 5de90a4

4 files changed

Lines changed: 92 additions & 25 deletions

File tree

java-client/src/main/java/co/elastic/clients/elasticsearch/_types/mapping/TextIndexPrefixes.java

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@
2626
import co.elastic.clients.json.JsonpUtils;
2727
import co.elastic.clients.json.ObjectBuilderDeserializer;
2828
import co.elastic.clients.json.ObjectDeserializer;
29-
import co.elastic.clients.util.ApiTypeHelper;
3029
import co.elastic.clients.util.ObjectBuilder;
3130
import co.elastic.clients.util.WithJsonObjectBuilderBase;
3231
import jakarta.json.stream.JsonGenerator;
3332
import java.lang.Integer;
3433
import java.util.Objects;
3534
import java.util.function.Function;
35+
import javax.annotation.Nullable;
3636

3737
//----------------------------------------------------------------
3838
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
@@ -59,16 +59,18 @@
5959
*/
6060
@JsonpDeserializable
6161
public class TextIndexPrefixes implements JsonpSerializable {
62-
private final int maxChars;
62+
@Nullable
63+
private final Integer maxChars;
6364

64-
private final int minChars;
65+
@Nullable
66+
private final Integer minChars;
6567

6668
// ---------------------------------------------------------------------------------------------
6769

6870
private TextIndexPrefixes(Builder builder) {
6971

70-
this.maxChars = ApiTypeHelper.requireNonNull(builder.maxChars, this, "maxChars", 0);
71-
this.minChars = ApiTypeHelper.requireNonNull(builder.minChars, this, "minChars", 0);
72+
this.maxChars = builder.maxChars;
73+
this.minChars = builder.minChars;
7274

7375
}
7476

@@ -77,16 +79,18 @@ public static TextIndexPrefixes of(Function<Builder, ObjectBuilder<TextIndexPref
7779
}
7880

7981
/**
80-
* Required - API name: {@code max_chars}
82+
* API name: {@code max_chars}
8183
*/
82-
public final int maxChars() {
84+
@Nullable
85+
public final Integer maxChars() {
8386
return this.maxChars;
8487
}
8588

8689
/**
87-
* Required - API name: {@code min_chars}
90+
* API name: {@code min_chars}
8891
*/
89-
public final int minChars() {
92+
@Nullable
93+
public final Integer minChars() {
9094
return this.minChars;
9195
}
9296

@@ -101,11 +105,16 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) {
101105

102106
protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
103107

104-
generator.writeKey("max_chars");
105-
generator.write(this.maxChars);
108+
if (this.maxChars != null) {
109+
generator.writeKey("max_chars");
110+
generator.write(this.maxChars);
106111

107-
generator.writeKey("min_chars");
108-
generator.write(this.minChars);
112+
}
113+
if (this.minChars != null) {
114+
generator.writeKey("min_chars");
115+
generator.write(this.minChars);
116+
117+
}
109118

110119
}
111120

@@ -121,8 +130,10 @@ public String toString() {
121130
*/
122131

123132
public static class Builder extends WithJsonObjectBuilderBase<Builder> implements ObjectBuilder<TextIndexPrefixes> {
133+
@Nullable
124134
private Integer maxChars;
125135

136+
@Nullable
126137
private Integer minChars;
127138

128139
public Builder() {
@@ -133,17 +144,17 @@ private Builder(TextIndexPrefixes instance) {
133144

134145
}
135146
/**
136-
* Required - API name: {@code max_chars}
147+
* API name: {@code max_chars}
137148
*/
138-
public final Builder maxChars(int value) {
149+
public final Builder maxChars(@Nullable Integer value) {
139150
this.maxChars = value;
140151
return this;
141152
}
142153

143154
/**
144-
* Required - API name: {@code min_chars}
155+
* API name: {@code min_chars}
145156
*/
146-
public final Builder minChars(int value) {
157+
public final Builder minChars(@Nullable Integer value) {
147158
this.minChars = value;
148159
return this;
149160
}

java-client/src/main/java/co/elastic/clients/elasticsearch/doc-files/api-spec.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2184,7 +2184,7 @@
21842184
'inference.stream_completion.Response': 'inference/stream_completion/StreamInferenceResponse.ts#L22-L25',
21852185
'inference.text_embedding.Request': 'inference/text_embedding/TextEmbeddingRequest.ts#L25-L79',
21862186
'inference.text_embedding.Response': 'inference/text_embedding/TextEmbeddingResponse.ts#L22-L25',
2187-
'inference.update.Request': 'inference/update/UpdateInferenceRequest.ts#L25-L64',
2187+
'inference.update.Request': 'inference/update/UpdateInferenceRequest.ts#L26-L74',
21882188
'inference.update.Response': 'inference/update/UpdateInferenceResponse.ts#L22-L25',
21892189
'ingest._types.AppendProcessor': 'ingest/_types/Processors.ts#L334-L366',
21902190
'ingest._types.AttachmentProcessor': 'ingest/_types/Processors.ts#L368-L419',
@@ -3571,10 +3571,10 @@
35713571
if (hash.length > 1) {
35723572
hash = hash.substring(1);
35733573
}
3574-
window.location = "https://github.com/elastic/elasticsearch-specification/tree/7c4055b7a8e6c585dd8ed999086000838dcdf35e/specification/" + (paths[hash] || "");
3574+
window.location = "https://github.com/elastic/elasticsearch-specification/tree/e889bcfe71d60657cae811fb0b8e105569cc499f/specification/" + (paths[hash] || "");
35753575
</script>
35763576
</head>
35773577
<body>
3578-
Please see the <a href="https://github.com/elastic/elasticsearch-specification/tree/7c4055b7a8e6c585dd8ed999086000838dcdf35e/specification/">Elasticsearch API specification</a>.
3578+
Please see the <a href="https://github.com/elastic/elasticsearch-specification/tree/e889bcfe71d60657cae811fb0b8e105569cc499f/specification/">Elasticsearch API specification</a>.
35793579
</body>
35803580
</html>

java-client/src/main/java/co/elastic/clients/elasticsearch/inference/PutRequest.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,9 @@ public final TaskType taskType() {
171171

172172
/**
173173
* Specifies the amount of time to wait for the inference endpoint to be
174-
* created.
174+
* created. The default depends on the task type: 120s for
175+
* <code>completion</code> and <code>chat_completion</code>, and 30s for all
176+
* other task types.
175177
* <p>
176178
* API name: {@code timeout}
177179
*/
@@ -244,7 +246,9 @@ public final Builder taskType(@Nullable TaskType value) {
244246

245247
/**
246248
* Specifies the amount of time to wait for the inference endpoint to be
247-
* created.
249+
* created. The default depends on the task type: 120s for
250+
* <code>completion</code> and <code>chat_completion</code>, and 30s for all
251+
* other task types.
248252
* <p>
249253
* API name: {@code timeout}
250254
*/
@@ -255,7 +259,9 @@ public final Builder timeout(@Nullable Time value) {
255259

256260
/**
257261
* Specifies the amount of time to wait for the inference endpoint to be
258-
* created.
262+
* created. The default depends on the task type: 120s for
263+
* <code>completion</code> and <code>chat_completion</code>, and 30s for all
264+
* other task types.
259265
* <p>
260266
* API name: {@code timeout}
261267
*/

java-client/src/main/java/co/elastic/clients/elasticsearch/inference/UpdateInferenceRequest.java

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import co.elastic.clients.elasticsearch._types.ErrorResponse;
2323
import co.elastic.clients.elasticsearch._types.RequestBase;
24+
import co.elastic.clients.elasticsearch._types.Time;
2425
import co.elastic.clients.json.JsonpDeserializable;
2526
import co.elastic.clients.json.JsonpDeserializer;
2627
import co.elastic.clients.json.JsonpMapper;
@@ -34,7 +35,6 @@
3435
import jakarta.json.stream.JsonGenerator;
3536
import jakarta.json.stream.JsonParser;
3637
import java.lang.String;
37-
import java.util.Collections;
3838
import java.util.HashMap;
3939
import java.util.Map;
4040
import java.util.Objects;
@@ -85,6 +85,9 @@ public class UpdateInferenceRequest extends RequestBase implements JsonpSerializ
8585
@Nullable
8686
private final TaskType taskType;
8787

88+
@Nullable
89+
private final Time timeout;
90+
8891
private final InferenceEndpoint inferenceConfig;
8992

9093
// ---------------------------------------------------------------------------------------------
@@ -93,6 +96,7 @@ private UpdateInferenceRequest(Builder builder) {
9396

9497
this.inferenceId = ApiTypeHelper.requireNonNull(builder.inferenceId, this, "inferenceId");
9598
this.taskType = builder.taskType;
99+
this.timeout = builder.timeout;
96100
this.inferenceConfig = ApiTypeHelper.requireNonNull(builder.inferenceConfig, this, "inferenceConfig");
97101

98102
}
@@ -120,6 +124,19 @@ public final TaskType taskType() {
120124
return this.taskType;
121125
}
122126

127+
/**
128+
* Specifies the amount of time to wait for the inference endpoint to be
129+
* updated. The default depends on the task type: 120s for
130+
* <code>completion</code> and <code>chat_completion</code>, and 30s for all
131+
* other task types.
132+
* <p>
133+
* API name: {@code timeout}
134+
*/
135+
@Nullable
136+
public final Time timeout() {
137+
return this.timeout;
138+
}
139+
123140
/**
124141
* Required - Request body.
125142
*/
@@ -149,13 +166,17 @@ public static class Builder extends RequestBase.AbstractBuilder<Builder>
149166
@Nullable
150167
private TaskType taskType;
151168

169+
@Nullable
170+
private Time timeout;
171+
152172
private InferenceEndpoint inferenceConfig;
153173

154174
public Builder() {
155175
}
156176
private Builder(UpdateInferenceRequest instance) {
157177
this.inferenceId = instance.inferenceId;
158178
this.taskType = instance.taskType;
179+
this.timeout = instance.timeout;
159180
this.inferenceConfig = instance.inferenceConfig;
160181

161182
}
@@ -179,6 +200,31 @@ public final Builder taskType(@Nullable TaskType value) {
179200
return this;
180201
}
181202

203+
/**
204+
* Specifies the amount of time to wait for the inference endpoint to be
205+
* updated. The default depends on the task type: 120s for
206+
* <code>completion</code> and <code>chat_completion</code>, and 30s for all
207+
* other task types.
208+
* <p>
209+
* API name: {@code timeout}
210+
*/
211+
public final Builder timeout(@Nullable Time value) {
212+
this.timeout = value;
213+
return this;
214+
}
215+
216+
/**
217+
* Specifies the amount of time to wait for the inference endpoint to be
218+
* updated. The default depends on the task type: 120s for
219+
* <code>completion</code> and <code>chat_completion</code>, and 30s for all
220+
* other task types.
221+
* <p>
222+
* API name: {@code timeout}
223+
*/
224+
public final Builder timeout(Function<Time.Builder, ObjectBuilder<Time>> fn) {
225+
return this.timeout(fn.apply(new Time.Builder()).build());
226+
}
227+
182228
/**
183229
* Required - Request body.
184230
*/
@@ -306,7 +352,11 @@ protected static JsonpDeserializer<UpdateInferenceRequest> createUpdateInference
306352

307353
// Request parameters
308354
request -> {
309-
return Collections.emptyMap();
355+
Map<String, String> params = new HashMap<>();
356+
if (request.timeout != null) {
357+
params.put("timeout", request.timeout._toJsonString());
358+
}
359+
return params;
310360

311361
}, SimpleEndpoint.emptyMap(), true, UpdateInferenceResponse._DESERIALIZER);
312362
}

0 commit comments

Comments
 (0)