2025-09-27 01:06:15 +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-27 01:06:15 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// RemoveZoneRequest struct for removing zone from account for a user
|
|
|
|
|
type RemoveZoneRequest struct {
|
|
|
|
|
// ID of account to add to
|
|
|
|
|
// Required: true
|
|
|
|
|
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
|
|
|
|
|
|
|
|
|
// IDs of zones
|
|
|
|
|
// Required: true
|
|
|
|
|
ZoneIDs []uint64 `url:"zoneIds" json:"zoneIds" validate:"required"`
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-30 16:04:15 +03:00
|
|
|
type wrapperRemoveZoneRequest struct {
|
|
|
|
|
RemoveZoneRequest
|
|
|
|
|
|
|
|
|
|
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-27 01:06:15 +03:00
|
|
|
// RemoveZone removes zones with ids provided from a user.
|
|
|
|
|
func (a Account) RemoveZone(ctx context.Context, req RemoveZoneRequest) (bool, error) {
|
|
|
|
|
err := validators.ValidateRequest(req)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
url := "/cloudbroker/account/removeZone"
|
|
|
|
|
|
2026-10-30 16:04:15 +03:00
|
|
|
reqWrapped := wrapperRemoveZoneRequest{
|
|
|
|
|
RemoveZoneRequest: req,
|
|
|
|
|
AsyncMode: false,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
2025-09-27 01:06:15 +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
|
|
|
|
|
|
|
|
// RemoveZoneAsync removes zones with ids provided from a user in async mode
|
|
|
|
|
func (a Account) RemoveZoneAsync(ctx context.Context, req RemoveZoneRequest) (string, error) {
|
|
|
|
|
err := validators.ValidateRequest(req)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
url := "/cloudbroker/account/removeZone"
|
|
|
|
|
|
|
|
|
|
reqWrapped := wrapperRemoveZoneRequest{
|
|
|
|
|
RemoveZoneRequest: req,
|
|
|
|
|
AsyncMode: true,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return string(res), nil
|
|
|
|
|
}
|