Skip to content

Commit

Permalink
Allow YAML Templates (#296)
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Widdis <[email protected]>
  • Loading branch information
dbwiddis committed Dec 18, 2023
1 parent a7aa712 commit eb91263
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,9 @@ public void writeTo(StreamOutput output) throws IOException {
}

/**
* Parse raw json content into a Template instance.
* Parse raw xContent into a Template instance.
*
* @param parser json based content parser
* @param parser xContent based content parser
* @return an instance of the template
* @throws IOException if content can't be parsed correctly
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.opensearch.core.rest.RestStatus;
import org.opensearch.core.xcontent.ToXContent;
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.core.xcontent.XContentParser;
import org.opensearch.flowframework.common.FlowFrameworkFeatureEnabledSetting;
import org.opensearch.flowframework.exception.FlowFrameworkException;
import org.opensearch.flowframework.model.Template;
Expand All @@ -30,6 +31,7 @@
import java.util.List;
import java.util.Locale;

import static org.opensearch.core.xcontent.XContentParserUtils.ensureExpectedToken;
import static org.opensearch.flowframework.common.CommonValue.DRY_RUN;
import static org.opensearch.flowframework.common.CommonValue.PROVISION_WORKFLOW;
import static org.opensearch.flowframework.common.CommonValue.WORKFLOW_ID;
Expand Down Expand Up @@ -89,7 +91,9 @@ protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient cli
);
}
try {
Template template = Template.parse(request.content().utf8ToString());
XContentParser parser = request.contentParser();
ensureExpectedToken(XContentParser.Token.START_OBJECT, parser.nextToken(), parser);
Template template = Template.parse(parser);
boolean dryRun = request.paramAsBoolean(DRY_RUN, false);
boolean provision = request.paramAsBoolean(PROVISION_WORKFLOW, false);

Expand Down

0 comments on commit eb91263

Please sign in to comment.