note

package
v1.1.15 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2019 License: MIT Imports: 2 Imported by: 7

Documentation

Index

Constants

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 EventAdd = "note.add"

EventAdd (golint)

View Source
const EventDelete = "note.delete"

EventDelete (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 EventUpdate = "note.update"

EventUpdate (golint)

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)

Variables

This section is empty.

Functions

func JSONToBody added in v1.1.1

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

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

func ObjectToBody added in v1.1.1

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

ObjectToBody Marshals the specify object and returns it as map

func ObjectToJSON added in v1.1.1

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

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

Types

type DeviceSession

type DeviceSession struct {
	// Session ID that can be mapped to the events created during that session
	SessionUID string `json:"session,omitempty"`
	// Info from the device structure
	DeviceUID  string `json:"device,omitempty"`
	DeviceSN   string `json:"sn,omitempty"`
	ProductUID string `json:"product,omitempty"`
	FleetUID   string `json:"fleet,omitempty"`
	// IP address of the session
	Addr string `json:"addr,omitempty"`
	// Cell ID where the session originated and quality ("mcc,mnc,lac,cellid")
	CellID string `json:"cell,omitempty"`
	// Signal strength/quality of the cell
	Rssi int `json:"rssi,omitempty"`
	Sinr int `json:"sinr,omitempty"`
	// Last known tower location at beginning of session
	Tower TowerLocation `json:"tower,omitempty"`
	// Last known GPS location extracted from data flowing through 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"`
	// Total device usage at the beginning of the period
	This DeviceUsage `json:"this,omitempty"`
	// Total device usage at the beginning of the next period, whenever it happens to occur
	Next DeviceUsage `json:"next,omitempty"`
	// Usage during the period - initially estimated, but then corrected when we get to the next period
	Period DeviceUsage `json:"period,omitempty"`
	// Physical device info
	Voltage float64 `json:"voltage,omitempty"`
	Temp    float64 `json:"temp,omitempty"`
	// Development mode
	Development bool `json:"dev,omitempty"`
	// For keeping track of when the last work was done for a session
	LastWorkDone int64
}

DeviceSession is the basic unit of recorded device usage history

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"`
	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 {
	Body          *map[string]interface{}  `json:"body,omitempty"`
	Req           string                   `json:"req,omitempty"`
	Rsp           string                   `json:"rsp,omitempty"`
	Error         string                   `json:"err,omitempty"`
	When          int64                    `json:"when,omitempty"`
	Where         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"`
	Routed        int64                    `json:"routed,omitempty"`
	NoteID        string                   `json:"note,omitempty"`
	NotefileID    string                   `json:"file,omitempty"`
	Updates       int32                    `json:"updates,omitempty"`
	Deleted       bool                     `json:"deleted,omitempty"`
	Sent          bool                     `json:"queued,omitempty"`
	Bulk          bool                     `json:"bulk,omitempty"`
	TowerCountry  string                   `json:"tower_country,omitempty"`
	TowerLocation string                   `json:"tower_location,omitempty"`
	TowerTimeZone string                   `json:"tower_timezone,omitempty"`
	TowerLat      float64                  `json:"tower_lat,omitempty"`
	TowerLon      float64                  `json:"tower_lon,omitempty"`
	TowerID       string                   `json:"tower_id,omitempty"`
	LogAttn       bool                     `json:"logattn,omitempty"`
	Log           map[string]EventLogEntry `json:"log,omitempty"`
	App           *EventApp                `json:"project,omitempty"`
	DeviceContact *EventContact            `json:"device_contact,omitempty"`
	EndpointID    string                   `json:"endpoint,omitempty"`
	DeviceSN      string                   `json:"sn,omitempty"`
	DeviceUID     string                   `json:"device,omitempty"`
	ProductUID    string                   `json:"product,omitempty"`
	SessionUID    string                   `json:"session,omitempty"`
	EventUID      string                   `json:"event,omitempty"`
	Payload       []byte                   `json:"payload,omitempty"`
}

Event is the request structure passed to the Notification proc

type EventApp

type EventApp struct {
	AppUID   string        `json:"id,omitempty"`
	AppLabel string        `json:"name,omitempty"`
	Contacts EventContacts `json:"contacts,omitempty"`
}

EventApp has information about the app

type EventContact

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

EventContact has the basic contact info structure

type EventContacts

type EventContacts struct {
	Admin *EventContact `json:"admin,omitempty"`
	Tech  *EventContact `json:"tech,omitempty"`
}

EventContacts has contact info for this app

type EventLogEntry

type EventLogEntry struct {
	Attn   bool   `json:"attn,omitempty"`
	Status string `json:"status,omitempty"`
	Text   string `json:"text,omitempty"`
}

EventLogEntry is the log entry used by notification processing

type History

type History struct {
	When       int64  `json:"w,omitempty"`
	Where      string `json:"l,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 {
	Body    *map[string]interface{} `json:"body,omitempty"`
	Payload *[]byte                 `json:"payload,omitempty"`
	Deleted bool                    `json:"deleted,omitempty"`
}

Info is a general "content" structure

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"`
}

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

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"`
	// 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"`
}

NotefileInfo has parameters about the Notefile

type TowerLocation

type TowerLocation struct {
	Name        string  `json:"n,omitempty"`    // name of the location
	CountryCode string  `json:"c,omitempty"`    // country code
	TimeZoneID  int     `json:"z,omitempty"`    // timezone id (see tz.go)
	OLC         string  `json:"l,omitempty"`    // location
	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"`
}

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

Jump to

Keyboard shortcuts

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