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`] if the grant already exists, or [`TeamsError::PermissionDenied`] if the caller is not a workspace admin. Returns [`TeamsError::InvalidInput`] when `subject_type` is [`GrantSubjectType::Everyone`]
(
client: &StorageClient,
workspace_slug: &str,
subject_type: GrantSubjectType,
subject_id: Uuid,
relation: GrantRelation,
)
| 160 | /// [`TeamsError::InvalidInput`] when |
| 161 | /// `subject_type` is [`GrantSubjectType::Everyone`]. |
| 162 | pub async fn add_workspace_grant( |
| 163 | client: &StorageClient, |
| 164 | workspace_slug: &str, |
| 165 | subject_type: GrantSubjectType, |
| 166 | subject_id: Uuid, |
| 167 | relation: GrantRelation, |
| 168 | ) -> TeamsResult<crate::types::WorkspaceGrantInfo> { |
| 169 | validate_mutation_subject(subject_type)?; |
| 170 | let path = format!("/workspaces/{workspace_slug}/grants"); |
| 171 | let body = AddGrantRequest { |
| 172 | subject_type, |
| 173 | subject_id, |
| 174 | relation, |
| 175 | }; |
| 176 | client |
| 177 | .post(&path, &body) |
| 178 | .await |
| 179 | .map_err(|e| map_remote_error(e, format!("workspace {workspace_slug}"))) |
| 180 | } |
| 181 | |
| 182 | /// Revoke all grants for a subject on a workspace. |
| 183 | /// |
no test coverage detected