Add first implementation of local backups for a server

This commit is contained in:
Dane Everitt
2020-04-04 16:07:25 -07:00
parent 5fd138e188
commit 4ce2b73490
6 changed files with 272 additions and 0 deletions

View File

@@ -122,3 +122,29 @@ func (r *PanelRequest) SendInstallationStatus(uuid string, successful bool) (*Re
return nil, nil
}
type BackupRequest struct {
Successful bool `json:"successful"`
Sha256Hash string `json:"sha256_hash"`
FileSize int64 `json:"file_size"`
}
func (r *PanelRequest) SendBackupStatus(uuid string, backup string, data BackupRequest) (*RequestError, error) {
b, err := json.Marshal(data)
if err != nil {
return nil, errors.WithStack(err)
}
resp, err := r.Post(fmt.Sprintf("/servers/%s/backup/%s", uuid, backup), b)
if err != nil {
return nil, errors.WithStack(err)
}
defer resp.Body.Close()
r.Response = resp
if r.HasError() {
return r.Error(), nil
}
return nil, nil
}