Maggie Walker
09/15/2022, 1:44 PMR.attr.account_id in P.attr.tenants.*.subaccount_ids
assuming there were two objects with:
P.attr.tenants.3.subaccount_ids
P.attr.tenants.5.subaccount_ids
Charith (Cerbos)
09/15/2022, 1:48 PMtenants
is a list, you could use exists
to iterate through the list until it finds a match.Maggie Walker
09/15/2022, 1:49 PMsubaccounts_id
field, for example:
Ginger = Principal(
id="Ginger",
roles={"user"},
attr={
"type": "human",
"apps": ["Content"],
"tenants": {
"3": {
"account_id": "3",
"subaccount_ids": ["31", "32"],
"attachments": {
"Label_administrator": {
"role": "Label_administrator",
"content_types": ["digital_audio"]
}
}
}
}
}
)
Colin = Principal(
id="Colin",
roles={"user"},
attr={
"type": "human",
"apps": ["Content"],
"tenants": {
"31": {
"account_id": "31",
"attachments": {
"Label_user": {
"role": "Label_user",
"content_types": ["digital_audio"]
}
}
}
}
}
)
Charith (Cerbos)
09/15/2022, 1:50 PMexists
it should work with objects too. I have to double check that.Maggie Walker
09/15/2022, 1:54 PMmy_obj.tenants.exists(x, x.matches("subaccount_ids"))
Charith (Cerbos)
09/15/2022, 1:56 PM:let tenants = {"3": {"subaccounts": [31, 32]}, "4": {"accounts": [4]}}
tenants.exists(t, 31 in tenants[t].subaccounts)
_ = true
Maggie Walker
09/15/2022, 1:57 PMCharith (Cerbos)
09/15/2022, 1:58 PMmy_obj.tenants.exists(x, my_obj.tenants[x].matches("subaccount_ids"))
perhaps (untested)Luis Diaz
09/15/2022, 1:58 PMtenants[x]
is an object I can perform an exist in it as well?Charith (Cerbos)
09/15/2022, 1:59 PMMaggie Walker
09/15/2022, 1:59 PMLuis Diaz
09/15/2022, 2:00 PMIt would be quite difficult to read thoughThat’s what I’m known for! Presumably you could assign it to a variable though, then it becomes more manageable?
Charith (Cerbos)
09/15/2022, 2:00 PM