Skip to content
aworkman edited this page May 21, 2014 · 13 revisions

Content Hosting Service Documentation

For the purposes of this project, this service contains the following endpoints:

  • Search
  • Advanced Search
  • GetKeys
  • GetMetadata
  • SetMetadata
  • UploadFile
  • DownloadFile
  • DeleteFile
  • GetAllVersions

Installation

Install Riak

Riak 2.0.0pre20 Download page

Download the Riak package relevant to your operating system and architecture. Install according to the instructions.

Install the Prototype

$ git clone https://github.com/adlnet/Content-Hosting-Service.git
$ cd content-repo
$ pip install virtualenv
$ virtualenv env
$ source env/bin/activate
(env)$ pip install -r requirements.txt

to quit and leave the virtualenv:

(env)$ deactivate

Running

to start riak:

$ sudo riak start

to start the webserver:

(env)$ cd content-repo
(env)$ source env/bin/activate
(env)$ python main.py

Stopping

to stop riak:

$ sudo riak stop

to stop the webserver:

(env)$^C

Usage

This is a very simple API. It exposes several endpoints:

  • /CHS/keys/ for checking the keys stored in the database,
  • /CHS/search/ that sends and receives JSON documents to conduct a search of the database using one term,
  • /CHS/advanced_search/ that sends and receives JSON documents to conduct an advanced, more specific search of the database using three terms,
  • /CHS/get_metadata/{id} that sends and receives JSON documents to retrieve a file's metadata, where {id} is the filename,
  • /CHS/set_metadata/{id} that sends and receives JSON documents to set a file's metadata, where {id} is the filename,
  • /CHS/upload_file for uploading a file, or multiple files to the database,
  • /CHS/download_file/{id} for downloading a file from the database, where {id} is the filename,
  • /CHS/{id} for deleting a file from the database, where {id} is the filename,
  • /CHS/get_all_versions/{id} that sends and receives JSON documents for obtaining a list of versions of a file in the database, where {id} is the filename.

Endpoint /CHS/keys/

GET /CHS/keys/

Returns an HTML template with a list of all the keys in the database.

Arguments

None

Returns

200 OK (HTML) Returns HTML with a list of the keys in the database.

404 Not Found (HTML) There are no keys.

Endpoint /CHS/search

POST /CHS/search

Use this method to perform a simple search of the database object's metadata. It takes a JSON document with a single search term. (This method is currently stubbed out for testing responses).

Arguments

None

Returns

200 OK (JSON) Returns JSON with a list of files' metadata that match the searchterm

400 Bad Request (No body) The request body is not a valid JSON body, or does not contain the required term field.

Example JSON request:


{
    "search": {
        "term": "some term"
    }
}

Endpoint /CHS/advanced_search

POST /CHS/advanced_search This method is currently stubbed out for testing responses.

Arguments

None

Returns

200

404

Endpoint /CHS/get_metadata/{id}

GET /CHS/get_metadata/{id}

Arguments

None

Returns

200

404

Endpoint /CHS/set_metadata/{id}

POST /CHS/set_metadata/{id}

Arguments

None

Returns

200

404

Endpoint /CHS/upload_file

POST /CHS/upload_file

Arguments

None

Returns

200

404

Endpoint /CHS/download_file

GET /CHS/download_file

Arguments

None

Returns

200

404

Endpoint /CHS/{id}

DELETE /CHS/{id}

Arguments

None

Returns

200

404

Endpoint /CHS/get_all_versions/{id}

GET /CHS/get_all_versions/{id}

Arguments

None

Returns

**200 OK **

404

Clone this wiki locally