node

package
v0.0.0-...-c6a7f1f Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2022 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

View Source
const (
	KindAsset  = "asset"
	KindDevice = "device"
)

KindAsset and KindDevice are constants for creating Object Heirarchy

Variables

This section is empty.

Functions

func Validation

func Validation(ctx context.Context, log *zap.Logger) (md metadata.MD, acc string, err error)

Validation method does the pre-checks for a REST request

Types

type AccountController

type AccountController struct {
	nodepb.UnimplementedAccountServiceServer

	Dgraph *dgo.Dgraph
	Log    *zap.Logger

	Grafana *grafana.Client
	Repo    Repo
}

AccountController is a Data type for Account Controller file

func (*AccountController) AssignOwner

func (s *AccountController) AssignOwner(ctx context.Context, request *nodepb.OwnershipRequest) (response *nodepb.OwnershipResponse, err error)

AssignOwner is a method that assigns an Admin to an account

func (*AccountController) Authenticate

func (s *AccountController) Authenticate(ctx context.Context, request *nodepb.AuthenticateRequest) (response *nodepb.AuthenticateResponse, err error)

Authenticate is a method that validates user credentials

func (*AccountController) Authorize

func (s *AccountController) Authorize(ctx context.Context, request *nodepb.AuthorizeRequest) (response *nodepb.AuthorizeResponse, err error)

Authorize is a method that provides the user access to a particulare node in Dgraph

func (*AccountController) AuthorizeNamespace

func (s *AccountController) AuthorizeNamespace(ctx context.Context, request *nodepb.AuthorizeNamespaceRequest) (response *nodepb.AuthorizeNamespaceResponse, err error)

AuthorizeNamespace is a method that provides the user access to namespace

func (*AccountController) CreateUserAccount

func (s *AccountController) CreateUserAccount(ctx context.Context, request *nodepb.CreateUserAccountRequest) (response *nodepb.CreateUserAccountResponse, err error)

CreateUserAccount is a method for creating user account

func (*AccountController) DeleteAccount

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

DeleteAccount is a method that deletes an account

func (*AccountController) GetAccount

func (s *AccountController) GetAccount(ctx context.Context, request *nodepb.GetAccountRequest) (response *nodepb.Account, err error)

GetAccount is a method that reutrns details of the an account

func (*AccountController) IsAdmin

func (s *AccountController) IsAdmin(ctx context.Context, request *nodepb.IsAdminRequest) (response *nodepb.IsAdminResponse, err error)

IsAdmin is a method that returns if the account has root priviledges or not

func (*AccountController) IsAuthorized

func (s *AccountController) IsAuthorized(ctx context.Context, request *nodepb.IsAuthorizedRequest) (response *nodepb.IsAuthorizedResponse, err error)

IsAuthorized is a method that reutrns if the user has access to a node

func (*AccountController) IsAuthorizedNamespace

func (s *AccountController) IsAuthorizedNamespace(ctx context.Context, request *nodepb.IsAuthorizedNamespaceRequest) (response *nodepb.IsAuthorizedNamespaceResponse, err error)

IsAuthorizedNamespace is a method that returns true if the user has access to namespace

func (*AccountController) IsOwnedbyAdmin

func (s *AccountController) IsOwnedbyAdmin(ctx context.Context, log *zap.Logger, requestorID string, accountID string) (isowned bool, err error)

IsOwnedbyAdmin is a method to validation if the account is owned by admin or not

func (*AccountController) IsRoot

func (s *AccountController) IsRoot(ctx context.Context, request *nodepb.IsRootRequest) (response *nodepb.IsRootResponse, err error)

IsRoot is a method that returns if the account has root priviledges or not

func (*AccountController) ListAccounts

func (s *AccountController) ListAccounts(ctx context.Context, request *nodepb.ListAccountsRequest) (response *nodepb.ListAccountsResponse, err error)

ListAccounts is a method that list details of the all account

func (*AccountController) RemoveOwner

func (s *AccountController) RemoveOwner(ctx context.Context, request *nodepb.OwnershipRequest) (response *nodepb.OwnershipResponse, err error)

RemoveOwner is a method that assigns an Admin to an account

func (*AccountController) SetPassword

func (s *AccountController) SetPassword(ctx context.Context, request *nodepb.SetPasswordRequest) (response *nodepb.SetPasswordResponse, err error)

SetPassword is a method that allows to change password for the account

func (*AccountController) UpdateAccount

func (s *AccountController) UpdateAccount(ctx context.Context, request *nodepb.UpdateAccountRequest) (response *nodepb.UpdateAccountResponse, err error)

UpdateAccount is a method that update details of the an account

type NamespaceController

type NamespaceController struct {
	nodepb.UnimplementedNamespacesServer

	Repo Repo
	Log  *zap.Logger
}

NamespaceController is a Data type for Namespace Controller file

func (*NamespaceController) CreateNamespace

func (n *NamespaceController) CreateNamespace(ctx context.Context, request *nodepb.CreateNamespaceRequest) (response *nodepb.Namespace, err error)

CreateNamespace is a method for creating Namespace

func (*NamespaceController) DeleteNamespace

func (n *NamespaceController) DeleteNamespace(ctx context.Context, request *nodepb.DeleteNamespaceRequest) (response *nodepb.DeleteNamespaceResponse, err error)

DeleteNamespace is a method to delete a Namespace

func (*NamespaceController) DeletePermission

