/
service.proto
373 lines (305 loc) · 9.45 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
syntax = "proto3";
package berty.node;
import "api/protobuf/graphql/graphql.proto";
import "api/p2p/event.proto";
import "api/node/kind.proto";
import "network/metrics.proto";
import "network/peer.proto";
import "entity/contact.proto";
import "entity/conversation.proto";
import "entity/message.proto";
import "pkg/deviceinfo/deviceinfo.proto";
import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";
option go_package = "berty.tech/core/api/node";
service Service {
// return node current ID
rpc ID (Void) returns (berty.network.Peer) {
option (gql.graphql_type) = "Query";
};
//
// Events
//
// yield new events in real-time
rpc EventStream (EventStreamInput) returns (stream berty.p2p.Event) {
option (gql.graphql_type) = "Subscription";
};
// list old events
rpc EventList (EventListInput) returns (stream berty.p2p.Event) {
option (gql.graphql_output) = ".berty.node.EventListConnection";
option (gql.graphql_type) = "Query";
};
rpc GetEvent (gql.Node) returns (berty.p2p.Event) {
option (gql.graphql_type) = "Query";
};
rpc EventSeen (EventIDInput) returns (berty.p2p.Event) {
option (gql.graphql_type) = "Mutation";
}
//
// Contacts
//
rpc ContactRequest (ContactRequestInput) returns (berty.entity.Contact) {
option (gql.graphql_type) = "Mutation";
};
rpc ContactAcceptRequest (berty.entity.Contact) returns (berty.entity.Contact) {
option (gql.graphql_type) = "Mutation";
};
rpc ContactRemove (berty.entity.Contact) returns (berty.entity.Contact) {
option (gql.graphql_type) = "Mutation";
};
rpc ContactUpdate (berty.entity.Contact) returns (berty.entity.Contact) {
option (gql.graphql_type) = "Mutation";
};
rpc ContactList (ContactListInput) returns (stream berty.entity.Contact) {
option (gql.graphql_output) = ".berty.node.ContactListConnection";
option (gql.graphql_type) = "Query";
};
rpc Contact (ContactInput) returns (berty.entity.Contact) {
option (gql.graphql_type) = "Query";
};
//
// Conversations
//
rpc ConversationCreate (ConversationCreateInput) returns (berty.entity.Conversation) {
option (gql.graphql_type) = "Mutation";
};
rpc ConversationList (ConversationListInput) returns (stream berty.entity.Conversation) {
option (gql.graphql_output) = ".berty.node.ConversationListConnection";
option (gql.graphql_type) = "Query";
};
rpc ConversationInvite (ConversationManageMembersInput) returns (berty.entity.Conversation) {
option (gql.graphql_type) = "Mutation";
};
rpc ConversationExclude (ConversationManageMembersInput) returns (berty.entity.Conversation) {
option (gql.graphql_type) = "Mutation";
};
rpc ConversationAddMessage (ConversationAddMessageInput) returns (berty.p2p.Event) {
option (gql.graphql_type) = "Mutation";
};
rpc GetConversation (gql.Node) returns (berty.entity.Conversation) {
option (gql.graphql_type) = "Query";
};
rpc GetConversationMember (gql.Node) returns (berty.entity.ConversationMember) {
option (gql.graphql_type) = "Query";
};
rpc ConversationRead (gql.Node) returns (berty.entity.Conversation) {
option (gql.graphql_type) = "Mutation";
}
//rpc ConversationLeave(berty.entity.Conversation) returns (berty.entity.Conversation);
//rpc ConversationJoinRequest(berty.entity.Conversation) returns (berty.entity.Conversation);
//rpc ConverstionAcceptJoinRequest(berty.entity.Conversation) returns (berty.entity.Conversation);
//
// Devtools
//
// HandleEvent is the unencrypted (and unsafe) version of HandleEnvelope.
// it's only exposed over the node API, it should be completely deactivated in public releases
rpc HandleEvent (berty.p2p.Event) returns (Void) {
};
rpc GenerateFakeData (Void) returns (Void) {
option (gql.graphql_type) = "Mutation";
};
rpc RunIntegrationTests (IntegrationTestInput) returns (IntegrationTestOutput) {
option (gql.graphql_type) = "Mutation";
};
rpc DebugPing (PingDestination) returns (Void) {
};
rpc DebugRequeueEvent (EventIDInput) returns (berty.p2p.Event) {
option (gql.graphql_type) = "Mutation";
};
rpc DebugRequeueAll (Void) returns (Void) {
option (gql.graphql_type) = "Mutation";
};
rpc DeviceInfos (Void) returns (berty.pkg.deviceinfo.DeviceInfos) {
option (gql.graphql_type) = "Query";
};
rpc AppVersion (Void) returns (AppVersionOutput) {
option (gql.graphql_type) = "Query";
};
rpc Peers (Void) returns (berty.network.Peers) {
option (gql.graphql_type) = "Query";
};
rpc Protocols (berty.network.Peer) returns (ProtocolsOutput) {
option (gql.graphql_type) = "Query";
};
rpc LogStream (LogStreamInput) returns (stream LogEntry) {
option (gql.graphql_type) = "Subscription";
};
rpc LogfileList (Void) returns (stream LogfileEntry) {
option (gql.graphql_type) = "Query";
}
rpc LogfileRead (LogfileReadInput) returns (stream LogEntry) {
option (gql.graphql_type) = "Subscription";
}
//
// Metrics
//
// Yield bandwidth in real-time
rpc MonitorBandwidth (berty.network.BandwidthStats) returns (stream berty.network.BandwidthStats) {
option (gql.graphql_type) = "Subscription";
};
// Yield new peers in real-time
rpc MonitorPeers (Void) returns (stream berty.network.Peer) {
option (gql.graphql_type) = "Subscription";
};
rpc Panic (Void) returns (Void) {
option (gql.graphql_type) = "Query";
};
}
message ProtocolsOutput {
repeated string protocols = 1;
};
message AppVersionOutput {
string version = 1;
}
message PingDestination {
string destination = 1;
}
message ContactRequestInput {
berty.entity.Contact contact = 1;
string intro_text = 2;
}
message ConversationAddMessageInput {
berty.entity.Conversation conversation = 1;
berty.entity.Message message = 2;
}
message EventStreamInput {
berty.p2p.Event filter = 1;
}
// Node
//
// EventList
//
message EventListInput {
berty.p2p.Event filter = 1;
NullableTrueFalse only_without_acked_at = 2;
Pagination paginate = 99 [(gql.graphql_spread) = true];
}
message EventEdge {
berty.p2p.Event node = 1;
string cursor = 2;
}
message EventListConnection {
repeated EventEdge edges = 1;
PageInfo page_info = 99 [(gql.graphql_non_nullable) = true];
}
//
// ContactList
//
message ContactListInput {
berty.entity.Contact filter = 1;
Pagination paginate = 99 [(gql.graphql_spread) = true];
}
message ContactEdge {
berty.entity.Contact node = 1;
string cursor = 2;
}
message ContactListConnection {
repeated ContactEdge edges = 1;
PageInfo page_info = 99 [(gql.graphql_non_nullable) = true];
}
message ContactInput {
berty.entity.Contact filter = 1;
}
//
// ConversationList
//
message ConversationListInput {
berty.entity.Conversation filter = 1;
Pagination paginate = 99 [(gql.graphql_spread) = true];
}
message ConversationEdge {
berty.entity.Conversation node = 1;
string cursor = 2;
}
message ConversationListConnection{
repeated ConversationEdge edges = 1;
PageInfo page_info = 99 [(gql.graphql_non_nullable) = true];
}
message ConversationCreateInput {
repeated berty.entity.Contact contacts = 1;
string title = 2;
string topic = 3;
}
message ConversationManageMembersInput {
berty.entity.Conversation conversation = 1;
repeated berty.entity.ConversationMember members = 2;
}
//
// common
//
message Pagination {
// argument definition
string order_by = 1;
bool order_desc = 2;
// feed definition
int32 first = 11 [(gql.graphql_nullable) = true];
string after = 12 [(gql.graphql_nullable) = true];
int32 last = 13 [(gql.graphql_nullable) = true];
string before = 14 [(gql.graphql_nullable) = true];
}
message PageInfo {
string start_cursor = 1;
string end_cursor = 2;
bool has_next_page = 3;
bool has_previous_page = 4;
// non-standard
uint32 count = 5;
}
message IntegrationTestInput {
string name = 1;
}
message IntegrationTestOutput {
string name = 1;
bool success = 2;
string verbose = 3;
google.protobuf.Timestamp started_at = 4 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false];
google.protobuf.Timestamp finished_at = 5 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false];
}
message Void {
bool T = 1;
}
enum NullableTrueFalse {
Null = 0;
True = 1;
False = 2;
}
message EventIDInput {
string event_id = 1 [(gql.graphql_id) = true, (gogoproto.customname) = "EventID"];
}
//
// Logs
//
message LogStreamInput {
bool continues = 1; // stay connected and wait for new lines
string log_level = 2; // "debug", "info", "warn", "error"
string namespaces = 3; // "core.*", "*", ...
int32 last = 4; // number of previous lines to return, capped by the rotating buffer size
}
message LogEntry {
string line = 1; // line
// string log_level = 2;
// namespace
// ...
}
message LogfileEntry {
string path = 1;
int32 filesize = 2;
google.protobuf.Timestamp created_at = 3 [(gogoproto.stdtime) = true, (gogoproto.nullable) = true];
google.protobuf.Timestamp updated_at = 4 [(gogoproto.stdtime) = true, (gogoproto.nullable) = true];
}
message LogfileReadInput {
string path = 1;
// position
}
//
// Node Event (see kind.proto)
//
// NodeEvent is embedded in a classical p2p.Event with p2p.Event.Kind = p2p.Kind_Node
// we don't need to add base information as the created_at field, as we can already
// read them from the parent p2p.Event.
message NodeEvent {
// Kind is an enum defining the event type.
Kind kind = 1;
// Attributes is a nested protobuf message containing per-event-type additional attributes.
bytes attributes = 2;
}