Skip to content

Rest API

Taeguk Kwon edited this page Oct 10, 2016 · 20 revisions

DrawML Cloud Distributed File System REST API


A Summary of rest api ----------------------------
URI(default) Method Description
/ GET redirect to /help
/help GET show helpful messages
/data POST put a data file
/data/:token GET get a data file
/data/:token DELETE delete a data file
/group POST create a data group
/group/:token GET get a information of data group
/group/:token DELETE remove a data group

A Detail of rest api ----------------------------

/* (Common to all api)

HTTP Status :

400 - Bad Request : The request was invalid or cannot be served.
404 – Not found : There is no URI.
500 - Internal Server Error : An unknown error occurs while a server is running.
...

Description :

A token is 512 bytes.


/help (GET)

Params :

x

Response :
Header
Content-Type: 'application/json'
Body
{
  "api_doc": "https://github.com/DrawML/cloud_dfs/wiki/Rest-API#drawml-cloud-rest-api",
  "drawml_repo": "https://github.com/DrawML",
  "who_are_we": "Stacker"
}
HTTP Status :

200 - OK : Everything is working.

Description :

x


/data (POST)

HTTP Headers :
Content-Type: 'multipart/form-data' if data type is 'binary'
Content-Type: 'application/json' if data type is 'text'
Params if data type is 'binary':
'data': <binary data> ('filename': <filename>)
'group_token': <a token for data group> // optional
Params if data type is 'text':
{
  "name": "the name of file",
  "data": "text data",
  "group_token": "a token for data group (optional)"
}
Response :
Header
Content-Type: 'application/json'
Body
{
  "token": "token to data file"
}
HTTP Status :

201 - OK : New data file has been created.
422 - Unprocessable Entity : A server cannot create a data file.

Description :

If a system storage capability can't handle the size of a data file, a server can return 422 as a http status.


/data/:token (GET)

Params :

x

Response :
Header
Content-Type: 'application/octet-stream' if data type is 'binary'
Content-Type: 'application/json' if data type is 'text'
Body if data type is 'binary'
Binary Data
Body if data type is 'text'
{
  "name": "name of data file",
  "data": "string data of data file"
}
HTTP Status :

200 - OK : Everything is working.
404 - Not found : There is no data file whose token is :token.

Description :

x


/data/:token (DELETE)

Params :

x

Response
Body

x

HTTP Status :

204 - OK : A data file was successfully deleted.
404 - Not found : There is no data file whose token is :token.

Description :

x


/group (POST)

Params :
'name': <the name of group to make> 
Response :
Header
Content-Type: 'application/json'
Body
{
  "token": "token to data file"
}
HTTP Status :

201 - OK : New data group has been created.

Description :

x


/group/:token (GET)

Params :

x

Response :
Header
Content-Type: 'application/octet-stream' if data type is 'binary'
Content-Type: 'application/json' if data type is 'text'
Body if data type is 'text'
{
  "name": "name of data group",
  "data_token_list": "a list of data tokens"
}
HTTP Status :

200 - OK : Everything is working.
404 - Not found : There is no data group whose token is :token.

Description :

x


/group/:token (DELETE)

Params :

x

Response
Body

x

HTTP Status :

204 - OK : A data group was successfully deleted.
404 - Not found : There is no data group whose token is :token.

Description :

x