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

Function add_org_grant

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

Add a permission grant to an organization. Binds `subject_id` (a user or team UUID) 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 owner.

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

Source from the content-addressed store, hash-verified

61/// [`TeamsError::PermissionDenied`](crate::error::TeamsError::PermissionDenied)
62/// if the caller is not an org owner.
63pub async fn add_org_grant(
64 client: &StorageClient,
65 org_slug: &str,
66 subject_type: GrantSubjectType,
67 subject_id: Uuid,
68 relation: GrantRelation,
69) -> TeamsResult<GrantInfo> {
70 let path = format!("/orgs/{org_slug}/grants");
71 let body = AddGrantRequest {
72 subject_type,
73 subject_id,
74 relation,
75 };
76 client
77 .post(&path, &body)
78 .await
79 .map_err(|e| map_remote_error(e, format!("org {org_slug}")))
80}
81
82/// Revoke all grants for a subject on an organization.
83///

Callers

nothing calls this directly

Calls 2

map_remote_errorFunction · 0.85
postMethod · 0.80

Tested by

no test coverage detected