package compute

import (
	"context"
	"net/http"
	"strings"

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

// MigrateStorageInfoRequest struct to get info about migration
type MigrateStorageInfoRequest struct {
	// ID of the compute instance
	// Required: true
	ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
}

// MigrateStorageInfo gets info about last (include ongoing) storage migration
func (c Compute) MigrateStorageInfo(ctx context.Context, req MigrateStorageInfoRequest) (string, error) {
	err := validators.ValidateRequest(req)
	if err != nil {
		return "", validators.ValidationErrors(validators.GetErrors(err))
	}

	url := "/cloudbroker/compute/migrateStorageInfo"

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

	result := strings.ReplaceAll(string(res), "\"", "")

	return result, nil
}
