Add ability to create archives of servers, add GET and POST /api/servers/:server/archive routes to get and request an archive of a server

This commit is contained in:
Matthew Penner
2020-04-03 23:17:26 -06:00
parent 5fd138e188
commit 3dba11ac6f
8 changed files with 244 additions and 39 deletions

View File

@@ -122,3 +122,27 @@ func (r *PanelRequest) SendInstallationStatus(uuid string, successful bool) (*Re
return nil, nil
}
type archiveRequest struct {
Successful bool `json:"successful"`
}
func (r *PanelRequest) SendArchiveStatus(uuid string, successful bool) (*RequestError, error) {
b, err := json.Marshal(archiveRequest{Successful: successful})
if err != nil {
return nil, errors.WithStack(err)
}
resp, err := r.Post(fmt.Sprintf("/servers/%s/archive", uuid), 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
}