-
Notifications
You must be signed in to change notification settings - Fork 110
/
indradb.proto
375 lines (321 loc) · 10.3 KB
/
indradb.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
syntax = "proto3";
package indradb;
import "google/protobuf/timestamp.proto";
import "google/protobuf/empty.proto";
// A UUID.
message Uuid {
bytes value = 1;
}
// A string that must be less than 256 characters long, and can only contain
// letters, numbers, dashes and underscores. This is used for vertex and edge
// types, as well as property names.
message Identifier {
string value = 1;
}
// A JSON value.
message Json {
string value = 1;
}
// An edge.
//
// Edges are how you would represent a verb or a relationship in the
// datastore. An example might be "liked" or "reviewed". Edges are typed and
// directed.
message Edge {
// The id of the outbound vertex.
Uuid outbound_id = 1;
// The type of the edge.
Identifier t = 2;
// The id of the inbound vertex.
Uuid inbound_id = 3;
}
// A vertex.
//
// Vertices are how you would represent nouns in the datastore. An example
// might be a user, or a movie. All vertices have a unique ID and a type.
message Vertex {
// The id of the vertex.
Uuid id = 1;
// The type of the vertex.
Identifier t = 2;
}
// A query to get a set of values from the database.
message Query {
oneof query {
// Gets all vertices.
google.protobuf.Empty all_vertex = 1;
// Gets a range of vertices.
RangeVertexQuery range_vertex = 2;
// Gets a specific set of vertices.
SpecificVertexQuery specific_vertex = 3;
// Gets vertices with or without a given property.
VertexWithPropertyPresenceQuery vertex_with_property_presence = 4;
// Gets vertices with a property equal to a given value.
VertexWithPropertyValueQuery vertex_with_property_value = 5;
// Gets all edges.
google.protobuf.Empty all_edge = 6;
// Gets a specific set of edges.
SpecificEdgeQuery specific_edge = 7;
// Gets edges with or without a given property.
EdgeWithPropertyPresenceQuery edge_with_property_presence = 8;
// Gets edges with a property equal to a given value.
EdgeWithPropertyValueQuery edge_with_property_value = 9;
// Gets the vertices associated with edges, or edges associated with
// vertices.
PipeQuery pipe = 10;
// Returns the properties associated with a vertex or edge.
PipePropertyQuery pipe_property = 11;
// Gets vertices or edges with or without a property.
PipeWithPropertyPresenceQuery pipe_with_property_presence = 12;
// Gets vertices or edges with a property equal to a given value.
PipeWithPropertyValueQuery pipe_with_property_value = 13;
// Includes the results of a query in output.
IncludeQuery include = 14;
// Counts the number of items returned from a query.
CountQuery count = 15;
}
}
// Gets a range of vertices.
message RangeVertexQuery {
// Limits the number of vertices to get.
uint32 limit = 1;
// Filters the type of vertices returned.
Identifier t = 2;
// Sets the lowest vertex ID to return.
Uuid start_id = 3;
}
// Gets a specific set of vertices.
message SpecificVertexQuery {
// The IDs of the vertices to get.
repeated Uuid ids = 1;
}
// Gets vertices with or without a given property.
message VertexWithPropertyPresenceQuery {
// The name of the property.
Identifier name = 1;
}
// Gets vertices with a property equal to a given value.
message VertexWithPropertyValueQuery {
// The name of the property.
Identifier name = 1;
// The value of the property.
Json value = 2;
}
// Gets a specific set of edges.
message SpecificEdgeQuery {
// The edges to get.
repeated Edge edges = 1;
}
// Gets edges with or without a given property.
message EdgeWithPropertyPresenceQuery {
// The name of the property.
Identifier name = 1;
}
// Gets edges with a property equal to a given value.
message EdgeWithPropertyValueQuery {
// The name of the property.
Identifier name = 1;
// The value of the property.
Json value = 2;
}
// Gets the vertices associated with edges, or edges associated with
// vertices.
message PipeQuery {
// The query to build off of.
Query inner = 1;
// Whether to get outbound or inbound vertices on the edges.
EdgeDirection direction = 2;
// Limits the number of vertices to get.
uint32 limit = 3;
// Filters the type of vertices returned.
Identifier t = 4;
}
// Returns the properties associated with a vertex or edge.
message PipePropertyQuery {
// The inner query.
Query inner = 1;
// The property name to get. If `None`, all properties will be fetched.
Identifier name = 2;
}
// Gets vertices or edges with or without a property.
message PipeWithPropertyPresenceQuery {
// The query to filter.
Query inner = 1;
// The name of the property.
Identifier name = 2;
// Whether we should look for property presence or lack thereof.
bool exists = 3;
}
// Gets vertices or edges with a property equal to a given value.
message PipeWithPropertyValueQuery {
// The query to filter.
Query inner = 1;
// The name of the property.
Identifier name = 2;
// The value of the property.
Json value = 3;
// Whether we should look for property equality or non-equality.
bool equal = 4;
}
// Includes the results of a query in output.
//
// The outermost part of a query will always be explicitly included. This
// allows you to also output an intermediate result.
message IncludeQuery {
// The query to export.
Query inner = 1;
}
// Counts the number of items returned from a query.
message CountQuery {
// The query to export.
Query inner = 1;
}
// Value(s) returned from a query.
message QueryOutputValue {
oneof value {
QueryOutputVertices vertices = 1;
QueryOutputEdges edges = 2;
uint64 count = 3;
QueryOutputVertexProperties vertex_properties = 4;
QueryOutputEdgeProperties edge_properties = 5;
}
}
message QueryOutputVertices {
repeated Vertex vertices = 1;
}
message QueryOutputEdges {
repeated Edge edges = 1;
}
message QueryOutputVertexProperties {
repeated VertexProperties vertex_properties = 1;
}
message QueryOutputEdgeProperties {
repeated EdgeProperties edge_properties = 1;
}
// Specifies what kind of items should be piped from one type of query to
// another.
//
// Edge and vertex queries can build off of one another via pipes - e.g. you
// can get the outbound edges of a set of vertices by piping from a vertex
// query to an edge query. `EdgeDirection`s are used to specify which
// end of things you want to pipe - either the outbound items or the inbound
// items.
enum EdgeDirection {
OUTBOUND = 0;
INBOUND = 1;
}
// A property.
message NamedProperty {
reserved 1;
// The id of the vertex.
Identifier name = 3;
// The property value.
Json value = 2;
}
// Represents a vertex property.
message VertexProperty {
// The id of the vertex.
Uuid id = 1;
// The property value.
Json value = 2;
}
// A vertex with properties.
message VertexProperties {
// The vertex.
Vertex vertex = 1;
// All of the vertex's properties.
repeated NamedProperty props = 2;
}
// Represents an edge property.
message EdgeProperty {
// The edge.
Edge edge = 1;
// The property value.
Json value = 2;
}
// An edge with properties.
message EdgeProperties {
// The edge.
Edge edge = 1;
// All of the edge's properties.
repeated NamedProperty props = 2;
}
// An item to insert, as part of a bulk insert request.
message BulkInsertItem {
oneof item {
Vertex vertex = 1;
Edge edge = 2;
VertexPropertyBulkInsertItem vertex_property = 3;
EdgePropertyBulkInsertItem edge_property = 4;
}
}
// A vertex property to insert.
message VertexPropertyBulkInsertItem {
reserved 2;
Uuid id = 1;
Identifier name = 4;
Json value = 3;
}
// An edge property to insert.
message EdgePropertyBulkInsertItem {
reserved 2;
Edge edge = 1;
Identifier name = 4;
Json value = 3;
}
// A request to index a property.
message IndexPropertyRequest {
Identifier name = 1;
}
message SetPropertiesRequest {
Query q = 1;
Identifier name = 2;
Json value = 3;
}
message CreateResponse {
bool created = 1;
}
// A request to execute a plugin.
message ExecutePluginRequest {
string name = 1;
Json arg = 2;
}
// A response to a plugin execution.
message ExecutePluginResponse {
Json value = 1;
}
service IndraDB {
// Pings the server.
rpc Ping(google.protobuf.Empty) returns (google.protobuf.Empty);
// Syncs persisted content. Depending on the datastore implementation,
// this has different meanings - including potentially being a no-op.
rpc Sync(google.protobuf.Empty) returns (google.protobuf.Empty);
// Creates a new vertex.
rpc CreateVertex(Vertex) returns (CreateResponse);
// Creates a new vertex with just a type specification. As opposed to
// `CreateVertex`, this is used when you do not want to manually specify
// the vertex's UUID. Returns the new vertex's UUID.
rpc CreateVertexFromType(Identifier) returns (Uuid);
// Creates a new edge.
rpc CreateEdge(Edge) returns (CreateResponse);
// Gets values specified by a query.
rpc Get(Query) returns (stream QueryOutputValue);
// Deletes values specified by a query.
rpc Delete(Query) returns (google.protobuf.Empty);
// Sets properties.
rpc SetProperties(SetPropertiesRequest) returns (google.protobuf.Empty);
// Bulk inserts many vertices, edges, and/or properties.
//
// Note that datastores have discretion on how to approach safeguard vs
// performance tradeoffs. In particular:
// * If the datastore is disk-backed, it may or may not flush before
// returning.
// * The datastore might not verify for correctness; e.g., it might not
// ensure that the relevant vertices exist before inserting an edge.
rpc BulkInsert(stream BulkInsertItem) returns (google.protobuf.Empty);
// Enables indexing on a specified property. When indexing is enabled on a
// property, it's possible to query on its presence and values.
rpc IndexProperty(IndexPropertyRequest) returns (google.protobuf.Empty);
// Executes a plugin and returns back the response from the plugin.
rpc ExecutePlugin(ExecutePluginRequest) returns (ExecutePluginResponse);
}