Beer-garden plugin and utility library
Project description
Brewtils is the Python library for interfacing with Beergarden systems. If you are planning on writing beer-garden plugins, this is the correct library for you. In addition to writing plugins, it provides simple ways to query the API and is officially supported by the beer-garden team.
Features
Brewtils helps you interact with beer-garden.
Easy way to create beer-garden plugins
Full support of the entire Beer-Garden API
Officially supported by the beer-garden team
Installation
To install brewtils, run this command in your terminal:
$ pip install brewtils
Or add it to your requirements.txt
$ cat brewtils >> requirements.txt
$ pip install -r requirements.txt
Quick Start
You can create your own beer-garden plugins without much problem at all. To start, we’ll create the obligatory hello-world plugin. Creating a plugin is as simple as:
from brewtils.decorators import system, parameter, command
from brewtils.plugin import RemotePlugin
@system
class HelloWorld(object):
@parameter(key="message", description="The message to echo", type="String")
def say_hello(self, message="World!"):
print("Hello, %s!" % message)
return "Hello, %s!" % message
if __name__ == "__main__":
client = HelloWorld()
plugin = RemotePlugin(client,
name="hello",
version="0.0.1",
bg_host='127.0.0.1',
bg_port=2337)
plugin.run()
Assuming you have a Beer Garden running on port 2337 on localhost, running this will register and start your plugin! You now have your first plugin running in beer-garden. Let’s use another part of the brewtils library to exercise your plugin from python.
The SystemClient is designed to help you interact with registered Systems as if they were native Python objects.
from brewtils.rest.system_client import SystemClient
hello_client = SystemClient('localhost', 2337, 'hello')
request = hello_client.say_hello(message="from system client")
print(request.status) # 'SUCCESS'
print(request.output) # Hello, from system client!
In the background, the SystemClient has executed an HTTP POST with the payload required to get beer-garden to execute your command. The SystemClient is how most people interact with beer-garden when they are in the context of python and want to be making requests.
Of course, the rest of the API is accessible through the brewtils package. The EasyClient provides simple convenient methods to call the API and auto-serialize the responses. Suppose you want to get a list of all the commands on all systems:
from brewtils.rest.easy_client import EasyClient
client = EasyClient('localhost', 2337)
systems = client.find_systems()
for system in systems:
for command in system.commands:
print(command.name)
This is just a small taste of what is possible with the EasyClient. Feel free to explore all the methods that are exposed.
For more detailed information and better walkthroughs, checkout the full documentation!
Documentation
Full Beer Garden documentation is available at https://beer-garden.io
Brewtils Documentation is available at https://brewtils.readthedocs.io
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 brewtils-3.0.0a1.tar.gz
.
File metadata
- Download URL: brewtils-3.0.0a1.tar.gz
- Upload date:
- Size: 74.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4059d0106f2ee2ff698160846b73bc5d852918a944ba8b08242ae2e83acfc178 |
|
MD5 | 4fed0da81781aaa738fcb63a0ccceadd |
|
BLAKE2b-256 | fbf7839433ca5abfcb22143d8a724c17c52b4aefdfae9f95bf5f8ac9a26831a5 |
File details
Details for the file brewtils-3.0.0a1-py2.py3-none-any.whl
.
File metadata
- Download URL: brewtils-3.0.0a1-py2.py3-none-any.whl
- Upload date:
- Size: 84.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fdad1cbf4bffb7c3e19bd451992d9e38811667c6d2a2fdb63aba762e858ae35c |
|
MD5 | ba6388edc18529b2a71ee2e9e65aaf94 |
|
BLAKE2b-256 | 0d1bc0435d104072fcaee5c09cb767db61081a1c6d016555fcd9baaa701193e5 |