Skip to content

Lambda Request

Gaurav Sharma edited this page Nov 8, 2018 · 1 revision

Two ways to execute jobs

  • Send JSON request to execute a job (POST)

  • Hit REST API (GET) with alias name (Uses XML Configuration)

  • Method 1 (JSON Request)

    URL Path - http://localhost:8080/lambda/post/execute

    • path - Path to the script/program

    • alias - name for this job

    • commandType - This is the command you use to execute the script eg. sh, java, bash

    • argsCommandType - args for commandType eg. -jar, -x

    • command - The name of the script you want to execute

    • argsCommand - args for your program

    {
        "path": "/Users/gaurav/Downloads/",
        "alias":"testPost",
        "commandType":"sh",
        "command":"TestScript.sh",
        "waitTime": "32"
    
    }

    Test it by this command -

    curl --header "Content-Type: application/json" --request POST  --data '{"path": "/Users/gaurav/Downloads/", "alias":"testPost", "commandType":"sh", "command":"TestScript.sh", "waitTime": "32"}' http://localhost:8080/lambda/post/execute
    
  • Method 2 (XML)

    Create the configuration

    Create a configuration file in /usr/local/var/rest-lambda/Configuration.

    Name - rest_lambda_jobs.xml

    Content of the XML -

         <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
        <ns2:restConfiguration xmlns:ns2="com.gaurav.rest.lambda.configuration">
            <restJobs>
            <!--Rest Job with custom command type-->
                <restJob>
                    <args-command>dataForScript</args-command>
                    <args-command-type>-x</args-command-type>
                    <alias>testJob1</alias>
                    <command>TestScript.sh</command>
                    <commandType>bash</commandType>
                    <path>/Users/gaurav/Downloads/</path>
                    <waitTime>20</waitTime>
                </restJob>
    
                 <!--Rest Job with Batch (Windows) command type-->
                <restJob>
                    <args-command>dataForScript_1</args-command>
                    <args-command>dataForScript_2</args-command>
                    <args-command-type>/c</args-command-type>
                    <alias>testJob2</alias>
                    <command>TestBatch.bat</command>
                    <commandType>BATCH</commandType>
                    <path>C://testbat.bat</path>
                    <waitTime>20</waitTime>
                </restJob>
    
                     <!--Rest Job with Java command type-->
                <restJob>
                    <args-command>dataForScript_1</args-command>
                    <args-command>dataForScript_2</args-command>
                    <args-command-type>-jar</args-command-type>
                    <alias>testJob3</alias>
                    <command>/testJar.jar</command>
                    <commandType>JAVA</commandType>
                    <path>/usr/local/var</path>
                    <waitTime>20</waitTime>
                </restJob>
            </restJobs>
        </ns2:restConfiguration>
Clone this wiki locally