Skip to content
This repository was archived by the owner on Jul 18, 2022. It is now read-only.

Backmeup python api

fschoeppl edited this page Jul 2, 2012 · 2 revisions

The [RESTBackMeUp-Module] (https://github.com/backmeup/backmeup-prototype/blob/master/python-tests/RESTBackMeUp.py) contains functions to communicate with the Backmeup-REST-Layer. This section gives a brief overview about its configuration and usage.

Prerequisites

The API has been tested with Python 2.7.2. The latest python 2.x version can be downloaded from here

Configuration

The configuration can be specified within [RESTConfig] (https://github.com/backmeup/backmeup-prototype/blob/master/python-tests/RESTConfig.py):

SERVER="127.0.0.1"   # connect to this server
PORT=8080            # at this port
BASE_URL=""          # with this relative URL (has to start with /)
# http://SERVER:PORT/BASE_URL

How to use the REST-Python-Binding

Example 1: Register a user

>>> import RESTBackMeUp
>>> help (RESTBackMeUp) # prints all available operations
>>> result = RESTBackMeUp.register_user("Username", "Secretpassword", "Secretpassword2", "[email protected]") # register a new user
>>> result.code # the error code of the http request
204
>>> result.data  # no json data has been sent back
''
>>> result.location # no location header within this answer

Example 2: retrieving the available datasources

>>> result = RESTBackMeUp.get_datasources()
>>> result.code
200
>>> result.data
{u'sources': [{u'imageURL': u'http://about:blank', u'datasourceId': u'org.backmeup.dropbox', u'title': u'BackMeUp Dropbo
x Plug-In'}, {u'imageURL': u'http://moodle.org/logo/logo-4045x1000.jpg', u'datasourceId': u'org.backmeup.moodle', u'titl
e': u'BackMeUp Moodle Plug-In'}]}
>>> result.data["sources"][1]["imageURL"]
u'http://moodle.org/logo/logo-4045x1000.jpg'
>>>
Clone this wiki locally