本文整理汇总了Python中portalpy.Portal.delete_user方法的典型用法代码示例。如果您正苦于以下问题:Python Portal.delete_user方法的具体用法?Python Portal.delete_user怎么用?Python Portal.delete_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类portalpy.Portal
的用法示例。
在下文中一共展示了Portal.delete_user方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from portalpy import Portal [as 别名]
# 或者: from portalpy.Portal import delete_user [as 别名]
def main():
scriptName = sys.argv[0]
specified_users = None
# ---------------------------------------------------------------------
# Check arguments
# ---------------------------------------------------------------------
if len(sys.argv) < 4:
print '\n' + scriptName + ' <PortalURL> <AdminUser> <AdminPassword> {UsersToDelete}'
print '\nWhere:'
print '\n\t<PortalURL> (required parameter): URL of Portal to delete content (i.e. https://fully_qualified_domain_name/arcgis)'
print '\n\t<AdminUser> (required parameter): Portal user that has administrator role.'
print '\n\t<AdminPassword> (required parameter): Password for AdminUser.'
print '\n\t{UsersToDelete} (optional):'
print '\t\t-By default, all users are deleted.'
print '\t\t-To delete only specific users, specify comma delimited list of users, i.e. user1,user2,...'
print '\t\t-To delete ALL except specific users, specify comma delimited '
print '\t\t list of users not to delete using "-" prefix, i.e. -user1,user2,...'
sys.exit(1)
# Set variables from script parameters
portal_address = sys.argv[1]
adminuser = sys.argv[2]
adminpassword = sys.argv[3]
if len(sys.argv) > 4:
specified_users = sys.argv[4]
# Add specified user parameter value to exclude list.
if adminuser not in exclude_users:
exclude_users.append(adminuser)
# Create portal object based on specified connection information
portaladmin = Portal(portal_address, adminuser, adminpassword)
portalProps = portaladmin.properties
print sectionBreak
print "Deleting Portal Content"
print sectionBreak
print "Portal: " + portaladmin.hostname
print "Hardcoded users to exclude from delete: " + str(exclude_users)
print "User specified users to include/exclude(-) from delete: " + str(specified_users)
print
print "WARNING: this script will delete all user content in the specified portal: "
print portaladmin.url + "\n"
user_response = raw_input("Do you want to continue? Enter 'y' to continue: ")
if not val_user_response(user_response):
print "Exiting script..."
sys.exit(1)
# get a list of users
portal_users_to_del = val_arg_users(portaladmin, specified_users)
# Remove excluded users from list of users to delete
for user_to_del in portal_users_to_del:
if user_to_del['username'].lower() in exclude_users:
portal_users_to_del.remove(user_to_del)
if len(portal_users_to_del) == 0:
print "\nWARNING: there are no users to delete. Exiting script."
sys.exit(1)
# remove their groups and items
for user_dict in portal_users_to_del:
current_user = user_dict['username']
print sectionBreak
print "User: \t" + current_user
# Delete the user and all owned groups and content
resp = portaladmin.delete_user(current_user, cascade=True)
printResponse(resp)
print "\nDONE: Finished deleting content from portal."
示例2: delete_non_admin_users
# 需要导入模块: from portalpy import Portal [as 别名]
# 或者: from portalpy.Portal import delete_user [as 别名]
def delete_non_admin_users():
portal = Portal('http://wittm.esri.com', 'admin', 'esri.agp')
users = portal.org_users(['username', 'role'])
for user in users:
if user['role'] != 'org_admin':
portal.delete_user(user['username'], cascade=True)
示例3: main
# 需要导入模块: from portalpy import Portal [as 别名]
# 或者: from portalpy.Portal import delete_user [as 别名]
def main():
scriptName = sys.argv[0]
# ---------------------------------------------------------------------
# Check arguments
# ---------------------------------------------------------------------
if len(sys.argv) <> 4:
print '\n' + scriptName + ' <PortalURL> <AdminUser> <AdminPassword>'
print '\nWhere:'
print '\n\t<PortalURL> (required parameter): URL of Portal to delete content (i.e. https://fully_qualified_domain_name/arcgis)'
print '\n\t<AdminUser> (required parameter): Portal user that has administrator role.'
print '\n\t<AdminPassword> (required parameter): Password for AdminUser.\n'
sys.exit(1)
# Set variables from script parameters
portal_address = sys.argv[1]
adminuser = sys.argv[2]
adminpassword = sys.argv[3]
# Add specified user parameter value to exclude list.
if adminuser not in exclude_users:
exclude_users.append(adminuser)
# Create portal object based on specified connection information
portaladmin = Portal(portal_address, adminuser, adminpassword)
portalProps = portaladmin.properties
print sectionBreak
print "Deleting Portal Content"
print sectionBreak
print "Portal: " + portaladmin.hostname
print "Excluded users: " + str(exclude_users)
print
print "WARNING: this script will delete all user content in the specified portal: "
print portaladmin.url + "\n"
user_response = raw_input("Do you want to continue? Enter 'y' to continue: ")
if not val_user_response(user_response):
print "Exiting script..."
sys.exit(1)
# get a list of users
portal_users = portaladmin.users()
# Create list of users to delete
portal_users_to_del = []
for portal_user in portal_users:
if portal_user['username'] not in exclude_users:
portal_users_to_del.append(portal_user)
if len(portal_users_to_del) == 0:
print "\nWARNING: there are no users to delete. Exiting script."
sys.exit(1)
# remove their groups and items
for user_dict in portal_users_to_del:
current_user = user_dict['username']
print sectionBreak
print "User: \t" + current_user
# Delete the user and all owned groups and content
resp = portaladmin.delete_user(current_user, cascade=True)
printResponse(resp)
print "\nDONE: Finished deleting content from portal."