# octavia.api.common package

## Submodules

## octavia.api.common.hooks module

class ContentTypeHook

  Bases: `PecanHook`

  Force the request content type to JSON if that is acceptable.

  on_route(state)

    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 ContextHook

  Bases: `PecanHook`

  Configures a request context and attaches it to the request.

  on_route(state)

    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

  Bases: `PecanHook`

  before(state)

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

  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)

    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 AlpnProtocolType

  Bases: `UserType`

  basetype

    alias of `str`

  name = 'alpn_protocol'
  static validate(value)

    Validates whether value is a valid ALPN protocol ID.

class BaseMeta(name, bases, dct)

  Bases: `BaseMeta`

class BaseType(**kw)

  Bases: `Base`

  classmethod from_data_model(data_model, children=False)

    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)

    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)

    Translate the keys from wsme class type, to data_model.

  classmethod translate_key_to_data_model(key)

    Translate the keys from wsme class type, to data_model.

class CidrType

  Bases: `UserType`

  basetype

    alias of `str`

  name = 'cidr'
  static validate(value)

    Validates whether value is an IPv4 or IPv6 CIDR.

class IPAddressType

  Bases: `UserType`

  basetype

    alias of `str`

  name = 'ipaddress'
  static validate(value)

    Validates whether value is an IPv4 or IPv6 address.

class IdOnlyType(**kw)

  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)

  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)

  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)

class URLPathType

  Bases: `UserType`

  basetype

    alias of `str`

  name = 'url_path'
  static validate(value)

class URLType(require_scheme=True)

  Bases: `UserType`

  basetype

    alias of `str`

  name = 'url'
  validate(value)

## octavia.api.common.utils module

json_error_formatter(body, status, title, environ)

  A json_formatter for webob exceptions.

  Follows API-WG guidelines at http://specs.openstack.org/openstack/api-wg/guidelines/errors.html

## Module contents

this page last updated: 2025-10-06 11:22:08

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

found an error? report a bug