-
Notifications
You must be signed in to change notification settings - Fork 302
/
join_json.pb.go
241 lines (231 loc) · 6.7 KB
/
join_json.pb.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
// Code generated by protoc-gen-go-json. DO NOT EDIT.
// versions:
// - protoc-gen-go-json v1.5.1
// - protoc v4.22.2
// source: lorawan-stack/api/join.proto
package ttnpb
import (
golang "github.com/TheThingsIndustries/protoc-gen-go-json/golang"
jsonplugin "github.com/TheThingsIndustries/protoc-gen-go-json/jsonplugin"
types "go.thethings.network/lorawan-stack/v3/pkg/types"
)
// MarshalProtoJSON marshals the JoinRequest message to JSON.
func (x *JoinRequest) MarshalProtoJSON(s *jsonplugin.MarshalState) {
if x == nil {
s.WriteNil()
return
}
s.WriteObjectStart()
var wroteField bool
if len(x.RawPayload) > 0 || s.HasField("raw_payload") {
s.WriteMoreIf(&wroteField)
s.WriteObjectField("raw_payload")
s.WriteBytes(x.RawPayload)
}
if x.Payload != nil || s.HasField("payload") {
s.WriteMoreIf(&wroteField)
s.WriteObjectField("payload")
x.Payload.MarshalProtoJSON(s.WithField("payload"))
}
if len(x.DevAddr) > 0 || s.HasField("dev_addr") {
s.WriteMoreIf(&wroteField)
s.WriteObjectField("dev_addr")
types.MarshalHEXBytes(s.WithField("dev_addr"), x.DevAddr)
}
if x.SelectedMacVersion != 0 || s.HasField("selected_mac_version") {
s.WriteMoreIf(&wroteField)
s.WriteObjectField("selected_mac_version")
x.SelectedMacVersion.MarshalProtoJSON(s)
}
if len(x.NetId) > 0 || s.HasField("net_id") {
s.WriteMoreIf(&wroteField)
s.WriteObjectField("net_id")
types.MarshalHEXBytes(s.WithField("net_id"), x.NetId)
}
if x.DownlinkSettings != nil || s.HasField("downlink_settings") {
s.WriteMoreIf(&wroteField)
s.WriteObjectField("downlink_settings")
x.DownlinkSettings.MarshalProtoJSON(s.WithField("downlink_settings"))
}
if x.RxDelay != 0 || s.HasField("rx_delay") {
s.WriteMoreIf(&wroteField)
s.WriteObjectField("rx_delay")
x.RxDelay.MarshalProtoJSON(s)
}
if x.CfList != nil || s.HasField("cf_list") {
s.WriteMoreIf(&wroteField)
s.WriteObjectField("cf_list")
x.CfList.MarshalProtoJSON(s.WithField("cf_list"))
}
if len(x.CorrelationIds) > 0 || s.HasField("correlation_ids") {
s.WriteMoreIf(&wroteField)
s.WriteObjectField("correlation_ids")
s.WriteStringArray(x.CorrelationIds)
}
if x.ConsumedAirtime != nil || s.HasField("consumed_airtime") {
s.WriteMoreIf(&wroteField)
s.WriteObjectField("consumed_airtime")
if x.ConsumedAirtime == nil {
s.WriteNil()
} else {
golang.MarshalDuration(s, x.ConsumedAirtime)
}
}
s.WriteObjectEnd()
}
// MarshalJSON marshals the JoinRequest to JSON.
func (x *JoinRequest) MarshalJSON() ([]byte, error) {
return jsonplugin.DefaultMarshalerConfig.Marshal(x)
}
// UnmarshalProtoJSON unmarshals the JoinRequest message from JSON.
func (x *JoinRequest) UnmarshalProtoJSON(s *jsonplugin.UnmarshalState) {
if s.ReadNil() {
return
}
s.ReadObject(func(key string) {
switch key {
default:
s.ReadAny() // ignore unknown field
case "raw_payload", "rawPayload":
s.AddField("raw_payload")
x.RawPayload = s.ReadBytes()
case "payload":
if s.ReadNil() {
x.Payload = nil
return
}
x.Payload = &Message{}
x.Payload.UnmarshalProtoJSON(s.WithField("payload", true))
case "dev_addr", "devAddr":
s.AddField("dev_addr")
x.DevAddr = types.Unmarshal4Bytes(s.WithField("dev_addr", false))
case "selected_mac_version", "selectedMacVersion":
s.AddField("selected_mac_version")
x.SelectedMacVersion.UnmarshalProtoJSON(s)
case "net_id", "netId":
s.AddField("net_id")
x.NetId = types.Unmarshal3Bytes(s.WithField("net_id", false))
case "downlink_settings", "downlinkSettings":
if s.ReadNil() {
x.DownlinkSettings = nil
return
}
x.DownlinkSettings = &DLSettings{}
x.DownlinkSettings.UnmarshalProtoJSON(s.WithField("downlink_settings", true))
case "rx_delay", "rxDelay":
s.AddField("rx_delay")
x.RxDelay.UnmarshalProtoJSON(s)
case "cf_list", "cfList":
if s.ReadNil() {
x.CfList = nil
return
}
x.CfList = &CFList{}
x.CfList.UnmarshalProtoJSON(s.WithField("cf_list", true))
case "correlation_ids", "correlationIds":
s.AddField("correlation_ids")
if s.ReadNil() {
x.CorrelationIds = nil
return
}
x.CorrelationIds = s.ReadStringArray()
case "consumed_airtime", "consumedAirtime":
s.AddField("consumed_airtime")
if s.ReadNil() {
x.ConsumedAirtime = nil
return
}
v := golang.UnmarshalDuration(s)
if s.Err() != nil {
return
}
x.ConsumedAirtime = v
}
})
}
// UnmarshalJSON unmarshals the JoinRequest from JSON.
func (x *JoinRequest) UnmarshalJSON(b []byte) error {
return jsonplugin.DefaultUnmarshalerConfig.Unmarshal(b, x)
}
// MarshalProtoJSON marshals the JoinResponse message to JSON.
func (x *JoinResponse) MarshalProtoJSON(s *jsonplugin.MarshalState) {
if x == nil {
s.WriteNil()
return
}
s.WriteObjectStart()
var wroteField bool
if len(x.RawPayload) > 0 || s.HasField("raw_payload") {
s.WriteMoreIf(&wroteField)
s.WriteObjectField("raw_payload")
s.WriteBytes(x.RawPayload)
}
if x.SessionKeys != nil || s.HasField("session_keys") {
s.WriteMoreIf(&wroteField)
s.WriteObjectField("session_keys")
x.SessionKeys.MarshalProtoJSON(s.WithField("session_keys"))
}
if x.Lifetime != nil || s.HasField("lifetime") {
s.WriteMoreIf(&wroteField)
s.WriteObjectField("lifetime")
if x.Lifetime == nil {
s.WriteNil()
} else {
golang.MarshalDuration(s, x.Lifetime)
}
}
if len(x.CorrelationIds) > 0 || s.HasField("correlation_ids") {
s.WriteMoreIf(&wroteField)
s.WriteObjectField("correlation_ids")
s.WriteStringArray(x.CorrelationIds)
}
s.WriteObjectEnd()
}
// MarshalJSON marshals the JoinResponse to JSON.
func (x *JoinResponse) MarshalJSON() ([]byte, error) {
return jsonplugin.DefaultMarshalerConfig.Marshal(x)
}
// UnmarshalProtoJSON unmarshals the JoinResponse message from JSON.
func (x *JoinResponse) UnmarshalProtoJSON(s *jsonplugin.UnmarshalState) {
if s.ReadNil() {
return
}
s.ReadObject(func(key string) {
switch key {
default:
s.ReadAny() // ignore unknown field
case "raw_payload", "rawPayload":
s.AddField("raw_payload")
x.RawPayload = s.ReadBytes()
case "session_keys", "sessionKeys":
if s.ReadNil() {
x.SessionKeys = nil
return
}
x.SessionKeys = &SessionKeys{}
x.SessionKeys.UnmarshalProtoJSON(s.WithField("session_keys", true))
case "lifetime":
s.AddField("lifetime")
if s.ReadNil() {
x.Lifetime = nil
return
}
v := golang.UnmarshalDuration(s)
if s.Err() != nil {
return
}
x.Lifetime = v
case "correlation_ids", "correlationIds":
s.AddField("correlation_ids")
if s.ReadNil() {
x.CorrelationIds = nil
return
}
x.CorrelationIds = s.ReadStringArray()
}
})
}
// UnmarshalJSON unmarshals the JoinResponse from JSON.
func (x *JoinResponse) UnmarshalJSON(b []byte) error {
return jsonplugin.DefaultUnmarshalerConfig.Unmarshal(b, x)
}