Scheduled Jobs
Scheduled jobs are recurring tasks that run on a cron schedule. You can create, read, update, and delete them, as well as list available job actions.
| Verb | URL | Action |
|---|---|---|
GET | /@scheduled-jobs | List all scheduled jobs |
GET | /@scheduled-jobs/{id} | Get a specific scheduled job |
POST | /@scheduled-jobs | Create a new scheduled job |
PATCH | /@scheduled-jobs/{id} | Update a scheduled job |
DELETE | /@scheduled-jobs/{id} | Delete a scheduled job |
GET | /@scheduled-job-actions | List available job actions |
Scheduled job schema
A scheduled job object has the following properties:
| Property | Type | Description |
|---|---|---|
@id | string | Unique IRI for the scheduled job |
id | string | ID of the scheduled job |
title | string | Human-readable title |
description | string | Human-readable description |
action | string | The action to execute |
params | object | Parameters passed to the job action |
schedule | string | Cron expression defining the schedule |
List all scheduled jobs
To retrieve all scheduled jobs, send a GET request to the /@scheduled-jobs endpoint:
GET /@scheduled-jobs HTTP/1.1
Accept: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbiIsImZ1bGxuYW1lIjoiQWRtaW4iLCJpYXQiOjE2NDkzMTI0NDl9.RS1Ny_r0v7vIylFfK6q0JVJrkiDuTOh9iG9IL8xbzAk
Or use the client directly:
import { Client } from '@robgietema/nick';
const cli = Client.initialize({ apiPath: 'http://localhost:8080' });
const login = await cli.login({
data: { login: 'admin', password: 'admin' },
});
const { data } = await cli.getScheduledJobs({
token: login.data.token,
});
Response:
HTTP/1.1 200 OK
Content-Type: application/json
[
{
"id": "reindex-events",
"title": "Reindex Events",
"description": "Reindex all events",
"action": "reindex",
"params": {
"type": "Event"
},
"schedule": "0 0 * * *"
}
]
Get a specific scheduled job
To retrieve a single scheduled job by its ID, send a GET request to the /@scheduled-jobs/{id} endpoint:
GET /@scheduled-jobs/reindex-events HTTP/1.1
Accept: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbiIsImZ1bGxuYW1lIjoiQWRtaW4iLCJpYXQiOjE2NDkzMTI0NDl9.RS1Ny_r0v7vIylFfK6q0JVJrkiDuTOh9iG9IL8xbzAk
Or use the client directly:
import { Client } from '@robgietema/nick';
const cli = Client.initialize({ apiPath: 'http://localhost:8080' });
const login = await cli.login({
data: { login: 'admin', password: 'admin' },
});
const { data } = await cli.getScheduledJob({
token: login.data.token,
params: { id: 'reindex-events' },
});
Response:
HTTP/1.1 200 OK
Content-Type: application/json
{
"@id": "http://localhost:8080/@scheduled-jobs/reindex-events",
"id": "reindex-events",
"title": "Reindex Events",
"description": "Reindex all events",
"action": "reindex",
"params": {
"type": "Event"
},
"schedule": "0 0 * * *"
}
Create a scheduled job
To create a new scheduled job, send a POST request to the /@scheduled-jobs endpoint with a JSON payload:
POST /@scheduled-jobs HTTP/1.1
Accept: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbiIsImZ1bGxuYW1lIjoiQWRtaW4iLCJpYXQiOjE2NDkzMTI0NDl9.RS1Ny_r0v7vIylFfK6q0JVJrkiDuTOh9iG9IL8xbzAk
Content-Type: application/json
{
"id": "reindex-pages",
"title": "Reindex Pages",
"description": "Reindex all pages",
"action": "reindex",
"params": {
"type": "Page"
},
"schedule": "0 0 * * *"
}
Or use the client directly:
import { Client } from '@robgietema/nick';
const cli = Client.initialize({ apiPath: 'http://localhost:8080' });
const login = await cli.login({
data: { login: 'admin', password: 'admin' },
});
const { data } = await cli.createScheduledJob({
token: login.data.token,
data: {
id: 'reindex-pages',
title: 'Reindex Pages',
description: 'Reindex all pages',
action: 'reindex',
params: {
type: 'Page',
},
schedule: '0 0 * * *',
},
});
Response:
HTTP/1.1 201 Created
Content-Type: application/json
{
"@id": "http://localhost:8080/@scheduled-jobs/reindex-pages",
"id": "reindex-pages",
"title": "Reindex Pages",
"description": "Reindex all pages",
"action": "reindex",
"params": {
"type": "Page"
},
"schedule": "0 0 * * *"
}
Update a scheduled job
To update an existing scheduled job, send a PATCH request to the /@scheduled-jobs/{id} endpoint with a JSON payload:
PATCH /@groups/nicks HTTP/1.1
Accept: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbiIsImZ1bGxuYW1lIjoiQWRtaW4iLCJpYXQiOjE2NDkzMTI0NDl9.RS1Ny_r0v7vIylFfK6q0JVJrkiDuTOh9iG9IL8xbzAk
Content-Type: application/json
{
"id": "reindex-pages",
"title": "Reindex More Pages",
"description": "Reindex all pages",
"action": "reindex",
"params": {
"type": "Page"
},
"schedule": "0 0 * * *"
}
Or use the client directly:
import { Client } from '@robgietema/nick';
const cli = Client.initialize({ apiPath: 'http://localhost:8080' });
const login = await cli.login({
data: { login: 'admin', password: 'admin' },
});
const { data } = await cli.updateScheduledJob({
token: login.data.token,
id: 'reindex-pages',
data: {
id: 'reindex-pages',
title: 'Reindex More Pages',
description: 'Reindex all pages',
action: 'reindex',
params: {
type: 'Page',
},
schedule: '0 0 * * *',
},
});
Response:
HTTP/1.1 204 No Content
Delete a scheduled job
To delete a scheduled job, send a DELETE request to the /@scheduled-jobs/{id} endpoint:
DELETE /@scheduled-jobs/reindex-pages HTTP/1.1
Accept: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbiIsImZ1bGxuYW1lIjoiQWRtaW4iLCJpYXQiOjE2NDkzMTI0NDl9.RS1Ny_r0v7vIylFfK6q0JVJrkiDuTOh9iG9IL8xbzAk
Or use the client directly:
import { Client } from '@robgietema/nick';
const cli = Client.initialize({ apiPath: 'http://localhost:8080' });
const login = await cli.login({
data: { login: 'admin', password: 'admin' },
});
const { data } = await cli.deleteScheduledJob({
token: login.data.token,
params: {
id: 'reindex-pages',
},
});
Response:
HTTP/1.1 204 No Content
List available job actions
To retrieve all available scheduled job actions, send a GET request to the /@scheduled-job-actions endpoint:
GET /@scheduled-job-actions HTTP/1.1
Accept: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbiIsImZ1bGxuYW1lIjoiQWRtaW4iLCJpYXQiOjE2NDkzMTI0NDl9.RS1Ny_r0v7vIylFfK6q0JVJrkiDuTOh9iG9IL8xbzAk
Or use the client directly:
import { Client } from '@robgietema/nick';
const cli = Client.initialize({ apiPath: 'http://localhost:8080' });
const login = await cli.login({
data: { login: 'admin', password: 'admin' },
});
const { data } = await cli.getScheduledJobActions({
token: login.data.token,
});
Response:
HTTP/1.1 200 OK
Content-Type: application/json
[
{
"@schema": {
"fieldsets": [
{
"fields": [
"type"
],
"id": "default",
"title": "Default"
}
],
"properties": {
"type": {
"additionalItems": true,
"description": "The content type to reindex.",
"factory": "Multiple Choice",
"items": {
"description": "",
"factory": "Choice",
"title": "",
"type": "string",
"vocabulary": {
"@id": "types"
}
},
"title": "Content type",
"type": "array",
"uniqueItems": true
}
},
"required": [
"type"
],
"type": "object"
},
"addview": "reindex",
"description": "Reindex items based on type",
"title": "Reindex items"
}
]