Jump to content

Python Blesta Api


velaware

Recommended Posts

I made a thread on this elsewhere but since I did a bit of a major overhaul, enough to warrant basically a 2.0 of it.

 

This differs in very, very big ways.  The biggest is that this supports ORM now.

 

Instead of manually calling APIs via doing this:

from blesta_api import *

api = BlestaAPI(...)
api.get("ApiKeys", "getList")

You can do it this way:

from blesta_api import *

api = BlestaAPI(...)

# Get list of API keys
api.models.ApiKeys.getList()

# Use my API Helper's test module
api.plugins.apihelper.test(str="Returning this string")

This makes the code easier and more pleasant to read.

 

It should be noted that both methods are supported, and for ORM to work the API Helper plugin needs to be installed.  Otherwise this won't work (Blesta doesn't offer a native way to get all available API calls).

 

All api.models calls are found in /blesta/app/models while api.plugins reads all plugins that have a public model in the /blesta/plugins directory.

 

Source: https://github.com/anzenehansen/Blesta-Goodies/blob/master/api/blesta_api.py

API Helper tarball: https://github.com/anzenehansen/Blesta-Goodies/raw/master/apihelper_plugin.tar.gz

 

INSTALL

Use as you would any other Python script.  The only thing you have to actually import is BlestaAPI, so from blesta_api import BlestaAPI is fine too.

 

TODO

  • Create a way to determine HTTP method for each API call (currently only GET is supported)

CHANGE LOG

v2.0.0 - 01/28/2014

  • Initial release
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...