-
Notifications
You must be signed in to change notification settings - Fork 302
/
identityserver_json.pb.go
139 lines (133 loc) · 4.14 KB
/
identityserver_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
// Code generated by protoc-gen-go-json. DO NOT EDIT.
// versions:
// - protoc-gen-go-json v1.1.0
// - protoc v3.9.1
// source: lorawan-stack/api/identityserver.proto
package ttnpb
import (
gogo "github.com/TheThingsIndustries/protoc-gen-go-json/gogo"
jsonplugin "github.com/TheThingsIndustries/protoc-gen-go-json/jsonplugin"
)
// MarshalProtoJSON marshals the AuthInfoResponse_APIKeyAccess message to JSON.
func (x *AuthInfoResponse_APIKeyAccess) MarshalProtoJSON(s *jsonplugin.MarshalState) {
if x == nil {
s.WriteNil()
return
}
s.WriteObjectStart()
var wroteField bool
if x.ApiKey != nil || s.HasField("api_key") {
s.WriteMoreIf(&wroteField)
s.WriteObjectField("api_key")
x.ApiKey.MarshalProtoJSON(s.WithField("api_key"))
}
if true { // (gogoproto.nullable) = false
s.WriteMoreIf(&wroteField)
s.WriteObjectField("entity_ids")
// NOTE: EntityIdentifiers does not seem to implement MarshalProtoJSON.
gogo.MarshalMessage(s, &x.EntityIds)
}
s.WriteObjectEnd()
}
// UnmarshalProtoJSON unmarshals the AuthInfoResponse_APIKeyAccess message from JSON.
func (x *AuthInfoResponse_APIKeyAccess) UnmarshalProtoJSON(s *jsonplugin.UnmarshalState) {
if s.ReadNil() {
return
}
s.ReadObject(func(key string) {
switch key {
default:
s.ReadAny() // ignore unknown field
case "api_key", "apiKey":
if !s.ReadNil() {
x.ApiKey = &APIKey{}
x.ApiKey.UnmarshalProtoJSON(s.WithField("api_key", true))
}
case "entity_ids", "entityIds":
s.AddField("entity_ids")
// NOTE: EntityIdentifiers does not seem to implement UnmarshalProtoJSON.
var v EntityIdentifiers
gogo.UnmarshalMessage(s, &v)
x.EntityIds = v
}
})
}
// MarshalProtoJSON marshals the AuthInfoResponse message to JSON.
func (x *AuthInfoResponse) MarshalProtoJSON(s *jsonplugin.MarshalState) {
if x == nil {
s.WriteNil()
return
}
s.WriteObjectStart()
var wroteField bool
if x.AccessMethod != nil {
switch ov := x.AccessMethod.(type) {
case *AuthInfoResponse_ApiKey:
s.WriteMoreIf(&wroteField)
s.WriteObjectField("api_key")
ov.ApiKey.MarshalProtoJSON(s.WithField("api_key"))
case *AuthInfoResponse_OauthAccessToken:
s.WriteMoreIf(&wroteField)
s.WriteObjectField("oauth_access_token")
ov.OauthAccessToken.MarshalProtoJSON(s.WithField("oauth_access_token"))
case *AuthInfoResponse_UserSession:
s.WriteMoreIf(&wroteField)
s.WriteObjectField("user_session")
// NOTE: UserSession does not seem to implement MarshalProtoJSON.
gogo.MarshalMessage(s, ov.UserSession)
}
}
if x.UniversalRights != nil || s.HasField("universal_rights") {
s.WriteMoreIf(&wroteField)
s.WriteObjectField("universal_rights")
x.UniversalRights.MarshalProtoJSON(s.WithField("universal_rights"))
}
if x.IsAdmin || s.HasField("is_admin") {
s.WriteMoreIf(&wroteField)
s.WriteObjectField("is_admin")
s.WriteBool(x.IsAdmin)
}
s.WriteObjectEnd()
}
// UnmarshalProtoJSON unmarshals the AuthInfoResponse message from JSON.
func (x *AuthInfoResponse) UnmarshalProtoJSON(s *jsonplugin.UnmarshalState) {
if s.ReadNil() {
return
}
s.ReadObject(func(key string) {
switch key {
default:
s.ReadAny() // ignore unknown field
case "api_key", "apiKey":
ov := &AuthInfoResponse_ApiKey{}
if !s.ReadNil() {
ov.ApiKey = &AuthInfoResponse_APIKeyAccess{}
ov.ApiKey.UnmarshalProtoJSON(s.WithField("api_key", true))
}
x.AccessMethod = ov
case "oauth_access_token", "oauthAccessToken":
ov := &AuthInfoResponse_OauthAccessToken{}
if !s.ReadNil() {
ov.OauthAccessToken = &OAuthAccessToken{}
ov.OauthAccessToken.UnmarshalProtoJSON(s.WithField("oauth_access_token", true))
}
x.AccessMethod = ov
case "user_session", "userSession":
s.AddField("user_session")
ov := &AuthInfoResponse_UserSession{}
// NOTE: UserSession does not seem to implement UnmarshalProtoJSON.
var v UserSession
gogo.UnmarshalMessage(s, &v)
ov.UserSession = &v
x.AccessMethod = ov
case "universal_rights", "universalRights":
if !s.ReadNil() {
x.UniversalRights = &Rights{}
x.UniversalRights.UnmarshalProtoJSON(s.WithField("universal_rights", true))
}
case "is_admin", "isAdmin":
s.AddField("is_admin")
x.IsAdmin = s.ReadBool()
}
})
}