Skip to content

REST API of Pomegranate

macan edited this page · 10 revisions

Document of REST API of Pomegranate

Known Issues

Authorization of REST API has not been added in, thus this API is ONLY for demo!

Requests

  • GET service
  • PUT service
  • POST service
  • DELETE service

GET service

Request Headers

Header Description Required
Authorization The authentication string for the request. (Not implement yet) No
Date The date and time of the request. No
Host The Host machine of yourself. Yes
Command statfs/list/stat/read Yes
Args
Command Name Arguments
statfs None
list /path/to/directory
stat /path/to/file/or/directory
read /path/to/file/or/directory
Yes

Request Body Elements

This request does not include a plain document in the request body.

Response Details

The response content is in the response body. Examples following:

STATFS Request

Request

GET /hvfs HTTP/1.1
Host: 10.10.111.9
Accept: */*
Command: statfs

Response

HTTP/1.1 200 OK
Content-Length: 145
Server: CherryPy/3.1.2
Command-Id: 2
Allow: DELETE, GET, HEAD, POST, PUT
Date: Sun, 19 Dec 2010 11:56:55 GMT
Content-Type: text/html

FS STAT:
    f_type      0x4af5
    f_bsize     0
    f_blocks    0
    f_bfree     0
    f_bavail    0
    f_files     1000100
    f_ffree     35184371088720
    f_fsid      ????
    f_namelen   256

LIST Request

Request to list the ROOT (/) directory

GET /hvfs HTTP/1.1
Host: 10.10.111.9
Accept: */*
Command: list
Args: /

Response

HTTP/1.1 200 OK
Content-Length: 74
Server: CherryPy/3.1.2
Command-Id: 4
Allow: DELETE, GET, HEAD, POST, PUT
Date: Sun, 19 Dec 2010 12:07:17 GMT
Content-Type: text/html

d 040755     8000000000041163 dir
- 100644                41164 first.txt

STAT Request

Request to stat file '/second.txt'

GET /hvfs HTTP/1.1
Host: 10.10.111.9
Accept: */*
Command: stat
Args: /dir/second.txt

Response

HTTP/1.1 200 OK
Content-Length: 118
Server: CherryPy/3.1.2
Command-Id: 5
Allow: DELETE, GET, HEAD, POST, PUT
Date: Sun, 19 Dec 2010 12:10:05 GMT
Content-Type: text/html

8000000000041163 93295cf 40000003e745 8000000 0 0 100644 1 19 0 1292760183 1292760183 1292760183 0 0 $0$0$ [0 0 19 0]

READ Request

Request to read the file content of '/dir/second.txt'

GET /hvfs HTTP/1.1
Host: 10.10.111.9
Accept: */*
Command: read
Args: /dir/second.txt

Response

HTTP/1.1 200 OK
Content-Length: 19
Server: CherryPy/3.1.2
Command-Id: 7
Allow: DELETE, GET, HEAD, POST, PUT
Date: Sun, 19 Dec 2010 12:12:34 GMT
Content-Type: text/html

Hello, Pomegranate!

PUT service

Request Headers

Header Description Required
Authorization The authentication string for the request. (Not implement yet) No
Date The date and time of the request. No
Host The Host machine of yourself. Yes
Command create/mkdir Yes
Args
Command Name Arguments
create /path/to/file
mkdir /path/to/directory
Yes

Request Body Elements

This request does not include a plain document in the request body.

Response Details

The response content is in the response body. Examples following:

CREATE Request

Request to write file '/dir/third.txt'

PUT /hvfs HTTP/1.1
Host: 10.10.111.9
Accept: */*
Command: create
Args: /dir/third.txt
Content-Length: 0

Response

HTTP/1.1 200 OK
Content-Length: 116
Server: CherryPy/3.1.2
Command-Id: 9
Allow: DELETE, GET, HEAD, POST, PUT
Date: Sun, 19 Dec 2010 13:17:26 GMT
Content-Type: text/html

8000000000041163 93295cf 200000030837 8000000 0 0 100644 1 0 0 1292764646 1292764646 1292764646 0 0 $0$0$ [0 0 0 0]

MKDIR Request

Reqeust to make a new directory '/dir2'

PUT /hvfs HTTP/1.1
Host: 10.10.111.9
Accept: */*
Command: mkdir
Args: /dir2
Content-Length: 0

