List File Servers

This example accesses the fileserver resource to find all file server directories.

This example demonstrates the use of the httplib2 Python REST library:

import httplib2
import json

On the first request, perform authentication:

h = httplib2.Http(".cache")
h.add_credentials('myusername', 'mypassword')

Request all fileserver elements using the GET method:

resp, content = h.request("http://localhost/rundb/api/v1/fileserver?format=json", "GET")

Parse the JSON string response into Python objects:

contentdict = json.loads(content)

Loop through each object in the list and display the directory name:

objects = contentdict['objects']

for obj in objects:
        print obj['filesPrefix']

Previous topic

Download a FASTQ File

Next topic

Run a Plugin

This Page