The watcher.db.api Module

Base classes for storage engines

class watcher.db.api.BaseConnection[source]

Bases: object

Base class for storage system connections.

create_action(values)[source]

Create a new action.

Parameters:values

A dict containing several items used to identify and track the action, and several dicts which are passed into the Drivers when managing this action. For example:

{
 'uuid': utils.generate_uuid(),
 'name': 'example',
 'description': 'free text description'
 'aggregate': 'nova aggregate name or uuid'
}
Returns:A action.
Raises:ActionAlreadyExists
create_action_plan(values)[source]

Create a new action plan.

Parameters:values – A dict containing several items used to identify and track the action plan.
Returns:An action plan.
Raises:ActionPlanAlreadyExists
create_audit(values)[source]

Create a new audit.

Parameters:values

A dict containing several items used to identify and track the audit, and several dicts which are passed into the Drivers when managing this audit. For example:

{
 'uuid': utils.generate_uuid(),
 'type': 'ONESHOT',
}
Returns:An audit.
Raises:AuditAlreadyExists
create_audit_template(values)[source]

Create a new audit template.

Parameters:values

A dict containing several items used to identify and track the audit template. For example:

{
 'uuid': utils.generate_uuid(),
 'name': 'example',
 'description': 'free text description'
 'goal': 'DUMMY'
}
Returns:An audit template.
Raises:AuditTemplateAlreadyExists
create_efficacy_indicator(values)[source]

Create a new efficacy indicator.

Parameters:values

A dict containing items used to identify and track the efficacy indicator. For example:

{
 'id': 1,
 'uuid': utils.generate_uuid(),
 'name': 'my_efficacy_indicator',
 'display_name': 'My efficacy indicator',
 'goal_uuid': utils.generate_uuid(),
}
Returns:An efficacy_indicator
Raises:EfficacyIndicatorAlreadyExists
create_goal(values)[source]

Create a new goal.

Parameters:values

A dict containing several items used to identify and track the goal. For example:

{
 'uuid': utils.generate_uuid(),
 'name': 'DUMMY',
 'display_name': 'Dummy',
}
Returns:A goal
Raises:GoalAlreadyExists
create_scoring_engine(values)[source]

Create a new scoring engine.

Parameters:values – A dict containing several items used to identify and track the scoring engine.
Returns:A scoring engine.
Raises:ScoringEngineAlreadyExists
create_service(values)[source]

Create a new service.

Parameters:values

A dict containing items used to identify and track the service. For example:

{
 'id': 1,
 'name': 'watcher-api',
 'status': 'ACTIVE',
 'host': 'controller'
}
Returns:A service
Raises:ServiceAlreadyExists
create_strategy(values)[source]

Create a new strategy.

Parameters:values

A dict containing items used to identify and track the strategy. For example:

{
 'id': 1,
 'uuid': utils.generate_uuid(),
 'name': 'my_strategy',
 'display_name': 'My strategy',
 'goal_uuid': utils.generate_uuid(),
}
Returns:A strategy
Raises:StrategyAlreadyExists
destroy_action(action_id)[source]

Destroy a action and all associated interfaces.

Parameters:action_id – The id or uuid of a action.
Raises:ActionNotFound
Raises:ActionReferenced
destroy_action_plan(action_plan_id)[source]

Destroy an action plan and all associated interfaces.

Parameters:action_plan_id – The id or uuid of a action plan.
Raises:ActionPlanNotFound
Raises:ActionPlanReferenced
destroy_audit(audit_id)[source]

Destroy an audit and all associated action plans.

Parameters:audit_id – The id or uuid of an audit.
Raises:AuditNotFound
destroy_audit_template(audit_template_id)[source]

Destroy an audit template.

Parameters:audit_template_id – The id or uuid of an audit template.
Raises:AuditTemplateNotFound
destroy_efficacy_indicator(efficacy_indicator_uuid)[source]

Destroy an efficacy indicator.

Parameters:efficacy_indicator_uuid – The UUID of an efficacy indicator
Raises:EfficacyIndicatorNotFound
destroy_goal(goal_uuid)[source]

Destroy a goal.

Parameters:goal_uuid – The UUID of a goal
Raises:GoalNotFound
destroy_scoring_engine(scoring_engine_id)[source]

