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

Function add_org_grant

atomic-teams/src/grant.rs:78–96  ·  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`] if the grant already exists, or [`TeamsError::PermissionDenied`] if the caller is not an org owner. Returns [`TeamsError::InvalidInput`] when `subject_type` is [`GrantSubjectType::Everyone`].

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

Source from the content-addressed store, hash-verified

76/// [`TeamsError::InvalidInput`] when
77/// `subject_type` is [`GrantSubjectType::Everyone`].
78pub async fn add_org_grant(
79 client: &StorageClient,
80 org_slug: &str,
81 subject_type: GrantSubjectType,
82 subject_id: Uuid,
83 relation: GrantRelation,
84) -> TeamsResult<GrantInfo> {
85 validate_mutation_subject(subject_type)?;
86 let path = format!("/orgs/{org_slug}/grants");
87 let body = AddGrantRequest {
88 subject_type,
89 subject_id,
90 relation,
91 };
92 client
93 .post(&path, &body)
94 .await
95 .map_err(|e| map_remote_error(e, format!("org {org_slug}")))
96}
97
98/// Revoke all grants for a subject on an organization.
99///

Callers

nothing calls this directly

Calls 3

map_remote_errorFunction · 0.85
postMethod · 0.80

Tested by

no test coverage detected