-
Notifications
You must be signed in to change notification settings - Fork 0
/
adapter-cancel-remove-device-command.go
72 lines (63 loc) · 2.29 KB
/
adapter-cancel-remove-device-command.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
// Code generated by github.com/atombender/go-jsonschema, DO NOT EDIT.
package messages
import "fmt"
import "encoding/json"
// Message-specific data
type AdapterCancelRemoveDeviceCommandJsonData struct {
// ID of the adapter
AdapterId string `json:"adapterId" yaml:"adapterId"`
// ID of the device which is being removed
DeviceId string `json:"deviceId" yaml:"deviceId"`
// ID of the plugin
PluginId string `json:"pluginId" yaml:"pluginId"`
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *AdapterCancelRemoveDeviceCommandJsonData) UnmarshalJSON(b []byte) error {
var raw map[string]any
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if v, ok := raw["adapterId"]; !ok || v == nil {
return fmt.Errorf("field adapterId in AdapterCancelRemoveDeviceCommandJsonData: required")
}
if v, ok := raw["deviceId"]; !ok || v == nil {
return fmt.Errorf("field deviceId in AdapterCancelRemoveDeviceCommandJsonData: required")
}
if v, ok := raw["pluginId"]; !ok || v == nil {
return fmt.Errorf("field pluginId in AdapterCancelRemoveDeviceCommandJsonData: required")
}
type Plain AdapterCancelRemoveDeviceCommandJsonData
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = AdapterCancelRemoveDeviceCommandJsonData(plain)
return nil
}
// Tell an adapter to cancel the removal of a device
type AdapterCancelRemoveDeviceCommandJson struct {
// Message-specific data
Data AdapterCancelRemoveDeviceCommandJsonData `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 *AdapterCancelRemoveDeviceCommandJson) 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 AdapterCancelRemoveDeviceCommandJson: required")
}
if v, ok := raw["messageType"]; !ok || v == nil {
return fmt.Errorf("field messageType in AdapterCancelRemoveDeviceCommandJson: required")
}
type Plain AdapterCancelRemoveDeviceCommandJson
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = AdapterCancelRemoveDeviceCommandJson(plain)
return nil
}