google.cloud.forseti.services.actions.action_engine module

The action and action engine API implementations.

class Action(config, action_id, action_type)[source]

Bases: object

The base action class.

__eq__(other)[source]

Tests Action equality.

Parameters:other (Action) – Object to compare to.
Returns:Comparison result.
Return type:bool
__str__()[source]

String representation.

Returns:A string representation of this object.
Return type:str
act(rule_results)[source]

Acts on rule results.

Parameters:rule_results (list) – A list of RuleResults.
Raises:NotImplementedError – When not implemented.
classmethod from_dict(action_dict)[source]

Creates an instance SampleAction from a dictionary.

Parameters:
  • cls (SampleAction) – A SampleAction class.
  • action_dict (dict) – A action configuration dictionary.
Returns:

The configured SampleAction.

Return type:

SampleAction

Raises:

MissingRequiredActionField – If the action_dict is missing a field.

class ActionEngine(config_path)[source]

Bases: object

Action engine API implementation.

_create_actions()[source]

Creates the actions from the configuration.

actions

The configured actions.

Returns:A list of Actions.
Return type:list
process_results(rule_results)[source]

Processes rule results.

Parameters:rule_results (list) – A list of RuleResults.
Returns:A list of ActionResults.
Return type:list
exception ActionImportError[source]

Bases: google.cloud.forseti.services.actions.action_engine.Error

Error raised when an action cannot be imported.

exception Error[source]

Bases: exceptions.Exception

Base error class for this module.

exception MissingRequiredActionField[source]

Bases: google.cloud.forseti.services.actions.action_engine.Error

Error raised when an action configuration is missing a field.

class RuleResult(rule_result, code, action_id, info)

Bases: tuple

__getnewargs__()

Return self as a plain tuple. Used by copy and pickle.

__getstate__()

Exclude the OrderedDict from pickling

__repr__()

Return a nicely formatted representation string

_asdict()

Return a new OrderedDict which maps field names to their values

_fields = ('rule_result', 'code', 'action_id', 'info')
classmethod _make(iterable, new=<built-in method __new__ of type object>, len=<built-in function len>)

Make a new RuleResult object from a sequence or iterable

_replace(**kwds)

Return a new RuleResult object replacing specified fields with new values

action_id
code
info
rule_result
class SampleAction(config, action_id, action_type, code=0, info='')[source]

Bases: google.cloud.forseti.services.actions.action_engine.Action

An example action.

act(rule_results)[source]

Acts on rule results.

Parameters:rule_results (list) – A list of RuleResults.
Yields:dict – A dictionary of rule results.
get_action_class(class_str)[source]

Imports the action class.

Parameters:class_str (str) – A string action class.
Returns:A child class of Action.
Return type:Action
Raises:ActionImportError – If the class doesn’t exist.