Skip to content

Commit 6db92be

Browse files
authored
Merge pull request #98 from josephschorr/reflection-apis
Experimental Reflection apis
2 parents d12b0c6 + f9bbb28 commit 6db92be

1 file changed

Lines changed: 220 additions & 1 deletion

File tree

authzed/api/v1/experimental_service.proto

Lines changed: 220 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,67 @@ service ExperimentalService {
4444
};
4545
}
4646

47+
// NOTE: BulkCheckPermission has been promoted to the stable API as "CheckBulkPermission" and the
48+
// API will be removed from experimental in a future release.
4749
rpc BulkCheckPermission(BulkCheckPermissionRequest)
4850
returns (BulkCheckPermissionResponse) {
4951
option (google.api.http) = {
5052
post: "/v1/experimental/permissions/bulkcheckpermission"
5153
body: "*"
5254
};
55+
option deprecated = true;
56+
}
57+
58+
// EXPERIMENTAL: ReflectSchema is an API that allows clients to reflect the schema stored in
59+
// SpiceDB. This is useful for clients that need to introspect the schema of a SpiceDB instance.
60+
rpc ExperimentalReflectSchema(ExperimentalReflectSchemaRequest)
61+
returns (ExperimentalReflectSchemaResponse) {
62+
option (google.api.http) = {
63+
post: "/v1/experimental/reflectschema"
64+
body: "*"
65+
};
66+
}
67+
68+
// EXPERIMENTAL: ComputablePermissions is an API that allows clients to request the set of
69+
// permissions that compute based off a set of relations. For example, if a schema has a relation
70+
// `viewer` and a permission `view` defined as `permission view = viewer + editor`, then the
71+
// computable permissions for the relation `viewer` will include `view`.
72+
rpc ExperimentalComputablePermissions(ExperimentalComputablePermissionsRequest)
73+
returns (ExperimentalComputablePermissionsResponse) {
74+
option (google.api.http) = {
75+
post: "/v1/experimental/permissions/computable"
76+
body: "*"
77+
};
78+
}
79+
80+
// EXPERIMENTAL: DependentRelations is an API that allows clients to request the set of
81+
// relations that used to compute a permission, recursively. It is the inverse of the
82+
// ComputablePermissions API.
83+
rpc ExperimentalDependentRelations(ExperimentalDependentRelationsRequest)
84+
returns (ExperimentalDependentRelationsResponse) {
85+
option (google.api.http) = {
86+
post: "/v1/experimental/permissions/dependent"
87+
body: "*"
88+
};
89+
}
90+
91+
// EXPERIMENTAL: DiffSchema is an API that allows clients to request the difference between the
92+
// specified schema and the schema stored in SpiceDB. This is useful for clients that need to
93+
// introspect the schema of a SpiceDB instance.
94+
rpc ExperimentalSchemaDiff(ExperimentalSchemaDiffRequest)
95+
returns (ExperimentalSchemaDiffResponse) {
96+
option (google.api.http) = {
97+
post: "/v1/experimental/schemadiff"
98+
body: "*"
99+
};
53100
}
54101
}
55102

103+
// NOTE: Deprecated now that BulkCheckPermission has been promoted to the stable API as "CheckBulkPermission".
56104
message BulkCheckPermissionRequest {
57105
Consistency consistency = 1;
58106

59-
repeated BulkCheckPermissionRequestItem items = 2 [ (validate.rules).repeated .items.message.required = true ];
107+
repeated BulkCheckPermissionRequestItem items = 2 [ (validate.rules).repeated .items.message.required = true, deprecated=true ];
60108
}
61109

