-
Notifications
You must be signed in to change notification settings - Fork 0
/
device-request-action-response.go
90 lines (78 loc) · 2.85 KB
/
device-request-action-response.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// Code generated by github.com/atombender/go-jsonschema, DO NOT EDIT.
package messages
import "fmt"
import "encoding/json"
// Message-specific data
type DeviceRequestActionResponseJsonData struct {
// ID of the action
ActionId string `json:"actionId" yaml:"actionId"`
// Instance of the action
ActionName string `json:"actionName" yaml:"actionName"`
// ID of the adapter
AdapterId string `json:"adapterId" yaml:"adapterId"`
// ID of the device
DeviceId string `json:"deviceId" yaml:"deviceId"`
// ID of the plugin
PluginId string `json:"pluginId" yaml:"pluginId"`
// Whether or not the operation was successful
Success bool `json:"success" yaml:"success"`
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *DeviceRequestActionResponseJsonData) UnmarshalJSON(b []byte) error {
var raw map[string]any
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if v, ok := raw["actionId"]; !ok || v == nil {
return fmt.Errorf("field actionId in DeviceRequestActionResponseJsonData: required")
}
if v, ok := raw["actionName"]; !ok || v == nil {
return fmt.Errorf("field actionName in DeviceRequestActionResponseJsonData: required")
}
if v, ok := raw["adapterId"]; !ok || v == nil {
return fmt.Errorf("field adapterId in DeviceRequestActionResponseJsonData: required")
}
if v, ok := raw["deviceId"]; !ok || v == nil {
return fmt.Errorf("field deviceId in DeviceRequestActionResponseJsonData: required")
}
if v, ok := raw["pluginId"]; !ok || v == nil {
return fmt.Errorf("field pluginId in DeviceRequestActionResponseJsonData: required")
}
if v, ok := raw["success"]; !ok || v == nil {
return fmt.Errorf("field success in DeviceRequestActionResponseJsonData: required")
}
type Plain DeviceRequestActionResponseJsonData
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = DeviceRequestActionResponseJsonData(plain)
return nil
}
// Notice that an action has been requested on a device
type DeviceRequestActionResponseJson struct {
// Message-specific data
Data DeviceRequestActionResponseJsonData `json:"data" yaml:"data"`
// The message type, used by the IPC client and server to differentiate messages
MessageType int `json:"messageType" yaml:"messageType"`
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *DeviceRequestActionResponseJson) UnmarshalJSON(b []byte) error {
var raw map[string]any
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if v, ok := raw["data"]; !ok || v == nil {
return fmt.Errorf("field data in DeviceRequestActionResponseJson: required")
}
if v, ok := raw["messageType"]; !ok || v == nil {
return fmt.Errorf("field messageType in DeviceRequestActionResponseJson: required")
}
type Plain DeviceRequestActionResponseJson
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = DeviceRequestActionResponseJson(plain)
return nil
}