types

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ActionEnable  = "enable"
	ActionDisable = "disable"
	ActionReload  = "reload"
	ActionDelete  = "delete"
	ActionToggle  = "toggle"
)

common resource actions

View Source
const (
	StatusOk          = "ok"
	StatusUp          = "up"
	StatusDown        = "down"
	StatusError       = "error"
	StatusUnavailable = "unavailable"
)

State

View Source
const (
	EntityGateway          = "gateway"           // keeps gateway config details
	EntityNode             = "node"              // keeps node details
	EntitySource           = "source"            // keeps source details
	EntityField            = "field"             // keeps field details from source and fields from node, like battery, rssi, etc.,
	EntityFirmware         = "firmware"          // keeps firmware details
	EntityUser             = "user"              // keeps user details
	EntityDashboard        = "dashboard"         // keeps dashboard details
	EntityForwardPayload   = "forward_payload"   // keeps forward payload mapping details
	EntityHandler          = "handler"           // keeps configurations for handlers
	EntityTask             = "task"              // keeps configurations for tasks
	EntitySchedule         = "schedule"          // keeps configurations for schedules
	EntitySettings         = "settings"          // settings of the system
	EntityDataRepository   = "data_repository"   // holds user data, can be used across
	EntityVirtualDevice    = "virtual_device"    // holds virtual devices
	EntityVirtualAssistant = "virtual_assistant" // holds virtual assistants
	EntityServiceToken     = "service_token"     // holds service token
)

Entities

View Source
const (
	KeyID           = "ID"
	KeyGatewayID    = "GatewayID"
	KeyNodeID       = "NodeID"
	KeySourceID     = "SourceID"
	KeyFieldID      = "FieldID"
	KeyFieldName    = "FieldName"
	KeyUsername     = "Username"
	KeyUserID       = "UserID"
	KeyTokenID      = "Token.ID"
	KeyEmail        = "Email"
	KeyHandlerType  = "Type"
	KeyHandlerName  = "Name"
	KeyEnabled      = "Enabled"
	KeyDisabled     = "Disabled"
	KeyScheduleType = "Type"
	KeyType         = "Type"
	KeySrcFieldID   = "SrcFieldID"
	KeyName         = "Name"
	KeyLocation     = "Location"
)

Entity field keys

View Source
const (
	KeyKeyPath     = "keyPath"
	KeyTemplate    = "template"
	KeyTask        = "task"
	KeySchedule    = "schedule"
	KeyEventType   = "eventType"
	KeyTaskEvent   = "taskEvent"
	KeyPayload     = "payload"
	KeyValue       = "value"
	KeyMetricTypes = "metricTypes"
	KeyOthers      = "others"
	KeyLabels      = "labels"
	KeyUnits       = "units"
)

keys used in other locations

View Source
const (
	ENV_TELEMETRY_ENABLED      = "MC_TELEMETRY_ENABLED"
	ENV_DOCUMENTATION_URL      = "MC_DOCUMENTATION_URL"
	ENV_METRIC_DB_DISABLED     = "MC_METRIC_DB_DISABLED"
	ENV_DIR_DATA               = "MC_DIR_DATA"
	ENV_DIR_DATA_STORAGE       = "MC_DIR_DATA_STORAGE"
	ENV_DIR_DATA_FIRMWARE      = "MC_DIR_DATA_FIRMWARE"
	ENV_DIR_DATA_INTERNAL      = "MC_DIR_DATA_INTERNAL"
	ENV_DIR_TMP                = "MC_DIR_TMP"
	ENV_DIR_GATEWAY_LOGS       = "MC_DIR_GATEWAY_LOGS"
	ENV_DIR_GATEWAY_TMP        = "MC_DIR_GATEWAY_TMP"
	ENV_DIR_SHARE_SECURE       = "MC_DIR_SHARE_SECURE"
	ENV_DIR_SHARE_INSECURE     = "MC_DIR_SHARE_INSECURE"
	ENV_LOG_LEVEL_CORE         = "MC_LOG_LEVEL_CORE"
	ENV_LOG_LEVEL_STORAGE      = "MC_LOG_LEVEL_STORAGE"
	ENV_LOG_LEVEL_METRIC       = "MC_LOG_LEVEL_METRIC"
	ENV_LOG_LEVEL_WEB_HANDLER  = "MC_LOG_LEVEL_WEB_HANDLER"
	ENV_LOG_ENABLE_STACK_TRACE = "MC_LOG_ENABLE_STACK_TRACE"
	ENV_LOG_ENCODING           = "MC_LOG_ENCODING"
	ENV_LOG_MODE               = "MC_LOG_MODE"

	ENV_RUNNING_SINCE = "MC_RUNNING_SINCE" // update starting time

	ENV_JWT_ACCESS_SECRET = "JWT_ACCESS_SECRET" // environment variable to set secret for JWT token
)
View Source
const (
	FieldNone           = ""
	FieldName           = "name"
	FieldParentID       = "parent_id"
	FieldSignalStrength = "signal_strength"
	FieldBatteryLevel   = "battery_level"
	FieldLocked         = "locked"
	FieldHeartbeat      = "heartbeat"
	FieldIPAddress      = "ip_address"
	FieldNodeWebURL     = "node_web_url"
	FieldOTAProgress    = "ota_progress"     // in percentage
	FieldOTARunning     = "ota_running"      // in bool
	FieldOTABlockNumber = "ota_block_number" // current block number
	FieldOTABlockTotal  = "ota_block_total"  // total block count
	FieldOTAStatusOn    = "ota_status_on"    // time
	FieldOTAStartTime   = "ota_start_time"   // start time
	FieldOTAEndTime     = "ota_end_time"     // end time
	FieldOTATimeTaken   = "ota_time_taken"   // time taken to complete the update
)

