note

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 9 Imported by: 6

Documentation

Overview

Package note errors.go contains programmatically-testable error strings

Index

Constants

View Source
const ACActionAnd = "&"

ACActionAnd ensures that all of these actions are allowed

View Source
const ACActionCreate = "create"

ACActionCreate (golint)

View Source
const ACActionDelete = "delete"

ACActionDelete (golint)

View Source
const ACActionMonitor = "monitor"

ACActionMonitor (golint)

View Source
const ACActionOr = "|"

ACActionOr ensures that any of these actions are allowed

View Source
const ACActionRead = "read"

ACActionRead (golint)

View Source
const ACActionUpdate = "update"

ACActionUpdate (golint)

View Source
const ACResourceAccount = "account:"

ACResourceAccount is an account resource, which is the accountUID that always begins with this string

View Source
const ACResourceAccounts = "account:*"

ACResourceAccounts is the resource for all accounts and all meta-account-level actions

View Source
const ACResourceApp = "app:"

ACResourceApp is the app (project) resource, which is the appUID that always begins with this string

View Source
const ACResourceApps = "app:*"

ACResourceApps is the resource for all apps

View Source
const ACResourceDevice = "dev:"

ACResourceDevice is the device resource, which is the deviceUID that always begins with this string

View Source
const ACResourceDevices = "dev:*"

ACResourceDevices is the resource for all devices

View Source
const ACResourceNotecardFirmwares = "notecard:*"

ACResourceNotecardFirmwares is the resource for all notecard firmware

View Source
const ACResourceNotefile = "file:"

ACResourceNotefile is the notefile resource and its note-level actions, which is the notefileID prefixed with this string

View Source
const ACResourceNotefiles = "file:*"

ACResourceNotefiles is the resource for all notefiles and all meta-notefile-level actions

View Source
const ACResourceRoute = "route:"

ACResourceRoute is an route resource, which is the routeUID that always begins with this string

View Source
const ACResourceRoutes = "route:*"

ACResourceRoutes is the resource for all routes and all meta-route-level actions

View Source
const ACResourceSep = ":"

ACResourceSep is the separator for building compound resource names

View Source
const ACResourceUserFirmwares = "firmware:*"

ACResourceUserFirmwares is the resource for all user firmware

View Source
const ACValidActionsAccount = "account:create,account:read,account:update,account:delete"

ACValidActionsAccount are actions allowed on accounts

View Source
const ACValidActionsApp = "app:create,app:read,app:update,app:delete,app:monitor"

ACValidActionsApp are actions allowed on apps

View Source
const ACValidActionsDev = "dev:read,dev:update,dev:delete,dev:monitor"

ACValidActionsDev are actions allowed on devices

View Source
const ACValidActionsFile = "file:create,file:read,file:update,file:delete"

ACValidActionsFile are actions allowed on notefiles

View Source
const ACValidActionsFirmware = "firmware:create,firmware:read,firmware:update,firmware:delete"

ACValidActionsFirmware are actions allowed on user firmware

View Source
const ACValidActionsNotecard = "notecard:create,notecard:read,notecard:update,notecard:delete"

ACValidActionsNotecard are actions allowed on notecard firmware

View Source
const ACValidActionsRoute = "route:create,route:read,route:update,route:delete"

ACValidActionsRoute are actions allowed on routes

View Source
const ContactOwnerNoteID = "owner"

ContactOwnerNoteID indicates that this is my contact

View Source
const ContactStore = "contacts.db"

ContactStore is the place where the user retains contact info

View Source
const DefaultDeviceEndpointID = ""

DefaultDeviceEndpointID is the default endpoint name of the edge, chosen for its length in protocol messages

View Source
const DefaultHubEndpointID = "1"

DefaultHubEndpointID is the default endpoint name of the hub, chosen for its length in protocol messages

View Source
const ErrAccessDenied = "{access-denied}"

ErrAccessDenied (golint)

View Source
const ErrAppDeleted = "{app-deleted}"

ErrAppDeleted (golint)

View Source
const ErrAppExists = "{app-exists}"

ErrAppExists (golint)

View Source
const ErrAppNotFound = "{app-noexist}"

ErrAppNotFound (golint)

View Source
const ErrAppNotSpecified = "{app-none}"

ErrAppNotSpecified (golint)

View Source
const ErrAuth = "{auth}"

ErrAuth (golint)

View Source
const ErrCardIo = "{io}"

ErrCardIo (golint)

View Source
const ErrClosed = "{closed}"

