ckanext-validationapi
ckanext-validationapi provides an API as a public wrapper around the internal Validator functions of CKAN.
Vitality
Vitality index info
The vitality index indicates the degree of activity carried out in the last time period on each OSS Solution repository indexed in the Catalogue.
It reproduces exactly (in its definition and calculation) that envisaged by the guidelines on acquisition and reuse of software for Public Administrations defined by the Agency for Digital Italy - AGID, and currently officially implemented within the Developers.Italia OSS Solutions Catalogue.
This vitality index is calculated on the time window of the last 60 days (and updated once a week within this catalogue) taking into consideration the following four categories:
- Code activity: the number of commits and merges per day,
- Release history: the number of releases per day,
- User community: the number of unique authors,
- Longevity: the age of the project,
The ranges of each measurement can be found in the file vitality-ranges.yml.
Quick links
Detailed information
Description
This plugin belongs to a set of plugins for the _Datenregister_ – the non-public [CKAN] (https://ckan.org/) instance that is part of Berry’s open data portal [daten.berlin.de] (https://daten.berlin.de/).
‘ckanext-validationapì provides an API as a public wrapper around the internal Validator functions of CKAN.
The plugin implements the following CKAN interfaces:
— [IBlueprint] (http://docs.ckan.org/en/latest/extensions/plugin-interfaces.html#ckan.p…)
— [IConfigurer] (http://docs.ckan.org/en/latest/extensions/plugin-interfaces.html#ckan.p…)
# # Requirements
This plugin has been tested with CKAN 2.9 (which requires Python 3).
# # Using the API
All Validator functions that are available through ‘ckan.plugins.toolkit.get \ _validator’ can be used. The list of standard validators that CKAN offers is available at [https://docs.ckan.org/en/latest/extensions/validators.html] (https://docs.ckan.org/en/latest/extensions/validators.html). Plugins can add more validators by implementing the [IValidators] (https://docs.ckan.org/en/latest/extensions/plugin-interfaces.html#ckan…) interface.
The API is accessible via '$CKAN \ _URL/bees/validation’; currently its only method is validated. Only POST requests with content type ‘application/json’ are accepted.
The expected payload to 'validatè is a JSON object with two attributes:
— ‘Validator’: The name of the Validator as it would be passed to ‘ckan.plugins.toolkit.get \ _validator’.
— 'evaluates: The value we want to submit for validation.
HERE is an example:
THE FOLLOWING:
‘Validator’: ‘email \ _validator’,
‘value’: “jane.doe@company.com”
BULL.
If the Validator exists, ‘validationapì will call the Validator function with the provided value. The response will be a JSON object with these attributes:
— ‘Validator’: The name of the Validator as it would be passed to ‘ckan.plugins.toolkit.get \ _validator’.
— 'evaluates: The value that was submitted for validation.
— ‘success’: Whether or not 'valuis passed the validation.
— ‘result’: If successful, the output of the Validator. This will be the same as’ valué, but sometimes the Validator will perform some transformation as well.
— ‘messagea: If not successful, this will contain an error message as provided by the Validator.
HERE are some examples for communicating with the validation API via curl:
# # # Valid input, unchanged
curl – X POST \
—date ‘Validator’: ‘email \ _validator’, ‘value’: “jane.doe@company.com” “” \
—H "Content-Type: application/json "\
$CKAN \ _URL/bees/validation/validated
THE FOLLOWING:
‘Validator’: ‘email \ _validator’,
‘value’: “jane.doe@company.com”,
‘success’: true,
‘result’: “jane.doe@company.com”
BULL.
# # # Valid input, changed
curl – X POST \
—date ‘Validator’: ‘isodate’, ‘value’: “2004-10-10” – "\
—H "Content-Type: application/json "\
$CKAN \ _URL/bees/validation/validated
THE FOLLOWING:
‘Validator’: ‘isodate’,
‘value’: ‘2004-10-10’,
‘success’: true,
‘result’: ‘2004-10-10 00: 00: 00’
BULL.
# # # Invalid input
curl – X POST \
—date ‘Validator’: ‘isodate’, ‘value’: “2004-10-10x” – "\
—H "Content-Type: application/json "\
$CKAN \ _URL/bees/validation/validated
THE FOLLOWING:
‘message’: ‘Invalid: U’Datumsformat ung \ \ xfcltig. ',
‘Validator’: ‘isodate’,
‘value’: ‘2004-10-10x’,
‘success’: false
BULL.
# # # Errors
If possible, validationapi will catch errors and provide an error message in the same format as above, but with the HTTP Response Code 400 (Bad Request). Below are some examples:
# # # # Unknown Validator
curl – X POST \
—date ‘Validator’: ‘foolidator’, ‘value’: ‘Barbar’
—H "Content-Type: application/json "\
$CKAN \ _URL/bees/validation/validated
THE FOLLOWING:
‘Validator’: ‘foolidator’,
‘value’: ‘Barbar’,
‘success’: false,
‘Error’: THE FOLLOWING:
‘message’: ‘Bad Request – Validator \ ‘foolidator \’ does not exist’,
‘Code’: 7
BULL.
BULL.
# # # # Wrong Request Format
curl $CKAN \ _URL/bees/validation/validated
THE FOLLOWING:
‘Validator’: NULL,
‘value’: NULL,
‘success’: false,
‘Error’: THE FOLLOWING:
‘message’: ‘Bad Request – Validation API accepts only POST requests with content type ‘application/json’.’,
‘Code’: 1
BULL.
BULL.
# # # # Error Codes
The complete list of error codes is:
— Wrong HTTP method = 1
— Wrong content type = 2
— No request data found = 3
— Cannot decode JSON = 4
— Wrong type of JSON = 5
— Wrong JSON structure = 6
— Unknown Validator = 7
— Validator has unexpected number of arguments = 8
— Unexpected error = 20