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

Function add_org_grant

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

Add a permission grant to an organization. Binds `subject_id` (a user or team identity) with the given `relation` on the organization identified by `org_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 an org admin/owner.

(
    client: &StorageClient,
    org_slug: &str,
    subject_type: GrantSubjectType,
    subject_id: Option<Uuid>,
    relation: GrantRelation,
)

Source from the content-addressed store, hash-verified

48/// [`TeamsError::PermissionDenied`](crate::error::TeamsError::PermissionDenied)
49/// if the caller is not an org admin/owner.
50pub async fn add_org_grant(
51 client: &StorageClient,
52 org_slug: &str,
53 subject_type: GrantSubjectType,
54 subject_id: Option<Uuid>,
55 relation: GrantRelation,
56) -> TeamsResult<GrantInfo> {
57 let path = format!("/orgs/{org_slug}/grants");
58 let body = AddGrantRequest {
59 subject_type,
60 subject_id,
61 relation,
62 };
63 client
64 .post(&path, &body)
65 .await
66 .map_err(|e| map_remote_error(e, format!("org {org_slug}")))
67}
68
69/// Revoke a permission grant from an organization.
70///

Callers

nothing calls this directly

Calls 2

map_remote_errorFunction · 0.85
postMethod · 0.80

Tested by

no test coverage detected