Please follow the API guide of CKAN at http://docs.ckan.org/en/latest/api/index.html to get a common understanding of the capabilities and the workflow of how to use CKANs included API.
ckan.logic.action.geoserver_publish_ogc(context, data_dict)
Publish a qualified dataset as OGC complied service on a geoserver. The user must have permission to 'edit' the dataset. Return True
if the publishing process was successful and False
otherwise.
Parameter:
Return type: boolean
ckan.logic.action.geoserver_unpublish_ogc(context, data_dict)
Unpublish a already published dataset from geoserver. The user must have permission to 'edit' the dataset. Return True
if the unpublishing process was successful and False
otherwise.
Parameter:
Return type: boolean
The action API of CKAN is extended with new endpoints:
/api/3/action/geoserver_publish_ogc
to publish a package/api/3/action/geoserver_unpublish_ogc
to unpublish a packageExample in python:
import urllib2
import urllib
import json
request = urllib2.Request('http://YOUR_SERVER/api/3/action/geoserver_publish_ogc')
To use this endpoints you have to create a dictionary and provide your API key in an HTTP request. So include it in an Authorization header like in this python code:
request.add_header('Authorization', 'YOUR KEY')
The dictionary has to have information about the package which should be published or unpublished [mandatory] and can have information about the keys which should be used when a join over different tables is necessary.
Example in python:
dataset_dict = {
'package_id': 'ID_OF_PACKAGE', # the id of the package for update
'join_key': 'KEY_FOR_JOIN' # the key if database table joins are necessary
}
The response of this request should claim that everything worked and the package has been published / unpublished
data_string = urllib.quote(json.dumps(dataset_dict))
response = urllib2.urlopen(request, data_string)