Business-API-Ecosystem
Business-API-Ecosystem copied to clipboard
CKAN_dataset plugin problem in "on_post_product_spec_validation" method
Good morning, I am trying to do a Product Specification using as Digital Asset, CKAN Dataset. For that I have to load CKAN-Dataset plugin. I install the latest one because it has support with IDM 7. This plugin support Umbrella too but for me it is not necessary. When I was creating a Product Specification I found an error or an understanding for me ;-) in ckan_dataset.py file in "on_post_product_spec_validation" method. In this pluging there is a setting.py file where you can put variables like: AUTH_METHOD = 'idm' Looking into ckan_dataset.py nobody call to this method,
def _get_api_client(self, url):
# Return API Client (Umbrella or keystone) depending on the authorization mechanism
return self._clients[AUTH_METHOD](url)
After in on_post_product_spec_validation method it puts:
def on_post_product_spec_validation(self, provider, asset):
# Read CKAN dataset resources in order to determine the broker URLs
token = User.objects.get(username=provider.name).userprofile.access_token
dataset_info = self._get_dataset_info(asset.get_url(), token)['result']
print ("on_post_product_spec_validation")
for resource in dataset_info['resources']:
# If the CKAN resource is a URL, save it in order to enable activation and accounting
if 'url' in resource and len(resource['url']) > 0:
# Validate that the service exists and is secured with API Umbrella
**app_id = self._check_dataset_api(resource['url'], provider.name)**
if 'resources' not in asset.meta_info:
asset.meta_info['resources'] = []
asset.meta_info['resources'].append({
'url': resource['url'],
'app_id': app_id
})
# Check that the provided role is valid for the given API service
self._check_role(app_id, asset.meta_info['role'], resource['url'])
asset.save()
And in check_dataset_api(resource['url'], provider.name) method in third line appear reference to umbrella client to get an app_id and the funcion return app_id If I have not got Umbrella the code returns error. :
def _check_dataset_api(self, url, provider_name):
parsed_url = urlparse(url)
server = '{}://{}'.format(parsed_url.scheme, parsed_url.netloc)
**umbrella_client = UmbrellaClient(server)
app_id = umbrella_client.validate_service(parsed_url.path)
if app_id is None:
# Raise an error since this plugin only supports FIWARE IDM role authorization
raise PluginError('The dataset resource {} is not configured to support idm authentication'.format(url))**
# Check if the provided app_id is valid for the included keystone instance
keystone_client = self._get_keystone_client(url)
keystone_client.check_ownership(app_id, provider_name)
return app_id
If I haven't got Umbrella where I get the app id?
I thinks so that in def_check_dataset_api should be a call to def _get_api_client(self, url): and depending on that follow.
Please, I have amn European Project review in 22th October and I would like to show all of this working properly. I have IDM KeyRock v7.01 and Biz 6.4.1 versions. Someone can help me with this.? Thanks Urtza