-
Notifications
You must be signed in to change notification settings - Fork 2
/
webhook.proto
361 lines (289 loc) · 11.5 KB
/
webhook.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
syntax = "proto3";
package hiber.webhook;
import "base.proto";
import "tag.proto";
option java_multiple_files = false;
option java_package = "global.hiber.api.grpc.webhook";
option java_outer_classname = "WebhookApi";
option go_package = ".;hiber";
service WebhookService {
rpc List (ListWebhooksRequest) returns (ListWebhooksRequest.Response);
rpc History (WebhookHistoryRequest) returns (WebhookHistoryRequest.Response);
rpc Create (CreateWebhookRequest) returns (Webhook);
rpc Enable (EnableWebhookRequest) returns (Webhook);
rpc Disable (DisableWebhookRequest) returns (Webhook);
rpc UpdateFilter (UpdateWebhookFilterRequest) returns (Webhook);
rpc Update (UpdateWebhookRequest) returns (Webhook);
rpc UpdateWebhooks (UpdateWebhooksRequest) returns (UpdateWebhooksRequest.Response);
rpc UpdateTags (UpdateWebhookTagsRequest) returns (UpdateWebhookTagsRequest.Response);
rpc Get (GetWebhookRequest) returns (Webhook);
rpc Delete (DeleteWebhookRequest) returns (DeleteWebhookRequest.Response);
}
/* Webhook publisher that sends events to a webhook.
*
* When the webhook call fails, it enters cooldown, so as not to overload a failing server
* or spend unnecessary time on an incorrectly configured webhook.
* When the first call after the cooldown time has passed fails again, the cooldown is increased as follows:
* 1m, 2m, 5m, 10m, 15m, 30m, 1h, 3h, 6h, 12h, 24h.
*
* To disable the cooldown, use EnableWebhookRequest to re-enable it.
*/
message Webhook {
int64 id = 1;
string organization = 2;
string created_by = 10;
string description = 3;
WebhookData data = 4;
WebhookFilters filters = 5;
repeated hiber.tag.Tag tags = 6;
Health health = 7;
HealthConfig health_config = 9;
/* The time the cooldown ends. */
Timestamp in_cooldown_until = 8;
enum ContentType {
DEFAULT = 0;
JSON = 1;
PROTO = 2;
}
message WebhookData {
string url = 1;
/* Used to generate the HMAC-SHA256 header on every webhook call, which you can use to verify the message.
* The HMAC-SHA256 header is calculated with the message body and this secret.
* There are many examples of how to do this in different languages, for example:
* https://github.com/danharper/hmac-examples
*/
optional string secret = 2;
/* The header that the hmac value is placed in. Defaults to X-Hub-Signature. */
string hmac_header_name = 9;
ContentType content_type = 3;
bool disabled = 4;
optional int64 certificate_id = 5;
optional string certificate_name = 6;
optional int64 ca_certificate_id = 7;
optional string ca_certificate_name = 8;
/* Custom headers to add to every call. */
map<string, string> custom_headers = 10;
}
message WebhookFilters {
optional Filter.Events event_types = 1;
optional Filter.Modems modem_numbers = 2;
optional Filter.Tags tags = 3;
/* Filter events by health level caused. */
repeated string health_levels = 4;
}
/* Health configuration for the webhook. Defines how the health is calculated. */
message HealthConfig {
reserved 1;
/* Period to consider when determining health from warning events. Warning events cannot be resolved. */
Duration health_warning_period = 2;
/* Allowed percentage of failures.
* If the failure percentage is higher, within the warning period, the health is switched to WARNING.
*/
int32 health_warning_failure_percentage = 3;
}
}
message WebhookSelection {
optional string description = 1;
optional string url = 2;
optional Filter.Webhooks webhooks = 3;
optional hiber.tag.TagSelection tags = 4;
repeated Health health = 5;
repeated int64 certificate_ids = 6;
/* Search in the all available text, like description and url. */
optional string search = 7;
}
message WebhookCall {
Timestamp time = 1;
string url = 2;
map<string, string> headers = 3;
bytes body_proto = 4;
string body_json = 7;
bool successful = 5;
string error = 6;
}
message WebhookHistorySelection {
optional bool only_failures = 2;
optional TimeRange time_range = 3;
}
message ListWebhooksRequest {
enum Sort {
/* Sort by id. */
DEFAULT = 0;
/* Sort by id, high to low. */
ID_DESC = 1;
/* Sort by description. */
DESCRIPTION = 2;
/* Sort by description, z to a. */
DESCRIPTION_DESC = 3;
/* Sort by url. */
URL = 4;
/* Sort by url, z to a. */
URL_DESC = 5;
/* Sort unhealthy webhooks before health webhooks. */
HEALTH = 6;
}
message Response {
repeated Webhook webhooks = 1;
ListWebhooksRequest request = 2;
Pagination.Result pagination = 3;
}
/* Pick the organization to use (/impersonate). If unset, your default organization is used. */
optional string organization = 1;
/* Select the webhooks to list. Optional, when omitted or empty everything is included. */
optional WebhookSelection selection = 2;
optional Pagination pagination = 3;
repeated Sort sort = 4;
}
message WebhookHistoryRequest {
message Response {
repeated WebhookCall calls = 1;
WebhookHistoryRequest request = 2;
Pagination.Result pagination = 3;
}
/* Pick the organization to use (/impersonate). If unset, your default organization is used. */
optional string organization = 1;
int64 webhook_id = 2;
optional WebhookHistorySelection selection = 3;
optional Pagination pagination = 4;
}
message CreateWebhookRequest {
/* Pick the organization to use (/impersonate). If unset, your default organization is used. */
optional string organization = 1;
string description = 2;
Webhook.WebhookData data = 3;
optional Webhook.WebhookFilters filters = 4;
/* Filter events by health level caused. */
repeated string health_levels = 7;
repeated int64 tags = 5;
/* Optionally, a client certificate can be used for the webhook call.
* See the CertificateService for certificate management options.
*/
optional int64 certificate_id = 6;
}
message GetWebhookRequest {
int64 id = 1;
/* Pick the organization to use (/impersonate). If unset, your default organization is used. */
string organization = 2;
reserved 3;
}
message EnableWebhookRequest {
int64 id = 1;
/* Pick the organization to use (/impersonate). If unset, your default organization is used. */
string organization = 2;
reserved 3;
}
message DisableWebhookRequest {
int64 id = 1;
/* Pick the organization to use (/impersonate). If unset, your default organization is used. */
string organization = 2;
reserved 3;
}
message UpdateWebhookFilterRequest {
int64 id = 1;
/* Pick the organization to use (/impersonate). If unset, your default organization is used. */
string organization = 2;
reserved 6;
optional Filter.Events.Update deprecated_event_filter = 7 [deprecated = true];
optional Filter.Events event_filter = 12;
optional Filter.Modems.Update deprecated_modem_filter = 8 [deprecated = true];
optional Filter.Modems modem_filter = 13;
optional Filter.Tags.Update deprecated_tag_filter = 9 [deprecated = true];
optional Filter.Tags tag_filter = 14;
/* Add health levels to the health levels filter. */
repeated string add_health_levels_to_filter = 10;
/* Remove health levels from the health levels filter. */
repeated string remove_health_levels_from_filter = 11;
}
message UpdateWebhookRequest {
message UpdateWebhook {
message UpdateEvents {
option deprecated = true;
bool updated = 1;
Filter.Events value = 2;
}
message UpdateModems {
option deprecated = true;
bool updated = 1;
Filter.Modems value = 2;
}
message UpdateTags {
option deprecated = true;
bool updated = 1;
Filter.Tags value = 2;
}
string url = 1;
optional UpdateClearableString deprecated_secret = 2 [deprecated = true];
optional string secret = 22;
optional Webhook.ContentType content_type = 3;
optional UpdateClearableString deprecated_description = 4 [deprecated = true];
optional string description = 23;
optional Filter.Events.Update deprecated_event_filter = 10 [deprecated = true];
optional Filter.Events event_filter = 24;
optional Filter.Modems.Update deprecated_modem_filter = 11 [deprecated = true];
optional Filter.Modems modem_filter = 25;
optional Filter.Tags.Update deprecated_tag_filter = 12 [deprecated = true];
optional Filter.Tags tag_filter = 26;
/* Add health levels to the health levels filter. */
repeated string add_health_levels = 16;
/* Remove health levels from the health levels filter. */
repeated string remove_health_levels = 17;
optional UpdateBoolean deprecated_active = 8 [deprecated = true];
optional bool active = 27;
/* A value of 0 removes the certificate */
optional UpdateOptionalId deprecated_certificate_id = 9 [deprecated = true];
optional int64 certificate_id = 28;
reserved 13;
/* Period to consider when determining health from warning events. Warning events cannot be resolved.
* Set this to 0 to disable warnings based on failure percentage.
*/
optional Duration health_warning_period = 14;
/* Allowed percentage of call failures.
* If the failure percentage is higher, within the warning period, the health is switched to WARNING.
*/
optional uint32 health_warning_failure_percentage = 29;
optional UpdateZeroableInt deprecated_health_warning_failure_percentage = 15 [deprecated = true];
/* Update the custom hmac header, or clear to reset to default. */
optional string update_hmac_header_name = 30;
optional UpdateClearableString deprecated_update_hmac_header_name = 18 [deprecated = true];
/* Custom headers to add to every call. */
map<string, string> add_custom_headers = 19;
/* Remove previously configured custom headers. */
repeated string remove_custom_headers = 20;
/* Replace the custom headers to add to every call. If set, remove_custom_headers is ignored. */
map<string, string> replace_custom_headers = 21;
}
int64 id = 1;
/* Pick the organization to use (/impersonate). If unset, your default organization is used. */
string organization = 2;
UpdateWebhook update = 3;
reserved 4;
}
message UpdateWebhooksRequest {
message Update {
int64 id = 1;
UpdateWebhookRequest.UpdateWebhook update = 2;
}
message Response {
repeated Webhook webhooks = 1;
UpdateWebhooksRequest request = 2;
}
/* Pick the organization to use (/impersonate). If unset, your default organization is used. */
optional string organization = 1;
repeated Update webhook_updates = 2;
}
message UpdateWebhookTagsRequest {
message Response {
repeated Webhook webhooks = 1;
}
optional string organization = 1;
repeated int64 webhook_ids = 2;
hiber.tag.UpdateTagsForItem update = 3;
reserved 4;
}
message DeleteWebhookRequest {
message Response {
}
int64 id = 1;
/* Pick the organization to use (/impersonate). If unset, your default organization is used. */
string organization = 2;
}