From 69e5d8a6a8aa0c4c6b286f42efab4f79a20566bb Mon Sep 17 00:00:00 2001 From: Maximillian Brustkern <6314562+nuclearbob@users.noreply.github.com> Date: Fri, 12 May 2023 12:19:21 -0400 Subject: [PATCH] Add Rescue function to device Signed-off-by: Maximillian Brustkern <6314562+nuclearbob@users.noreply.github.com> --- devices.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/devices.go b/devices.go index 3e5e925..751474f 100644 --- a/devices.go +++ b/devices.go @@ -28,6 +28,7 @@ type DeviceService interface { Reinstall(string, *DeviceReinstallFields) (*Response, error) PowerOff(string) (*Response, error) PowerOn(string) (*Response, error) + Rescue(string) (*Response, error) Lock(string) (*Response, error) Unlock(string) (*Response, error) ListBGPSessions(deviceID string, opts *ListOptions) ([]BGPSession, *Response, error) @@ -443,9 +444,9 @@ type DeviceDeleteRequest struct { Force bool `json:"force_delete"` } type DeviceReinstallFields struct { - OperatingSystem string `json:"operating_system,omitempty"` - PreserveData bool `json:"preserve_data,omitempty"` - DeprovisionFast bool `json:"deprovision_fast,omitempty"` + OperatingSystem string `json:"operating_system,omitempty"` + PreserveData bool `json:"preserve_data,omitempty"` + DeprovisionFast bool `json:"deprovision_fast,omitempty"` } type DeviceReinstallRequest struct { @@ -600,6 +601,17 @@ func (s *DeviceServiceOp) PowerOn(deviceID string) (*Response, error) { return s.client.DoRequest("POST", apiPath, action, nil) } +// Rescue boots a device into Rescue OS +func (s *DeviceServiceOp) Rescue(deviceID string) (*Response, error) { + if validateErr := ValidateUUID(deviceID); validateErr != nil { + return nil, validateErr + } + apiPath := path.Join(deviceBasePath, deviceID, "actions") + action := &DeviceActionRequest{Type: "rescue"} + + return s.client.DoRequest("POST", apiPath, action, nil) +} + type lockType struct { Locked bool `json:"locked"` }