Destroy a scoring engine.

Parameters:scoring_engine_id – The id of a scoring engine.
Raises:ScoringEngineNotFound
destroy_service(service_id)[source]

Destroy a service.

Parameters:service_id – The ID of a service
Raises:ServiceNotFound
destroy_strategy(strategy_uuid)[source]

Destroy a strategy.

Parameters:strategy_uuid – The UUID of a strategy
Raises:StrategyNotFound
get_action_by_id(context, action_id, eager=False)[source]

Return a action.

Parameters:
  • context – The security context
  • action_id – The id of a action.
  • eager – If True, also loads One-to-X data (Default: False)
Returns:

A action.

Raises:

ActionNotFound

get_action_by_uuid(context, action_uuid, eager=False)[source]

Return a action.

Parameters:
  • context – The security context
  • action_uuid – The uuid of a action.
  • eager – If True, also loads One-to-X data (Default: False)
Returns:

A action.

Raises:

ActionNotFound

get_action_list(context, filters=None, limit=None, marker=None, sort_key=None, sort_dir=None, eager=False)[source]

Get specific columns for matching actions.

Return a list of the specified columns for all actions that match the specified filters.

Parameters:
  • context – The security context
  • filters – Filters to apply. Defaults to None.
  • limit – Maximum number of actions to return.
  • marker – the last item of the previous page; we return the next result set.
  • sort_key – Attribute by which results should be sorted.
  • sort_dir – direction in which results should be sorted. (asc, desc)
  • eager – If True, also loads One-to-X data (Default: False)
Returns:

A list of tuples of the specified columns.

get_action_plan_by_id(context, action_plan_id, eager=False)[source]

Return an action plan.

Parameters:
  • context – The security context
  • action_plan_id – The id of an action plan.
  • eager – If True, also loads One-to-X data (Default: False)
Returns:

An action plan.

Raises:

ActionPlanNotFound

get_action_plan_by_uuid(context, action_plan__uuid, eager=False)[source]

Return a action plan.

Parameters:
  • context – The security context
  • action_plan__uuid – The uuid of an action plan.
  • eager – If True, also loads One-to-X data (Default: False)
Returns:

An action plan.

Raises:

ActionPlanNotFound

get_action_plan_list(context, filters=None, limit=None, marker=None, sort_key=None, sort_dir=None, eager=False)[source]

Get specific columns for matching action plans.

Return a list of the specified columns for all action plans that match the specified filters.

Parameters:
  • context – The security context
  • filters – Filters to apply. Defaults to None.
  • limit – Maximum number of audits to return.
  • marker – the last item of the previous page; we return the next result set.
  • sort_key – Attribute by which results should be sorted.
  • sort_dir – direction in which results should be sorted. (asc, desc)
  • eager – If True, also loads One-to-X data (Default: False)
Returns:

A list of tuples of the specified columns.

get_audit_by_id(context, audit_id, eager=False)[source]

Return an audit.

Parameters:
  • context – The security context
  • audit_id – The id of an audit.
  • eager – If True, also loads One-to-X data (Default: False)
Returns:

An audit.

Raises:

AuditNotFound

get_audit_by_uuid(context, audit_uuid, eager=False)[source]

Return an audit.

Parameters:
  • context – The security context
  • audit_uuid – The uuid of an audit.
  • eager – If True, also loads One-to-X data (Default: False)
Returns:

An audit.

Raises:

AuditNotFound

get_audit_list(context, filters=None, limit=None, marker=None, sort_key=None, sort_dir=None, eager=False)[source]

Get specific columns for matching audits.

Return a list of the specified columns for all audits that match the specified filters.

Parameters:
  • context – The security context
  • filters – Filters to apply. Defaults to None.
  • limit – Maximum number of audits to return.
  • marker – the last item of the previous page; we return the next result set.
  • sort_key – Attribute by which results should be sorted.
  • sort_dir – direction in which results should be sorted. (asc, desc)
  • eager – If True, also loads One-to-X data (Default: False)
Returns:

A list of tuples of the specified columns.

get_audit_template_by_id(context, audit_template_id, eager=False)[source]

Return an audit template.

Parameters:
  • context – The security context
  • audit_template_id – The id of an audit template.
  • eager – If True, also loads One-to-X data (Default: False)
