def delete(self, req, id): context = req.environ["coriolis.context"] context.can(endpoint_policies.get_endpoints_policy_label("delete")) try: self._endpoint_api.delete(req.environ['coriolis.context'], id) raise exc.HTTPNoContent() except exception.NotFound as ex: raise exc.HTTPNotFound(explanation=ex.msg)
def update(self, req, id, body): context = req.environ["coriolis.context"] context.can(endpoint_policies.get_endpoints_policy_label("update")) updated_values = self._validate_update_body(body) return endpoint_view.single( req, self._endpoint_api.update(req.environ['coriolis.context'], id, updated_values))
def show(self, req, id): context = req.environ["coriolis.context"] context.can(endpoint_policies.get_endpoints_policy_label("show")) endpoint = self._endpoint_api.get_endpoint(context, id) if not endpoint: raise exc.HTTPNotFound() return endpoint_view.single(req, endpoint)
def create(self, req, body): context = req.environ["coriolis.context"] context.can(endpoint_policies.get_endpoints_policy_label("create")) (name, endpoint_type, description, connection_info, mapped_regions) = self._validate_create_body(body) return endpoint_view.single( req, self._endpoint_api.create(context, name, endpoint_type, description, connection_info, mapped_regions))
def index(self, req): context = req.environ["coriolis.context"] context.can(endpoint_policies.get_endpoints_policy_label("list")) return endpoint_view.collection( req, self._endpoint_api.get_endpoints(context))