Skip to content

Commit

Permalink
Merge pull request #263 from vanyasvl/requiredbackup_api_field
Browse files Browse the repository at this point in the history
RequiredBackup JSON field in /backup/list API call
  • Loading branch information
Slach authored Sep 9, 2021
2 parents 5532dce + 4c15a31 commit d252463
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,11 +400,12 @@ func (api *APIServer) httpTablesHandler(w http.ResponseWriter, _ *http.Request)
// ??? INSERT INTO system.backup_list (name) VALUES ('backup_name') - create backup
func (api *APIServer) httpListHandler(w http.ResponseWriter, _ *http.Request) {
type backupJSON struct {
Name string `json:"name"`
Created string `json:"created"`
Size int64 `json:"size,omitempty"`
Location string `json:"location"`
Desc string `json:"desc"`
Name string `json:"name"`
Created string `json:"created"`
Size int64 `json:"size,omitempty"`
Location string `json:"location"`
RequiredBackup string `json:"required"`
Desc string `json:"desc"`
}
backupsJSON := make([]backupJSON, 0)
cfg, err := config.LoadConfig(api.configPath)
Expand All @@ -426,11 +427,12 @@ func (api *APIServer) httpListHandler(w http.ResponseWriter, _ *http.Request) {
description = b.Broken
}
backupsJSON = append(backupsJSON, backupJSON{
Name: b.BackupName,
Created: b.CreationDate.Format(APITimeFormat),
Size: b.DataSize + b.MetadataSize,
Location: "local",
Desc: description,
Name: b.BackupName,
Created: b.CreationDate.Format(APITimeFormat),
Size: b.DataSize + b.MetadataSize,
Location: "local",
RequiredBackup: b.RequiredBackup,
Desc: description,
})
}
if cfg.General.RemoteStorage != "none" {
Expand All @@ -448,11 +450,12 @@ func (api *APIServer) httpListHandler(w http.ResponseWriter, _ *http.Request) {
description = b.Broken
}
backupsJSON = append(backupsJSON, backupJSON{
Name: b.BackupName,
Created: b.CreationDate.Format(APITimeFormat),
Size: b.DataSize + b.MetadataSize,
Location: "remote",
Desc: description,
Name: b.BackupName,
Created: b.CreationDate.Format(APITimeFormat),
Size: b.DataSize + b.MetadataSize,
Location: "remote",
RequiredBackup: b.RequiredBackup,
Desc: description,
})
}
}
Expand Down

0 comments on commit d252463

Please sign in to comment.