NAV
http shell

Overview

Chaos Loris is an application that destroys instances of Cloud Foundry applications. The destruction is governed by configuration an schedule of destruction and probability of destruction for a specific instance.

HTTP Verbs

Chaos Loris tries to adhere as closely as possible to standard HTTP and REST conventions in its use of HTTP verbs.

Verb Usage
GET Used to retrieve a resource
POST Used to create a new resource
PATCH Used to update an existing resource, including partial updates
DELETE Used to delete an existing resource

HTTP Status Codes

Chaos Loris tries to adhere as closely as possible to standard HTTP and REST conventions in its use of HTTP status codes.

Status code Usage
200 OK The request completed successfully
201 Created A new resource has been created successfully. The resource’s URI is available from the response’s Location header
204 No Content An update to an existing resource has been applied successfully
400 Bad Request The request was malformed. The response body will include an error providing further information
404 Not Found The requested resource did not exist

Errors

HTTP/1.1 400 Bad Request
Content-Type: application/json;charset=UTF-8
Content-Length: 201

{
  "timestamp" : "2015-11-24T19:20:11.920+0000",
  "status" : 400,
  "error" : "Bad Request",
  "message" : "The schedule 'https://chaos-lemur/schedules/123' does not exist",
  "path" : "/schedules"
}

Whenever an error response (status code >= 400) is returned, the body will contain a JSON object that describes the problem. The error object has the following structure:

Path Type Description
error String The HTTP error that occurred, e.g. Bad Request
message String A description of the cause of the error
path String The path to which the request was made
status Number The HTTP status code, e.g. 400
timestamp String The time, in milliseconds, at which the error occurred

Hypermedia

Chaos Lemur Notes uses hypermedia and resources include links to other resources in their responses. Responses are in Hypertext Application Language (HAL). Links can be found beneath the _links key. Users of the API should not create URIs themselves, instead they should use the above-described links to navigate

Applications

Applications are entites that encapsulate the id of a Cloud Foundry application. Applications can be created, delete, listed, and read.

Create an Application

$ curl 'https://chaos-lemur/applications' -i -X POST -H 'Content-Type: application/json' -d '{
  "applicationId" : "ab42dc01-6868-4859-969d-e2d4dc21419a"
}'
POST /applications HTTP/1.1
Content-Type: application/json
Host: chaos-lemur
Content-Length: 62

{
  "applicationId" : "ab42dc01-6868-4859-969d-e2d4dc21419a"
}
HTTP/1.1 201 Created
Location: https://chaos-lemur/applications/50

Request Fields

Path Type Description Constraints
applicationId String The Cloud Foundry application id Must not be null

Response Headers

Name Description
Location The URI of the newly created application

Delete an Application

$ curl 'https://chaos-lemur/applications/51' -i -X DELETE
DELETE /applications/51 HTTP/1.1
Host: chaos-lemur

HTTP/1.1 204 No Content

Path Parameters

/applications/{id}

Parameter Description
id The application’s id

List Applications

$ curl 'https://chaos-lemur/applications?page=2&size=3' -i -H 'Accept: application/hal+json'
GET /applications?page=2&size=3 HTTP/1.1
Accept: application/hal+json
Host: chaos-lemur

HTTP/1.1 200 OK
Content-Type: application/hal+json
Content-Length: 1142

{
  "_embedded" : {
    "applications" : [ {
      "applicationId" : "af3fa350-8077-43b9-8859-cccd4df9ef7f",
      "_links" : {
        "self" : {
          "href" : "https://chaos-lemur/applications/48"
        }
      }
    }, {
      "applicationId" : "d2322caa-3e6f-4308-90f7-8feb6c516b7c",
      "_links" : {
        "self" : {
          "href" : "https://chaos-lemur/applications/42"
        }
      }
    }, {
      "applicationId" : "e5cc86d0-0d8b-4c5d-a8e0-0401661c9c13",
      "_links" : {
        "self" : {
          "href" : "https://chaos-lemur/applications/47"
        }
      }
    } ]
  },
  "_links" : {
    "first" : {
      "href" : "https://chaos-lemur/applications?page=0&size=3"
    },
    "prev" : {
      "href" : "https://chaos-lemur/applications?page=1&size=3"
    },
    "self" : {
      "href" : "https://chaos-lemur/applications"
    },
    "next" : {
      "href" : "https://chaos-lemur/applications?page=3&size=3"
    },
    "last" : {
      "href" : "https://chaos-lemur/applications?page=3&size=3"
    }
  },
  "page" : {
    "size" : 3,
    "totalElements" : 12,
    "totalPages" : 4,
    "number" : 2
  }
}

