Skip to content

Milestone 2 REST API Guide

Mangirish Wagle edited this page Feb 28, 2016 · 17 revisions

Team Apex - Remote Job Runner REST API Client

Team Members:

  • Gourav Shenoy
  • Mangirish Wagle
  • Erika Dsouza

REST API Guide

This guide provides the details about the REST APIs provided by the Web Application to manage jobs on the target clusters.

Prerequisites

REST APIs:

Submit Job

  • URL: http://<host>:8080/SGA_Apex/sga/rest/job/submit

  • HTTP Method: POST

  • Request Content-type: application/json OR application/xml

  • Request Format:

    JSON:

    {
      "submitJobRequest":
      {
        "numProcessors": <number of processors>,
        "emailId": "<email id for notification: [email protected]>",
        "numNodes": <number of nodes>,
        "wallTime": "<wall time for the job>",
        "jobName": "<job name e.g. user01>"
      }
    }

    XML:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <submitJobRequest>
        <numProcessors>[number of processors]</numProcessors>
        <emailId>[email id for notification: user@domain.xxx]</emailId>
        <numNodes>[number of nodes]</numNodes>
        <wallTime>[wall time for the job]</wallTime>
        <jobName>[job name e.g. user01]</jobName>
    </submitJobRequest>
  • Response Content Type (Accept Header): application/json OR application/xml

  • Response Format:

    JSON:

    {
      "submitJobResponse":
      {
        "jobId": "<job_id>",
        "status": "Submitted"
      }
    }

    XML:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <submitJobResponse>
      <jobId>[job_id]</jobId>
      <status>Submitted</status>
    </submitJobResponse>

Monitor Job

  • URL: http://<host>:8080/SGA_Apex/sga/rest/job/<job_id>/monitor

  • HTTP Method: GET

  • Response Content Type (Accept Header): application/json OR application/xml

  • Response Format:

    JSON:

    {
        "simpleAPIResponse":
        {
            "message": "Submitted request to monitor job [<job_id>]. You should now receive emails providing you more information about the status of your submitted job.",
            "status": 202
        }
    }

    XML:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <simpleAPIResponse>
      <status>202</status>
      <message>Submitted request to monitor job [<job_id>]. You should now receive emails providing you more information about the status of your submitted job.</message>
    </simpleAPIResponse>

Get Job Status

  • URL: http://<host>:8080/SGA_Apex/sga/rest/job/<job_id>/status

  • HTTP Method: GET

  • Response Content Type (Accept Header): application/json OR application/xml

  • Response Format:

    JSON:

    {
        "jobResponse":
        {
            "queue": "serial",
            "requiredMemory": "--",
            "numProcessors": 12,
            "jobId": "<job_id>",
            "status": "Queued",
            "numNodes": 2,
            "requiredTime": "00:30:00",
            "userName": "<user>",
            "jobName": "<job name>",
            "elapsedTime": "--"
        }
    }
    

    XML:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <jobResponse>
      <jobId>[job_id]</jobId>
      <jobName>[job name]</jobName>
      <userName>[user]</userName>
      <status>Completed</status>
      <requiredTime>00:00:30</requiredTime>
      <elapsedTime>--</elapsedTime>
      <queue>serial</queue>
      <numNodes>2</numNodes>
      <numProcessors>12</numProcessors>
      <requiredMemory>--</requiredMemory>
    </jobResponse>
    

Cancel Job

  • URL: http://<host>:8080/SGA_Apex/sga/rest/job/<job_id>

  • HTTP Method: DELETE

  • Response Content Type (Accept Header): application/json OR application/xml

  • Response Format:

    JSON:

    {
        "simpleAPIResponse":
        {
            "message": "Submitted request to delete job [1245536.m2].",
            "status": 202
        }
    }
    

    XML:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <simpleAPIResponse>
      <status>202</status>
      <message>Submitted request to delete job [1245536.m2].</message>
    </simpleAPIResponse>  

Get Job Output file

  • URL: http://<host>:8080/SGA_Apex/sga/rest/job/<jobName>/output
  • HTTP Method: GET
  • Response: File Contents (File gets downloaded on the client machine).