本文整理汇总了Python中model.Category.list方法的典型用法代码示例。如果您正苦于以下问题:Python Category.list方法的具体用法?Python Category.list怎么用?Python Category.list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.Category
的用法示例。
在下文中一共展示了Category.list方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: service_category_list
# 需要导入模块: from model import Category [as 别名]
# 或者: from model.Category import list [as 别名]
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())}
示例2: List
# 需要导入模块: from model import Category [as 别名]
# 或者: from model.Category import list [as 别名]
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": [