Skip to content

Commit

Permalink
feat(instance): expose IP state in server.public_ips (#1895)
Browse files Browse the repository at this point in the history
  • Loading branch information
scaleway-bot authored Oct 26, 2023
1 parent 9d4d800 commit 2245af2
Showing 1 changed file with 36 additions and 0 deletions.
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

0 comments on commit 2245af2

Please sign in to comment.