Skip to content

Commit f5fb9ba

Browse files
committed
feat: Add experimental count relationships by filter to Materialize API
1 parent 5253a15 commit f5fb9ba

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
syntax = "proto3";
2+
package authzed.api.materialize.v0;
3+
4+
import "buf/validate/validate.proto";
5+
import "validate/validate.proto";
6+
import "authzed/api/v1/core.proto";
7+
import "authzed/api/v1/permission_service.proto";
8+
9+
option go_package = "github.com/authzed/authzed-go/proto/authzed/api/materialize/v0";
10+
option java_multiple_files = true;
11+
option java_package = "com.authzed.api.materialize.v0";
12+
13+
service RelationshipsService {
14+
// EXPERIMENTAL: CountRelationships returns the count of relationships for a given filter.
15+
rpc ExperimentalCountRelationshipsByFilter(ExperimentalCountRelationshipsByFilterRequest) returns (ExperimentalCountRelationshipsByFilterResponse) {}
16+
}
17+
18+
message ExperimentalCountRelationshipsByFilterRequest {
19+
// relationship_filter specifies the filter to apply when counting relationships.
20+
authzed.api.v1.RelationshipFilter relationship_filter = 1 [
21+
(validate.rules).message.required = true,
22+
(buf.validate.field).required = true
23+
];
24+
}
25+
26+
message ExperimentalCountRelationshipsByFilterResponse {
27+
// relationship_count is the count of relationships that match the filter.
28+
uint64 relationship_count = 1;
29+
30+
// read_at is the ZedToken at which the relationship count applies.
31+
authzed.api.v1.ZedToken read_at = 2 [
32+
(validate.rules).message.required = true,
33+
(buf.validate.field).required = true
34+
];
35+
}

docs/apidocs.swagger.json

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1946,6 +1946,20 @@
19461946
}
19471947
}
19481948
},
1949+
"ExperimentalCountRelationshipsByFilterResponse": {
1950+
"type": "object",
1951+
"properties": {
1952+
"relationshipCount": {
1953+
"type": "string",
1954+
"format": "uint64",
1955+
"description": "relationship_count is the count of relationships that match the filter."
1956+
},
1957+
"readAt": {
1958+
"$ref": "#/definitions/ZedToken",
1959+
"description": "read_at is the ZedToken at which the relationship count applies."
1960+
}
1961+
}
1962+
},
19491963
"ExperimentalCountRelationshipsRequest": {
19501964
"type": "object",
19511965
"properties": {
@@ -3164,7 +3178,7 @@
31643178
},
31653179
"optionalTransactionMetadata": {
31663180
"type": "object",
3167-
"description": "optional_transaction_metadata is an optional field that returns the transaction metadata\ngiven to SpiceDB during the transaction that produced the changes in this response.\nThis field may not exist if no transaction metadata was provided."
3181+
"description": "optional_transaction_metadata is an optional field that returns the transaction metadata\ngiven to SpiceDB during the transaction that produced the changes in this response.\nThis field may not exist if no transaction metadata was provided, or if multiple pieces\nof metadata were found during the transaction (in which case it is ambiguous which to return)."
31683182
},
31693183
"schemaUpdated": {
31703184
"type": "boolean",
@@ -3173,6 +3187,13 @@
31733187
"isCheckpoint": {
31743188
"type": "boolean",
31753189
"description": "is_checkpoint, if true, indicates that a checkpoint was reached.\nA checkpoint indicates that the server guarantees that the client\nwill not observe any changes at a revision below or equal to the revision in this response."
3190+
},
3191+
"fullRevisionMetadata": {
3192+
"type": "array",
3193+
"items": {
3194+
"type": "object"
3195+
},
3196+
"description": "full_revision_metadata contains all transaction metadata given to SpiceDB during the\nrevision that produced the changes in this response. Some datastores (such as CockroachDB)\ncan \"merge\" multiple transactions into a single revision (if the changes occurred concurrently),\nso this field is a list of all transaction metadata seen during the revision."
31763197
}
31773198
},
31783199
"description": "WatchResponse contains all mutation events in ascending timestamp order.\nThis excludes relationships that were deleted because they expired.\nThe response includes a field that can be used to resume\nwatching from that point."

0 commit comments

Comments
 (0)