ErrClosed (golint)

View Source
const ErrDFUInProgress = "{dfu-in-progress}"

ErrDFUInProgress (golint)

View Source
const ErrDFUNotReady = "{dfu-not-ready}"

ErrDFUNotReady (golint)

View Source
const ErrDeviceDelay10 = "{device-delay-10}"

ErrDeviceDelay10 (golint)

View Source
const ErrDeviceDelay15 = "{device-delay-15}"

ErrDeviceDelay15 (golint)

View Source
const ErrDeviceDelay20 = "{device-delay-20}"

ErrDeviceDelay20 (golint)

View Source
const ErrDeviceDelay30 = "{device-delay-30}"

ErrDeviceDelay30 (golint)

View Source
const ErrDeviceDelay5 = "{device-delay-5}"

ErrDeviceDelay5 (golint)

View Source
const ErrDeviceDelay60 = "{device-delay-60}"

ErrDeviceDelay60 (golint)

View Source
const ErrDeviceDisabled = "{device-disabled}"

ErrDeviceDisabled (golint)

View Source
const ErrDeviceNotFound = "{device-noexist}"

ErrDeviceNotFound (golint)

View Source
const ErrDeviceNotSpecified = "{device-none}"

ErrDeviceNotSpecified (golint)

View Source
const ErrDoNotRoute = "{do-not-route}"

ErrDoNotRoute (golint)

View Source
const ErrExtendedNetworkFailure = "{extended-network-failure}"

ErrExtendedNetworkFailure (golint)

View Source
const ErrExtendedServiceFailure = "{extended-service-failure}"

ErrExtendedServiceFailure (golint)

View Source
const ErrFileNoExist = "{file-noexist}"

ErrFileNoExist (golint)

View Source
const ErrFleetNotFound = "{fleet-noexist}"

ErrFleetNotFound (golint)

View Source
const ErrGPSInactive = "{gps-inactive}"

ErrGPSInactive (golint)

View Source
const ErrHostUnreachable = "{host-unreachable}"

ErrHostUnreachable (golint)

View Source
const ErrHubMode = "{hub-mode}"

ErrHubMode (golint)

View Source
const ErrHubNoHandler = "{no-handler}"

ErrHubNoHandler (golint)

View Source
const ErrIdle = "{idle}"

ErrIdle (golint)

View Source
const ErrIncompatible = "{incompatible}"

ErrIncompatible (golint)

View Source
const ErrJson = "{not-json}"

ErrJson (golint)

View Source
const ErrNetwork = "{network}"

ErrNetwork (golint)

View Source
const ErrNoteExists = "{note-exists}"

ErrNoteExists (golint)

View Source
const ErrNoteNoExist = "{note-noexist}"

ErrNoteNoExist (golint)

View Source
const ErrNotefileExists = "{notefile-exists}"

ErrNotefileExists (golint)

View Source
const ErrNotefileInUse = "{notefile-in-use}"

ErrNotefileInUse (golint)

View Source
const ErrNotefileName = "{notefile-bad-name}"

ErrNotefileName (golint)

View Source
const ErrNotefileNoExist = "{notefile-noexist}"

ErrNotefileNoExist (golint)

View Source
const ErrNotefileQueueDisallowed = "{notefile-queue-disallowed}"

ErrNotefileQueueDisallowed (golint)

View Source
const ErrProductNotFound = "{product-noexist}"

ErrProductNotFound (golint)

View Source
const ErrProductNotSpecified = "{product-none}"

ErrProductNotSpecified (golint)

View Source
const ErrRegistrationFailure = "{registration-failure}"

ErrRegistrationFailure (golint)

View Source
const ErrReqNotSupported = "{not-supported}"

ErrReqNotSupported (golint)

View Source
const ErrSyntax = "{syntax}"

ErrSyntax (golint)

View Source
const ErrTemplateIncompatible = "{template-incompatible}"

ErrTemplateIncompatible (golint)

View Source
const ErrTicket = "{ticket}"

ErrTicket (golint)

View Source
const ErrTimeout = "{timeout}"

ErrTimeout (golint)

View Source
const ErrTooBig = "{too-big}"

ErrTooBig (golint)

View Source
const ErrTrackerExists = "{tracker-exists}"

ErrTrackerExists (golint)

View Source
const ErrTrackerNoExist = "{tracker-noexist}"

ErrTrackerNoExist (golint)

View Source
const ErrTransportConnectFailure = "{connect-failure}"

