def unregister(request):
""" Deregister a service
:Example: curl -X DELETE http://localhost:8082/foglamp/service/dc9bfc01-066a-4cc0-b068-9c35486db87f
"""
try:
service_id = request.match_info.get('service_id', None)
if not service_id:
raise web.HTTPBadRequest(reason='Service id is required')
try:
Service.Instances.get(idx=service_id)
except Service.DoesNotExist:
raise web.HTTPBadRequest(reason='Service with {} does not exist'.format(service_id))
Service.Instances.unregister(service_id)
_resp = {'id': str(service_id), 'message': 'Service unregistered'}
return web.json_response(_resp)
except ValueError as ex:
raise web.HTTPNotFound(reason=str(ex))
评论列表
文章目录