Last active
December 30, 2015 03:49
-
-
Save fawcett/7772061 to your computer and use it in GitHub Desktop.
A quick example on how to purge a group from a CKAN instance via the CKAN API. You will need to edit the code to set the values for your CKAN URI, API key, and the name of the group that you wish to purge. Note that this example requires the ckanap Python module: https://github.com/open-data/ckanapi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ckanapi | |
ckanUrl = 'http://uri.to.your.ckan.instance' | |
apiKey='apiKeyForCkanSysadmin' | |
groupName='nameOfGroupToBePurged' | |
def purgeCkanGroup(ckanUrl,apiKey,groupId): | |
""" | |
This function purges an organization from a CKAN instance via the CKAN API. | |
Args: ckanUrl - string The URL for the CKAN instance that will receive the request. | |
apiKey - string The authorization key for a CKAN user with rights to delete or purge orgs | |
groupId - string The name or guid associated with the group to be purged | |
Requires: CKAN version >=2.2 | |
ckanapi Python module: https://github.com/open-data/ckanapi | |
""" | |
ckan = ckanapi.RemoteCKAN(ckanUrl, apikey=apiKey) | |
ckan.action.group_purge(id=groupId) | |
purgeCkanGroup(ckanUrl,apiKey,groupName) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment