octavia.api.common package¶
Submodules¶
octavia.api.common.hooks module¶
- class ContentTypeHook[source]¶
Bases:
PecanHook
Force the request content type to JSON if that is acceptable.
octavia.api.common.pagination module¶
- class PaginationHelper(params, sort_dir='asc')[source]¶
Bases:
object
Class helping to interact with pagination functionality
Pass this class to db.repositories to apply it on query
- apply(query, model, enforce_valid_params=True)[source]¶
Returns a query with sorting / pagination criteria added.
Pagination works by requiring a unique sort_key specified by sort_keys. (If sort_keys is not unique, then we risk looping through values.) We use the last row in the previous page as the pagination ‘marker’. So we must return values that follow the passed marker in the order. With a single-valued sort_key, this would be easy: sort_key > X. With a compound-values sort_key, (k1, k2, k3) we must do this to repeat the lexicographical ordering: (k1 > X1) or (k1 == X1 && k2 > X2) or (k1 == X1 && k2 == X2 && k3 > X3) We also have to cope with different sort_directions. Typically, the id of the last row is used as the client-facing pagination marker, then the actual marker object must be fetched from the db and passed in to us as marker. :param query: the query object to which we should add paging/sorting/filtering :param model: the ORM model class :param enforce_valid_params: check for invalid entries in self.params
- Return type:
sqlalchemy.orm.query.Query
- Returns:
The query with sorting/pagination/filtering added.
octavia.api.common.types module¶
- class BaseType(**kw)[source]¶
Bases:
Base
- classmethod from_data_model(data_model, children=False)[source]¶
Converts data_model to Octavia WSME type.
- Parameters:
data_model – data model to convert from
children – convert child data models
- to_dict(render_unsets=False)[source]¶
Converts Octavia WSME type to dictionary.
- Parameters:
render_unsets – If True, will convert items that are WSME Unset types to None. If False, does not add the item
- class IdOnlyType(**kw)[source]¶
Bases:
BaseType
- id¶
Complex type attribute definition.
Example:
class MyComplexType(wsme.types.Base): optionalvalue = int mandatoryvalue = wsattr(int, mandatory=True) named_value = wsattr(int, name='named.value')
After inspection, the non-wsattr attributes will be replaced, and the above class will be equivalent to:
class MyComplexType(wsme.types.Base): optionalvalue = wsattr(int) mandatoryvalue = wsattr(int, mandatory=True)
- class NameOnlyType(**kw)[source]¶
Bases:
BaseType
- name¶
Complex type attribute definition.
Example:
class MyComplexType(wsme.types.Base): optionalvalue = int mandatoryvalue = wsattr(int, mandatory=True) named_value = wsattr(int, name='named.value')
After inspection, the non-wsattr attributes will be replaced, and the above class will be equivalent to:
class MyComplexType(wsme.types.Base): optionalvalue = wsattr(int) mandatoryvalue = wsattr(int, mandatory=True)
- class PageType(**kw)[source]¶
Bases:
BaseType
- href¶
Complex type attribute definition.
Example:
class MyComplexType(wsme.types.Base): optionalvalue = int mandatoryvalue = wsattr(int, mandatory=True) named_value = wsattr(int, name='named.value')
After inspection, the non-wsattr attributes will be replaced, and the above class will be equivalent to:
class MyComplexType(wsme.types.Base): optionalvalue = wsattr(int) mandatoryvalue = wsattr(int, mandatory=True)
- rel¶
Complex type attribute definition.
Example:
class MyComplexType(wsme.types.Base): optionalvalue = int mandatoryvalue = wsattr(int, mandatory=True) named_value = wsattr(int, name='named.value')
After inspection, the non-wsattr attributes will be replaced, and the above class will be equivalent to:
class MyComplexType(wsme.types.Base): optionalvalue = wsattr(int) mandatoryvalue = wsattr(int, mandatory=True)
octavia.api.common.utils module¶
- json_error_formatter(body, status, title, environ)[source]¶
A json_formatter for webob exceptions.
Follows API-WG guidelines at http://specs.openstack.org/openstack/api-wg/guidelines/errors.html