Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(instance): expose IP state in server.public_ips #1895

Merged
merged 1 commit into from
Oct 26, 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
36 changes: 36 additions & 0 deletions api/instance/v1/instance_sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,39 @@ func (enum *ServerIPProvisioningMode) UnmarshalJSON(data []byte) error {
return nil
}

type ServerIPState string

const (
ServerIPStateUnknownState = ServerIPState("unknown_state")
ServerIPStateDetached = ServerIPState("detached")
ServerIPStateAttached = ServerIPState("attached")
ServerIPStatePending = ServerIPState("pending")
ServerIPStateError = ServerIPState("error")
)

func (enum ServerIPState) String() string {
if enum == "" {
// return default value if empty
return "unknown_state"
}
return string(enum)
}

func (enum ServerIPState) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf(`"%s"`, enum)), nil
}

func (enum *ServerIPState) UnmarshalJSON(data []byte) error {
tmp := ""

if err := json.Unmarshal(data, &tmp); err != nil {
return err
}

*enum = ServerIPState(ServerIPState(tmp).String())
return nil
}

type ServerState string

const (
Expand Down Expand Up @@ -1115,6 +1148,9 @@ type ServerIP struct {

// Tags: tags associated with the IP.
Tags []string `json:"tags"`

// State: default value: unknown_state
State ServerIPState `json:"state"`
}

// ServerIPv6: server i pv6.
Expand Down
Loading