beekeeper is a Python library designed around dynamically generating a RESTful client interface based on a minimal JSON hive
Project description
Description
beekeeper is a Python library designed around dynamically generating a RESTful client interface based on a minimal JSON hive.
The hive specification is designed to provide beekeeper (or other applications consuming hive files) with programmatically-designed insight into the structure of both the REST endpoints that are available and the objects and methods that those endpoints represent.
While the classes available in beekeeper can be used manually to create Pythonic representations of REST endpoints, it is strongly preferred that the library be used as a whole with a constructed hive file. As APIs become larger in scale (in terms of the number of endpoints and represented objects), the time benefit of beekeeper becomes more pronounced, as adding additional objects and endpoints is a trivial process.
Requirements
beekeeper requires Python 2.7.9/3.4.3 or higher and their built-in modules, as well as xmltodict.
Installation
pip install beekeeper
Usage
The usage of beekeeper will depend on what features are provided by the person who wrote the hive file. There are a number of ways that the hive writer can make your life easier. Regardless, at a base level, usage will look something like this:
from beekeeper import API
myAPI = API.from_hive_file('fname.json')
x = myAPI.Widgets.action(id='foo', argument='bar')
If the hive developer defines an ID variable for the object you’re working with, you can subscript, dictionary style:
x = myAPI.Widgets['foo'].action(argument='bar')
If you’ve only got one remaining argument in the method call, you don’t even need to name it! You can do something like this:
x = myAPI.Widgets['foo'].action('bar')
This also holds true if you have multiple variables, but the other ones are assigned by name:
x = myAPI.Widgets['foo'].action('bar', var2='baz')
If you’re using a hive file, then it should define which variables are needed. If you try to call a function without filling in that variable, it should automatically yell at you and tell you what variables are missing. Since these variables are defined within the hive, beekeeper will do the work for you, automatically determine what data type a particular variable is, and put it exactly where it needs to go.
beekeeper will also automatically handle parsing data. When you send data, beekeeper will read the MIME type that was defined in the variable for that data, and try to automatically move it from a “Python” format (e.g., a dictionary) to the right REST API format (e.g., JSON).
This holds true in the other direction as well; beekeeper will read the MIME type of the response data, and hand it back to you in a Pythonic format! If beekeeper doesn’t know how to handle the data, it’ll just give you the raw bytes so that you can do what you need to with them.
Notes
beekeeper does not currently do SSL certificate verification when used on Python versions earlier than 2.7.9 or 3.4.3.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file beekeeper-alt-2022.9.3.tar.gz
.
File metadata
- Download URL: beekeeper-alt-2022.9.3.tar.gz
- Upload date:
- Size: 16.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.0 CPython/3.7.12 Linux/5.15.0-47-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18addaa163febd69a9e1ec4ec4dddc210785c94c6c1f9b2bcb2a73451b2f23e3 |
|
MD5 | 778612c9600e9133e0727efef9dea8f2 |
|
BLAKE2b-256 | 2868b1c59d68275715e5174c0ec0185d3ceca3223933a6a35cda31389438e545 |
File details
Details for the file beekeeper_alt-2022.9.3-py3-none-any.whl
.
File metadata
- Download URL: beekeeper_alt-2022.9.3-py3-none-any.whl
- Upload date:
- Size: 16.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.0 CPython/3.7.12 Linux/5.15.0-47-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bc0beabe6374b980764f43bf997d5c7c7300e23727ca82e373cdca8081aace53 |
|
MD5 | 2fd4664146e08116954b1d2764cd8484 |
|
BLAKE2b-256 | 087b963bbbef1f4177db365696db91d21d4a713d05b61835fb6a383a8ba5d4ba |