metadata_registration_api.api package¶
Submodules¶
metadata_registration_api.api.api_ctrl_voc module¶
- class metadata_registration_api.api.api_ctrl_voc.ApiControlledVocabulary(api=None, *args, **kwargs)¶
Bases:
flask_restx.resource.Resource- delete(user=None)¶
Delete all entries
- get()¶
Fetch a list with all entries
- get_parser = <flask_restx.reqparse.RequestParser object>¶
- methods: Optional[List[str]] = {'DELETE', 'GET', 'POST'}¶
A list of methods this view can handle.
- post(user=None)¶
Add a new entry
- class metadata_registration_api.api.api_ctrl_voc.ApiControlledVocabularyId(api=None, *args, **kwargs)¶
Bases:
flask_restx.resource.Resource- delete(id, user=None)¶
Delete an entry given its unique identifier
- get(id)¶
Fetch an entry given its unique identifier
- methods: Optional[List[str]] = {'DELETE', 'GET', 'PUT'}¶
A list of methods this view can handle.
- put(id, user=None)¶
Update an entry given its unique identifier
metadata_registration_api.api.api_form module¶
- class metadata_registration_api.api.api_form.ApiForm(api=None, *args, **kwargs)¶
Bases:
flask_restx.resource.Resource- delete(user=None)¶
Delete all entries
- get()¶
Fetch a list with all entries
- get_parser = <flask_restx.reqparse.RequestParser object>¶
- methods: Optional[List[str]] = {'DELETE', 'GET', 'POST'}¶
A list of methods this view can handle.
- post(user=None)¶
Add a new entry
- class metadata_registration_api.api.api_form.ApiFormId(api=None, *args, **kwargs)¶
Bases:
flask_restx.resource.Resource- delete(id, user=None)¶
Delete an entry given its unique identifier
- get(id)¶
Fetch an entry given its unique identifier
- get_parser = <flask_restx.reqparse.RequestParser object>¶
- methods: Optional[List[str]] = {'DELETE', 'GET', 'PUT'}¶
A list of methods this view can handle.
- put(id, user=None)¶
Update an entry given its unique identifier
- class metadata_registration_api.api.api_form.ArgsField(default=None, attribute=None, title=None, description=None, required=None, readonly=None, example=None, mask=None, **kwargs)¶
Bases:
flask_restx.fields.RawCustom field for args field. If the value contains a DataObject, it is modeled with the objects model
- format(value)¶
Formats a field’s value. No-op by default - field classes that modify how the value of existing object keys should be presented should override this and apply the appropriate formatting.
- Parameters
value – The value to format
- Raises
MarshallingError – In case of formatting problem
Ex:
class TitleCase(Raw): def format(self, value): return unicode(value).title()
- class metadata_registration_api.api.api_form.SubformAddField(default=None, attribute=None, title=None, description=None, required=None, readonly=None, example=None, mask=None, **kwargs)¶
Bases:
flask_restx.fields.RawCustom field for subforms
- format(value)¶
Formats a field’s value. No-op by default - field classes that modify how the value of existing object keys should be presented should override this and apply the appropriate formatting.
- Parameters
value – The value to format
- Raises
MarshallingError – In case of formatting problem
Ex:
class TitleCase(Raw): def format(self, value): return unicode(value).title()
- class metadata_registration_api.api.api_form.SubformField(default=None, attribute=None, title=None, description=None, required=None, readonly=None, example=None, mask=None, **kwargs)¶
Bases:
flask_restx.fields.RawCustom field for subforms
- format(value)¶
Formats a field’s value. No-op by default - field classes that modify how the value of existing object keys should be presented should override this and apply the appropriate formatting.
- Parameters
value – The value to format
- Raises
MarshallingError – In case of formatting problem
Ex:
class TitleCase(Raw): def format(self, value): return unicode(value).title()
metadata_registration_api.api.api_props module¶
- class metadata_registration_api.api.api_props.ApiProperties(api=None, *args, **kwargs)¶
Bases:
flask_restx.resource.Resource- delete(user=None)¶
Deprecates all entries
- get()¶
Fetch a list with all entries
- get_parser = <flask_restx.reqparse.RequestParser object>¶
- methods: Optional[List[str]] = {'DELETE', 'GET', 'POST'}¶
A list of methods this view can handle.
- post(user=None)¶
Add a new entry
The name has to be unique and is internally used as a variable name. The passed string is preprocessed before it is inserted into the database. Preprocessing: All characters are converted to lower case, the leading and trailing white spaces are removed, and intermediate white spaces are replaced with underscores (“_”).
Do not pass a unique identifier since it is generated internally.
synonyms (optional)
deprecated (default=False)
If a data type other than “cv” is added, the controlled_vocabullary is not considered.
- class metadata_registration_api.api.api_props.ApiPropertyId(api=None, *args, **kwargs)¶
Bases:
flask_restx.resource.Resource- delete(id, user=None)¶
Deprecates an entry given its unique identifier
- get(id)¶
Fetch an entry given its unique identifier
- methods: Optional[List[str]] = {'DELETE', 'GET', 'PUT'}¶
A list of methods this view can handle.
- put(id, user=None)¶
Update entry given its unique identifier
- metadata_registration_api.api.api_props.check_synonyms_unicity(new_property_payload, exclude_id=None)¶
- metadata_registration_api.api.api_props.validate_controlled_vocabulary(entry)¶
metadata_registration_api.api.api_study module¶
- class metadata_registration_api.api.api_study.ApiStudy(api=None, *args, **kwargs)¶
Bases:
flask_restx.resource.Resource- delete(user=None)¶
Deprecates all entries
- get(user=None)¶
Fetch a list with all entries
- methods: Optional[List[str]] = {'DELETE', 'GET', 'POST'}¶
A list of methods this view can handle.
- post(user=None)¶
Add a new entry
- class metadata_registration_api.api.api_study.ApiStudyId(api=None, *args, **kwargs)¶
Bases:
flask_restx.resource.Resource- delete(id, user=None)¶
Delete an entry given its unique identifier
- get(id, user=None)¶
Fetch an entry given its unique identifier
- methods: Optional[List[str]] = {'DELETE', 'GET', 'PUT'}¶
A list of methods this view can handle.
- put(id, user=None)¶
Update an entry given its unique identifier
- metadata_registration_api.api.api_study.check_alternate_pk_unicity(entries, pseudo_apks, prop_map)¶
Another dirty mongoDB aggregation to enforce unicity of certain entry properties.
- metadata_registration_api.api.api_study.index_study_if_es(study, entries, action)¶
- metadata_registration_api.api.api_study.update_study(study, study_converter, payload, message, user=None)¶
Steps to update study state, metadata and upload to DB
- metadata_registration_api.api.api_study.validate_form_format_against_form(form_name, form_data, form_cls=None)¶
metadata_registration_api.api.api_user module¶
- class metadata_registration_api.api.api_user.ApiUser(api=None, *args, **kwargs)¶
Bases:
flask_restx.resource.Resource- delete(user=None)¶
Delete all entries
- get()¶
Fetch a list with all entries
- methods: Optional[List[str]] = {'DELETE', 'GET', 'POST'}¶
A list of methods this view can handle.
- parser = <flask_restx.reqparse.RequestParser object>¶
- post(user=None)¶
Add a new entry
- class metadata_registration_api.api.api_user.ApiUserId(api=None, *args, **kwargs)¶
Bases:
flask_restx.resource.Resource- delete(id, user=None)¶
Delete an entry given its unique identifier
- get(id)¶
Fetch an entry given its unique identifier
- methods: Optional[List[str]] = {'DELETE', 'GET', 'PUT'}¶
A list of methods this view can handle.
- put(id, user=None)¶
Update an entry given its unique identifier
- class metadata_registration_api.api.api_user.Login(api=None, *args, **kwargs)¶
Bases:
flask_restx.resource.Resource- methods: Optional[List[str]] = {'POST'}¶
A list of methods this view can handle.
- post()¶
Fetch an access token to perform requests which require elevated privileges
Upon successful login, you receive an access token. Pass the token as value of ‘x-access-token’ in the header of every request that requires elevated privileges. The token is only valid for a certain time interval.
metadata_registration_api.api.api_utils module¶
- class metadata_registration_api.api.api_utils.ChangeLog(action: str, user_id: str, timestamp: datetime.datetime, manual_user: Union[str, NoneType] = None)¶
Bases:
object- action: str¶
- manual_user: Optional[str] = None¶
- timestamp: datetime.datetime¶
- to_dict()¶
- user_id: str¶
- class metadata_registration_api.api.api_utils.MetaInformation(state: str, change_log=None)¶
Bases:
object- add_log(log: metadata_registration_api.api.api_utils.ChangeLog)¶
- to_json()¶
- metadata_registration_api.api.api_utils.get_cv_items_map(key='name', value='label')¶
Returns a map to find the CV item labels in this format: {cv_name: {item_name: item_label}}
- metadata_registration_api.api.api_utils.get_json(url, headers={})¶
- metadata_registration_api.api.api_utils.get_mask(request)¶
- metadata_registration_api.api.api_utils.get_property_map(key, value, mask=None)¶
Helper to get property mapper
metadata_registration_api.api.decorators module¶
- metadata_registration_api.api.decorators.token_required(f)¶
A decorator to ensure that the request contains an access token
Module contents¶
- metadata_registration_api.api.general_error_handler(error)¶
- metadata_registration_api.api.handle_authorization_error(error)¶
- metadata_registration_api.api.handle_does_not_exist_error(error)¶
- metadata_registration_api.api.handle_not_unique_error(error)¶
- metadata_registration_api.api.http_error_handler(error)¶
- metadata_registration_api.api.state_machine_exception(error)¶