Skip to content

Commit ceba4ce

Browse files
committed
Add relationships filtering to bulk export, delete and watch APIs and expand the filtering support
1 parent 97ac42f commit ceba4ce

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

authzed/api/v1/experimental_service.proto

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ message BulkExportRelationshipsRequest {
123123
// should resume being returned. The cursor can be found on the
124124
// BulkExportRelationshipsResponse object.
125125
Cursor optional_cursor = 3;
126+
127+
// optional_relationship_filter, if specified, indicates the
128+
// filter to apply to each relationship to be exported.
129+
RelationshipFilter optional_relationship_filter = 4;
126130
}
127131

128132
// BulkExportRelationshipsResponse is one page in a stream of relationship

authzed/api/v1/permission_service.proto

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,24 +122,42 @@ message Consistency {
122122
// RelationshipFilter is a collection of filters which when applied to a
123123
// relationship will return relationships that have exactly matching fields.
124124
//
125-
// resource_type is required. All other fields are optional and if left
126-
// unspecified will not filter relationships.
125+
// All fields are optional and if left unspecified will not filter relationships,
126+
// but at least one field must be specified.
127+
//
128+
// NOTE: The performance of the API will be affected by the selection of fields
129+
// on which to filter. If a field is not indexed, the performance of the API
130+
// can be significantly slower.
127131
message RelationshipFilter {
132+
// resource_type is the *optional* resource type of the relationship.
133+
// NOTE: It is not prefixed with "optional_" for legacy compatibility.
128134
string resource_type = 1 [ (validate.rules).string = {
129135
pattern : "^([a-z][a-z0-9_]{1,61}[a-z0-9]/)*[a-z][a-z0-9_]{1,62}[a-z0-9]$",
130136
max_bytes : 128,
131137
} ];
132138

139+
// optional_resource_id is the *optional* resource ID of the relationship.
140+
// If specified, optional_resource_id_prefix cannot be specified.
133141
string optional_resource_id = 2 [ (validate.rules).string = {
134142
pattern : "^([a-zA-Z0-9/_|\\-=+]{1,})?$",
135143
max_bytes : 1024,
136144
} ];
137145

146+
// optional_resource_id_prefix is the *optional* prefix for the resource ID of the relationship.
147+
// If specified, optional_resource_id cannot be specified.
148+
string optional_resource_id_prefix = 5 [ (validate.rules).string = {
149+
pattern : "^([a-zA-Z0-9/_|\\-=+]{1,})?$",
150+
max_bytes : 1024,
151+
} ];
152+
153+
154+
// relation is the *optional* relation of the relationship.
138155
string optional_relation = 3 [ (validate.rules).string = {
139156
pattern : "^([a-z][a-z0-9_]{1,62}[a-z0-9])?$",
140157
max_bytes : 64,
141158
} ];
142159

160+
// optional_subject_filter is the optional filter for the subjects of the relationships.
143161
SubjectFilter optional_subject_filter = 4;
144162
}
145163

authzed/api/v1/watch_service.proto

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ service WatchService {
2222
// watching mutations, and an optional start snapshot for when to start
2323
// watching.
2424
message WatchRequest {
25+
// optional_object_types is a filter of resource object types to watch for changes.
26+
// If specified, only changes to the specified object types will be returned and
27+
// optional_relationship_filters cannot be used.
2528
repeated string optional_object_types = 1 [
2629
(validate.rules).repeated .min_items = 0,
2730
(validate.rules).repeated .items.string = {
@@ -39,6 +42,11 @@ message WatchRequest {
3942
// Note that if this cursor references a point-in-time containing data
4043
// that has been garbage collected, an error will be returned.
4144
ZedToken optional_start_cursor = 2;
45+
46+
// optional_relationship_filters, if specified, indicates the
47+
// filter(s) to apply to each relationship to be returned by watch.
48+
// If specified, optional_object_types cannot be used.
49+
repeated RelationshipFilter optional_relationship_filters = 3;
4250
}
4351

4452
// WatchResponse contains all tuple modification events in ascending

0 commit comments

Comments
 (0)