Skip to content

Commit

Permalink
feat: support permission on list_collaborators (#630)
Browse files Browse the repository at this point in the history
* feat: support permission on list_collaborators

* Update src/api/repos/collaborators.rs

* address comments

Signed-off-by: tison <[email protected]>

* use existing type

Signed-off-by: tison <[email protected]>

* fixup format

Signed-off-by: tison <[email protected]>

---------

Signed-off-by: tison <[email protected]>
  • Loading branch information
tisonkun authored Jul 29, 2024
1 parent a147ef2 commit c8910fe
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/api/repos/collaborators.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use super::*;
use crate::params::teams::Permission;

#[derive(serde::Serialize)]
pub struct ListCollaboratorsBuilder<'octo, 'r> {
Expand All @@ -8,6 +9,8 @@ pub struct ListCollaboratorsBuilder<'octo, 'r> {
per_page: Option<u8>,
#[serde(skip_serializing_if = "Option::is_none")]
page: Option<u32>,
#[serde(skip_serializing_if = "Option::is_none")]
permission: Option<Permission>,
}

impl<'octo, 'r> ListCollaboratorsBuilder<'octo, 'r> {
Expand All @@ -16,6 +19,7 @@ impl<'octo, 'r> ListCollaboratorsBuilder<'octo, 'r> {
handler,
per_page: None,
page: None,
permission: None,
}
}

Expand All @@ -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<crate::Page<crate::models::Collaborator>> {
let route = format!(
Expand Down

0 comments on commit c8910fe

Please sign in to comment.