User Service

A simple rest based service, backed by Neo4J, to store information on users and relationships between them.

Installation

$ virtualenv ve
$ source ve/bin/activate
(ve)$ pip install -e .
(ve)$ twistd -n user-service \
        --endpoint=tcp:8081 \
        --database-connection-string=http://localhost:7474

API

GET /users/

Search for an existing user node.

Query Parameters:
 
  • username (string) – the username (optional).
  • msisdn (string) – the MSISDN (optional).
  • email_address (string) – the email address (optional).

Note

All three query string parameters are optional but at least one must be specified.

Response Headers:
 
  • Content-Type – will always be application/json.
Status Codes:
  • 200 – as this query cannot fail, it may return an empty result.
HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json

[
    {
        "user_id": "uuid1",
        "username": "the username",
        "msisdn": "27000000001",
        "email_address": "email@domain2.com"
    },
    {
        "user_id": "uuid2",
        "username": "the username",
        "msisdn": "27000000002",
        "email_address": "email@domain2.com"
    }
]
POST /users/

Create a new user node.

Json Parameters:
 
  • username (string) – The user’s username.
  • msisdn (string) – The user’s MSISDN.
  • email_address (string) – The user’s email address.
Response Headers:
 
  • Content-Type – will always be application/json.
Status Codes:
PUT /users/(uuid: user_id)/

Update a user node.

Json Parameters:
 
  • username (string) – The user’s username.
  • msisdn (string) – The user’s MSISDN.
  • email_address (string) – The user’s email address.
Response Headers:
 
  • Content-Type – will always be application/json.
Status Codes:
  • 200 – when update was successful.
  • 400 – when json parameters are invalid or missing.
HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json

{
    "user_id": "uuid",
    "username": "the username",
    "msisdn": "27000000000",
    "email_address": "email@domain.com"
}
GET /users/(uuid: user_id)/

Get a user node.

Response Headers:
 
  • Content-Type – will always be application/json.
Status Codes:
  • 200 – when the node was found.
  • 404 – when the node was not found.
HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json

{
    "user_id": "uuid",
    "username": "the username",
    "msisdn": "27000000000",
    "email_address": "email@domain.com"
}
DELETE /users/(uuid: user_id)/

Delete a user node.

Status Codes:
  • 204 – when the node was deleted.
  • 404 – when the node was not found.
HTTP/1.1 204 No Content
Vary: Accept