package disks

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

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

// GetMigrateStatusRequest struct to get information about disk migrate status
type GetMigrateStatusRequest struct {
	// ID of disk
	// Required: true
	DiskID uint64 `url:"disk_id" json:"disk_id" validate:"required"`
}

// GetMigrateStatus gets information about disk migrate status
func (c Disks) GetMigrateStatus(ctx context.Context, req GetMigrateStatusRequest) (*MigrateStatus, error) {
	err := validators.ValidateRequest(req)
	if err != nil {
		return nil, validators.ValidationErrors(validators.GetErrors(err))
	}

	url := "/cloudbroker/disks/migrate_status"

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

	status := MigrateStatus{}

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

	return &status, nil
}
