add rest api updateAllPlugins

This commit is contained in:
Eduard Heimbuch
2019-09-27 15:30:21 +02:00
parent 32cb67f92e
commit 281d812065
11 changed files with 99 additions and 2 deletions

View File

@@ -56,6 +56,21 @@ public class InstalledPluginResource {
return Response.ok(collectionMapper.mapInstalled(plugins, available)).build();
}
/**
* Updates all installed plugins.
*/
@POST
@Path("/update")
@StatusCodes({
@ResponseCode(code = 200, condition = "success"),
@ResponseCode(code = 500, condition = "internal server error")
})
@TypeHint(CollectionDto.class)
public Response updateAll(@QueryParam("restart") boolean restartAfterInstallation) {
pluginManager.updateAll(restartAfterInstallation);
return Response.ok().build();
}
/**
* Returns the installed plugin with the given id.
*

View File

@@ -12,6 +12,7 @@ import sonia.scm.plugin.PluginPermissions;
import java.util.List;
import static de.otto.edison.hal.Embedded.embeddedBuilder;
import static de.otto.edison.hal.Link.*;
import static de.otto.edison.hal.Links.linkingTo;
import static java.util.stream.Collectors.toList;
@@ -44,6 +45,9 @@ public class PluginDtoCollectionMapper {
Links.Builder linksBuilder = linkingTo()
.with(Links.linkingTo().self(baseUrl).build());
linksBuilder.single(link("update", resourceLinks.installedPluginCollection().update()));
return linksBuilder.build();
}

View File

@@ -686,6 +686,10 @@ class ResourceLinks {
String self() {
return installedPluginCollectionLinkBuilder.method("installedPlugins").parameters().method("getInstalledPlugins").parameters().href();
}
String update() {
return installedPluginCollectionLinkBuilder.method("installedPlugins").parameters().method("updateAll").parameters().href();
}
}
public AvailablePluginLinks availablePlugin() {