octavia.api.common package

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]
class QueryParametersHook[source]

Bases: pecan.hooks.PecanHook

before(state)[source]

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)[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

Return type:sqlalchemy.orm.query.Query
Returns:The query with sorting/pagination/filtering added.

octavia.api.common.types module

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
class IPAddressType[source]

Bases: wsme.types.UserType

basetype

alias of unicode

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 unicode

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

Bases: wsme.types.UserType

basetype

alias of unicode

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

Module contents

Creative Commons Attribution 3.0 License

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.