Select to view content in your preferred language

Accessing Hub Item Scheduled Update and Export Data settings

177
2
2 weeks ago
ShaunConwayCOL
Emerging Contributor

I'm working on a task to inventory items on our open data site. So far, I've been able to get a list of items on the hub site. However, what I have not been able to get access to is the items "Scheduled Update" value under General Settings. In addition, I'd like to gather an items "Export Data" property as well. Screenshots are attached of the information I am attempting to gather through the item.  

0 Kudos
2 Replies
Clubdebambos
MVP Regular Contributor

Hi @ShaunConwayCOL,

I don't see a direct way via the ArcGIS API for Python to access the Scheduled Update information but you can access via the requests module. See below.

from arcgis.gis import GIS
import requests

## Access ArcGIS Online if using AGOL Notebooks
agol = GIS("home")

## Access ArcGIS Online if using a standalone Python script
#agol = GIS("AGOL_URL", "USERNAME", "PASSWORD")

## the Item ID for the content item
item_id = "FS_ITEM_ID"

## return a token string
token = agol._con.token

## set the URL
url = f"https://hub.arcgis.com/api/download/v1/items/{item_id}/schedule?token={token}"

## get the response
response = requests.get(url)

## print the json response
print(response.json())

##json response example
## scheduled for the 15th of each month at 6pm
## {'date': 15, 'hour': 18, 'itemId': '12345678910', 'cadence': 'monthly', 'timezone': 'Europe/Dublin'}

## if you get the following, the updates are Automated by Hub
## {'message': 'Scheduled updates for the item 12345678910 is not found.', 'error': 'Not Found', 'statusCode': 404}

 

For the additional "Export Data" property see below...

from arcgis.gis import GIS
from arcgis.features import FeatureLayerCollection

## access ArcGIS Online
agol = GIS("home")

## get the Feature Sevice as an Item object
item = agol.content.get("FS_ITEM_ID")

## if the Item object type is Feature Service
if item.type == "Feature Service":
    ## create a FLC object
    flc = FeatureLayerCollection.fromitem(item)

    ## print the current capabilities - if Extract in there then it is enabled
    print(flc.properties.capabilities)

    if "Extract" in flc.properties.capabilities:
        print("\tExtract Enaled")
    else:
        print("\tExtract Disabled")

 

I hope that helps. Please let us know if it works for you.

All the best,

Glen

~ learn.finaldraftmapping.com
0 Kudos
Clubdebambos
MVP Regular Contributor

Hi @ShaunConwayCOL, updated original response above,

~ learn.finaldraftmapping.com
0 Kudos