Skip to content

Peer API

Philipp Zeppezauer edited this page Nov 19, 2014 · 1 revision

Peer API /peer

Peer JSON Entity:

{
    "name": "Peer1",
    "deliveryPolicy": "AT_LEAST_ONE",
    "peerAddressList": [
        {
            "type": "Email",
            "values": [
                "some.email@provider.com"
            ]
        },
        {
            "type": "REST",
            "values": [
                "http://localhost:8080/peer1"
            ]
        }
    ]
}

REST API

GET `/{id}` Get a peer with a given id
POST `/` Create a new peer (id is either set already or will be created)
PUT `/` Update a peer
DELETE `/{id}` Delete a peer with a given id
GET `/all` Get all available peers
DELETE `/all` Delete all peers
GET `/download` Download a file containing all available peers
POST `/upload` Upload a file containing a one or multiple peers

GET /{id}

Returns a peer with a given id. Returns a JSON object of Peer.

Parameter:
id required - defines the id of the peer

Respond:
200 peer instance is returned in the body 404 there is no peer with such an id

POST /

Create a new peer. If the id is empty, a new one will be created, otherwise the defined one will be used. Note that if this id already exists, status code 409 will be returned.

Parameter:
body required - instance of a peer JSON object

Respond:
200 resource has been created and the created peer (with id) is returned in the body
409 resource could not be created because the id already exists

PUT /

Updates an existing peer. Note that it is not possible to change the ID. Returns a JSON object of Peer.

Parameter:
body required - instance of a peer JSON object

Respond:
200 peer instance is returned in the body 404 there is no such peer

DELETE /{id}

Deletes a peer with a given id. Returns a JSON object of deleted peer.

Parameter:
id required - defines the id of the peer

Respond:
200 peer instance is returned in the body 404 there is no peer with such an id

GET /all

Returns all available peers as a list of JSON objects.

Respond:
200 list of peer instance is returned in the body

DELETE /all

Deletes all available peers. Note: this action is irreversible!

Respond:
200 all peers have been deleted

GET /download

Download a file containing all available peers

Respond:
200 file is attached in the header of the response

POST /upload

Upload a file containing peers. The optional parameter delete (default is true) defines if all the available peers should be deleted before inserting the ones from the file.

Parameter:
file required - parameter that defines the file with the peers delete optional (default is true) - defines if currently available peers should be deleted

Respond:
200 peers have been uploaded 501 file could not be handled