Request Parameters

Parameter Description
page Page to retrieve
size Size of the page to retrieve

Response Fields

Path Type Description
page.number Number The number of this page of results
page.size Number The size of this page of results
page.totalPages Number The total number of pages of results
page.totalElements Number The total number of results
_embedded.applications Array A collection of Applications as described in Read an Application
Relation Description
first The first page of results
last The last page of results
next The next page of results
prev The previous page of results

Read an Application

$ curl 'https://chaos-lemur/applications/49' -i -H 'Accept: application/hal+json'
GET /applications/49 HTTP/1.1
Accept: application/hal+json
Host: chaos-lemur

HTTP/1.1 200 OK
Content-Type: application/hal+json
Content-Length: 288

{
  "applicationId" : "89c357dc-e381-41d0-ba6d-9bebfc88eb0f",
  "_links" : {
    "self" : {
      "href" : "https://chaos-lemur/applications/49"
    },
    "chaos" : [ {
      "href" : "https://chaos-lemur/chaoses/24"
    }, {
      "href" : "https://chaos-lemur/chaoses/25"
    } ]
  }
}

Path Parameters

/applications/{id}

Parameter Description
id The application’s id

Response Fields

Path Type Description
applicationId String The Cloud Foundry application id
Relation Description
chaos Chaos instances using this application

Chaoses

Chaoses are entities that enacapsulate an Application, a Schedule, and a probability that an instance will experience chaos on each scheduled event. Chaoses can be created, deleted, listed, read, and updated.

Create a Chaos

$ curl 'https://chaos-lemur/chaoses' -i -X POST -H 'Content-Type: application/json' -d '{
  "schedule" : "http://localhost/schedules/29",
  "application" : "http://localhost/applications/52",
  "probability" : 0.1
}'
POST /chaoses HTTP/1.1
Content-Type: application/json
Host: chaos-lemur
Content-Length: 127

{
  "schedule" : "http://localhost/schedules/29",
  "application" : "http://localhost/applications/52",
  "probability" : 0.1
}
HTTP/1.1 201 Created
Location: https://chaos-lemur/chaoses/26

Request Fields

Path Type Description Constraints
application String The URI of the application to create chaos on Must not be null
probability Number The probability of an instance of the application experiencing chaos Must be at least 0,Must be at most 1,Must not be null
schedule String The URI of the schedule to create chaos on Must not be null

Response Headers

Name Description
Location The URI of the newly created chaos

Delete a Chaos

$ curl 'https://chaos-lemur/chaoses/27' -i -X DELETE
DELETE /chaoses/27 HTTP/1.1
Host: chaos-lemur

HTTP/1.1 204 No Content

Path Parameters

/chaoses/{id}

Parameter Description
id The chaos’ id

List Chaoses

$ curl 'https://chaos-lemur/chaoses?page=2&size=3' -i -H 'Accept: application/hal+json'
GET /chaoses?page=2&size=3 HTTP/1.1
Accept: application/hal+json
Host: chaos-lemur

HTTP/1.1 200 OK
Content-Type: application/hal+json
Content-Length: 1532

