Skip to content

Collective API

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

Collective API /collective

Collective JSON Entity:

{
    "id": "1",
    "peers": [],
    "deliveryPolicy": "TO_ALL_MEMBERS"
}

REST API

GET `/{id}` Get a collective with a given id
POST `/` Create a new collective (id is either set already or will be created)
PUT `/` Update a collective
PUT `/{collectiveId}/{peerId}` Add a peer with id 'peerId' to the collective with id 'collectiveId'
DELETE `/{collectiveId}/{peerId}` Delete a peer with id 'peerId' from the collective with id 'collectiveId'
DELETE `/{id}` Delete a collective with a given id
GET `/all` Get all available collectives
DELETE `/all` Delete all collectives
GET `/download` Download a file containing all available collectives
POST `/upload` Upload a file containing a one or multiple collectives

GET /{id}

Returns a collective with a given id. Returns a JSON object of collective.

Parameter:
id required - defines the id of the collective

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

POST /

Create a new collective. 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 collective JSON object

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

PUT /

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

Parameter:
body required - instance of a peer JSON object

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

PUT /{collectiveId}/{peerId}

Add a peer with id 'peerId' to the collective with id 'collectiveId'. Note that it is not checked if the peer really exists!

Parameter:
collectiveId required - id of the collective peerId required - id of the peer

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

DELETE /{collectiveId}/{peerId}

Delete a peer with id 'peerId' from the collective with id 'collectiveId'.

Parameter:
collectiveId required - id of the collective peerId required - id of the peer

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

DELETE /{id}

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

Parameter:
id required - defines the id of the collective

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

GET /all

Returns all available collectives as a list of JSON objects.

Respond:
200 list of collective instances is returned in the body

DELETE /all

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

Respond:
200 all collectives have been deleted

GET /download

Download a file containing all available collective

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

POST /upload

Upload a file containing collectives as JSON objects. Each line of the passed file corresponds to a single JSON object/collective! The optional parameter delete (default is true) defines if all the available collectives should be deleted before inserting the ones from the file.

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

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