The apmec.api.api_common Module

The apmec.api.api_common Module

class apmec.api.api_common.ApmecController(plugin)

Bases: object

Base controller class for Apmec API.

class apmec.api.api_common.NoPaginationHelper(request, primary_key='id')

Bases: apmec.api.api_common.PaginationHelper

class apmec.api.api_common.NoSortingHelper(request, attr_info)

Bases: apmec.api.api_common.SortingHelper

class apmec.api.api_common.PaginationEmulatedHelper(request, primary_key='id')

Bases: apmec.api.api_common.PaginationHelper

paginate(items)
update_fields(original_fields, fields_to_add)
class apmec.api.api_common.PaginationHelper(request, primary_key='id')

Bases: object

paginate(items)
update_args(args)
update_fields(original_fields, fields_to_add)
class apmec.api.api_common.PaginationNativeHelper(request, primary_key='id')

Bases: apmec.api.api_common.PaginationEmulatedHelper

paginate(items)
update_args(args)
class apmec.api.api_common.SortingEmulatedHelper(request, attr_info)

Bases: apmec.api.api_common.SortingHelper

sort(items)
update_fields(original_fields, fields_to_add)
class apmec.api.api_common.SortingHelper(request, attr_info)

Bases: object

sort(items)
update_args(args)
update_fields(original_fields, fields_to_add)
class apmec.api.api_common.SortingNativeHelper(request, attr_info)

Bases: apmec.api.api_common.SortingHelper

update_args(args)
apmec.api.api_common.convert_exception_to_http_exc(e, faults, language)
apmec.api.api_common.get_exception_data(e)

Extract the information about an exception.

Apmec client for the v1 API expects exceptions to have ‘type’, ‘message’ and ‘detail’ attributes.This information is extracted and converted into a dictionary.

Parameters:e – the exception to be reraised
Returns:a structured dict with the exception data
apmec.api.api_common.get_filters(request, attr_info, skips=None)

Extracts the filters from the request string.

Returns a dict of lists for the filters: check=a&check=b&name=Bob& becomes: {‘check’: [u’a’, u’b’], ‘name’: [u’Bob’]}

apmec.api.api_common.get_limit_and_marker(request)

Return marker, limit tuple from request.

Parameters:requestwsgi.Request possibly containing ‘marker’ and ‘limit’ GET variables. ‘marker’ is the id of the last element the client has seen, and ‘limit’ is the maximum number of items to return. If limit == 0, it means we needn’t pagination, then return None.
apmec.api.api_common.get_page_reverse(request)
apmec.api.api_common.get_sorts(request, attr_info)

Extract sort_key and sort_dir from request.

Return as: [(key1, value1), (key2, value2)]

apmec.api.api_common.list_args(request, arg)

Extracts the list of arg from request.

apmec.api.api_common.translate(translatable, locale)

Translates the object to the given locale.

If the object is an exception its translatable elements are translated in place, if the object is a translatable string it is translated and returned. Otherwise, the object is returned as-is.

Parameters:
  • translatable – the object to be translated
  • locale – the locale to translate to
Returns:

the translated object, or the object as-is if it was not translated

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.