{
  "_embedded" : {
    "chaoses" : [ {
      "probability" : 0.1,
      "_links" : {
        "self" : {
          "href" : "https://chaos-lemur/chaoses/34"
        },
        "application" : {
          "href" : "https://chaos-lemur/applications/60"
        },
        "schedule" : {
          "href" : "https://chaos-lemur/schedules/31"
        }
      }
    }, {
      "probability" : 0.1,
      "_links" : {
        "self" : {
          "href" : "https://chaos-lemur/chaoses/35"
        },
        "application" : {
          "href" : "https://chaos-lemur/applications/61"
        },
        "schedule" : {
          "href" : "https://chaos-lemur/schedules/31"
        }
      }
    }, {
      "probability" : 0.1,
      "_links" : {
        "self" : {
          "href" : "https://chaos-lemur/chaoses/36"
        },
        "application" : {
          "href" : "https://chaos-lemur/applications/62"
        },
        "schedule" : {
          "href" : "https://chaos-lemur/schedules/31"
        }
      }
    } ]
  },
  "_links" : {
    "first" : {
      "href" : "https://chaos-lemur/chaoses?page=0&size=3"
    },
    "prev" : {
      "href" : "https://chaos-lemur/chaoses?page=1&size=3"
    },
    "self" : {
      "href" : "https://chaos-lemur/chaoses"
    },
    "next" : {
      "href" : "https://chaos-lemur/chaoses?page=3&size=3"
    },
    "last" : {
      "href" : "https://chaos-lemur/chaoses?page=3&size=3"
    }
  },
  "page" : {
    "size" : 3,
    "totalElements" : 12,
    "totalPages" : 4,
    "number" : 2
  }
}

Request Parameters

Parameter Description
page Page to retrieve
size Size of the page to retrieve

Response Fields

Path Type Description
page.number Number The number of this page of results
page.size Number The size of this page of results
page.totalPages Number The total number of pages of results
page.totalElements Number The total number of results
_embedded.chaoses Array A collection of Chaoses as described in Read a Chaos
Relation Description
first The first page of results
last The last page of results
next The next page of results
prev The previous page of results

Read a Chaos

$ curl 'https://chaos-lemur/chaoses/40' -i -H 'Accept: application/hal+json'
GET /chaoses/40 HTTP/1.1
Accept: application/hal+json
Host: chaos-lemur

HTTP/1.1 200 OK
Content-Type: application/hal+json
Content-Length: 342

{
  "probability" : 0.1,
  "_links" : {
    "self" : {
      "href" : "https://chaos-lemur/chaoses/40"
    },
    "application" : {
      "href" : "https://chaos-lemur/applications/66"
    },
    "schedule" : {
      "href" : "https://chaos-lemur/schedules/32"
    },
    "event" : {
      "href" : "https://chaos-lemur/events/16"
    }
  }
}

Path Parameters

/chaoses/{id}

Parameter Description
id The chaos’ id

Response Fields

Path Type Description
probability Number The probability of an instance of the application experiencing chaos
Relation Description
application The Application to create chaos on
event The Events performed by this chaos
schedule The Schedule to create chaos on

Update a Chaos

$ curl 'https://chaos-lemur/chaoses/41' -i -X PATCH -H 'Content-Type: application/json' -d '{
  "probability" : 0.5
}'
PATCH /chaoses/41 HTTP/1.1
Content-Type: application/json
Host: chaos-lemur
Content-Length: 25

{
  "probability" : 0.5
}
HTTP/1.1 204 No Content

Path Parameters

/chaoses/{id}

Parameter Description
id The chaos’ id

Request Fields

Path Type Description Constraints
probability Number The probability of an instance of the application experiencing chaos Must be at least 0,Must be at most 1

Events

Events are entitues that encapsulate an execution of a Chaos. Events can be deleted, listed, and read.

Delete an Event

$ curl 'https://chaos-lemur/events/17' -i -X DELETE
DELETE /events/17 HTTP/1.1
Host: chaos-lemur

HTTP/1.1 204 No Content

Path Parameters

/events/{id}

Parameter Description
id The event’s id

List Events

$ curl 'https://chaos-lemur/events?page=2&size=3' -i -H 'Accept: application/hal+json'
GET /events?page=2&size=3 HTTP/1.1
Accept: application/hal+json
Host: chaos-lemur

HTTP/1.1 200 OK
Content-Type: application/hal+json
Content-Length: 1613

