43 lines
1.0 KiB
Go
43 lines
1.0 KiB
Go
|
|
package user
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
"net/http"
|
||
|
|
"strconv"
|
||
|
|
|
||
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||
|
|
)
|
||
|
|
|
||
|
|
// UpdateServiceAccountRequest to update ServiceAccount field
|
||
|
|
type UpdateServiceAccountRequest struct {
|
||
|
|
// User ID
|
||
|
|
// Required: true
|
||
|
|
UserID string `url:"user_id" json:"user_id" validate:"required"`
|
||
|
|
|
||
|
|
// Whether the account is a service account
|
||
|
|
// Required: true
|
||
|
|
ServiceAccount interface{} `url:"serviceaccount" json:"serviceaccount" validate:"required,isBool"`
|
||
|
|
}
|
||
|
|
|
||
|
|
// UpdateServiceAccount updates ServiceAccount field
|
||
|
|
func (u User) UpdateServiceAccount(ctx context.Context, req UpdateServiceAccountRequest) (bool, error) {
|
||
|
|
err := validators.ValidateRequest(req)
|
||
|
|
if err != nil {
|
||
|
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||
|
|
}
|
||
|
|
|
||
|
|
url := "/cloudbroker/user/update_service_account"
|
||
|
|
|
||
|
|
res, err := u.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||
|
|
if err != nil {
|
||
|
|
return false, err
|
||
|
|
}
|
||
|
|
|
||
|
|
result, err := strconv.ParseBool(string(res))
|
||
|
|
if err != nil {
|
||
|
|
return false, err
|
||
|
|
}
|
||
|
|
|
||
|
|
return result, nil
|
||
|
|
}
|