Name: ckanext-extras
Owner: GeoSolutions
Description: CKAN extension for extra APIs
Created: 2018-01-26 17:37:11.0
Updated: 2018-05-18 13:28:57.0
Pushed: 2018-05-18 13:28:56.0
Homepage: null
Size: 21
Language: Python
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
The ckanext-extras CKAN's extension provides external_resource_list
action, which returns list of public resources, which are not local (are served by external service).
The ckanext-extras extension has been developed for CKAN 2.4.3 or later.
Installing all the other extensions required
Activate your CKAN virtual environment, for example:
. /usr/lib/ckan/default/bin/activate
Go into your CKAN path for extension (like /usr/lib/ckan/default/src):
git clone https://github.com/geosolutions-it/ckanext-extras.git
cd ckanext-extras
pip install -e .
Add external_resource_list
to the ckan.plugins
setting in your CKAN
config file (by default the config file is located at /etc/ckan/default/production.ini
).
Restart CKAN. For example if you've deployed CKAN with Apache on Ubuntu::
sudo service apache2 reload
This extension uses ckan.site_url
value to resolve if url is external. If url starts with local site value, it will be considered as local.
However, it may came to situation, that single site url is insufficient. For that case, you can add ckanext.extras.local_sites
to config. This can be a string or list of strings with base urls, which should be considered as local.
Additionally, urls that starts with values from local sites, may be actually external (proxied from external sites). In that case, you can also set ckanext.extras.external_sites
.
To establish if url is external in such scenario, url will be checked with external sites first (if url starts with external site prefix, it will be considered external at this point), then with local sites (if url starts with local site prefix, it will be considered local). If none of those checks will provide result, url will eventually be considered as external.
Sample configuration:
.site_url = http://public.address
ext.extras.local_sites =
http://localhost
http://127.0.0.1
ext.extras.external_sites =
http://localhost/proxied
http://public.address/remote/
url | is external
— | —
http://public.address/index
| No
http://public.address/remote/index
| Yes
http://localhost/resource/001
| No
http://localhost/proxied/resource/001
| Yes
To install ckanext-extras
for development, activate your CKAN virtualenv and do:
git clone https://github.com/geosolutions-it/ckanext-extras.git
cd ckanext-extras
python setup.py develop
The API is reachable at the following endpoint: http://public.address/api/action/external_resource_list
Parameters to be used to navigate the resource list are:
limit: the max number of resource returned offset: the resource index from which results are returned
Below a sample URL:
http://public.address/api/action/external_resource_list?limit=50&offset=0