Flux REST API

You can use the Flux REST API to interact with a Flux Cluster using an HTTP interface. Complete documentation for the REST API (including input and output payload details for each API) is available in the directory /doc/restapidoc located under your Flux installation directory.

A REST Java client API is also available, allowing Java developers to utilize REST using standard Java development techniques. You can find complete Javadoc documentation for these APIs in the /doc/clusterapidoc directory in your Flux installation directory.

To use the REST Java client APIs, just add the file restaction.jar (included in the /lib directory under your Flux installation directory) to your Java class path, as well as the flux.jar file located in the Flux installation directory itself.

The example code below demonstrates how you might use the REST Java client APIs:

import flux.*;
import fluxopsconsole.Cluster;
 
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
public class RestJavaClient { 
  public static void main(String[] args) throws Exception {    
    // Flux Helper   
    EngineHelper helper = Factory.makeInstance().makeEngineHelper();
     
    // Create a flow chart   
    FlowChart flowChart = helper.makeFlowChart("/Order Processing");    
 
    // Add variables to flow chart   
    Map<String, String> variables = new HashMap<String, String>();   
    variables.put("order_num""4589");   
    flowChart.getVariableManager().putAll(variables);
 
    // Create a manual trigger    
    ManualTrigger manualTrigger = flowChart.makeManualTrigger("manual trigger");   
 
    // Create a console action
    ConsoleAction consoleAction = flowChart.makeConsoleAction("console action");   
    consoleAction.setMessage("Order expedited for ${order_num}");   
    consoleAction.println();   
    manualTrigger.addFlow(consoleAction);    
 
    // Create a Cluster instance   
    fluxopsconsole.Cluster cluster = new Cluster("http://localhost:7186");   
    cluster.login("admin""admin");
 
    // Schedule a job
    String name = cluster.put(flowChart);   
    System.out.println("Added job " + name + " to engine.");    
 
    // Query the status of the flow chart   
    List<fluxopsconsole.FlowChartInfo> flowChartInfos = cluster.getFlowCharts(name, nullnullnullnull110);   
    System.out.println("Status : " + flowChartInfos.get(0).getActionInfo().get(0).getSubState());    
 
    // Wait for 2 secs and query status again   
    Thread.sleep(2000);   
    flowChartInfos = cluster.getFlowCharts(name, nullnullnullnull110);   
    System.out.println("Status : " + flowChartInfos.get(0).getActionInfo().get(0).getSubState());    
 
    // Expedite the flow chart   
    long count = cluster.expediteNamespace(name);   
    System.out.println("Expedited : " + count);   
    cluster.logout();
  }
}
 
 
Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.