Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add relationships filtering to bulk export, delete and watch APIs and expand the filtering support #90

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions authzed/api/v1/experimental_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ message BulkExportRelationshipsRequest {
// should resume being returned. The cursor can be found on the
// BulkExportRelationshipsResponse object.
Cursor optional_cursor = 3;

// optional_relationship_filter, if specified, indicates the
// filter to apply to each relationship to be exported.
RelationshipFilter optional_relationship_filter = 4;
}

// BulkExportRelationshipsResponse is one page in a stream of relationship
Expand Down
22 changes: 20 additions & 2 deletions authzed/api/v1/permission_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -122,24 +122,42 @@ message Consistency {
// RelationshipFilter is a collection of filters which when applied to a
// relationship will return relationships that have exactly matching fields.
//
// resource_type is required. All other fields are optional and if left
// unspecified will not filter relationships.
// All fields are optional and if left unspecified will not filter relationships,
// but at least one field must be specified.
//
// NOTE: The performance of the API will be affected by the selection of fields
// on which to filter. If a field is not indexed, the performance of the API
// can be significantly slower.
message RelationshipFilter {
// resource_type is the *optional* resource type of the relationship.
// NOTE: It is not prefixed with "optional_" for legacy compatibility.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's the number 1 that provides the compatibility, right? are you concerned about the generated client APIs changing?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm concerned it'll break existing client code

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It shouldn't break existing client code, it would break when someone updates their version and finds codegen changed the field name

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what I meant, but it is still a "breaking" change in the sense that moving a minor version of the client library could break existing callers. We'd either have to major version all the client libraries or just not change it

string resource_type = 1 [ (validate.rules).string = {
pattern : "^([a-z][a-z0-9_]{1,61}[a-z0-9]/)*[a-z][a-z0-9_]{1,62}[a-z0-9]$",
max_bytes : 128,
} ];

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

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


// relation is the *optional* relation of the relationship.
string optional_relation = 3 [ (validate.rules).string = {
pattern : "^([a-z][a-z0-9_]{1,62}[a-z0-9])?$",
max_bytes : 64,
} ];

// optional_subject_filter is the optional filter for the subjects of the relationships.
SubjectFilter optional_subject_filter = 4;
}

Expand Down
9 changes: 9 additions & 0 deletions authzed/api/v1/watch_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import "google/api/annotations.proto";
import "validate/validate.proto";

import "authzed/api/v1/core.proto";
import "authzed/api/v1/permission_service.proto";

service WatchService {
rpc Watch(WatchRequest) returns (stream WatchResponse) {
Expand All @@ -22,6 +23,9 @@ service WatchService {
// watching mutations, and an optional start snapshot for when to start
// watching.
message WatchRequest {
// optional_object_types is a filter of resource object types to watch for changes.
// If specified, only changes to the specified object types will be returned and
// optional_relationship_filters cannot be used.
repeated string optional_object_types = 1 [
(validate.rules).repeated .min_items = 0,
(validate.rules).repeated .items.string = {
Expand All @@ -39,6 +43,11 @@ message WatchRequest {
// Note that if this cursor references a point-in-time containing data
// that has been garbage collected, an error will be returned.
ZedToken optional_start_cursor = 2;

// optional_relationship_filters, if specified, indicates the
// filter(s) to apply to each relationship to be returned by watch.
// If specified, optional_object_types cannot be used.
repeated RelationshipFilter optional_relationship_filters = 3;
}

// WatchResponse contains all tuple modification events in ascending
Expand Down
Loading