token

More info about the token schema can be found here.

Note

This resource can also be accessed using the plural form tokens.

Note

All operations on the token resource can only be performed with an administrator token.

GET

GET /token/(string: token)

Get all the available tokens or a single one if token is provided.

Parameters:
  • token (string) – The token whose values to retrieve.
Request Headers:
 
Response Headers:
 
Query Parameters:
 
  • limit (int) – Number of results to return. Default 0 (all results).
  • skip (int) – Number of results to skip. Default 0 (none).
  • sort (string) – Field to sort the results on. Can be repeated multiple times.
  • sort_order (int) – The sort order of the results: -1 (descending), 1 (ascending). This will be applied only to the first sort parameter passed. Default -1.
  • date_range (int) – Number of days to consider, starting from today (more info). By default consider all results.
  • field (string) – The field that should be returned in the response. Can be repeated multiple times.
  • nfield (string) – The field that should not be returned in the response. Can be repeated multiple times.
  • _id (string) – The internal ID of the token object.
  • created_on (string) – The creation date: accepted formats are YYYY-MM-DD and YYYYMMDD.
  • email (string) – The email address associated with the token.
  • expired (boolean) – If the token is expired or not.
  • username (string) – The user name associated with the token.
Status Codes:

Example Requests

GET /token/ HTTP/1.1
Host: api.kernelci.org
Accept: */*
Authorization: token
GET /token/12345-12345-12345 HTTP/1.1
Host: api.kernelci.org
Accept: */*
Authorization: token

Example Responses

HTTP/1.1 200 OK
Vary: Accept-Encoding
Date: Mon, 06 Feb 2015 15:12:50 GMT
Content-Type: application/json; charset=UTF-8

{
    "code": 200,
    "result": [
        {
            "created_on": {
                "$date": 1407818315043},
            "email": "email@example.net",
            "token": "12345-12345-12345",
            "expired": false
        }
    ]
}

Note

Results shown here do not include the full JSON response.

POST

POST /token

Create a token as defined in the JSON data.

For more info on all the required JSON request fields, see the JSON token schema for POST requests.

Note

When creating the first token to be stored in the database, you must use the configured master key.

Request JSON Object:
 
  • email (string) – The email associated with the token (required only when creating a new token).
  • username (string) – The user name associated with the token.
  • admin (string) – If the token is an administrator one (it automatically sets GET/DELETE/POST/PUT operations)
  • superuser (string) – If the token is a super user one (a super user cannot create new tokens, but can perform GET/DELETE/POST/PUT operations).
  • get (boolean) – If the token can perform GET operations.
  • post (boolean) – If the token can perform POST/PUT operations.
  • delete (boolean) – If the token can perform DELETE operations.
  • upload (boolean) – If the token can be used to upload files.
  • ip_restricted (boolean) – If the token is restricted to be used on certain IP addresses.
  • ip_address (array) – Array of IP addresses the token is restricted to.
  • lab (boolean) – If the token is a boot lab one.
  • test_lab (boolean) – If the token is a test lab one.
Request Headers:
 
Response Headers:
 
Status Codes:

Example Requests

POST /token HTTP/1.1
Host: api.kernelci.org
Content-Type: application/json
Accept: */*
Authorization: token

{
    "email": "email@example.net",
    "admin": 1,
    "ip_restricted": 1,
    "ip_address": ["192.168.2.1"]
}

PUT

PUT /token/(string: token_id)

Update an existing token identified by its token_id with the values provided in the JSON data.

The token_id value is different from the token value itself: the token_id is the internal ID as provided by the database.

For more info on all the required JSON request fields, see the JSON token schema for POST requests.

Request JSON Object:
 
  • email (string) – The email associated with the token (required only when creating a new token).
  • username (string) – The user name associated with the token.
  • admin (string) – If the token is an administrator one (it automatically sets GET/DELETE/POST/PUT operations)
  • superuser (string) – If the token is a super user one (a super user cannot create new tokens, but can perform GET/DELETE/POST/PUT operations).
  • get (boolean) – If the token can perform GET operations.
  • post (boolean) – If the token can perform POST/PUT operations.
  • delete (boolean) – If the token can perform DELETE operations.
  • upload (boolean) – If the token can be used to upload files.
  • ip_restricted (boolean) – If the token is restricted to be used on certain IP addresses.
  • ip_address (array) – Array of IP addresses the token is restricted to.
  • lab (boolean) – If the token is a boot lab one.
  • test_lab (boolean) – If the token is a test lab one.
Request Headers:
 
Response Headers:
 
Status Codes:

Example Requests

POST /token/12345-12345-12345 HTTP/1.1
Host: api.kernelci.org
Content-Type: application/json
Accept: */*
Authorization: token

{
    "upload": 1
}

DELETE

DELETE /token/(string: token_id)

Delete the token identified by its token_id.

The token_id value is different from the token value itself: the token_id is the internal ID as provided by the database.

Parameters:
  • token_id (string) – The token ID as provided by the database.
Request Headers:
 
Response Headers:
 
Status Codes:

Example Requests

DELETE /token/abcdefghi HTTP/1.1
Host: api.kernelci.org
Accept: */*
Content-Type: application/json
Authorization: token