Documentation ¶
Index ¶
- Constants
- func IsNotificationsCategory(as string) bool
- func IsNotificationsSeverity(as string) bool
- func IsNotificationsStatus(as string) bool
- func IsTransmissionStatus(as string) bool
- func NewErrContractInvalid(message string) error
- type Action
- type ActionType
- type Addressable
- type AdminState
- type AutoEvent
- type CallbackAlert
- type Channel
- type ChannelType
- type Command
- type CommandResponse
- type DescribedObject
- type Device
- type DeviceProfile
- type DeviceReportdeprecated
- type DeviceResource
- type DeviceService
- type EncryptionDetails
- type ErrContractInvalid
- type Event
- type Filter
- type Get
- type Interval
- type IntervalAction
- type LogEntry
- type Notification
- type NotificationsCategory
- type NotificationsSeverity
- type NotificationsStatus
- type OperatingState
- type Operation
- type ProfileProperty
- type ProfileResource
- type PropertyValue
- type ProtocolProperties
- type ProvisionWatcher
- type Put
- type Reading
- type ResourceOperation
- type Response
- type Subscription
- type Timestamps
- type Transmission
- type TransmissionRecord
- type TransmissionStatus
- type Units
- type Validator
- type ValueDescriptor
Constants ¶
const ( PROFILE ActionType = "PROFILE" DEVICE = "DEVICE" SERVICE = "SERVICE" SCHEDULE = "SCHEDULE" SCHEDULEEVENT = "SCHEDULEEVENT" ADDRESSABLE = "ADDRESSABLE" VALUEDESCRIPTOR = "VALUEDESCRIPTOR" PROVISIONWATCHER = "PROVISIONWATCHER" REPORT = "REPORT" )
const ( // Locked : device is locked // Unlocked : device is unlocked Locked = "LOCKED" Unlocked = "UNLOCKED" )
const ( Security = "SECURITY" Hwhealth = "HW_HEALTH" Swhealth = "SW_HEALTH" )
const ( Rest = "REST" Email = "EMAIL" )
const ( EncNone = "NONE" EncAes = "AES" )
Encryption types
const ( TraceLog = "TRACE" DebugLog = "DEBUG" InfoLog = "INFO" WarnLog = "WARN" ErrorLog = "ERROR" )
These constants identify the log levels in order of increasing severity.
const ( Enabled = "ENABLED" Disabled = "DISABLED" )
Enabled : ENABLED Disabled : DISABLED
const ( // Base64Encoding : the float value is represented in Base64 encoding Base64Encoding = "Base64" // ENotation : the float value is represented in eNotation ENotation = "eNotation" )
const ( ValueTypeBool = "Bool" ValueTypeString = "String" ValueTypeUint8 = "Uint8" ValueTypeUint16 = "Uint16" ValueTypeUint32 = "Uint32" ValueTypeUint64 = "Uint64" ValueTypeInt8 = "Int8" ValueTypeInt16 = "Int16" ValueTypeInt32 = "Int32" ValueTypeInt64 = "Int64" ValueTypeFloat32 = "Float32" ValueTypeFloat64 = "Float64" ValueTypeBinary = "Binary" ValueTypeBoolArray = "BoolArray" ValueTypeStringArray = "StringArray" ValueTypeUint8Array = "Uint8Array" ValueTypeUint16Array = "Uint16Array" ValueTypeUint32Array = "Uint32Array" ValueTypeUint64Array = "Uint64Array" ValueTypeInt8Array = "Int8Array" ValueTypeInt16Array = "Int16Array" ValueTypeInt32Array = "Int32Array" ValueTypeInt64Array = "Int64Array" ValueTypeFloat32Array = "Float32Array" ValueTypeFloat64Array = "Float64Array" )
Constants related to Reading ValueTypes
const ( Critical = "CRITICAL" Normal = "NORMAL" )
const ( New = "NEW" Processed = "PROCESSED" Escalated = "ESCALATED" )
const ( Failed = "FAILED" Sent = "SENT" Acknowledged = "ACKNOWLEDGED" Trxescalated = "TRXESCALATED" )
const (
ValidateTag = "validate"
)
Variables ¶
This section is empty.
Functions ¶
func IsNotificationsCategory ¶
IsNotificationsCategory allows external code to verify whether the supplied string is a valid NotificationsCategory value
func IsNotificationsSeverity ¶
func IsNotificationsStatus ¶
func IsTransmissionStatus ¶
func NewErrContractInvalid ¶
NewErrContractInvalid returns an instance of the error interface with ErrContractInvalid as its implementation.
Types ¶
type Action ¶
type Action struct { Path string `json:"path,omitempty" yaml:"path,omitempty"` // Path used by service for action on a device or sensor Responses []Response `json:"responses,omitempty" yaml:"responses,omitempty"` // Responses from get or put requests to service URL string `json:"url,omitempty" yaml:"url,omitempty"` // Url for requests from command service }
Action describes state related to the capabilities of a device
type Addressable ¶
type Addressable struct { Timestamps Id string `json:"id,omitempty"` // ID is a unique identifier for the Addressable, such as a UUID Name string `json:"name,omitempty"` // Name is a unique name given to the Addressable Protocol string `json:"protocol,omitempty"` // Protocol for the address (HTTP/TCP) HTTPMethod string `json:"method,omitempty"` // Method for connecting (i.e. POST) Address string `json:"address,omitempty"` // Address of the addressable Port int `json:"port,omitempty,Number"` // Port for the address Path string `json:"path,omitempty"` // Path for callbacks Publisher string `json:"publisher,omitempty"` // For message bus protocols User string `json:"user,omitempty"` // User id for authentication Password string `json:"password,omitempty"` // Password of the user for authentication for the addressable Topic string `json:"topic,omitempty"` // Topic for message bus addressables // contains filtered or unexported fields }
Addressable holds information indicating how to contact a specific endpoint
func (Addressable) GetBaseURL ¶
func (a Addressable) GetBaseURL() string
GetBaseURL returns a base URL consisting of protocol, host and port as a string assembled from the constituent parts of the Addressable
func (Addressable) GetCallbackURL ¶
func (a Addressable) GetCallbackURL() string
GetCallbackURL returns the callback url for the addressable if all relevant tokens have values. If any token is missing, string will be empty. Tokens include protocol, address, port and path.
func (Addressable) MarshalJSON ¶
func (a Addressable) MarshalJSON() ([]byte, error)
MarshalJSON implements the Marshaler interface for the Addressable type Use custom logic to create the URL and Base URL
func (Addressable) String ¶
func (a Addressable) String() string
String returns a JSON encoded string representation of the addressable.
func (*Addressable) UnmarshalJSON ¶
func (a *Addressable) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the Unmarshaler interface for the Addressable type
func (Addressable) Validate ¶
func (a Addressable) Validate() (bool, error)
Validate satisfies the Validator interface
type AdminState ¶
type AdminState string
AdminState controls the range of values which constitute valid administrative states for a device
func GetAdminState ¶
func GetAdminState(as string) (AdminState, bool)
GetAdminState is called from within the router logic of the core services. For example, there are PUT calls like the one below from core-metadata which specify their update parameters in the URL
d.HandleFunc("/{"+ID+"}/"+URLADMINSTATE+"/{"+ADMINSTATE+"}", restSetDeviceAdminStateById).Methods(http.MethodPut)
Updates like this should be refactored to pass a body containing the new values instead of via the URL. This would allow us to utilize the model validation above and remove the logic from the controller.
This will be removed once work on the following issue begins -- https://github.com/edgexfoundry/edgex-go/issues/1244
func (*AdminState) UnmarshalJSON ¶
func (as *AdminState) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the Unmarshaler interface for the enum type
func (AdminState) Validate ¶
func (as AdminState) Validate() (bool, error)
Validate satisfies the Validator interface
type AutoEvent ¶
type AutoEvent struct { // Frequency indicates how often the specific resource needs to be polled. // It represents as a duration string. // The format of this field is to be an unsigned integer followed by a unit which may be "ms", "s", "m" or "h" // representing milliseconds, seconds, minutes or hours. Eg, "100ms", "24h" Frequency string `json:"frequency,omitempty"` // OnChange indicates whether the device service will generate an event only, // if the reading value is different from the previous one. // If true, only generate events when readings change OnChange bool `json:"onChange,omitempty"` // Resource indicates the name of the resource in the device profile which describes the event to generate Resource string `json:"resource,omitempty"` }
AutoEvent supports auto-generated events sourced from a device service
type CallbackAlert ¶
type CallbackAlert struct { ActionType ActionType `json:"type,omitempty"` Id string `json:"id,omitempty"` }
CallbackAlert indicates an action to take when a callback fires.
func (CallbackAlert) String ¶
func (ca CallbackAlert) String() string
* String function for representing a CallbackAlert
type Channel ¶
type Channel struct { Type ChannelType `json:"type,omitempty"` // Type indicates whether the channel facilitates email or REST MailAddresses []string `json:"mailAddresses,omitempty"` // MailAddresses contains email addresses Url string `json:"url,omitempty"` // URL contains a REST API destination }
Channel supports transmissions and notifications with fields for delivery via email or REST
type ChannelType ¶
type ChannelType string
ChannelType controls the range of values which constitute valid delivery types for channels
func (*ChannelType) UnmarshalJSON ¶
func (as *ChannelType) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the Unmarshaler interface for the type
func (ChannelType) Validate ¶
func (as ChannelType) Validate() (bool, error)
type Command ¶
type Command struct { Timestamps `yaml:",inline"` Id string `json:"id" yaml:"id,omitempty"` // Id is a unique identifier, such as a UUID Name string `json:"name" yaml:"name,omitempty"` // Command name (unique on the profile) Get Get `json:"get" yaml:"get,omitempty"` // Get Command Put Put `json:"put" yaml:"put,omitempty"` // Put Command // contains filtered or unexported fields }
Command defines a specific read/write operation targeting a device
func (*Command) AllAssociatedValueDescriptors ¶
AllAssociatedValueDescriptors will append all the associated value descriptors to the list associated by PUT command parameters and PUT/GET command return values
func (Command) MarshalJSON ¶
MarshalJSON implements the Marshaler interface. Empty strings will be null.
func (*Command) UnmarshalJSON ¶
UnmarshalJSON implements the Unmarshaler interface for the Command type
type CommandResponse ¶
type CommandResponse struct { Id string `json:"id,omitempty"` // Id uniquely identifies the CommandResponse, UUID for example. Name string `json:"name,omitempty"` // Unique name for identifying a device AdminState AdminState `json:"adminState,omitempty"` // Admin state (locked/unlocked) OperatingState OperatingState `json:"operatingState,omitempty"` // Operating state (enabled/disabled) LastConnected int64 `json:"lastConnected,omitempty"` // Time (milliseconds) that the device last provided any feedback or responded to any request LastReported int64 `json:"lastReported,omitempty"` // Time (milliseconds) that the device reported data to the core microservice Labels []string `json:"labels,omitempty"` // Other labels applied to the device to help with searching Location interface{} `json:"location,omitempty"` // Device service specific location (interface{} is an empty interface so it can be anything) Commands []Command `json:"commands,omitempty"` // Associated Device Profile - Describes the device }
CommandResponse identifies a specific device along with its supported commands.
func CommandResponseFromDevice ¶
func CommandResponseFromDevice(d Device, commands []Command, cmdURL string) CommandResponse
* CommandResponseFromDevice will create a CommandResponse struct from the supplied Device struct
func (CommandResponse) String ¶
func (d CommandResponse) String() string
* String function for representing a device
type DescribedObject ¶
type DescribedObject struct { Timestamps `yaml:",inline"` Description string `json:"description,omitempty" yaml:"description,omitempty"` // Description. Capicé? }
DescribedObject is a hold-over from the Java conversion and is supposed to represent inheritance whereby a type with a Description property IS A DescribedObject. However since there is no inheritance in Go, this should be eliminated and the Description property moved to the relevant types. 4 types currently use this.
func (DescribedObject) String ¶
func (o DescribedObject) String() string
String returns a JSON formatted string representation of this DescribedObject
type Device ¶
type Device struct { DescribedObject Id string `json:"id"` // ID uniquely identifies the device, a UUID for example 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) Protocols map[string]ProtocolProperties `json:"protocols"` // A map of supported protocols for the given device 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) Service DeviceService `json:"service"` // Associated Device Service - One per device Profile DeviceProfile `json:"profile"` // Associated Device Profile - Describes the device AutoEvents []AutoEvent `json:"autoEvents"` // A list of auto-generated events coming from the device // contains filtered or unexported fields }
Device represents a registered device participating within the EdgeX Foundry ecosystem
func (*Device) AllAssociatedValueDescriptors ¶
AllAssociatedValueDescriptors returns all the associated value descriptors through Put command parameters and Put/Get command return values
func (Device) MarshalJSON ¶
MarshalJSON implements the Marshaler interface in order to make empty strings null
func (*Device) UnmarshalJSON ¶
UnmarshalJSON implements the Unmarshaler interface for the Device type
type DeviceProfile ¶
type DeviceProfile struct { DescribedObject `yaml:",inline"` Id string `json:"id,omitempty" yaml:"id,omitempty"` Name string `json:"name,omitempty" yaml:"name,omitempty"` // Non-database identifier (must be unique) Manufacturer string `json:"manufacturer,omitempty" yaml:"manufacturer,omitempty"` // Manufacturer of the device Model string `json:"model,omitempty" yaml:"model,omitempty"` // Model of the device Labels []string `json:"labels,omitempty" yaml:"labels,flow,omitempty"` // Labels used to search for groups of profiles DeviceResources []DeviceResource `json:"deviceResources,omitempty" yaml:"deviceResources,omitempty"` DeviceCommands []ProfileResource `json:"deviceCommands,omitempty" yaml:"deviceCommands,omitempty"` CoreCommands []Command `json:"coreCommands,omitempty" yaml:"coreCommands,omitempty"` // List of commands to Get/Put information for devices associated with this profile // contains filtered or unexported fields }
DeviceProfile represents the attributes and operational capabilities of a device. It is a template for which there can be multiple matching devices within a given system.
func (DeviceProfile) String ¶
func (dp DeviceProfile) String() string
* To String function for DeviceProfile
func (*DeviceProfile) UnmarshalJSON ¶
func (dp *DeviceProfile) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the Unmarshaler interface for the DeviceProfile type
func (DeviceProfile) Validate ¶
func (dp DeviceProfile) Validate() (bool, error)
Validate satisfies the Validator interface
type DeviceReport
deprecated
type DeviceReport struct { Timestamps Id string `json:"id,omitempty"` Name string `json:"name,omitempty"` // non-database identifier for a device report - must be unique Device string `json:"device,omitempty"` // associated device name - should be a valid and unique device name Action string `json:"action,omitempty"` // associated interval action name - should be a valid and unique interval action name Expected []string `json:"expected,omitempty"` // array of value descriptor names describing the types of data captured in the report }
Deprecated: DeviceReport isn't utilized and needs to be removed.
func (DeviceReport) String ¶
func (dr DeviceReport) String() string
* To String function for DeviceProfile
type DeviceResource ¶
type DeviceResource struct { Description string `json:"description" yaml:"description,omitempty"` Name string `json:"name" yaml:"name,omitempty"` Tag string `json:"tag" yaml:"tag,omitempty"` Properties ProfileProperty `json:"properties" yaml:"properties"` Attributes map[string]string `json:"attributes" yaml:"attributes,omitempty"` }
DeviceResource represents a value on a device that can be read or written
func (DeviceResource) MarshalJSON ¶
func (do DeviceResource) MarshalJSON() ([]byte, error)
MarshalJSON implements the Marshaler interface in order to make empty strings null
func (DeviceResource) String ¶
func (do DeviceResource) String() string
* To String function for DeviceResource
type DeviceService ¶
type DeviceService struct { DescribedObject Id string `json:"id"` Name string `json:"name"` // time in milliseconds that the device last provided any feedback or responded to any request LastConnected int64 `json:"lastConnected"` // time in milliseconds that the device last reported data to the core LastReported int64 `json:"lastReported"` // operational state - either enabled or disabled OperatingState OperatingState `json:"operatingState"` // operational state - ether enabled or disableddc Labels []string `json:"labels"` // tags or other labels applied to the device service for search or other identification needs Addressable Addressable `json:"addressable"` // address (MQTT topic, HTTP address, serial bus, etc.) for reaching the service AdminState AdminState `json:"adminState"` // Device Service Admin State // contains filtered or unexported fields }
DeviceService represents a service that is responsible for proxying connectivity between a set of devices and the EdgeX Foundry core services.
func (DeviceService) MarshalJSON ¶
func (ds DeviceService) MarshalJSON() ([]byte, error)
MarshalJSON implements the Marshaler interface in order 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
UnmarshalJSON implements the Unmarshaler interface for the DeviceService type
func (DeviceService) Validate ¶
func (ds DeviceService) Validate() (bool, error)
Validate satisfies the Validator interface
type EncryptionDetails ¶
type EncryptionDetails struct { Algo string `json:"encryptionAlgorithm,omitempty"` Key string `json:"encryptionKey,omitempty"` InitVector string `json:"initializingVector,omitempty"` }
EncryptionDetails - Provides details for encryption of export data per client request
type ErrContractInvalid ¶
type ErrContractInvalid struct {
// contains filtered or unexported fields
}
ErrContractInvalid is a specific error type for handling model validation failures. Type checking within the calling application will facilitate more explicit error handling whereby it's clear that validation has failed as opposed to something unexpected happening.
func (ErrContractInvalid) Error ¶
func (e ErrContractInvalid) Error() string
Error fulfills the error interface and returns an error message assembled from the state of ErrContractInvalid.
type Event ¶
type Event struct { ID string `json:"id,omitempty" codec:"id,omitempty"` // ID uniquely identifies an event, for example a UUID Pushed int64 `json:"pushed,omitempty" codec:"pushed,omitempty"` // Pushed is a timestamp indicating when the event was exported. If unexported, the value is zero. Device string `json:"device,omitempty" codec:"device,omitempty"` // Device identifies the source of the event, can be a device name or id. Usually the device name. Created int64 `json:"created,omitempty" codec:"created,omitempty"` // Created is a timestamp indicating when the event was created. Modified int64 `json:"modified,omitempty" codec:"modified,omitempty"` // Modified is a timestamp indicating when the event was last modified. Origin int64 `json:"origin,omitempty" codec:"origin,omitempty"` // Origin is a timestamp that can communicate the time of the original reading, prior to event creation Readings []Reading `json:"readings,omitempty" codec:"readings,omitempty"` // Readings will contain zero to many entries for the associated readings of a given event. // contains filtered or unexported fields }
Event represents a single measurable event read from a device
func (*Event) UnmarshalJSON ¶
UnmarshalJSON implements the Unmarshaler interface for the Event type
type Filter ¶
type Filter struct { DeviceIDs []string `json:"deviceIdentifiers,omitempty"` ValueDescriptorIDs []string `json:"valueDescriptorIdentifiers,omitempty"` }
Filter - Specifies the client filters on reading data
type Get ¶
type Get struct {
Action `json:",omitempty" yaml:",inline"`
}
func (*Get) AllAssociatedValueDescriptors ¶
Append the associated value descriptors to the list
type Interval ¶
type Interval struct { Timestamps Timestamps ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` // non-database identifier for a shcedule (*must be quitue) Start string `json:"start,omitempty"` // Start time i ISO 8601 format YYYYMMDD'T'HHmmss End string `json:"end,omitempty"` // Start time i ISO 8601 format YYYYMMDD'T'HHmmss Frequency string `json:"frequency,omitempty"` // how frequently should the event occur according ISO 8601 Cron string `json:"cron,omitempty"` // cron styled regular expression indicating how often the action under interval should occur. Use either runOnce, frequency or cron and not all. RunOnce bool `json:"runOnce,omitempty"` // boolean indicating that this interval runs one time - at the time indicated by the start // contains filtered or unexported fields }
Interval a period of time
func (Interval) MarshalJSON ¶
Custom marshaling to make empty strings null
func (*Interval) UnmarshalJSON ¶
UnmarshalJSON implements the Unmarshaler interface for the Interval type
type IntervalAction ¶
type IntervalAction struct { ID string `json:"id,omitempty"` Created int64 `json:"created,omitempty"` Modified int64 `json:"modified,omitempty"` Origin int64 `json:"origin,omitempty"` Name string `json:"name,omitempty"` Interval string `json:"interval,omitempty"` Parameters string `json:"parameters,omitempty"` Target string `json:"target,omitempty"` Protocol string `json:"protocol,omitempty"` HTTPMethod string `json:"httpMethod,omitempty"` Address string `json:"address,omitempty"` Port int `json:"port,omitempty"` Path string `json:"path,omitempty"` Publisher string `json:"publisher,omitempty"` User string `json:"user,omitempty"` Password string `json:"password,omitempty"` Topic string `json:"topic,omitempty"` // contains filtered or unexported fields }
func (IntervalAction) GetBaseURL ¶
func (ia IntervalAction) GetBaseURL() string
func (IntervalAction) String ¶
func (ia IntervalAction) String() string
func (*IntervalAction) UnmarshalJSON ¶
func (ia *IntervalAction) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the Unmarshaler interface for the IntervalAction type
func (IntervalAction) Validate ¶
func (ia IntervalAction) Validate() (bool, error)
Validate satisfies the Validator interface
type LogEntry ¶
type LogEntry struct { Level string `bson:"logLevel,omitempty" json:"logLevel"` Args []interface{} `bson:"args,omitempty" json:"args"` OriginService string `bson:"originService,omitempty" json:"originService"` Message string `bson:"message,omitempty" json:"message"` Created int64 `bson:"created,omitempty" json:"created"` // contains filtered or unexported fields }
func (*LogEntry) UnmarshalJSON ¶
UnmarshalJSON implements the Unmarshaler interface for the LogEntry type
type Notification ¶
type Notification struct { Timestamps ID string `json:"id,omitempty"` Slug string `json:"slug,omitempty"` Sender string `json:"sender,omitempty"` Category NotificationsCategory `json:"category,omitempty"` Severity NotificationsSeverity `json:"severity,omitempty"` Content string `json:"content,omitempty"` Description string `json:"description,omitempty"` Status NotificationsStatus `json:"status,omitempty"` Labels []string `json:"labels,omitempty"` ContentType string `json:"contenttype,omitempty"` // contains filtered or unexported fields }
func (Notification) MarshalJSON ¶
func (n Notification) MarshalJSON() ([]byte, error)
func (Notification) String ¶
func (n Notification) String() string
* To String function for Notification Struct
func (*Notification) UnmarshalJSON ¶
func (n *Notification) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the Unmarshaler interface for the Notification type
func (Notification) Validate ¶
func (n Notification) Validate() (bool, error)
Validate satisfies the Validator interface
type NotificationsCategory ¶
type NotificationsCategory string
NotificationsCategory controls the range of values which constitute valid categories for notifications
func (*NotificationsCategory) UnmarshalJSON ¶
func (as *NotificationsCategory) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the Unmarshaler interface for the type
type NotificationsSeverity ¶
type NotificationsSeverity string
func (*NotificationsSeverity) UnmarshalJSON ¶
func (as *NotificationsSeverity) UnmarshalJSON(data []byte) error
type NotificationsStatus ¶
type NotificationsStatus string
func (*NotificationsStatus) UnmarshalJSON ¶
func (as *NotificationsStatus) UnmarshalJSON(data []byte) error
type OperatingState ¶
type OperatingState string
OperatingState Constant String
func GetOperatingState ¶
func GetOperatingState(os string) (OperatingState, bool)
GetOperatingState is called from within the router logic of the core services. For example, there are PUT calls like the one below from core-metadata which specify their update parameters in the URL
d.HandleFunc("/{"+ID+"}/"+OPSTATE+"/{"+OPSTATE+"}", restSetDeviceOpStateById).Methods(http.MethodPut)
Updates like this should be refactored to pass a body containing the new values instead of via the URL. This would allow us to utilize the model validation above and remove the logic from the controller.
This will be removed once work on the following issue begins -- https://github.com/edgexfoundry/edgex-go/issues/1244
func (*OperatingState) UnmarshalJSON ¶
func (os *OperatingState) UnmarshalJSON(data []byte) error
UnmarshalJSON : Struct into json
func (OperatingState) Validate ¶
func (os OperatingState) Validate() (bool, error)
Validate satisfies the Validator interface
type Operation ¶
type Operation struct { Action string `bson:"action" json:"action,omitempty"` Services []string `bson:"services,omitempty" json:"services,omitempty"` }
* An Operation for SMA processing. * * * Operation struct
func (*Operation) UnmarshalJSON ¶
Implements unmarshaling of JSON string to Operation type instance
type ProfileProperty ¶
type ProfileProperty struct { Value PropertyValue `json:"value"` Units Units `json:"units"` }
func (ProfileProperty) MarshalJSON ¶
func (pp ProfileProperty) MarshalJSON() ([]byte, error)
MarshalJSON implements the Marshaler interface
func (ProfileProperty) String ¶
func (pp ProfileProperty) String() string
String returns a JSON encoded string representation of this ProfileProperty
type ProfileResource ¶
type ProfileResource struct { Name string `json:"name,omitempty" yaml:"name,omitempty"` Get []ResourceOperation `json:"get,omitempty" yaml:"get,omitempty"` Set []ResourceOperation `json:"set,omitempty" yaml:"set,omitempty"` }
func (ProfileResource) String ¶
func (pr ProfileResource) String() string
String returns a JSON encoded string representation of the model
type PropertyValue ¶
type PropertyValue struct { Type string `json:"type,omitempty" yaml:"type,omitempty"` // ValueDescriptor Type of property after transformations ReadWrite string `json:"readWrite,omitempty" yaml:"readWrite,omitempty"` // Read/Write Permissions set for this property Minimum string `json:"minimum,omitempty" yaml:"minimum,omitempty"` // Minimum value that can be get/set from this property Maximum string `json:"maximum,omitempty" yaml:"maximum,omitempty"` // Maximum value that can be get/set from this property DefaultValue string `json:"defaultValue,omitempty" yaml:"defaultValue,omitempty"` // Default value set to this property if no argument is passed Size string `json:"size,omitempty" yaml:"size,omitempty"` // Size of this property in its type (i.e. bytes for numeric types, characters for string types) Mask string `json:"mask,omitempty" yaml:"mask,omitempty"` // Mask to be applied prior to get/set of property Shift string `json:"shift,omitempty" yaml:"shift,omitempty"` // Shift to be applied after masking, prior to get/set of property Scale string `json:"scale,omitempty" yaml:"scale,omitempty"` // Multiplicative factor to be applied after shifting, prior to get/set of property Offset string `json:"offset,omitempty" yaml:"offset,omitempty"` // Additive factor to be applied after multiplying, prior to get/set of property Base string `json:"base,omitempty" yaml:"base,omitempty"` // Base for property to be applied to, leave 0 for no power operation (i.e. base ^ property: 2 ^ 10) Assertion string `json:"assertion,omitempty" yaml:"assertion,omitempty"` // Required value of the property, set for checking error state. Failing an assertion condition will mark the device with an error state Precision string `json:"precision,omitempty" yaml:"precision,omitempty"` FloatEncoding string `json:"floatEncoding,omitempty" yaml:"floatEncoding,omitempty"` // FloatEncoding indicates the representation of floating value of reading. It should be 'Base64' or 'eNotation' MediaType string `json:"mediaType,omitempty" yaml:"mediaType,omitempty"` RequestType string `json:"requestType,omitempty" yaml:"requestType,omitempty"` }
func (PropertyValue) String ¶
func (pv PropertyValue) String() string
String returns a JSON encoded string representation of the model
type ProtocolProperties ¶
ProtocolProperties contains the device connection information in key/value pair
type ProvisionWatcher ¶
type ProvisionWatcher struct { Timestamps Id string `json:"id"` Name string `json:"name"` // unique name and identifier of the provision watcher Identifiers map[string]string `json:"identifiers"` // set of key value pairs that identify property (MAC, HTTP,...) and value to watch for (00-05-1B-A1-99-99, 10.0.0.1,...) BlockingIdentifiers map[string][]string `json:"blockingidentifiers"` // set of key-values pairs that identify devices which will not be added despite matching on Identifiers Profile DeviceProfile `json:"profile"` // device profile that should be applied to the devices available at the identifier addresses Service DeviceService `json:"service"` // device service that new devices will be associated to AdminState AdminState `json:"adminState"` // administrative state for new devices - either unlocked or locked OperatingState OperatingState `validate:"-"` // Deprecated: exists for historical compatibility and will be ignored // contains filtered or unexported fields }
func (ProvisionWatcher) MarshalJSON ¶
func (pw ProvisionWatcher) MarshalJSON() ([]byte, error)
MarshalJSON returns a JSON encoded byte representation of the model
func (ProvisionWatcher) String ¶
func (pw ProvisionWatcher) String() string
String returns a JSON encoded string representation of the model
func (*ProvisionWatcher) UnmarshalJSON ¶
func (pw *ProvisionWatcher) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the Unmarshaler interface for the ProvisionWatcher type
func (ProvisionWatcher) Validate ¶
func (pw ProvisionWatcher) Validate() (bool, error)
Validate satisfies the Validator interface
type Put ¶
type Put struct { Action `yaml:",inline"` ParameterNames []string `json:"parameterNames,omitempty" yaml:"parameterNames,omitempty"` }
Put models a put command in EdgeX
func (*Put) AllAssociatedValueDescriptors ¶
Append the associated value descriptors to the list
type Reading ¶
type Reading struct { Id string `json:"id,omitempty" codec:"id,omitempty"` Pushed int64 `json:"pushed,omitempty" codec:"pushed,omitempty"` // When the data was pushed out of EdgeX (0 - not pushed yet) Created int64 `json:"created,omitempty" codec:"created,omitempty"` // When the reading was created Origin int64 `json:"origin,omitempty" codec:"origin,omitempty"` Modified int64 `json:"modified,omitempty" codec:"modified,omitempty"` Device string `json:"device,omitempty" codec:"device,omitempty"` Name string `json:"name,omitempty" codec:"name,omitempty"` Value string `json:"value,omitempty" codec:"value,omitempty"` // Device sensor data value ValueType string `json:"valueType,omitempty" codec:"valueType,omitempty"` FloatEncoding string `json:"floatEncoding,omitempty" codec:"floatEncoding,omitempty"` // BinaryValue binary data payload. This information is not persisted in the Database and is expected to be empty // when retrieving a Reading for the ValueType of Binary. BinaryValue []byte `json:"binaryValue,omitempty" codec:"binaryValue,omitempty"` MediaType string `json:"mediaType,omitempty" codec:"mediaType,omitempty"` RequestType string `json:"requestType,omitempty" codes:"requestType,omitempty"` // contains filtered or unexported fields }
Reading contains data that was gathered from a device.
NOTE a Reading's BinaryValue is not to be persisted in the database. This architectural decision requires that serialization validation be relaxed for enforcing the presence of binary data for Binary ValueTypes. Also, that issuing GET operations to obtain Readings directly or indirectly via Events will result in a Reading with no BinaryValue for Readings with a ValueType of Binary. BinaryValue is to be present when creating or updating a Reading either directly, indirectly via an Event, and when the information is put on the EventBus.
func (*Reading) UnmarshalJSON ¶
UnmarshalJSON implements the Unmarshaler interface for the Reading type
type ResourceOperation ¶
type ResourceOperation struct { Index string `json:"index" yaml:"index,omitempty"` Operation string `json:"operation" yaml:"operation,omitempty"` Object string `json:"object" yaml:"object,omitempty"` // Deprecated DeviceResource string `json:"deviceResource" yaml:"deviceResource,omitempty"` // The replacement of Object field Parameter string `json:"parameter" yaml:"parameter,omitempty"` Resource string `json:"resource" yaml:"resource,omitempty"` // Deprecated DeviceCommand string `json:"deviceCommand" yaml:"deviceCommand,omitempty"` // The replacement of Resource field Secondary []string `json:"secondary" yaml:"secondary,omitempty"` Mappings map[string]string `json:"mappings" yaml:"mappings,omitempty"` // contains filtered or unexported fields }
func (ResourceOperation) MarshalJSON ¶
func (ro ResourceOperation) MarshalJSON() ([]byte, error)
MarshalJSON returns a JSON encoded byte representation of the model and performs custom autofill
func (ResourceOperation) String ¶
func (ro ResourceOperation) String() string
String returns a JSON encoded string representation of the model
func (*ResourceOperation) UnmarshalJSON ¶
func (ro *ResourceOperation) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the Unmarshaler interface for the ResourceOperation type
func (ResourceOperation) Validate ¶
func (ro ResourceOperation) Validate() (bool, error)
Validate satisfies the Validator interface
type Response ¶
type Response struct { Code string `json:"code,omitempty" yaml:"code,omitempty"` Description string `json:"description,omitempty" yaml:"description,omitempty"` ExpectedValues []string `json:"expectedValues,omitempty" yaml:"expectedValues,omitempty"` }
Response for a Get or Put request to a service
type Subscription ¶
type Subscription struct { Timestamps ID string `json:"id,omitempty"` Slug string `json:"slug,omitempty"` Receiver string `json:"receiver,omitempty"` Description string `json:"description,omitempty"` SubscribedCategories []NotificationsCategory `json:"subscribedCategories,omitempty"` SubscribedLabels []string `json:"subscribedLabels,omitempty"` Channels []Channel `json:"channels,omitempty"` }
Subscription represents an object for notification alerts
func (Subscription) String ¶
func (s Subscription) String() string
String returns a JSON encoded string representation of the model
type Timestamps ¶
type Timestamps struct { Created int64 `json:"created,omitempty" yaml:"created,omitempty"` Modified int64 `json:"modified,omitempty" yaml:"modified,omitempty"` Origin int64 `json:"origin,omitempty" yaml:"origin,omitempty"` }
func (*Timestamps) String ¶
func (ts *Timestamps) String() string
String returns a JSON encoded string representation of the model
type Transmission ¶
type Transmission struct { Timestamps ID string `json:"id"` Notification Notification `json:"notification"` Receiver string `json:"receiver,omitempty"` Channel Channel `json:"channel,omitempty"` Status TransmissionStatus `json:"status,omitempty"` ResendCount int `json:"resendcount"` Records []TransmissionRecord `json:"records,omitempty"` // contains filtered or unexported fields }
func (Transmission) MarshalJSON ¶
func (t Transmission) MarshalJSON() ([]byte, error)
Marshal returns a JSON encoded byte array representation of the model
func (Transmission) String ¶
func (t Transmission) String() string
String returns a JSON encoded string representation of the model
func (*Transmission) UnmarshalJSON ¶
func (t *Transmission) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the Unmarshaler interface for the Transmission type
func (Transmission) Validate ¶
func (t Transmission) Validate() (bool, error)
Validate satisfies the Validator interface
type TransmissionRecord ¶
type TransmissionRecord struct { Status TransmissionStatus `json:"status,omitempty"` Response string `json:"response,omitempty"` Sent int64 `json:"sent,omitempty"` }
func (TransmissionRecord) String ¶
func (t TransmissionRecord) String() string
String returns a JSON encoded string representation of the model
type TransmissionStatus ¶
type TransmissionStatus string
func (*TransmissionStatus) UnmarshalJSON ¶
func (as *TransmissionStatus) UnmarshalJSON(data []byte) error
* Unmarshal the enum type
func (TransmissionStatus) Validate ¶
func (as TransmissionStatus) Validate() (bool, error)
type Units ¶
type Validator ¶
type Validator interface { // Validate performs integrity checks on the internal state of the model. It returns a boolean indicating whether // the validation passed or not, and the associated error if validation was unsuccessful. Validate() (bool, error) }
Validator provides an interface for struct types to implement validation of their internal state. They can also indicate to a caller whether their validation has already been completed.
NOTE: This cannot be applied to struct types that are simply aliased to a primitive.
type ValueDescriptor ¶
type ValueDescriptor struct { Id string `json:"id,omitempty"` Created int64 `json:"created,omitempty"` Description string `json:"description,omitempty"` Modified int64 `json:"modified,omitempty"` Origin int64 `json:"origin,omitempty"` Name string `json:"name,omitempty"` Min interface{} `json:"min,omitempty"` Max interface{} `json:"max,omitempty"` DefaultValue interface{} `json:"defaultValue,omitempty"` Type string `json:"type,omitempty"` UomLabel string `json:"uomLabel,omitempty"` Formatting string `json:"formatting,omitempty"` Labels []string `json:"labels,omitempty"` MediaType string `json:"mediaType,omitempty"` RequestType string `json:"requestType,omitempty"` FloatEncoding string `json:"floatEncoding,omitempty"` // contains filtered or unexported fields }
* Value Descriptor Struct
func From ¶
func From(dr DeviceResource) ValueDescriptor
From creates a ValueDescriptor based on the information provided in the DeviceResource.
func (ValueDescriptor) String ¶
func (a ValueDescriptor) String() string
String returns a JSON encoded string representation of the model
func (*ValueDescriptor) UnmarshalJSON ¶
func (v *ValueDescriptor) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the Unmarshaler interface for the ValueDescriptor type
func (ValueDescriptor) Validate ¶
func (v ValueDescriptor) Validate() (bool, error)
Validate satisfies the Validator interface
Source Files ¶
- action.go
- actiontype.go
- addressable.go
- adminstate.go
- autoevent.go
- callbackalert.go
- category.go
- channel.go
- channel_type.go
- command.go
- commandresponse.go
- constants.go
- describedobject.go
- device.go
- deviceprofile.go
- devicereport.go
- deviceresource.go
- deviceservice.go
- encryptiondetails.go
- errors.go
- event.go
- filter.go
- get.go
- interval.go
- interval_action.go
- log_entry.go
- notifications.go
- operatingstate.go
- profileproperty.go
- profileresource.go
- propertyvalue.go
- provisionwatcher.go
- put.go
- reading.go
- resourceoperation.go
- response.go
- severity.go
- sma_operation.go
- status.go
- subscription.go
- timestamps.go
- transmission.go
- transmission_record.go
- transmission_status.go
- units.go
- validator.go
- value-descriptor.go