models

package
v0.0.0-...-6312dd6 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2022 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ActionCompleted = "completed"
	ActionPending   = "pending"
	ActionCreated   = "created"
	ActionError     = "error"
	ActionDeleted   = "deleted"
	ActionPair      = "pair"
	ActionUnpair    = "unpair"
)
View Source
const RoleUserToken = "user_token"

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	Id            string         `json:"-"`
	ThingId       string         `json:"-"`
	Name          string         `json:"name,omitempty"`
	Input         map[string]any `json:"input,omitempty"`
	Href          string         `json:"href,omitempty"`
	TimeRequested *time.Time     `json:"timeRequested,omitempty"`
	TimeCompleted *time.Time     `json:"timeCompleted,omitempty"`
	Status        string         `json:"status,omitempty"`
	Error         error          `json:"error,omitempty"`
}

func NewActionModel

func NewActionModel(name string, input map[string]any, things ...*container.Thing) *Action

func (*Action) GetDescription

func (action *Action) GetDescription() ActionDescription

func (*Action) GetId

func (action *Action) GetId() string

func (*Action) GetInput

func (action *Action) GetInput() map[string]any

func (*Action) GetName

func (action *Action) GetName() string

func (*Action) GetStatus

func (action *Action) GetStatus() string

func (*Action) GetThingId

func (action *Action) GetThingId() string

func (*Action) SetErr

func (action *Action) SetErr(err error)

type ActionDescription

type ActionDescription struct {
	Input         map[string]any `json:"input,omitempty"`
	Href          string         `json:"href,omitempty"`
	TimeRequested *time.Time     `json:"timeRequested,omitempty"`
	TimeCompleted *time.Time     `json:"timeCompleted,omitempty"`
	Error         error          `json:"error,omitempty"`
}

type ActionsManager

type ActionsManager interface {
	AddNewThings(timeOut int) error
	CancelAddNewThing()
	RequestAction(ctx context.Context, thingId, actionName string, input map[string]any) error
	RemoveThing(id string) error
	RemoveAction(thingId string, actionId string, actionName string) error
	CancelRemoveThing(id string)
}

type ActionsModel

type ActionsModel struct {
	// contains filtered or unexported fields
}

func NewActionsModel

func NewActionsModel(m ActionsManager, container *container.ThingsContainer) *ActionsModel

func (*ActionsModel) Add

func (m *ActionsModel) Add(a *Action) error

func (*ActionsModel) Remove

func (m *ActionsModel) Remove(id string) error

type AddonInfo

type AddonInfo struct {
	Urls           []string `json:"urls"`
	Architecture   string   `json:"architecture"`
	Version        string   `json:"version"`
	NodeVersion    string   `json:"nodeVersion"`
	PythonVersions []string `json:"pythonVersions"`
}

type AddonStore

type AddonStore interface {
	LoadAddonSetting(id string) (value string, err error)
	StoreAddonSetting(id, value string) error
	LoadAddonConfig(id string) (value string, err error)
	StoreAddonsConfig(id string, value any) error
}

type AddonsModel

type AddonsModel struct {
	Store AddonStore
}

func NewAddonsModel

func NewAddonsModel(store AddonStore) *AddonsModel

type Claims

type Claims struct {
	UserId int64  `json:"userId"`
	KeyId  string `json:"KeyId"`
	Payload
	jwt.StandardClaims
}

type Jsonwebtoken

type Jsonwebtoken struct {
	Store JsonwebtokenStore
	// contains filtered or unexported fields
}

func NewJsonwebtokenModel

func NewJsonwebtokenModel(settingsModel *Settings, store JsonwebtokenStore) *Jsonwebtoken

func (*Jsonwebtoken) IssueToken

func (j *Jsonwebtoken) IssueToken(userId int64) (string, error)

type JsonwebtokenStore

type JsonwebtokenStore interface {
	CreateJSONWebToken(data *db.TokeDataStorage) error
	GetJSONWebTokenByKeyId(keyId string) (*db.TokeDataStorage, error)
}

type Payload

type Payload struct {
	Role     string `json:"role"`
	Scope    string `json:"scope"`
	ClientId string `json:"clientId"`
}

type Settings

type Settings struct {
	// contains filtered or unexported fields
}

func NewSettingsModel

func NewSettingsModel(addonUrl []string, storage SettingsStore) *Settings

func (*Settings) GetAddonInfo

func (s *Settings) GetAddonInfo() AddonInfo

func (*Settings) GetTemperatureUnits

func (s *Settings) GetTemperatureUnits() (string, error)

func (*Settings) GetTunnelInfo

func (s *Settings) GetTunnelInfo() string

type SettingsStore

type SettingsStore interface {
	GetSetting(key string) (string, error)
	SetSetting(key, value string) error
}

type TokenData

type TokenData struct {
	User      int64     `json:"user"`
	IssuedAt  time.Time `json:"issuedAt"`
	PublicKey []byte    `json:"publicKey"`
	KeyId     string    `json:"keyId"`
	Payload
	// contains filtered or unexported fields
}

func NewTokenData

func NewTokenData() *TokenData

type User

type User struct {
	ID              int64
	Name            string
	Email           string
	Hash            string
	MfaSharedSecret string
	MfaEnrolled     bool
	MfaBackupCodes  string
}

func (*User) ComparePassword

func (u *User) ComparePassword(password string) bool

ComparePassword check the password

type Users

type Users struct {
	// contains filtered or unexported fields
}

func NewUsersModel

func NewUsersModel(store UsersStore) *Users

func (*Users) CreateUser

func (u *Users) CreateUser(email, password, name string) (int64, error)

func (*Users) GetUser

func (u *Users) GetUser(email string) *User

func (*Users) GetUsersCount

func (u *Users) GetUsersCount() int

type UsersStore

type UsersStore interface {
	CreateUser(user *db.User) (int64, error)
	DeleteUser(id int64) error
	GetUsers() []*db.User
	UpdateUser(user *db.User) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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