mirror of https://github.com/micromata/borgbackup-butler.git

Kai Reinhard
20.15.2019 87b542fbd20a48795a543b3244858541f120309f
BorgRepoConfig stuff -> BorgRepoConfigsRest.
1 files modified
19 ■■■■■ changed files
borgbutler-server/src/main/java/de/micromata/borgbutler/server/rest/BorgRepoConfigsRest.java 19 ●●●●● patch | view | raw | blame | history
borgbutler-server/src/main/java/de/micromata/borgbutler/server/rest/BorgRepoConfigsRest.java
@@ -4,36 +4,17 @@
import de.micromata.borgbutler.config.BorgRepoConfig;
import de.micromata.borgbutler.config.ConfigurationHandler;
import de.micromata.borgbutler.json.JsonUtils;
import de.micromata.borgbutler.json.borg.BorgRepository;
import org.apache.commons.collections4.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import java.util.List;
@Path("/repoConfig")
public class BorgRepoConfigsRest {
    private static Logger log = LoggerFactory.getLogger(BorgRepoConfigsRest.class);
    /**
     * @param prettyPrinter If true then the json output will be in pretty format.
     * @return A list of repositories of type {@link BorgRepository}.
     * @see JsonUtils#toJson(Object, boolean)
     */
    @GET
    @Path("list")
    @Produces(MediaType.APPLICATION_JSON)
    public String getRepoConfigs(@QueryParam("prettyPrinter") boolean prettyPrinter) {
        List<BorgRepoConfig> repoConfigs = ConfigurationHandler.getConfiguration().getRepoConfigs();
        if (CollectionUtils.isEmpty(repoConfigs)) {
            return "[]";
        }
        return JsonUtils.toJson(repoConfigs, prettyPrinter);
    }
    /**
     * @param id            id or name of repo.
     * @param prettyPrinter If true then the json output will be in pretty format.
     * @return {@link BorgRepoConfig} as json string.