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

Removing unsupported dynamic_templates option for bulk #276

Merged
merged 2 commits into from
Nov 17, 2022
Merged
Show file tree
Hide file tree
Changes from all 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: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
### Deprecated

### Removed

- Removed support for unsupported dynamic_templates in bulk ([#276](https://github.com/opensearch-project/opensearch-java/pull/276))
### Fixed

### Security
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,14 @@
import org.opensearch.client.json.JsonpDeserializer;
import org.opensearch.client.json.JsonpMapper;
import org.opensearch.client.json.ObjectDeserializer;
import org.opensearch.client.util.ApiTypeHelper;
import jakarta.json.stream.JsonGenerator;
import java.util.Map;
import javax.annotation.Nullable;

// typedef: _global.bulk.WriteOperation



public abstract class WriteOperation extends BulkOperationBase {
private final Map<String, String> dynamicTemplates;

@Nullable
private final String pipeline;
Expand All @@ -62,22 +59,11 @@ public abstract class WriteOperation extends BulkOperationBase {
protected WriteOperation(AbstractBuilder<?> builder) {
super(builder);

this.dynamicTemplates = ApiTypeHelper.unmodifiable(builder.dynamicTemplates);
this.pipeline = builder.pipeline;
this.requireAlias = builder.requireAlias;

}

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

/**
* API name: {@code pipeline}
*/
@Nullable
public final String pipeline() {
return this.pipeline;
Expand All @@ -94,17 +80,6 @@ public final Boolean requireAlias() {
protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

super.serializeInternal(generator, mapper);
if (ApiTypeHelper.isDefined(this.dynamicTemplates)) {
generator.writeKey("dynamic_templates");
generator.writeStartObject();
for (Map.Entry<String, String> item0 : this.dynamicTemplates.entrySet()) {
generator.writeKey(item0.getKey());
generator.write(item0.getValue());

}
generator.writeEnd();

}
if (this.pipeline != null) {
generator.writeKey("pipeline");
generator.write(this.pipeline);
Expand All @@ -121,35 +96,13 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
protected abstract static class AbstractBuilder<BuilderT extends AbstractBuilder<BuilderT>>
extends
BulkOperationBase.AbstractBuilder<BuilderT> {
@Nullable
private Map<String, String> dynamicTemplates;

@Nullable
private String pipeline;

@Nullable
private Boolean requireAlias;

/**
* API name: {@code dynamic_templates}
* <p>
* Adds all entries of <code>map</code> to <code>dynamicTemplates</code>.
*/
public final BuilderT dynamicTemplates(Map<String, String> map) {
this.dynamicTemplates = _mapPutAll(this.dynamicTemplates, map);
return self();
}

/**
* API name: {@code dynamic_templates}
* <p>
* Adds an entry to <code>dynamicTemplates</code>.
*/
public final BuilderT dynamicTemplates(String key, String value) {
this.dynamicTemplates = _mapPut(this.dynamicTemplates, key, value);
return self();
}

/**
* API name: {@code pipeline}
*/
Expand All @@ -172,8 +125,6 @@ public final BuilderT requireAlias(@Nullable Boolean value) {
protected static <BuilderT extends AbstractBuilder<BuilderT>> void setupWriteOperationDeserializer(
ObjectDeserializer<BuilderT> op) {
BulkOperationBase.setupBulkOperationBaseDeserializer(op);
op.add(AbstractBuilder::dynamicTemplates,
JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.stringDeserializer()), "dynamic_templates");
op.add(AbstractBuilder::pipeline, JsonpDeserializer.stringDeserializer(), "pipeline");
op.add(AbstractBuilder::requireAlias, JsonpDeserializer.booleanDeserializer(), "require_alias");

Expand Down