ErrTransportConnectFailure (golint)

View Source
const ErrTransportConnected = "{connected}"

ErrTransportConnected (golint)

View Source
const ErrTransportConnectedClosed = "{connected-closed}"

ErrTransportConnectedClosed (golint)

View Source
const ErrTransportConnecting = "{connecting}"

ErrTransportConnecting (golint)

View Source
const ErrTransportDisconnected = "{disconnected}"

ErrTransportDisconnected (golint)

View Source
const ErrTransportWaitData = "{wait-data}"

ErrTransportWaitData (golint)

View Source
const ErrTransportWaitGateway = "{wait-gateway}"

ErrTransportWaitGateway (golint)

View Source
const ErrTransportWaitModule = "{wait-module}"

ErrTransportWaitModule (golint)

View Source
const ErrTransportWaitService = "{wait-service}"

ErrTransportWaitService (golint)

View Source
const ErrWebPayload = "{web-payload}"

ErrWebPayload (golint)

View Source
const EventAdd = "note.add"

EventAdd (golint)

View Source
const EventDelete = "note.delete"

EventDelete (golint)

View Source
const EventGeolocation = "device.geolocation"

EventGeolocation (golint)

View Source
const EventGet = "get"

EventGet (golint)

View Source
const EventNoAction = ""

EventNoAction (golint)

View Source
const EventPost = "post"

EventPost (golint)

View Source
const EventPut = "put"

EventPut (golint)

View Source
const EventSession = "session.begin"

EventSession (golint)

View Source
const EventTest = "test"

EventTest (golint)

View Source
const EventUpdate = "note.update"

EventUpdate (golint)

View Source
const EventWebhook = "webhook"

EventWebhook (golint)

View Source
const GeolocationNotefile = "_geolocate.qo"

GeolocationNotefile is the hard-wired notefile that the notehub uses when performing a geolocation

View Source
const HealthNotefile = "_health.qo"

HealthNotefile is the hard-wired notefile that the notecard uses for health-related info

View Source
const HubDefaultInboundNotefile = "data.qi"

HubDefaultInboundNotefile is the hard-wired default notefile for user data

View Source
const HubDefaultOutboundNotefile = "data.qo"

HubDefaultOutboundNotefile is the hard-wired default notefile for user data

View Source
const LogNotefile = "_log.qo"

LogNotefile is the hard-wired notefile that the notecard uses for debug logging

View Source
const MessageContentASCII = ""

MessageContentASCII is just simple ASCII text

View Source
const MessageInbox = "messages.qi"

MessageInbox is the place into which messages are received

View Source
const MessageOutbox = "messages.qo"

MessageOutbox is the place from which messages are sent

View Source
const MessageSTagReceived = "received"

MessageSTagReceived indicates that this was a received message

View Source
const MessageSTagSent = "sent"

MessageSTagSent indicates that this was a sent message

View Source
const MessageStore = "messages.db"

MessageStore is the place where the user retains messages

View Source
const MessageTagImportant = "important"

MessageTagImportant indicates that the sender feels that this is an important message

View Source
const MessageTagUrgent = "urgent"

MessageTagUrgent indicates that the sender feels that this is an urgent message

View Source
const NotecardRequestNotefile = "_req.qis"

NotecardRequestNotefile is a special notefile for sending notecard requests

View Source
const NotecardResponseNotefile = "_rsp.qos"

NotecardResponseNotefile is a special notefile for sending notecard responses

View Source
const SessionNotefile = "_session.qo"

SessionNotefile is the hard-wired notefile that the notehub uses when starting a session

View Source
const SyncPriorityHigh = 1

SyncPriorityHigh (golint)

View Source
const SyncPriorityHigher = 2

SyncPriorityHigher (golint)

View Source
const SyncPriorityHighest = 3

SyncPriorityHighest (golint)

View Source
const SyncPriorityLow = -1

SyncPriorityLow (golint)

View Source
const SyncPriorityLower = -2

SyncPriorityLower (golint)

View Source
const SyncPriorityLowest = -3

SyncPriorityLowest (golint)

View Source
const SyncPriorityNormal = 0

SyncPriorityNormal (golint)

View Source
const TrackNotefile = "_track.qo"

TrackNotefile is the hard-wired notefile that the notecard can use for tracking the device

View Source
const WebNotefile = "_web.qo"

WebNotefile is the hard-wired notefile that the notehub uses when performing web requests

Variables

This section is empty.

Functions

func BodyToObject added in v1.2.1