{
  "_embedded" : {
    "events" : [ {
      "executedAt" : "2015-11-24T19:20:11.732Z",
      "terminatedInstances" : [ 6 ],
      "totalInstanceCount" : 10,
      "terminatedInstanceCount" : 1,
      "_links" : {
        "self" : {
          "href" : "https://chaos-lemur/events/24"
        },
        "chaos" : {
          "href" : "https://chaos-lemur/chaoses/43"
        }
      }
    }, {
      "executedAt" : "2015-11-24T19:20:11.736Z",
      "terminatedInstances" : [ 7 ],
      "totalInstanceCount" : 10,
      "terminatedInstanceCount" : 1,
      "_links" : {
        "self" : {
          "href" : "https://chaos-lemur/events/25"
        },
        "chaos" : {
          "href" : "https://chaos-lemur/chaoses/43"
        }
      }
    }, {
      "executedAt" : "2015-11-24T19:20:11.739Z",
      "terminatedInstances" : [ 8 ],
      "totalInstanceCount" : 10,
      "terminatedInstanceCount" : 1,
      "_links" : {
        "self" : {
          "href" : "https://chaos-lemur/events/26"
        },
        "chaos" : {
          "href" : "https://chaos-lemur/chaoses/43"
        }
      }
    } ]
  },
  "_links" : {
    "first" : {
      "href" : "https://chaos-lemur/events?page=0&size=3"
    },
    "prev" : {
      "href" : "https://chaos-lemur/events?page=1&size=3"
    },
    "self" : {
      "href" : "https://chaos-lemur/events"
    },
    "next" : {
      "href" : "https://chaos-lemur/events?page=3&size=3"
    },
    "last" : {
      "href" : "https://chaos-lemur/events?page=3&size=3"
    }
  },
  "page" : {
    "size" : 3,
    "totalElements" : 12,
    "totalPages" : 4,
    "number" : 2
  }
}

Request Parameters

Parameter Description
page Page to retrieve
size Size of the page to retrieve

Response Fields

Path Type Description
page.number Number The number of this page of results
page.size Number The size of this page of results
page.totalPages Number The total number of pages of results
page.totalElements Number The total number of results
_embedded.events Array A collection of Events as described in Read an Event
Relation Description
first The first page of results
last The last page of results
next The next page of results
prev The previous page of results

Read an Event

$ curl 'https://chaos-lemur/events/30' -i -H 'Accept: application/hal+json'
GET /events/30 HTTP/1.1
Accept: application/hal+json
Host: chaos-lemur

HTTP/1.1 200 OK
Content-Type: application/hal+json
Content-Length: 301

{
  "executedAt" : "2015-11-24T19:20:11.822Z",
  "terminatedInstances" : [ 3 ],
  "totalInstanceCount" : 10,
  "terminatedInstanceCount" : 1,
  "_links" : {
    "self" : {
      "href" : "https://chaos-lemur/events/30"
    },
    "chaos" : {
      "href" : "https://chaos-lemur/chaoses/44"
    }
  }
}

Path Parameters

/events/{id}

Parameter Description
id The event’s id

Response Fields

Path Type Description
executedAt String An ISO-8601 timestamp for when the event occurred
terminatedInstances Array The instances terminated during the event
totalInstanceCount Number The total number of instances that were candidates for termination during the event
terminatedInstanceCount Number The total number of instances terminated during the event
Relation Description
chaos The Chaos that triggered the event

Index

The index provides the main entry point into the service. Users of the service should not need to use any URI other than this, and can access any other entity via links.

$ curl 'https://chaos-lemur/' -i -H 'Accept: application/hal+json'
GET / HTTP/1.1
Accept: application/hal+json
Host: chaos-lemur

HTTP/1.1 200 OK
Content-Type: application/hal+json
Content-Length: 373

{
  "_links" : {
    "self" : {
      "href" : "https://chaos-lemur/"
    },
    "applications" : {
      "href" : "https://chaos-lemur/applications"
    },
    "chaoses" : {
      "href" : "https://chaos-lemur/chaoses"
    },
    "events" : {
      "href" : "https://chaos-lemur/events"
    },
    "schedules" : {
      "href" : "https://chaos-lemur/schedules"
    }
  }
}
Relation Description
applications Link to operations on Applications
chaoses Link to operations on Chaos
events Link to operations on Events
schedules Link to operations on Schedules

Schedules

Schedules are entities that enacapsulate a name and a CRON expression. Schedules can be created, deleted, listed, read, and updated.

Create a Schedule

$ curl 'https://chaos-lemur/schedules' -i -X POST -H 'Content-Type: application/json' -d '{
  "name" : "hourly",
  "expression" : "0 0 * * * *"
}'
POST /schedules HTTP/1.1
Content-Type: application/json
Host: chaos-lemur
Content-Length: 55

