dgraph

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckExists

func CheckExists(ctx context.Context, txn *dgo.Txn, uid string) bool

func FingerprintExists added in v0.1.5

func FingerprintExists(ctx context.Context, txn *dgo.Txn, fingerprint []byte) bool

FingerprintExists is a method to execute Dgraph Query to check if the finger print is present in the DB

func ImportSchema

func ImportSchema(dg *dgo.Dgraph, drop bool) error

ImportSchema is a method to import the schema in Dgraph DB for tests

func ImportStandardSet

func ImportStandardSet(repo node.Repo) (userID string, adminID string, err error)

ImportStandardSet is a method to impor the test data for tests

func NameExists

func NameExists(ctx context.Context, txn *dgo.Txn, name, namespace, parent string) bool

func NewDGraphRepo

func NewDGraphRepo(dg *dgo.Dgraph) node.Repo

NewDGraphRepo is a method to connect to Dgraph Database

Types

type Account

type Account struct {
	Node
	Name string `json:"name,omitempty"`

	IsRoot  bool `json:"isRoot"`
	IsAdmin bool `json:"isAdmin"`
	Enabled bool `json:"enabled"`

	AccessTo          []*Object    `json:"access.to,omitempty"`
	AccessToNamespace []*Namespace `json:"access.to.namespace,omitempty"`

	DefaultNamespace []*Namespace `json:"default.namespace"`

	HasCredentials []*UsernameCredential `json:"has.credentials,omitempty"`

	Owns    []*Account `json:"owns,omitempty"`
	OwnedBy []*Account `json:"~owns,omitempty"`
}

Account Data structure for Dgraph database

type DGraphRepo

type DGraphRepo struct {
	Dg *dgo.Dgraph
}

DGraphRepo is a Data type for executing Dgraph Query

func (*DGraphRepo) AssignOwner added in v0.1.5

func (s *DGraphRepo) AssignOwner(ctx context.Context, ownerID, acccountID string) (err error)

AssignOwner is a method to delete the Account

func (*DGraphRepo) Authenticate

func (s *DGraphRepo) Authenticate(ctx context.Context, username, password string) (success bool, uid string, defaultNamespace string, err error)

func (*DGraphRepo) Authorize

func (s *DGraphRepo) Authorize(ctx context.Context, account, node, action string, inherit bool) (err error)

func (*DGraphRepo) AuthorizeNamespace

func (s *DGraphRepo) AuthorizeNamespace(ctx context.Context, account, namespaceID string, action nodepb.Action) (err error)

func (*DGraphRepo) CreateNamespace

func (s *DGraphRepo) CreateNamespace(ctx context.Context, name string) (id string, err error)

CreateNamespace is a method to execute Dgraph Query to create Namespaces

func (*DGraphRepo) CreateObject

func (s *DGraphRepo) CreateObject(ctx context.Context, name, parentID, kind, namespaceID string) (id string, err error)

CreateObject is a method to execute Dgraph query to create objects

func (*DGraphRepo) CreateUserAccount

func (s *DGraphRepo) CreateUserAccount(ctx context.Context, username, password string, isRoot, isAdmin, enabled bool) (uid string, err error)

CreateUserAccount is a method to Create User Account

func (*DGraphRepo) DeleteAccount added in v0.1.5

func (s *DGraphRepo) DeleteAccount(ctx context.Context, request *nodepb.DeleteAccountRequest) (err error)

DeleteAccount is a method to delete the Account

func (*DGraphRepo) DeleteObject

func (s *DGraphRepo) DeleteObject(ctx context.Context, uid string) (err error)

DeleteObject is a method to execute Dgraph query to delete objects

func (*DGraphRepo) DeletePermissionInNamespace added in v0.1.4

func (s *DGraphRepo) DeletePermissionInNamespace(ctx context.Context, namespaceID, accountID string) (err error)

DeletePermissionInNamespace is a method to execute Dgraph Query to delete permissions for a Namespaces for an account

func (*DGraphRepo) GetAccount

func (s *DGraphRepo) GetAccount(ctx context.Context, name string) (account *nodepb.Account, err error)

GetAccount is a method to Get details of an Account

func (*DGraphRepo) GetNamespace

func (s *DGraphRepo) GetNamespace(ctx context.Context, namespacename string) (namespace *nodepb.Namespace, err error)

GetNamespace is a method to execute Dgraph Query to get the namespace based on Name

func (*DGraphRepo) GetNamespaceID added in v0.1.5

func (s *DGraphRepo) GetNamespaceID(ctx context.Context, namespaceID string) (namespace *nodepb.Namespace, err error)

GetNamespaceID is a method to execute Dgraph Query to get the namespace based on ID

func (*DGraphRepo) HardDeleteNamespace added in v0.1.5

func (s *DGraphRepo) HardDeleteNamespace(ctx context.Context, datecondition string) (err error)

HardDeleteNamespace is a method to execute Dgraph Query that deletes a namespace permantly

func (*DGraphRepo) IsAuthorized

func (s *DGraphRepo) IsAuthorized(ctx context.Context, node, accountid, action string) (decision bool, err error)

IsAuthorized is a method to check if the given account has the mentioned action for the node

func (*DGraphRepo) IsAuthorizedNamespace

