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