-
Notifications
You must be signed in to change notification settings - Fork 4
/
service.proto
396 lines (336 loc) · 10.4 KB
/
service.proto
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
syntax = "proto3";
package razorpay.gateway;
// import "google/protobuf/struct.proto";
// OpenApi Spec config
// Refer to https://github.com/grpc-ecosystem/grpc-gateway/blob/main/protoc-gen-openapiv2/options/openapiv2.proto
import "protoc-gen-openapiv2/options/annotations.proto";
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
info: {
title: "Trino Gateway Server API";
version: "1.0";
description: "1. Set correct scheme matching the server's hostname.\n2. Secured APIs (WRITE operations) are hidden from UI till the user is authorized.";
contact: {
name: "Trino Gateway";
url: "https://github.com/razorpay/trino-gateway";
};
};
schemes: [HTTP, HTTPS];
base_path: "/twirp/";
security: {
security_requirement :{
key: "ApiKeyAuth";
value: {};
}
}
security_definitions: {
security: {
key: "ApiKeyAuth";
value: {
type: TYPE_API_KEY;
in: IN_HEADER;
name: "X-Auth-Key";
};
};
}
};
option go_package = "./rpc/gateway;gatewayv1";
message Empty {}
service HealthCheckAPI {
rpc Check(HealthCheckRequest) returns (HealthCheckResponse){
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "Healthcheck status of the service";
description: "Runs healthchecks of the service and returns current status as HealthCheckResponse";
security: {};
};
};
}
message HealthCheckRequest {
string service = 1;
}
message HealthCheckResponse {
// ServingStatus denotes the status of the service.
enum ServingStatus {
SERVING_STATUS_INVALID = 0;
SERVING_STATUS_UNKNOWN = 1;
SERVING_STATUS_SERVING = 2;
SERVING_STATUS_NOT_SERVING = 3;
}
ServingStatus serving_status = 1;
}
service BackendApi {
rpc CreateOrUpdateBackend (Backend) returns (Empty);
rpc GetBackend (BackendGetRequest) returns (BackendGetResponse){
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
security: {};
};
};
rpc ListAllBackends (Empty) returns (BackendListAllResponse){
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
security: {};
};
};
rpc DeleteBackend (BackendDeleteRequest) returns (Empty);
rpc EnableBackend (BackendEnableRequest) returns (Empty);
rpc DisableBackend (BackendDisableRequest) returns (Empty);
rpc MarkHealthyBackend (BackendMarkHealthyRequest) returns (Empty);
rpc MarkUnhealthyBackend (BackendMarkUnhealthyRequest) returns (Empty);
rpc UpdateClusterLoadBackend (BackendUpdateClusterLoadRequest) returns (Empty){
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "Updates cluster load values";
description: "Update cluster load values of a backend";
};
};
}
message Backend {
enum Scheme {
http = 0;
https = 1;
}
string id = 1; // required
bool is_enabled = 2;
Scheme scheme = 3; // required
string hostname = 4; // required
string external_url = 5;
string uptime_schedule = 6;
bool is_healthy = 7;
int32 cluster_load = 8;
int32 threshold_cluster_load = 9;
int64 stats_updated_at = 10;
}
message BackendCreateResponse {
string id = 1; // required
}
message BackendGetRequest {
string id = 1; // required
}
message BackendGetResponse {
Backend backend = 1; //required
}
message BackendListAllResponse {
repeated Backend items = 1;
}
message BackendDeleteRequest {
string id = 1; // required
}
message BackendEnableRequest {
string id = 1; // required
}
message BackendDisableRequest {
string id = 1; // required
}
message BackendMarkHealthyRequest {
string id = 1; // required
}
message BackendMarkUnhealthyRequest {
string id = 1; // required
}
message BackendUpdateClusterLoadRequest {
string id = 1; // required
int32 cluster_load = 2; //required
}
service GroupApi {
rpc CreateOrUpdateGroup (Group) returns (Empty);
rpc GetGroup (GroupGetRequest) returns (GroupGetResponse){
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
security: {};
};
};
rpc ListAllGroups (Empty) returns (GroupListAllResponse){
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
security: {};
};
};
rpc DeleteGroup (GroupDeleteRequest) returns (Empty);
rpc EnableGroup (GroupEnableRequest) returns (Empty);
rpc DisableGroup (GroupDisableRequest) returns (Empty);
rpc EvaluateBackendForGroups(EvaluateBackendRequest) returns (EvaluateBackendResponse){
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "Returns backend to be used for routing requests to this group";
description: "Evaluates which backend to be used for routing requests for this group. Depends on the configured routing strategy and backend health.";
};
};
}
message Group {
enum RoutingStrategy {
LEAST_LOAD = 0;
ROUND_ROBIN = 1;
RANDOM = 2;
}
string id = 1; // required
repeated string backends = 2; // required
RoutingStrategy strategy = 3;
string last_routed_backend = 4;
bool is_enabled = 5;
}
message GroupGetRequest {
string id = 1; // required
}
message GroupGetResponse {
Group group = 2;
}
message GroupListAllResponse {
repeated Group items = 1;
}
message GroupDeleteRequest {
string id = 1; // required
}
message GroupEnableRequest {
string id = 1; // required
}
message GroupDisableRequest {
string id = 1; // required
}
message EvaluateBackendRequest {
repeated string group_ids = 1; // required
}
message EvaluateBackendResponse {
string backend_id = 1; // required
string group_id = 2; // required
}
service PolicyApi {
rpc CreateOrUpdatePolicy (Policy) returns (Empty);
rpc GetPolicy (PolicyGetRequest) returns (PolicyGetResponse){
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
security: {};
};
};
rpc ListAllPolicies (Empty) returns (PolicyListAllResponse){
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
security: {};
};
};
rpc DeletePolicy (PolicyDeleteRequest) returns (Empty);
rpc EnablePolicy (PolicyEnableRequest) returns (Empty);
rpc DisablePolicy (PolicyDisableRequest) returns (Empty);
rpc EvaluateGroupsForClient(EvaluateGroupsRequest) returns (EvaluateGroupsResponse){
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "Returns groups eligible for routing for this client request.";
description: "Evaluates routing policies and returns a list of groups eligible for this client request.";
};
};
rpc EvaluateAuthDelegationForClient(EvaluateAuthDelegationRequest) returns (EvaluateAuthDelegationResponse);
rpc EvaluateRequestSourceForClient(EvaluateRequestSourceRequest) returns (EvaluateRequestSourceResponse);
}
message Policy {
message Rule {
enum RuleType {
header_connection_properties = 0;
header_client_tags = 1;
header_host = 2;
listening_port = 3;
}
RuleType type = 1; // required
string value = 2; // required
}
string id = 1; // required
Rule rule = 2; // required
string group = 3; // required
string fallback_group = 4;
bool is_enabled = 5;
bool is_auth_delegated = 6;
string set_request_source = 7;
}
message PolicyGetRequest {
string id = 1; // required
}
message PolicyGetResponse {
Policy policy = 1; // required
}
message PolicyListAllResponse {
repeated Policy items = 1;
}
message PolicyDeleteRequest {
string id = 1; // required
}
message PolicyEnableRequest {
string id = 1; // required
}
message PolicyDisableRequest {
string id = 1; // required
}
message EvaluateGroupsRequest {
int32 incoming_port = 1;
string host = 2;
string header_connection_properties = 3;
string header_client_tags = 4;
}
message EvaluateGroupsResponse {
repeated string group_ids = 1; // required
}
message EvaluateAuthDelegationRequest {
int32 incoming_port = 1; // required
}
message EvaluateAuthDelegationResponse {
bool is_auth_delegated = 1; // required
}
message EvaluateRequestSourceRequest {
int32 incoming_port = 1; // required
}
message EvaluateRequestSourceResponse {
string set_request_source = 1;
}
service QueryApi {
rpc CreateOrUpdateQuery (Query) returns (Empty);
rpc GetQuery (QueryGetRequest) returns (QueryGetResponse){
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
security: {};
};
};
rpc ListQueries (QueriesListRequest) returns (QueriesListResponse){
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
security: {};
summary: "Returns paginated list of queries submitted";
description: "List of queries are returned as per the pagination parameters in Request. Pagination is handled on client side.";
};
};
rpc FindBackendForQuery(FindBackendForQueryRequest) returns (FindBackendForQueryResponse){
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "Finds backend used for routing this query";
description: "Finds backend used for routing this query. Returns error message if backend is not found.";
};
};
}
message Query {
string id = 1; // required
string text = 2; // required
int64 submitted_at = 3; // required
string client_ip = 4;
string group_id = 5; // required
string backend_id = 6; // required
string username = 7;
string server_host = 8;
}
message QueryGetRequest {
string id = 1; // required
}
message QueryGetResponse {
Query query = 1; // required
}
message QueriesListRequest {
enum Order {
ASC = 0;
DESC = 1;
}
// standard
int32 count = 1;
Order order_by = 2;
int64 from = 3;
int64 to = 4;
int32 skip = 5;
reserved 6 to 10;
// custom fields to filter on
string username = 11;
string backend_id = 12;
string group_id = 13;
}
message QueriesListResponse {
int32 Count = 1; // required
repeated Query items = 2;
}
message FindBackendForQueryRequest {
string query_id = 1; // required
}
message FindBackendForQueryResponse {
string backend_id = 1; // required
string group_id = 2; // required
}