Instrução
Ao reatribuir propriedade de itens no ArcGIS Online, uma etapa de pré-requisito é cancelar o compartilhamento de itens de grupos especiais, como aqueles com o recurso Atualizar para todos os membros, antes de alterar ou reatribuir propriedade. Isso consome tempo ao reatribuir a propriedade de vários itens compartilhados para os grupos de atualização. Portanto, é útil automatizar o processo usando um script de Python.
Para automatizar o fluxo de trabalho, use o seguinte script de Python independnete:
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!")
O seguinte demonstra o script completo.
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!")
Obtenha ajuda de especialistas do ArcGIS
Baixe o Aplicativo de Suporte da Esri