How to use the REST API Endpoints

Overview

ClusterCockpit offers several REST API Endpoints. While some are integral part of the ClusterCockpit-Stack Workflow (such asstart_job), others are optional. These optional endpoints supplement the functionality of the webinterface with information reachable from scripts or the command line. For example, job metrics could be requested for specific jobs and handled in external statistics programs.

All of the endpoints listed for both administrators and users are secured by JWT authentication. As such, all prerequisites applicable to JSON Web Tokens apply in this case as well, e.g. private and public key setup.

See also the Swagger Reference for more detailed information on each endpoint and the payloads.

Admin Accessible REST API

Admin API Prerequisites

  1. JWT has to be generated by either a dedicated API user (has only api role) or by an administrator with both admin and api roles.
  2. JWTs have a limited lifetime, i.e. will become invalid after a configurable amount of time (see jwt.max-age config option).
  3. Administrator endpoints are additionally subjected to a configurable IP whitelist (see apiAllowedIPs config option). The config option has to be present with at least the wildcard * as only entry or the endpoints will block all requests.

Admin API Endpoints and Functions

EndpointMethodRequest Payload(s)Description
/api/users/GET-Lists all Users
/api/clusters/GET-Lists all Clusters
/api/tags/DELETEJSON PayloadRemoves payload array of tags specified with Type, Name, Scope from DB. Private Tags cannot be removed.
/api/jobs/start_job/POST, PUTJSON PayloadStarts Job
/api/jobs/stop_job/POST, PUTJSON PayloadStops Jobs
/api/jobs/GETURL-Query ParamsLists Jobs
/api/jobs/{id}POST$id, JSON PayloadLoads specified job metadata
/api/jobs/{id}GET$idLoads specified job with metrics
/api/jobs/tag_job/{id}POST, PATCH$id, JSON PayloadAdds payload array of tags specified with Type, Name, Scope to Job with $id. Tags are created in BD.
/api/jobs/tag_job/{id}POST, PATCH$id, JSON PayloadRemoves payload array of tags specified with Type, Name, Scope from Job with $id. Tags remain in DB.
/api/jobs/edit_meta/{id}POST, PATCH$id, JSON PayloadEdits meta_data db colums info
/api/jobs/metrics/{id}GET$id, URL-Query ParamsLoads specified jobmetrics for metric and scope params
/api/jobs/delete_job/DELETEJSON PayloadDeletes job specified in payload
/api/jobs/delete_job/{id}DELETE$id, JSON PayloadDeletes job specified by db id
/api/jobs/delete_job_before/{ts}DELETE$tsDeletes all jobs before specified unix timestamp

User Accessible REST API

User API Prerequisites

  1. JWT has to be generated by either a dedicated API user (Has only api role) or an User with additional api role.
  2. JWTs have a limited lifetime, i.e. will become invalid after a configurable amount of time (see jwt.max-age config option).

User API Endpoints and Functions

EndpointMethodRequestDescription
/userapi/jobs/GETURL-Query ParamsLists Jobs
/userapi/jobs/{id}POST$id, JSON PayloadLoads specified job metadata
/userapi/jobs/{id}GET$idLoads specified job with metrics
/userapi/jobs/metrics/{id}GET$id, URL-Query ParamsLoads specified jobmetrics for metric and scope params