forked from keybase/client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
apiserver.go
186 lines (169 loc) · 5.68 KB
/
apiserver.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
// Auto-generated by avdl-compiler v1.3.25 (https://github.com/keybase/node-avdl-compiler)
// Input file: avdl/keybase1/apiserver.avdl
package keybase1
import (
"github.com/keybase/go-framed-msgpack-rpc/rpc"
context "golang.org/x/net/context"
)
type APIRes struct {
Status string `codec:"status" json:"status"`
Body string `codec:"body" json:"body"`
HttpStatus int `codec:"httpStatus" json:"httpStatus"`
AppStatus string `codec:"appStatus" json:"appStatus"`
}
func (o APIRes) DeepCopy() APIRes {
return APIRes{
Status: o.Status,
Body: o.Body,
HttpStatus: o.HttpStatus,
AppStatus: o.AppStatus,
}
}
type GetArg struct {
Endpoint string `codec:"endpoint" json:"endpoint"`
Args []StringKVPair `codec:"args" json:"args"`
HttpStatus []int `codec:"httpStatus" json:"httpStatus"`
AppStatusCode []int `codec:"appStatusCode" json:"appStatusCode"`
}
type DeleteArg struct {
Endpoint string `codec:"endpoint" json:"endpoint"`
Args []StringKVPair `codec:"args" json:"args"`
HttpStatus []int `codec:"httpStatus" json:"httpStatus"`
AppStatusCode []int `codec:"appStatusCode" json:"appStatusCode"`
}
type GetWithSessionArg struct {
Endpoint string `codec:"endpoint" json:"endpoint"`
Args []StringKVPair `codec:"args" json:"args"`
HttpStatus []int `codec:"httpStatus" json:"httpStatus"`
AppStatusCode []int `codec:"appStatusCode" json:"appStatusCode"`
}
type PostArg struct {
Endpoint string `codec:"endpoint" json:"endpoint"`
Args []StringKVPair `codec:"args" json:"args"`
HttpStatus []int `codec:"httpStatus" json:"httpStatus"`
AppStatusCode []int `codec:"appStatusCode" json:"appStatusCode"`
}
type PostJSONArg struct {
Endpoint string `codec:"endpoint" json:"endpoint"`
Args []StringKVPair `codec:"args" json:"args"`
JSONPayload []StringKVPair `codec:"JSONPayload" json:"JSONPayload"`
HttpStatus []int `codec:"httpStatus" json:"httpStatus"`
AppStatusCode []int `codec:"appStatusCode" json:"appStatusCode"`
}
type ApiserverInterface interface {
Get(context.Context, GetArg) (APIRes, error)
Delete(context.Context, DeleteArg) (APIRes, error)
GetWithSession(context.Context, GetWithSessionArg) (APIRes, error)
Post(context.Context, PostArg) (APIRes, error)
PostJSON(context.Context, PostJSONArg) (APIRes, error)
}
func ApiserverProtocol(i ApiserverInterface) rpc.Protocol {
return rpc.Protocol{
Name: "keybase.1.apiserver",
Methods: map[string]rpc.ServeHandlerDescription{
"Get": {
MakeArg: func() interface{} {
var ret [1]GetArg
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[1]GetArg)
if !ok {
err = rpc.NewTypeError((*[1]GetArg)(nil), args)
return
}
ret, err = i.Get(ctx, typedArgs[0])
return
},
MethodType: rpc.MethodCall,
},
"Delete": {
MakeArg: func() interface{} {
var ret [1]DeleteArg
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[1]DeleteArg)
if !ok {
err = rpc.NewTypeError((*[1]DeleteArg)(nil), args)
return
}
ret, err = i.Delete(ctx, typedArgs[0])
return
},
MethodType: rpc.MethodCall,
},
"GetWithSession": {
MakeArg: func() interface{} {
var ret [1]GetWithSessionArg
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[1]GetWithSessionArg)
if !ok {
err = rpc.NewTypeError((*[1]GetWithSessionArg)(nil), args)
return
}
ret, err = i.GetWithSession(ctx, typedArgs[0])
return
},
MethodType: rpc.MethodCall,
},
"Post": {
MakeArg: func() interface{} {
var ret [1]PostArg
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[1]PostArg)
if !ok {
err = rpc.NewTypeError((*[1]PostArg)(nil), args)
return
}
ret, err = i.Post(ctx, typedArgs[0])
return
},
MethodType: rpc.MethodCall,
},
"PostJSON": {
MakeArg: func() interface{} {
var ret [1]PostJSONArg
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[1]PostJSONArg)
if !ok {
err = rpc.NewTypeError((*[1]PostJSONArg)(nil), args)
return
}
ret, err = i.PostJSON(ctx, typedArgs[0])
return
},
MethodType: rpc.MethodCall,
},
},
}
}
type ApiserverClient struct {
Cli rpc.GenericClient
}
func (c ApiserverClient) Get(ctx context.Context, __arg GetArg) (res APIRes, err error) {
err = c.Cli.Call(ctx, "keybase.1.apiserver.Get", []interface{}{__arg}, &res)
return
}
func (c ApiserverClient) Delete(ctx context.Context, __arg DeleteArg) (res APIRes, err error) {
err = c.Cli.Call(ctx, "keybase.1.apiserver.Delete", []interface{}{__arg}, &res)
return
}
func (c ApiserverClient) GetWithSession(ctx context.Context, __arg GetWithSessionArg) (res APIRes, err error) {
err = c.Cli.Call(ctx, "keybase.1.apiserver.GetWithSession", []interface{}{__arg}, &res)
return
}
func (c ApiserverClient) Post(ctx context.Context, __arg PostArg) (res APIRes, err error) {
err = c.Cli.Call(ctx, "keybase.1.apiserver.Post", []interface{}{__arg}, &res)
return
}
func (c ApiserverClient) PostJSON(ctx context.Context, __arg PostJSONArg) (res APIRes, err error) {
err = c.Cli.Call(ctx, "keybase.1.apiserver.PostJSON", []interface{}{__arg}, &res)
return
}