Skip to content
This repository has been archived by the owner on Jun 21, 2024. It is now read-only.

Add Rescue function to device #365

Merged
merged 1 commit into from
May 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions devices.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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"`
Copy link
Contributor

@displague displague May 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so sayeth go fmt. (I ran it against master to confirm)

Other files with unexpected formatting (to be addressed in a separate PR):

  • batches.go
  • organizations_test.go
  • ports.go

PreserveData bool `json:"preserve_data,omitempty"`
DeprovisionFast bool `json:"deprovision_fast,omitempty"`
}

type DeviceReinstallRequest struct {
Expand Down Expand Up @@ -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"`
}
Expand Down