func (s *DGraphRepo) IsAuthorizedNamespace(ctx context.Context, namespaceid, account string, action nodepb.Action) (decision bool, err error)

IsAuthorizedNamespace is a method to execute Dgraph Query that returns if the access to the namespace for an account is true or false

func (*DGraphRepo) ListAccounts

func (s *DGraphRepo) ListAccounts(ctx context.Context) (accounts []*nodepb.Account, err error)

ListAccounts is a method to List details of all Account

func (*DGraphRepo) ListAccountsforAdmin added in v0.1.5

func (s *DGraphRepo) ListAccountsforAdmin(ctx context.Context, requestorID string) (accounts []*nodepb.Account, err error)

ListAccountsforAdmin is a method to List accounts owned by an Admin user

func (*DGraphRepo) ListForAccount

func (s *DGraphRepo) ListForAccount(ctx context.Context, account string, namespaceid string, recurse bool) (inheritedObjects []*nodepb.Object, err error)

ListForAccount is a method to execute Dgraph query to list all the objects for an account

func (*DGraphRepo) ListNamespaces

func (s *DGraphRepo) ListNamespaces(ctx context.Context) (namespaces []*nodepb.Namespace, err error)

ListNamespaces is a method to execute Dgraph Query to List details of all Namespaces

func (*DGraphRepo) ListNamespacesForAccount

func (s *DGraphRepo) ListNamespacesForAccount(ctx context.Context, accountID string) (namespaces []*nodepb.Namespace, err error)

ListNamespacesForAccount is a method to execute Dgraph Query to list Namespaces for an Account

func (*DGraphRepo) ListPermissionsInNamespace added in v0.1.4

func (s *DGraphRepo) ListPermissionsInNamespace(ctx context.Context, namespaceid string) (permissions []*nodepb.Permission, err error)

ListPermissionsInNamespace is a method to execute Dgraph Query to list permissions for all accounts for a Namespace

func (*DGraphRepo) RemoveOwner added in v1.0.0

func (s *DGraphRepo) RemoveOwner(ctx context.Context, ownerID, acccountID string) (err error)

RemoveOwner is a method to delete the Account.

func (*DGraphRepo) RevokeNamespace added in v0.1.5

func (s *DGraphRepo) RevokeNamespace(ctx context.Context, namespaceID string) (err error)

RevokeNamespace is a method to execute Dgraph Query that nmarks the Namespace from deletion

func (*DGraphRepo) SetPassword added in v0.1.4

func (s *DGraphRepo) SetPassword(ctx context.Context, accountid, password string) error

SetPassword is a method to change the password of the user account

func (*DGraphRepo) SoftDeleteNamespace added in v0.1.5

func (s *DGraphRepo) SoftDeleteNamespace(ctx context.Context, namespaceID string) (err error)

SoftDeleteNamespace is a method to execute Dgraph Query that mark the namespace for deletion

func (*DGraphRepo) UpdateAccount

func (s *DGraphRepo) UpdateAccount(ctx context.Context, account *nodepb.UpdateAccountRequest, isself bool) (err error)

UpdateAccount is a method to Udpdate details of an Account

func (*DGraphRepo) UpdateNamespace added in v0.1.5

func (s *DGraphRepo) UpdateNamespace(ctx context.Context, namespace *nodepb.UpdateNamespaceRequest) (err error)

UpdateNamespace is a method to execute Dgraph Query to Udpdate details of an Namespace

func (*DGraphRepo) UserExists added in v0.1.5

func (s *DGraphRepo) UserExists(ctx context.Context, account string) (exists bool, err error)

UserExists is a method to check if the user is present in the Dgraph DB

type Namespace

type Namespace struct {
	Node
	Name                 string `json:"name,omitempty"`
	MarkForDeletion      bool   `json:"markfordeletion,omitempty"`
	DeleteInitiationTime string `json:"deleteinitiationtime,omitempty"`

	Owns []*Object `json:"owns,omitempty"`

	AccessedBy         []Account `json:"~access.to.namespace"`
	AccessToPermission string    `json:"access.to.namespace|permission,omitempty"`
}

Namespace Data structure for Dgraph database

type Node

type Node struct {
	Type string `json:"type,omitempty"`
	UID  string `json:"uid,omitempty"`
}

Node Data strcuture for Dgraph database

type Object

type Object struct {
	Node

	Name string `json:"name,omitempty"`
	Kind string `json:"kind,omitempty"`

	OwnedBy []*Namespace `json:"~owns,omitempty"`

	Children []*Object `json:"children"`
	Parent   []Node    `json:"~children"` // Namespace or Object

	AccessedBy         []Account `json:"~access.to"`
	AccessToPermission string    `json:"access.to|permission,omitempty"`
	AccessToInherit    bool      `json:"access.to|inherit"`
}

Object Data structure for Dgraph database

type UsernameCredential

type UsernameCredential struct {
	Node
	Username string     `json:"username"`
	Password string     `json:"password"`
	CheckPwd bool       `json:"checkpwd(password),omitempty"`
	Account  []*Account `json:"~has.credentials,omitempty"`
}

UsernameCredential Data structure for Dgraph database

Jump to

Keyboard shortcuts

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