62110
message BulkCheckPermissionRequestItem {
@@ -136,3 +184,174 @@ message BulkExportRelationshipsResponse {
136184
Cursor after_result_cursor = 1;
137185
repeated Relationship relationships = 2;
138186
}
187+
188+
// Reflection types ////////////////////////////////////////////
189+
190+
message ExperimentalReflectSchemaRequest {
191+
Consistency consistency = 1;
192+
193+
// optional_filters defines optional filters that are applied in
194+
// an OR fashion to the schema, before being returned
195+
repeated ExpSchemaFilter optional_filters = 2;
196+
}
197+
198+
message ExperimentalReflectSchemaResponse {
199+
// definitions are the definitions defined in the schema.
200+
repeated ExpDefinition definitions = 1;
201+
202+
// caveats are the caveats defined in the schema.
203+
repeated ExpCaveat caveats = 2;
204+
205+
// read_at is the ZedToken at which the schema was read.
206+
ZedToken read_at = 3;
207+
}
208+
209+
message ExpSchemaFilter {
210+
enum KindFilter {
211+
KIND_FILTER_UNSPECIFIED = 0;
212+
KIND_FILTER_DEFINITION = 1;
213+
KIND_FILTER_CAVEAT = 2;
214+
KIND_FILTER_RELATION = 3;
215+
KIND_FILTER_PERMISSION = 4;
216+
}
217+
218+
// optional_definition_name_match is a regex that is matched against the definition or caveat name.
219+
// If not specified, will be ignored.
220+
string optional_definition_name_match = 1;
221+
222+
// optional_relation_or_permission_name_match is a regex that is matched against the relation or permission name.
223+
// If not specified, will be ignored.
224+
string optional_relation_or_permission_name_match = 2;
225+
226+
// kind_filters is a list of kinds to filter on. If not specified, will be ignored. If multiple are specified,
227+
// the filter will be applied in an OR fashion.
228+
repeated KindFilter kind_filters = 3;
229+
}
230+
231+
message ExpDefinition {
232+
string name = 1;
233+
string comment = 2;
234+
235+
repeated ExpRelation relations = 3;
236+
repeated ExpPermission permissions = 4;
237+
}
238+
239+
message ExpCaveat {
240+
string name = 1;
241+
string comment = 2;
242+
243+
repeated ExpCaveatParameter parameters = 3;
244+
string expression = 4;
245+
}
246+
247+
message ExpCaveatParameter {
248+
string name = 1;
249+
string type = 2;
250+
string parent_caveat_name = 3;
251+
}
252+
253+
message ExpRelation {
254+
string name = 1;
255+
string comment = 2;
256+
string parent_definition_name = 3;
257+
repeated ExpTypeReference subject_types = 4;
258+
}
259+
260+
message ExpTypeReference {
261+
// subject_definition_name is the name of the subject's definition.
262+
string subject_definition_name = 1;
263+
264+
// optional_caveat_name is the name of the caveat that is applied to the subject, if any.
265+
string optional_caveat_name = 2;
266+
267+
oneof typeref {
268+
// is_terminal_subject is true if the subject is terminal, meaning it is referenced directly vs a sub-relation.
269+
bool is_terminal_subject = 3;
270+
271+
// optional_relation_name is the name of the relation that is applied to the subject, if any.
272+
string optional_relation_name = 4;
273+
274+
// is_public_wildcard is true if the subject is a public wildcard.
275+
bool is_public_wildcard = 5;
276+
}
277+
}
278+
279+
message ExpPermission {
280+
string name = 1;
281+
string comment = 2;
282+
string parent_definition_name = 3;
283+
}
284+
285+
message ExperimentalComputablePermissionsRequest {
286+
Consistency consistency = 1;
287+
repeated ExpRelationReference relations = 2;
288+
289+
// optional_definition_name_match is a regex that is matched against the definition name(s)
290+
// for the permissions returned.
291+
// If not specified, will be ignored.
292+
string optional_definition_name_match = 3;
293+
}
294+
295+
message ExpRelationReference {
296+
string definition_name = 1;
297+
string relation_name = 2;
298+
}
299+
300+
message ExpPermissionReference {
301+
string definition_name = 1;
302+
string relation_name = 2;
303+
}
304+
305+
message ExperimentalComputablePermissionsResponse {
306+
repeated ExpPermissionReference permissions = 1;
307+
308+
// read_at is the ZedToken at which the schema was read.
309+
ZedToken read_at = 2;
310+
}
311+
312+
message ExperimentalDependentRelationsRequest {
313+
Consistency consistency = 1;
314+
ExpPermissionReference permission = 2;
315+
}
316+
317+
message ExperimentalDependentRelationsResponse {
318+
repeated ExpRelationReference relations = 1;
319+
320+
// read_at is the ZedToken at which the schema was read.
321+
ZedToken read_at = 2;
322+
}
323+
324+
message ExperimentalSchemaDiffRequest {
325+
Consistency consistency = 1;
326+
string comparison_schema = 2;
327+
}
328+
329+
message ExperimentalSchemaDiffResponse {
330+
repeated ExpSchemaDiff diffs = 1;
331+
332+
// read_at is the ZedToken at which the schema was read.
333+
ZedToken read_at = 2;
334+
}
335+
336+
message ExpSchemaDiff {
337+
oneof diff {
338+
ExpDefinition definition_added = 1;
339+
ExpDefinition definition_removed = 2;
340+
ExpDefinition definition_doc_comment_changed = 3;
341+
ExpRelation relation_added = 4;
342+
ExpRelation relation_removed = 5;
343+
ExpRelation relation_doc_comment_changed = 6;
344+
ExpRelation relation_type_changed = 7;
345+
ExpPermission permission_added = 8;
346+
ExpPermission permission_removed = 9;
347+
ExpPermission permission_doc_comment_changed = 10;
348+
ExpPermission permission_expr_changed = 11;
349+
ExpCaveat caveat_added = 12;
350+
ExpCaveat caveat_removed = 13;
351+
ExpCaveat caveat_doc_comment_changed = 14;
352+
ExpCaveat caveat_expr_changed = 15;
353+
ExpCaveatParameter caveat_parameter_added = 16;
354+
ExpCaveatParameter caveat_parameter_removed = 17;
355+
ExpCaveatParameter caveat_parameter_type_changed = 18;
356+
}
357+
}

0 commit comments

Comments
 (0)