blob: 85dc7b41895a3fe86ac7e82e99de3a4a8d41817a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
package datastore
import (
"context"
core "github.com/authzed/spicedb/pkg/proto/core/v1"
)
// RevisionedCaveat is a revisioned version of a caveat definition.
type RevisionedCaveat = RevisionedDefinition[*core.CaveatDefinition]
// CaveatReader offers read operations for caveats
type CaveatReader interface {
// ReadCaveatByName returns a caveat with the provided name.
// It returns an instance of CaveatNotFoundError if not found.
ReadCaveatByName(ctx context.Context, name string) (caveat *core.CaveatDefinition, lastWritten Revision, err error)
// ListAllCaveats returns all caveats stored in the system.
ListAllCaveats(ctx context.Context) ([]RevisionedCaveat, error)
// LookupCaveatsWithNames finds all caveats with the matching names.
LookupCaveatsWithNames(ctx context.Context, names []string) ([]RevisionedCaveat, error)
}
// CaveatStorer offers both read and write operations for Caveats
type CaveatStorer interface {
CaveatReader
// WriteCaveats stores the provided caveats, and returns the assigned IDs
// Each element of the returning slice corresponds by position to the input slice
WriteCaveats(context.Context, []*core.CaveatDefinition) error
// DeleteCaveats deletes the provided caveats by name
DeleteCaveats(ctx context.Context, names []string) error
}
|