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

Function add_workspace_grant

atomic-teams/src/grant.rs:141–158  ·  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`](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,
)

Source from the content-addressed store, hash-verified

139/// [`TeamsError::PermissionDenied`](crate::error::TeamsError::PermissionDenied)
140/// if the caller is not a workspace admin.
141pub 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///

Callers 1

runMethod · 0.85

Calls 2

map_remote_errorFunction · 0.85
postMethod · 0.80

Tested by

no test coverage detected