Skip to main content

ephemeris_forge_github/api/operations/
access.rs

1use ephemeris_forge::{RepoRef, UserName};
2
3use crate::Permission;
4use crate::api::error::ForgeError;
5use crate::api::model::{Collaborator, Invitation, Membership, OwnerKind, Team};
6
7/// The access operations of the GitHub API.
8pub trait AccessApi {
9    /// Grant `user` the given permission, which invites them if needed.
10    fn add_collaborator(
11        &self,
12        repository: &RepoRef,
13        user: &UserName,
14        permission: &Permission,
15    ) -> impl Future<Output = Result<(), ForgeError>> + Send;
16
17    /// Grant the team with this slug the given permission on the repository.
18    fn add_team(
19        &self,
20        repository: &RepoRef,
21        slug: &str,
22        permission: &Permission,
23    ) -> impl Future<Output = Result<(), ForgeError>> + Send;
24
25    /// Cancel the pending invitation `id`.
26    fn cancel_invitation(
27        &self,
28        repository: &RepoRef,
29        id: u64,
30    ) -> impl Future<Output = Result<(), ForgeError>> + Send;
31
32    /// Read the repository's direct collaborators, without inherited access.
33    fn collaborators(
34        &self,
35        repository: &RepoRef,
36    ) -> impl Future<Output = Result<Vec<Collaborator>, ForgeError>> + Send;
37
38    /// Read the login of the authenticated user.
39    fn current_user(&self) -> impl Future<Output = Result<String, ForgeError>> + Send;
40
41    /// Read the repository's pending invitations.
42    fn invitations(
43        &self,
44        repository: &RepoRef,
45    ) -> impl Future<Output = Result<Vec<Invitation>, ForgeError>> + Send;
46
47    /// Read the teams available for assignment at `organization`.
48    fn organization_teams(
49        &self,
50        organization: &str,
51    ) -> impl Future<Output = Result<Vec<Team>, ForgeError>> + Send;
52
53    /// Read whether `owner` is an organization or a personal account.
54    fn owner_kind(&self, owner: &str)
55    -> impl Future<Output = Result<OwnerKind, ForgeError>> + Send;
56
57    /// Remove `user`'s direct grant on the repository.
58    fn remove_collaborator(
59        &self,
60        repository: &RepoRef,
61        user: &UserName,
62    ) -> impl Future<Output = Result<(), ForgeError>> + Send;
63
64    /// Remove the direct grant of the team with this slug on the repository.
65    fn remove_team(
66        &self,
67        repository: &RepoRef,
68        slug: &str,
69    ) -> impl Future<Output = Result<(), ForgeError>> + Send;
70
71    /// Read the repository's current direct team grants.
72    fn teams(
73        &self,
74        repository: &RepoRef,
75    ) -> impl Future<Output = Result<Vec<Team>, ForgeError>> + Send;
76
77    /// Change the permission of the pending invitation `id`.
78    fn update_invitation(
79        &self,
80        repository: &RepoRef,
81        id: u64,
82        permission: &Permission,
83    ) -> impl Future<Output = Result<(), ForgeError>> + Send;
84
85    /// Read the teams the authenticated user belongs to, in any organization.
86    fn user_teams(&self) -> impl Future<Output = Result<Vec<Membership>, ForgeError>> + Send;
87}