Returns:

An audit template.

Raises:

AuditTemplateNotFound

get_audit_template_by_name(context, audit_template_name, eager=False)[source]

Return an audit template.

Parameters:
  • context – The security context
  • audit_template_name – The name of an audit template.
  • eager – If True, also loads One-to-X data (Default: False)
Returns:

An audit template.

Raises:

AuditTemplateNotFound

get_audit_template_by_uuid(context, audit_template_uuid, eager=False)[source]

Return an audit template.

Parameters:
  • context – The security context
  • audit_template_uuid – The uuid of an audit template.
  • eager – If True, also loads One-to-X data (Default: False)
Returns:

An audit template.

Raises:

AuditTemplateNotFound

get_audit_template_list(context, filters=None, limit=None, marker=None, sort_key=None, sort_dir=None, eager=False)[source]

Get specific columns for matching audit templates.

Return a list of the specified columns for all audit templates that match the specified filters.

Parameters:
  • context – The security context
  • filters – Filters to apply. Defaults to None.
  • limit – Maximum number of audit templates to return.
  • marker – the last item of the previous page; we return the next result set.
  • sort_key – Attribute by which results should be sorted.
  • sort_dir – direction in which results should be sorted. (asc, desc)
  • eager – If True, also loads One-to-X data (Default: False)
Returns:

A list of tuples of the specified columns.

get_efficacy_indicator_by_id(context, efficacy_indicator_id, eager=False)[source]

Return an efficacy indicator given its ID.

Parameters:
  • context – The security context
  • efficacy_indicator_id – The ID of an efficacy indicator
  • eager – If True, also loads One-to-X data (Default: False)
Returns:

An efficacy indicator

Raises:

EfficacyIndicatorNotFound

get_efficacy_indicator_by_name(context, efficacy_indicator_name, eager=False)[source]

Return an efficacy indicator given its name.

Parameters:
  • context – The security context
  • efficacy_indicator_name – The name of an efficacy indicator
  • eager – If True, also loads One-to-X data (Default: False)
Returns:

An efficacy indicator

Raises:

EfficacyIndicatorNotFound

get_efficacy_indicator_by_uuid(context, efficacy_indicator_uuid, eager=False)[source]

Return an efficacy indicator given its UUID.

Parameters:
  • context – The security context
  • efficacy_indicator_uuid – The UUID of an efficacy indicator
  • eager – If True, also loads One-to-X data (Default: False)
Returns:

An efficacy indicator

Raises:

EfficacyIndicatorNotFound

get_efficacy_indicator_list(context, filters=None, limit=None, marker=None, sort_key=None, sort_dir=None, eager=False)[source]

Get specific columns for matching efficacy indicators.

Return a list of the specified columns for all efficacy indicators that match the specified filters.

Parameters:
  • context – The security context
  • columns – List of column names to return. Defaults to ‘id’ column when columns == None.
  • filters – Filters to apply. Defaults to None.
  • limit – Maximum number of efficacy indicators to return.
  • marker – The last item of the previous page; we return the next result set.
  • sort_key – Attribute by which results should be sorted.
  • sort_dir – Direction in which results should be sorted. (asc, desc)
  • eager – If True, also loads One-to-X data (Default: False)
Returns:

A list of tuples of the specified columns.

get_goal_by_id(context, goal_id, eager=False)[source]

Return a goal given its ID.

Parameters:
  • context – The security context
  • goal_id – The ID of a goal
  • eager – If True, also loads One-to-X data (Default: False)
Returns:

A goal

Raises:

GoalNotFound

get_goal_by_name(context, goal_name, eager=False)[source]

Return a goal given its name.

Parameters:
  • context – The security context
  • goal_name – The name of a goal
  • eager – If True, also loads One-to-X data (Default: False)
Returns:

A goal

Raises:

GoalNotFound

get_goal_by_uuid(context, goal_uuid, eager=False)[source]

Return a goal given its UUID.

Parameters:
  • context – The security context
  • goal_uuid – The UUID of a goal
  • eager – If True, also loads One-to-X data (Default: False)
Returns:

A goal

Raises:

GoalNotFound

get_goal_list(context, filters=None, limit=None, marker=None, sort_key=None, sort_dir=None, eager=False)[source]

