'POST /api/tool_shed_repositories/repair_repository_revision
Repair a specified repository revision previously installed into Galaxy.
:param key: the current Galaxy admin user\'s API key
The following parameters are included in the payload.
:param tool_shed_url (required): the base URL of the Tool Shed from which the Repository was installed
:param name (required): the name of the Repository
:param owner (required): the owner of the Repository
:param changeset_revision (required): the changeset_revision of the RepositoryMetadata object associated with the Repository'

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

    (tool_shed_url, name, owner, changeset_revision) = self.__parse_repository_from_payload(payload, include_changeset=True)
    tool_shed_repositories = []
    tool_shed_repository = repository_util.get_installed_repository(self.app, tool_shed=tool_shed_url, name=name, owner=owner, changeset_revision=changeset_revision)
    rrm = RepairRepositoryManager(self.app)
    repair_dict = rrm.get_repair_dict(tool_shed_repository)
    ordered_tsr_ids = repair_dict.get('ordered_tsr_ids', [])
    ordered_repo_info_dicts = repair_dict.get('ordered_repo_info_dicts', [])
    if (ordered_tsr_ids and ordered_repo_info_dicts):
        for (index, tsr_id) in enumerate(ordered_tsr_ids):
            repository = trans.install_model.context.query(trans.install_model.ToolShedRepository).get(trans.security.decode_id(tsr_id))
            repo_info_dict = ordered_repo_info_dicts[index]
            repair_dict = rrm.repair_tool_shed_repository(repository, encoding_util.tool_shed_encode(repo_info_dict))
            repository_dict = repository.to_dict(value_mapper=self.__get_value_mapper(trans, repository))
            repository_dict['url'] = web.url_for(controller='tool_shed_repositories', action='show', id=trans.security.encode_id(repository.id))
            if repair_dict:
                errors = repair_dict.get(repository.name, [])
                repository_dict['errors_attempting_repair'] = '        '.join(errors)
            tool_shed_repositories.append(repository_dict)
    return tool_shed_repositories
