Skip to main content

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.

Gitter PyPI Build Status Code Coverage Documentation Status Pyup Updates

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

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

brewtils-3.11.0.tar.gz (87.3 kB view details)

Uploaded Source

Built Distribution

brewtils-3.11.0-py2.py3-none-any.whl (98.9 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file brewtils-3.11.0.tar.gz.

File metadata

  • Download URL: brewtils-3.11.0.tar.gz
  • Upload date:
  • Size: 87.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.12

File hashes

Hashes for brewtils-3.11.0.tar.gz
Algorithm Hash digest
SHA256 e8aca64e62e27360bcb49d0b72332add2f3d686c340040d0d762db2da499df72
MD5 a24f2e9615eb235188ba28fe71cbdb45
BLAKE2b-256 b7bba1b3db7b21fbf77aa49273f463966e8811d4d9d7aaef00db45b270cce630

See more details on using hashes here.

File details

Details for the file brewtils-3.11.0-py2.py3-none-any.whl.

File metadata

  • Download URL: brewtils-3.11.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 98.9 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.12

File hashes

Hashes for brewtils-3.11.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ad02b88db3eadef9cc820b9059a52ff50fbad2112ebb74081dff6f94d3aa12ff
MD5 10d601ffb7cad9370b22221b8a7b0076
BLAKE2b-256 65ab90c3b59e6a9297094880c936737ad7539abcfa31357c08c1e8352aac87c3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page