2026-03-27 17:29:52 +03:00
|
|
|
package resource_optimizer
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"net/http"
|
|
|
|
|
"strconv"
|
|
|
|
|
|
|
|
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// DRSUpdateRequest struct to update DRS
|
|
|
|
|
type DRSUpdateRequest struct {
|
|
|
|
|
// ID of the zone
|
|
|
|
|
// Required: true
|
|
|
|
|
ZoneID uint64 `url:"zone_id" json:"zone_id" validate:"required"`
|
|
|
|
|
|
2026-04-17 17:04:11 +03:00
|
|
|
// SSO provider type
|
|
|
|
|
// Available values: bvs, decs3o
|
|
|
|
|
// Required: true
|
|
|
|
|
SSOType string `url:"sso_type" json:"sso_type" validate:"required,oneof=bvs decs3o"`
|
|
|
|
|
|
2026-03-27 17:29:52 +03:00
|
|
|
// Application ID
|
|
|
|
|
// Required: false
|
|
|
|
|
AppID string `url:"app_id,omitempty" json:"app_id,omitempty"`
|
|
|
|
|
|
|
|
|
|
// Application secret
|
|
|
|
|
// Required: false
|
|
|
|
|
AppSecret string `url:"app_secret,omitempty" json:"app_secret,omitempty"`
|
|
|
|
|
|
|
|
|
|
// Decort URL
|
|
|
|
|
// Required: false
|
|
|
|
|
DecortURL string `url:"decort_url,omitempty" json:"decort_url,omitempty"`
|
|
|
|
|
|
|
|
|
|
// SSO URL
|
|
|
|
|
// Required: false
|
|
|
|
|
SSOURL string `url:"sso_url,omitempty" json:"sso_url,omitempty"`
|
|
|
|
|
|
|
|
|
|
// DRS name
|
|
|
|
|
// Required: false
|
|
|
|
|
DRSName string `url:"drs_name,omitempty" json:"drs_name,omitempty"`
|
2026-04-17 17:04:11 +03:00
|
|
|
|
|
|
|
|
// Username
|
|
|
|
|
// Required: false
|
|
|
|
|
Username string `url:"username,omitempty" json:"username,omitempty"`
|
|
|
|
|
|
|
|
|
|
// Password
|
|
|
|
|
// Required: false
|
|
|
|
|
Password string `url:"password,omitempty" json:"password,omitempty"`
|
|
|
|
|
|
|
|
|
|
// Broadcast address
|
|
|
|
|
// Required: false
|
|
|
|
|
BroadcastAddr string `url:"broadcast_addr,omitempty" json:"broadcast_addr,omitempty"`
|
|
|
|
|
|
|
|
|
|
// Ping address
|
|
|
|
|
// Required: false
|
|
|
|
|
PingAddr string `url:"ping_addr,omitempty" json:"ping_addr,omitempty"`
|
|
|
|
|
|
|
|
|
|
// Skip SSL certificate verification
|
|
|
|
|
// Required: false
|
|
|
|
|
SSLSkipVerify interface{} `url:"ssl_skip_verify,omitempty" json:"ssl_skip_verify,omitempty"`
|
|
|
|
|
|
|
|
|
|
// Domain
|
|
|
|
|
// Required: false
|
|
|
|
|
Domain string `url:"domain,omitempty" json:"domain,omitempty"`
|
2026-03-27 17:29:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// DRSUpdate updates DRS configuration in the specified zone
|
|
|
|
|
func (ro ResourceOptimizer) DRSUpdate(ctx context.Context, req DRSUpdateRequest) (bool, error) {
|
|
|
|
|
err := validators.ValidateRequest(req)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
url := "/cloudbroker/resource_optimizer/drs_update"
|
|
|
|
|
|
|
|
|
|
res, err := ro.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
|
|
|
|
|
}
|