You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
decort-golang-sdk/pkg/cloudbroker/account/restore.go

39 lines
724 B

package account
import (
"context"
"errors"
"net/http"
)
type RestoreRequest struct {
AccountID uint64 `url:"accountId"`
Reason string `url:"reason"`
}
func (arq RestoreRequest) Validate() error {
if arq.AccountID == 0 {
return errors.New("validation-error: field AccountID must be set")
}
if arq.Reason == "" {
return errors.New("validation-error: field Reason must be set")
}
return nil
}
func (a Account) Restore(ctx context.Context, req RestoreRequest) (bool, error) {
err := req.Validate()
if err != nil {
return false, err
}
url := "/cloudbroker/account/restore"
_, err = a.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return false, err
}
return true, nil
}