MCPcopy Create free account
hub / github.com/StackStorm/st2 / delete

Method delete

st2api/st2api/controllers/v1/rules.py:250–284  ·  view source on GitHub ↗

Delete a rule. Handles requests: DELETE /rules/1

(self, rule_ref_or_id, requester_user)

Source from the content-addressed store, hash-verified

248 return rule_api
249
250 def delete(self, rule_ref_or_id, requester_user):
251 """
252 Delete a rule.
253
254 Handles requests:
255 DELETE /rules/1
256 """
257 rule_db = self._get_by_ref_or_id(ref_or_id=rule_ref_or_id)
258
259 permission_type = PermissionType.RULE_DELETE
260 rbac_utils = get_rbac_backend().get_utils_class()
261 rbac_utils.assert_user_has_resource_db_permission(
262 user_db=requester_user, resource_db=rule_db, permission_type=permission_type
263 )
264
265 LOG.debug(
266 "DELETE /rules/ lookup with id=%s found object: %s", rule_ref_or_id, rule_db
267 )
268 try:
269 Rule.delete(rule_db)
270 except Exception as e:
271 LOG.exception(
272 'Database delete encountered exception during delete of id="%s".',
273 rule_ref_or_id,
274 )
275 abort(http_client.INTERNAL_SERVER_ERROR, six.text_type(e))
276 return
277
278 # use old_rule_db for cleanup.
279 cleanup_trigger_db_for_rule(rule_db)
280
281 extra = {"rule_db": rule_db}
282 LOG.audit("Rule deleted. Rule.id=%s." % (rule_db.id), extra=extra)
283
284 return Response(status=http_client.NO_CONTENT)
285
286
287rule_controller = RuleController()

Callers 15

_handle_executionMethod · 0.45
_update_to_scheduledMethod · 0.45
test_next_executionMethod · 0.45
test_failed_next_itemMethod · 0.45
test_action_updateMethod · 0.45
tearDownClassMethod · 0.45
__do_deleteMethod · 0.45

Calls 7

get_rbac_backendFunction · 0.90
abortFunction · 0.90
ResponseClass · 0.90
_get_by_ref_or_idMethod · 0.45
get_utils_classMethod · 0.45

Tested by 15

test_next_executionMethod · 0.36
test_failed_next_itemMethod · 0.36
test_action_updateMethod · 0.36
tearDownClassMethod · 0.36
__do_deleteMethod · 0.36
_do_deleteMethod · 0.36
test_get_one_by_idMethod · 0.36
test_get_one_by_refMethod · 0.36
test_get_oneMethod · 0.36
test_get_one_refMethod · 0.36