@@ -0,0 +1,2653 @@
+%22%22%22%0A%0AWarning: SSL Cert Verification not verified. See: http://docs.python-requests.org/en/latest/user/advanced/#ssl-cert-verification%0A%0AWarning: Open Data API is not documented and therefore the endpoints may change at any point : http://ideas.arcgis.com/ideaView?id=087E0000000blPIIAY%0A%0ANot supported by Esri Support Services.%0A%0ARequests module is needed, download it here: http://docs.python-requests.org/en/latest/%0A%0A%22%22%22%0Aprint(__doc__)%0A%0Aimport requests%0A%0Aclass OpenData(object):%0A%0A    %22%22%22%0A    Example Open Data object. Open Data site needs to be public.%0A    %22%22%22%0A%0A    def __init__(self, username, password, OpenDataSite):%0A        %22%22%22%0A        username : Username used to log into an ArcGIS Online Organization.%0A        password : Password used to log into an ArcGIS Online Organization.%0A        OpenDataSite: Open Data Site Number (i.e. 0001).%0A        %22%22%22%0A        self.username = username%0A        self.password = password%0A        self.token = self.generateToken()%0A%0A        self.OpenDataSite = OpenDataSite%0A        self.OpenDataItems = self.findAllOpenDataItems()%0A%0A    def generateToken(self):%0A        %22%22%22%0A        Generate Token generates an access token in exchange for %5C%0A        user credentials that can be used by clients when working with the ArcGIS Portal API:%0A        http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r3000000m5000000%0A        %22%22%22%0A        url = %22https://arcgis.com/sharing/rest/generateToken%22%0A        data = %7B'username': self.username,%0A                'password': self.password,%0A                'referer': %22https://www.arcgis.com%22,%0A                'f': 'json'%7D%0A        return requests.post(url, data, verify=False).json()%5B'token'%5D%0A%0A    def findAllOpenDataItems(self):%0A        %22%22%22%0A        Matches item ID of service that is being updated to the itemID in Open Data. %5C%0A        Will receive error if the Open Data site is not public.%0A        %22%22%22%0A        url = %22https://opendata.arcgis.com/api/sites/%7B0%7D/datasets.json?token=%7B1%7D%22.format(self.OpenDataSite, self.token)%0A        info = requests.get(url, verify=False).json()%5B'datasets'%5D%0A        return %5Bx%5B'id'%5D for x in info%5D%0A%0A    def refresh(self):%0A        %22%22%22%0A        Refreshes all Open Data datasets and download cache.%0A        %22%22%22%0A        for dataset in self.OpenDataItems:%0A            url = %22https://opendata.arcgis.com/api/datasets/%7B0%7D/refresh.json?token=%7B1%7D%22.format(dataset, self.token)%0A            requests.put(url, verify=False)%0A%0Aif __name__ == %22__main__%22:%0A    %22%22%22Example workflow that refreshes all datasets in an Open Data site. This will not work for datasets that have errors in Open Data.%22%22%22%0A    test = OpenData(%22username%22, %22password%22, %220000%22)%0A    test.refresh()%0A

Create opendata.py