Add a permission grant to a workspace. Binds `subject_id` (a user or team UUID) with the given `relation` on the workspace identified by `workspace_slug`. # Errors Returns [`TeamsError::AlreadyExists`](crate::error::TeamsError::AlreadyExists) if the grant already exists, or [`TeamsError::PermissionDenied`](crate::error::TeamsError::PermissionDenied) if the caller is not a workspace admin.
(
client: &StorageClient,
workspace_slug: &str,
subject_type: GrantSubjectType,
subject_id: Uuid,
relation: GrantRelation,
)
| 139 | /// [`TeamsError::PermissionDenied`](crate::error::TeamsError::PermissionDenied) |
| 140 | /// if the caller is not a workspace admin. |
| 141 | pub async fn add_workspace_grant( |
| 142 | client: &StorageClient, |
| 143 | workspace_slug: &str, |
| 144 | subject_type: GrantSubjectType, |
| 145 | subject_id: Uuid, |
| 146 | relation: GrantRelation, |
| 147 | ) -> TeamsResult<crate::types::WorkspaceGrantInfo> { |
| 148 | let path = format!("/workspaces/{workspace_slug}/grants"); |
| 149 | let body = AddGrantRequest { |
| 150 | subject_type, |
| 151 | subject_id, |
| 152 | relation, |
| 153 | }; |
| 154 | client |
| 155 | .post(&path, &body) |
| 156 | .await |
| 157 | .map_err(|e| map_remote_error(e, format!("workspace {workspace_slug}"))) |
| 158 | } |
| 159 | |
| 160 | /// Revoke all grants for a subject on a workspace. |
| 161 | /// |
no test coverage detected