def service_category_list(self): """ Returns list of categories with localized names :return list category_list: List of dict with category **Example**:: {"category_list": [ {"category_id": "net", "localized_name": {"ru": "Сеть", "en": "Network"}}, {"category_id": "storage", "localized_name": {"ru": "Хранение данных", "en": "Storage"}}, {"category_id": "vm", "localized_name": {"ru": "Виртуальные машины", "en": "Virtual machine"}}, {"category_id": "custom", "localized_name": {"ru": "Дополнительные", "en": "Custom"}}]} """ return {"category_list": display(Category.list().values())}
import conf import errors from model import display, autocommit from api import get, post, delete, AdminApi, put from api.check_params import check_params from api.validator import IntRange, String, TokenId, List, Choose, LocalizedName, ModelId, Visibility, Integer from api.admin.role import TokenAdmin, TokenAccount, TokenManager from model import Category, Service, Measure from os_interfaces.openstack_wrapper import openstack from novaclient.exceptions import NotFound CategoryList = List(Choose(list(Category.list().keys()))) MeasureTime = Choose({measure.measure_id: measure for measure in Measure.list(Measure.TIME)}) ServiceIdExpand = ModelId(Service, errors.ServiceNotFound) ServiceId = ModelId(Service, errors.ServiceNotFound, expand=False) class ServiceApi(AdminApi): @get("category/") @check_params( token=TokenId, ) def service_category_list(self): """ Returns list of categories with localized names :return list category_list: List of dict with category **Example**:: {"category_list": [
import conf import errors from model import display, autocommit from api import get, post, delete, AdminApi, put from api.check_params import check_params from api.validator import IntRange, String, TokenId, List, Choose, LocalizedName, ModelId, Visibility, Integer from api.admin.role import TokenAdmin, TokenAccount, TokenManager from model import Category, Service, Measure from os_interfaces.openstack_wrapper import openstack from novaclient.exceptions import NotFound CategoryList = List(Choose(list(Category.list().keys()))) MeasureTime = Choose( {measure.measure_id: measure for measure in Measure.list(Measure.TIME)}) ServiceIdExpand = ModelId(Service, errors.ServiceNotFound) ServiceId = ModelId(Service, errors.ServiceNotFound, expand=False) class ServiceApi(AdminApi): @get("category/") @check_params( token=TokenId, ) def service_category_list(self): """ Returns list of categories with localized names :return list category_list: List of dict with category **Example**::