func (n *NamespaceController) DeletePermission(ctx context.Context, request *nodepb.DeletePermissionRequest) (response *nodepb.DeletePermissionResponse, err error)

DeletePermission is a method to delete access to a Namespace for a account

func (*NamespaceController) GetNamespace

func (n *NamespaceController) GetNamespace(ctx context.Context, request *nodepb.GetNamespaceRequest) (response *nodepb.Namespace, err error)

GetNamespace is a method to get details of a Namespace using Namespace name

func (*NamespaceController) GetNamespaceID

func (n *NamespaceController) GetNamespaceID(ctx context.Context, request *nodepb.GetNamespaceRequest) (response *nodepb.Namespace, err error)

GetNamespaceID is a method to get details of a Namespace using Namespace ID

func (*NamespaceController) ListNamespaces

func (n *NamespaceController) ListNamespaces(ctx context.Context, request *nodepb.ListNamespacesRequest) (response *nodepb.ListNamespacesResponse, err error)

ListNamespaces is a method for Listing all the Namespaces

func (*NamespaceController) ListPermissions

func (n *NamespaceController) ListPermissions(ctx context.Context, request *nodepb.ListPermissionsRequest) (response *nodepb.ListPermissionsResponse, err error)

ListPermissions is a method to list all the accounts that have access to a Namespace

func (*NamespaceController) UpdateNamespace

func (n *NamespaceController) UpdateNamespace(ctx context.Context, request *nodepb.UpdateNamespaceRequest) (response *nodepb.UpdateNamespaceResponse, err error)

UpdateNamespace is a method to delete access to a Namespace for a account

type ObjectController

type ObjectController struct {
	nodepb.UnimplementedObjectServiceServer

	Dgraph *dgo.Dgraph
	Log    *zap.Logger

	Repo Repo
}

ObjectController is a Data type for Object Controller file

func (*ObjectController) CreateObject

func (s *ObjectController) CreateObject(ctx context.Context, request *nodepb.CreateObjectRequest) (response *nodepb.Object, err error)

CreateObject is a method for creating objects in heirarchy

func (*ObjectController) DeleteObject

func (s *ObjectController) DeleteObject(ctx context.Context, request *nodepb.DeleteObjectRequest) (response *nodepb.DeleteObjectResponse, err error)

DeleteObject is a method for deleting objects in heirarchy

func (*ObjectController) ListObjects

func (s *ObjectController) ListObjects(ctx context.Context, request *nodepb.ListObjectsRequest) (response *nodepb.ListObjectsResponse, err error)

ListObjects is a method for listing objects in heirarchy

type Repo

type Repo interface {
	//Accounts
	CreateUserAccount(ctx context.Context, username, password string, isRoot, isAdmin, enabled bool) (uid string, err error)
	ListAccounts(ctx context.Context) (accounts []*nodepb.Account, err error)
	ListAccountsforAdmin(ctx context.Context, requestorID string) (accounts []*nodepb.Account, err error)
	UpdateAccount(ctx context.Context, account *nodepb.UpdateAccountRequest, isself bool) (err error)
	GetAccount(ctx context.Context, accountID string) (account *nodepb.Account, err error)
	SetPassword(ctx context.Context, account, password string) error
	DeleteAccount(ctx context.Context, account *nodepb.DeleteAccountRequest) (err error)
	AssignOwner(ctx context.Context, ownerID, accountID string) (err error)
	RemoveOwner(ctx context.Context, ownerID, accountID string) (err error)
	UserExists(ctx context.Context, account string) (exists bool, err error)

	//Authorizations
	IsAuthorized(ctx context.Context, target, who, action string) (decision bool, err error)
	IsAuthorizedNamespace(ctx context.Context, namespaceid, account string, action nodepb.Action) (decision bool, err error)
	Authorize(ctx context.Context, account, node, action string, inherit bool) (err error)
	AuthorizeNamespace(ctx context.Context, account, namespaceID string, action nodepb.Action) (err error)
	Authenticate(ctx context.Context, username, password string) (success bool, uid string, defaultNamespace string, err error)

	//Objects
	CreateObject(ctx context.Context, name, parentID, kind, namespaceID string) (id string, err error)
	DeleteObject(ctx context.Context, uid string) (err error)
	ListForAccount(ctx context.Context, account string, namespaceID string, recurse bool) (inheritedObjects []*nodepb.Object, err error)

	//Namespaces
	CreateNamespace(ctx context.Context, name string) (id string, err error)
	GetNamespace(ctx context.Context, uid string) (namespace *nodepb.Namespace, err error)
	GetNamespaceID(ctx context.Context, uid string) (namespace *nodepb.Namespace, err error)
	ListNamespaces(ctx context.Context) (namespaces []*nodepb.Namespace, err error)
	ListNamespacesForAccount(ctx context.Context, accountID string) (namespaces []*nodepb.Namespace, err error)
	ListPermissionsInNamespace(ctx context.Context, namespaceID string) (permissions []*nodepb.Permission, err error)
	DeletePermissionInNamespace(ctx context.Context, namespaceID, accountID string) (err error)
	SoftDeleteNamespace(ctx context.Context, namespaceID string) (err error)
	HardDeleteNamespace(ctx context.Context, datecondition string, retentionperiod string) (err error)
	UpdateNamespace(ctx context.Context, namespace *nodepb.UpdateNamespaceRequest) (err error)
	GetRetentionPeriods(ctx context.Context) (retentionperiod []int, err error)
}

Repo Interface to expose methods

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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