registry

package
v0.0.0-...-6fb8895 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidMacAddress   = errors.New("invalid mac address")
	ErrGeneratingNodeToken = errors.New("error generating new node token")
)
View Source
var (
	ErrInvalidEmail  = errors.New("invalid email format")
	ErrShortPassword = errors.New("password length is short")
)
View Source
var ErrGeneratingID = errors.New("generating id failed")

ErrGeneratingID indicates error in generating UUID

Functions

This section is empty.

Types

type Hasher

type Hasher interface {
	// Hash generates the hashed string from plain-text.
	Hash(string) (string, error)

	// Compare compares plain-text version to the hashed one. An error should
	// indicate failed comparison.
	Compare(string, string) error
}

Hasher specifies an API for generating hashes of an arbitrary textual content.

type Node

type Node struct {
	ID           string `json:"id"`
	Addr         string `json:"addr"`
	Name         string `json:"name"`
	Type         int    `json:"type"`
	Status       int    `json:"status"`
	Latitude     string `json:"lat"`
	Longitude    string `json:"long"`
	Token        string `json:"token"`
	CreatedAt    int64  `json:"created_at"`
	MasterNodeID string `json:"master_node_id"`
	ChildNodes   []Node `json:"child_nodes"`
}

Node represent the edge node deployed in the igrid network

func NewNode

func NewNode(addr, name, lat, long string, nodeType int) (Node, error)

type NodeStatus

type NodeStatus int
const (
	Revoked NodeStatus = iota + 1
	AllowedOffline
	AllowedOnline
)

func (NodeStatus) String

func (ns NodeStatus) String() string

type RegionOfOp

type RegionOfOp struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	Desc string `json:"desc"`
}

type Repository

type Repository interface {
	AddUser(ctx context.Context, user User) error

	ListUsers(ctx context.Context) ([]User, error)

	DeleteUser(ctx context.Context, email string) error

	GetUser(ctx context.Context, email string) (User, error)

	EditUser(ctx context.Context, email string, user User) (User, error)

	ListUsersByGroup(ctx context.Context, group UserGroup) ([]User, error)

	ListUsersByRegion(ctx context.Context, region string) ([]User, error)

	AddNode(ctx context.Context, user Node) error

	ListNodes(ctx context.Context) ([]Node, error)

	DeleteNode(ctx context.Context, email string) error

	GetNode(ctx context.Context, email string) (Node, error)

	EditNode(ctx context.Context, email string, user Node) (Node, error)

	ListNodesByType(ctx context.Context, nodeType int) ([]Node, error)

	ListNodesByRegion(ctx context.Context, region string) ([]Node, error)

	RemoveRegion(ctx context.Context, region string) error

	AddRegion(ctx context.Context, region RegionOfOp) error

	ListRegions(ctx context.Context) ([]RegionOfOp, error)

	EditRegion(ctx context.Context, id string, op RegionOfOp) (RegionOfOp, error)
}

type Service

type Service interface {
	Version(ctx context.Context) (string, error)

	AddUser(ctx context.Context, user User) error

	ListUsers(ctx context.Context) ([]User, error)

	DeleteUser(ctx context.Context, email string) error

	GetUser(ctx context.Context, email string) (User, error)

	EditUser(ctx context.Context, email string, user User) (User, error)

	ListUsersByGroup(ctx context.Context, group UserGroup) ([]User, error)

	ListUsersByRegion(ctx context.Context, region string) ([]User, error)

	AddNode(ctx context.Context, user Node) error

	ListNodes(ctx context.Context) ([]Node, error)

	DeleteNode(ctx context.Context, email string) error

	GetNode(ctx context.Context, email string) (Node, error)

	EditNode(ctx context.Context, email string, user Node) (Node, error)

	ListNodesByType(ctx context.Context, nodeType int) ([]Node, error)

	ListNodesByRegion(ctx context.Context, region string) ([]Node, error)

	RemoveRegion(ctx context.Context, region string) error

	AddRegion(ctx context.Context, region RegionOfOp) error

	ListRegions(ctx context.Context) ([]RegionOfOp, error)

	EditRegion(ctx context.Context, id string, op RegionOfOp) (RegionOfOp, error)
}

Service describes the service.

func NewService

func NewService(repository Repository, hasher Hasher, provider UUIDProvider, logger logger.Logger) Service

type Type

type Type int
const (
	Sensor Type = iota + 1
	Actuator
	Controller
)

func (Type) String

func (t Type) String() string

type UUIDProvider

type UUIDProvider interface {
	// ID generates the unique identifier.
	ID() (string, error)
}

UUIDProvider specifies an API for generating unique identifiers.

func UuidProvider

func UuidProvider() UUIDProvider

UuidProvider instantiates a UUID provider.

type User

type User struct {
	ID         string `json:"id,omitempty"`                  //id or user token | uuid
	Name       string `json:"name"`                          //fullname
	Email      string `json:"email"`                         //email
	Group      int    `json:"group"`                         //user group
	Password   string `json:"password,omitempty"`            //password of user
	RegionOfOp string `json:"region_of_operation,omitempty"` //operating region in case of multi cloud
	Created    string `json:"created,omitempty"`             //when was this user added
}

func CreateUser

func CreateUser(name, email, password string) (User, error)

func (User) Validate

func (u User) Validate() error

Validate returns an error if user representation is invalid.

type UserGroup

type UserGroup int
const (
	Admin UserGroup = iota + 1 //owner of the network
	RegionAdmin
	RegionUser
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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