Api Endpoints

api/gates/<group_name>/<service_name>

POST

POST api/gates/<group_name>/<service_name>

This endpoint will create a new service with the environments given.

If the group does not exists, it will be created and represented as its own tab.

Default values for all gates is open.

Your Service name must be unique in that group. The gate name must not contain dots.

Example request:

POST /services/awesome_service HTTP/1.1
Content-Type: application/json

{
  "environments": [
      "testing",
      "my_live_gate"
  ]
}

Positiv response:

HTTP/1.1 200 OK
Content-Type: application/json

{
  "status": "ok"
}
Request Headers:
 
Response Headers:
 
Status Codes:

PUT

PUT api/gates/<group_name>/<service_name>

Let you update a single service.

If your payload includes name, group and/or environments it will update the given.

Example request:

POST /services/awesome_service HTTP/1.1
Content-Type: application/json

{
  "name": "new_awesome_name",
  "environments": [
      "totally_new_environment"
  ]
}

Positiv response:

HTTP/1.1 200 OK
Content-Type: application/json

{
  "group": "new_awesome_name",
  "name": "team_12",
  "environments": {
    "totally_new_environment": {
      "queue": [],
      "message_timestamp": "",
      "state": "open",
      "message": "",
      "state_timestamp": "2016-04-27 22:29:49+0200"
    }
  }
}
Request Headers:
 
Response Headers:
 
Status Codes:

GET

GET api/gates/<group_name>/<service_name>

Will get you the state of the gates in json format.

Example request:

GET api/gates/team_12/awesome_service HTTP/1.1
Accept: application/json

Example response:

HTTP/1.1 200 OK
Content-Type: application/json

{
  "group": "awesome_service",
  "name": "team_12",
  "environments": {
    "develop": {
      "queue": [],
      "message_timestamp": "",
      "state": "open",
      "message": "",
      "state_timestamp": "2016-04-27 22:29:49+0200"
    }
  }
}
Request Headers:
 
Response Headers:
 
Status Codes:

DELETE

DELETE api/gates/<group_name>/<service_name>

Will remove a service.

Example request:

DELETE api/gates/team_12/awesome_service HTTP/1.1
Accept: application/json

Example response:

HTTP/1.1 200 OK
Content-Type: application/json

{
  "status": "ok"
}

Error response:

HTTP/1.1 400 BAD REQUEST
Content-Type: application/json

{
  "status": "error"
  "reason": "Json was not valid"
}
Request Headers:
 
Response Headers:
 
Status Codes:

api/gates/<group_name>/<service_name>/<environment>

PUT

PUT api/gates/<group_name>/<service_name>/<environment>

Lets you set the state of one environment.

If your payload includes ‘state’, ‘message’ it will update the given.

Only valid options for state are open and close.

Example request:

PUT api/services/awesome_service/live HTTP/1.1
Content-Type: application/json

{
  "state": "closed",
  "message": "I want to do some testing. -Jens"
}

Positiv response:

HTTP/1.1 200 OK
Content-Type: application/json

{
  "status": "ok"
}
Request Headers:
 
Response Headers:
 
Status Codes:

api/gates

PUT

PUT api/gates

With this you can close multiple gates at once and it provides a test-and-set functionality, which means that you only get a positive response if none of the gates you asking for is already closed.

This is useful if you want two gates to be mutually exclusive.

As example we do not want to deploy our pipeline, if a deployment is currently in progress.

Example request:

PUT api/services HTTP/1.1
Content-Type: application/json

{
  "gates": {
    "team_applications": {
      "service_12": ["live"]
    },
    "team_pipelines": {
      "service_12_pipeline": ["live"]
    }
  },
  "link": "https://github.com/otto-de/gatekeeper"
}

Positiv response:

HTTP/1.1 200 OK
Content-Type: application/json

{
  "status": "ok",
  "ticket": {
    "expiration_date": 1461833574.495491,
    "updated": "2016-04-27 22:52:54+0200",
    "id": "ec3fe716-2cc1-4a56-908b-7348910dbce0",
    "link": "https://github.com/otto-de/gatekeeper"
  }
}

Negativ response:

HTTP/1.1 200 OK
Content-Type: application/json

{
  "status": "denied"
}

Queued response:

If the queue=true query is used and the gate is closed, you receive “queued” as response.

In queue the ticket you get will be valid for 2 minutes. With every subsequent requests that includes the ticket id the tickets expiration date will be refreshed.

Ticket lifetime for tickets in queue and in front of the queue can be configured.

If the gate was closed manually the status will still be “denied”.

HTTP/1.1 200 OK
Content-Type: application/json

{
  "status": "queue",
  "ticket": {
    "expiration_date": 1453799405.26424,
    "updated": "2016-01-26 09:35:18+0100",
    "link": "https://github.com/otto-de/gatekeeper",
    "id": "4ca72ee9-82b9-48c5-bf66-994ac907386b"
  }
}

Example request with queued ticket:

To include your ticket id use the following request structure:

PUT api/services HTTP/1.1
Content-Type: application/json

{
  "gates": {
    "team_applications": {
      "service_12": ["live"]
    },
    "team_pipelines": {
      "service_12_pipeline": ["live"]
    }
  },
  "ticket": "4ca72ee9-82b9-48c5-bf66-994ac907386b"
}

Positiv Queued response:

HTTP/1.1 200 OK
Content-Type: application/json

{
  "status": "ok",
  "ticket": {
    "expiration_date": 0,
    "updated": "2016-01-26 09:35:18+0100",
    "link": "https://github.com/otto-de/gatekeeper",
    "id": "4ca72ee9-82b9-48c5-bf66-994ac907386b"
  }
}

Negativ Queued response:

HTTP/1.1 200 OK
Content-Type: application/json

{
  "status": "denied"
}

Still Queued response:

If its not yet your turn, the status will remain as queue.

HTTP/1.1 200 OK
Content-Type: application/json

{
  "status": "queue",
  "ticket": {
    "expiration_date": 1453799405.26424,
    "updated": "2016-01-26 09:35:18+0100",
    "link": "https://github.com/otto-de/gatekeeper",
    "id": "4ca72ee9-82b9-48c5-bf66-994ac907386b"
  }
}
Query Parameters:
 
  • queue=true – creates a ticket and uses queueing
Request Headers:
 
Response Headers:
 
Status Codes:

api/tickets/<ticket_id>

DELETE

DELETE api/tickets/<ticket_id>

This end

Example request:

DELETE api/tickets/8fb0cefd-34b9-4094-8cb4-8198e4f95737 HTTP/1.1
Accept: application/json

Positiv response:

HTTP/1.1 200 OK
Content-Type: application/json

{
  "status": "ok"
}
Status Codes: