Documentation ¶
Overview ¶
******************************************************************************
- Copyright 2017 Dell Inc. *
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- in compliance with the License. You may obtain a copy of the License at *
- http://www.apache.org/licenses/LICENSE-2.0 *
- Unless required by applicable law or agreed to in writing, software distributed under the License
- is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- or implied. See the License for the specific language governing permissions and limitations under
- the License. *
- @microservice: core-domain-go library
- @author: Ryan Comer & Spencer Bull, Dell
- @version: 0.5.0 ******************************************************************************
Index ¶
- Constants
- func IsAdminStateType(as string) bool
- func IsOperatingStateType(os string) bool
- type Action
- type ActionType
- type Addressable
- type AdminState
- type BaseObject
- type CallbackAlert
- type Command
- type CommandResponse
- type DescribedObject
- type Device
- type DeviceObject
- type DeviceProfile
- type DeviceReport
- type DeviceService
- type Event
- type Get
- type NotifyAction
- type OperatingState
- type ProfileProperty
- type ProfileResource
- type PropertyValue
- type Protocol
- type ProvisionWatcher
- type Put
- type Reading
- type ResourceOperation
- type Response
- type Schedule
- type ScheduleEvent
- type Service
- type Units
- type ValueDescriptor
Constants ¶
const ( PROFILE ActionType = "PROFILE" DEVICE = "DEVICE" SERVICE = "SERVICE" SCHEDULE = "SCHEDULE" SCHEDULEEVENT = "SCHEDULEEVENT" ADDRESSABLE = "ADDRESSABLE" VALUEDESCRIPTOR = "VALUEDESCRIPTOR" PROVISIONWATCHER = "PROVISIONWATCHER" REPORT = "REPORT" )
const ( MethodGet = "GET" MethodPost = "POST" )
const ( // Locked : device is locked // Unlocked : device is unlocked // locked : TODO rename all ref to Locked // unlocked : TODO rename all ref to Unlocked Locked = "LOCKED" Unlocked = "UNLOCKED" )
const ( Enabled = "ENABLED" Disabled = "DISABLED" )
Enabled : ENABLED Disabled : DISABLED enabled : TODO rename all ref to Enabled disabled : TODO rename all ref to Disabled
Variables ¶
This section is empty.
Functions ¶
func IsAdminStateType ¶
func IsOperatingStateType ¶
IsOperatingStateType : return if ostype
Types ¶
type Action ¶
type ActionType ¶
type ActionType string
type Addressable ¶
type Addressable struct { BaseObject `bson:",inline"` Id bson.ObjectId `bson:"_id,omitempty" json:"id"` Name string `bson:"name" json:"name"` Protocol string `bson:"protocol" json:"protocol"` // Protocol for the address (HTTP/TCP) HTTPMethod string `bson:"method" json:"method"` // Method for connecting (i.e. POST) Address string `bson:"address" json:"address"` // Address of the addressable Port int `bson:"port" json:"port,Number"` // Port for the address Path string `bson:"path" json:"path"` // Path for callbacks Publisher string `bson:"publisher" json:"publisher"` // For message bus protocols User string `bson:"user" json:"user"` // User id for authentication Password string `bson:"password" json:"password"` // Password of the user for authentication for the addressable Topic string `bson:"topic" json:"topic"` // Topic for message bus addressables }
* This file is the model for addressable in EdgeX * Addressable holds information about a specific address * * Addressable struct
func (Addressable) GetBaseURL ¶
func (a Addressable) GetBaseURL() string
func (Addressable) MarshalJSON ¶
func (a Addressable) MarshalJSON() ([]byte, error)
Custom marshaling for JSON Create the URL and Base URL Treat the strings as pointers so they can be null in JSON
type AdminState ¶
type AdminState string
AdminState : unlocked or locked
func (*AdminState) UnmarshalJSON ¶
func (as *AdminState) UnmarshalJSON(data []byte) error
* Unmarshal the enum type
type BaseObject ¶
type BaseObject struct { Created int64 `bson:"created" json:"created"` Modified int64 `bson:"modified" json:"modified"` Origin int64 `bson:"origin" json:"origin"` }
func (*BaseObject) String ¶
func (o *BaseObject) String() string
* String function for representing a device
type CallbackAlert ¶
type CallbackAlert struct { ActionType ActionType `json:"type"` Id string `json:"id"` }
func (CallbackAlert) MarshalJSON ¶
func (ca CallbackAlert) MarshalJSON() ([]byte, error)
Custom JSON marshaling to turn empty strings into null pointers
func (CallbackAlert) String ¶
func (ca CallbackAlert) String() string
type Command ¶
type Command struct { BaseObject `bson:",inline" yaml:",inline"` Id bson.ObjectId `bson:"_id,omitempty" json:"id"` Name string `bson:"name" json:"name" yaml:"name"` // Command name (unique on the profile) Get *Get `bson:"get" json:"get" yaml:"get"` // Get Command Put *Put `bson:"put" json:"put" yaml:"put"` // Put Command }
* This file is the model for a command in EdgeX * * * Command struct
func (*Command) AllAssociatedValueDescriptors ¶
Append all the associated value descriptors to the list Associated by PUT command parameters and PUT/GET command return values
func (Command) MarshalJSON ¶
Custom marshaling for making empty strings null
type CommandResponse ¶
type CommandResponse struct { Id bson.ObjectId `json:"id"` Name string `json:"name"` // Unique name for identifying a device AdminState AdminState `json:"adminState"` // Admin state (locked/unlocked) OperatingState OperatingState `json:"operatingState"` // Operating state (enabled/disabled) LastConnected int64 `json:"lastConnected"` // Time (milliseconds) that the device last provided any feedback or responded to any request LastReported int64 `json:"lastReported"` // Time (milliseconds) that the device reported data to the core microservice Labels []string `json:"labels"` // Other labels applied to the device to help with searching Location interface{} `json:"location"` // Device service specific location (interface{} is an empty interface so it can be anything) Commands []Command `json:"commands"` // Associated Device Profile - Describes the device }
* This file is the model for the CommandResponse object in EdgeX * * * CommandResponse struct
func CommandResponseFromDevice ¶
func CommandResponseFromDevice(d Device, cmdURL string) CommandResponse
* Create a Command Response struct from a Device Struct
func (CommandResponse) MarshalJSON ¶
func (cr CommandResponse) MarshalJSON() ([]byte, error)
Custom marshaling to make empty strings null
func (CommandResponse) String ¶
func (d CommandResponse) String() string
* String function for representing a device
type DescribedObject ¶
type DescribedObject struct { BaseObject `bson:",inline" yaml:",inline"` Description string `bson:"description" json:"description" yaml:"description"` }
func (DescribedObject) String ¶
func (o DescribedObject) String() string
* String function for DescribedObject
type Device ¶
type Device struct { DescribedObject `bson:",inline"` Id bson.ObjectId `bson:"_id,omitempty" json:"id"` Name string `bson:"name" json:"name"` // Unique name for identifying a device AdminState AdminState `bson:"adminState" json:"adminState"` // Admin state (locked/unlocked) OperatingState OperatingState `bson:"operatingState" json:"operatingState"` // Operating state (enabled/disabled) Addressable Addressable `bson:"addressable" json:"addressable"` // Addressable for the device - stores information about it's address LastConnected int64 `bson:"lastConnected" json:"lastConnected"` // Time (milliseconds) that the device last provided any feedback or responded to any request LastReported int64 `bson:"lastReported" json:"lastReported"` // Time (milliseconds) that the device reported data to the core microservice Labels []string `bson:"labels" json:"labels"` // Other labels applied to the device to help with searching Location interface{} `bson:"location" json:"location"` // Device service specific location (interface{} is an empty interface so it can be anything) Service DeviceService `bson:"service" json:"service"` // Associated Device Service - One per device Profile DeviceProfile `bson:"profile" json:"profile"` // Associated Device Profile - Describes the device }
* This file is the model for the Device object in EdgeX * * * Device struct
func (*Device) AllAssociatedValueDescriptors ¶
Return all the associated value descriptors through Put command parameters and Put/Get command return values
func (Device) MarshalJSON ¶
Custom marshaling to make empty strings null
type DeviceObject ¶
type DeviceObject struct { // DescribedObject `bson:",inline" yaml:",inline"` // Id bson.ObjectId `bson:"_id,omitempty" json:"id"` Description string `bson:"description" json:"description"` Name string `bson:"name" json:"name"` Tag string `bson:"tag" json:"tag"` // Properties ProfileProperty `bson:"profileProperty" json:"profileProperty"` Properties ProfileProperty `bson:"properties" json:"properties" yaml:"properties"` Attributes map[string]string `bson:"attributes" json:"attributes" yaml:"attributes"` }
func (DeviceObject) MarshalJSON ¶
func (do DeviceObject) MarshalJSON() ([]byte, error)
Custom marshaling to make empty strings null
func (DeviceObject) String ¶
func (do DeviceObject) String() string
* To String function for DeviceObject
type DeviceProfile ¶
type DeviceProfile struct { DescribedObject `bson:",inline" yaml:",inline"` Id bson.ObjectId `bson:"_id,omitempty" json:"id"` Name string `bson:"name" json:"name" yaml:"name"` // Non-database identifier (must be unique) Manufacturer string `bson:"manufacturer" json:"manufacturer" yaml:"manufacturer"` // Manufacturer of the device Model string `bson:"model" json:"model" yaml:"model"` // Model of the device Labels []string `bson:"labels" json:"labels" yaml:"labels,flow"` // Labels used to search for groups of profiles Objects interface{} `bson:"objects" json:"objects" yaml:"objects"` // JSON data that the device service uses to communicate with devices with this profile DeviceResources []DeviceObject `bson:"deviceResources" json:"deviceResources" yaml:"deviceResources"` Resources []ProfileResource `bson:"resources" json:"resources" yaml:"resources"` Commands []Command `bson:"commands" json:"commands" yaml:"commands"` // List of commands to Get/Put information for devices associated with this profile }
*This file is the model for a device profile in EdgeX * * * Device profile struct
func (DeviceProfile) MarshalJSON ¶
func (dp DeviceProfile) MarshalJSON() ([]byte, error)
Custom marshaling so that empty strings and arrays are null
func (DeviceProfile) String ¶
func (dp DeviceProfile) String() string
* To String function for DeviceProfile
type DeviceReport ¶
type DeviceReport struct { BaseObject `bson:",inline"` Id bson.ObjectId `bson:"_id,omitempty" json:"id"` Name string `bson:"name" json:"name"` // non-database identifier for a device report - must be unique Device string `bson:"device" json:"device"` // associated device name - should be a valid and unique device name Event string `bson:"event" json:"event"` // associated schedule event name - should be a valid and unique schedule event name Expected []string `bson:"expected" json:"expected"` // array of value descriptor names describing the types of data captured in the report }
func (DeviceReport) MarshalJSON ¶
func (dp DeviceReport) MarshalJSON() ([]byte, error)
Custom marshaling to make empty strings null
func (DeviceReport) String ¶
func (dr DeviceReport) String() string
* To String function for DeviceProfile
type DeviceService ¶
type DeviceService struct { Service AdminState AdminState `bson:"adminState" json:"adminState"` // Device Service Admin State }
func (DeviceService) MarshalJSON ¶
func (ds DeviceService) MarshalJSON() ([]byte, error)
Custom Marshaling to make empty strings null
func (DeviceService) String ¶
func (ds DeviceService) String() string
* To String function for DeviceService
func (*DeviceService) UnmarshalJSON ¶
func (ds *DeviceService) UnmarshalJSON(data []byte) error
Custom unmarshaling funcion
type Event ¶
type Event struct { ID bson.ObjectId `bson:"_id,omitempty" json:"id"` Pushed int64 `bson:"pushed" json:"pushed"` Device string `bson:"device" json:"device"` // Device identifier (name or id) Created int64 `bson:"created" json:"created"` Modified int64 `bson:"modified" json:"modified"` Origin int64 `bson:"origin" json:"origin"` Schedule string `bson:"schedule,omitempty" json:"schedule"` // Schedule identifier Event string `bson:"event",omitempty` // Schedule event identifier Readings []Reading `bson:"readings" json:"readings"` // List of readings }
* This file is for the Event model in EdgeX * * * Event struct to hold event data
func (Event) MarshalJSON ¶
Custom marshaling to make empty strings null
type Get ¶
type Get struct {
Action `bson:",inline" yaml:",inline"`
}
func (*Get) AllAssociatedValueDescriptors ¶
Append the associated value descriptors to the list
func (Get) MarshalJSON ¶
Custom marshaling to make empty strings and arrays null
type NotifyAction ¶
type NotifyAction string
const ( POST NotifyAction = "POST" PUT NotifyAction = "PUT" DELETE NotifyAction = "DELETE" GET NotifyAction = "GET" )
type OperatingState ¶
type OperatingState string
OperatingState Constant String
func (*OperatingState) UnmarshalJSON ¶
func (os *OperatingState) UnmarshalJSON(data []byte) error
UnmarshalJSON : Struct into json
type ProfileProperty ¶
type ProfileProperty struct { Value PropertyValue `bson:"value" json:"value"` Units Units `bson:"units" json:"units"` }
func (ProfileProperty) String ¶
func (pp ProfileProperty) String() string
* To String function for DeviceService
type ProfileResource ¶
type ProfileResource struct { Name string `bson:"name" json:"name"` Get []ResourceOperation `bson:"get" json:"get"` Set []ResourceOperation `bson:"set" json:"set"` }
func (ProfileResource) MarshalJSON ¶
func (pr ProfileResource) MarshalJSON() ([]byte, error)
Custom marshaling to make empty strings null
func (ProfileResource) String ¶
func (pr ProfileResource) String() string
* To String function for Profile Resource
type PropertyValue ¶
type PropertyValue struct { Type string `bson:"type" json:"type"` // ValueDescriptor Type of property after transformations ReadWrite string `bson:"readWrite" json:"readWrite" yaml:"readWrite"` // Read/Write Permissions set for this property Minimum string `bson:"minimum" json:"minimum"` // Minimum value that can be get/set from this property Maximum string `bson:"maximum" json:"maximum"` // Maximum value that can be get/set from this property DefaultValue string `bson:"defaultValue" json:"defaultValue" yaml:"defaultValue"` // Default value set to this property if no argument is passed Size string `bson:"size" json:"size"` // Size of this property in its type (i.e. bytes for numeric types, characters for string types) Word string `bson:"word" json:"word"` // Word size of property used for endianness LSB string `bson:"lsb" json:"lsb"` // Endianness setting for a property Mask string `bson:"mask" json:"mask"` // Mask to be applied prior to get/set of property Shift string `bson:"shift" json:"shift"` // Shift to be applied after masking, prior to get/set of property Scale string `bson:"scale" json:"scale"` // Multiplicative factor to be applied after shifting, prior to get/set of property Offset string `bson:"offset" json:"offset"` // Additive factor to be applied after multiplying, prior to get/set of property Base string `bson:"base" json:"base"` // Base for property to be applied to, leave 0 for no power operation (i.e. base ^ property: 2 ^ 10) Assertion string `bson:"assertion" json:"assertion"` // Required value of the property, set for checking error state. Failing an assertion condition will mark the device with an error state Signed bool `bson:"signed" json:"signed"` // Treat the property as a signed or unsigned value Precision string `bson:"precision" json:"precision"` }
func (PropertyValue) MarshalJSON ¶
func (pv PropertyValue) MarshalJSON() ([]byte, error)
Custom marshaling to make empty strings null
func (PropertyValue) String ¶
func (pv PropertyValue) String() string
* To String function for DeviceService
func (*PropertyValue) UnmarshalJSON ¶
func (p *PropertyValue) UnmarshalJSON(data []byte) error
Custom unmarshaling to handle default values
func (*PropertyValue) UnmarshalYAML ¶
func (p *PropertyValue) UnmarshalYAML(unmarshal func(interface{}) error) error
Custom YAML unmarshaling
type Protocol ¶
type Protocol byte
* HTTP - for REST communications * TCP - for MQTT and other general TCP based communications * MAC - MAC address - low level (example serial) communications * ZMQ - Zero MQ communications * SSL - for TLS encrypted sockets
func (*Protocol) UnmarshalJSON ¶
* Unmarshaller for enum type
type ProvisionWatcher ¶
type ProvisionWatcher struct { BaseObject `bson:",inline"` Id bson.ObjectId `bson:"_id,omitempty" json:"id"` Name string `bson:"name" json:"name"` // unique name and identifier of the addressable Identifiers map[string]string `bson:"identifiers" json:"identifiers"` // set of key value pairs that identify type of of address (MAC, HTTP,...) and address to watch for (00-05-1B-A1-99-99, 10.0.0.1,...) Profile DeviceProfile `bson:"profile" json:"profile"` // device profile that should be applied to the devices available at the identifier addresses Service DeviceService `bson:"service" json:"service"` // device service that owns the watcher OperatingState OperatingState `bson:"operatingState" json:"operatingState"` // operational state - either enabled or disabled }
func (ProvisionWatcher) MarshalJSON ¶
func (pw ProvisionWatcher) MarshalJSON() ([]byte, error)
Custom marshaling to make empty strings null
func (ProvisionWatcher) String ¶
func (pw ProvisionWatcher) String() string
* To String function for ProvisionWatcher
type Put ¶
type Put struct { Action `bson:",inline" yaml:",inline"` ParameterNames []string `bson:"parameterNames" json:"parameterNames" yaml:"parameterNames"` }
* This file is the model for Put commands in EdgeX * * Put Struct
func (*Put) AllAssociatedValueDescriptors ¶
Append the associated value descriptors to the list
func (Put) MarshalJSON ¶
Custom marshaling to make empty strings null
type Reading ¶
type Reading struct { Id bson.ObjectId `bson:"_id,omitempty"` Pushed int64 `bson:"pushed" json:"pushed"` // When the data was pushed out of EdgeX (0 - not pushed yet) Created int64 `bson:"created" json:"created"` // When the reading was created Origin int64 `bson:"origin" json:"origin"` Modified int64 `bson:"modified" json:"modified"` Device string `bson:"device" json:"device"` Name string `bson:"name" json:"name"` Value string `bson:"value" json:"value"` // Device sensor data value }
* This file is for the Reading model in EdgeX * Holds data that was gathered from a device * * * Struct for the Reading object in EdgeX
func (Reading) MarshalJSON ¶
Custom marshaling to make empty strings null
type ResourceOperation ¶
type ResourceOperation struct { Index string `bson:"index" json:"index"` Operation string `bson:"operation" json:"operation"` Object string `bson:"object" json:"object"` Property string `bson:"property" json:"property"` Parameter string `bson:"parameter" json:"parameter"` Resource string `bson:"resource" json:"resource"` Secondary []string `bson:"secondary" json:"secondary"` Mappings map[string]string `bson:"mappings" json:"mappings"` }
func (ResourceOperation) MarshalJSON ¶
func (ro ResourceOperation) MarshalJSON() ([]byte, error)
Custom marshaling to make empty strings null
func (ResourceOperation) String ¶
func (ro ResourceOperation) String() string
* To String function for ResourceOperation
type Response ¶
type Response struct { Code string `bson:"code" json:"code" yaml:"code"` Description string `bson:"description" json:"description" yaml:"description"` ExpectedValues []string `bson:"expectedValues" json:"expectedValues" yaml:"expectedValues"` }
* Response for a Get or Put request to a service * * * Response Struct
func (Response) MarshalJSON ¶
Custom marshalling to make empty strings null
type Schedule ¶
type Schedule struct { BaseObject `bson:",inline"` Id bson.ObjectId `bson:"_id,omitempty" json:"id"` Name string `bson:"name" json:"name"` // non-database identifier for a shcedule (*must be quitue) Start string `bson:"start" json:"start"` // Start time in ISO 8601 format YYYYMMDD'T'HHmmss @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyymmdd'T'HHmmss") End string `bson:"end" json:"end"` // Start time in ISO 8601 format YYYYMMDD'T'HHmmss @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyymmdd'T'HHmmss") Frequency string `bson:"frequency" json:"frequency"` // how frequently should the event occur Cron string `bson:"cron" json:"cron"` // cron styled regular expression indicating how often the action under schedule should occur. Use either runOnce, frequency or cron and not all. RunOnce bool `bson:"runOnce" json:"runOnce"` // boolean indicating that this schedules runs one time - at the time indicated by the start }
func (Schedule) MarshalJSON ¶
Custom marshaling to make empty strings null
type ScheduleEvent ¶
type ScheduleEvent struct { BaseObject `bson:",inline"` Id bson.ObjectId `bson:"_id,omitempty" json:"id"` Name string `bson:"name" json:"name"` // non-database unique identifier for a schedule event Schedule string `bson:"schedule" json:"schedule"` // Name to associated owning schedule Addressable Addressable `bson:"addressable" json:"addressable"` // address {MQTT topic, HTTP address, serial bus, etc.} for the action (can be empty) Parameters string `bson:"parameters" json:"parameters"` // json body for parameters Service string `bson:"service" json:"service"` // json body for parameters }
func (ScheduleEvent) MarshalJSON ¶
func (se ScheduleEvent) MarshalJSON() ([]byte, error)
Custom marshaling to make empty strings null
func (ScheduleEvent) String ¶
func (se ScheduleEvent) String() string
* To String function for ScheduleEvent
type Service ¶
type Service struct { DescribedObject `bson:",inline"` Id bson.ObjectId `bson:"_id,omitempty" json:"id"` Name string `bson:"name" json:"name"` // time in milliseconds that the device last provided any feedback or responded to any request LastConnected int64 `bson:"lastConnected" json:"lastConnected"` // time in milliseconds that the device last reported data to the core LastReported int64 `bson:"lastReported" json:"lastReported"` // operational state - either enabled or disabled OperatingState OperatingState `bson:"operatingState" json:"operatingState"` // operational state - ether enabled or disableddc Labels []string `bson:"labels" json:"labels"` // tags or other labels applied to the device service for search or other identification needs Addressable Addressable `bson:"addressable" json:"addressable"` // address (MQTT topic, HTTP address, serial bus, etc.) for reaching the service }
func (Service) MarshalJSON ¶
Custom Marshaling to make empty strings null
type Units ¶
type Units struct { Type string `bson:"type" json:"type"` ReadWrite string `bson:"readWrite" json:"readWrite" yaml:"readWrite"` DefaultValue string `bson:"defaultValue" json:"defaultValue" yaml:"defaultValue"` }
func (Units) MarshalJSON ¶
Custom marshaling to make empty strings null
type ValueDescriptor ¶
type ValueDescriptor struct { Id bson.ObjectId `json:"id" bson:"_id,omitempty"` Created int64 `bson:"created" json:"created"` Description string `bson:"description" json:"description"` Modified int64 `bson:"modified" json:"modified"` Origin int64 `bson:"origin" json:"origin"` Name string `bson:"name" json:"name"` Min interface{} `bson:"min,omitempty" json:"min"` Max interface{} `bson:"max,omitempty" json:"max"` DefaultValue interface{} `bson:"defaultValue,omitempty" json:"defaultValue"` Type string `bson:"type" json:"type"` UomLabel string `bson:"uomLabel,omitempty" json:"uomLabel"` Formatting string `bson:"formatting,omitempty" json:"formatting"` Labels []string `bson:"labels,omitempty" json:"labels"` }
* Value Descriptor Struct
func (ValueDescriptor) MarshalJSON ¶
func (v ValueDescriptor) MarshalJSON() ([]byte, error)
Custom marshaling to make empty strings null
func (ValueDescriptor) String ¶
func (a ValueDescriptor) String() string
* To String function for ValueDescriptor Struct
Source Files ¶
- action.go
- actiontype.go
- addressable.go
- adminstate.go
- baseobject.go
- callbackalert.go
- command.go
- commandresponse.go
- describedobject.go
- device.go
- deviceobject.go
- deviceprofile.go
- devicereport.go
- deviceservice.go
- event.go
- get.go
- notifyaction.go
- operatingstate.go
- profileproperty.go
- profileresource.go
- propertyvalue.go
- protocol.go
- provisionwatcher.go
- put.go
- reading.go
- resourceoperation.go
- response.go
- schedule.go
- scheduleevent.go
- service.go
- units.go
- value-descriptor.go