Skip to content

Instantly share code, notes, and snippets.

@natbusa
Last active August 29, 2015 14:20
Show Gist options
  • Save natbusa/24f62bfd7a6423366fb7 to your computer and use it in GitHub Desktop.
Save natbusa/24f62bfd7a6423366fb7 to your computer and use it in GitHub Desktop.
Gist REST Json API
// creation flow
POST /api/actors
{
"data" : {
"type": "actors",
"attributes": {
"type": "threashold",
"params": {
"threashold": 2.5
}
},
"links" : {
"trigger": {
"linkage" : { "type": "actors", "id":"9"}
}
}
}
}
// read
// meta and id generated server side
GET /api/actors/12
{
"data" : {
"type": "actors",
"id": "12"
"attributes": {
"type": "threashold",
"params": {
"threashold": 2.5
}
},
"links" : {
"trigger": {
"linkage" : { "type": "actors", "id":"9", "meta": "http://coral.io/api/actors/9" }
}
}
}
}
// full modify
POST/PUT /api/actors/12
{
"data" : {
"type": "actors",
"id": "12"
"attributes": {
"type": "threashold",
"params": {
"threashold": 2.5
}
},
"links" : {
"trigger": {
"linkage" : { "type": "actors", "id":"5" }
}
}
}
}
// partial modify the resource
PATCH /api/actors/12
{
"data" : {
"attributes": {
"params": {
"threashold": 3.5
}
}
}
}
// modify the trigger
PATCH /api/actors/12
{
"data" : {
"links" : {
"trigger": {
"linkage" : { "type": "actors", "id":"7" }
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment