model

package
v0.0.17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2023 License: Apache-2.0 Imports: 10 Imported by: 5

Documentation

Index

Constants

View Source
const ModelVersion int = 1

Variables

View Source
var ErrInvalidIdentifier = errors.New("invalid identifier")

Functions

func IsValidIdentifier added in v0.0.5

func IsValidIdentifier(in string) bool

func NormalizeIdentifier added in v0.0.5

func NormalizeIdentifier(in string) (string, error)

Types

type ArrowPermission

type ArrowPermission struct {
	Relation   string `json:"relation,omitempty"`
	Permission string `json:"permission,omitempty"`
}

type ExclusionPermission

type ExclusionPermission struct {
	Base     string `json:"base,omitempty"`
	Subtract string `json:"subtract,omitempty"`
}

type Identifier added in v0.0.5

type Identifier string

Identifier is the string representation of an object, relation and permission type name.

Identifiers are bounded by the underlying defined regex definition (reIdentifier).

An identifier MUST be: - all lowercase characters - have a minimum length of 3 characters - have a maximum length of 64 characters - start with a character (a-z) - end with a character of a digit (a-z0-9) - can contain dots, underscores and dashes, between the first and last position.

func (Identifier) Valid added in v0.0.5

func (i Identifier) Valid() bool

type Metadata added in v0.0.4

type Metadata struct {
	UpdatedAt time.Time `json:"updated_at"`
	ETag      string    `json:"etag"`
}

type Model

type Model struct {
	Version  int                    `json:"version"`
	Objects  map[ObjectName]*Object `json:"types"`
	Metadata *Metadata              `json:"metadata"`
}

func New added in v0.0.3

func New(r io.Reader) (*Model, error)

func (*Model) Diff added in v0.0.5

func (m *Model) Diff(newModel *Model) *diff.Diff

func (*Model) GetGraph added in v0.0.8

func (m *Model) GetGraph() *graph.Graph

func (*Model) Reader added in v0.0.3

func (m *Model) Reader() (io.Reader, error)

func (*Model) Write added in v0.0.4

func (m *Model) Write(w io.Writer) error

type Object

type Object struct {
	Relations   map[RelationName][]*Relation   `json:"relations,omitempty"`
	Permissions map[PermissionName]*Permission `json:"permissions,omitempty"`
}

type ObjectName

type ObjectName Identifier

func (ObjectName) String added in v0.0.14

func (on ObjectName) String() string

type ObjectRelation added in v0.0.14

type ObjectRelation struct {
	Object   ObjectName   `json:"object"`
	Relation RelationName `json:"relation,omitempty"`
}

func (ObjectRelation) String added in v0.0.14

func (or ObjectRelation) String() string

type Permission

type Permission struct {
	Union        []string             `json:"union,omitempty"`
	Intersection []string             `json:"intersection,omitempty"`
	Exclusion    *ExclusionPermission `json:"exclusion,omitempty"`
	Arrow        *ArrowPermission     `json:"arrow,omitempty"`
}

type PermissionName

type PermissionName Identifier

func (PermissionName) RN added in v0.0.14

func (pn PermissionName) RN() RelationName

func (PermissionName) String added in v0.0.14

func (pn PermissionName) String() string

type Relation

type Relation struct {
	Direct   ObjectName       `json:"direct,omitempty"`
	Subject  *SubjectRelation `json:"subject,omitempty"`
	Wildcard ObjectName       `json:"wildcard,omitempty"`
}

type RelationName

type RelationName Identifier

func (RelationName) String added in v0.0.14

func (rn RelationName) String() string

type SubjectRelation

type SubjectRelation struct {
	Object   ObjectName   `json:"object,omitempty"`
	Relation RelationName `json:"relation,omitempty"`
}

Directories

Path Synopsis
Package diff is a generated GoMock package.
Package diff is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL