github.com/jingruilea/kubeedge@v1.2.0-beta.0.0.20200410162146-4bb8902b3879/cloud/pkg/devicecontroller/types/device.go (about) 1 package types 2 3 // Device the struct of device 4 type Device struct { 5 ID string `json:"id,omitempty"` 6 Name string `json:"name,omitempty"` 7 Description string `json:"description,omitempty"` 8 State string `json:"state,omitempty"` 9 LastOnline string `json:"last_online,omitempty"` 10 Attributes map[string]*MsgAttr `json:"attributes,omitempty"` 11 Twin map[string]*MsgTwin `json:"twin,omitempty"` 12 } 13 14 // BaseMessage the base struct of event message 15 type BaseMessage struct { 16 EventID string `json:"event_id"` 17 Timestamp int64 `json:"timestamp"` 18 } 19 20 // Parameter container para 21 type Parameter struct { 22 EventID string 23 Code int 24 Reason string 25 } 26 27 // Result the struct of Result for sending 28 type Result struct { 29 BaseMessage 30 Code int `json:"code,omitempty"` 31 Reason string `json:"reason,omitempty"` 32 } 33 34 // MembershipDetail the struct of membership detail 35 type MembershipDetail struct { 36 BaseMessage 37 Devices []Device `json:"devices"` 38 } 39 40 // MembershipUpdate the struct of membership update 41 type MembershipUpdate struct { 42 BaseMessage 43 AddDevices []Device `json:"added_devices"` 44 RemoveDevices []Device `json:"removed_devices"` 45 } 46 47 // MsgAttr the struct of device attr 48 type MsgAttr struct { 49 Value string `json:"value"` 50 Optional *bool `json:"optional,omitempty"` 51 Metadata *TypeMetadata `json:"metadata,omitempty"` 52 } 53 54 // MsgTwin the struct of device twin 55 type MsgTwin struct { 56 Expected *TwinValue `json:"expected,omitempty"` 57 Actual *TwinValue `json:"actual,omitempty"` 58 Optional *bool `json:"optional,omitempty"` 59 Metadata *TypeMetadata `json:"metadata,omitempty"` 60 ExpectedVersion *TwinVersion `json:"expected_version,omitempty"` 61 ActualVersion *TwinVersion `json:"actual_version,omitempty"` 62 } 63 64 // TwinValue the struct of twin value 65 type TwinValue struct { 66 Value *string `json:"value,omitempty"` 67 Metadata *ValueMetadata `json:"metadata,omitempty"` 68 } 69 70 // TwinVersion twin version 71 type TwinVersion struct { 72 CloudVersion int64 `json:"cloud"` 73 EdgeVersion int64 `json:"edge"` 74 } 75 76 // TypeMetadata the meta of value type 77 type TypeMetadata struct { 78 Type string `json:"type,omitempty"` 79 } 80 81 // ValueMetadata the meta of value 82 type ValueMetadata struct { 83 Timestamp int64 `json:"timestamp,omitempty"` 84 } 85 86 // ConnectedInfo connected info 87 type ConnectedInfo struct { 88 EventType string `json:"event_type"` 89 TimeStamp int64 `json:"timestamp"` 90 } 91 92 // DeviceTwinDocument the struct of twin document 93 type DeviceTwinDocument struct { 94 BaseMessage 95 Twin map[string]*TwinDoc `json:"twin"` 96 } 97 98 // TwinDoc the struct of twin document 99 type TwinDoc struct { 100 LastState *MsgTwin `json:"last"` 101 CurrentState *MsgTwin `json:"current"` 102 } 103 104 // DeviceTwinUpdate the struct of device twin update 105 type DeviceTwinUpdate struct { 106 BaseMessage 107 Twin map[string]*MsgTwin `json:"twin"` 108 }