Get specific columns for matching goals.

Return a list of the specified columns for all goals that match the specified filters.

Parameters:
  • context – The security context
  • filters – Filters to apply. Defaults to None.
  • limit – Maximum number of goals to return.
  • marker – the last item of the previous page; we return the next result set.
  • sort_key – Attribute by which results should be sorted.
  • sort_dir – direction in which results should be sorted. (asc, desc)
  • eager – If True, also loads One-to-X data (Default: False)
Returns:

A list of tuples of the specified columns.

get_scoring_engine_by_id(context, scoring_engine_id, eager=False)[source]

Return a scoring engine by its id.

Parameters:
  • context – The security context
  • scoring_engine_id – The id of a scoring engine.
  • eager – If True, also loads One-to-X data (Default: False)
Returns:

A scoring engine.

Raises:

ScoringEngineNotFound

get_scoring_engine_by_name(context, scoring_engine_name, eager=False)[source]

Return a scoring engine by its name.

Parameters:
  • context – The security context
  • scoring_engine_name – The name of a scoring engine.
  • eager – If True, also loads One-to-X data (Default: False)
Returns:

A scoring engine.

Raises:

ScoringEngineNotFound

get_scoring_engine_by_uuid(context, scoring_engine_uuid, eager=False)[source]

Return a scoring engine by its uuid.

Parameters:
  • context – The security context
  • scoring_engine_uuid – The uuid of a scoring engine.
  • eager – If True, also loads One-to-X data (Default: False)
Returns:

A scoring engine.

Raises:

ScoringEngineNotFound

get_scoring_engine_list(context, columns=None, filters=None, limit=None, marker=None, sort_key=None, sort_dir=None, eager=False)[source]

Get specific columns for matching scoring engines.

Return a list of the specified columns for all scoring engines that match the specified filters.

Parameters:
  • context – The security context
  • columns – List of column names to return. Defaults to ‘id’ column when columns == None.
  • filters – Filters to apply. Defaults to None.
  • limit – Maximum number of scoring engines to return.
  • marker – the last item of the previous page; we return the next result set.
  • sort_key – Attribute by which results should be sorted.
  • sort_dir – direction in which results should be sorted. (asc, desc)
  • eager – If True, also loads One-to-X data (Default: False)
Returns:

A list of tuples of the specified columns.

get_service_by_id(context, service_id, eager=False)[source]

Return a service given its ID.

Parameters:
  • context – The security context
  • service_id – The ID of a service
  • eager – If True, also loads One-to-X data (Default: False)
Returns:

A service

Raises:

ServiceNotFound

get_service_by_name(context, service_name, eager=False)[source]

Return a service given its name.

Parameters:
  • context – The security context
  • service_name – The name of a service
  • eager – If True, also loads One-to-X data (Default: False)
Returns:

A service

Raises:

ServiceNotFound

get_service_list(context, filters=None, limit=None, marker=None, sort_key=None, sort_dir=None, eager=False)[source]

Get specific columns for matching services.

Return a list of the specified columns for all services that match the specified filters.

Parameters:
  • context – The security context
  • filters – Filters to apply. Defaults to None.
  • limit – Maximum number of services to return.
  • marker – The last item of the previous page; we return the next result set.
  • sort_key – Attribute by which results should be sorted.
  • sort_dir – Direction in which results should be sorted. (asc, desc)
  • eager – If True, also loads One-to-X data (Default: False)
Returns:

A list of tuples of the specified columns.

get_strategy_by_id(context, strategy_id, eager=False)[source]

Return a strategy given its ID.

Parameters:
  • context – The security context
  • strategy_id – The ID of a strategy
  • eager – If True, also loads One-to-X data (Default: False)
Returns:

A strategy

Raises:

StrategyNotFound

get_strategy_by_name(context, strategy_name, eager=False)[source]

Return a strategy given its name.

Parameters:
  • context – The security context
  • strategy_name – The name of a strategy
  • eager – If True, also loads One-to-X data (Default: False)
Returns:

A strategy

Raises:

StrategyNotFound

get_strategy_by_uuid(context, strategy_uuid, eager=False)[source]

Return a strategy given its UUID.

