Obtain all relationships between a resource and su...
# spicedb
p
Hi, I have create a definition with a relation and have added some data for the resource and subject ''' definition role{} definition feature{ relation is_accessilble_by: role relation can_be_edited_by:role } ''' Is there a way I can get the list of all relations that I have between the Resource and the Subject?
v
you can do
ReadRelationships
and define filter over the
resource_type
,
resource_id
and
subject_type
and
subject_id
. You'd just leave
relation
undefined. That'd give you all relationships between those two objects. https://buf.build/authzed/api/docs/main:authzed.api.v1#authzed.api.v1.RelationshipFilter
p
I tried it from zed commandline, like the one below, but it picked the role:Manager as a relation here rather than a Subject zed relationship read feature:Timesheets role:Manager
v
that would seem like a limitation in
zed
because the arguments are positional, but the API should technically support it. Would you mind opening an issue in
zed
?
you can try building the same request using
grpcurl
example:
Copy code
grpcurl -vv -H "Authorization: bearer foobar" -d '{"relationship_filter":{"resource_type": "resource"}, "optional_limit": "250", "optional_allow_partial_deletions": "true"}' --plaintext localhost:50051 authzed.api.v1.PermissionsService.DeleteRelationships
(this is a delete relationships example, but should illustrate how to do a read relationships)
example HTTP request payload:
Copy code
{
    "consistency": {
        "minimize_latency": true
    },
    "relationship_filter": {
        "resource_type": "resource",
        "optional_resource_id": "1",
        "optional_subject_filter": {
            "subject_type": "user",
            "optional_subject_id": "1"
        }
    }
}
`
note
relation
is not defined
p
this also worked..thanks
need to try this..