本文整理汇总了Python中st2common.persistence.action.Action.delete方法的典型用法代码示例。如果您正苦于以下问题:Python Action.delete方法的具体用法?Python Action.delete怎么用?Python Action.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类st2common.persistence.action.Action
的用法示例。
在下文中一共展示了Action.delete方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: tearDownClass
# 需要导入模块: from st2common.persistence.action import Action [as 别名]
# 或者: from st2common.persistence.action.Action import delete [as 别名]
def tearDownClass(cls):
for actiondb in cls.actiondbs.values():
Action.delete(actiondb)
RunnerType.delete(cls.runnerdb)
super(TestActionExecutionService, cls).tearDownClass()
示例2: delete
# 需要导入模块: from st2common.persistence.action import Action [as 别名]
# 或者: from st2common.persistence.action.Action import delete [as 别名]
def delete(self, action_ref_or_id):
"""
Delete an action.
Handles requests:
POST /actions/1?_method=delete
DELETE /actions/1
DELETE /actions/mypack.myaction
"""
action_db = self._get_by_ref_or_id(ref_or_id=action_ref_or_id)
action_id = action_db.id
try:
validate_not_part_of_system_pack(action_db)
except ValueValidationException as e:
abort(http_client.BAD_REQUEST, str(e))
LOG.debug('DELETE /actions/ lookup with ref_or_id=%s found object: %s',
action_ref_or_id, action_db)
try:
Action.delete(action_db)
except Exception as e:
LOG.error('Database delete encountered exception during delete of id="%s". '
'Exception was %s', action_id, e)
abort(http_client.INTERNAL_SERVER_ERROR, str(e))
return
extra = {'action_db': action_db}
LOG.audit('Action deleted. Action.id=%s' % (action_db.id), extra=extra)
return None
示例3: test_pack_name_missing
# 需要导入模块: from st2common.persistence.action import Action [as 别名]
# 或者: from st2common.persistence.action.Action import delete [as 别名]
def test_pack_name_missing(self):
registrar = actions_registrar.ActionsRegistrar()
action_file = os.path.join(tests_base.get_fixtures_path(),
'wolfpack/actions/action_3_pack_missing.json')
registrar._register_action('dummy', action_file)
action_name = None
with open(action_file, 'r') as fd:
content = json.load(fd)
action_name = str(content['name'])
action_db = Action.get_by_name(action_name)
self.assertEqual(action_db.pack, 'dummy', 'Content pack must be ' +
'set to dummy')
Action.delete(action_db)
示例4: test_pack_name_missing
# 需要导入模块: from st2common.persistence.action import Action [as 别名]
# 或者: from st2common.persistence.action.Action import delete [as 别名]
def test_pack_name_missing(self):
registrar = actions_registrar.ActionsRegistrar()
loader = fixtures_loader.FixturesLoader()
action_file = loader.get_fixture_file_path_abs(
'generic', 'actions', 'action_3_pack_missing.yaml')
registrar._register_action('dummy', action_file)
action_name = None
with open(action_file, 'r') as fd:
content = yaml.safe_load(fd)
action_name = str(content['name'])
action_db = Action.get_by_name(action_name)
self.assertEqual(action_db.pack, 'dummy', 'Content pack must be ' +
'set to dummy')
Action.delete(action_db)
示例5: test_action_update
# 需要导入模块: from st2common.persistence.action import Action [as 别名]
# 或者: from st2common.persistence.action.Action import delete [as 别名]
def test_action_update(self):
registrar = actions_registrar.ActionsRegistrar()
loader = fixtures_loader.FixturesLoader()
action_file = loader.get_fixture_file_path_abs(
'generic', 'actions', 'action1.yaml')
registrar._register_action('wolfpack', action_file)
# try registering again. this should not throw errors.
registrar._register_action('wolfpack', action_file)
action_name = None
with open(action_file, 'r') as fd:
content = yaml.safe_load(fd)
action_name = str(content['name'])
action_db = Action.get_by_name(action_name)
self.assertEqual(action_db.pack, 'wolfpack', 'Content pack must be ' +
'set to wolfpack')
Action.delete(action_db)
示例6: delete
# 需要导入模块: from st2common.persistence.action import Action [as 别名]
# 或者: from st2common.persistence.action.Action import delete [as 别名]
def delete(self, ref_or_id, requester_user):
"""
Delete an action.
Handles requests:
POST /actions/1?_method=delete
DELETE /actions/1
DELETE /actions/mypack.myaction
"""
action_db = self._get_by_ref_or_id(ref_or_id=ref_or_id)
action_id = action_db.id
permission_type = PermissionType.ACTION_DELETE
rbac_utils = get_rbac_backend().get_utils_class()
rbac_utils.assert_user_has_resource_db_permission(user_db=requester_user,
resource_db=action_db,
permission_type=permission_type)
try:
validate_not_part_of_system_pack(action_db)
except ValueValidationException as e:
abort(http_client.BAD_REQUEST, six.text_type(e))
LOG.debug('DELETE /actions/ lookup with ref_or_id=%s found object: %s',
ref_or_id, action_db)
try:
Action.delete(action_db)
except Exception as e:
LOG.error('Database delete encountered exception during delete of id="%s". '
'Exception was %s', action_id, e)
abort(http_client.INTERNAL_SERVER_ERROR, six.text_type(e))
return
extra = {'action_db': action_db}
LOG.audit('Action deleted. Action.id=%s' % (action_db.id), extra=extra)
return Response(status=http_client.NO_CONTENT)
示例7: tearDown
# 需要导入模块: from st2common.persistence.action import Action [as 别名]
# 或者: from st2common.persistence.action.Action import delete [as 别名]
def tearDown(self):
Action.delete(ACTION)
RunnerType.delete(RUNNER_TYPE)
Trigger.delete(TRIGGER)