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

Kai Reinhard
18.09.2021 ea8ad4f8ce1208a08efc8557240c5499b06e4b9a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package de.micromata.borgbutler.server.rest
 
import de.micromata.borgbutler.BorgQueueExecutor
import de.micromata.borgbutler.json.JsonUtils
import de.micromata.borgbutler.server.BorgInstallation
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
 
@RestController
@RequestMapping("/rest/system")
class SystemInfoRest {
    /**
     * @return The total number of jobs queued or running (and other statistics): [de.micromata.borgbutler.BorgQueueStatistics].
     * @see JsonUtils.toJson
     */
    @GetMapping("info")
    fun statistics(): SystemInfo {
        val borgVersion = BorgInstallation.getInstance().borgVersion
        val systemInfonfo = SystemInfo()
            .setQueueStatistics(BorgQueueExecutor.getInstance().statistics)
            .setConfigurationOK(borgVersion.isVersionOK)
            .setBorgVersion(borgVersion)
        return systemInfonfo
    }
}