congress.api.webservice.
AbstractApiHandler
(path_regex)¶Bases: object
Abstract handler for API requests.
handler.
handle_request
(request)¶Handle a REST request.
request: A webob request object.
A webob response object.
handles_request
(request)¶Return true iff handler supports the request.
congress.api.webservice.
CollectionHandler
(path_regex, model, allow_named_create=True, allow_list=True, allow_create=True, allow_replace=False)¶Bases: congress.api.webservice.AbstractApiHandler
API handler for REST collection resources.
REST collections represent collections of entities in the data model, and often support the following operations: - List elements in the collection - Create new element in the collection
The following less-common collection operations are NOT SUPPORTED: - Replace all elements in the collection - Delete all elements in the collection
create_member
(request, id_=None)¶handle_request
(request)¶Handle a REST request.
request: A webob request object.
A webob response object.
list_members
(request)¶replace_members
(request)¶congress.api.webservice.
DataModelException
(error_code, description, data=None, http_status_code=<HTTPStatus.BAD_REQUEST: 400>)¶Bases: Exception
Congress API Data Model Exception
Custom exception raised by API Data Model methods to communicate errors to the API framework.
create
(error)¶Generate a DataModelException from an existing CongressException.
error: has a ‘name’ field corresponding to an error_codes error-name. It may also have a ‘data’ field.
a DataModelException properly populated.
rest_response
()¶congress.api.webservice.
ElementHandler
(path_regex, model, collection_handler=None, allow_read=True, allow_actions=True, allow_replace=True, allow_update=True, allow_delete=True)¶Bases: congress.api.webservice.AbstractApiHandler
API handler for REST element resources.
REST elements represent individual entities in the data model, and often support the following operations: - Read a representation of the element - Update (replace) the entire element with a new version - Update (patch) parts of the element with new values - Delete the element
Elements may also exhibit ‘controller’ semantics for RPC-style method invocation, however this is not currently supported.
action
(request)¶delete
(request)¶handle_request
(request)¶Handle a REST request.
request: A webob request object.
A webob response object.
read
(request)¶replace
(request)¶update
(request)¶congress.api.webservice.
SimpleDataModel
(model_name)¶Bases: object
A container providing access to a single type of data.
add_item
(item, params, id_=None, context=None)¶Add item to model.
item: The item to add to the model
params: A dict-like object containing parameters from the request query string and body.
The ID of the item, or None if an ID should be generated
context: Key-values providing frame of reference of request
Tuple of (ID, newly_created_item)
KeyError – ID already exists.
DataModelException – Addition cannot be performed.
delete_item
(id_, params, context=None)¶Remove item from model.
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
The removed item.
KeyError – Item with specified id_ not present.
get_item
(id_, params, context=None)¶Retrieve item with id id_ from model.
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
The matching item or None if item with id_ does not exist.
get_items
(params, context=None)¶Get items in model.
params: A dict-like object containing parameters from the request query string and body.
context: Key-values providing frame of reference of request
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.
id_: The ID of the item to be replaced item: The new item
params: A dict-like object containing parameters from the request query string and body.
context: Key-values providing frame of reference of request
The new item after replacement.
KeyError – Item with specified id_ not present.
DataModelException – Replacement cannot be performed.
replace_items
(items, params, context=None)¶Replace items in the model.
items: A dict-like object containing new data
params: A dict-like object containing parameters
context: Key-values providing frame of reference of request
None
update_item
(id_, item, params, context=None)¶Update item with id_ with new data.
id_: The ID of the item to be updated item: The new item
params: A dict-like object containing parameters from the request query string and body.
context: Key-values providing frame of reference of request
The updated item.
KeyError – Item with specified id_ not present.
DataModelException – Update cannot be performed.
congress.api.webservice.
error_response
(status, error_code, description, data=None)¶Construct and return an error response.
status: The HTTP status code of the response. error_code: The application-specific error code. description: Friendly G11N-enabled string corresponding to error_code. data: Additional data (not G11N-enabled) for the API consumer.
congress.api.webservice.
original_msg
(e)¶Undo oslo-messaging added traceback to return original exception msg
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.