How to use the arcgis.gis.sharing modle

326
1
Jump to solution
12-06-2023 04:57 PM
SFM_TravisBott
Occasional Contributor III

I have a workflow that involves managing content and users between our organizational account and our Hub account. This process involves hundreds of groups that will require a half-dozen users each. An important piece of the puzzle is a script that invites my Hub account into all of the several hundred groups (as a manager) so that, from that Hub account, another script can run that creates the users and adds them to their respective groups. 

Finding my relevant groups and inviting my Hub account is no problem. However, I would like to be able to accept all of those invitations within the script, so I don't have to click 'accept' five hundred times. 

According to the documentation, the gis.sharing module, and calling the UserInvitationManager, should do the trick. However, I keep getting property map errors when I attempt to access invitations.

 

from arcgis.gis import sharing as GIShare

user = gis.properties.user

GIShare.UserInvitationManager(user=user)

 

SFM_TravisBott_0-1701910578773.png

Looking for some guidance on how to use this....apologies if I'm overlooking something obvious as I'm a bit of a novice. There's not a lot of documentation. 

0 Kudos
1 Solution

Accepted Solutions
SFM_TravisBott
Occasional Contributor III

Figured this out. I was using the wrong type of user object and missed in the documentation the need to access the list property for the invitation manager. To find and accept all of your invitations for a user...

from arcgis.gis import sharing as GIShare

user = gis.users.get('UserName')
invitationManager = GIShare.UserInvitationManager(user=user)
inviteList = invitationManager.list

for invite in invitationsList:
    invite.accept()

View solution in original post

0 Kudos
1 Reply
SFM_TravisBott
Occasional Contributor III

Figured this out. I was using the wrong type of user object and missed in the documentation the need to access the list property for the invitation manager. To find and accept all of your invitations for a user...

from arcgis.gis import sharing as GIShare

user = gis.users.get('UserName')
invitationManager = GIShare.UserInvitationManager(user=user)
inviteList = invitationManager.list

for invite in invitationsList:
    invite.accept()
0 Kudos