package service

import (
	"context"
	"github.com/example/storage-appliance/internal/domain"
)

type DiskService interface {
	List(ctx context.Context) ([]domain.Disk, error)
	Inspect(ctx context.Context, path string) (domain.Disk, error)
}

type ZFSService interface {
	ListPools(ctx context.Context) ([]domain.Pool, error)
	// CreatePool is a higher level operation handled by StorageService with jobs
	// CreatePool(ctx context.Context, name string, vdevs []string) (string, error)
	GetPoolStatus(ctx context.Context, pool string) (domain.PoolHealth, error)
	ListDatasets(ctx context.Context, pool string) ([]domain.Dataset, error)
	CreateDataset(ctx context.Context, name string, props map[string]string) error
	Snapshot(ctx context.Context, dataset, snapName string) error
	ScrubStart(ctx context.Context, pool string) error
	ScrubStatus(ctx context.Context, pool string) (string, error)
}

type JobRunner interface {
	Enqueue(ctx context.Context, j domain.Job) (string, error)
}

type SharesService interface {
	ListNFS(ctx context.Context) ([]domain.Share, error)
	CreateNFS(ctx context.Context, user, role, name, path string, opts map[string]string) (string, error)
	DeleteNFS(ctx context.Context, user, role, id string) error
	NFSStatus(ctx context.Context) (string, error)
	ListSMB(ctx context.Context) ([]domain.Share, error)
	CreateSMB(ctx context.Context, user, role, name, path string, readOnly bool, allowedUsers []string) (string, error)
	DeleteSMB(ctx context.Context, user, role, id string) error
}

type ObjectService interface {
	SetSettings(ctx context.Context, user, role string, s map[string]any) error
	GetSettings(ctx context.Context) (map[string]any, error)
	ListBuckets(ctx context.Context) ([]string, error)
	CreateBucket(ctx context.Context, user, role, name string) (string, error)
}

type ISCSIService interface {
	ListTargets(ctx context.Context) ([]map[string]any, error)
	CreateTarget(ctx context.Context, user, role, name, iqn string) (string, error)
	CreateLUN(ctx context.Context, user, role, targetID, lunName string, size string, blocksize int) (string, error)
	DeleteLUN(ctx context.Context, user, role, id string, force bool) error
	UnmapLUN(ctx context.Context, user, role, id string) error
	AddPortal(ctx context.Context, user, role, targetID, address string, port int) (string, error)
	AddInitiator(ctx context.Context, user, role, targetID, initiatorIQN string) (string, error)
	ListLUNs(ctx context.Context, targetID string) ([]map[string]any, error)
	GetTargetInfo(ctx context.Context, targetID string) (map[string]any, error)
}