Field names

View Source
const (
	// resource ids
	LabelGatewayID = "gateway_id"
	LabelNodeID    = "node_id"
	LabelSourceID  = "source_id"
	LabelFieldID   = "field_id"

	// Common labels
	LabelName      = "name"
	LabelTimezone  = "timezone"
	LabelReadOnly  = "read_only"
	LabelWriteOnly = "write_only"

	// Node specific labels
	LabelNodeSleepNode          = "sleep_node"           // messages always will be kept in sleep queue
	LabelNodeSleepQueueDisabled = "sleep_queue_disabled" // failed messages and messages will not be kept in sleep queue
	LabelNodeVersion            = "version"              // version of the application
	LabelNodeLibraryVersion     = "library_version"      // version of the underlying library
	LabelNodeAssignedFirmware   = "assigned_firmware"    // assigned firmware of the node
	LabelNodeOTABlockOrder      = "ota_block_order"      // used on OTA
	LabelNodeInactiveDuration   = "inactive_duration"    // mark the node as DOWN, if there is no message on the specified period

	// Field specific labels
	LabelMetricType = "metric_type"
	LabelUnit       = "unit"

	// device specific
	LabelDeviceType = "device_type"
	LabelTraitType  = "trait_type"
	LabelParamType  = "param_type"

	// used in virtual device
	LabelRoom = "room"

	// used in schedule, task and other resources. to activate timeout feature on javascript execution
	LabelScriptTimeout = "script_timeout"
)

reserved labels there is common prefix in all resources

View Source
const (
	VariableTypeString            = "string"
	VariableTypeResourceByQuickID = "resource_by_quick_id"
	VariableTypeResourceByLabels  = "resource_by_labels"
	VariableTypeWebhook           = "webhook"
)
View Source
const (
	NameType = "type"
)

Field names used in entities

Variables

This section is empty.

Functions

func GetAction

func GetAction(action string) string

GetAction parse and rename if required

func GetEnvBool

func GetEnvBool(key string) bool

func GetEnvString

func GetEnvString(key string) string

func SetEnv

func SetEnv(key string, value interface{}) error

Types

type File

type File struct {
	Name         string    `json:"name" yaml:"name"`
	Size         int64     `json:"size" yaml:"size"`
	CreationTime time.Time `json:"creationTime" yaml:"creationTime"`
	ModifiedTime time.Time `json:"modifiedTime" yaml:"modifiedTime"`
	Data         string    `json:"data" yaml:"data"`
	IsDir        bool      `json:"isDir" yaml:"isDir"`
	FullPath     string    `json:"fullPath" yaml:"fullPath"`
}

File struct

type State

type State struct {
	Status  string    `json:"status" yaml:"status" structs:"status"`
	Message string    `json:"message" yaml:"message" structs:"message"`
	Since   time.Time `json:"since"  yaml:"since" structs:"since"`
}

State data

type Sunrise

type Sunrise interface {
	SunriseTime() (*time.Time, error)
	SunsetTime() (*time.Time, error)
}

type TemplateEngine

type TemplateEngine interface {
	Execute(templateText string, data interface{}) (string, error)
}

type VariablesEngine

type VariablesEngine interface {
	Load(input map[string]interface{}) (map[string]interface{}, error)
	TemplateEngine() TemplateEngine
}

Jump to

Keyboard shortcuts

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