congress.api.library_policy_model module

class congress.api.library_policy_model.LibraryPolicyModel(name, bus=None)

Bases: congress.api.base.APIModel

Model for handling API requests about Library Policies.

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

Add item to model.

Param

item: The item to add to the model

Param

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

Param

id_: The unique name of the item

Param

context: Key-values providing frame of reference of request

Returns

Tuple of (ID, newly_created_item)

Raises
delete_item(id_, params, context=None)

Remove item from model.

Param

id_: The unique name of the item to be removed

Param

params:

Param

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 from model.

Param

id_: The id of the item to retrieve

Param

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

Param

context: Key-values providing frame of reference of request

Returns

The matching item or None if no item with id exists.

get_items(params, context=None)

Get items in model.

Param

params: A dict-like object containing parameters from the request query string and body. The name parameter filters results by name policy name.

Param

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.

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

Replace item with id_ with new data.

Param

id_: The ID of the item to be replaced

Param

item: The new item

Param

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

Param

context: Key-values providing frame of reference of request

Returns

The new item after replacement.

Raises

KeyError – Item with specified id_ not present.