-
Notifications
You must be signed in to change notification settings - Fork 66
/
bar.thrift
462 lines (413 loc) · 13.9 KB
/
bar.thrift
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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
namespace java com.uber.zanzibar.clients.bar
include "../foo/foo.thrift"
typedef string UUID
typedef i64 (json.type = 'Date') Timestamp
typedef i64 (json.type = "Long") Long
typedef list<string> StringList
typedef list<UUID> UUIDList
enum Fruit {
APPLE,
BANANA
}
struct BarRequest {
1: required string stringField
2: required bool boolField
3: required binary binaryField
4: required Timestamp timestamp
5: required Fruit enumField
6: required Long longField
}
struct RequestWithDuplicateType {
1: optional BarRequest request1
2: optional BarRequest request2
}
struct BarResponse {
1: required string stringField (
zanzibar.http.ref = "headers.some-header-field"
zanzibar.validation.type = "object,number"
)
2: required i32 intWithRange
3: required i32 intWithoutRange (zanzibar.ignore.integer.range = "true")
4: required map<UUID, i32> mapIntWithRange
5: required map<string, i32> mapIntWithoutRange (
zanzibar.ignore.integer.range = "true"
)
6: required binary binaryField
7: optional BarResponse nextResponse
}
struct BarRequestRecur {
1: required string name
2: optional BarRequestRecur recur
}
struct BarResponseRecur {
1: required list<string> nodes
2: required i32 height
}
struct QueryParamsStruct {
1: required string name
2: optional string userUUID
// TODO: support header annotation
3: optional string authUUID
4: optional string authUUID2 (zanzibar.http.ref = "query.myuuid")
5: required list<string> foo
}
struct QueryParamsOptsStruct {
1: required string name
2: optional string userUUID
3: optional string authUUID
4: optional string authUUID2
}
struct QueryParamsUntaggedStruct {
1: required string name
2: optional string userUUID
3: required i32 count
4: optional i32 optCount
5: required list<string> foos
}
struct QueryParamsUntaggedOptStruct {
1: required string name
2: optional string userUUID
3: required i32 count
4: optional i32 optCount
5: required list<string> foos
}
struct ParamsStruct {
1: required string userUUID (zanzibar.http.ref = "params.user-uuid")
}
enum DemoType {
FIRST,
SECOND
}
exception BarException {
1: required string stringField (zanzibar.http.ref = "headers.another-header-field")
}
service Bar {
string helloWorld(
) throws (
1: BarException barException (zanzibar.http.status = "403")
) (
zanzibar.http.method = "GET"
zanzibar.http.path = "/bar/hello"
zanzibar.http.status = "200"
)
string listAndEnum (
1: required list<string> demoIds (zanzibar.http.ref = "query.demoIds")
2: optional DemoType demoType (zanzibar.http.ref = "query.demoType")
) throws (
1: BarException barException (zanzibar.http.status = "403")
) (
zanzibar.http.method = "GET"
zanzibar.http.path = "/bar/list-and-enum"
zanzibar.http.status = "200"
)
BarResponse normal (
1: required BarRequest request
) throws (
1: BarException barException (zanzibar.http.status = "403")
) (
zanzibar.http.method = "POST"
zanzibar.http.path = "/bar-path"
zanzibar.http.status = "200"
)
BarResponseRecur normalRecur (
1: required BarRequestRecur request
) throws (
1: BarException barException (zanzibar.http.status = "403")
) (
zanzibar.http.method = "POST"
zanzibar.http.path = "/bar/recur"
zanzibar.http.status = "200"
)
BarResponse noRequest (
) throws (
1: BarException barException (zanzibar.http.status = "403")
) (
zanzibar.http.method = "GET"
zanzibar.http.path = "/no-request-path"
zanzibar.http.status = "200"
)
BarResponse missingArg (
) throws (
1: BarException barException (zanzibar.http.status = "403")
) (
zanzibar.http.method = "GET"
zanzibar.http.path = "/missing-arg-path"
zanzibar.http.status = "200"
)
BarResponse tooManyArgs (
1: required BarRequest request
2: optional foo.FooStruct foo
) throws (
1: BarException barException (zanzibar.http.status = "403")
2: foo.FooException fooException (zanzibar.http.status = "418")
) (
zanzibar.http.method = "POST"
zanzibar.http.path = "/too-many-args-path"
zanzibar.http.status = "200"
)
void argNotStruct (
1: required string request
) throws (
1: BarException barException (zanzibar.http.status = "403")
) (
zanzibar.http.method = "POST"
zanzibar.http.path = "/arg-not-struct-path"
zanzibar.http.status = "200"
)
// TODO: support headers annotation
BarResponse argWithHeaders (
1: required string name (
zanzibar.http.ref = "headers.name"
go.tag = "json:\"-\""
)
2: optional string userUUID (
zanzibar.http.ref = "headers.x-uuid"
go.tag = "json:\"-\""
)
) (
zanzibar.http.method = "POST"
zanzibar.http.reqHeaders = "x-uuid"
zanzibar.http.path = "/bar/argWithHeaders"
zanzibar.http.status = "200"
)
BarResponse argWithQueryParams(
1: required string name (zanzibar.http.ref = "query.name")
2: optional string userUUID (zanzibar.http.ref = "query.userUUID")
3: optional list<string> foo (zanzibar.http.ref = "query.foo")
4: required list<i8> bar (zanzibar.http.ref = "query.bar")
// TODO(argouber): Actually allow sets - preferably with go.tag of slice
) (
zanzibar.http.method = "GET"
zanzibar.http.path = "/bar/argWithQueryParams"
zanzibar.http.status = "200"
)
BarResponse argWithNestedQueryParams(
1: required QueryParamsStruct request
2: optional QueryParamsOptsStruct opt
) (
zanzibar.http.method = "GET"
zanzibar.http.path = "/bar/argWithNestedQueryParams"
zanzibar.http.status = "200"
)
BarResponse argWithUntaggedNestedQueryParams(
1: required QueryParamsUntaggedStruct request (zanzibar.http.ref = "query.request")
2: optional QueryParamsUntaggedOptStruct opt (zanzibar.http.ref = "query.opt")
) (
zanzibar.http.method = "GET"
zanzibar.http.path = "/bar/argWithUntaggedNestedQueryParams"
zanzibar.http.status = "200"
)
// TODO: support headers annotation
BarResponse argWithQueryHeader(
1: optional string userUUID
) (
zanzibar.http.method = "POST"
zanzibar.http.path = "/bar/argWithQueryHeader"
zanzibar.http.status = "200"
)
BarResponse argWithParams(
1: required string uuid (zanzibar.http.ref = "params.uuid")
2: optional ParamsStruct params
) (
zanzibar.http.method = "GET"
zanzibar.http.path = "/bar/argWithParams/:uuid/segment/:user-uuid"
zanzibar.http.status = "200"
)
BarResponse argWithManyQueryParams(
1: required string aStr (zanzibar.http.ref = "query.aStr")
2: optional string anOptStr (zanzibar.http.ref = "query.anOptStr")
3: required bool aBool (
zanzibar.http.ref = "query.aBoolean"
)
4: optional bool anOptBool (zanzibar.http.ref = "query.anOptBool")
5: required i8 aInt8 (zanzibar.http.ref = "query.aInt8")
6: optional i8 anOptInt8 (zanzibar.http.ref = "query.anOptInt8")
7: required i16 aInt16 (zanzibar.http.ref = "query.aInt16")
8: optional i16 anOptInt16 (zanzibar.http.ref = "query.anOptInt16")
9: required i32 aInt32 (zanzibar.http.ref = "query.aInt32")
10: optional i32 anOptInt32 (zanzibar.http.ref = "query.anOptInt32")
11: required i64 aInt64 (zanzibar.http.ref = "query.aInt64")
12: optional i64 anOptInt64 (zanzibar.http.ref = "query.anOptInt64")
13: required double aFloat64 (zanzibar.http.ref = "query.aFloat64")
14: optional double anOptFloat64 (zanzibar.http.ref = "query.anOptFloat64")
15: required UUID aUUID (zanzibar.http.ref = "query.aUUID")
16: optional UUID anOptUUID (zanzibar.http.ref = "query.anOptUUID")
17: required list<UUID> aListUUID (zanzibar.http.ref = "query.aListUUID")
18: optional list<UUID> anOptListUUID (zanzibar.http.ref = "query.anOptListUUID")
19: required StringList aStringList (zanzibar.http.ref = "query.aStringList")
20: optional StringList anOptStringList (zanzibar.http.ref = "query.anOptStringList")
21: required UUIDList aUUIDList (zanzibar.http.ref = "query.aUUIDList")
22: optional UUIDList anOptUUIDList (zanzibar.http.ref = "query.anOptUUIDList")
23: required Timestamp aTs (zanzibar.http.ref = "query.aTs")
24: optional Timestamp anOptTs (zanzibar.http.ref = "query.anOptTs")
) (
zanzibar.http.method = "GET"
zanzibar.http.path = "/bar/argWithManyQueryParams"
zanzibar.http.status = "200"
)
BarResponse argWithParamsAndDuplicateFields(
1: required RequestWithDuplicateType request
2: required string entityUUID (zanzibar.http.ref = "params.uuid")
) (
zanzibar.http.method = "POST"
zanzibar.http.path = "/bar/argWithParamsAndDuplicateFields/:uuid/segment"
zanzibar.http.status = "200"
)
void deleteFoo(
1: required string userUUID (zanzibar.http.ref = "headers.x-uuid")
) (
zanzibar.http.method = "DELETE"
zanzibar.http.path = "/bar/foo"
zanzibar.http.reqHeaders = "x-uuid"
zanzibar.http.status = "200"
)
void deleteWithQueryParams(
2: required string filter (zanzibar.http.ref = "query.filter")
3: optional i32 count (zanzibar.http.ref = "query.count")
) (
zanzibar.http.method = "DELETE"
zanzibar.http.path = "/bar/withQueryParams"
zanzibar.http.status = "200"
)
}
service Echo {
i8 echoI8 (
1: required i8 arg
) (
zanzibar.http.method = "POST"
zanzibar.http.reqHeaders = "x-uuid"
zanzibar.http.path = "/echo/i8"
zanzibar.http.status = "200"
)
i16 echoI16(
1: required i16 arg
) (
zanzibar.http.method = "POST"
zanzibar.http.reqHeaders = "x-uuid"
zanzibar.http.path = "/echo/i16"
zanzibar.http.status = "200"
)
i32 echoI32(
1: required i32 arg
) (
zanzibar.http.method = "POST"
zanzibar.http.reqHeaders = "x-uuid"
zanzibar.http.path = "/echo/i32"
zanzibar.http.status = "200"
)
i64 echoI64(
1: required i64 arg
) (
zanzibar.http.method = "POST"
zanzibar.http.reqHeaders = "x-uuid"
zanzibar.http.path = "/echo/i64"
zanzibar.http.status = "200"
)
double echoDouble(
1: required double arg
) (
zanzibar.http.method = "POST"
zanzibar.http.reqHeaders = "x-uuid"
zanzibar.http.path = "/echo/double"
zanzibar.http.status = "200"
)
bool echoBool (
1: required bool arg
) (
zanzibar.http.method = "POST"
zanzibar.http.reqHeaders = "x-uuid"
zanzibar.http.path = "/echo/bool"
zanzibar.http.status = "200"
)
binary echoBinary (
1: required binary arg
) (
zanzibar.http.method = "POST"
zanzibar.http.reqHeaders = "x-uuid"
zanzibar.http.path = "/echo/binary"
zanzibar.http.status = "200"
)
string echoString(
1: required string arg
) (
zanzibar.http.method = "POST"
zanzibar.http.reqHeaders = "x-uuid"
zanzibar.http.path = "/echo/string"
zanzibar.http.status = "200"
)
Fruit echoEnum (
1: required Fruit arg = Fruit.APPLE
) (
zanzibar.http.method = "POST"
zanzibar.http.reqHeaders = "x-uuid"
zanzibar.http.path = "/echo/enum"
zanzibar.http.status = "200"
)
UUID echoTypedef(
1: required UUID arg
) (
zanzibar.http.method = "POST"
zanzibar.http.reqHeaders = "x-uuid"
zanzibar.http.path = "/echo/typedef"
zanzibar.http.status = "200"
)
set<string> echoStringSet(
1: required set<string> arg
) (
zanzibar.http.method = "POST"
zanzibar.http.reqHeaders = "x-uuid"
zanzibar.http.path = "/echo/string-set"
zanzibar.http.status = "200"
)
// value is unhashable
set<BarResponse> echoStructSet(
1: required set<BarResponse> arg
) (
zanzibar.http.method = "POST"
zanzibar.http.reqHeaders = "x-uuid"
zanzibar.http.path = "/echo/struct-set"
zanzibar.http.status = "200"
)
list<string> echoStringList (
1: required list<string> arg
) (
zanzibar.http.method = "POST"
zanzibar.http.reqHeaders = "x-uuid"
zanzibar.http.path = "/echo/string-list"
zanzibar.http.status = "200"
)
list<BarResponse> echoStructList (
1: required list<BarResponse> arg
) (
zanzibar.http.method = "POST"
zanzibar.http.reqHeaders = "x-uuid"
zanzibar.http.path = "/echo/struct-list"
zanzibar.http.status = "200"
)
map<i32, BarResponse> echoI32Map (
1: required map<i32, BarResponse> arg
) (
zanzibar.http.method = "POST"
zanzibar.http.reqHeaders = "x-uuid"
zanzibar.http.path = "/echo/i32-map"
zanzibar.http.status = "200"
)
map<string, BarResponse> echoStringMap (
1: required map<string, BarResponse> arg
) (
zanzibar.http.method = "POST"
zanzibar.http.reqHeaders = "x-uuid"
zanzibar.http.path = "/echo/string-map"
zanzibar.http.status = "200"
)
// key is unhashable
// TODO: mockgen can't deal this, https://github.com/golang/mock/issues/153
map<BarResponse, string> echoStructMap (
1: required map<BarResponse, string> arg
) (
zanzibar.http.method = "POST"
zanzibar.http.reqHeaders = "x-uuid"
zanzibar.http.path = "/echo/struct-map"
zanzibar.http.status = "200"
)
}