2025-09-27 01:06:15 +03:00
|
|
|
package compute
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"net/http"
|
|
|
|
|
"strconv"
|
|
|
|
|
|
2026-06-05 17:30:36 +03:00
|
|
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators"
|
2025-09-27 01:06:15 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// GuestAgentFeatureUpdateRequest struct to feature update guest agent
|
|
|
|
|
type GuestAgentFeatureUpdateRequest struct {
|
|
|
|
|
// ID of compute instance
|
|
|
|
|
// Required: true
|
|
|
|
|
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-05 17:30:36 +03:00
|
|
|
type wrapperGuestAgentFeatureUpdateRequest struct {
|
|
|
|
|
GuestAgentFeatureUpdateRequest
|
|
|
|
|
|
|
|
|
|
AsyncMode bool `url:"asyncMode"`
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-27 01:06:15 +03:00
|
|
|
// Feature update guest agent
|
|
|
|
|
func (c Compute) GuestAgentFeatureUpdate(ctx context.Context, req GuestAgentFeatureUpdateRequest) (bool, error) {
|
|
|
|
|
err := validators.ValidateRequest(req)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-05 17:30:36 +03:00
|
|
|
reqWrapped := wrapperGuestAgentFeatureUpdateRequest{
|
|
|
|
|
GuestAgentFeatureUpdateRequest: req,
|
|
|
|
|
AsyncMode: false,
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-27 01:06:15 +03:00
|
|
|
url := "/cloudapi/compute/guest_agent_feature_update"
|
|
|
|
|
|
2026-06-05 17:30:36 +03:00
|
|
|
res, err := c.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-06-05 17:30:36 +03:00
|
|
|
|
|
|
|
|
// GuestAgentFeatureUpdateAsync feature updates guest agent with AsyncMode
|
|
|
|
|
func (c Compute) GuestAgentFeatureUpdateAsync(ctx context.Context, req GuestAgentFeatureUpdateRequest) (string, error) {
|
|
|
|
|
err := validators.ValidateRequest(req)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
reqWrapped := wrapperGuestAgentFeatureUpdateRequest{
|
|
|
|
|
GuestAgentFeatureUpdateRequest: req,
|
|
|
|
|
AsyncMode: true,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
url := "/cloudapi/compute/guest_agent_feature_update"
|
|
|
|
|
|
|
|
|
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return string(res), nil
|
|
|
|
|
}
|