-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Update relationship handling and deletion
Significant changes have been made to the way relationships are handled and deleted. The ReadRelationships method now accepts a SubjectFilter for the second parameter, along with an optional relationship limit and cursor. DeleteRelationshipsAsync has also been updated to use an optional SubjectFilter instead of a RelationshipFilter, and it now returns a DeleteRelationshipsResponse object with the ZedToken and deletion progress instead of just the ZedToken. In addition, new parameters have been added to several methods in ISpiceDbClient interface to support partial deletions and limiting results. A new enum DeletionProgress has been introduced to track progress of deletions. The code changes also include updates to tests reflecting these modifications.
- Loading branch information
Showing
10 changed files
with
218 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace SpiceDb.Enum; | ||
|
||
public enum DeletionProgress | ||
{ | ||
Unspecified = 0, | ||
|
||
/// <summary> | ||
/// Indicates that all remaining relationships matching the filter were deleted. Will be returned | ||
/// even if no relationships were deleted. | ||
/// </summary> | ||
Complete = 1, | ||
|
||
/// <summary> | ||
/// Indicates that a subset of the relationships matching the filter | ||
/// were deleted. Only returned if optional_allow_partial_deletions was true, an optional_limit was | ||
/// specified, and there existed more relationships matching the filter than optional_limit would allow. | ||
/// Once all remaining relationships have been deleted, DeletionProgress.Complete will be returned. | ||
/// </summary> | ||
Partial = 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using SpiceDb.Enum; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace SpiceDb.Models; | ||
|
||
public class DeleteRelationshipsResponse | ||
{ | ||
public ZedToken? DeletedAt { get; set; } | ||
public DeletionProgress DeletionProgress { get; set; } = DeletionProgress.Unspecified; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,23 @@ | ||
namespace SpiceDb.Models; | ||
|
||
/// <summary> | ||
/// RelationshipFilter is a collection of filters which when applied to a relationship will return | ||
/// relationships that have exactly matching fields. | ||
/// All fields are optional and if left unspecified will not filter relationships, but at least one | ||
/// field must be specified. | ||
/// </summary> | ||
public class RelationshipFilter | ||
{ | ||
/// <summary> | ||
/// Optional resource type of teh relationship | ||
/// </summary> | ||
public string Type { get; set; } = string.Empty; | ||
/// <summary> | ||
/// Optional relation of the relationship | ||
/// </summary> | ||
public string OptionalRelation { get; set; } = string.Empty; | ||
/// <summary> | ||
/// Optional Id of the relationship | ||
/// </summary> | ||
public string OptionalId { get; set; } = string.Empty; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,20 @@ | ||
namespace SpiceDb.Models; | ||
|
||
/// <summary> | ||
/// Specifies a filter on the subject of a relationship. | ||
/// </summary> | ||
public class SubjectFilter | ||
{ | ||
/// <summary> | ||
/// Required subject type of the relationship | ||
/// </summary> | ||
public required string Type { get; set; } | ||
/// <summary> | ||
/// Optional relation of the relationship | ||
/// </summary> | ||
public string? OptionalRelation { get; set; } | ||
/// <summary> | ||
/// Optional resource ID of the relationship | ||
/// </summary> | ||
public string OptionalId { get; set; } = string.Empty; | ||
} |
Oops, something went wrong.