Skip to content

Commit

Permalink
Removing unsupported dynamic_templates option for bulk (opensearch-pr…
Browse files Browse the repository at this point in the history
…oject#276)

* Removing unsupported dynamic_templates option

Signed-off-by: Vacha Shah <vachshah@amazon.com>

* Update CHANGELOG

Signed-off-by: Vacha Shah <vachshah@amazon.com>

Signed-off-by: Vacha Shah <vachshah@amazon.com>
  • Loading branch information
VachaShah authored Nov 17, 2022
1 parent fcdfa93 commit 52679c3
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 50 deletions.
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

0 comments on commit 52679c3

Please sign in to comment.