Hello - does anyone know if there is anyway to pause / resume collaboration syncs using the arcgis api? Maybe somewhere in the arcgis.gis.admin module? From the rest api here:
https://developers.arcgis.com/rest/users-groups-and-items/pause/
I've been trying to implement this:
POST /sharing/rest/portals/0123456789ABCDEF/collaborations/3e9d1694351a4b5badef66c7599fced5/workspaces/c3c831f1274a4f228ecd87f1953c6f21/schedule/pause HTTP/1.1
Host: org.arcgis.com
Content-Type: application/x-www-form-urlencoded
Content-Length: []
f=pjson
but with no success.
Any ideas?
Solved! Go to Solution.
>>> from arcgis.gis import GIS
>>> from arcgis.gis.admin import Collaboration
>>> gis = GIS('https://your.portalsite.here/portal/')
>>> cm = gis.admin.collaborations
>>> c = Collaboration(cm, 'yourCollaborationIDhere')
>>> c.pause_schedule('yourWorkspaceIDhere')
The python code would look something like this
Grabbed from arcgis.gis.admin module | ArcGIS API for Python the collaboration section of the documentation
The command to resume is resume_schedule
>>> from arcgis.gis import GIS
>>> from arcgis.gis.admin import Collaboration
>>> gis = GIS('https://your.portalsite.here/portal/')
>>> cm = gis.admin.collaborations
>>> c = Collaboration(cm, 'yourCollaborationIDhere')
>>> c.pause_schedule('yourWorkspaceIDhere')
The python code would look something like this
Grabbed from arcgis.gis.admin module | ArcGIS API for Python the collaboration section of the documentation
The command to resume is resume_schedule
Oh hey that's it @valenj88 - thanks for this! I've got like 13 distributed collaborations where I update data each weekend, but until this latest release of the api I could not find anything on pause / resume.
The problem has been that each time a collaboration syncs on schedule, it un-authorizes each collaboration feature layers. And so each day I was having to run an re-authorization script so our layers would re-acquire that green 'authorized' icon . . .
And thanks for reaching out earlier
No worries. Also if the data is marked "authoritative" (with the green check) in portal, it *should* carry over to AGOL.
It may now. I had not checked since maybe 10.9.1 - but it didn't then. Could be the way I was doing my collaborations... hosted in my portal (guest), sent to our agol by reference (host)
Ok @valenj88 - here's how I set this up to run in the python IDLE:
try:
myCollabs = gis.admin.collaborations.list()
for myCollab in myCollabs:
#print (myCollab.name + ' - ' + myCollab.id + ' - ' + myCollab.workspaces)
if (myCollab.name == 'Sarasota County GIS Cadastral'):
wss = myCollab.workspaces
for ws in wss:
for key, value in ws.items(): #need to set up key value pair because workspaces property is a dictionary of items
if key == 'id':
print (value)
myCollab.pause_schedule(value)
except Exception:
# If an error occurred, print line number and error message
import traceback, sys
tb = sys.exc_info()[2]
e = sys.exc_info()[1]
print(e.args[0])
print ("Line %i" % tb.tb_lineno)
message = message + "\n" + "Line %i" % tb.tb_lineno
message = message + "\n" + str(e)
Then I'll just set up a try block for each collab I want to pause or resume . . .