brewtils package¶
Subpackages¶
Submodules¶
brewtils.choices module¶
-
class
brewtils.choices.
FunctionTransformer
[source]¶ Bases:
lark.tree.Transformer
-
func_args
¶ alias of
__builtin__.list
-
url_args
¶ alias of
__builtin__.list
-
-
brewtils.choices.
parse
(input_string, parse_as=None)[source]¶ Attempt to parse a string into a choices dictionary.
Parameters: - input_string – The string to parse
- parse_as – String specifying how to parse input_string. Valid values are ‘func’ or ‘url’. Will try all valid values if None.
Returns: A dictionary containing the results of the parse
Raises: lark.common.ParseError – The parser was not able to find a valid parsing of input_string
brewtils.decorators module¶
-
brewtils.decorators.
system
(cls)[source]¶ Class decorator that marks a class as a beer-garden System
Creates a
_commands
property on the class that holds all registered commands.Parameters: cls – The class to decorated Returns: The decorated class
-
brewtils.decorators.
parameter
(_wrapped=None, key=None, type=None, multi=None, display_name=None, optional=None, default=None, description=None, choices=None, nullable=None, maximum=None, minimum=None, regex=None, is_kwarg=None, model=None, form_input_type=None)[source]¶ Decorator that enables Parameter specifications for a beer-garden Command
This decorator is intended to be used when more specification is desired for a Parameter.
For example:
@parameter(key="message", description="Message to echo", optional=True, type="String", default="Hello, World!") def echo(self, message): return message
Parameters: - _wrapped – The function to decorate. This is handled as a positional argument and shouldn’t be explicitly set.
- key – String specifying the parameter identifier. Must match an argument name of the decorated function.
- type – String indicating the type to use for this parameter.
- multi – Boolean indicating if this parameter is a multi. See documentation for discussion of what this means.
- display_name – String that will be displayed as a label in the user interface.
- optional – Boolean indicating if this parameter must be specified.
- default – The value this parameter will be assigned if not overridden when creating a request.
- description – An additional string that will be displayed in the user interface.
- choices – List or dictionary specifying allowed values. See documentation for more information.
- nullable – Boolean indicating if this parameter is allowed to be null.
- maximum – Integer indicating the maximum value of the parameter.
- minimum – Integer indicating the minimum value of the parameter.
- regex – String describing a regular expression constraint on the parameter.
- is_kwarg – Boolean indicating if this parameter is meant to be part of the decorated function’s kwargs.
- model – Class to be used as a model for this parameter. Must be a Python type object, not an instance.
- form_input_type – Only used for string fields. Changes the form input field (e.g. textarea)
Returns: The decorated function.
-
brewtils.decorators.
command
(_wrapped=None, command_type='ACTION', output_type='STRING', schema=None, form=None, template=None, icon_name=None, description=None)[source]¶ Decorator that marks a function as a beer-garden command
For example:
@command(output_type='JSON') def echo_json(self, message): return message
Parameters: - _wrapped – The function to decorate. This is handled as a positional argument and shouldn’t be explicitly set.
- command_type – The command type. Valid options are Command.COMMAND_TYPES.
- output_type – The output type. Valid options are Command.OUTPUT_TYPES.
- schema – A custom schema definition.
- form – A custom form definition.
- template – A custom template definition.
- icon_name – The icon name. Should be either a FontAwesome or a Glyphicon name.
- description – The command description. Will override the function’s docstring.
Returns: The decorated function.
-
brewtils.decorators.
command_registrar
(cls)¶ Class decorator that marks a class as a beer-garden System
Creates a
_commands
property on the class that holds all registered commands.Parameters: cls – The class to decorated Returns: The decorated class
-
brewtils.decorators.
plugin_param
(_wrapped=None, key=None, type=None, multi=None, display_name=None, optional=None, default=None, description=None, choices=None, nullable=None, maximum=None, minimum=None, regex=None, is_kwarg=None, model=None, form_input_type=None)¶ Decorator that enables Parameter specifications for a beer-garden Command
This decorator is intended to be used when more specification is desired for a Parameter.
For example:
@parameter(key="message", description="Message to echo", optional=True, type="String", default="Hello, World!") def echo(self, message): return message
Parameters: - _wrapped – The function to decorate. This is handled as a positional argument and shouldn’t be explicitly set.
- key – String specifying the parameter identifier. Must match an argument name of the decorated function.
- type – String indicating the type to use for this parameter.
- multi – Boolean indicating if this parameter is a multi. See documentation for discussion of what this means.
- display_name – String that will be displayed as a label in the user interface.
- optional – Boolean indicating if this parameter must be specified.
- default – The value this parameter will be assigned if not overridden when creating a request.
- description – An additional string that will be displayed in the user interface.
- choices – List or dictionary specifying allowed values. See documentation for more information.
- nullable – Boolean indicating if this parameter is allowed to be null.
- maximum – Integer indicating the maximum value of the parameter.
- minimum – Integer indicating the minimum value of the parameter.
- regex – String describing a regular expression constraint on the parameter.
- is_kwarg – Boolean indicating if this parameter is meant to be part of the decorated function’s kwargs.
- model – Class to be used as a model for this parameter. Must be a Python type object, not an instance.
- form_input_type – Only used for string fields. Changes the form input field (e.g. textarea)
Returns: The decorated function.
-
brewtils.decorators.
register
(_wrapped=None, command_type='ACTION', output_type='STRING', schema=None, form=None, template=None, icon_name=None, description=None)¶ Decorator that marks a function as a beer-garden command
For example:
@command(output_type='JSON') def echo_json(self, message): return message
Parameters: - _wrapped – The function to decorate. This is handled as a positional argument and shouldn’t be explicitly set.
- command_type – The command type. Valid options are Command.COMMAND_TYPES.
- output_type – The output type. Valid options are Command.OUTPUT_TYPES.
- schema – A custom schema definition.
- form – A custom form definition.
- template – A custom template definition.
- icon_name – The icon name. Should be either a FontAwesome or a Glyphicon name.
- description – The command description. Will override the function’s docstring.
Returns: The decorated function.
brewtils.errors module¶
Module containing all of the BREWMASTER error definitions
-
exception
brewtils.errors.
BGConflictError
[source]¶ Bases:
brewtils.errors.BrewmasterRestError
Error indicating a 409 was raised on the server
-
exception
brewtils.errors.
BGNotFoundError
[source]¶ Bases:
brewtils.errors.BrewmasterRestError
Error Indicating a 404 was raised on the server
-
exception
brewtils.errors.
BrewmasterConnectionError
[source]¶ Bases:
brewtils.errors.BrewmasterRestError
Error indicating a connection error while performing a request
-
exception
brewtils.errors.
BrewmasterDeleteError
[source]¶ Bases:
brewtils.errors.BrewmasterRestError
Error Indicating a server Error occurred performing a DELETE
-
exception
brewtils.errors.
BrewmasterFetchError
[source]¶ Bases:
brewtils.errors.BrewmasterRestError
Error Indicating a server Error occurred performing a GET
-
exception
brewtils.errors.
BrewmasterModelError
[source]¶ Bases:
exceptions.Exception
Wrapper Error for All BrewmasterModelErrors
-
exception
brewtils.errors.
BrewmasterModelValidationError
[source]¶ Bases:
brewtils.errors.BrewmasterModelError
Error to indicate an invalid Brewmaster Model
-
exception
brewtils.errors.
BrewmasterRestError
[source]¶ Bases:
exceptions.Exception
Wrapper Error to Wrap more specific BREWMASTER Rest Errors
-
exception
brewtils.errors.
BrewmasterSaveError
[source]¶ Bases:
brewtils.errors.BrewmasterRestError
Error Indicating a server Error occurred performing a POST/PUT
-
exception
brewtils.errors.
BrewmasterTimeoutError
[source]¶ Bases:
brewtils.errors.BrewmasterRestError
Error Indicating a Timeout was reached while performing a request
-
exception
brewtils.errors.
BrewmasterValidationError
[source]¶ Bases:
brewtils.errors.BrewmasterRestError
Error Indicating a client (400) Error occurred performing a POST/PUT
-
exception
brewtils.errors.
DiscardMessageException
[source]¶ Bases:
exceptions.Exception
Raising an instance will result in a message not being requeued
-
exception
brewtils.errors.
PluginParamError
[source]¶ Bases:
brewtils.errors.PluginError
Error used when plugins have illegal parameters
-
exception
brewtils.errors.
PluginValidationError
[source]¶ Bases:
brewtils.errors.PluginError
Plugin could not be validated successfully
-
exception
brewtils.errors.
RepublishRequestException
(request, headers)[source]¶ Bases:
exceptions.Exception
Republish to the end of the message queue
Parameters: - request (
brewtils.models.Request
) – The Request to republish - headers – A dictionary of headers to be used by brewtils.request_consumer.RequestConsumer
- request (
-
exception
brewtils.errors.
RequestStatusTransitionError
[source]¶ Bases:
brewtils.errors.BrewmasterModelValidationError
Error to indicate an updated status was not a valid transition
brewtils.models module¶
-
class
brewtils.models.
Choices
(type=None, display=None, value=None, strict=None, details=None)[source]¶ Bases:
object
-
DISPLAYS
= ('select', 'typeahead')¶
-
TYPES
= ('static', 'url', 'command')¶
-
schema
= 'ChoicesSchema'¶
-
-
class
brewtils.models.
Command
(name, description=None, id=None, parameters=None, command_type=None, output_type=None, schema=None, form=None, template=None, icon_name=None, system=None)[source]¶ Bases:
object
-
COMMAND_TYPES
= ('ACTION', 'INFO', 'EPHEMERAL')¶
-
OUTPUT_TYPES
= ('STRING', 'JSON', 'XML', 'HTML')¶
-
get_parameter_by_key
(key)[source]¶ Given a Key, it will return the parameter (or None) with that key
Parameters: key – Return parameter:
-
has_different_parameters
(parameters)[source]¶ Given a set of parameters, determines if the parameters provided differ from the parameters already defined on this command.
Parameters: parameters – Return boolean:
-
parameter_keys
()[source]¶ Convenience Method for returning all the keys of this command’s parameters.
Return list_of_parameters:
-
schema
= 'CommandSchema'¶
-
-
class
brewtils.models.
Event
(name=None, payload=None, error=None, metadata=None, timestamp=None)[source]¶ Bases:
object
-
schema
= 'EventSchema'¶
-
-
class
brewtils.models.
Events
[source]¶ Bases:
enum.Enum
-
ALL_QUEUES_CLEARED
= 15¶
-
BARTENDER_STARTED
= 3¶
-
BARTENDER_STOPPED
= 4¶
-
BREWVIEW_STARTED
= 1¶
-
BREWVIEW_STOPPED
= 2¶
-
INSTANCE_INITIALIZED
= 8¶
-
INSTANCE_STARTED
= 9¶
-
INSTANCE_STOPPED
= 10¶
-
QUEUE_CLEARED
= 14¶
-
REQUEST_COMPLETED
= 7¶
-
REQUEST_CREATED
= 5¶
-
REQUEST_STARTED
= 6¶
-
SYSTEM_CREATED
= 11¶
-
SYSTEM_REMOVED
= 13¶
-
SYSTEM_UPDATED
= 12¶
-
-
class
brewtils.models.
Instance
(name=None, description=None, id=None, status=None, status_info=None, queue_type=None, queue_info=None, icon_name=None, metadata=None)[source]¶ Bases:
object
-
INSTANCE_STATUSES
= set(['UNKNOWN', 'DEAD', 'PAUSED', 'RUNNING', 'STOPPED', 'INITIALIZING', 'STOPPING', 'STARTING', 'UNRESPONSIVE'])¶
-
schema
= 'InstanceSchema'¶
-
-
class
brewtils.models.
LoggingConfig
(level=None, handlers=None, formatters=None, loggers=None)[source]¶ Bases:
object
-
DEFAULT_FORMAT
= '%(asctime)s - %(name)s - %(levelname)s - %(message)s'¶
-
DEFAULT_HANDLER
= {'class': 'logging.StreamHandler', 'formatter': 'default', 'stream': 'ext::/sys.stdout'}¶
-
LEVELS
= ('DEBUG', 'INFO', 'WARN', 'ERROR')¶
-
SUPPORTED_HANDLERS
= ('stdout', 'file', 'logstash')¶
-
formatter_names
¶
-
get_plugin_log_config
(**kwargs)[source]¶ Get a specific plugin logging configuration.
It is possible for different systems to have different logging configurations. This method will create the correct plugin logging configuration and return it. If a specific logger is not found for a system, then the current logging configuration will be returned.
Parameters: kwargs – Identifying information for a system (i.e. system_name) Returns:
-
handler_names
¶
-
schema
= 'LoggingConfigSchema'¶
-
-
class
brewtils.models.
Parameter
(key, type=None, multi=None, display_name=None, optional=None, default=None, description=None, choices=None, parameters=None, nullable=None, maximum=None, minimum=None, regex=None, form_input_type=None)[source]¶ Bases:
object
-
FORM_INPUT_TYPES
= ('textarea',)¶
-
TYPES
= ('String', 'Integer', 'Float', 'Boolean', 'Any', 'Dictionary', 'Date', 'DateTime')¶
-
schema
= 'ParameterSchema'¶
-
-
class
brewtils.models.
PatchOperation
(operation=None, path=None, value=None)[source]¶ Bases:
object
-
schema
= 'PatchSchema'¶
-
-
class
brewtils.models.
Queue
(name=None, system=None, version=None, instance=None, system_id=None, display=None, size=None)[source]¶ Bases:
object
-
schema
= 'QueueSchema'¶
-
-
class
brewtils.models.
Request
(system=None, system_version=None, instance_name=None, command=None, id=None, parent=None, children=None, parameters=None, comment=None, output=None, output_type=None, status=None, command_type=None, created_at=None, error_class=None, metadata=None, updated_at=None)[source]¶ Bases:
object
-
COMMAND_TYPES
= ('ACTION', 'INFO', 'EPHEMERAL')¶
-
COMPLETED_STATUSES
= ('CANCELED', 'SUCCESS', 'ERROR')¶
-
OUTPUT_TYPES
= ('STRING', 'JSON', 'XML', 'HTML')¶
-
STATUS_LIST
= ('CREATED', 'RECEIVED', 'IN_PROGRESS', 'CANCELED', 'SUCCESS', 'ERROR')¶
-
is_ephemeral
¶
-
schema
= 'RequestSchema'¶
-
status
¶
-
-
class
brewtils.models.
System
(name=None, description=None, version=None, id=None, max_instances=None, instances=None, commands=None, icon_name=None, display_name=None, metadata=None)[source]¶ Bases:
object
-
get_command_by_name
(command_name)[source]¶ Retrieve a particular command from the system
Parameters: command_name – Name of the command to retrieve Returns: The command object. None if the given command name does not exist in this system.
-
get_instance
(name)[source]¶ Get an instance that currently exists in the system
Parameters: name – The name of the instance to search Returns: The instance with the given name exists for this system, None otherwise
-
has_different_commands
(commands)[source]¶ Check if a set of commands is different than the current commands
Parameters: commands – The set commands to compare against the current set Returns: True if the sets are different, False if the sets are the same
-
has_instance
(name)[source]¶ Determine if an instance currently exists in the system
Parameters: name – The name of the instance to search Returns: True if an instance with the given name exists for this system, False otherwise.
-
instance_names
¶
-
schema
= 'SystemSchema'¶
-
brewtils.plugin module¶
-
class
brewtils.plugin.
PluginBase
(client, bg_host=None, bg_port=None, ssl_enabled=None, ca_cert=None, client_cert=None, system=None, name=None, description=None, version=None, icon_name=None, instance_name=None, logger=None, parser=None, multithreaded=None, metadata=None, max_concurrent=None, bg_url_prefix=None, **kwargs)[source]¶ Bases:
object
A beer-garden Plugin.
This class represents a beer-garden Plugin - a continuously-running process that can receive and process Requests.
To work, a Plugin needs a Client instance - an instance of a class defining which Requests this plugin can accept and process. The easiest way to define a
Client
is by annotating a class with the@system
decorator.When creating a Plugin you can pass certain keyword arguments to let the Plugin know how to communicate with the beer-garden instance. These are:
bg_host
bg_port
ssl_enabled
ca_cert
client_cert
bg_url_prefix
A Plugin also needs some identifying data. You can either pass parameters to the Plugin or pass a fully defined System object (but not both). Note that some fields are optional:
PluginBase(name="Test", version="1.0.0", instance_name="default", description="A Test")
or:
the_system = System(name="Test", version="1.0.0", instance_name="default, description="A Test") PluginBase(system=the_system)
If passing parameters directly note that these fields are required:
- name
- Environment variable
BG_NAME
will be used if not specified - version
- Environment variable
BG_VERSION
will be used if not specified - instance_name
- Environment variable
BG_INSTANCE_NAME
will be used if not specified. ‘default’ will be used if not specified and loading from envirornment variable was unsuccessful
And these fields are optional:
- description (Will use docstring summary line from Client if not specified)
- icon_name
- metadata
- display_name
Plugins service requests using a
concurrent.futures.ThreadPoolExecutor
. The maximum number of threads available is controlled by the max_concurrent argument (the ‘multithreaded’ argument has been deprecated).Warning
The default value for
max_concurrent
is 1. This means that a Plugin that invokes a Command on itself in the course of processing a Request will deadlock! If you intend to do this, please setmax_concurrent
to a value that makes sense and be aware that Requests are processed in separate thread contexts!Parameters: - client – Instance of a class annotated with @system.
- bg_host (str) – Hostname of a beer-garden.
- bg_port (int) – Port beer-garden is listening on.
- ssl_enabled (bool) – Whether to use SSL for beer-garden communication.
- ca_cert – Certificate that issued the server certificate used by the beer-garden server.
- client_cert – Certificate used by the server making the connection to beer-garden.
- system – The system definition.
- name – The system name.
- description – The system description.
- version – The system version.
- icon_name – The system icon name.
- instance_name (str) – The name of the instance.
- logger (
logging.Logger
.) – A logger that will be used by the Plugin. - parser (
brewtils.schema_parser.SchemaParser
.) – The parser to use when communicating with beer-garden. - multithreaded (bool) – DEPRECATED Process requests in a separate thread.
- worker_shutdown_timeout (int) – Time to wait during shutdown to finish processing.
- metadata (dict) – Metadata specific to this plugin.
- max_concurrent (int) – Maximum number of requests to process concurrently.
- bg_url_prefix (str) – URL Prefix beer-garden is on.
- display_name (str) – The display name to use for the system.
- max_attempts (int) – Number of times to attempt updating the request before giving up (default -1 aka never).
- max_timeout (int) – Maximum amount of time to wait before retrying to update a request.
- starting_timeout (int) – Initial time to wait before the first retry.
- max_instances (int) – Maximum number of instances allowed for the system.
- ca_verify (bool) – Verify server certificate when making a request.
-
process_message
(target, request, headers)[source]¶ Process a message. Intended to be run on an Executor.
Parameters: - target – The object to invoke received commands on. (self or self.client)
- request – The parsed Request object
- headers – Dictionary of headers from the brewtils.request_consumer.RequestConsumer
Returns: None
-
class
brewtils.plugin.
RemotePlugin
(client, bg_host=None, bg_port=None, ssl_enabled=None, ca_cert=None, client_cert=None, system=None, name=None, description=None, version=None, icon_name=None, instance_name=None, logger=None, parser=None, multithreaded=None, metadata=None, max_concurrent=None, bg_url_prefix=None, **kwargs)[source]¶ Bases:
brewtils.plugin.PluginBase
brewtils.request_consumer module¶
-
class
brewtils.request_consumer.
RequestConsumer
(amqp_url, queue_name, on_message_callback, panic_event, logger=None, thread_name=None, **kwargs)[source]¶ Bases:
threading.Thread
Consumer that will handle unexpected interactions with RabbitMQ.
If RabbitMQ closes the connection, it will reopen it. You should look at the output, as there are limited reasons why the connection may be closed, which usually are tied to permission related issues or socket timeouts.
If the channel is closed, it will indicate a problem with one of the commands that were issued and that should surface in the output as well.
Parameters: - amqp_url (str) – The AMQP url to connection with
- queue_name (str) – The name of the queue to connect to
- on_message_callback (func) – The function called to invoke message processing. Must return a Future.
- panic_event (event) – An event to be set in the event of a catastrophic failure
- logger (
logging.Logger
) – A configured logger - thread_name (str) – The name to use for this thread
- max_connect_retries (int) – Number of connection retry attempts before failure. Default -1 (retry forever).
- max_connect_backoff (int) – Maximum amount of time to wait between connection retry attempts. Default 30.
- max_concurrent (int) – Maximum number of requests to process concurrently
-
close_channel
()[source]¶ Call to close the channel cleanly by issuing the Channel.Close RPC command.
-
on_cancelok
(unused_frame)[source]¶ Invoked when the queueing service acknowledges cancellation.
This method is invoked by pika when RabbitMQ acknowledges the cancellation of a consumer. At this point we will close the channel. This will invoke the on_channel_closed method once the channel has been closed, which will in-turn close the connection.
Parameters: unused_frame (pika.frame.Method) – The Basic.CancelOK frame
-
on_channel_closed
(channel, reply_code, reply_text)[source]¶ Invoekd when the queueing service unexpectedly closes the channle.
Invoked by pika when RabbitMQ unexpectedly closes the channel. Channels are usually closed if you attempt to do something that violates the protocol, such as re-declare an exchange or queue with different parameters. In this case, we’ll close the connection to shutdown the object.
Parameters: - channel (pika.channel.Channel) – The closed channel
- reply_code (int) – The numeric reason the channel was closed
- reply_text (str) – The text reason the channel was closed
-
on_channel_open
(channel)[source]¶ This method is invoked by pika when the channel has been opened. The channel object is passed in so we can make use of it.
The exchange / queue binding should have already been set up so just start consuming.
Parameters: channel (pika.channel.Channel) – The channel object
-
on_connection_closed
(connection, reply_code, reply_text)[source]¶ Invoked when the connection is closed.
This method is invoked by pika when the connection to RabbitMQ is closed unexpectedly. Since it is unexpected, we will reconnect to RabbitMQ if it disconnects.
Parameters: - connection (pika.connection.Connection) – the closed connection object
- reply_code (int) – The server provided reply_code if given
- reply_text (basestring) – The server provided reply_text if given
-
on_connection_open
(unused_connection)[source]¶ Invoked when the connection has been established.
This method is called by pika once the connection to RabbitMQ has been established. It passes the handle to the connection object in case we need it, but in this case, we’ll just mark it unused.
-
on_consumer_cancelled
(method_frame)[source]¶ Invoked by pika when RabbitMQ sends a Basic.Cancel for a consumer receiving messages.
Parameters: method_frame (pika.frame.Method) – The Basic.Cancel frame
-
on_message
(channel, basic_deliver, properties, body)[source]¶ Invoked when a message is delivered from the queueing service.
Invoked by pika when a message is delivered from RabbitMQ. The channel is passed for your convenience. The basic_deliver object that is passed in carries the exchange, routing key, delivery tag and a redelivered flag for the message. the properties passed in is an instance of BasicProperties with the message properties and the body is the message that was sent.
Parameters: - channel (pika.channel.Channel) – The channel object
- basic_deliver (pika.Spec.Basic.Deliver) – basic_deliver method
- properties (pika.Spec.BasicProperties) – properties
- body (str|unicode) – The message body
-
on_message_callback_complete
(basic_deliver, future)[source]¶ Invoked when the future returned by _on_message_callback completes.
Parameters: - basic_deliver (pika.Spec.Basic.Deliver) – basic_deliver method
- future (concurrent.futures.Future) – Completed future
Returns: None
-
open_channel
()[source]¶ Opens a channel on the queueing service.
Open a new channel with RabbitMQ by issuing the Channel.Open RPC command. When RabbitMQ responds that the channel is open, the on_channel_open callback will be invoked by pika.
-
open_connection
()[source]¶ Opens a connection to the queueing service.
This method connects to RabbitMQ, returning the connection handle. When the connection is established, the on_connection_open method will be invoked by pika.
Return type: pika.SelectConnection
-
run
()[source]¶ Run the example consumer.
Creates a connection to the queueing service, then starts the IOLoop. The IOLoop will block and allow the SelectConnection to operate.
Returns:
-
start_consuming
()[source]¶ Begin consuming messages from the queueing service.
This method sets up the consumer by first calling add_on_cancel_callback so that the object is notified if RabbitMQ cancels the consumer. It then issues the Basic.Consume RPC command which returns the consumer tag that is used to uniquely identify the consumer with RabbitMQ. We keep the value to use it when we want to cancel consuming. The on_message method is passed in as a callback pika will invoke when a message is fully received.
brewtils.schema_parser module¶
-
class
brewtils.schema_parser.
SchemaParser
[source]¶ Bases:
object
Serialize and deserialize Brewtils models
-
logger
= <logging.Logger object>¶
-
classmethod
parse_command
(command, from_string=False, **kwargs)[source]¶ Convert raw JSON string or dictionary to a command model object
Parameters: - command – The raw input
- from_string – True if ‘command’ is a JSON string, False if a dictionary
- kwargs – Additional parameters to be passed to the Schema (e.g. many=True)
Returns: A Command object
-
classmethod
parse_event
(event, from_string=False, **kwargs)[source]¶ Convert raw JSON string or dictionary to an event model object
Parameters: - event – The raw input
- from_string – True if ‘event’ is a JSON string, False if a dictionary
- kwargs – Additional parameters to be passed to the Schema (e.g. many=True)
Returns: An Event object
-
classmethod
parse_instance
(instance, from_string=False, **kwargs)[source]¶ Convert raw JSON string or dictionary to an instance model object
Parameters: - instance – The raw input
- from_string – True if ‘instance’ is a JSON string, False if a dictionary
- kwargs – Additional parameters to be passed to the Schema (e.g. many=True)
Returns: An Instance object
-
classmethod
parse_logging_config
(logging_config, from_string=False, **kwargs)[source]¶ Convert raw JSON string or dictionary to a logging config model object
Note: for our logging_config, many is _always_ set to False. We will always return a dict from this method.
Parameters: - logging_config – The raw input
- from_string – True if ‘logging_config’ is a JSON string, False if a dictionary
- kwargs – Additional parameters to be passed to the Schema (e.g. many=True)
Returns: A LoggingConfig object
-
classmethod
parse_parameter
(parameter, from_string=False, **kwargs)[source]¶ Convert raw JSON string or dictionary to a parameter model object
Parameters: - parameter – The raw input
- from_string – True if ‘parameter’ is a JSON string, False if a dictionary
- kwargs – Additional parameters to be passed to the Schema (e.g. many=True)
Returns: An Parameter object
-
classmethod
parse_patch
(patch, from_string=False, **kwargs)[source]¶ Convert raw JSON string or dictionary to a patch model object
Note: for our patches, many is _always_ set to True. We will always return a list from this method.
Parameters: - patch – The raw input
- from_string – True if ‘patch’ is a JSON string, False if a dictionary
- kwargs – Additional parameters to be passed to the Schema (e.g. many=True)
Returns: A PatchOperation object
-
classmethod
parse_queue
(queue, from_string=False, **kwargs)[source]¶ Convert raw JSON string or dictionary to a queue model object
Parameters: - queue – The raw input
- from_string – True if ‘event’ is a JSON string, False if a dictionary
- kwargs – Additional parameters to be passed to the Schema (e.g. many=True)
Returns: A Queue object
-
classmethod
parse_request
(request, from_string=False, **kwargs)[source]¶ Convert raw JSON string or dictionary to a request model object
Parameters: - request – The raw input
- from_string – True if ‘request’ is a JSON string, False if a dictionary
- kwargs – Additional parameters to be passed to the Schema (e.g. many=True)
Returns: A Request object
-
classmethod
parse_system
(system, from_string=False, **kwargs)[source]¶ Convert raw JSON string or dictionary to a system model object
Parameters: - system – The raw input
- from_string – True if ‘system’ is a JSON string, False if a dictionary
- kwargs – Additional parameters to be passed to the Schema (e.g. many=True)
Returns: A System object
-
classmethod
serialize_command
(command, to_string=True, **kwargs)[source]¶ Convert a command model into serialized form
Parameters: - command – The command object(s) to be serialized
- to_string – True to generate a JSON-formatted string, False to generate a dictionary
- kwargs – Additional parameters to be passed to the Schema (e.g. many=True)
Returns: Serialized representation of command
-
classmethod
serialize_event
(event, to_string=True, **kwargs)[source]¶ Convert a logging config model into serialized form
Parameters: - event – The event object(s) to be serialized
- to_string – True to generate a JSON-formatted string, False to generate a dictionary
- kwargs – Additional parameters to be passed to the Schema (e.g. many=True)
Returns: Serialized representation of event
-
classmethod
serialize_instance
(instance, to_string=True, **kwargs)[source]¶ Convert an instance model into serialized form
Parameters: - instance – The instance object(s) to be serialized
- to_string – True to generate a JSON-formatted string, False to generate a dictionary
- kwargs – Additional parameters to be passed to the Schema (e.g. many=True)
Returns: Serialized representation of instance
-
classmethod
serialize_logging_config
(logging_config, to_string=True, **kwargs)[source]¶ Convert a logging config model into serialize form
Parameters: - logging_config – The logging config object(s) to be serialized
- to_string – True to generate a JSON-formatted string, False to generate a dictionary
- kwargs – Additional parameters to be passed to the Schema (e.g. many=True)
Returns: Serialized representation of logging config
-
classmethod
serialize_parameter
(parameter, to_string=True, **kwargs)[source]¶ Convert a parameter model into serialized form
Parameters: - parameter – The parameter object(s) to be serialized
- to_string – True to generate a JSON-formatted string, False to generate a dictionary
- kwargs – Additional parameters to be passed to the Schema (e.g. many=True)
Returns: Serialized representation of parameter
-
classmethod
serialize_patch
(patch, to_string=True, **kwargs)[source]¶ Convert a patch model into serialized form
Parameters: - patch – The patch object(s) to be serialized
- to_string – True to generate a JSON-formatted string, False to generate a dictionary
- kwargs – Additional parameters to be passed to the Schema (e.g. many=True)
Returns: Serialized representation of patch
-
classmethod
serialize_queue
(queue, to_string=True, **kwargs)[source]¶ Convert a queue model into serialized form
Parameters: - queue – The queue object(s) to be serialized
- to_string – True to generate a JSON-formatted string, False to generate a dictionary
- kwargs – Additional parameters to be passed to the Schema (e.g. many=True)
Returns: Serialized representation of queue
-
classmethod
serialize_request
(request, to_string=True, **kwargs)[source]¶ Convert a request model into serialized form
Parameters: - request – The request object(s) to be serialized
- to_string – True to generate a JSON-formatted string, False to generate a dictionary
- kwargs – Additional parameters to be passed to the Schema (e.g. many=True)
Returns: Serialized representation of request
-
classmethod
serialize_system
(system, to_string=True, include_commands=True, **kwargs)[source]¶ Convert a system model into serialized form
Parameters: - system – The system object(s) to be serialized
- to_string – True to generate a JSON-formatted string, False to generate a dictionary
- include_commands – True if the system’s command list should be included
- kwargs – Additional parameters to be passed to the Schema (e.g. many=True)
Returns: Serialized representation of system
-
brewtils.schemas module¶
-
class
brewtils.schemas.
BaseSchema
(strict=True, **kwargs)[source]¶ Bases:
marshmallow.schema.Schema
-
opts
= <marshmallow.schema.SchemaOpts object>¶
-
-
class
brewtils.schemas.
ChoicesSchema
(strict=True, **kwargs)[source]¶ Bases:
brewtils.schemas.BaseSchema
-
opts
= <marshmallow.schema.SchemaOpts object>¶
-
-
class
brewtils.schemas.
CommandSchema
(strict=True, **kwargs)[source]¶ Bases:
brewtils.schemas.BaseSchema
-
opts
= <marshmallow.schema.SchemaOpts object>¶
-
-
class
brewtils.schemas.
DateTime
(format='epoch', **kwargs)[source]¶ Bases:
marshmallow.fields.DateTime
Class that adds methods for (de)serializing DateTime fields as an epoch
-
class
brewtils.schemas.
EventSchema
(strict=True, **kwargs)[source]¶ Bases:
brewtils.schemas.BaseSchema
-
opts
= <marshmallow.schema.SchemaOpts object>¶
-
-
class
brewtils.schemas.
InstanceSchema
(strict=True, **kwargs)[source]¶ Bases:
brewtils.schemas.BaseSchema
-
opts
= <marshmallow.schema.SchemaOpts object>¶
-
-
class
brewtils.schemas.
LoggingConfigSchema
(strict=True, **kwargs)[source]¶ Bases:
brewtils.schemas.BaseSchema
-
opts
= <marshmallow.schema.SchemaOpts object>¶
-
-
class
brewtils.schemas.
ParameterSchema
(strict=True, **kwargs)[source]¶ Bases:
brewtils.schemas.BaseSchema
-
opts
= <marshmallow.schema.SchemaOpts object>¶
-
-
class
brewtils.schemas.
PatchSchema
(strict=True, **kwargs)[source]¶ Bases:
brewtils.schemas.BaseSchema
-
opts
= <marshmallow.schema.SchemaOpts object>¶
-
-
class
brewtils.schemas.
QueueSchema
(strict=True, **kwargs)[source]¶ Bases:
brewtils.schemas.BaseSchema
-
opts
= <marshmallow.schema.SchemaOpts object>¶
-
-
class
brewtils.schemas.
RequestSchema
(strict=True, **kwargs)[source]¶ Bases:
brewtils.schemas.BaseSchema
-
opts
= <marshmallow.schema.SchemaOpts object>¶
-
-
class
brewtils.schemas.
StatusInfoSchema
(strict=True, **kwargs)[source]¶ Bases:
brewtils.schemas.BaseSchema
-
opts
= <marshmallow.schema.SchemaOpts object>¶
-
-
class
brewtils.schemas.
SystemSchema
(strict=True, **kwargs)[source]¶ Bases:
brewtils.schemas.BaseSchema
-
opts
= <marshmallow.schema.SchemaOpts object>¶
-
brewtils.stoppable_thread module¶
Module contents¶
-
brewtils.
get_bg_connection_parameters
(**kwargs)[source]¶ Parse the keyword arguments, search in the arguments, and environment for the values
Parameters: kwargs – Returns:
-
brewtils.
get_bool_from_kwargs_and_env
(key, env_name, **kwargs)[source]¶ Gets a boolean value defaults to True
-
brewtils.
get_easy_client
(**kwargs)[source]¶ Initialize an EasyClient using Environment variables as default values
Parameters: kwargs – Options for configuring the EasyClient Returns: An EasyClient
-
brewtils.
get_from_kwargs_or_env
(key, env_names, default, **kwargs)[source]¶ Get a value from the kwargs provided or environment
Parameters: - key – Key to search in the keyword args
- env_names – Environment names to search
- default – The default if it is not found elsewhere
- kwargs – Keyword Arguments
Returns: