Files
dynamix-golang-sdk/pkg/cloudapi/account/delete_user.go
T

79 lines
1.8 KiB
Go
Raw Normal View History

2025-09-23 14:34:24 +03:00
package account
import (
"context"
"net/http"
"strconv"
2026-08-21 18:12:55 +04:00
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/validators"
2025-09-23 14:34:24 +03:00
)
// DeleteUserRequest struct to revoke access to account
type DeleteUserRequest struct {
// ID of the account
// Required: true
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
// ID or emailaddress of the user to remove
// Required: true
UserID string `url:"userId" json:"userId" validate:"required"`
}
2026-10-30 16:04:15 +03:00
type wrapperDeleteUserRequest struct {
DeleteUserRequest
AsyncMode bool `url:"async_mode" json:"async_mode"`
}
2025-09-23 14:34:24 +03:00
// DeleteUser revokes user access from the account
2026-08-28 16:47:26 +03:00
//
2026-10-16 15:40:34 +03:00
// Deprecated: will be removed in SDK v17.0
2025-09-23 14:34:24 +03:00
func (a Account) DeleteUser(ctx context.Context, req DeleteUserRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudapi/account/deleteUser"
2026-10-30 16:04:15 +03:00
reqWrapped := wrapperDeleteUserRequest{
DeleteUserRequest: req,
AsyncMode: false,
}
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
2025-09-23 14:34:24 +03:00
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return result, nil
}
2026-10-30 16:04:15 +03:00
// DeleteUserAsync revokes user access from the account in async mode
//
// Deprecated: will be removed in SDK v17.0
func (a Account) DeleteUserAsync(ctx context.Context, req DeleteUserRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudapi/account/deleteUser"
reqWrapped := wrapperDeleteUserRequest{
DeleteUserRequest: req,
AsyncMode: true,
}
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}
return string(res), nil
}