Skip to content

Commit

Permalink
Add BackupGetSchedule, BackupSetSchedule
Browse files Browse the repository at this point in the history
  • Loading branch information
allen-munsch committed Oct 15, 2018
1 parent ab00f58 commit f205dd9
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions lib/servers.go
Original file line number Diff line number Diff line change
Expand Up @@ -645,3 +645,34 @@ func (c *Client) EnablePrivateNetworkForServer(id, networkID string) error {

return c.post(`server/private_network_enable`, values, nil)
}

// BackupSchedule represents a scheduled backup on a server
// see: server/backup_set_schedule, server/backup_get_schedule
type BackupSchedule struct {
Enabled bool `json:"enabled"`
CronType string `json:"cron_type"`
NextScheduledTimeUtc string `json:"next_scheduled_time_utc"`
Hour int `json:"hour"`
Dow int `json:"dow"`
Dom int `json:"dom"`
}

// BackupGetSchedule
func (c *Client) BackupGetSchedule(id string) (BackupSchedule, error) {
values := url.Values{
"SUBID": {id},
}
return c.post(`server/backup_get_schedule`, values, nil)
}

// BackupSetSchedule
func (c *Client) BackupSetSchedule(id string, cronType string, hour int, dayOfWeek int, dayOfMonth int) error {
values := url.Values{
"SUBID": {id},
"cron_type": {cronType},
"hour": {hour},
"dow": {dayOfWeek},
"dom": {dayOfMonth},
}
return c.post(`server/backup_set_schedule`, values, nil)
}

0 comments on commit f205dd9

Please sign in to comment.