The congress.api.rule_model Module

class congress.api.rule_model.RuleModel(name, bus=None)

Bases: congress.api.base.APIModel

Model for handling API requests about policy Rules.

add_item(item, params, id_=None, context=None)

Add item to model.

Args:

item: The item to add to the model params: A dict-like object containing parameters

from the request query string and body.

id_: The ID of the item, or None if an ID should be generated context: Key-values providing frame of reference of request

Returns:
Tuple of (ID, newly_created_item)
Raises:
KeyError: ID already exists.
delete_item(id_, params, context=None)

Remove item from model.

Args:

id_: The ID of the item to be removed params: A dict-like object containing parameters

from the request query string and body.

context: Key-values providing frame of reference of request

Returns:
The removed item.
Raises:
KeyError: Item with specified id_ not present.
get_item(id_, params, context=None)

Retrieve item with id id_ from model.

Args:

id_: The ID of the item to retrieve params: A dict-like object containing parameters

from the request query string and body.

context: Key-values providing frame of reference of request

Returns:
The matching item or None if item with id_ does not exist.
get_items(params, context=None)

Get items in model.

Args:
params: A dict-like object containing parameters
from the request query string and body.

context: Key-values providing frame of reference of request

Returns: A dict containing at least a ‘results’ key whose value is
a list of items in the model. Additional keys set in the dict will also be rendered for the user.
policy_name(context)