octavia.api.common package

Submodules

octavia.api.common.hooks module

class ContextHook[source]

Bases: pecan.hooks.PecanHook

Configures a request context and attaches it to the request.

on_route(state)[source]

Override this method to create a hook that gets called upon the start of routing.

Parameters

state – The Pecan state object for the current request.

class QueryParametersHook[source]

Bases: pecan.hooks.PecanHook

before(state)[source]

Override this method to create a hook that gets called after routing, but before the request gets passed to your controller.

Parameters

state – The Pecan state object for the current request.

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 enteries in self.params

Return type

sqlalchemy.orm.query.Query

Returns

The query with sorting/pagination/filtering added.

octavia.api.common.types module

class BaseMeta(name, bases, dct)[source]

Bases: wsme.types.BaseMeta

class BaseType(**kw)[source]

Bases: wsme.types.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

classmethod translate_dict_keys_to_data_model(wsme_dict)[source]

Translate the keys from wsme class type, to data_model.

class CidrType[source]

Bases: wsme.types.UserType

basetype

alias of builtins.str

name = 'cidr'
static validate(value)[source]

Validates whether value is an IPv4 or IPv6 CIDR.

class IPAddressType[source]

Bases: wsme.types.UserType

basetype

alias of builtins.str

name = 'ipaddress'
static validate(value)[source]

Validates whether value is an IPv4 or IPv6 address.

class IdOnlyType(**kw)[source]

Bases: octavia.api.common.types.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: octavia.api.common.types.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: octavia.api.common.types.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)
class URLPathType[source]

Bases: wsme.types.UserType

basetype

alias of builtins.str

name = 'url_path'
static validate(value)[source]
class URLType(require_scheme=True)[source]

Bases: wsme.types.UserType

basetype

alias of builtins.str

name = 'url'
validate(value)[source]

Module contents