Python RESTful interface to the IXF database,
The easiest method of installation is go get it directly from PyPI using pip or setuptools by running the respective command below.
pip install -U ixf
or:
easy_install -U ixf
Otherwise you can clone it with:
git clone https://github.com/euro-ix/ixf-client-py.git
cd ixf-client-py
Then install it directly from source:
python setup.py install
or if you want to hack on it, link it directly into your environment with:
python setup.py develop
from ixf import IXFClient
# anonymous
ixfc = IXFClient()
or
# writes require authentication
ixfc = IXFClient(user='guest', password='guest')
or
# override to localhost for development
ixfc = IXFClient(host="localhost", port=8000, user="test", password="test")
# list all records of type IXP
print ixfc.list_all('IXP')
# get IXP42
print ixfc.get('IXP', 42)
# delete IXP42
print ixfc.rm('IXP', 42)
# create new IXP
data = {
"full_name": "Test IXP",
"short_name": "TIX",
}
response = ixfc.save("IXP", data)
ixpid = response['id']
# update from keyword variables
ixfc.update('IXP', 42, full_name="Test IXP", short_name="TIX")
# update from dict
ixfc.update('IXP', 42, **data)
# try to get a non existent IXP
ixfc.get('IXP', 999999999)
results in:
KeyError: u'Object not found: IXP.999999999'