Parameters:
  • context – The security context
  • strategy_uuid – The UUID of a strategy
  • eager – If True, also loads One-to-X data (Default: False)
Returns:

A strategy

Raises:

StrategyNotFound

get_strategy_list(context, filters=None, limit=None, marker=None, sort_key=None, sort_dir=None, eager=True)[source]

Get specific columns for matching strategies.

Return a list of the specified columns for all strategies that match the specified filters.

Parameters:
  • context – The security context
  • filters – Filters to apply. Defaults to None.
  • limit – Maximum number of strategies to return.
  • marker – The last item of the previous page; we return the next result set.
  • sort_key – Attribute by which results should be sorted.
  • sort_dir – Direction in which results should be sorted. (asc, desc)
  • eager – If True, also loads One-to-X data (Default: False)
Returns:

A list of tuples of the specified columns.

soft_delete_action(action_id)[source]

Soft delete an action.

Parameters:action_id – The id or uuid of an action.
Raises:ActionNotFound
soft_delete_action_plan(action_plan_id)[source]

Soft delete an action plan.

Parameters:action_plan_id – The id or uuid of an action plan.
Raises:ActionPlanNotFound
soft_delete_audit(audit_id)[source]

Soft delete an audit and all associated action plans.

Parameters:audit_id – The id or uuid of an audit.
Raises:AuditNotFound
soft_delete_audit_template(audit_template_id)[source]

Soft delete an audit template.

Parameters:audit_template_id – The id or uuid of an audit template.
Raises:AuditTemplateNotFound
soft_delete_goal(goal_id)[source]

Soft delete a goal.

Parameters:goal_id – The id or uuid of a goal.
Raises:GoalNotFound
soft_delete_service(service_id)[source]

Soft delete a service.

Parameters:service_id – The id of a service.
Returns:A service.
Raises:ServiceNotFound
soft_delete_strategy(strategy_id)[source]

Soft delete a strategy.

Parameters:strategy_id – The id or uuid of a strategy.
Raises:StrategyNotFound
update_action(action_id, values)[source]

Update properties of a action.

Parameters:action_id – The id or uuid of a action.
Returns:A action.
Raises:ActionNotFound
Raises:ActionReferenced
Raises:Invalid
update_action_plan(action_plan_id, values)[source]

Update properties of an action plan.

Parameters:action_plan_id – The id or uuid of an action plan.
Returns:An action plan.
Raises:ActionPlanNotFound
Raises:ActionPlanReferenced
Raises:Invalid
update_audit(audit_id, values)[source]

Update properties of an audit.

Parameters:audit_id – The id or uuid of an audit.
Returns:An audit.
Raises:AuditNotFound
Raises:Invalid
update_audit_template(audit_template_id, values)[source]

Update properties of an audit template.

Parameters:audit_template_id – The id or uuid of an audit template.
Returns:An audit template.
Raises:AuditTemplateNotFound
Raises:Invalid
update_efficacy_indicator(efficacy_indicator_id, values)[source]

Update properties of an efficacy indicator.

Parameters:efficacy_indicator_uuid – The UUID of an efficacy indicator
Returns:An efficacy indicator
Raises:EfficacyIndicatorNotFound
Raises:Invalid
update_goal(goal_uuid, values)[source]

Update properties of a goal.

Parameters:
  • goal_uuid – The UUID of a goal
  • values

    A dict containing several items used to identify and track the goal. For example:

    {
     'uuid': utils.generate_uuid(),
     'name': 'DUMMY',
     'display_name': 'Dummy',
    }
    
Returns:

A goal

Raises:

GoalNotFound

Raises:

Invalid

update_scoring_engine(scoring_engine_id, values)[source]

Update properties of a scoring engine.

Parameters:scoring_engine_id – The id of a scoring engine.
Returns:A scoring engine.
Raises:ScoringEngineNotFound
Raises:Invalid
update_service(service_id, values)[source]

Update properties of a service.

Parameters:service_id – The ID of a service
Returns:A service
Raises:ServiceyNotFound
Raises:Invalid
update_strategy(strategy_uuid, values)[source]

Update properties of a strategy.

Parameters:strategy_uuid – The UUID of a strategy
Returns:A strategy
Raises:StrategyNotFound
Raises:Invalid