Plugin API

class canaryd.plugin.Plugin

The base plugin implementation.

exception PrepareError

Raised when a plugin cannot be prepared for execution.

check_spec_key(key, value)
static generate_issues_from_change(change, settings)

Plugin can generate issue type events from a given change. Executed on the server side on receiving state.

Parameters:
  • change (Change) – a change object
  • settings (dict) – canaryd daemon settings
Yields:

events (tuple)(event_type, event_message, event_data)

static get_action_for_change(change)

Get the event action for a given change. Executed on the server side on receiving state.

Parameters:change (Change) – a change object
Returns:the event action
Return type:action (str)
static get_description_for_change(change)

Get the event description for a given change. Executed on the server side on receiving state.

Parameters:change (Change) – a change object
Returns:the event description
Return type:description (str)
get_events(settings)

Plugin can generate raw events here, ie for things that don’t fit into the spec/state model. This should be a generator yielding event tuples:

Parameters:settings (dict) – canaryd daemon settings
Returns:[(event_type, event_message, event_data), ...]
Return type:events (list)
get_state(settings)

Get the current state for this plugin. Returns structured objects that match the spec defined on the plugin.

Parameters:settings (dict) – canaryd daemon settings
Returns:dictionary of current state items, matching plugin spec
Return type:state (dict)
get_timeout(settings)
log(message)
parse(data)
prepare(settings)

Determine if this plugin can be executed.

Parameters:

settings (dict) – canaryd daemon settings

Raises:
static should_apply_change(change)

Deterime whether a given change should be applied. Executed on the server side on receiving state.

Parameters:change (Change) – a change object
Returns:whether the change should be applied
Return type:status (bool)
validate_state(state)

Validate a given state dict is valid by checking each key/value within an item match up with the spec.

diff_updates = True

Whether to diff state changes or always pass the entire state

generate_added_events = True

Whether to generate added events for this plugin

generate_deleted_events = True

Whether to generate deleted events for this plugin

generate_update_events = True

Whether to generate update events for this plugin

is_slow = False

Whether this plugin is considered “slow” and run less often

warn_for_missing_keys = True

Log warnings for missing keys when validating state items?