func BodyToObject(body *map[string]interface{}, object interface{}) (err error)

BodyToObject Unmarshals the specified map into an object

func ErrorClean added in v1.1.21

func ErrorClean(err error) error

ErrorClean removes all error keywords from an error string

func ErrorContains added in v1.1.21

func ErrorContains(err error, errKeyword string) bool

ErrorContains tests to see if an error contains an error keyword that we might expect

func ErrorJSON added in v1.3.8

func ErrorJSON(message string, err error) (rspJSON []byte)

ErrorJSON returns a JSON object with nothing but an error code, and with an optional message

func ErrorString added in v1.1.21

func ErrorString(err error) string

ErrorString safely returns a string from any error, returning "" for nil

func JSONMarshal added in v1.2.1

func JSONMarshal(v interface{}) ([]byte, error)

JSONMarshal is the equivalent to the json package's Marshal, however it does not escape HTML sitting inside JSON strings.

func JSONMarshalIndent added in v1.2.1

func JSONMarshalIndent(v interface{}, prefix, indent string) ([]byte, error)

JSONMarshalIndent is like Marshal but applies Indent to format the output. Each JSON element in the output will begin on a new line beginning with prefix followed by one or more copies of indent according to the indentation nesting.

func JSONToBody added in v1.1.1

func JSONToBody(bodyJSON []byte) (body map[string]interface{}, err error)

JSONToBody unmarshals the specified object and returns it as a map[string]interface{}

func JSONUnmarshal added in v1.2.1

func JSONUnmarshal(data []byte, v interface{}) (err error)

JSONUnmarshal uses JSON Numbers, rather than assuming Floats. This fixes an issue in which, when decoding to an arbitrary interface, the JSON package decodes large numbers (like Unix epoch) into floats.

func ObjectToBody added in v1.1.1

func ObjectToBody(object interface{}) (body map[string]interface{}, err error)

ObjectToBody Marshals the specified object and returns it as map

func ObjectToJSON added in v1.1.1

func ObjectToJSON(object interface{}) (bodyJSON []byte, err error)

ObjectToJSON Marshals the specified object and returns it as a []byte

func WordToNumber added in v1.3.7

func WordToNumber(word string) (num uint, success bool)

WordToNumber converts a single word to a number

func WordsFromNumber added in v1.3.7

func WordsFromNumber(number uint32) string

WordsFromNumber converts a number to three simple words

func WordsFromString added in v1.3.7

func WordsFromString(in string) (out string)

WordsFromString hashes a string with a 32-bit function and converts it to three simple words

func WordsToNumber added in v1.3.7

func WordsToNumber(words string) (num uint32, found bool)

WordsToNumber looks up a number from two or three simple words

Types

type Contact added in v1.5.1

type Contact struct {
	Name        string `json:"name,omitempty"`
	Affiliation string `json:"org,omitempty"`
	Role        string `json:"role,omitempty"`
	Email       string `json:"email,omitempty"`
}

Contact has the basic contact info structure

NOTE: This structure's underlying storage has been decoupled from the use of the structure in business logic. As such, please share any changes to these structures with cloud services to ensure that storage and testing frameworks are kept in sync with these structures used for business logic

type Contacts added in v1.5.1

type Contacts struct {
	Admin *Contact `json:"admin,omitempty"`
	Tech  *Contact `json:"tech,omitempty"`
}

Contacts has contact info for this app

NOTE: This structure's underlying storage has been decoupled from the use of the structure in business logic. As such, please share any changes to these structures with cloud services to ensure that storage and testing frameworks are kept in sync with these structures used for business logic

type DeviceSession

