forked from Permify/permify
/
interfaces.go
59 lines (51 loc) · 2.82 KB
/
interfaces.go
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package repositories
import (
"context"
"github.com/adminium/permify/pkg/database"
base "github.com/adminium/permify/pkg/pb/base/v1"
"github.com/adminium/permify/pkg/token"
)
// RelationshipReader -
type RelationshipReader interface {
// QueryRelationships reads relation tuples from the repository.
QueryRelationships(ctx context.Context, tenantID string, filter *base.TupleFilter, snap string) (iterator *database.TupleIterator, err error)
// ReadRelationships reads relation tuples from the repository with different options.
ReadRelationships(ctx context.Context, tenantID string, filter *base.TupleFilter, snap string, pagination database.Pagination) (collection *database.TupleCollection, ct database.EncodedContinuousToken, err error)
// GetUniqueEntityIDsByEntityType reads unique entity IDs from the repository.
GetUniqueEntityIDsByEntityType(ctx context.Context, tenantID string, typ, snap string) (ids []string, err error)
// HeadSnapshot reads the latest version of the snapshot from the repository.
HeadSnapshot(ctx context.Context, tenantID string) (token.SnapToken, error)
}
// RelationshipWriter -
type RelationshipWriter interface {
// WriteRelationships writes relation tuples to the repository.
WriteRelationships(ctx context.Context, tenantID string, collection *database.TupleCollection) (token token.EncodedSnapToken, err error)
// DeleteRelationships deletes relation tuples from the repository.
DeleteRelationships(ctx context.Context, tenantID string, filter *base.TupleFilter) (token token.EncodedSnapToken, err error)
}
// SchemaReader -
type SchemaReader interface {
// ReadSchema reads entity config from the repository.
ReadSchema(ctx context.Context, tenantID string, version string) (schema *base.SchemaDefinition, err error)
// ReadSchemaDefinition reads entity config from the repository.
ReadSchemaDefinition(ctx context.Context, tenantID string, entityType, version string) (definition *base.EntityDefinition, v string, err error)
// HeadVersion reads the latest version of the schema from the repository.
HeadVersion(ctx context.Context, tenantID string) (version string, err error)
}
// SchemaWriter -
type SchemaWriter interface {
// WriteSchema writes schema to the repository.
WriteSchema(ctx context.Context, definitions []SchemaDefinition) (err error)
}
// TenantReader -
type TenantReader interface {
// ListTenants reads tenants from the repository.
ListTenants(ctx context.Context, pagination database.Pagination) (tenants []*base.Tenant, ct database.EncodedContinuousToken, err error)
}
// TenantWriter -
type TenantWriter interface {
// CreateTenant writes tenant to the repository.
CreateTenant(ctx context.Context, id, name string) (tenant *base.Tenant, err error)
// DeleteTenant deletes tenant from the repository.
DeleteTenant(ctx context.Context, tenantID string) (tenant *base.Tenant, err error)
}