Skip to content

Commit

Permalink
feat: update generated APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
scaleway-bot committed Jan 16, 2025
1 parent 0782539 commit 2d0a2f3
Showing 1 changed file with 111 additions and 3 deletions.
114 changes: 111 additions & 3 deletions api/iam/v1alpha1/iam_sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -1406,6 +1406,12 @@ type CreateSSHKeyRequest struct {
ProjectID string `json:"project_id"`
}

// CreateUserMFAOTPRequest: create user mfaotp request.
type CreateUserMFAOTPRequest struct {
// UserID: user ID of the MFA OTP.
UserID string `json:"-"`
}

// CreateUserRequest: create user request.
type CreateUserRequest struct {
// OrganizationID: ID of the Organization.
Expand Down Expand Up @@ -1458,6 +1464,12 @@ type DeleteSSHKeyRequest struct {
SSHKeyID string `json:"-"`
}

// DeleteUserMFAOTPRequest: delete user mfaotp request.
type DeleteUserMFAOTPRequest struct {
// UserID: user ID of the MFA OTP.
UserID string `json:"-"`
}

// DeleteUserRequest: delete user request.
type DeleteUserRequest struct {
// UserID: ID of the user to delete.
Expand Down Expand Up @@ -2157,6 +2169,11 @@ type LockUserRequest struct {
UserID string `json:"-"`
}

// MFAOTP: mfaotp.
type MFAOTP struct {
Secret string `json:"secret"`
}

// OrganizationSecuritySettings: organization security settings.
type OrganizationSecuritySettings struct {
// EnforcePasswordRenewal: defines whether password renewal is enforced during first login.
Expand Down Expand Up @@ -2319,9 +2336,6 @@ type UpdateUserPasswordRequest struct {

// Password: the new password.
Password string `json:"password"`

// SendEmail: whether or not to send an email alerting the user their password has changed.
SendEmail bool `json:"send_email"`
}

// UpdateUserRequest: update user request.
Expand All @@ -2345,6 +2359,21 @@ type UpdateUserUsernameRequest struct {
Username string `json:"username"`
}

// ValidateUserMFAOTPRequest: validate user mfaotp request.
type ValidateUserMFAOTPRequest struct {
// UserID: user ID of the MFA OTP.
UserID string `json:"-"`

// OneTimePassword: a password generated using the OTP.
OneTimePassword string `json:"one_time_password"`
}

// ValidateUserMFAOTPResponse: validate user mfaotp response.
type ValidateUserMFAOTPResponse struct {
// RecoveryCodes: list of recovery codes usable for this OTP method.
RecoveryCodes []string `json:"recovery_codes"`
}

// This API allows you to manage Identity and Access Management (IAM) across your Scaleway Organizations, Projects and resources.
type API struct {
client *scw.Client
Expand Down Expand Up @@ -2675,6 +2704,85 @@ func (s *API) UpdateUserPassword(req *UpdateUserPasswordRequest, opts ...scw.Req
return &resp, nil
}

// CreateUserMFAOTP: Create a MFA OTP. Private Beta feature.
func (s *API) CreateUserMFAOTP(req *CreateUserMFAOTPRequest, opts ...scw.RequestOption) (*MFAOTP, error) {
var err error

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

scwReq := &scw.ScalewayRequest{
Method: "POST",
Path: "/iam/v1alpha1/users/" + fmt.Sprint(req.UserID) + "/mfa-otp",
}

err = scwReq.SetBody(req)
if err != nil {
return nil, err
}

var resp MFAOTP

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

// ValidateUserMFAOTP: Validate a MFA OTP. Private Beta feature.
func (s *API) ValidateUserMFAOTP(req *ValidateUserMFAOTPRequest, opts ...scw.RequestOption) (*ValidateUserMFAOTPResponse, error) {
var err error

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

scwReq := &scw.ScalewayRequest{
Method: "POST",
Path: "/iam/v1alpha1/users/" + fmt.Sprint(req.UserID) + "/validate-mfa-otp",
}

err = scwReq.SetBody(req)
if err != nil {
return nil, err
}

var resp ValidateUserMFAOTPResponse

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

// DeleteUserMFAOTP: Delete a MFA OTP. Private Beta feature.
func (s *API) DeleteUserMFAOTP(req *DeleteUserMFAOTPRequest, opts ...scw.RequestOption) error {
var err error

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

scwReq := &scw.ScalewayRequest{
Method: "DELETE",
Path: "/iam/v1alpha1/users/" + fmt.Sprint(req.UserID) + "/mfa-otp",
}

err = scwReq.SetBody(req)
if err != nil {
return err
}

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

// LockUser: Lock a member. A locked member cannot log in or use API keys until the locked status is removed. Private Beta feature.
func (s *API) LockUser(req *LockUserRequest, opts ...scw.RequestOption) (*User, error) {
var err error
Expand Down

0 comments on commit 2d0a2f3

Please sign in to comment.