Description
I'm starting to work with the GET and PUT org and project policy endpoints in the console and found it surprising that the policy response body has no reference to the resource the policy is for. I assume this was to keep the Policy
type simple by not having it know about the resource:
omicron/nexus/src/external_api/shared.rs
Lines 32 to 44 in 4c933a1
The simplest thing we could do is add a resource_id
field, though it would be a bit weird if it didn't also indicate the resource type. So that could either be resource_id: "abc"
and resource_type: "project"
or we could combine that into one thing: project_id
. On one hand project_id
is neater. On the other hand, if a client has a policy and wants to know what kind of resource it is for, policy.resource_type === "project"
makes a lot more sense than "is project_id
present?" or some horrible /^(.+)_id$/
situation. On the other other hand, I don't know why a client would have a policy on hand but not know what kind of resource it came from. You just made the request, buddy.
So I guess the change I'm suggesting is this (sorry for the TS syntax, it's the most concise way to put it):
type IdentityType = 'silo_user'
type ProjectRoles = 'admin' | 'collaborator' | 'viewer'
type ProjectRolesRoleAssignment = {
identity_id: string
identity_type: IdentityType
role_name: ProjectRoles
}
type ProjectRolesPolicy = {
+ project_id: string
role_assignments: ProjectRolesRoleAssignment[]
}
type OrganizationRolesPolicy = {
+ organization_id: string
role_assignments: OrganizationRolesRoleAssignment[]
}
// etc