API - Version 2‎ > ‎

Schedules

Schedules are like Cron in the cloud, you can setup recurring schedulers for a task that will be executed on your schedule.



List Schedules

GET /projects/:project_id/schedules

Parameters


In URL:
  • project_id
Required:

Optional:



Request

HTTP GET /2/projects/4eb1b46fcddb13606500000d/schedules?oauth=jTxYQDmMx5ZtVeZBT8jVx6oJDLw




Response

{
    "schedules": [
        {
            "id": "4eb1b490cddb136065000011",
            "Timestamper": {
                "created_at": 1320268944162000000,
                "updated_at": 1320268971000000000
            },
            "project_id": "4eb1b46fcddb13606500000d",
            "api_version": 2,
            "msg": "Ran max times.",
            "status": "complete",
            "error_class": "Patron::HostResolutionError",
            "delay_type": "fixed_delay",
            "code_name": "helloFromPythonOLFSEQETEM",
            "delay": 10,
            "start_at": "2011-11-02T21:22:34Z",
            "end_at": "2262-04-11T23:47:16Z",
            "next_start": "2011-11-02T21:22:34Z",
            "last_run_time": 1320268971000000000,
            "run_times": 1,
            "run_count": 1
        }
    ]
}




Create a Schedule

POST /projects/:project_id/schedules

Parameters


In URL:
  • project_id
In JSON:
  • schedules - required - array of schedules containing:
    • start_at OR delay — required - start_at is time of first run. Delay is number of seconds to wait before starting.
    • name - required - name of schedule. If rescheduled, the new schedule will replace an old one with the same name (NOT IMPLEMENTED YET, but be ready for it).
    • code_name - required - name of code to execute. Name must match the name of a code package previously uploaded.
    • payload - required - data payload for task as a string. Same as payload when queuing up a task
    • run_every — optional - Time in seconds between runs. If omitted, task will only run once.
    • end_at — optional - Time tasks will stop being enqueued. (Should be a Time or DateTime object.)
    • run_times — optional - Number of times to run task. For example, if run_times: is 5, the task will run 5 times.
    • priority — optional - Priority queue to run the job in (0, 1, 2). p0 is default. Run at higher priorities to reduce time jobs may spend in the queue once they come off schedule. Same as priority when queuing up a task.




Request

Minimum Viable Request:

{  
  schedules:[{
    delay:  <int> [seconds],
    code_name: <string>
  }]
}

Annotated Request:

{
  oauth: <token>,
  schedules: [
    {
      delay : <int> [seconds], 
      start_at : <string> [UTC timestamp],
      payload : <payload>,
      name: <schedule_name>,
      code_name: <code_name>
    },
    ...
  ]
}

Example:

{
    "schedules": [
        {
            "delay": 10,
            "code_name": "helloFromPythonOLFSEQETEM"
        }
    ]
}

Response


{
    "msg": "Scheduled",
    "schedules": [
        {
            "id": "4eb1b490cddb136065000011"
        }
    ],
    "status_code": 200
}



Get a Schedule

GET /projects/:project_id/schedules/:schedule_id


Parameters


In URL:
  • project_id
  • schedule_id
Required:

Optional:




Request

HTTP GET /2/projects/4eb1b46fcddb13606500000d/schedules/4eb1b490cddb136065000011?oauth=jTxYQDmMx5ZtVeZBT8jVx6oJDLw




Response

{
    "id": "4eb1b490cddb136065000011",
    "Timestamper": {
        "created_at": 1320268944162000000,
        "updated_at": 1320268971000000000
    },
    "project_id": "4eb1b46fcddb13606500000d",
    "api_version": 2,
    "msg": "Ran max times.",
    "status": "complete",
    "error_class": "Patron::HostResolutionError",
    "delay_type": "fixed_delay",
    "code_name": "helloFromPythonOLFSEQETEM",
    "delay": 10,
    "start_at": "2011-11-02T21:22:34Z",
    "end_at": "2262-04-11T23:47:16Z",
    "next_start": "2011-11-02T21:22:34Z",
    "last_run_time": 1320268971000000000,
    "run_times": 1,
    "run_count": 1
}



Delete a Schedule

DELETE /projects/:project_id/schedules/:schedule_id


Parameters


In URL:
  • project_id
  • schedule_id

Response

{
    "msg": "Deleted"
}


Cancel a Schedule

POST /projects/:project_id/schedules/:schedule_id/cancel

A cancelled schedule will not run, but still shows up on the dashboard.

Parameters


In URL:
  • project_id
  • schedule_id

Response

{
    "msg": "Cancelled"
}


Comments