Janitor API

A simple JSON API to interact with Janitor containers, hosts and projects.

Hosts

List hosts

GET /api/hosts

List all cluster hosts owned by the authenticated user.

Response

[
  "example.com"
]

Get a single host

GET /api/hosts/:hostname

Input

GET /api/hosts/example.com

Response

{
  "port": "2376",
  "ca": "",
  "crt": "",
  "key": ""
}

Create a host

POST /api/hosts/:hostname

Create a new host and add it to the cluster.

Input

POST /api/hosts/example.com
Content-Type: application/json

{
  "port": "2376"
}

Show host credentials

GET /api/hosts/:hostname/credentials

Show a host's OAuth2 client credentials.

Input

GET /api/hosts/example.com/credentials

Response

{
  "id": "1234",
  "secret": "123456"
}

Reset host credentials

DELETE /api/hosts/:hostname/credentials

Reset a host's OAuth2 client secret.

Input

DELETE /api/hosts/example.com/credentials

List host images

GET /api/hosts/:hostname/images

List the Docker images available on this host.

Show host version

GET /api/hosts/:hostname/version

Input

GET /api/hosts/example.com/version

Response

{
  "docker": {
    "Version": "17.06.0-ce"
  }
}

Containers

List containers

GET /api/hosts/:hostname/containers

List all Docker containers on this host.

Create a container

PUT /api/hosts/:hostname/containers

Update a container

PATCH /api/hosts/:hostname/containers/:container

Update the properties of a given Docker container.

Input

PATCH /api/hosts/example.com/containers/abcdef0123456789

[
  {
    "op": "replace",
    "path": "/name",
    "value": "Much container. Such wow."
  }
]

Response

{
  "name": "Much container. Such wow."
}

Delete a container

DELETE /api/hosts/:hostname/containers/:container

List changed files in a container

GET /api/hosts/:hostname/containers/:container/changes

List all files that were modified (Kind: 0), added (1) or deleted (2) in a given Docker container.

Input

GET /api/hosts/example.com/containers/abcdef0123456789/changes

Response

[
  {
    "Path": "/tmp",
    "Kind": 0
  },
  {
    "Path": "/tmp/test",
    "Kind": 1
  }
]

Get a single container port

GET /api/hosts/:hostname/containers/:container/:port

Get the properties of a given Docker container port.

Input

GET /api/hosts/example.com/containers/abcdef0123456789/8088

Response

{
  "port": 42001,
  "proxy": "https"
}

Projects

List projects

GET /api/projects

List all the software projects supported by this Janitor instance.

Response

[
  "test-project"
]

Pull a project

POST /api/projects/:project/pull

Trigger a Docker image pull for a given software project.

Input

POST /api/projects/test-project/pull

Response

{
  "image": "image:latest",
  "created": 1500000000000
}

User

Get the authenticated user

GET /api/user

Response

{
  "name": "User"
}

Update the authenticated user

PATCH /api/user

Update the user's profile information (with JSON Patch).

Input

PATCH /api/user

[
  {
    "op": "add",
    "path": "/name",
    "value": "Different Name"
  }
]

Response

{
  "name": "Different Name"
}

Get all user configurations

GET /api/user/configurations

Response

{
  ".gitconfig": "[user]\nname = User"
}

Update user configurations

PATCH /api/user/configurations

Update any user configuration file(s) (using JSON Patch).

Input

PATCH /api/user/configurations

[
  {
    "op": "add",
    "path": "/.gitconfig",
    "value": "[user]\nname = Sally"
  }
]

Response

{
  ".gitconfig": "[user]\nname = Sally"
}

Reset a user configuration

DELETE /api/user/configurations/:file

Reset a user configuration file to its default template value.

Input

DELETE /api/user/configurations/.gitconfig

Response

Status: 204 No Content

Deploy a user configuration

PUT /api/user/configurations/:file

Install or overwrite a configuration file in all the user's containers (any local changes will be lost!)

Input

PUT /api/user/configurations/.gitconfig

Response

{
  "message": "Successfully deployed to 1 container"
}

Delete user credentials

DELETE /api/user/credentials/:type

Input

DELETE /api/user/credentials/github

Response

Status: 204 No Content

Get all user notifications

GET /api/user/notifications

Response

[]

Get the notification settings of the user

GET /api/user/notifications/enabled

Response

{
  "enabled": false
}

Enable or disable user notifications

PUT /api/user/notifications/enabled

Input

PUT /api/user/notifications/enabled

{ "enabled": true }

Response

{
  "enabled": true
}

Admin

List OAuth2 providers

GET /api/admin/oauth2providers

Response

{
  "github": {
    "id": "1234",
    "secret": "123456",
    "hostname": "github.com",
    "api": "api.github.com"
  }
}

Update an OAuth2 provider

PATCH /api/admin/oauth2providers/:provider

Update an OAuth2 provider configuration (with JSON Patch).

Input

PATCH /api/admin/oauth2providers/github

[
  {
    "op": "add",
    "path": "/secret",
    "value": "654321"
  }
]

Response

{
  "id": "1234",
  "secret": "654321",
  "hostname": "github.com",
  "api": "api.github.com"
}