package compute

import (
	"context"
	"encoding/json"
	"net/http"

	"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)

// GuestAgentFeatureGetRequest struct to feature get guest agent
type GuestAgentFeatureGetRequest struct {
	// ID of compute instance
	// Required: true
	ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
}

// List of features
func (c Compute) GuestAgentFeatureGet(ctx context.Context, req GuestAgentFeatureGetRequest) ([]string, error) {
	err := validators.ValidateRequest(req)
	if err != nil {
		return nil, validators.ValidationErrors(validators.GetErrors(err))
	}

	url := "/cloudbroker/compute/guest_agent_feature_get"

	res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
	if err != nil {
		return nil, err
	}

	features := make([]string, 0)

	err = json.Unmarshal(res, &features)
	if err != nil {
		return nil, err
	}

	return features, nil
}
