From c8910fec661e65ccc86ee7d94982ed89e6267692 Mon Sep 17 00:00:00 2001 From: tison Date: Mon, 29 Jul 2024 19:40:06 +0800 Subject: [PATCH] feat: support permission on list_collaborators (#630) * feat: support permission on list_collaborators * Update src/api/repos/collaborators.rs * address comments Signed-off-by: tison * use existing type Signed-off-by: tison * fixup format Signed-off-by: tison --------- Signed-off-by: tison --- src/api/repos/collaborators.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/api/repos/collaborators.rs b/src/api/repos/collaborators.rs index 9ed2a840..8ea0eb81 100644 --- a/src/api/repos/collaborators.rs +++ b/src/api/repos/collaborators.rs @@ -1,4 +1,5 @@ use super::*; +use crate::params::teams::Permission; #[derive(serde::Serialize)] pub struct ListCollaboratorsBuilder<'octo, 'r> { @@ -8,6 +9,8 @@ pub struct ListCollaboratorsBuilder<'octo, 'r> { per_page: Option, #[serde(skip_serializing_if = "Option::is_none")] page: Option, + #[serde(skip_serializing_if = "Option::is_none")] + permission: Option, } impl<'octo, 'r> ListCollaboratorsBuilder<'octo, 'r> { @@ -16,6 +19,7 @@ impl<'octo, 'r> ListCollaboratorsBuilder<'octo, 'r> { handler, per_page: None, page: None, + permission: None, } } @@ -31,6 +35,14 @@ impl<'octo, 'r> ListCollaboratorsBuilder<'octo, 'r> { self } + /// Filter collaborators by the permissions they have on the repository. + /// If not specified, all collaborators will be returned. + /// Can be one of: pull, triage, push, maintain, admin + pub fn permission(mut self, permission: Permission) -> Self { + self.permission = Some(permission); + self + } + /// Sends the actual request. pub async fn send(self) -> crate::Result> { let route = format!(