Response

HTTP/1.1 200 OK
Content-Length: 104
Server: CherryPy/3.1.2
Command-Id: 10
Allow: DELETE, GET, HEAD, POST, PUT
Date: Sun, 19 Dec 2010 13:18:58 GMT
Content-Type: text/html

1 562e36f 80006000000441d1 8000000 0 0 40755 2 0 0 1292764738 1292764738 1292764738 0 0 $0$0$ [0 0 0 0]

POST service

Request Headers

Header Description Required
Authorization The authentication string for the request. (Not implement yet) No
Date The date and time of the request. No
Host The Host machine of yourself. Yes
Command write/setattr Yes
Args
Command Name Arguments
write /path/to/file
setattr /path/to/file/or/directory key1=val1,key2=val2
Yes

Request Body Elements

The write request contains a text/plain body for data content.

Response Details

The response content is in the response body. Examples follwing:

WRITE Reqeust

Request

POST /hvfs HTTP/1.1
Host: 10.10.111.9
Accept: */*
Command: write
Args: /dir/second.txt
Content-Type: text/plain
Content-Length: 19

Hello, Pomegranate!

Response

HTTP/1.1 200 OK
Content-Length: 3
Server: CherryPy/3.1.2
Command-Id: 3
Allow: DELETE, GET, HEAD, POST, PUT
Date: Sun, 19 Dec 2010 12:03:03 GMT
Content-Type: text/html

+OK

SETATTR Request

Request to set new uid,gid for file '/dir/third.txt'

POST /hvfs HTTP/1.1
Host: 10.10.111.9
Accept: */*
Command: setattr
Args: /dir/third.txt uid=100,gid=1000
Content-Type: text/plain
Content-Length: 0

Response

HTTP/1.1 200 OK
Content-Length: 121
Server: CherryPy/3.1.2
Command-Id: 12
Allow: DELETE, GET, HEAD, POST, PUT
Date: Sun, 19 Dec 2010 13:22:25 GMT
Content-Type: text/html

8000000000041163 93295cf 200000030837 8000000 100 1000 100644 1 0 0 1292764646 1292764646 1292764646 0 0 $0$0$ [0 0 0 0]

DELETE service

Request Headers

Header Description Required
Authorization The authentication string for the request. (Not implement yet) No
Date The date and time of the request. No
Host The Host machine of yourself. Yes
Command delete/rmdir Yes
Args
Command Name Arguments
delete /path/to/file
rmdir /path/to/directory
Yes

Request Body Elements

This request does not include a plain document in the request body.

Response Details

The response content is in the response body. Examples following:

DELETE Request

Request to delete file '/dir/third.txt'

DELETE /hvfs HTTP/1.1
Host: 10.10.111.9
Accept: */*
Command: delete
Args: /dir/third.txt

Response

HTTP/1.1 200 OK
Content-Length: 121
Server: CherryPy/3.1.2
Command-Id: 13
Allow: DELETE, GET, HEAD, POST, PUT
Date: Sun, 19 Dec 2010 13:24:12 GMT
Content-Type: text/html

8000000000041163 93295cf 200000030837 8000000 100 1000 100644 0 0 0 1292764646 1292764646 1292764646 0 0 $0$0$ [0 0 0 0]

RMDIR REQUEST

Request to remove directory '/dir2'

DELETE /hvfs HTTP/1.1
Host: 10.10.111.9
Accept: */*
Command: rmdir
Args: /dir2

Response

HTTP/1.1 200 OK
Content-Length: 104
Server: CherryPy/3.1.2
Command-Id: 14
Allow: DELETE, GET, HEAD, POST, PUT
Date: Sun, 19 Dec 2010 13:25:50 GMT
Content-Type: text/html

1 562e36f 80006000000441d1 8000000 0 0 40755 0 0 0 1292764738 1292764738 1292764738 0 0 $0$0$ [0 0 0 0]
Something went wrong with that request. Please try again.