Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing issues when deserializing response for tasks API #463

Merged
merged 3 commits into from
May 3, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
## [Unreleased 2.x]

### Added
- Add workflow to publish snapshots via GHA ([#454](https://github.com/opensearch-project/opensearch-java/pull/454))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to be not related?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was added to make it consistent with the Changelog on 2.x branch.


### Dependencies

Expand All @@ -36,6 +37,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
### Fixed
- Fix missing Highlight and SourceConfig in the MultisearchBody ([#442](https://github.com/opensearch-project/opensearch-java/pull/442))
- Fix search failure with missing required property HitsMetadata.total when trackTotalHits is disabled ([#372](https://github.com/opensearch-project/opensearch-java/pull/372))
- Fix failure when deserialing response for tasks API ([#463](https://github.com/opensearch-project/opensearch-java/pull/463))

### Security

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,38 +67,38 @@ public abstract class BaseNode implements JsonpSerializable {

protected BaseNode(AbstractBuilder<?> builder) {

this.attributes = ApiTypeHelper.unmodifiableRequired(builder.attributes, this, "attributes");
this.host = ApiTypeHelper.requireNonNull(builder.host, this, "host");
this.ip = ApiTypeHelper.requireNonNull(builder.ip, this, "ip");
this.name = ApiTypeHelper.requireNonNull(builder.name, this, "name");
this.attributes = ApiTypeHelper.unmodifiable(builder.attributes);
this.host = builder.host;
this.ip = builder.ip;
this.name = builder.name;
this.roles = ApiTypeHelper.unmodifiable(builder.roles);
this.transportAddress = ApiTypeHelper.requireNonNull(builder.transportAddress, this, "transportAddress");
this.transportAddress = builder.transportAddress;

}

/**
* Required - API name: {@code attributes}
* API name: {@code attributes}
*/
public final Map<String, String> attributes() {
return this.attributes;
}

/**
* Required - API name: {@code host}
* API name: {@code host}
*/
public final String host() {
return this.host;
}

/**
* Required - API name: {@code ip}
* API name: {@code ip}
*/
public final String ip() {
return this.ip;
}

/**
* Required - API name: {@code name}
* API name: {@code name}
*/
public final String name() {
return this.name;
Expand All @@ -112,7 +112,7 @@ public final List<NodeRole> roles() {
}

/**
* Required - API name: {@code transport_address}
* API name: {@code transport_address}
*/
public final String transportAddress() {
return this.transportAddress;
Expand Down Expand Up @@ -180,7 +180,7 @@ protected abstract static class AbstractBuilder<BuilderT extends AbstractBuilder
private String transportAddress;

/**
* Required - API name: {@code attributes}
* API name: {@code attributes}
VachaShah marked this conversation as resolved.
Show resolved Hide resolved
* <p>
* Adds all entries of <code>map</code> to <code>attributes</code>.
*/
Expand All @@ -190,7 +190,7 @@ public final BuilderT attributes(Map<String, String> map) {
}

/**
* Required - API name: {@code attributes}
* API name: {@code attributes}
* <p>
* Adds an entry to <code>attributes</code>.
*/
Expand All @@ -200,23 +200,23 @@ public final BuilderT attributes(String key, String value) {
}

/**
* Required - API name: {@code host}
* API name: {@code host}
*/
public final BuilderT host(String value) {
this.host = value;
return self();
}

/**
* Required - API name: {@code ip}
* API name: {@code ip}
*/
public final BuilderT ip(String value) {
this.ip = value;
return self();
}

/**
* Required - API name: {@code name}
* API name: {@code name}
*/
public final BuilderT name(String value) {
this.name = value;
Expand Down Expand Up @@ -244,7 +244,7 @@ public final BuilderT roles(NodeRole value, NodeRole... values) {
}

/**
* Required - API name: {@code transport_address}
* API name: {@code transport_address}
*/
public final BuilderT transportAddress(String value) {
this.transportAddress = value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,22 @@
import static org.hamcrest.Matchers.anEmptyMap;

import java.io.IOException;
import java.util.Arrays;

import org.opensearch.client.opensearch.nodes.NodesStatsResponse;
import org.opensearch.client.opensearch.tasks.ListRequest;
import org.opensearch.client.opensearch.tasks.ListResponse;

public abstract class AbstractNodesIT extends OpenSearchJavaClientTestCase {
public void testNodesStats() throws IOException {
final NodesStatsResponse response = javaClient().nodes().stats();
assertThat(response.clusterName(), not(nullValue()));
assertThat(response.nodes(), not(anEmptyMap()));
}

public void testNodesList() throws IOException {
ListRequest listRequest = new ListRequest.Builder().actions(Arrays.asList("*reindex")).build();
ListResponse listResponse = javaClient().tasks().list();
assertThat(listResponse.nodes(), not(anEmptyMap()));
}
}