type DeviceSession struct {
	// Session ID that can be mapped to the events created during that session
	SessionUID string `json:"session,omitempty"`
	// Log key for this session
	SessionLogKey string `json:"session_log_key,omitempty"`
	// Info from the device structure
	DeviceUID  string   `json:"device,omitempty"`
	DeviceSN   string   `json:"sn,omitempty"`
	ProductUID string   `json:"product,omitempty"`
	FleetUIDs  []string `json:"fleets,omitempty"`
	// Protocol:IP:port address of the handler serving the session
	Handler string `json:"handler,omitempty"`
	// Cell ID where the session originated and quality ("mcc,mnc,lac,cellid")
	CellID string `json:"cell,omitempty"`
	// Parameters passed by device as a result of scanning towers/APs
	ScanResults *[]byte                 `json:"scan,omitempty"`
	Triangulate *map[string]interface{} `json:"triangulate,omitempty"`
	// Network connection information sent by the notecard
	Rssi   int    `json:"rssi,omitempty"`
	Sinr   int    `json:"sinr,omitempty"`
	Rsrp   int    `json:"rsrp,omitempty"`
	Rsrq   int    `json:"rsrq,omitempty"`
	Bars   int    `json:"bars,omitempty"`
	Rat    string `json:"rat,omitempty"`
	Bearer string `json:"bearer,omitempty"`
	Ip     string `json:"ip,omitempty"`
	Bssid  string `json:"bssid,omitempty"`
	Ssid   string `json:"ssid,omitempty"`
	Iccid  string `json:"iccid,omitempty"`
	Apn    string `json:"apn,omitempty"`
	// Last known tower and triangulated location as determined at the start of session
	Tower TowerLocation `json:"tower,omitempty"`
	Tri   TowerLocation `json:"tri,omitempty"`
	// Last known capture time of a note routed through this session
	When int64 `json:"when,omitempty"`
	// Last known GPS location of a note routed through this session
	WhereWhen     int64   `json:"where_when,omitempty"`
	WhereOLC      string  `json:"where,omitempty"`
	WhereLat      float64 `json:"where_lat,omitempty"`
	WhereLon      float64 `json:"where_lon,omitempty"`
	WhereLocation string  `json:"where_location,omitempty"`
	WhereCountry  string  `json:"where_country,omitempty"`
	WhereTimeZone string  `json:"where_timezone,omitempty"`
	// Flag indicating whether the usage data is based on actual stats from the device
	IsUsageActual bool `json:"usage_actual,omitempty"`
	// Physical device info
	Voltage float64 `json:"voltage,omitempty"`
	Temp    float64 `json:"temp,omitempty"`
	// Type of session
	ContinuousSession bool `json:"continuous,omitempty"`
	TLSSession        bool `json:"tls,omitempty"`
	// For keeping track of when the last work was done for a session
	LastWorkDone int64 `json:"work,omitempty"`
	// Number of Events routed
	EventCount int64 `json:"events,omitempty"`
	// Motion of the notecard
	Moved       int64  `json:"moved,omitempty"`
	Orientation string `json:"orientation,omitempty"`
	// Why a session was triggered
	Trigger string `json:"trigger,omitempty"`
	// Last known power stats at start of session
	HighPowerSecsTotal   uint32 `json:"hp_secs_total,omitempty"`
	HighPowerSecsData    uint32 `json:"hp_secs_data,omitempty"`
	HighPowerSecsGPS     uint32 `json:"hp_secs_gps,omitempty"`
	HighPowerCyclesTotal uint32 `json:"hp_cycles_total,omitempty"`
	HighPowerCyclesData  uint32 `json:"hp_cycles_data,omitempty"`
	HighPowerCyclesGPS   uint32 `json:"hp_cycles_gps,omitempty"`
	// Total device usage at the beginning of the period
	ThisPtr *DeviceUsage `json:"this,omitempty"`
	// Total device usage at the beginning of the next period, whenever it happens to occur
	NextPtr *DeviceUsage `json:"next,omitempty"`
	// Usage during the period - initially estimated, but then corrected when we get to the next period
	PeriodPtr *DeviceUsage `json:"period,omitempty"`
}

DeviceSession is the basic unit of recorded device usage history

func (*DeviceSession) Next

func (s *DeviceSession) Next() *DeviceUsage

func (*DeviceSession) Period

func (s *DeviceSession) Period() *DeviceUsage

func (*DeviceSession) This

func (s *DeviceSession) This() *DeviceUsage

type DeviceUsage

type DeviceUsage struct {
	Since              int64  `json:"since,omitempty"`
	DurationSecs       uint32 `json:"duration,omitempty"`
	RcvdBytes          uint32 `json:"bytes_rcvd,omitempty"`
	SentBytes          uint32 `json:"bytes_sent,omitempty"`
	RcvdBytesSecondary uint32 `json:"bytes_rcvd_secondary,omitempty"`
	SentBytesSecondary uint32 `json:"bytes_sent_secondary,omitempty"`
	TCPSessions        uint32 `json:"sessions_tcp,omitempty"`
	TLSSessions        uint32 `json:"sessions_tls,omitempty"`
	RcvdNotes          uint32 `json:"notes_rcvd,omitempty"`
	SentNotes          uint32 `json:"notes_sent,omitempty"`
}

DeviceUsage is the device usage metric representing values from the beginning of time, since Provisioned