{
  "name" : "hourly",
  "expression" : "0 0 * * * *"
}
HTTP/1.1 201 Created
Location: https://chaos-lemur/schedules/37

Request Fields

Path Type Description Constraints
expression String The CRON expression of the schedule Must not be null
name String The user-readable name of the schedule Must not be null

Response Headers

Name Description
Location The URI of the newly created schedule

Delete a Schedule

$ curl 'https://chaos-lemur/schedules/38' -i -X DELETE
DELETE /schedules/38 HTTP/1.1
Host: chaos-lemur

HTTP/1.1 204 No Content

Path Parameters

/schedules/{id}

Parameter Description
id The schedule’s id

List Schedules

$ curl 'https://chaos-lemur/schedules?page=2&size=3' -i -H 'Accept: application/hal+json'
GET /schedules?page=2&size=3 HTTP/1.1
Accept: application/hal+json
Host: chaos-lemur

HTTP/1.1 200 OK
Content-Type: application/hal+json
Content-Length: 1112

{
  "_embedded" : {
    "schedules" : [ {
      "expression" : "0 0 * * * *",
      "name" : "hourly-6",
      "_links" : {
        "self" : {
          "href" : "https://chaos-lemur/schedules/46"
        }
      }
    }, {
      "expression" : "0 0 * * * *",
      "name" : "hourly-7",
      "_links" : {
        "self" : {
          "href" : "https://chaos-lemur/schedules/47"
        }
      }
    }, {
      "expression" : "0 0 * * * *",
      "name" : "hourly-8",
      "_links" : {
        "self" : {
          "href" : "https://chaos-lemur/schedules/48"
        }
      }
    } ]
  },
  "_links" : {
    "first" : {
      "href" : "https://chaos-lemur/schedules?page=0&size=3"
    },
    "prev" : {
      "href" : "https://chaos-lemur/schedules?page=1&size=3"
    },
    "self" : {
      "href" : "https://chaos-lemur/schedules"
    },
    "next" : {
      "href" : "https://chaos-lemur/schedules?page=3&size=3"
    },
    "last" : {
      "href" : "https://chaos-lemur/schedules?page=3&size=3"
    }
  },
  "page" : {
    "size" : 3,
    "totalElements" : 12,
    "totalPages" : 4,
    "number" : 2
  }
}

Request Parameters

Parameter Description
page Page to retrieve
size Size of the page to retrieve

Response Fields

Path Type Description
page.number Number The number of this page of results
page.size Number The size of this page of results
page.totalPages Number The total number of pages of results
page.totalElements Number The total number of results
_embedded.schedules Array A collection of Schedules as described in Read a Schedule
Relation Description
first The first page of results
last The last page of results
next The next page of results
prev The previous page of results

Read a Schedule

$ curl 'https://chaos-lemur/schedules/52' -i -H 'Accept: application/hal+json'
GET /schedules/52 HTTP/1.1
Accept: application/hal+json
Host: chaos-lemur

HTTP/1.1 200 OK
Content-Type: application/hal+json
Content-Length: 278

{
  "expression" : "0 0 * * * *",
  "name" : "hourly",
  "_links" : {
    "self" : {
      "href" : "https://chaos-lemur/schedules/52"
    },
    "chaos" : [ {
      "href" : "https://chaos-lemur/chaoses/45"
    }, {
      "href" : "https://chaos-lemur/chaoses/46"
    } ]
  }
}

Path Parameters

/schedules/{id}

Parameter Description
id The schedule’s id

Response Fields

Path Type Description
expression String The CRON expression of the schedule
name String The user-readable name of the schedule
Relation Description
chaos Chaos instances using this schedule

Update a Schedule

$ curl 'https://chaos-lemur/schedules/39' -i -X PATCH -H 'Content-Type: application/json' -d '{
  "name" : "default"
}'
PATCH /schedules/39 HTTP/1.1
Content-Type: application/json
Host: chaos-lemur
Content-Length: 24

{
  "name" : "default"
}
HTTP/1.1 204 No Content

Path Parameters

/schedules/{id}

Parameter Description
id The schedule’s id

Request Fields

Path Type Description Constraints
expression String The CRON expression of the schedule
name String The user-readable name of the schedule