Documentation ¶
Index ¶
- Variables
- type Exclusion
- type Model
- func (c *Model) Dump(filepath string)
- func (c *Model) ExpandPermission(objectType, permission string) []string
- func (c *Model) ExpandRelation(objectType, relation string) []string
- func (c *Model) GetObjectType(objectType string) (*dsc2.ObjectType, error)
- func (c *Model) GetObjectTypes() ([]*dsc2.ObjectType, error)
- func (c *Model) GetPermission(permission string) (*dsc2.Permission, error)
- func (c *Model) GetPermissions() ([]*dsc2.Permission, error)
- func (c *Model) GetRelationType(objectType, relation string) (*dsc2.RelationType, error)
- func (c *Model) GetRelationTypes(objectType string) ([]*dsc2.RelationType, error)
- func (c *Model) ObjectTypeExists(ot string) bool
- func (c *Model) PermissionExists(ot, p string) bool
- func (c *Model) RelationTypeExists(ot, rt string) bool
- func (c *Model) SetObjectTypes(objectTypes map[string]*ObjectType)
- func (c *Model) SetPermissions(permissions map[string]struct{})
- type ObjectType
- type RelationType
Constants ¶
This section is empty.
Variables ¶
var ( ErrModelNodeNotFound = cerr.NewAsertoError("E10000", codes.NotFound, http.StatusNotFound, "manifest does not contain a model node") ErrSchemaVersionNotFound = cerr.NewAsertoError("E10001", codes.NotFound, http.StatusNotFound, "manifest does not contain a model.version field") ErrInvalidSchemaVersion = cerr.NewAsertoError("E10002", codes.InvalidArgument, http.StatusBadRequest, "invalid or unsupported schema version") )
Functions ¶
This section is empty.
Types ¶
type Model ¶
type Model struct { ObjectTypes map[string]*ObjectType `json:"object_types"` Permissions map[string]struct{} `json:"permissions"` // contains filtered or unexported fields }
func (*Model) Dump ¶
Dump serializes the model cache to a JSON file, used for validation and testing.
func (*Model) ExpandPermission ¶
ExpandPermission returns list of relations which cover the given permission for the given object type.
func (*Model) ExpandRelation ¶
ExpandRelation, returns list of relations which are a union of the given relation. For example, when a writer relation inherits reader, the expansion of a reader = reader + writer.
func (*Model) GetObjectType ¶
func (c *Model) GetObjectType(objectType string) (*dsc2.ObjectType, error)
GetObjectType, v2 backwards-compatibility accessor function, returns v2 ObjectType by name.
func (*Model) GetObjectTypes ¶
func (c *Model) GetObjectTypes() ([]*dsc2.ObjectType, error)
GetObjectTypes, v2 backwards-compatibility accessor function, returns list of v2.ObjectType instances.
func (*Model) GetPermission ¶
func (c *Model) GetPermission(permission string) (*dsc2.Permission, error)
GetPermission, v2 backwards-compatibility accessor function, returns v2 Permission by permission name.
func (*Model) GetPermissions ¶
func (c *Model) GetPermissions() ([]*dsc2.Permission, error)
GetPermissions, v2 backwards-compatibility accessor function, returns list of v2 Permission instances.
func (*Model) GetRelationType ¶
func (c *Model) GetRelationType(objectType, relation string) (*dsc2.RelationType, error)
GetRelationType, v2 backwards-compatibility accessor function, returns v2 RelationType by object type and relation name.
func (*Model) GetRelationTypes ¶
func (c *Model) GetRelationTypes(objectType string) ([]*dsc2.RelationType, error)
GetRelationTypes, v2 backwards-compatibility accessor function, returns list of v2 RelationType instances, optionally filtered by by object type.
func (*Model) ObjectTypeExists ¶
ObjectTypeExists, checks if given object type name exists in the model cache.
func (*Model) PermissionExists ¶
PermissionExists, checks if given permission, for the given object type, exists in the model cache.
func (*Model) RelationTypeExists ¶
RelationTypeExists, checks if given relation type, for the given object type, exists in the model cache.
func (*Model) SetObjectTypes ¶
func (c *Model) SetObjectTypes(objectTypes map[string]*ObjectType)
func (*Model) SetPermissions ¶
type ObjectType ¶
type ObjectType struct { RelationTypes map[string]*RelationType `json:"relation_types,omitempty"` Permissions map[string]*RelationType `json:"permissions,omitempty"` }