Skip to content

Commit

Permalink
mend
Browse files Browse the repository at this point in the history
Signed-off-by: Amit Galitzky <[email protected]>
  • Loading branch information
amitgalitz committed Nov 6, 2023
1 parent 7374672 commit 9539ae0
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.opensearch.env.NodeEnvironment;
import org.opensearch.flowframework.indices.FlowFrameworkIndicesHandler;
import org.opensearch.flowframework.rest.RestCreateWorkflowAction;
import org.opensearch.flowframework.rest.RestGetWorkflowAction;
import org.opensearch.flowframework.rest.RestProvisionWorkflowAction;
import org.opensearch.flowframework.transport.CreateWorkflowAction;
import org.opensearch.flowframework.transport.CreateWorkflowTransportAction;
Expand Down Expand Up @@ -96,7 +97,7 @@ public List<RestHandler> getRestHandlers(
IndexNameExpressionResolver indexNameExpressionResolver,
Supplier<DiscoveryNodes> nodesInCluster
) {
return ImmutableList.of(new RestCreateWorkflowAction(), new RestProvisionWorkflowAction());
return ImmutableList.of(new RestCreateWorkflowAction(), new RestProvisionWorkflowAction(), new RestGetWorkflowAction());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class RestCreateWorkflowAction extends BaseRestHandler {
private static final String CREATE_WORKFLOW_ACTION = "create_workflow_action";

/**
* Intantiates a new RestCreateWorkflowAction
* Instantiates a new RestCreateWorkflowAction
*/
public RestCreateWorkflowAction() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import org.opensearch.client.node.NodeClient;
import org.opensearch.core.rest.RestStatus;
import org.opensearch.flowframework.exception.FlowFrameworkException;
import org.opensearch.flowframework.transport.ProvisionWorkflowAction;
import org.opensearch.flowframework.transport.GetWorkflowAction;
import org.opensearch.flowframework.transport.WorkflowRequest;
import org.opensearch.rest.BaseRestHandler;
import org.opensearch.rest.RestRequest;
Expand Down Expand Up @@ -51,7 +51,6 @@ protected BaseRestHandler.RestChannelConsumer prepareRequest(RestRequest request
if (request.hasContent()) {
throw new FlowFrameworkException("Invalid request format", RestStatus.BAD_REQUEST);
}

// Validate params
String workflowId = request.param(WORKFLOW_ID);
if (workflowId == null) {
Expand All @@ -60,17 +59,16 @@ protected BaseRestHandler.RestChannelConsumer prepareRequest(RestRequest request

String rawPath = request.rawPath();
boolean all = request.paramAsBoolean("_all", false);

// Create request and provision
WorkflowRequest workflowRequest = new WorkflowRequest(workflowId, null, all);
return channel -> client.execute(ProvisionWorkflowAction.INSTANCE, workflowRequest, new RestToXContentListener<>(channel));
return channel -> client.execute(GetWorkflowAction.INSTANCE, workflowRequest, new RestToXContentListener<>(channel));
}

@Override
public List<Route> routes() {
return ImmutableList.of(
// Provision workflow from indexed use case template
new Route(RestRequest.Method.POST, String.format(Locale.ROOT, "%s/{%s}/%s", WORKFLOW_URI, WORKFLOW_ID, "_status"))
new Route(RestRequest.Method.GET, String.format(Locale.ROOT, "%s/{%s}/%s", WORKFLOW_URI, WORKFLOW_ID, "_status"))
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public GetWorkflowResponse(WorkflowState workflowState, boolean allStatus) {
this.workflowState = workflowState;
} else {
this.workflowState = new WorkflowState.Builder().workflowId(workflowState.getWorkflowId())
.error(workflowState.getWorkflowId())
.state(workflowState.getWorkflowId())
.error(workflowState.getError())
.state(workflowState.getState())
.build();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public WorkflowRequest(@Nullable String workflowId, @Nullable Template template)
public WorkflowRequest(@Nullable String workflowId, @Nullable Template template, boolean all) {
this.workflowId = workflowId;
this.template = template;
this.all = false;
this.all = all;
}

/**
Expand Down

0 comments on commit 9539ae0

Please sign in to comment.