-
Notifications
You must be signed in to change notification settings - Fork 302
/
applicationserver_web.proto
302 lines (260 loc) · 9.57 KB
/
applicationserver_web.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
// Copyright © 2019 The Things Network Foundation, The Things Industries B.V.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto3";
package ttn.lorawan.v3;
import "google/api/annotations.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/field_mask.proto";
import "google/protobuf/timestamp.proto";
import "protoc-gen-openapiv2/options/annotations.proto";
import "thethings/flags/annotations.proto";
import "ttn/lorawan/v3/error.proto";
import "ttn/lorawan/v3/identifiers.proto";
import "validate/validate.proto";
option go_package = "go.thethings.network/lorawan-stack/v3/pkg/ttnpb";
message ApplicationWebhookIdentifiers {
option (thethings.flags.message) = {
select: true,
set: true
};
ApplicationIdentifiers application_ids = 1 [(validate.rules).message.required = true];
string webhook_id = 2 [(validate.rules).string = {
pattern: "^[a-z0-9](?:[-]?[a-z0-9]){2,}$",
max_len: 36
}];
}
message ApplicationWebhookTemplateIdentifiers {
option (thethings.flags.message) = {
select: true,
set: true
};
string template_id = 1 [(validate.rules).string = {
pattern: "^[a-z0-9](?:[-]?[a-z0-9]){2,}$",
max_len: 36
}];
}
// ApplicationWebhookTemplateField represents a custom field that needs to be filled by the user in order to use the template.
// A field can be an API key, an username or password, or any custom platform specific field (such as region).
// The fields are meant to be replaced inside the URLs and headers when the webhook is created.
message ApplicationWebhookTemplateField {
string id = 1 [(validate.rules).string = {
pattern: "^[a-z0-9](?:[-]?[a-z0-9]){2,}$",
max_len: 36
}];
string name = 2 [(validate.rules).string.max_len = 20];
string description = 3 [(validate.rules).string.max_len = 100];
// Secret decides if the field should be shown in plain-text or should stay hidden.
bool secret = 4;
string default_value = 5 [(validate.rules).string.max_len = 100];
bool optional = 6;
}
message ApplicationWebhookTemplate {
ApplicationWebhookTemplateIdentifiers ids = 1 [(validate.rules).message.required = true];
string name = 2 [(validate.rules).string.max_len = 20];
string description = 3 [(validate.rules).string.max_len = 100];
string logo_url = 4 [(validate.rules).string.uri = true];
string info_url = 5 [(validate.rules).string.uri = true];
string documentation_url = 6 [(validate.rules).string.uri = true];
// The base URL of the template. Can contain template fields, in RFC 6570 format.
string base_url = 7 [(validate.rules).string.uri = true];
// The HTTP headers used by the template. Both the key and the value can contain template fields.
map<string, string> headers = 8 [(validate.rules).map = {
max_pairs: 50,
keys: {
string: {max_len: 64}
},
values: {
string: {max_len: 256}
}
}];
string format = 9 [(validate.rules).string = {
pattern: "^[a-z0-9](?:[-]?[a-z0-9]){2,}$",
max_len: 20
}];
repeated ApplicationWebhookTemplateField fields = 10;
// Control the creation of the downlink queue operations API key.
bool create_downlink_api_key = 19;
message Message {
// Path to append to the base URL. Can contain template fields, in RFC 6570 format.
string path = 1 [(validate.rules).string.max_len = 64];
}
Message uplink_message = 11;
Message uplink_normalized = 23;
Message join_accept = 12;
Message downlink_ack = 13;
Message downlink_nack = 14;
Message downlink_sent = 15;
Message downlink_failed = 16;
Message downlink_queued = 17;
Message downlink_queue_invalidated = 21;
Message location_solved = 18;
Message service_data = 20;
google.protobuf.FieldMask field_mask = 22;
// next: 24
}
message ApplicationWebhookTemplates {
repeated ApplicationWebhookTemplate templates = 1;
}
message ApplicationWebhookHealth {
option (thethings.flags.message) = {
select: true,
set: false
};
message WebhookHealthStatusHealthy {
option (thethings.flags.message) = {
select: true,
set: false
};
}
message WebhookHealthStatusUnhealthy {
option (thethings.flags.message) = {
select: true,
set: false
};
uint64 failed_attempts = 1;
google.protobuf.Timestamp last_failed_attempt_at = 2 [(validate.rules).timestamp.required = true];
ErrorDetails last_failed_attempt_details = 3;
}
oneof status {
WebhookHealthStatusHealthy healthy = 1;
WebhookHealthStatusUnhealthy unhealthy = 2;
}
}
message ApplicationWebhook {
option (thethings.flags.message) = {
select: true,
set: true
};
ApplicationWebhookIdentifiers ids = 1 [
(validate.rules).message.required = true,
(thethings.flags.field) = {
select: false,
hidden: true
}
];
google.protobuf.Timestamp created_at = 2 [(thethings.flags.field) = {
select: false,
set: false
}];
google.protobuf.Timestamp updated_at = 3 [(thethings.flags.field) = {
select: false,
set: false
}];
// Base URL to which the message's path is appended.
string base_url = 4 [(validate.rules).string.uri = true];
// HTTP headers to use.
map<string, string> headers = 5 [(validate.rules).map = {
max_pairs: 50,
keys: {
string: {max_len: 64}
},
values: {
string: {max_len: 4096}
}
}];
// The format to use for the body.
// Supported values depend on the Application Server configuration.
string format = 6 [(validate.rules).string = {
pattern: "^[a-z0-9](?:[-]?[a-z0-9]){2,}$",
max_len: 20
}];
// The ID of the template that was used to create the Webhook.
ApplicationWebhookTemplateIdentifiers template_ids = 15;
// The value of the fields used by the template. Maps field.id to the value.
map<string, string> template_fields = 16;
// The API key to be used for downlink queue operations.
// The field is provided for convenience reasons, and can contain API keys with additional rights (albeit this is discouraged).
string downlink_api_key = 17 [(validate.rules).string.max_len = 128];
message Message {
option (thethings.flags.message) = {
select: true,
set: true
};
// Path to append to the base URL.
string path = 1 [(validate.rules).string.max_len = 64];
}
Message uplink_message = 7;
Message uplink_normalized = 22;
Message join_accept = 8;
Message downlink_ack = 9;
Message downlink_nack = 10;
Message downlink_sent = 11;
Message downlink_failed = 12;
Message downlink_queued = 13;
Message downlink_queue_invalidated = 19;
Message location_solved = 14;
Message service_data = 18;
ApplicationWebhookHealth health_status = 20;
google.protobuf.FieldMask field_mask = 21;
reserved 24;
reserved "queue";
// next: 25
}
message ApplicationWebhooks {
repeated ApplicationWebhook webhooks = 1;
}
message ApplicationWebhookFormats {
// Format and description.
map<string, string> formats = 1;
}
message GetApplicationWebhookRequest {
ApplicationWebhookIdentifiers ids = 1 [(validate.rules).message.required = true];
google.protobuf.FieldMask field_mask = 2;
}
message ListApplicationWebhooksRequest {
ApplicationIdentifiers application_ids = 1 [(validate.rules).message.required = true];
google.protobuf.FieldMask field_mask = 2;
}
message SetApplicationWebhookRequest {
ApplicationWebhook webhook = 1 [(validate.rules).message.required = true];
google.protobuf.FieldMask field_mask = 2;
}
message GetApplicationWebhookTemplateRequest {
ApplicationWebhookTemplateIdentifiers ids = 1 [(validate.rules).message.required = true];
google.protobuf.FieldMask field_mask = 2;
}
message ListApplicationWebhookTemplatesRequest {
google.protobuf.FieldMask field_mask = 1;
}
service ApplicationWebhookRegistry {
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_tag) = {description: "Manage application webhooks."};
rpc GetFormats(google.protobuf.Empty) returns (ApplicationWebhookFormats) {
option (google.api.http) = {get: "/as/webhook-formats"};
}
rpc GetTemplate(GetApplicationWebhookTemplateRequest) returns (ApplicationWebhookTemplate) {
option (google.api.http) = {get: "/as/webhook-templates/{ids.template_id}"};
}
rpc ListTemplates(ListApplicationWebhookTemplatesRequest) returns (ApplicationWebhookTemplates) {
option (google.api.http) = {get: "/as/webhook-templates"};
}
rpc Get(GetApplicationWebhookRequest) returns (ApplicationWebhook) {
option (google.api.http) = {get: "/as/webhooks/{ids.application_ids.application_id}/{ids.webhook_id}"};
}
rpc List(ListApplicationWebhooksRequest) returns (ApplicationWebhooks) {
option (google.api.http) = {get: "/as/webhooks/{application_ids.application_id}"};
}
rpc Set(SetApplicationWebhookRequest) returns (ApplicationWebhook) {
option (google.api.http) = {
put: "/as/webhooks/{webhook.ids.application_ids.application_id}/{webhook.ids.webhook_id}"
body: "*"
additional_bindings {
post: "/as/webhooks/{webhook.ids.application_ids.application_id}"
body: "*"
}
};
}
rpc Delete(ApplicationWebhookIdentifiers) returns (google.protobuf.Empty) {
option (google.api.http) = {delete: "/as/webhooks/{application_ids.application_id}/{webhook_id}"};
}
}