-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 1940198
Showing
56 changed files
with
8,840 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
MODULE_NAME=brewtils | ||
PACKAGE_NAME=brewtils | ||
BUILD_IMAGE=beer-garden/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
[report] | ||
show_missing = True | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
env/ | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
eggs/ | ||
.eggs/ | ||
*.egg-info/ | ||
*.egg | ||
.installed.cfg | ||
.Python | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/otehr infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
output/ | ||
htmlcov/ | ||
coverage/ | ||
cover/ | ||
.tox/ | ||
.hypothesis/ | ||
.cache | ||
.coverage | ||
.coverage.* | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Swap files | ||
*.swp | ||
|
||
# Django stuff: | ||
*.log | ||
|
||
# Documentation | ||
docs/_build/ | ||
docs/generated_docs/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Ipython Notebook | ||
.ipynb_checkpoints | ||
|
||
# IDE stuff | ||
.idea/ | ||
.editorconfig | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
brewtils |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# CHANGELOG | ||
|
||
## [2.3.0] | ||
Date: 1/26/18 | ||
#### Added Features | ||
- Added methods for interacting with the Queue API to RestClient and EasyClient (#329) | ||
- Clients and Plugins can now be configured to skip server certificate verification when making HTTPS requests (#326) | ||
- Timestamps now have true millisecond precision on platforms that support it (#325) | ||
- Added `form_input_type` to Parameter model (#294) | ||
- Plugins can now be stopped correctly by calling their `_stop` method (#263) | ||
- Added Event model (#21) | ||
|
||
#### Bug Fixes | ||
- Plugins now additionally look for `ca_cert` and `client_cert` in `BG_CA_CERT` and `BG_CLIENT_CERT` (#326) | ||
|
||
#### Other Changes | ||
- Better data integrity by only allowing certain Request status transitions (#214) | ||
|
||
## [2.2.1] | ||
1/11/18 | ||
#### Bug Fixes | ||
- Nested requests that reference a different BEERGARDEN no longer fail (#313) | ||
|
||
## [2.2.0] | ||
10/23/17 | ||
#### Added Features | ||
- Command descriptions can now be changed without updating the System version (#225) | ||
- Standardized Remote Plugin logging configuration (#168) | ||
- Added domain-specific language for dynamic choices configuration (#130) | ||
- Added `metadata` field to Instance model | ||
|
||
#### Bug Fixes | ||
- Removed some default values from model `__init__` functions (#237) | ||
- System descriptors (description, display name, icon name, metadata) now always updated during startup (#213, #228) | ||
- Requests with output type 'JSON' will now have JSON error messages (#92) | ||
|
||
#### Other changes | ||
- Added license file | ||
|
||
## [2.1.1] | ||
8/25/17 | ||
#### Added Features | ||
- Added `updated_at` field to `Request` model (#182) | ||
- `SystemClient` now allows specifying a `client_cert` (#178) | ||
- `RestClient` now reuses the same session for subsequent connections (#174) | ||
- `SystemClient` can now make non-blocking requests (#121) | ||
- `RestClient` and `EasyClient` now support PATCHing a `System` | ||
|
||
#### Deprecations / Removals | ||
- `multithreaded` argument to `PluginBase` has been superseded by `max_concurrent` | ||
- These decorators are now deprecated (#164): | ||
- `@command_registrar`, instead use `@system` | ||
- `@plugin_param`, instead use `@parameter` | ||
- `@register`, instead use `@command` | ||
- These classes are now deprecated (#165): | ||
- `BrewmasterSchemaParser`, instead use `SchemaParser` | ||
- `BrewmasterRestClient`, instead use `RestClient` | ||
- `BrewmasterEasyClient`, instead use `EasyClient` | ||
- `BrewmasterSystemClient`, instead use `SystemClient` | ||
|
||
#### Bug fixes | ||
- Reworked message processing to remove the possibility of a failed request being stuck in 'IN_PROGRESS' (#183, #210) | ||
- Correctly handle custom form definitions with a top-level array (#177) | ||
- Smarter reconnect logic when the RabbitMQ connection fails (#83) | ||
|
||
#### Other changes | ||
- Removed dependency on `pyopenssl` so there's need to compile any Python extensions (#196) | ||
- Request processing now occurs inside of a `ThreadPoolExecutor` thread (#183) | ||
- Better serialization handling for epoch fields (#167) | ||
|
||
|
||
[unreleased]: https://github.com/beer-garden/bindings/compare/master...develop | ||
[2.3.0]: https://github.com/beer-garden/bindings/compare/2.2.1...2.3.0 | ||
[2.2.1]: https://github.com/beer-garden/bindings/compare/2.2.0...2.2.1 | ||
[2.2.0]: https://github.com/beer-garden/bindings/compare/2.1.1...2.2.0 | ||
[2.1.1]: https://github.com/beer-garden/bindings/compare/2.1.0...2.1.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Contributing to the Bindings | ||
========= | ||
|
||
Since many people have many different uses for Beergarden, it makes sense that you may need functionality that's not currently supported. If that's the case, and you think you can add the functionality yourself, feel free! Here's the easiest way to make changes: | ||
|
||
1. Clone or fork the project (`git clone [email protected]:beer-garden/brewtils.git`) | ||
2. Create a new branch (`git checkout -b my_amazing_feature`) | ||
3. Commit your changes (`git commit -m "It's done!"`) | ||
4. Push to the branch (`git push origin my_amazing_feature`) | ||
5. Create a new Merge Request in GitHub (https://github.com/beer-garden/brewtils/merge_requests/new) | ||
|
||
We want to do everything we can to make sure we're delivering robust software. So we just ask that before submitting a merge request you: | ||
|
||
1. Make sure all the existing tests work (`nosetests` for the Python bindings) | ||
2. Create new tests for the functionality you've created. These should work too :) | ||
|
||
Finally, __thank you for your contribution!__ Your help is very much appreciated by the Beergarden developers and users. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
FROM beer-garden/tox:latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
The MIT License | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO TEH WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
Brewtils | ||
========= | ||
|
||
Brewtils is the Python library for interfacing with Beergarden systems. It provides simple ways to query information, access systems, generate requests, and more. | ||
|
||
## Installation | ||
Brewtils lives on PyPI. You can install it via: | ||
|
||
pip install brewtils | ||
|
||
If you already have a requirements definition file you can add brewtils like this: | ||
|
||
brewtils | ||
|
||
And then install with pip as normal. | ||
|
||
## Usage | ||
|
||
There are three major ways to use `brewtils`. A brief summary of each is given below so you can determine which best fits your use-case. | ||
|
||
|
||
### Remote Plugin Decorators | ||
|
||
The `decorators` module helps you create your own remote plugin. Suppose you have the following class: | ||
|
||
```python | ||
Class MyClient(object): | ||
|
||
def do_something(self): | ||
print("Hello, World!") | ||
return "Hello, World!" | ||
|
||
def echo_message(self, message): | ||
print(message) | ||
return message | ||
``` | ||
|
||
There are two steps for making this class into a Beergarden plugin. First, you'll need to decorate your class and methods: | ||
|
||
```python | ||
from brewtils.decorators import system, parameter, command | ||
|
||
@system | ||
Class MyClient(object): | ||
|
||
@command | ||
def do_something(self): | ||
print("Hello, World!") | ||
return "Hello, World!" | ||
|
||
@parameter(key="message", description="The message to echo", type="String") | ||
def echo_message(self, message): | ||
print(message) | ||
return message | ||
``` | ||
|
||
The `@system` tells us that the `MyClient` class is going to be a Beergarden plugin. | ||
|
||
The `@command` tells us that `do_something` is going to be a command. | ||
|
||
The `@parameter` tells us information about the parameters to the `echo_message` method. | ||
|
||
Now that we've decorated the client definition we just need to point the remote plugin at a Beergarden and start it. We can do that like this: | ||
|
||
```python | ||
from brewtils.plugin import RemotePlugin | ||
|
||
#...MyClient definition... | ||
|
||
def main(): | ||
client = MyClient() | ||
plugin = RemotePlugin(client, name="My Client", version="0.0.1", bg_host='127.0.0.1', bg_port=2337) | ||
plugin.run() | ||
|
||
if __name__ == "__main__": | ||
main() | ||
``` | ||
|
||
Assuming you have a Beergarden running on port 2337 on localhost, running this will register and start your plugin. | ||
|
||
|
||
### System Client | ||
|
||
The `SystemClient` is designed to help you interact with registered Systems as if they were native Python objects. Suppose the following System has been registered with Beergarden: | ||
|
||
System: | ||
Name: foo | ||
Version: 0.0.1 | ||
Commands: | ||
do_something1 | ||
Params: | ||
key1 | ||
key2 | ||
|
||
do_something2 | ||
Params: | ||
key3 | ||
key4 | ||
|
||
That is, we have a System named "foo" with two possible commands: `do_something1` and `do_something2`, each of which takes 2 parameters (key1-4). | ||
|
||
Now suppose we want to exercise `do_something1` and inspect the result. The `SystemClient` makes this trivial: | ||
|
||
```python | ||
from brewtils.rest.system_client import SystemClient | ||
|
||
foo_client = SystemClient('localhost', 2337, 'foo') | ||
|
||
request = foo_client.do_something1(key1="k1", key2="k2") | ||
|
||
print(request.status) # 'SUCCESS' | ||
print(request.output) # do_something1 output | ||
``` | ||
When you call `do_something1` on the `SystemClient` object it will make a REST call to Beergarden to generate a Request. It will then block until that request has completed, at which point the returned object can be queried the same way as any other Request object. | ||
|
||
If the system you are using has multiple instances, you can specify the default instance to use: | ||
|
||
```python | ||
foo_client = SystemClient('localhost', 2337, 'foo', default_instance="01") | ||
|
||
foo_client.do_something1(key1="k1", key2="k2") # Will set instance_name to '01' | ||
``` | ||
|
||
If you want to operate on multiple instances of the same system, you can specify the instance name each time: | ||
|
||
```python | ||
foo_client = SystemClient('localhost', 2337, 'foo') | ||
request = foo_client.do_something1(key1="k1", key2="k2", _instance_name="01") # Will set instance_name to '01' | ||
``` | ||
|
||
Notice the leading `_` in the `_instance_name` keyword argument. This is necessary to distinguish command arguments (things to pass to `do_something1`) from Beergarden arguments. In general, you should try to avoid naming parameters with a leading underscore to avoid name collisions. | ||
|
||
### Easy Client | ||
|
||
The `EasyClient` is intended to make it easy to directly query Beergarden. Suppose the same `foo` System as above has been registered in Beergarden. We can use the `EasyClient` to gather information: | ||
|
||
```python | ||
from brewtils.rest.easy_client import EasyClient | ||
|
||
client = EasyClient('localhost', 2337) | ||
|
||
foo_system = client.find_unique_system(name='foo', version='0.0.1') | ||
|
||
for command in foo_system.commands: | ||
print(command.name) | ||
``` | ||
|
||
The `EasyClient` is full of helpful commands so feel free to explore all the methods that are exposed. |
Oops, something went wrong.