Skip to content

Commit a5a30db

Browse files
authored
feat(mongodb): add DeleteEndpoint (scaleway#2308)
1 parent 093e607 commit a5a30db

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

api/mongodb/v1alpha1/mongodb_sdk.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,15 @@ type CreateUserRequest struct {
733733
Password string `json:"password"`
734734
}
735735

736+
// DeleteEndpointRequest: delete endpoint request.
737+
type DeleteEndpointRequest struct {
738+
// Region: region to target. If none is passed will use default region from the config.
739+
Region scw.Region `json:"-"`
740+
741+
// EndpointID: UUID of the Endpoint to delete.
742+
EndpointID string `json:"-"`
743+
}
744+
736745
// DeleteInstanceRequest: delete instance request.
737746
type DeleteInstanceRequest struct {
738747
// Region: region to target. If none is passed will use default region from the config.
@@ -1763,3 +1772,32 @@ func (s *API) UpdateUser(req *UpdateUserRequest, opts ...scw.RequestOption) (*Us
17631772
}
17641773
return &resp, nil
17651774
}
1775+
1776+
// DeleteEndpoint: Delete the endpoint of a Database Instance. You must specify the `endpoint_id` parameter of the endpoint you want to delete. Note that you might need to update any environment configurations that point to the deleted endpoint.
1777+
func (s *API) DeleteEndpoint(req *DeleteEndpointRequest, opts ...scw.RequestOption) error {
1778+
var err error
1779+
1780+
if req.Region == "" {
1781+
defaultRegion, _ := s.client.GetDefaultRegion()
1782+
req.Region = defaultRegion
1783+
}
1784+
1785+
if fmt.Sprint(req.Region) == "" {
1786+
return errors.New("field Region cannot be empty in request")
1787+
}
1788+
1789+
if fmt.Sprint(req.EndpointID) == "" {
1790+
return errors.New("field EndpointID cannot be empty in request")
1791+
}
1792+
1793+
scwReq := &scw.ScalewayRequest{
1794+
Method: "DELETE",
1795+
Path: "/mongodb/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/endpoints/" + fmt.Sprint(req.EndpointID) + "",
1796+
}
1797+
1798+
err = s.client.Do(scwReq, nil, opts...)
1799+
if err != nil {
1800+
return err
1801+
}
1802+
return nil
1803+
}

0 commit comments

Comments
 (0)