draincloud-core/internal/storage/interface.go

40 lines
1.2 KiB
Go
Raw Permalink Normal View History

2024-09-27 22:37:58 +00:00
package storage
import (
"context"
2024-11-23 08:52:06 +00:00
"os"
2024-09-27 22:37:58 +00:00
2024-10-10 21:36:51 +00:00
"git.optclblast.xyz/draincloud/draincloud-core/internal/storage/models"
2024-11-23 08:52:06 +00:00
auditmodels "git.optclblast.xyz/draincloud/draincloud-core/internal/storage/models/audit"
2024-12-14 07:42:59 +00:00
"git.optclblast.xyz/draincloud/draincloud-core/internal/storage/models/files"
2024-12-15 16:56:03 +00:00
"github.com/google/uuid"
2024-09-27 22:37:58 +00:00
)
type Database interface {
AuthStorage
}
type AuthStorage interface {
2024-12-16 05:08:37 +00:00
AddUser(ctx context.Context, id uuid.UUID, login string, username string, passwordHash []byte) error
2024-09-27 22:37:58 +00:00
GetUserByLogin(ctx context.Context, login string) (*models.User, error)
2024-12-15 16:56:03 +00:00
GetUserByID(ctx context.Context, id uuid.UUID) (*models.User, error)
2024-11-23 08:52:06 +00:00
2024-12-15 16:56:03 +00:00
AddSession(ctx context.Context, ses *models.Session) (uuid.UUID, error)
2024-11-23 08:52:06 +00:00
GetSession(ctx context.Context, sessionToken string) (*models.Session, error)
2024-12-15 16:56:03 +00:00
RemoveSession(ctx context.Context, id uuid.UUID) error
2024-11-23 08:52:06 +00:00
}
type AuthAuditLogStorage interface {
AddEntry(ctx context.Context, entry auditmodels.AuditLogEntry) error
}
type MetaStorage interface {
2024-12-15 16:56:03 +00:00
SaveMetadata(ctx context.Context, meta files.FileMetadata) (uuid.UUID, error)
2024-11-23 08:52:06 +00:00
}
type BlobStorage interface {
2024-12-15 16:56:03 +00:00
GetFile(ctx context.Context, id uuid.UUID) (*os.File, error)
SaveBlob(ctx context.Context, id uuid.UUID, data []byte) error
DeleteFile(ctx context.Context, id uuid.UUID) error
2024-09-27 22:37:58 +00:00
}