type Event

type Event struct {
	EventUID   string                  `json:"event,omitempty"`
	SessionUID string                  `json:"session,omitempty"`
	TLS        bool                    `json:"tls,omitempty"`
	Continuous bool                    `json:"continuous,omitempty"`
	BestID     string                  `json:"best_id,omitempty"`
	DeviceUID  string                  `json:"device,omitempty"`
	DeviceSN   string                  `json:"sn,omitempty"`
	ProductUID string                  `json:"product,omitempty"`
	AppUID     string                  `json:"app,omitempty"`
	EndpointID string                  `json:"endpoint,omitempty"`
	Received   float64                 `json:"received,omitempty"`
	Req        string                  `json:"req,omitempty"`
	Error      string                  `json:"err,omitempty"`
	When       int64                   `json:"when,omitempty"`
	NotefileID string                  `json:"file,omitempty"`
	NoteID     string                  `json:"note,omitempty"`
	Updates    int32                   `json:"updates,omitempty"`
	Deleted    bool                    `json:"deleted,omitempty"`
	Sent       bool                    `json:"queued,omitempty"`
	Bulk       bool                    `json:"bulk,omitempty"`
	Body       *map[string]interface{} `json:"body,omitempty"`
	Payload    []byte                  `json:"payload,omitempty"`
	// This field is ONLY used when we remove the payload for storage reasons, to show the app how large it was
	MissingPayloadLength int64 `json:"payload_length,omitempty"`
	// Location
	BestLocationType string  `json:"best_location_type,omitempty"`
	BestLocationWhen int64   `json:"best_location_when,omitempty"`
	BestLat          float64 `json:"best_lat,omitempty"`
	BestLon          float64 `json:"best_lon,omitempty"`
	BestLocation     string  `json:"best_location,omitempty"`
	BestCountry      string  `json:"best_country,omitempty"`
	BestTimeZone     string  `json:"best_timezone,omitempty"`
	Where            string  `json:"where_olc,omitempty"`
	WhereWhen        int64   `json:"where_when,omitempty"`
	WhereLat         float64 `json:"where_lat,omitempty"`
	WhereLon         float64 `json:"where_lon,omitempty"`
	WhereLocation    string  `json:"where_location,omitempty"`
	WhereCountry     string  `json:"where_country,omitempty"`
	WhereTimeZone    string  `json:"where_timezone,omitempty"`
	TowerWhen        int64   `json:"tower_when,omitempty"`
	TowerLat         float64 `json:"tower_lat,omitempty"`
	TowerLon         float64 `json:"tower_lon,omitempty"`
	TowerCountry     string  `json:"tower_country,omitempty"`
	TowerLocation    string  `json:"tower_location,omitempty"`
	TowerTimeZone    string  `json:"tower_timezone,omitempty"`
	TowerID          string  `json:"tower_id,omitempty"`
	TriWhen          int64   `json:"tri_when,omitempty"`
	TriLat           float64 `json:"tri_lat,omitempty"`
	TriLon           float64 `json:"tri_lon,omitempty"`
	TriLocation      string  `json:"tri_location,omitempty"`
	TriCountry       string  `json:"tri_country,omitempty"`
	TriTimeZone      string  `json:"tri_timezone,omitempty"`
	TriPoints        int32   `json:"tri_points,omitempty"`
	// Motion
	Moved       int64  `json:"moved,omitempty"`
	Orientation string `json:"orientation,omitempty"`
	// Signal strength/quality of the cell
	Rssi int    `json:"rssi,omitempty"`
	Sinr int    `json:"sinr,omitempty"`
	Rsrp int    `json:"rsrp,omitempty"`
	Rsrq int    `json:"rsrq,omitempty"`
	Rat  string `json:"rat,omitempty"`
	Bars uint32 `json:"bars,omitempty"`
	// Physical device info
	Voltage float64 `json:"voltage,omitempty"`
	Temp    float64 `json:"temp,omitempty"`
	// Triangulation
	Triangulate *map[string]interface{} `json:"triangulate,omitempty"`
	// "Routed" environment variables beginning with a "$" prefix
	Env       *map[string]string `json:"environment,omitempty"`
	Status    EventRoutingStatus `json:"status,omitempty"`
	FleetUIDs *[]string          `json:"fleets,omitempty"`

	// Extended details for routed events.  This is not referenced in the source
	// code because it gets optionally populated by a JSONata transform.  It was
	// added to support the v1 API /v1/projects/<UID>/webhooks/<UID>
	Details *map[string]interface{} `json:"details,omitempty"`
}

