Skip to content

Commit cb89246

Browse files
authored
Regenerate tasks namespace (#1187)
* Fix codegen integer handling Signed-off-by: Thomas Farr <[email protected]> * Add failing tests Signed-off-by: Thomas Farr <[email protected]> * Begin re-generating `tasks.ListRequest` and `TaskExecutingNode` renaming `State` to `TaskInfo` Signed-off-by: Thomas Farr <[email protected]> * Simplify client request methods Signed-off-by: Thomas Farr <[email protected]> * Re-generate _types.Retries Signed-off-by: Thomas Farr <[email protected]> * Handle types that are used in both abstract and concrete contexts Signed-off-by: Thomas Farr <[email protected]> * Re-generate tasks.ListResponse Signed-off-by: Thomas Farr <[email protected]> * Regenerate tasks.cancel Signed-off-by: Thomas Farr <[email protected]> * Regenerate tasks.get Signed-off-by: Thomas Farr <[email protected]> * spotless Signed-off-by: Thomas Farr <[email protected]> * Fixes Signed-off-by: Thomas Farr <[email protected]> --------- Signed-off-by: Thomas Farr <[email protected]>
1 parent 4133a94 commit cb89246

File tree

86 files changed

+6283
-2778
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+6283
-2778
lines changed

CHANGELOG.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
33

44
## [Unreleased 3.0]
55
### Dependencies
6-
- Bumps `org.junit:junit-bom` from 5.10.2 to 5.11.0
76
- Bumps `org.owasp.dependencycheck` from 10.0.2 to 10.0.4
87
- Bumps `org.eclipse.parsson:parsson` from 1.1.6 to 1.1.7
98
- Bumps `org.hamcrest:hamcrest` from 2.2 to 3.0
@@ -21,6 +20,7 @@ This section is for maintaining a changelog for all breaking changes for the cli
2120
- Changed SearchAfter of SearchRequest type to FieldValue instead of String ([#769](https://github.com/opensearch-project/opensearch-java/pull/769))
2221
- Changed type of `DanglingIndex`'s `creationDateMillis` field from `String` to `long` ([#1124](https://github.com/opensearch-project/opensearch-java/pull/1124))
2322
- Changed type of `ShardStatistics`'s `total`, `successful`, `failed` & `skipped` fields from `Number` to `int/Integer` ([#1158](https://github.com/opensearch-project/opensearch-java/pull/1158))
23+
- Unified `tasks.Info` and `tasks.State` classes into `tasks.TaskInfo` ([#1187](https://github.com/opensearch-project/opensearch-java/pull/1187))
2424

2525
### Deprecated
2626
- Deprecate RestClientTransport ([#536](https://github.com/opensearch-project/opensearch-java/pull/536))
@@ -29,7 +29,7 @@ This section is for maintaining a changelog for all breaking changes for the cli
2929

3030
### Fixed
3131
- Fix version and build ([#254](https://github.com/opensearch-project/opensearch-java/pull/254))
32-
- Fix queries not preserving boost and name when converted to builders ([#1181](https://github.com/opensearch-project/opensearch-java/pull/1181))
32+
- Fixed deserializing `tasks.ListResponse` when using `GroupBy.None` ([#1187](https://github.com/opensearch-project/opensearch-java/pull/1187))
3333

3434
### Security
3535

@@ -38,6 +38,7 @@ This section is for maintaining a changelog for all breaking changes for the cli
3838
### Added
3939

4040
### Dependencies
41+
- Bumps `org.junit:junit-bom` from 5.10.3 to 5.11.0
4142

4243
### Changed
4344

@@ -46,6 +47,7 @@ This section is for maintaining a changelog for all breaking changes for the cli
4647
### Removed
4748

4849
### Fixed
50+
- Fix queries not preserving boost and name when converted to builders ([#1181](https://github.com/opensearch-project/opensearch-java/pull/1181))
4951

5052
### Security
5153

UPGRADING.md

+16-1
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,19 @@ After:
2727

2828
### ShardStatistics properties types
2929
- The type of the `total`, `successful` and `failed` fields has been corrected from `Number` to `int`.
30-
- The type of the `skipped` field has been corrected from `Number` to `Integer`.
30+
- The type of the `skipped` field has been corrected from `Number` to `Integer`.
31+
32+
### Unified tasks.Info & tasks.State classes into tasks.TaskInfo
33+
- The `tasks.Info` and `tasks.State` classes have been unified into `tasks.TaskInfo`, this affects:
34+
- `TaskExecutingNode`'s `tasks` field.
35+
- `GetTasksResponse`'s `task` field.
36+
- `core.update_by_query_rethrottle.UpdateByQueryRethrottleNode`'s `tasks` field.
37+
- The `headers` field is now a `Map<String, String>` instead of a `Map<String, List<String>>`.
38+
39+
### tasks.ListResponse properties lifted to tasks.TaskListResponseBase
40+
- All fields previously defined on `tasks.ListResponse` have been lifted to `tasks.TaskListResponseBase`.
41+
- `DeleteByQueryRethrottleResponse` now extends `tasks.TaskListResponseBase` instead of `tasks.ListResponse`.
42+
- The `tasks` field is now a `TaskInfos` union type instead of a `Map<String, Info>` to correctly handle `groupBy` parents or none.
43+
44+
### GetTasksResponse response type
45+
- The type of `GetTasksResponse`'s `response` field has been changed from `tasks.Status` to `tasks.TaskResponse`.

java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchAsyncClientBase.java

+5
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import org.opensearch.client.opensearch.core.InfoResponse;
4747
import org.opensearch.client.opensearch.dangling_indices.OpenSearchDanglingIndicesAsyncClient;
4848
import org.opensearch.client.opensearch.ml.OpenSearchMlAsyncClient;
49+
import org.opensearch.client.opensearch.tasks.OpenSearchTasksAsyncClient;
4950
import org.opensearch.client.transport.OpenSearchTransport;
5051
import org.opensearch.client.transport.TransportOptions;
5152

@@ -68,6 +69,10 @@ public OpenSearchMlAsyncClient ml() {
6869
return new OpenSearchMlAsyncClient(this.transport, this.transportOptions);
6970
}
7071

72+
public OpenSearchTasksAsyncClient tasks() {
73+
return new OpenSearchTasksAsyncClient(this.transport, this.transportOptions);
74+
}
75+
7176
// ----- Endpoint: info
7277

7378
/**

java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchClientBase.java

+5
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import org.opensearch.client.opensearch.core.InfoResponse;
4646
import org.opensearch.client.opensearch.dangling_indices.OpenSearchDanglingIndicesClient;
4747
import org.opensearch.client.opensearch.ml.OpenSearchMlClient;
48+
import org.opensearch.client.opensearch.tasks.OpenSearchTasksClient;
4849
import org.opensearch.client.transport.OpenSearchTransport;
4950
import org.opensearch.client.transport.TransportOptions;
5051

@@ -67,6 +68,10 @@ public OpenSearchMlClient ml() {
6768
return new OpenSearchMlClient(this.transport, this.transportOptions);
6869
}
6970

71+
public OpenSearchTasksClient tasks() {
72+
return new OpenSearchTasksClient(this.transport, this.transportOptions);
73+
}
74+
7075
// ----- Endpoint: info
7176

7277
/**

java-client/src/generated/java/org/opensearch/client/opensearch/_types/AcknowledgedResponseBase.java

+1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ public final BuilderT acknowledged(boolean value) {
101101

102102
protected abstract BuilderT self();
103103
}
104+
104105
// ---------------------------------------------------------------------------------------------
105106

106107
protected static <BuilderT extends AbstractBuilder<BuilderT>> void setupAcknowledgedResponseBaseDeserializer(

java-client/src/main/java/org/opensearch/client/opensearch/_types/BaseNode.java renamed to java-client/src/generated/java/org/opensearch/client/opensearch/_types/BaseNode.java

+45-29
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,16 @@
3030
* GitHub history for details.
3131
*/
3232

33+
//----------------------------------------------------
34+
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
35+
//----------------------------------------------------
36+
3337
package org.opensearch.client.opensearch._types;
3438

3539
import jakarta.json.stream.JsonGenerator;
3640
import java.util.List;
3741
import java.util.Map;
42+
import javax.annotation.Generated;
3843
import javax.annotation.Nullable;
3944
import org.opensearch.client.json.JsonpDeserializer;
4045
import org.opensearch.client.json.JsonpMapper;
@@ -43,32 +48,35 @@
4348
import org.opensearch.client.util.ApiTypeHelper;
4449
import org.opensearch.client.util.ObjectBuilderBase;
4550

46-
// typedef: _spec_utils.BaseNode
51+
// typedef: _types.BaseNode
4752

53+
@Generated("org.opensearch.client.codegen.CodeGenerator")
4854
public abstract class BaseNode implements PlainJsonSerializable {
55+
4956
private final Map<String, String> attributes;
5057

58+
@Nullable
5159
private final String host;
5260

61+
@Nullable
5362
private final String ip;
5463

5564
private final String name;
5665

5766
private final List<NodeRole> roles;
5867

68+
@Nullable
5969
private final String transportAddress;
6070

6171
// ---------------------------------------------------------------------------------------------
6272

6373
protected BaseNode(AbstractBuilder<?> builder) {
64-
6574
this.attributes = ApiTypeHelper.unmodifiable(builder.attributes);
6675
this.host = builder.host;
6776
this.ip = builder.ip;
68-
this.name = builder.name;
77+
this.name = ApiTypeHelper.requireNonNull(builder.name, this, "name");
6978
this.roles = ApiTypeHelper.unmodifiable(builder.roles);
7079
this.transportAddress = builder.transportAddress;
71-
7280
}
7381

7482
/**
@@ -81,19 +89,21 @@ public final Map<String, String> attributes() {
8189
/**
8290
* API name: {@code host}
8391
*/
92+
@Nullable
8493
public final String host() {
8594
return this.host;
8695
}
8796

8897
/**
8998
* API name: {@code ip}
9099
*/
100+
@Nullable
91101
public final String ip() {
92102
return this.ip;
93103
}
94104

95105
/**
96-
* API name: {@code name}
106+
* Required - API name: {@code name}
97107
*/
98108
public final String name() {
99109
return this.name;
@@ -109,37 +119,41 @@ public final List<NodeRole> roles() {
109119
/**
110120
* API name: {@code transport_address}
111121
*/
122+
@Nullable
112123
public final String transportAddress() {
113124
return this.transportAddress;
114125
}
115126

116127
/**
117128
* Serialize this object to JSON.
118129
*/
130+
@Override
119131
public void serialize(JsonGenerator generator, JsonpMapper mapper) {
120132
generator.writeStartObject();
121133
serializeInternal(generator, mapper);
122134
generator.writeEnd();
123135
}
124136

125137
protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
126-
127138
if (ApiTypeHelper.isDefined(this.attributes)) {
128139
generator.writeKey("attributes");
129140
generator.writeStartObject();
130141
for (Map.Entry<String, String> item0 : this.attributes.entrySet()) {
131142
generator.writeKey(item0.getKey());
132143
generator.write(item0.getValue());
133-
134144
}
135145
generator.writeEnd();
146+
}
136147

148+
if (this.host != null) {
149+
generator.writeKey("host");
150+
generator.write(this.host);
137151
}
138-
generator.writeKey("host");
139-
generator.write(this.host);
140152

141-
generator.writeKey("ip");
142-
generator.write(this.ip);
153+
if (this.ip != null) {
154+
generator.writeKey("ip");
155+
generator.write(this.ip);
156+
}
143157

144158
generator.writeKey("name");
145159
generator.write(this.name);
@@ -151,36 +165,35 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
151165
item0.serialize(generator, mapper);
152166
}
153167
generator.writeEnd();
154-
155168
}
156-
generator.writeKey("transport_address");
157-
generator.write(this.transportAddress);
158169

170+
if (this.transportAddress != null) {
171+
generator.writeKey("transport_address");
172+
generator.write(this.transportAddress);
173+
}
159174
}
160175

176+
// ---------------------------------------------------------------------------------------------
177+
161178
protected abstract static class AbstractBuilder<BuilderT extends AbstractBuilder<BuilderT>> extends ObjectBuilderBase {
162179
@Nullable
163180
private Map<String, String> attributes;
164-
165181
@Nullable
166182
private String host;
167-
168183
@Nullable
169184
private String ip;
170-
171-
@Nullable
172185
private String name;
173-
174186
@Nullable
175187
private List<NodeRole> roles;
176-
177188
@Nullable
178189
private String transportAddress;
179190

180191
/**
181192
* API name: {@code attributes}
193+
*
182194
* <p>
183-
* Adds all entries of <code>map</code> to <code>attributes</code>.
195+
* Adds all elements of <code>map</code> to <code>attributes</code>.
196+
* </p>
184197
*/
185198
public final BuilderT attributes(Map<String, String> map) {
186199
this.attributes = _mapPutAll(this.attributes, map);
@@ -189,8 +202,10 @@ public final BuilderT attributes(Map<String, String> map) {
189202

190203
/**
191204
* API name: {@code attributes}
205+
*
192206
* <p>
193207
* Adds an entry to <code>attributes</code>.
208+
* </p>
194209
*/
195210
public final BuilderT attributes(String key, String value) {
196211
this.attributes = _mapPut(this.attributes, key, value);
@@ -200,21 +215,21 @@ public final BuilderT attributes(String key, String value) {
200215
/**
201216
* API name: {@code host}
202217
*/
203-
public final BuilderT host(String value) {
218+
public final BuilderT host(@Nullable String value) {
204219
this.host = value;
205220
return self();
206221
}
207222

208223
/**
209224
* API name: {@code ip}
210225
*/
211-
public final BuilderT ip(String value) {
226+
public final BuilderT ip(@Nullable String value) {
212227
this.ip = value;
213228
return self();
214229
}
215230

216231
/**
217-
* API name: {@code name}
232+
* Required - API name: {@code name}
218233
*/
219234
public final BuilderT name(String value) {
220235
this.name = value;
@@ -223,8 +238,10 @@ public final BuilderT name(String value) {
223238

224239
/**
225240
* API name: {@code roles}
241+
*
226242
* <p>
227243
* Adds all elements of <code>list</code> to <code>roles</code>.
244+
* </p>
228245
*/
229246
public final BuilderT roles(List<NodeRole> list) {
230247
this.roles = _listAddAll(this.roles, list);
@@ -233,8 +250,10 @@ public final BuilderT roles(List<NodeRole> list) {
233250

234251
/**
235252
* API name: {@code roles}
253+
*
236254
* <p>
237255
* Adds one or more values to <code>roles</code>.
256+
* </p>
238257
*/
239258
public final BuilderT roles(NodeRole value, NodeRole... values) {
240259
this.roles = _listAdd(this.roles, value, values);
@@ -244,25 +263,22 @@ public final BuilderT roles(NodeRole value, NodeRole... values) {
244263
/**
245264
* API name: {@code transport_address}
246265
*/
247-
public final BuilderT transportAddress(String value) {
266+
public final BuilderT transportAddress(@Nullable String value) {
248267
this.transportAddress = value;
249268
return self();
250269
}
251270

252271
protected abstract BuilderT self();
253-
254272
}
255273

256274
// ---------------------------------------------------------------------------------------------
257-
protected static <BuilderT extends AbstractBuilder<BuilderT>> void setupBaseNodeDeserializer(ObjectDeserializer<BuilderT> op) {
258275

276+
protected static <BuilderT extends AbstractBuilder<BuilderT>> void setupBaseNodeDeserializer(ObjectDeserializer<BuilderT> op) {
259277
op.add(AbstractBuilder::attributes, JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.stringDeserializer()), "attributes");
260278
op.add(AbstractBuilder::host, JsonpDeserializer.stringDeserializer(), "host");
261279
op.add(AbstractBuilder::ip, JsonpDeserializer.stringDeserializer(), "ip");
262280
op.add(AbstractBuilder::name, JsonpDeserializer.stringDeserializer(), "name");
263281
op.add(AbstractBuilder::roles, JsonpDeserializer.arrayDeserializer(NodeRole._DESERIALIZER), "roles");
264282
op.add(AbstractBuilder::transportAddress, JsonpDeserializer.stringDeserializer(), "transport_address");
265-
266283
}
267-
268284
}

0 commit comments

Comments
 (0)