-
Notifications
You must be signed in to change notification settings - Fork 310
/
keys_json.pb.go
226 lines (212 loc) · 6.2 KB
/
keys_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
// 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/keys.proto
package ttnpb
import (
jsonplugin "github.com/TheThingsIndustries/protoc-gen-go-json/jsonplugin"
types "go.thethings.network/lorawan-stack/v3/pkg/types"
)
// MarshalProtoJSON marshals the KeyEnvelope message to JSON.
func (x *KeyEnvelope) MarshalProtoJSON(s *jsonplugin.MarshalState) {
if x == nil {
s.WriteNil()
return
}
s.WriteObjectStart()
var wroteField bool
if len(x.Key) > 0 || s.HasField("key") {
s.WriteMoreIf(&wroteField)
s.WriteObjectField("key")
types.MarshalHEXBytes(s.WithField("key"), x.Key)
}
if x.KekLabel != "" || s.HasField("kek_label") {
s.WriteMoreIf(&wroteField)
s.WriteObjectField("kek_label")
s.WriteString(x.KekLabel)
}
if len(x.EncryptedKey) > 0 || s.HasField("encrypted_key") {
s.WriteMoreIf(&wroteField)
s.WriteObjectField("encrypted_key")
s.WriteBytes(x.EncryptedKey)
}
s.WriteObjectEnd()
}
// MarshalJSON marshals the KeyEnvelope to JSON.
func (x *KeyEnvelope) MarshalJSON() ([]byte, error) {
return jsonplugin.DefaultMarshalerConfig.Marshal(x)
}
// UnmarshalProtoJSON unmarshals the KeyEnvelope message from JSON.
func (x *KeyEnvelope) UnmarshalProtoJSON(s *jsonplugin.UnmarshalState) {
if s.ReadNil() {
return
}
s.ReadObject(func(key string) {
switch key {
default:
s.ReadAny() // ignore unknown field
case "key":
s.AddField("key")
x.Key = types.Unmarshal16Bytes(s.WithField("key", false))
case "kek_label", "kekLabel":
s.AddField("kek_label")
x.KekLabel = s.ReadString()
case "encrypted_key", "encryptedKey":
s.AddField("encrypted_key")
x.EncryptedKey = s.ReadBytes()
}
})
}
// UnmarshalJSON unmarshals the KeyEnvelope from JSON.
func (x *KeyEnvelope) UnmarshalJSON(b []byte) error {
return jsonplugin.DefaultUnmarshalerConfig.Unmarshal(b, x)
}
// MarshalProtoJSON marshals the RootKeys message to JSON.
func (x *RootKeys) MarshalProtoJSON(s *jsonplugin.MarshalState) {
if x == nil {
s.WriteNil()
return
}
s.WriteObjectStart()
var wroteField bool
if x.RootKeyId != "" || s.HasField("root_key_id") {
s.WriteMoreIf(&wroteField)
s.WriteObjectField("root_key_id")
s.WriteString(x.RootKeyId)
}
if x.AppKey != nil || s.HasField("app_key") {
s.WriteMoreIf(&wroteField)
s.WriteObjectField("app_key")
x.AppKey.MarshalProtoJSON(s.WithField("app_key"))
}
if x.NwkKey != nil || s.HasField("nwk_key") {
s.WriteMoreIf(&wroteField)
s.WriteObjectField("nwk_key")
x.NwkKey.MarshalProtoJSON(s.WithField("nwk_key"))
}
s.WriteObjectEnd()
}
// MarshalJSON marshals the RootKeys to JSON.
func (x *RootKeys) MarshalJSON() ([]byte, error) {
return jsonplugin.DefaultMarshalerConfig.Marshal(x)
}
// UnmarshalProtoJSON unmarshals the RootKeys message from JSON.
func (x *RootKeys) UnmarshalProtoJSON(s *jsonplugin.UnmarshalState) {
if s.ReadNil() {
return
}
s.ReadObject(func(key string) {
switch key {
default:
s.ReadAny() // ignore unknown field
case "root_key_id", "rootKeyId":
s.AddField("root_key_id")
x.RootKeyId = s.ReadString()
case "app_key", "appKey":
if s.ReadNil() {
x.AppKey = nil
return
}
x.AppKey = &KeyEnvelope{}
x.AppKey.UnmarshalProtoJSON(s.WithField("app_key", true))
case "nwk_key", "nwkKey":
if s.ReadNil() {
x.NwkKey = nil
return
}
x.NwkKey = &KeyEnvelope{}
x.NwkKey.UnmarshalProtoJSON(s.WithField("nwk_key", true))
}
})
}
// UnmarshalJSON unmarshals the RootKeys from JSON.
func (x *RootKeys) UnmarshalJSON(b []byte) error {
return jsonplugin.DefaultUnmarshalerConfig.Unmarshal(b, x)
}
// MarshalProtoJSON marshals the SessionKeys message to JSON.
func (x *SessionKeys) MarshalProtoJSON(s *jsonplugin.MarshalState) {
if x == nil {
s.WriteNil()
return
}
s.WriteObjectStart()
var wroteField bool
if len(x.SessionKeyId) > 0 || s.HasField("session_key_id") {
s.WriteMoreIf(&wroteField)
s.WriteObjectField("session_key_id")
s.WriteBytes(x.SessionKeyId)
}
if x.FNwkSIntKey != nil || s.HasField("f_nwk_s_int_key") {
s.WriteMoreIf(&wroteField)
s.WriteObjectField("f_nwk_s_int_key")
x.FNwkSIntKey.MarshalProtoJSON(s.WithField("f_nwk_s_int_key"))
}
if x.SNwkSIntKey != nil || s.HasField("s_nwk_s_int_key") {
s.WriteMoreIf(&wroteField)
s.WriteObjectField("s_nwk_s_int_key")
x.SNwkSIntKey.MarshalProtoJSON(s.WithField("s_nwk_s_int_key"))
}
if x.NwkSEncKey != nil || s.HasField("nwk_s_enc_key") {
s.WriteMoreIf(&wroteField)
s.WriteObjectField("nwk_s_enc_key")
x.NwkSEncKey.MarshalProtoJSON(s.WithField("nwk_s_enc_key"))
}
if x.AppSKey != nil || s.HasField("app_s_key") {
s.WriteMoreIf(&wroteField)
s.WriteObjectField("app_s_key")
x.AppSKey.MarshalProtoJSON(s.WithField("app_s_key"))
}
s.WriteObjectEnd()
}
// MarshalJSON marshals the SessionKeys to JSON.
func (x *SessionKeys) MarshalJSON() ([]byte, error) {
return jsonplugin.DefaultMarshalerConfig.Marshal(x)
}
// UnmarshalProtoJSON unmarshals the SessionKeys message from JSON.
func (x *SessionKeys) UnmarshalProtoJSON(s *jsonplugin.UnmarshalState) {
if s.ReadNil() {
return
}
s.ReadObject(func(key string) {
switch key {
default:
s.ReadAny() // ignore unknown field
case "session_key_id", "sessionKeyId":
s.AddField("session_key_id")
x.SessionKeyId = s.ReadBytes()
case "f_nwk_s_int_key", "fNwkSIntKey":
if s.ReadNil() {
x.FNwkSIntKey = nil
return
}
x.FNwkSIntKey = &KeyEnvelope{}
x.FNwkSIntKey.UnmarshalProtoJSON(s.WithField("f_nwk_s_int_key", true))
case "s_nwk_s_int_key", "sNwkSIntKey":
if s.ReadNil() {
x.SNwkSIntKey = nil
return
}
x.SNwkSIntKey = &KeyEnvelope{}
x.SNwkSIntKey.UnmarshalProtoJSON(s.WithField("s_nwk_s_int_key", true))
case "nwk_s_enc_key", "nwkSEncKey":
if s.ReadNil() {
x.NwkSEncKey = nil
return
}
x.NwkSEncKey = &KeyEnvelope{}
x.NwkSEncKey.UnmarshalProtoJSON(s.WithField("nwk_s_enc_key", true))
case "app_s_key", "appSKey":
if s.ReadNil() {
x.AppSKey = nil
return
}
x.AppSKey = &KeyEnvelope{}
x.AppSKey.UnmarshalProtoJSON(s.WithField("app_s_key", true))
}
})
}
// UnmarshalJSON unmarshals the SessionKeys from JSON.
func (x *SessionKeys) UnmarshalJSON(b []byte) error {
return jsonplugin.DefaultUnmarshalerConfig.Unmarshal(b, x)
}