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

fix: properly convert ipId to ip-id, rename field of DeleteIpRequest #272

Merged
merged 3 commits into from
Dec 10, 2019
Merged
Show file tree
Hide file tree
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
10 changes: 5 additions & 5 deletions api/instance/v1/instance_sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -4054,8 +4054,8 @@ func (s *API) updateIP(req *updateIPRequest, opts ...scw.RequestOption) (*Update

type DeleteIPRequest struct {
Zone scw.Zone `json:"-"`

IPID string `json:"-"`
// IP the ID or the address of the IP to delete
IP string `json:"-"`
}

// DeleteIP delete IP
Expand All @@ -4073,13 +4073,13 @@ func (s *API) DeleteIP(req *DeleteIPRequest, opts ...scw.RequestOption) error {
return errors.New("field Zone cannot be empty in request")
}

if fmt.Sprint(req.IPID) == "" {
return errors.New("field IPID cannot be empty in request")
if fmt.Sprint(req.IP) == "" {
return errors.New("field IP cannot be empty in request")
}

scwReq := &scw.ScalewayRequest{
Method: "DELETE",
Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/ips/" + fmt.Sprint(req.IPID) + "",
Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/ips/" + fmt.Sprint(req.IP) + "",
Headers: http.Header{},
}

Expand Down
2 changes: 1 addition & 1 deletion api/instance/v1/instance_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func TestInstanceHelpers(t *testing.T) {
// Delete IP
err = instanceAPI.DeleteIP(&DeleteIPRequest{
Zone: zone,
IPID: ipID,
IP: ipID,
})
testhelpers.AssertNoError(t, err)

Expand Down
4 changes: 2 additions & 2 deletions strcase/bash_arg.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package strcase
import "strings"

var customBashNames = map[string]string{
"IPID": "ip-id",
"ipid": "ip-id",
}

// ToBashArg returns the Bash public name of the given string.
func ToBashArg(s string) string {
s = ToPublicGoName(s)
if customBashName, exists := customBashNames[s]; exists {
if customBashName, exists := customBashNames[strings.ToLower(s)]; exists {
return customBashName
}
for _, initialism := range customInitialisms {
Expand Down