MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / add_workspace_grant

Function add_workspace_grant

atomic-teams/src/grant.rs:162–180  ·  view source on GitHub ↗

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,
)

Source from the content-addressed store, hash-verified

160/// [`TeamsError::InvalidInput`] when
161/// `subject_type` is [`GrantSubjectType::Everyone`].
162pub 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///

Callers 1

runMethod · 0.85

Calls 3

map_remote_errorFunction · 0.85
postMethod · 0.80

Tested by

no test coverage detected