'PUT /api/repositories/reset_metadata_on_repository
Resets all metadata on a specified repository in the Tool Shed.
:param key: the API key of the Tool Shed user.
The following parameters must be included in the payload.
:param repository_id: the encoded id of the repository on which metadata is to be reset.'

@web.expose_api
def reset_metadata_on_repository(self, trans, payload, **kwd):

    def handle_repository(trans, start_time, repository):
        results = dict(start_time=start_time, repository_status=[])
        try:
            rmm = repository_metadata_manager.RepositoryMetadataManager(app=self.app, user=trans.user, repository=repository, resetting_all_metadata_on_repository=True, updating_installed_repository=False, persist=False)
            rmm.reset_all_metadata_on_repository_in_tool_shed()
            rmm_invalid_file_tups = rmm.get_invalid_file_tups()
            if rmm_invalid_file_tups:
                message = tool_util.generate_message_for_invalid_tools(self.app, rmm_invalid_file_tups, repository, None, as_html=False)
                results['status'] = 'warning'
            else:
                message = ('Successfully    reset    metadata    on    repository    %s    owned    by    %s' % (str(repository.name), str(repository.user.username)))
                results['status'] = 'ok'
        except Exception as e:
            message = ('Error    resetting    metadata    on    repository    %s    owned    by    %s:    %s' % (str(repository.name), str(repository.user.username), str(e)))
            results['status'] = 'error'
        status = ('%s    :    %s' % (str(repository.name), message))
        results['repository_status'].append(status)
        return results
    repository_id = payload.get('repository_id', None)
    if (repository_id is not None):
        repository = repository_util.get_repository_in_tool_shed(self.app, repository_id)
        start_time = strftime('%Y-%m-%d    %H:%M:%S')
        log.debug(('%s...resetting    metadata    on    repository    %s' % (start_time, str(repository.name))))
        results = handle_repository(trans, start_time, repository)
        stop_time = strftime('%Y-%m-%d    %H:%M:%S')
        results['stop_time'] = stop_time
    return results
