CÓMO
Al reasignar la propiedad de elementos en ArcGIS Online, un paso previo necesario consiste en dejar de compartir elementos de grupos especiales, como los de la funcionalidad Actualizar para todos los miembros, antes de cambiar o reasignar la propiedad. Esto lleva mucho tiempo cuando se reasigna la propiedad de varios elementos compartidos con los grupos de actualizaciones. Por lo tanto, resulta útil automatizar el proceso mediante un script de Python.
Para automatizar el flujo de trabajo, utilice el siguiente script de Python independiente:
from arcgis.gis import * gis = GIS("https://maps_sample.arcgis.com", "username", "password")
orig_userid = "First_User" new_userid = "Second_User" olduser = gis.users.get(orig_userid)
usergroups = olduser.groups for group in usergroups: grp = gis.groups.get(group['id']) if (grp.owner == orig_userid): grp.reassign_to(new_userid) else: grp.add_users(new_userid) grp.remove_users(orig_userid) print("Groups has been transferred!") #Transferring items in folders folders = olduser.folders for folder in folders: gis.content.create_folder(folder['title'], new_userid) folderitems = olduser.items(folder=folder['title']) for item in folderitems: itemgroup=item.shared_with item.unshare(groups=itemgroup['groups']) item.reassign_to(new_userid, target_folder=folder['title']) item.share(groups=itemgroup['groups'], allow_members_to_edit=True) print("Folder content has been transferred!") userrootcontent = olduser.items() rootfoldername=olduser.username+"_RootFolder" gis.content.create_folder(rootfoldername, new_userid)
for item in userrootcontent: itemgroup=item.shared_with item.unshare(groups=itemgroup['groups']) item.reassign_to(new_userid, target_folder=rootfoldername) item.share(groups=itemgroup['groups'], allow_members_to_edit=True) print("Root folder content has been transferred!")
A continuación se muestra la secuencia de comandos completa.
from arcgis.gis import * gis = GIS("https://maps_sample.arcgis.com/", "username", "password") #Identifying users orig_userid = "User1" new_userid = "User2" olduser = gis.users.get(orig_userid) #Transferring the ownership of groups usergroups = olduser.groups for group in usergroups: grp = gis.groups.get(group['id']) if (grp.owner == orig_userid): grp.reassign_to(new_userid) else: grp.add_users(new_userid) grp.remove_users(orig_userid) print("Groups has been transferred!") #Transferring items in folders folders = olduser.folders for folder in folders: gis.content.create_folder(folder['title'], new_userid) folderitems = olduser.items(folder=folder['title']) for item in folderitems: itemgroup=item.shared_with item.unshare(groups=itemgroup['groups']) item.reassign_to(new_userid, target_folder=folder['title']) item.share(groups=itemgroup['groups'], allow_members_to_edit=True) print("Folder content has been transferred!") #Transferring items in the root folder userrootcontent = olduser.items() rootfoldername=olduser.username+"_RootFolder" gis.content.create_folder(rootfoldername, new_userid) for item in userrootcontent: itemgroup=item.shared_with item.unshare(groups=itemgroup['groups']) item.reassign_to(new_userid, target_folder=rootfoldername) item.share(groups=itemgroup['groups'], allow_members_to_edit=True) print("Root folder content has been transferred!")
Obtener ayuda de expertos en ArcGIS
Descargar la aplicación de soporte de Esri