Skip to content

Commit e61d703

Browse files
fix(iam/v1alpha1): set UpdateOrganizationLoginMethods body (scaleway#2774)
Co-authored-by: Jonathan R. <[email protected]>
1 parent 3eb0f2a commit e61d703

File tree

1 file changed

+9
-42
lines changed

1 file changed

+9
-42
lines changed

api/iam/v1alpha1/iam_sdk.go

Lines changed: 9 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2538,12 +2538,6 @@ type MFAOTP struct {
25382538
Secret string `json:"secret"`
25392539
}
25402540

2541-
// MigrateOrganizationGuestsRequest: migrate organization guests request.
2542-
type MigrateOrganizationGuestsRequest struct {
2543-
// OrganizationID: ID of the Organization.
2544-
OrganizationID string `json:"-"`
2545-
}
2546-
25472541
// Organization: organization.
25482542
type Organization struct {
25492543
// ID: ID of the Organization.
@@ -2712,16 +2706,16 @@ type UpdateOrganizationLoginMethodsRequest struct {
27122706
OrganizationID string `json:"-"`
27132707

27142708
// LoginPasswordEnabled: defines whether login with a password is enabled for the Organization.
2715-
LoginPasswordEnabled *bool `json:"-"`
2709+
LoginPasswordEnabled *bool `json:"login_password_enabled,omitempty"`
27162710

27172711
// LoginOauth2Enabled: defines whether login through OAuth2 is enabled for the Organization.
2718-
LoginOauth2Enabled *bool `json:"-"`
2712+
LoginOauth2Enabled *bool `json:"login_oauth2_enabled,omitempty"`
27192713

27202714
// LoginMagicCodeEnabled: defines whether login with an authentication code is enabled for the Organization.
2721-
LoginMagicCodeEnabled *bool `json:"-"`
2715+
LoginMagicCodeEnabled *bool `json:"login_magic_code_enabled,omitempty"`
27222716

27232717
// LoginSamlEnabled: defines whether login through SAML is enabled for the Organization.
2724-
LoginSamlEnabled *bool `json:"-"`
2718+
LoginSamlEnabled *bool `json:"login_saml_enabled,omitempty"`
27252719
}
27262720

27272721
// UpdateOrganizationSecuritySettingsRequest: update organization security settings request.
@@ -4559,31 +4553,6 @@ func (s *API) GetOrganization(req *GetOrganizationRequest, opts ...scw.RequestOp
45594553
return &resp, nil
45604554
}
45614555

4562-
// MigrateOrganizationGuests: Migrate the organization's guests to IAM members.
4563-
func (s *API) MigrateOrganizationGuests(req *MigrateOrganizationGuestsRequest, opts ...scw.RequestOption) error {
4564-
var err error
4565-
4566-
if req.OrganizationID == "" {
4567-
defaultOrganizationID, _ := s.client.GetDefaultOrganizationID()
4568-
req.OrganizationID = defaultOrganizationID
4569-
}
4570-
4571-
if fmt.Sprint(req.OrganizationID) == "" {
4572-
return errors.New("field OrganizationID cannot be empty in request")
4573-
}
4574-
4575-
scwReq := &scw.ScalewayRequest{
4576-
Method: "POST",
4577-
Path: "/iam/v1alpha1/organizations/" + fmt.Sprint(req.OrganizationID) + "/migrate-guests",
4578-
}
4579-
4580-
err = s.client.Do(scwReq, nil, opts...)
4581-
if err != nil {
4582-
return err
4583-
}
4584-
return nil
4585-
}
4586-
45874556
// UpdateOrganizationLoginMethods: Set your Organization's allowed login methods.
45884557
func (s *API) UpdateOrganizationLoginMethods(req *UpdateOrganizationLoginMethodsRequest, opts ...scw.RequestOption) (*Organization, error) {
45894558
var err error
@@ -4593,20 +4562,18 @@ func (s *API) UpdateOrganizationLoginMethods(req *UpdateOrganizationLoginMethods
45934562
req.OrganizationID = defaultOrganizationID
45944563
}
45954564

4596-
query := url.Values{}
4597-
parameter.AddToQuery(query, "login_password_enabled", req.LoginPasswordEnabled)
4598-
parameter.AddToQuery(query, "login_oauth2_enabled", req.LoginOauth2Enabled)
4599-
parameter.AddToQuery(query, "login_magic_code_enabled", req.LoginMagicCodeEnabled)
4600-
parameter.AddToQuery(query, "login_saml_enabled", req.LoginSamlEnabled)
4601-
46024565
if fmt.Sprint(req.OrganizationID) == "" {
46034566
return nil, errors.New("field OrganizationID cannot be empty in request")
46044567
}
46054568

46064569
scwReq := &scw.ScalewayRequest{
46074570
Method: "PATCH",
46084571
Path: "/iam/v1alpha1/organizations/" + fmt.Sprint(req.OrganizationID) + "/login-methods",
4609-
Query: query,
4572+
}
4573+
4574+
err = scwReq.SetBody(req)
4575+
if err != nil {
4576+
return nil, err
46104577
}
46114578

46124579
var resp Organization

0 commit comments

Comments
 (0)