Skip to content

Commit

Permalink
Change grpc enum to sdk enum
Browse files Browse the repository at this point in the history
  • Loading branch information
algamaes committed Aug 4, 2023
1 parent d49608d commit 8faebe9
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 10 deletions.
11 changes: 10 additions & 1 deletion services/compute/compute.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ const (
IPv6 IPVersion = "IPv6"
)

type StatusLevelType string

const (
StatusLevelUnknown StatusLevelType = "Unknown"
StatusLevelInfo StatusLevelType = "Info"
StatusLevelWarning StatusLevelType = "Warning"
StatusLevelError StatusLevelType = "Error"
)

// ImageReference specifies information about the image to use. You can specify information about platform
// images, marketplace images, or virtual machine images. This element is required when you want to use a
// platform image, marketplace image, or virtual machine image, but is not used in other creation
Expand Down Expand Up @@ -239,7 +248,7 @@ type InstanceViewStatus struct {
// Code - READ-ONLY; The status code, which only appears in the response.
Code string `json:"code,omitempty"`
// Level - READ-ONLY; The level code, which only appears in the response.
Level common.InstanceViewStatus_StatusLevelType `json:"level,omitempty"`
Level StatusLevelType `json:"level,omitempty"`
// DisplayStatus - READ-ONLY; The short localizable label for the status, which only appears in the response.
DisplayStatus string `json:"displayStatus,omitempty"`
// Message - READ-ONLY; The detailed status message, including for alerts and error messages, which only appears in the response.
Expand Down
30 changes: 21 additions & 9 deletions services/compute/virtualmachine/virtualmachine.go
Original file line number Diff line number Diff line change
Expand Up @@ -593,15 +593,7 @@ func (c *client) getVirtualMachineGuestInstanceView(g *wssdcommon.VirtualMachine
}

for _, status := range g.GetStatuses() {
gapStatus := compute.InstanceViewStatus{
Code: status.GetCode(),
Level: status.GetLevel(),
DisplayStatus: status.GetDisplayStatus(),
Message: status.GetMessage(),
Time: status.GetTime(),
}

gap.Statuses = append(gap.Statuses, &gapStatus)
gap.Statuses = append(gap.Statuses, c.getInstanceViewStatus(status))
}

return gap
Expand Down Expand Up @@ -654,6 +646,26 @@ func (c *client) getVirtualMachineLinuxConfiguration(linuxConfiguration *wssdclo
return lc
}

func (c *client) getInstanceViewStatus(status *wssdcommon.InstanceViewStatus) *compute.InstanceViewStatus {
level := compute.StatusLevelUnknown
switch status.GetLevel() {
case wssdcommon.InstanceViewStatus_Info:
level = compute.StatusLevelInfo
case wssdcommon.InstanceViewStatus_Warning:
level = compute.StatusLevelWarning
case wssdcommon.InstanceViewStatus_Error:
level = compute.StatusLevelError
}

return &compute.InstanceViewStatus{
Code: status.GetCode(),
Level: level,
DisplayStatus: status.GetDisplayStatus(),
Message: status.GetMessage(),
Time: status.GetTime(),
}
}

func (c *client) getVirtualMachineOSProfile(o *wssdcloudcompute.OperatingSystemConfiguration) *compute.OSProfile {
osType := compute.Windows
switch o.Ostype {
Expand Down

0 comments on commit 8faebe9

Please sign in to comment.