Skip to content

Commit 9dfdabf

Browse files
authored
feat(webhosting): add public reset hosting password (#2061)
1 parent 90f2be2 commit 9dfdabf

File tree

1 file changed

+52
-1
lines changed

1 file changed

+52
-1
lines changed

api/webhosting/v1alpha1/webhosting_sdk.go

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,21 @@ type ListOffersResponse struct {
747747
Offers []*Offer `json:"offers"`
748748
}
749749

750+
// ResetHostingPasswordRequest: reset hosting password request.
751+
type ResetHostingPasswordRequest struct {
752+
// Region: region to target. If none is passed will use default region from the config.
753+
Region scw.Region `json:"-"`
754+
755+
// HostingID: UUID of the hosting.
756+
HostingID string `json:"-"`
757+
}
758+
759+
// ResetHostingPasswordResponse: reset hosting password response.
760+
type ResetHostingPasswordResponse struct {
761+
// Password: new password.
762+
Password string `json:"password"`
763+
}
764+
750765
// RestoreHostingRequest: restore hosting request.
751766
type RestoreHostingRequest struct {
752767
// Region: region to target. If none is passed will use default region from the config.
@@ -1082,7 +1097,7 @@ func (s *API) ListOffers(req *ListOffersRequest, opts ...scw.RequestOption) (*Li
10821097
return &resp, nil
10831098
}
10841099

1085-
// ListControlPanels: List the control panels type: cpanel or plesk.
1100+
// ListControlPanels: "List the control panels type: cpanel or plesk.".
10861101
func (s *API) ListControlPanels(req *ListControlPanelsRequest, opts ...scw.RequestOption) (*ListControlPanelsResponse, error) {
10871102
var err error
10881103

@@ -1154,3 +1169,39 @@ func (s *API) CreateSession(req *CreateSessionRequest, opts ...scw.RequestOption
11541169
}
11551170
return &resp, nil
11561171
}
1172+
1173+
// ResetHostingPassword:
1174+
func (s *API) ResetHostingPassword(req *ResetHostingPasswordRequest, opts ...scw.RequestOption) (*ResetHostingPasswordResponse, error) {
1175+
var err error
1176+
1177+
if req.Region == "" {
1178+
defaultRegion, _ := s.client.GetDefaultRegion()
1179+
req.Region = defaultRegion
1180+
}
1181+
1182+
if fmt.Sprint(req.Region) == "" {
1183+
return nil, errors.New("field Region cannot be empty in request")
1184+
}
1185+
1186+
if fmt.Sprint(req.HostingID) == "" {
1187+
return nil, errors.New("field HostingID cannot be empty in request")
1188+
}
1189+
1190+
scwReq := &scw.ScalewayRequest{
1191+
Method: "POST",
1192+
Path: "/webhosting/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/hostings/" + fmt.Sprint(req.HostingID) + "/reset-password",
1193+
}
1194+
1195+
err = scwReq.SetBody(req)
1196+
if err != nil {
1197+
return nil, err
1198+
}
1199+
1200+
var resp ResetHostingPasswordResponse
1201+
1202+
err = s.client.Do(scwReq, &resp, opts...)
1203+
if err != nil {
1204+
return nil, err
1205+
}
1206+
return &resp, nil
1207+
}

0 commit comments

Comments
 (0)