def delete_configuration_item_value(request):
"""
Args:
request: category_name, config_item are required
Returns:
set the configuration item value to empty string in the given category
:Example:
curl -X DELETE http://localhost:8081/foglamp/category/{category_name}/{config_item}/value
For {category_name}=>PURGE delete value for {config_item}=>age
curl -X DELETE http://localhost:8081/foglamp/category/PURGE/age/value
"""
category_name = request.match_info.get('category_name', None)
config_item = request.match_info.get('config_item', None)
if not category_name or not config_item:
raise web.HTTPBadRequest(reason="Both Category Name and Config items are required")
# TODO: make it optimized and elegant
cf_mgr = ConfigurationManager(connect.get_storage())
await cf_mgr.set_category_item_value_entry(category_name, config_item, '')
result = await cf_mgr.get_category_item(category_name, config_item)
if result is None:
raise web.HTTPNotFound(reason="No detail found for the category_name: {} and config_item: {}".format(category_name, config_item))
return web.json_response(result)
评论列表
文章目录