'PUT /api/tool_shed_repositories/reset_metadata_on_installed_repositories
Resets all metadata on all repositories installed into Galaxy in an "orderly fashion".
:param key: the API key of the Galaxy admin user.'

@expose_api
def reset_metadata_on_installed_repositories(self, trans, payload, **kwd):

    start_time = strftime('%Y-%m-%d    %H:%M:%S')
    results = dict(start_time=start_time, successful_count=0, unsuccessful_count=0, repository_status=[])
    if (not trans.user_is_admin()):
        raise HTTPForbidden(detail='You    are    not    authorized    to    reset    metadata    on    repositories    installed    into    this    Galaxy    instance.')
    irmm = InstalledRepositoryMetadataManager(self.app)
    query = irmm.get_query_for_setting_metadata_on_repositories(order=False)
    for repository in query:
        try:
            irmm.set_repository(repository)
            irmm.reset_all_metadata_on_installed_repository()
            irmm_invalid_file_tups = irmm.get_invalid_file_tups()
            if irmm_invalid_file_tups:
                message = tool_util.generate_message_for_invalid_tools(self.app, irmm_invalid_file_tups, repository, None, as_html=False)
                results['unsuccessful_count'] += 1
            else:
                message = ('Successfully    reset    metadata    on    repository    %s    owned    by    %s' % (str(repository.name), str(repository.owner)))
                results['successful_count'] += 1
        except Exception as e:
            message = ('Error    resetting    metadata    on    repository    %s    owned    by    %s:    %s' % (str(repository.name), str(repository.owner), str(e)))
            results['unsuccessful_count'] += 1
        results['repository_status'].append(message)
    stop_time = strftime('%Y-%m-%d    %H:%M:%S')
    results['stop_time'] = stop_time
    return json.dumps(results, sort_keys=True, indent=4)
