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(k8s): add support for DeleteNode #1290

Merged
merged 2 commits into from
Jun 10, 2022
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
38 changes: 38 additions & 0 deletions api/k8s/v1/k8s_sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -2215,6 +2215,44 @@ func (s *API) RebootNode(req *RebootNodeRequest, opts ...scw.RequestOption) (*No
return &resp, nil
}

type DeleteNodeRequest struct {
// Region:
//
// Region to target. If none is passed will use default region from the config
Region scw.Region `json:"-"`

NodeID string `json:"-"`
}

func (s *API) DeleteNode(req *DeleteNodeRequest, opts ...scw.RequestOption) error {
var err error

if req.Region == "" {
defaultRegion, _ := s.client.GetDefaultRegion()
req.Region = defaultRegion
}

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

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

scwReq := &scw.ScalewayRequest{
Method: "DELETE",
Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/nodes/" + fmt.Sprint(req.NodeID) + "",
Headers: http.Header{},
}

err = s.client.Do(scwReq, nil, opts...)
if err != nil {
return err
}
return nil
}

type ListVersionsRequest struct {
// Region:
//
Expand Down