mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-06-13 06:40:41 +00:00
swagger: improve doc
This commit is contained in:
+13
-8
@@ -7,19 +7,24 @@ import (
|
|||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type diskFree struct {
|
||||||
|
// Storage size [MiB]
|
||||||
|
Total uint64
|
||||||
|
// Available Storage [MiB]
|
||||||
|
Free uint64
|
||||||
|
// Percentage Full
|
||||||
|
PercentFull float32
|
||||||
|
}
|
||||||
|
|
||||||
// @Summary Get Storage Utilization
|
// @Summary Get Storage Utilization
|
||||||
// @Description Get disk free information of aptly storage
|
// @Description **Get disk free information of aptly storage**
|
||||||
// @Tags Status
|
// @Tags Status
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Success 200 {object} string "usage information"
|
// @Success 200 {object} diskFree "Storage information"
|
||||||
// @Failure 400 {object} Error "Internal Error"
|
// @Failure 400 {object} Error "Internal Error"
|
||||||
// @Router /api/storage [get]
|
// @Router /api/storage [get]
|
||||||
func apiDiskFree(c *gin.Context) {
|
func apiDiskFree(c *gin.Context) {
|
||||||
var df struct {
|
var df diskFree
|
||||||
Total uint64
|
|
||||||
Free uint64
|
|
||||||
PercentUsed float32
|
|
||||||
}
|
|
||||||
|
|
||||||
fs := context.Config().GetRootDir()
|
fs := context.Config().GetRootDir()
|
||||||
|
|
||||||
@@ -32,7 +37,7 @@ func apiDiskFree(c *gin.Context) {
|
|||||||
|
|
||||||
df.Total = uint64(stat.Blocks) * uint64(stat.Bsize) / 1048576
|
df.Total = uint64(stat.Blocks) * uint64(stat.Bsize) / 1048576
|
||||||
df.Free = uint64(stat.Bavail) * uint64(stat.Bsize) / 1048576
|
df.Free = uint64(stat.Bavail) * uint64(stat.Bsize) / 1048576
|
||||||
df.PercentUsed = 100.0 - float32(stat.Bavail)/float32(stat.Blocks)*100.0
|
df.PercentFull = 100.0 - float32(stat.Bavail)/float32(stat.Blocks)*100.0
|
||||||
|
|
||||||
c.JSON(200, df)
|
c.JSON(200, df)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user