Skip to content

Commit

Permalink
Undo breaking changes in CatRequestBase
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Farr <tsfarr@amazon.com>
  • Loading branch information
Xtansia committed Feb 21, 2025
1 parent 0d5aa80 commit 5390191
Showing 1 changed file with 26 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,41 +33,39 @@
package org.opensearch.client.opensearch.cat;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.opensearch.client.opensearch._types.RequestBase;
import org.opensearch.client.util.ApiTypeHelper;
import org.opensearch.client.util.ObjectBuilder;

// typedef: cat._types.CatRequestBase

public abstract class CatRequestBase extends RequestBase {
@Nonnull
private final List<String> headers;
@Nonnull
private final List<String> sort;
@Nullable
private final String headers;
@Nullable
private final String sort;

public CatRequestBase() {
this.headers = ApiTypeHelper.undefinedList();
this.sort = ApiTypeHelper.undefinedList();
this.headers = null;
this.sort = null;
}

protected CatRequestBase(AbstractBuilder<?> builder) {
super(builder);
this.headers = ApiTypeHelper.unmodifiable(builder.headers);
this.sort = ApiTypeHelper.unmodifiable(builder.sort);
this.headers = builder.headers;
this.sort = builder.sort;
}

/**
* A comma-separated list of headers to limit the returned information
* <p>
* API name: {@code h}
*/
@Nonnull
@Nullable
public final String headers() {
return String.join(",", this.headers);
return this.headers;
}

/**
Expand All @@ -76,9 +74,9 @@ public final String headers() {
* API name: {@code s}
* <p>
*/
@Nonnull
@Nullable
public final String sort() {
return String.join(",", this.sort);
return this.sort;
}

protected abstract static class CatRequestBaseBuilder<BuilderT extends CatRequestBaseBuilder<BuilderT>> extends AbstractBuilder<
Expand All @@ -89,22 +87,22 @@ protected abstract static class CatRequestBaseBuilder<BuilderT extends CatReques
protected abstract static class AbstractBuilder<BuilderT extends AbstractBuilder<BuilderT>> extends RequestBase.AbstractBuilder<
BuilderT> {
@Nullable
protected List<String> headers;
protected String headers;
@Nullable
protected List<String> sort;
protected String sort;

protected AbstractBuilder() {}

protected AbstractBuilder(CatRequestBase o) {
super(o);
this.headers = _listCopy(o.headers);
this.sort = _listCopy(o.sort);
this.headers = o.headers;
this.sort = o.sort;
}

protected AbstractBuilder(AbstractBuilder<BuilderT> o) {
super(o);
this.headers = _listCopy(o.headers);
this.sort = _listCopy(o.sort);
this.headers = o.headers;
this.sort = o.sort;
}

/**
Expand All @@ -114,32 +112,8 @@ protected AbstractBuilder(AbstractBuilder<BuilderT> o) {
* <p>
*/
@Nonnull
public final BuilderT headers(List<String> values) {
this.headers = _listAddAll(this.headers, values);
return self();
}

/**
* A comma-separated list of specific headers to limits the output
* <p>
* API name: {@code h}
* <p>
*/
@Nonnull
public final BuilderT headers(String value, String... values) {
this.headers = _listAdd(this.headers, value, values);
return self();
}

/**
* A comma-separated list of headers to sort the returned information
* <p>
* API name: {@code s}
* <p>
*/
@Nonnull
public final BuilderT sort(List<String> values) {
this.sort = _listAddAll(this.sort, values);
public final BuilderT headers(@Nullable String headers) {
this.headers = headers;
return self();
}

Expand All @@ -150,20 +124,20 @@ public final BuilderT sort(List<String> values) {
* <p>
*/
@Nonnull
public final BuilderT sort(String value, String... values) {
this.sort = _listAdd(this.sort, value, values);
public final BuilderT sort(@Nullable String sort) {
this.sort = sort;
return self();
}
}

@Override
protected void applyQueryParameters(@Nonnull Map<String, String> params) {
super.applyQueryParameters(params);
if (ApiTypeHelper.isDefined(headers)) {
params.put("h", String.join(",", headers));
if (headers != null && !headers.trim().isEmpty()) {
params.put("h", headers);
}
if (ApiTypeHelper.isDefined(sort)) {
params.put("s", String.join(",", sort));
if (sort != null && !sort.trim().isEmpty()) {
params.put("s", sort);
}
params.put("format", "json");
}
Expand Down

0 comments on commit 5390191

Please sign in to comment.