package backup

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

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

// ListBackupPathsRequest struct for getting list of backup paths
type ListBackupPathsRequest struct {
	// Grid ID
	GID uint64 `url:"gridId" json:"gridId" validate:"required"`
}

// ListBackupPaths gets list of backup paths
func (b Backup) ListBackupPaths(ctx context.Context, req ListBackupPathsRequest) ([]string, error) {

	err := validators.ValidateRequest(req)
	if err != nil {
		return nil, validators.ValidationErrors(validators.GetErrors(err))
	}

	url := "/cloudbroker/backup/listBackupPaths"

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

	list := make([]string, 0)

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

	return list, nil
}
