本文整理汇总了Python中st2common.persistence.rbac.Role.delete方法的典型用法代码示例。如果您正苦于以下问题:Python Role.delete方法的具体用法?Python Role.delete怎么用?Python Role.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类st2common.persistence.rbac.Role
的用法示例。
在下文中一共展示了Role.delete方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: delete_role
# 需要导入模块: from st2common.persistence.rbac import Role [as 别名]
# 或者: from st2common.persistence.rbac.Role import delete [as 别名]
def delete_role(name):
""""
Delete role with the provided name.
"""
if name in SystemRole.get_valid_values():
raise ValueError("System roles can't be deleted")
role_db = Role.get(name=name)
result = Role.delete(role_db)
return result
示例2: delete_mistyped_role
# 需要导入模块: from st2common.persistence.rbac import Role [as 别名]
# 或者: from st2common.persistence.rbac.Role import delete [as 别名]
def delete_mistyped_role():
"""
Delete " system_admin" role which was fat fingered.
"""
# Note: Space is significant here since we want to remove a bad role
role_name = ' system_admin'
assert(role_name.startswith(' '))
try:
role_db = Role.get_by_name(role_name)
except:
return
if not role_db:
return
try:
Role.delete(role_db)
except:
return