Event is the request structure passed to the Notification proc

NOTE: This structure's underlying storage has been decoupled from the use of the structure in business logic. As such, please share any changes to these structures with cloud services to ensure that storage and testing frameworks are kept in sync with these structures used for business logic

type EventRoutingStatus added in v1.7.1

type EventRoutingStatus string
const (
	EventStatusEmpty      EventRoutingStatus = ""
	EventStatusSuccess    EventRoutingStatus = "success"
	EventStatusFailure    EventRoutingStatus = "failure"
	EventStatusInProgress EventRoutingStatus = "in_progress"
)

func GetAggregateEventStatus added in v1.6.11

func GetAggregateEventStatus(logs []RouteLogEntry) EventRoutingStatus

GetAggregateEventStatus returns the status of the event given all of the route logs for the event.

The aggregate status is determined by taking the most recent status for each route. If any of these are failures then the overall status is EventStatusFailure, otherwise it's EventStatusSuccess

type History

type History struct {
	When       int64  `json:"w,omitempty"`
	Where      string `json:"l,omitempty"`
	WhereWhen  int64  `json:"m,omitempty"`
	EndpointID string `json:"e,omitempty"`
	Sequence   int32  `json:"s,omitempty"`
}

History records the update history, optimized so that if the most recent entry is by the same endpoint as an update/delete, that entry is re-used. The primary use of History is for conflict detection, and you don't need to detect conflicts against yourself.

type Info

type Info struct {
	NoteID  string                  `json:"id,omitempty"`
	Body    *map[string]interface{} `json:"body,omitempty"`
	Payload *[]byte                 `json:"payload,omitempty"`
	Deleted bool                    `json:"deleted,omitempty"`
}

Info is a general "content" structure

type Message added in v1.2.1

type Message struct {
	UID         string                  `json:"id,omitempty"`
	Sent        uint32                  `json:"sent,omitempty"`
	Received    uint32                  `json:"received,omitempty"`
	From        MessageContact          `json:"from,omitempty"`
	To          []MessageContact        `json:"to,omitempty"`
	Tags        []string                `json:"tags,omitempty"`
	StoreTags   []string                `json:"stags,omitempty"`
	ContentType string                  `json:"type,omitempty"`
	Content     string                  `json:"content,omitempty"`
	Body        *map[string]interface{} `json:"body,omitempty"`
}

Message is the core message data structure. Note that when stored in a map or a note, the UID is not present but rather is the map key or noteID.

type MessageAddress added in v1.2.1

type MessageAddress struct {
	Hub        string `json:"hub,omitempty"`
	ProductUID string `json:"product,omitempty"`
	DeviceUID  string `json:"device,omitempty"`
	DeviceSN   string `json:"sn,omitempty"`
	Active     uint32 `json:"active,omitempty"`
}

MessageAddress is the network routing information for a message

type MessageContact added in v1.2.1

type MessageContact struct {
	Name      string           `json:"name,omitempty"`
	Email     string           `json:"email,omitempty"`
	StoreTags []string         `json:"stags,omitempty"`
	Addresses []MessageAddress `json:"addresses,omitempty"`
}

MessageContact is the entity sending a message, who may have multiple devices/addresses

type Note

type Note struct {
	Body      map[string]interface{} `json:"b,omitempty"`
	Payload   []byte                 `json:"p,omitempty"`
	Change    int64                  `json:"c,omitempty"`
	Histories *[]History             `json:"h,omitempty"`
	Conflicts *[]Note                `json:"x,omitempty"`
	Updates   int32                  `json:"u,omitempty"`
	Deleted   bool                   `json:"d,omitempty"`
	Sent      bool                   `json:"s,omitempty"`
	Bulk      bool                   `json:"k,omitempty"`
	XPOff     uint32                 `json:"O,omitempty"`
	XPLen     uint32                 `json:"L,omitempty"`
	Tower     *TowerLocation         `json:"T,omitempty"`
}

Note is the most fundamental data structure, containing user data referred to as its "body" and its "payload". All access to these fields, and changes to these fields, must be done indirectly through the note API.

func CreateNote

func CreateNote(body []byte, payload []byte) (newNote Note, err error)

CreateNote creates the core data structure for an object, given a JSON body

func (*Note) Close

func (note *Note) Close()

