tacker.api.api_common module

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

Bases: PaginationHelper

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

Bases: SortingHelper

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

Bases: PaginationHelper

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

Bases: object

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

Bases: PaginationEmulatedHelper

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

Bases: SortingHelper

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

Bases: object

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

Bases: SortingHelper

update_args(args)
class tacker.api.api_common.TackerController(plugin)

Bases: object

Base controller class for Tacker API.

tacker.api.api_common.convert_exception_to_http_exc(e, faults, language)
tacker.api.api_common.get_exception_data(e)

Extract the information about an exception.

Tacker 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

tacker.api.api_common.get_filters(request, attr_info, skips=None)

Extract the filters from the request string.

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

tacker.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.

tacker.api.api_common.get_page_reverse(request)
tacker.api.api_common.get_sorts(request, attr_info)

Extract sort_key and sort_dir from request.

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

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

Extract the list of arg from request.

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

Translate 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

tacker.api.api_common.validate_supported_params(supported_params)

Decorator for Restful API methods which specifies supported parameters.

If there are unsupported parameters in the request parameters, the http code 400 Bad Request will be returned and the user will be told which parameters in the request are not supported.