This repository was archived by the owner on Mar 21, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 46
OOP Bindings
tjfontaine edited this page Sep 14, 2010
·
2 revisions
I got inspired by Django and decided to implement a bit of their object model on top of the base Linode bindings. Thankfully the API is already pretty object oriented. A quick example of usage:
from oop import *for d in Domain.list(): print d.name for record in Resource.list(domain=d): print "\t%s\t%s\t%s" % (record.name, record.type, record.target)
results in
example.com
A 127.0.0.1
www A 127.0.0.1
mail A 127.0.0.1
MX mail.example.com
trac CNAME www.example.com
svn CNAME trac.example.comThere is a class for each of the sections listed on the main API documentation page. A list (that may change in the future) of the classes currently available:
- Linode
- LinodeConfig
- LinodeDisk
- LinodeIP
- LinodeJob
- LinodePlan
- Datacenter
- Distribution
- Kernel
- Domain
- Resource
These classes (depending on their underlying abilities) have save/delete/list/get methods. To list all the configs for instance you may do: LinodeConfig.list(linode=l) where l is either a Linode object or an integer. The list() methods returns a generator object, and get() returns a specific object. There is also a builtin cache.