Close closes and frees the object on a note {

func (*Note) Dup

func (note *Note) Dup() Note

Dup duplicates the note

func (*Note) EndpointID

func (note *Note) EndpointID() string

EndpointID determines the endpoint that last modified the note

func (*Note) GetBody

func (note *Note) GetBody() []byte

GetBody retrieves the application-specific Body of a given Note

func (*Note) GetConflicts

func (note *Note) GetConflicts() []Note

GetConflicts fetches the conflicts, so that they may be displayed

func (*Note) GetModified

func (note *Note) GetModified() (isAvailable bool, endpointID string, when string, where string, updates int32)

GetModified retrieves information about the note's modification

func (*Note) GetPayload

func (note *Note) GetPayload() []byte

GetPayload retrieves the Payload from a given Note

func (*Note) HasConflicts

func (note *Note) HasConflicts() bool

HasConflicts determines whether or not a given Note has conflicts

func (*Note) SetBody

func (note *Note) SetBody(body []byte) (err error)

SetBody sets the application-supplied Body field of a given Note given some JSON

func (*Note) SetPayload

func (note *Note) SetPayload(payload []byte)

SetPayload sets the application-supplied Payload field of a given Note, which must be binary bytes that will ultimately be rendered as base64 in JSON

func (*Note) When added in v1.6.11

func (note *Note) When() (when int64)

GetWhen retrieves the epoch modification time

type NotefileInfo

type NotefileInfo struct {
	// The count of modified notes in this notefile. This is used in the Req API, but not in the Notebox info
	Changes int `json:"changes,omitempty"`
	// The count of total notes in this notefile. This is used in the Req API, but not in the Notebox info
	Total int `json:"total,omitempty"`
	// This is a unidirectional "to-hub" or "from-hub" endpoint
	SyncHubEndpointID string `json:"sync_hub_endpoint,omitempty"`
	// Relative positive/negative priority of data, with 0 being normal
	SyncPriority int `json:"sync_priority,omitempty"`
	// Timed: Target for sync period, if modified and if the value hasn't been synced sooner
	SyncPeriodSecs int `json:"sync_secs,omitempty"`
	// ReqTime is specified if notes stored in this notefile must have a valid time associated with them
	ReqTime bool `json:"req_time,omitempty"`
	// ReqLoc is specified if notes stored in this notefile must have a valid location associated with them
	ReqLoc bool `json:"req_loc,omitempty"`
	// AnonAddAllowed is specified if anyone is allowed to drop into this notefile without authentication
	AnonAddAllowed bool `json:"anon_add,omitempty"`
	// ImportTime is the epoch time of when an external data source (such as a feed) last sync'ed data inbound
	ImportTime int64 `json:"import_time,omitempty"`
	// ExportTime is the epoch time of when an external data source (such as a feed) last sync'ed data outbound
	ExportTime int64 `json:"export_time,omitempty"`
}

NotefileInfo has parameters about the Notefile

type RouteLogEntry added in v1.5.1

type RouteLogEntry struct {
	EventSerial int64     `json:"event,omitempty"`
	RouteSerial int64     `json:"route,omitempty"`
	Date        time.Time `json:"date,omitempty"`
	Attn        bool      `json:"attn,omitempty"`
	Status      string    `json:"status,omitempty"`
	Text        string    `json:"text,omitempty"`
	URL         string    `json:"url,omitempty"`
}

RouteLogEntry is the log entry used by notification processing

type TowerLocation

type TowerLocation struct {
	When        int64   `json:"time,omitempty"` // time when this location was ascertained
	Name        string  `json:"n,omitempty"`    // name of the location
	CountryCode string  `json:"c,omitempty"`    // country code
	Lat         float64 `json:"lat,omitempty"`  // latitude
	Lon         float64 `json:"lon,omitempty"`  // longitude
	TimeZone    string  `json:"zone,omitempty"` // timezone name
	MCC         int     `json:"mcc,omitempty"`
	MNC         int     `json:"mnc,omitempty"`
	LAC         int     `json:"lac,omitempty"`
	CID         int     `json:"cid,omitempty"`
	OLC         string  `json:"l,omitempty"`      // open location code
	TimeZoneID  int     `json:"z,omitempty"`      // timezone id (see tz.go)
	Count       int64   `json:"count,omitempty"`  // number of times this location was recently used
	Towers      int     `json:"towers,omitempty"` // number of triangulation points
}

TowerLocation is the cell tower location structure generated by the tower utility

type Word added in v1.3.7

type Word struct {
	WordIndex uint
}

Word index data structure

Jump to

Keyboard shortcuts

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