//! Method, error and parameter types for the Teams endpoint.
#![allow(
clippy::all
)]
/*
* GitHub v3 REST API
*
* GitHub's v3 REST API.
*
* OpenAPI spec version: 1.1.4
*
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/
use serde::Deserialize;
use roctokit::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt};
use crate::models::*;
use super::PerPage;
use std::collections::HashMap;
use serde_json::value::Value;
pub struct Teams<'api, C: Client> where AdapterError: From<<C as Client>::Err> {
client: &'api C
}
pub fn new<C: Client>(client: &C) -> Teams<C> where AdapterError: From<<C as Client>::Err> {
Teams { client }
}
/// Errors for the [Add team member (Legacy)](Teams::add_member_legacy_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsAddMemberLegacyError {
#[error("Not Found if team synchronization is set up")]
Status404,
#[error("Unprocessable Entity if you attempt to add an organization to a team or you attempt to add a user to a team when they are not a member of at least one other team in the same organization")]
Status422,
#[error("Forbidden")]
Status403(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsAddMemberLegacyError> for AdapterError {
fn from(err: TeamsAddMemberLegacyError) -> Self {
let (description, status_code) = match err {
TeamsAddMemberLegacyError::Status404 => (String::from("Not Found if team synchronization is set up"), 404),
TeamsAddMemberLegacyError::Status422 => (String::from("Unprocessable Entity if you attempt to add an organization to a team or you attempt to add a user to a team when they are not a member of at least one other team in the same organization"), 422),
TeamsAddMemberLegacyError::Status403(_) => (String::from("Forbidden"), 403),
TeamsAddMemberLegacyError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Add or update team membership for a user](Teams::add_or_update_membership_for_user_in_org_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsAddOrUpdateMembershipForUserInOrgError {
#[error("Forbidden if team synchronization is set up")]
Status403,
#[error("Unprocessable Entity if you attempt to add an organization to a team")]
Status422,
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsAddOrUpdateMembershipForUserInOrgError> for AdapterError {
fn from(err: TeamsAddOrUpdateMembershipForUserInOrgError) -> Self {
let (description, status_code) = match err {
TeamsAddOrUpdateMembershipForUserInOrgError::Status403 => (String::from("Forbidden if team synchronization is set up"), 403),
TeamsAddOrUpdateMembershipForUserInOrgError::Status422 => (String::from("Unprocessable Entity if you attempt to add an organization to a team"), 422),
TeamsAddOrUpdateMembershipForUserInOrgError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Add or update team membership for a user (Legacy)](Teams::add_or_update_membership_for_user_legacy_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsAddOrUpdateMembershipForUserLegacyError {
#[error("Forbidden if team synchronization is set up")]
Status403,
#[error("Unprocessable Entity if you attempt to add an organization to a team")]
Status422,
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsAddOrUpdateMembershipForUserLegacyError> for AdapterError {
fn from(err: TeamsAddOrUpdateMembershipForUserLegacyError) -> Self {
let (description, status_code) = match err {
TeamsAddOrUpdateMembershipForUserLegacyError::Status403 => (String::from("Forbidden if team synchronization is set up"), 403),
TeamsAddOrUpdateMembershipForUserLegacyError::Status422 => (String::from("Unprocessable Entity if you attempt to add an organization to a team"), 422),
TeamsAddOrUpdateMembershipForUserLegacyError::Status404(_) => (String::from("Resource not found"), 404),
TeamsAddOrUpdateMembershipForUserLegacyError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Add or update team project permissions](Teams::add_or_update_project_permissions_in_org_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsAddOrUpdateProjectPermissionsInOrgError {
#[error("Forbidden if the project is not owned by the organization")]
Status403(PutTeamsAddOrUpdateProjectPermissionsLegacyResponse403),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsAddOrUpdateProjectPermissionsInOrgError> for AdapterError {
fn from(err: TeamsAddOrUpdateProjectPermissionsInOrgError) -> Self {
let (description, status_code) = match err {
TeamsAddOrUpdateProjectPermissionsInOrgError::Status403(_) => (String::from("Forbidden if the project is not owned by the organization"), 403),
TeamsAddOrUpdateProjectPermissionsInOrgError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Add or update team project permissions (Legacy)](Teams::add_or_update_project_permissions_legacy_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsAddOrUpdateProjectPermissionsLegacyError {
#[error("Forbidden if the project is not owned by the organization")]
Status403(PutTeamsAddOrUpdateProjectPermissionsLegacyResponse403),
#[error("Resource not found")]
Status404(BasicError),
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsAddOrUpdateProjectPermissionsLegacyError> for AdapterError {
fn from(err: TeamsAddOrUpdateProjectPermissionsLegacyError) -> Self {
let (description, status_code) = match err {
TeamsAddOrUpdateProjectPermissionsLegacyError::Status403(_) => (String::from("Forbidden if the project is not owned by the organization"), 403),
TeamsAddOrUpdateProjectPermissionsLegacyError::Status404(_) => (String::from("Resource not found"), 404),
TeamsAddOrUpdateProjectPermissionsLegacyError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
TeamsAddOrUpdateProjectPermissionsLegacyError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Add or update team repository permissions](Teams::add_or_update_repo_permissions_in_org_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsAddOrUpdateRepoPermissionsInOrgError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsAddOrUpdateRepoPermissionsInOrgError> for AdapterError {
fn from(err: TeamsAddOrUpdateRepoPermissionsInOrgError) -> Self {
let (description, status_code) = match err {
TeamsAddOrUpdateRepoPermissionsInOrgError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Add or update team repository permissions (Legacy)](Teams::add_or_update_repo_permissions_legacy_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsAddOrUpdateRepoPermissionsLegacyError {
#[error("Forbidden")]
Status403(BasicError),
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsAddOrUpdateRepoPermissionsLegacyError> for AdapterError {
fn from(err: TeamsAddOrUpdateRepoPermissionsLegacyError) -> Self {
let (description, status_code) = match err {
TeamsAddOrUpdateRepoPermissionsLegacyError::Status403(_) => (String::from("Forbidden"), 403),
TeamsAddOrUpdateRepoPermissionsLegacyError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
TeamsAddOrUpdateRepoPermissionsLegacyError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Check team permissions for a project](Teams::check_permissions_for_project_in_org_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsCheckPermissionsForProjectInOrgError {
#[error("Not Found if project is not managed by this team")]
Status404,
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsCheckPermissionsForProjectInOrgError> for AdapterError {
fn from(err: TeamsCheckPermissionsForProjectInOrgError) -> Self {
let (description, status_code) = match err {
TeamsCheckPermissionsForProjectInOrgError::Status404 => (String::from("Not Found if project is not managed by this team"), 404),
TeamsCheckPermissionsForProjectInOrgError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Check team permissions for a project (Legacy)](Teams::check_permissions_for_project_legacy_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsCheckPermissionsForProjectLegacyError {
#[error("Not Found if project is not managed by this team")]
Status404,
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsCheckPermissionsForProjectLegacyError> for AdapterError {
fn from(err: TeamsCheckPermissionsForProjectLegacyError) -> Self {
let (description, status_code) = match err {
TeamsCheckPermissionsForProjectLegacyError::Status404 => (String::from("Not Found if project is not managed by this team"), 404),
TeamsCheckPermissionsForProjectLegacyError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Check team permissions for a repository](Teams::check_permissions_for_repo_in_org_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsCheckPermissionsForRepoInOrgError {
#[error("Response if team has permission for the repository. This is the response when the repository media type hasn't been provded in the Accept header.")]
Status204,
#[error("Not Found if team does not have permission for the repository")]
Status404,
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsCheckPermissionsForRepoInOrgError> for AdapterError {
fn from(err: TeamsCheckPermissionsForRepoInOrgError) -> Self {
let (description, status_code) = match err {
TeamsCheckPermissionsForRepoInOrgError::Status204 => (String::from("Response if team has permission for the repository. This is the response when the repository media type hasn't been provded in the Accept header."), 204),
TeamsCheckPermissionsForRepoInOrgError::Status404 => (String::from("Not Found if team does not have permission for the repository"), 404),
TeamsCheckPermissionsForRepoInOrgError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Check team permissions for a repository (Legacy)](Teams::check_permissions_for_repo_legacy_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsCheckPermissionsForRepoLegacyError {
#[error("Response if repository is managed by this team")]
Status204,
#[error("Not Found if repository is not managed by this team")]
Status404,
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsCheckPermissionsForRepoLegacyError> for AdapterError {
fn from(err: TeamsCheckPermissionsForRepoLegacyError) -> Self {
let (description, status_code) = match err {
TeamsCheckPermissionsForRepoLegacyError::Status204 => (String::from("Response if repository is managed by this team"), 204),
TeamsCheckPermissionsForRepoLegacyError::Status404 => (String::from("Not Found if repository is not managed by this team"), 404),
TeamsCheckPermissionsForRepoLegacyError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Create a team](Teams::create_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsCreateError {
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsCreateError> for AdapterError {
fn from(err: TeamsCreateError) -> Self {
let (description, status_code) = match err {
TeamsCreateError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
TeamsCreateError::Status403(_) => (String::from("Forbidden"), 403),
TeamsCreateError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Create a discussion comment](Teams::create_discussion_comment_in_org_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsCreateDiscussionCommentInOrgError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsCreateDiscussionCommentInOrgError> for AdapterError {
fn from(err: TeamsCreateDiscussionCommentInOrgError) -> Self {
let (description, status_code) = match err {
TeamsCreateDiscussionCommentInOrgError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Create a discussion comment (Legacy)](Teams::create_discussion_comment_legacy_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsCreateDiscussionCommentLegacyError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsCreateDiscussionCommentLegacyError> for AdapterError {
fn from(err: TeamsCreateDiscussionCommentLegacyError) -> Self {
let (description, status_code) = match err {
TeamsCreateDiscussionCommentLegacyError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Create a discussion](Teams::create_discussion_in_org_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsCreateDiscussionInOrgError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsCreateDiscussionInOrgError> for AdapterError {
fn from(err: TeamsCreateDiscussionInOrgError) -> Self {
let (description, status_code) = match err {
TeamsCreateDiscussionInOrgError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Create a discussion (Legacy)](Teams::create_discussion_legacy_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsCreateDiscussionLegacyError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsCreateDiscussionLegacyError> for AdapterError {
fn from(err: TeamsCreateDiscussionLegacyError) -> Self {
let (description, status_code) = match err {
TeamsCreateDiscussionLegacyError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Delete a discussion comment](Teams::delete_discussion_comment_in_org_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsDeleteDiscussionCommentInOrgError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsDeleteDiscussionCommentInOrgError> for AdapterError {
fn from(err: TeamsDeleteDiscussionCommentInOrgError) -> Self {
let (description, status_code) = match err {
TeamsDeleteDiscussionCommentInOrgError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Delete a discussion comment (Legacy)](Teams::delete_discussion_comment_legacy_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsDeleteDiscussionCommentLegacyError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsDeleteDiscussionCommentLegacyError> for AdapterError {
fn from(err: TeamsDeleteDiscussionCommentLegacyError) -> Self {
let (description, status_code) = match err {
TeamsDeleteDiscussionCommentLegacyError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Delete a discussion](Teams::delete_discussion_in_org_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsDeleteDiscussionInOrgError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsDeleteDiscussionInOrgError> for AdapterError {
fn from(err: TeamsDeleteDiscussionInOrgError) -> Self {
let (description, status_code) = match err {
TeamsDeleteDiscussionInOrgError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Delete a discussion (Legacy)](Teams::delete_discussion_legacy_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsDeleteDiscussionLegacyError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsDeleteDiscussionLegacyError> for AdapterError {
fn from(err: TeamsDeleteDiscussionLegacyError) -> Self {
let (description, status_code) = match err {
TeamsDeleteDiscussionLegacyError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Delete a team](Teams::delete_in_org_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsDeleteInOrgError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsDeleteInOrgError> for AdapterError {
fn from(err: TeamsDeleteInOrgError) -> Self {
let (description, status_code) = match err {
TeamsDeleteInOrgError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Delete a team (Legacy)](Teams::delete_legacy_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsDeleteLegacyError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsDeleteLegacyError> for AdapterError {
fn from(err: TeamsDeleteLegacyError) -> Self {
let (description, status_code) = match err {
TeamsDeleteLegacyError::Status404(_) => (String::from("Resource not found"), 404),
TeamsDeleteLegacyError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
TeamsDeleteLegacyError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get a team by name](Teams::get_by_name_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsGetByNameError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsGetByNameError> for AdapterError {
fn from(err: TeamsGetByNameError) -> Self {
let (description, status_code) = match err {
TeamsGetByNameError::Status404(_) => (String::from("Resource not found"), 404),
TeamsGetByNameError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get a discussion comment](Teams::get_discussion_comment_in_org_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsGetDiscussionCommentInOrgError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsGetDiscussionCommentInOrgError> for AdapterError {
fn from(err: TeamsGetDiscussionCommentInOrgError) -> Self {
let (description, status_code) = match err {
TeamsGetDiscussionCommentInOrgError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get a discussion comment (Legacy)](Teams::get_discussion_comment_legacy_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsGetDiscussionCommentLegacyError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsGetDiscussionCommentLegacyError> for AdapterError {
fn from(err: TeamsGetDiscussionCommentLegacyError) -> Self {
let (description, status_code) = match err {
TeamsGetDiscussionCommentLegacyError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get a discussion](Teams::get_discussion_in_org_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsGetDiscussionInOrgError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsGetDiscussionInOrgError> for AdapterError {
fn from(err: TeamsGetDiscussionInOrgError) -> Self {
let (description, status_code) = match err {
TeamsGetDiscussionInOrgError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get a discussion (Legacy)](Teams::get_discussion_legacy_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsGetDiscussionLegacyError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsGetDiscussionLegacyError> for AdapterError {
fn from(err: TeamsGetDiscussionLegacyError) -> Self {
let (description, status_code) = match err {
TeamsGetDiscussionLegacyError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get a team (Legacy)](Teams::get_legacy_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsGetLegacyError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsGetLegacyError> for AdapterError {
fn from(err: TeamsGetLegacyError) -> Self {
let (description, status_code) = match err {
TeamsGetLegacyError::Status404(_) => (String::from("Resource not found"), 404),
TeamsGetLegacyError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get team member (Legacy)](Teams::get_member_legacy_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsGetMemberLegacyError {
#[error("if user is not a member")]
Status404,
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsGetMemberLegacyError> for AdapterError {
fn from(err: TeamsGetMemberLegacyError) -> Self {
let (description, status_code) = match err {
TeamsGetMemberLegacyError::Status404 => (String::from("if user is not a member"), 404),
TeamsGetMemberLegacyError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get team membership for a user](Teams::get_membership_for_user_in_org_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsGetMembershipForUserInOrgError {
#[error("if user has no team membership")]
Status404,
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsGetMembershipForUserInOrgError> for AdapterError {
fn from(err: TeamsGetMembershipForUserInOrgError) -> Self {
let (description, status_code) = match err {
TeamsGetMembershipForUserInOrgError::Status404 => (String::from("if user has no team membership"), 404),
TeamsGetMembershipForUserInOrgError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get team membership for a user (Legacy)](Teams::get_membership_for_user_legacy_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsGetMembershipForUserLegacyError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsGetMembershipForUserLegacyError> for AdapterError {
fn from(err: TeamsGetMembershipForUserLegacyError) -> Self {
let (description, status_code) = match err {
TeamsGetMembershipForUserLegacyError::Status404(_) => (String::from("Resource not found"), 404),
TeamsGetMembershipForUserLegacyError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List teams](Teams::list_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsListError {
#[error("Forbidden")]
Status403(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsListError> for AdapterError {
fn from(err: TeamsListError) -> Self {
let (description, status_code) = match err {
TeamsListError::Status403(_) => (String::from("Forbidden"), 403),
TeamsListError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List child teams](Teams::list_child_in_org_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsListChildInOrgError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsListChildInOrgError> for AdapterError {
fn from(err: TeamsListChildInOrgError) -> Self {
let (description, status_code) = match err {
TeamsListChildInOrgError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List child teams (Legacy)](Teams::list_child_legacy_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsListChildLegacyError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsListChildLegacyError> for AdapterError {
fn from(err: TeamsListChildLegacyError) -> Self {
let (description, status_code) = match err {
TeamsListChildLegacyError::Status404(_) => (String::from("Resource not found"), 404),
TeamsListChildLegacyError::Status403(_) => (String::from("Forbidden"), 403),
TeamsListChildLegacyError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
TeamsListChildLegacyError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List discussion comments](Teams::list_discussion_comments_in_org_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsListDiscussionCommentsInOrgError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsListDiscussionCommentsInOrgError> for AdapterError {
fn from(err: TeamsListDiscussionCommentsInOrgError) -> Self {
let (description, status_code) = match err {
TeamsListDiscussionCommentsInOrgError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List discussion comments (Legacy)](Teams::list_discussion_comments_legacy_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsListDiscussionCommentsLegacyError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsListDiscussionCommentsLegacyError> for AdapterError {
fn from(err: TeamsListDiscussionCommentsLegacyError) -> Self {
let (description, status_code) = match err {
TeamsListDiscussionCommentsLegacyError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List discussions](Teams::list_discussions_in_org_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsListDiscussionsInOrgError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsListDiscussionsInOrgError> for AdapterError {
fn from(err: TeamsListDiscussionsInOrgError) -> Self {
let (description, status_code) = match err {
TeamsListDiscussionsInOrgError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List discussions (Legacy)](Teams::list_discussions_legacy_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsListDiscussionsLegacyError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsListDiscussionsLegacyError> for AdapterError {
fn from(err: TeamsListDiscussionsLegacyError) -> Self {
let (description, status_code) = match err {
TeamsListDiscussionsLegacyError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List teams for the authenticated user](Teams::list_for_authenticated_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsListForAuthenticatedUserError {
#[error("Not modified")]
Status304,
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsListForAuthenticatedUserError> for AdapterError {
fn from(err: TeamsListForAuthenticatedUserError) -> Self {
let (description, status_code) = match err {
TeamsListForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304),
TeamsListForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404),
TeamsListForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403),
TeamsListForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List team members](Teams::list_members_in_org_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsListMembersInOrgError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsListMembersInOrgError> for AdapterError {
fn from(err: TeamsListMembersInOrgError) -> Self {
let (description, status_code) = match err {
TeamsListMembersInOrgError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List team members (Legacy)](Teams::list_members_legacy_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsListMembersLegacyError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsListMembersLegacyError> for AdapterError {
fn from(err: TeamsListMembersLegacyError) -> Self {
let (description, status_code) = match err {
TeamsListMembersLegacyError::Status404(_) => (String::from("Resource not found"), 404),
TeamsListMembersLegacyError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List pending team invitations](Teams::list_pending_invitations_in_org_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsListPendingInvitationsInOrgError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsListPendingInvitationsInOrgError> for AdapterError {
fn from(err: TeamsListPendingInvitationsInOrgError) -> Self {
let (description, status_code) = match err {
TeamsListPendingInvitationsInOrgError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List pending team invitations (Legacy)](Teams::list_pending_invitations_legacy_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsListPendingInvitationsLegacyError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsListPendingInvitationsLegacyError> for AdapterError {
fn from(err: TeamsListPendingInvitationsLegacyError) -> Self {
let (description, status_code) = match err {
TeamsListPendingInvitationsLegacyError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List team projects](Teams::list_projects_in_org_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsListProjectsInOrgError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsListProjectsInOrgError> for AdapterError {
fn from(err: TeamsListProjectsInOrgError) -> Self {
let (description, status_code) = match err {
TeamsListProjectsInOrgError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List team projects (Legacy)](Teams::list_projects_legacy_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsListProjectsLegacyError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsListProjectsLegacyError> for AdapterError {
fn from(err: TeamsListProjectsLegacyError) -> Self {
let (description, status_code) = match err {
TeamsListProjectsLegacyError::Status404(_) => (String::from("Resource not found"), 404),
TeamsListProjectsLegacyError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List team repositories](Teams::list_repos_in_org_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsListReposInOrgError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsListReposInOrgError> for AdapterError {
fn from(err: TeamsListReposInOrgError) -> Self {
let (description, status_code) = match err {
TeamsListReposInOrgError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List team repositories (Legacy)](Teams::list_repos_legacy_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsListReposLegacyError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsListReposLegacyError> for AdapterError {
fn from(err: TeamsListReposLegacyError) -> Self {
let (description, status_code) = match err {
TeamsListReposLegacyError::Status404(_) => (String::from("Resource not found"), 404),
TeamsListReposLegacyError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Remove team member (Legacy)](Teams::remove_member_legacy_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsRemoveMemberLegacyError {
#[error("Not Found if team synchronization is setup")]
Status404,
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsRemoveMemberLegacyError> for AdapterError {
fn from(err: TeamsRemoveMemberLegacyError) -> Self {
let (description, status_code) = match err {
TeamsRemoveMemberLegacyError::Status404 => (String::from("Not Found if team synchronization is setup"), 404),
TeamsRemoveMemberLegacyError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Remove team membership for a user](Teams::remove_membership_for_user_in_org_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsRemoveMembershipForUserInOrgError {
#[error("Forbidden if team synchronization is set up")]
Status403,
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsRemoveMembershipForUserInOrgError> for AdapterError {
fn from(err: TeamsRemoveMembershipForUserInOrgError) -> Self {
let (description, status_code) = match err {
TeamsRemoveMembershipForUserInOrgError::Status403 => (String::from("Forbidden if team synchronization is set up"), 403),
TeamsRemoveMembershipForUserInOrgError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Remove team membership for a user (Legacy)](Teams::remove_membership_for_user_legacy_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsRemoveMembershipForUserLegacyError {
#[error("if team synchronization is set up")]
Status403,
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsRemoveMembershipForUserLegacyError> for AdapterError {
fn from(err: TeamsRemoveMembershipForUserLegacyError) -> Self {
let (description, status_code) = match err {
TeamsRemoveMembershipForUserLegacyError::Status403 => (String::from("if team synchronization is set up"), 403),
TeamsRemoveMembershipForUserLegacyError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Remove a project from a team](Teams::remove_project_in_org_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsRemoveProjectInOrgError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsRemoveProjectInOrgError> for AdapterError {
fn from(err: TeamsRemoveProjectInOrgError) -> Self {
let (description, status_code) = match err {
TeamsRemoveProjectInOrgError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Remove a project from a team (Legacy)](Teams::remove_project_legacy_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsRemoveProjectLegacyError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsRemoveProjectLegacyError> for AdapterError {
fn from(err: TeamsRemoveProjectLegacyError) -> Self {
let (description, status_code) = match err {
TeamsRemoveProjectLegacyError::Status404(_) => (String::from("Resource not found"), 404),
TeamsRemoveProjectLegacyError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
TeamsRemoveProjectLegacyError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Remove a repository from a team](Teams::remove_repo_in_org_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsRemoveRepoInOrgError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsRemoveRepoInOrgError> for AdapterError {
fn from(err: TeamsRemoveRepoInOrgError) -> Self {
let (description, status_code) = match err {
TeamsRemoveRepoInOrgError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Remove a repository from a team (Legacy)](Teams::remove_repo_legacy_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsRemoveRepoLegacyError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsRemoveRepoLegacyError> for AdapterError {
fn from(err: TeamsRemoveRepoLegacyError) -> Self {
let (description, status_code) = match err {
TeamsRemoveRepoLegacyError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Update a discussion comment](Teams::update_discussion_comment_in_org_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsUpdateDiscussionCommentInOrgError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsUpdateDiscussionCommentInOrgError> for AdapterError {
fn from(err: TeamsUpdateDiscussionCommentInOrgError) -> Self {
let (description, status_code) = match err {
TeamsUpdateDiscussionCommentInOrgError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Update a discussion comment (Legacy)](Teams::update_discussion_comment_legacy_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsUpdateDiscussionCommentLegacyError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsUpdateDiscussionCommentLegacyError> for AdapterError {
fn from(err: TeamsUpdateDiscussionCommentLegacyError) -> Self {
let (description, status_code) = match err {
TeamsUpdateDiscussionCommentLegacyError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Update a discussion](Teams::update_discussion_in_org_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsUpdateDiscussionInOrgError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsUpdateDiscussionInOrgError> for AdapterError {
fn from(err: TeamsUpdateDiscussionInOrgError) -> Self {
let (description, status_code) = match err {
TeamsUpdateDiscussionInOrgError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Update a discussion (Legacy)](Teams::update_discussion_legacy_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsUpdateDiscussionLegacyError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsUpdateDiscussionLegacyError> for AdapterError {
fn from(err: TeamsUpdateDiscussionLegacyError) -> Self {
let (description, status_code) = match err {
TeamsUpdateDiscussionLegacyError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Update a team](Teams::update_in_org_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsUpdateInOrgError {
#[error("Response")]
Status201(TeamFull),
#[error("Resource not found")]
Status404(BasicError),
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsUpdateInOrgError> for AdapterError {
fn from(err: TeamsUpdateInOrgError) -> Self {
let (description, status_code) = match err {
TeamsUpdateInOrgError::Status201(_) => (String::from("Response"), 201),
TeamsUpdateInOrgError::Status404(_) => (String::from("Resource not found"), 404),
TeamsUpdateInOrgError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
TeamsUpdateInOrgError::Status403(_) => (String::from("Forbidden"), 403),
TeamsUpdateInOrgError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Update a team (Legacy)](Teams::update_legacy_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum TeamsUpdateLegacyError {
#[error("Response")]
Status201(TeamFull),
#[error("Resource not found")]
Status404(BasicError),
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<TeamsUpdateLegacyError> for AdapterError {
fn from(err: TeamsUpdateLegacyError) -> Self {
let (description, status_code) = match err {
TeamsUpdateLegacyError::Status201(_) => (String::from("Response"), 201),
TeamsUpdateLegacyError::Status404(_) => (String::from("Resource not found"), 404),
TeamsUpdateLegacyError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
TeamsUpdateLegacyError::Status403(_) => (String::from("Forbidden"), 403),
TeamsUpdateLegacyError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Query parameters for the [List teams](Teams::list_async()) endpoint.
#[derive(Default, Serialize)]
pub struct TeamsListParams {
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
per_page: Option<u16>,
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
page: Option<u16>
}
impl TeamsListParams {
pub fn new() -> Self {
Self::default()
}
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn per_page(self, per_page: u16) -> Self {
Self {
per_page: Some(per_page),
page: self.page,
}
}
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn page(self, page: u16) -> Self {
Self {
per_page: self.per_page,
page: Some(page),
}
}
}
impl<'enc> From<&'enc PerPage> for TeamsListParams {
fn from(per_page: &'enc PerPage) -> Self {
Self {
per_page: Some(per_page.per_page),
page: Some(per_page.page),
..Default::default()
}
}
}
/// Query parameters for the [List child teams](Teams::list_child_in_org_async()) endpoint.
#[derive(Default, Serialize)]
pub struct TeamsListChildInOrgParams {
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
per_page: Option<u16>,
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
page: Option<u16>
}
impl TeamsListChildInOrgParams {
pub fn new() -> Self {
Self::default()
}
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn per_page(self, per_page: u16) -> Self {
Self {
per_page: Some(per_page),
page: self.page,
}
}
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn page(self, page: u16) -> Self {
Self {
per_page: self.per_page,
page: Some(page),
}
}
}
impl<'enc> From<&'enc PerPage> for TeamsListChildInOrgParams {
fn from(per_page: &'enc PerPage) -> Self {
Self {
per_page: Some(per_page.per_page),
page: Some(per_page.page),
..Default::default()
}
}
}
/// Query parameters for the [List child teams (Legacy)](Teams::list_child_legacy_async()) endpoint.
#[derive(Default, Serialize)]
pub struct TeamsListChildLegacyParams {
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
per_page: Option<u16>,
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
page: Option<u16>
}
impl TeamsListChildLegacyParams {
pub fn new() -> Self {
Self::default()
}
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn per_page(self, per_page: u16) -> Self {
Self {
per_page: Some(per_page),
page: self.page,
}
}
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn page(self, page: u16) -> Self {
Self {
per_page: self.per_page,
page: Some(page),
}
}
}
impl<'enc> From<&'enc PerPage> for TeamsListChildLegacyParams {
fn from(per_page: &'enc PerPage) -> Self {
Self {
per_page: Some(per_page.per_page),
page: Some(per_page.page),
..Default::default()
}
}
}
/// Query parameters for the [List discussion comments](Teams::list_discussion_comments_in_org_async()) endpoint.
#[derive(Default, Serialize)]
pub struct TeamsListDiscussionCommentsInOrgParams<'req> {
/// The direction to sort the results by.
direction: Option<&'req str>,
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
per_page: Option<u16>,
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
page: Option<u16>
}
impl<'req> TeamsListDiscussionCommentsInOrgParams<'req> {
pub fn new() -> Self {
Self::default()
}
/// The direction to sort the results by.
pub fn direction(self, direction: &'req str) -> Self {
Self {
direction: Some(direction),
per_page: self.per_page,
page: self.page,
}
}
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn per_page(self, per_page: u16) -> Self {
Self {
direction: self.direction,
per_page: Some(per_page),
page: self.page,
}
}
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn page(self, page: u16) -> Self {
Self {
direction: self.direction,
per_page: self.per_page,
page: Some(page),
}
}
}
impl<'enc> From<&'enc PerPage> for TeamsListDiscussionCommentsInOrgParams<'enc> {
fn from(per_page: &'enc PerPage) -> Self {
Self {
per_page: Some(per_page.per_page),
page: Some(per_page.page),
..Default::default()
}
}
}
/// Query parameters for the [List discussion comments (Legacy)](Teams::list_discussion_comments_legacy_async()) endpoint.
#[derive(Default, Serialize)]
pub struct TeamsListDiscussionCommentsLegacyParams<'req> {
/// The direction to sort the results by.
direction: Option<&'req str>,
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
per_page: Option<u16>,
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
page: Option<u16>
}
impl<'req> TeamsListDiscussionCommentsLegacyParams<'req> {
pub fn new() -> Self {
Self::default()
}
/// The direction to sort the results by.
pub fn direction(self, direction: &'req str) -> Self {
Self {
direction: Some(direction),
per_page: self.per_page,
page: self.page,
}
}
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn per_page(self, per_page: u16) -> Self {
Self {
direction: self.direction,
per_page: Some(per_page),
page: self.page,
}
}
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn page(self, page: u16) -> Self {
Self {
direction: self.direction,
per_page: self.per_page,
page: Some(page),
}
}
}
impl<'enc> From<&'enc PerPage> for TeamsListDiscussionCommentsLegacyParams<'enc> {
fn from(per_page: &'enc PerPage) -> Self {
Self {
per_page: Some(per_page.per_page),
page: Some(per_page.page),
..Default::default()
}
}
}
/// Query parameters for the [List discussions](Teams::list_discussions_in_org_async()) endpoint.
#[derive(Default, Serialize)]
pub struct TeamsListDiscussionsInOrgParams<'req> {
/// The direction to sort the results by.
direction: Option<&'req str>,
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
per_page: Option<u16>,
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
page: Option<u16>,
/// Pinned discussions only filter
pinned: Option<&'req str>
}
impl<'req> TeamsListDiscussionsInOrgParams<'req> {
pub fn new() -> Self {
Self::default()
}
/// The direction to sort the results by.
pub fn direction(self, direction: &'req str) -> Self {
Self {
direction: Some(direction),
per_page: self.per_page,
page: self.page,
pinned: self.pinned,
}
}
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn per_page(self, per_page: u16) -> Self {
Self {
direction: self.direction,
per_page: Some(per_page),
page: self.page,
pinned: self.pinned,
}
}
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn page(self, page: u16) -> Self {
Self {
direction: self.direction,
per_page: self.per_page,
page: Some(page),
pinned: self.pinned,
}
}
/// Pinned discussions only filter
pub fn pinned(self, pinned: &'req str) -> Self {
Self {
direction: self.direction,
per_page: self.per_page,
page: self.page,
pinned: Some(pinned),
}
}
}
impl<'enc> From<&'enc PerPage> for TeamsListDiscussionsInOrgParams<'enc> {
fn from(per_page: &'enc PerPage) -> Self {
Self {
per_page: Some(per_page.per_page),
page: Some(per_page.page),
..Default::default()
}
}
}
/// Query parameters for the [List discussions (Legacy)](Teams::list_discussions_legacy_async()) endpoint.
#[derive(Default, Serialize)]
pub struct TeamsListDiscussionsLegacyParams<'req> {
/// The direction to sort the results by.
direction: Option<&'req str>,
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
per_page: Option<u16>,
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
page: Option<u16>
}
impl<'req> TeamsListDiscussionsLegacyParams<'req> {
pub fn new() -> Self {
Self::default()
}
/// The direction to sort the results by.
pub fn direction(self, direction: &'req str) -> Self {
Self {
direction: Some(direction),
per_page: self.per_page,
page: self.page,
}
}
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn per_page(self, per_page: u16) -> Self {
Self {
direction: self.direction,
per_page: Some(per_page),
page: self.page,
}
}
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn page(self, page: u16) -> Self {
Self {
direction: self.direction,
per_page: self.per_page,
page: Some(page),
}
}
}
impl<'enc> From<&'enc PerPage> for TeamsListDiscussionsLegacyParams<'enc> {
fn from(per_page: &'enc PerPage) -> Self {
Self {
per_page: Some(per_page.per_page),
page: Some(per_page.page),
..Default::default()
}
}
}
/// Query parameters for the [List teams for the authenticated user](Teams::list_for_authenticated_user_async()) endpoint.
#[derive(Default, Serialize)]
pub struct TeamsListForAuthenticatedUserParams {
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
per_page: Option<u16>,
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
page: Option<u16>
}
impl TeamsListForAuthenticatedUserParams {
pub fn new() -> Self {
Self::default()
}
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn per_page(self, per_page: u16) -> Self {
Self {
per_page: Some(per_page),
page: self.page,
}
}
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn page(self, page: u16) -> Self {
Self {
per_page: self.per_page,
page: Some(page),
}
}
}
impl<'enc> From<&'enc PerPage> for TeamsListForAuthenticatedUserParams {
fn from(per_page: &'enc PerPage) -> Self {
Self {
per_page: Some(per_page.per_page),
page: Some(per_page.page),
..Default::default()
}
}
}
/// Query parameters for the [List team members](Teams::list_members_in_org_async()) endpoint.
#[derive(Default, Serialize)]
pub struct TeamsListMembersInOrgParams<'req> {
/// Filters members returned by their role in the team.
role: Option<&'req str>,
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
per_page: Option<u16>,
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
page: Option<u16>
}
impl<'req> TeamsListMembersInOrgParams<'req> {
pub fn new() -> Self {
Self::default()
}
/// Filters members returned by their role in the team.
pub fn role(self, role: &'req str) -> Self {
Self {
role: Some(role),
per_page: self.per_page,
page: self.page,
}
}
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn per_page(self, per_page: u16) -> Self {
Self {
role: self.role,
per_page: Some(per_page),
page: self.page,
}
}
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn page(self, page: u16) -> Self {
Self {
role: self.role,
per_page: self.per_page,
page: Some(page),
}
}
}
impl<'enc> From<&'enc PerPage> for TeamsListMembersInOrgParams<'enc> {
fn from(per_page: &'enc PerPage) -> Self {
Self {
per_page: Some(per_page.per_page),
page: Some(per_page.page),
..Default::default()
}
}
}
/// Query parameters for the [List team members (Legacy)](Teams::list_members_legacy_async()) endpoint.
#[derive(Default, Serialize)]
pub struct TeamsListMembersLegacyParams<'req> {
/// Filters members returned by their role in the team.
role: Option<&'req str>,
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
per_page: Option<u16>,
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
page: Option<u16>
}
impl<'req> TeamsListMembersLegacyParams<'req> {
pub fn new() -> Self {
Self::default()
}
/// Filters members returned by their role in the team.
pub fn role(self, role: &'req str) -> Self {
Self {
role: Some(role),
per_page: self.per_page,
page: self.page,
}
}
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn per_page(self, per_page: u16) -> Self {
Self {
role: self.role,
per_page: Some(per_page),
page: self.page,
}
}
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn page(self, page: u16) -> Self {
Self {
role: self.role,
per_page: self.per_page,
page: Some(page),
}
}
}
impl<'enc> From<&'enc PerPage> for TeamsListMembersLegacyParams<'enc> {
fn from(per_page: &'enc PerPage) -> Self {
Self {
per_page: Some(per_page.per_page),
page: Some(per_page.page),
..Default::default()
}
}
}
/// Query parameters for the [List pending team invitations](Teams::list_pending_invitations_in_org_async()) endpoint.
#[derive(Default, Serialize)]
pub struct TeamsListPendingInvitationsInOrgParams {
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
per_page: Option<u16>,
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
page: Option<u16>
}
impl TeamsListPendingInvitationsInOrgParams {
pub fn new() -> Self {
Self::default()
}
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn per_page(self, per_page: u16) -> Self {
Self {
per_page: Some(per_page),
page: self.page,
}
}
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn page(self, page: u16) -> Self {
Self {
per_page: self.per_page,
page: Some(page),
}
}
}
impl<'enc> From<&'enc PerPage> for TeamsListPendingInvitationsInOrgParams {
fn from(per_page: &'enc PerPage) -> Self {
Self {
per_page: Some(per_page.per_page),
page: Some(per_page.page),
..Default::default()
}
}
}
/// Query parameters for the [List pending team invitations (Legacy)](Teams::list_pending_invitations_legacy_async()) endpoint.
#[derive(Default, Serialize)]
pub struct TeamsListPendingInvitationsLegacyParams {
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
per_page: Option<u16>,
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
page: Option<u16>
}
impl TeamsListPendingInvitationsLegacyParams {
pub fn new() -> Self {
Self::default()
}
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn per_page(self, per_page: u16) -> Self {
Self {
per_page: Some(per_page),
page: self.page,
}
}
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn page(self, page: u16) -> Self {
Self {
per_page: self.per_page,
page: Some(page),
}
}
}
impl<'enc> From<&'enc PerPage> for TeamsListPendingInvitationsLegacyParams {
fn from(per_page: &'enc PerPage) -> Self {
Self {
per_page: Some(per_page.per_page),
page: Some(per_page.page),
..Default::default()
}
}
}
/// Query parameters for the [List team projects](Teams::list_projects_in_org_async()) endpoint.
#[derive(Default, Serialize)]
pub struct TeamsListProjectsInOrgParams {
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
per_page: Option<u16>,
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
page: Option<u16>
}
impl TeamsListProjectsInOrgParams {
pub fn new() -> Self {
Self::default()
}
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn per_page(self, per_page: u16) -> Self {
Self {
per_page: Some(per_page),
page: self.page,
}
}
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn page(self, page: u16) -> Self {
Self {
per_page: self.per_page,
page: Some(page),
}
}
}
impl<'enc> From<&'enc PerPage> for TeamsListProjectsInOrgParams {
fn from(per_page: &'enc PerPage) -> Self {
Self {
per_page: Some(per_page.per_page),
page: Some(per_page.page),
..Default::default()
}
}
}
/// Query parameters for the [List team projects (Legacy)](Teams::list_projects_legacy_async()) endpoint.
#[derive(Default, Serialize)]
pub struct TeamsListProjectsLegacyParams {
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
per_page: Option<u16>,
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
page: Option<u16>
}
impl TeamsListProjectsLegacyParams {
pub fn new() -> Self {
Self::default()
}
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn per_page(self, per_page: u16) -> Self {
Self {
per_page: Some(per_page),
page: self.page,
}
}
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn page(self, page: u16) -> Self {
Self {
per_page: self.per_page,
page: Some(page),
}
}
}
impl<'enc> From<&'enc PerPage> for TeamsListProjectsLegacyParams {
fn from(per_page: &'enc PerPage) -> Self {
Self {
per_page: Some(per_page.per_page),
page: Some(per_page.page),
..Default::default()
}
}
}
/// Query parameters for the [List team repositories](Teams::list_repos_in_org_async()) endpoint.
#[derive(Default, Serialize)]
pub struct TeamsListReposInOrgParams {
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
per_page: Option<u16>,
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
page: Option<u16>
}
impl TeamsListReposInOrgParams {
pub fn new() -> Self {
Self::default()
}
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn per_page(self, per_page: u16) -> Self {
Self {
per_page: Some(per_page),
page: self.page,
}
}
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn page(self, page: u16) -> Self {
Self {
per_page: self.per_page,
page: Some(page),
}
}
}
impl<'enc> From<&'enc PerPage> for TeamsListReposInOrgParams {
fn from(per_page: &'enc PerPage) -> Self {
Self {
per_page: Some(per_page.per_page),
page: Some(per_page.page),
..Default::default()
}
}
}
/// Query parameters for the [List team repositories (Legacy)](Teams::list_repos_legacy_async()) endpoint.
#[derive(Default, Serialize)]
pub struct TeamsListReposLegacyParams {
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
per_page: Option<u16>,
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
page: Option<u16>
}
impl TeamsListReposLegacyParams {
pub fn new() -> Self {
Self::default()
}
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn per_page(self, per_page: u16) -> Self {
Self {
per_page: Some(per_page),
page: self.page,
}
}
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn page(self, page: u16) -> Self {
Self {
per_page: self.per_page,
page: Some(page),
}
}
}
impl<'enc> From<&'enc PerPage> for TeamsListReposLegacyParams {
fn from(per_page: &'enc PerPage) -> Self {
Self {
per_page: Some(per_page.per_page),
page: Some(per_page.page),
..Default::default()
}
}
}
impl<'api, C: Client> Teams<'api, C> where AdapterError: From<<C as Client>::Err> {
/// ---
///
/// # Add team member (Legacy)
///
/// The "Add team member" endpoint (described below) is closing down.
///
/// We recommend using the [Add or update team membership for a user](https://docs.github.com/rest/teams/members#add-or-update-team-membership-for-a-user) endpoint instead. It allows you to invite new organization members to your teams.
///
/// Team synchronization is available for organizations using GitHub Enterprise Cloud. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// To add someone to a team, the authenticated user must be an organization owner or a team maintainer in the team they're changing. The person being added to the team must be a member of the team's organization.
///
/// > [!NOTE]
/// > When you have team synchronization set up for a team with your organization's identity provider (IdP), you will see an error if you attempt to use the API for making changes to the team's membership. If you have access to manage group membership in your IdP, you can manage GitHub team membership through your identity provider, which automatically adds and removes team members in an organization. For more information, see "[Synchronizing teams between your identity provider and GitHub](https://docs.github.com/articles/synchronizing-teams-between-your-identity-provider-and-github/)."
///
/// Note that you'll need to set `Content-Length` to zero when calling out to this endpoint. For more information, see "[HTTP method](https://docs.github.com/rest/guides/getting-started-with-the-rest-api#http-method)."
///
/// [GitHub API docs for add_member_legacy](https://docs.github.com/rest/teams/members#add-team-member-legacy)
///
/// ---
pub async fn add_member_legacy_async(&self, team_id: i32, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/teams/{}/members/{}", super::GITHUB_BASE_API_URL, team_id, username);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "PUT",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
404 => Err(TeamsAddMemberLegacyError::Status404.into()),
422 => Err(TeamsAddMemberLegacyError::Status422.into()),
403 => Err(TeamsAddMemberLegacyError::Status403(github_response.to_json_async().await?).into()),
code => Err(TeamsAddMemberLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Add team member (Legacy)
///
/// The "Add team member" endpoint (described below) is closing down.
///
/// We recommend using the [Add or update team membership for a user](https://docs.github.com/rest/teams/members#add-or-update-team-membership-for-a-user) endpoint instead. It allows you to invite new organization members to your teams.
///
/// Team synchronization is available for organizations using GitHub Enterprise Cloud. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// To add someone to a team, the authenticated user must be an organization owner or a team maintainer in the team they're changing. The person being added to the team must be a member of the team's organization.
///
/// > [!NOTE]
/// > When you have team synchronization set up for a team with your organization's identity provider (IdP), you will see an error if you attempt to use the API for making changes to the team's membership. If you have access to manage group membership in your IdP, you can manage GitHub team membership through your identity provider, which automatically adds and removes team members in an organization. For more information, see "[Synchronizing teams between your identity provider and GitHub](https://docs.github.com/articles/synchronizing-teams-between-your-identity-provider-and-github/)."
///
/// Note that you'll need to set `Content-Length` to zero when calling out to this endpoint. For more information, see "[HTTP method](https://docs.github.com/rest/guides/getting-started-with-the-rest-api#http-method)."
///
/// [GitHub API docs for add_member_legacy](https://docs.github.com/rest/teams/members#add-team-member-legacy)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn add_member_legacy(&self, team_id: i32, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/teams/{}/members/{}", super::GITHUB_BASE_API_URL, team_id, username);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "PUT",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
404 => Err(TeamsAddMemberLegacyError::Status404.into()),
422 => Err(TeamsAddMemberLegacyError::Status422.into()),
403 => Err(TeamsAddMemberLegacyError::Status403(github_response.to_json()?).into()),
code => Err(TeamsAddMemberLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Add or update team membership for a user
///
/// Adds an organization member to a team. An authenticated organization owner or team maintainer can add organization members to a team.
///
/// Team synchronization is available for organizations using GitHub Enterprise Cloud. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// > [!NOTE]
/// > When you have team synchronization set up for a team with your organization's identity provider (IdP), you will see an error if you attempt to use the API for making changes to the team's membership. If you have access to manage group membership in your IdP, you can manage GitHub team membership through your identity provider, which automatically adds and removes team members in an organization. For more information, see "[Synchronizing teams between your identity provider and GitHub](https://docs.github.com/articles/synchronizing-teams-between-your-identity-provider-and-github/)."
///
/// An organization owner can add someone who is not part of the team's organization to a team. When an organization owner adds someone to a team who is not an organization member, this endpoint will send an invitation to the person via email. This newly-created membership will be in the "pending" state until the person accepts the invitation, at which point the membership will transition to the "active" state and the user will be added as a member of the team.
///
/// If the user is already a member of the team, this endpoint will update the role of the team member's role. To update the membership of a team member, the authenticated user must be an organization owner or a team maintainer.
///
/// > [!NOTE]
/// > You can also specify a team by `org_id` and `team_id` using the route `PUT /organizations/{org_id}/team/{team_id}/memberships/{username}`.
///
/// [GitHub API docs for add_or_update_membership_for_user_in_org](https://docs.github.com/rest/teams/members#add-or-update-team-membership-for-a-user)
///
/// ---
pub async fn add_or_update_membership_for_user_in_org_async(&self, org: &str, team_slug: &str, username: &str, body: PutTeamsAddOrUpdateMembershipForUserInOrg) -> Result<TeamMembership, AdapterError> {
let request_uri = format!("{}/orgs/{}/teams/{}/memberships/{}", super::GITHUB_BASE_API_URL, org, team_slug, username);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutTeamsAddOrUpdateMembershipForUserInOrg>(body)?),
method: "PUT",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
403 => Err(TeamsAddOrUpdateMembershipForUserInOrgError::Status403.into()),
422 => Err(TeamsAddOrUpdateMembershipForUserInOrgError::Status422.into()),
code => Err(TeamsAddOrUpdateMembershipForUserInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Add or update team membership for a user
///
/// Adds an organization member to a team. An authenticated organization owner or team maintainer can add organization members to a team.
///
/// Team synchronization is available for organizations using GitHub Enterprise Cloud. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// > [!NOTE]
/// > When you have team synchronization set up for a team with your organization's identity provider (IdP), you will see an error if you attempt to use the API for making changes to the team's membership. If you have access to manage group membership in your IdP, you can manage GitHub team membership through your identity provider, which automatically adds and removes team members in an organization. For more information, see "[Synchronizing teams between your identity provider and GitHub](https://docs.github.com/articles/synchronizing-teams-between-your-identity-provider-and-github/)."
///
/// An organization owner can add someone who is not part of the team's organization to a team. When an organization owner adds someone to a team who is not an organization member, this endpoint will send an invitation to the person via email. This newly-created membership will be in the "pending" state until the person accepts the invitation, at which point the membership will transition to the "active" state and the user will be added as a member of the team.
///
/// If the user is already a member of the team, this endpoint will update the role of the team member's role. To update the membership of a team member, the authenticated user must be an organization owner or a team maintainer.
///
/// > [!NOTE]
/// > You can also specify a team by `org_id` and `team_id` using the route `PUT /organizations/{org_id}/team/{team_id}/memberships/{username}`.
///
/// [GitHub API docs for add_or_update_membership_for_user_in_org](https://docs.github.com/rest/teams/members#add-or-update-team-membership-for-a-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn add_or_update_membership_for_user_in_org(&self, org: &str, team_slug: &str, username: &str, body: PutTeamsAddOrUpdateMembershipForUserInOrg) -> Result<TeamMembership, AdapterError> {
let request_uri = format!("{}/orgs/{}/teams/{}/memberships/{}", super::GITHUB_BASE_API_URL, org, team_slug, username);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutTeamsAddOrUpdateMembershipForUserInOrg>(body)?),
method: "PUT",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
403 => Err(TeamsAddOrUpdateMembershipForUserInOrgError::Status403.into()),
422 => Err(TeamsAddOrUpdateMembershipForUserInOrgError::Status422.into()),
code => Err(TeamsAddOrUpdateMembershipForUserInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Add or update team membership for a user (Legacy)
///
/// > [!WARNING]
/// > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [Add or update team membership for a user](https://docs.github.com/rest/teams/members#add-or-update-team-membership-for-a-user) endpoint.
///
/// Team synchronization is available for organizations using GitHub Enterprise Cloud. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// If the user is already a member of the team's organization, this endpoint will add the user to the team. To add a membership between an organization member and a team, the authenticated user must be an organization owner or a team maintainer.
///
/// > [!NOTE]
/// > When you have team synchronization set up for a team with your organization's identity provider (IdP), you will see an error if you attempt to use the API for making changes to the team's membership. If you have access to manage group membership in your IdP, you can manage GitHub team membership through your identity provider, which automatically adds and removes team members in an organization. For more information, see "[Synchronizing teams between your identity provider and GitHub](https://docs.github.com/articles/synchronizing-teams-between-your-identity-provider-and-github/)."
///
/// If the user is unaffiliated with the team's organization, this endpoint will send an invitation to the user via email. This newly-created membership will be in the "pending" state until the user accepts the invitation, at which point the membership will transition to the "active" state and the user will be added as a member of the team. To add a membership between an unaffiliated user and a team, the authenticated user must be an organization owner.
///
/// If the user is already a member of the team, this endpoint will update the role of the team member's role. To update the membership of a team member, the authenticated user must be an organization owner or a team maintainer.
///
/// [GitHub API docs for add_or_update_membership_for_user_legacy](https://docs.github.com/rest/teams/members#add-or-update-team-membership-for-a-user-legacy)
///
/// ---
pub async fn add_or_update_membership_for_user_legacy_async(&self, team_id: i32, username: &str, body: PutTeamsAddOrUpdateMembershipForUserLegacy) -> Result<TeamMembership, AdapterError> {
let request_uri = format!("{}/teams/{}/memberships/{}", super::GITHUB_BASE_API_URL, team_id, username);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutTeamsAddOrUpdateMembershipForUserLegacy>(body)?),
method: "PUT",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
403 => Err(TeamsAddOrUpdateMembershipForUserLegacyError::Status403.into()),
422 => Err(TeamsAddOrUpdateMembershipForUserLegacyError::Status422.into()),
404 => Err(TeamsAddOrUpdateMembershipForUserLegacyError::Status404(github_response.to_json_async().await?).into()),
code => Err(TeamsAddOrUpdateMembershipForUserLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Add or update team membership for a user (Legacy)
///
/// > [!WARNING]
/// > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [Add or update team membership for a user](https://docs.github.com/rest/teams/members#add-or-update-team-membership-for-a-user) endpoint.
///
/// Team synchronization is available for organizations using GitHub Enterprise Cloud. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// If the user is already a member of the team's organization, this endpoint will add the user to the team. To add a membership between an organization member and a team, the authenticated user must be an organization owner or a team maintainer.
///
/// > [!NOTE]
/// > When you have team synchronization set up for a team with your organization's identity provider (IdP), you will see an error if you attempt to use the API for making changes to the team's membership. If you have access to manage group membership in your IdP, you can manage GitHub team membership through your identity provider, which automatically adds and removes team members in an organization. For more information, see "[Synchronizing teams between your identity provider and GitHub](https://docs.github.com/articles/synchronizing-teams-between-your-identity-provider-and-github/)."
///
/// If the user is unaffiliated with the team's organization, this endpoint will send an invitation to the user via email. This newly-created membership will be in the "pending" state until the user accepts the invitation, at which point the membership will transition to the "active" state and the user will be added as a member of the team. To add a membership between an unaffiliated user and a team, the authenticated user must be an organization owner.
///
/// If the user is already a member of the team, this endpoint will update the role of the team member's role. To update the membership of a team member, the authenticated user must be an organization owner or a team maintainer.
///
/// [GitHub API docs for add_or_update_membership_for_user_legacy](https://docs.github.com/rest/teams/members#add-or-update-team-membership-for-a-user-legacy)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn add_or_update_membership_for_user_legacy(&self, team_id: i32, username: &str, body: PutTeamsAddOrUpdateMembershipForUserLegacy) -> Result<TeamMembership, AdapterError> {
let request_uri = format!("{}/teams/{}/memberships/{}", super::GITHUB_BASE_API_URL, team_id, username);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutTeamsAddOrUpdateMembershipForUserLegacy>(body)?),
method: "PUT",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
403 => Err(TeamsAddOrUpdateMembershipForUserLegacyError::Status403.into()),
422 => Err(TeamsAddOrUpdateMembershipForUserLegacyError::Status422.into()),
404 => Err(TeamsAddOrUpdateMembershipForUserLegacyError::Status404(github_response.to_json()?).into()),
code => Err(TeamsAddOrUpdateMembershipForUserLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Add or update team project permissions
///
/// > [!WARNING]
/// > **Closing down notice:** Projects (classic) is being deprecated in favor of the new Projects experience.
/// > See the [changelog](https://github.blog/changelog/2024-05-23-sunset-notice-projects-classic/) for more information.
///
/// [GitHub API docs for add_or_update_project_permissions_in_org](https://docs.github.com/rest/teams/teams#add-or-update-team-project-permissions)
///
/// ---
pub async fn add_or_update_project_permissions_in_org_async(&self, org: &str, team_slug: &str, project_id: i32, body: PutTeamsAddOrUpdateProjectPermissionsInOrg) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/teams/{}/projects/{}", super::GITHUB_BASE_API_URL, org, team_slug, project_id);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutTeamsAddOrUpdateProjectPermissionsInOrg>(body)?),
method: "PUT",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
403 => Err(TeamsAddOrUpdateProjectPermissionsInOrgError::Status403(github_response.to_json_async().await?).into()),
code => Err(TeamsAddOrUpdateProjectPermissionsInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Add or update team project permissions
///
/// > [!WARNING]
/// > **Closing down notice:** Projects (classic) is being deprecated in favor of the new Projects experience.
/// > See the [changelog](https://github.blog/changelog/2024-05-23-sunset-notice-projects-classic/) for more information.
///
/// [GitHub API docs for add_or_update_project_permissions_in_org](https://docs.github.com/rest/teams/teams#add-or-update-team-project-permissions)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn add_or_update_project_permissions_in_org(&self, org: &str, team_slug: &str, project_id: i32, body: PutTeamsAddOrUpdateProjectPermissionsInOrg) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/teams/{}/projects/{}", super::GITHUB_BASE_API_URL, org, team_slug, project_id);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutTeamsAddOrUpdateProjectPermissionsInOrg>(body)?),
method: "PUT",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
403 => Err(TeamsAddOrUpdateProjectPermissionsInOrgError::Status403(github_response.to_json()?).into()),
code => Err(TeamsAddOrUpdateProjectPermissionsInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Add or update team project permissions (Legacy)
///
/// > [!WARNING]
/// > **Closing down notice:** Projects (classic) is being deprecated in favor of the new Projects experience.
/// > See the [changelog](https://github.blog/changelog/2024-05-23-sunset-notice-projects-classic/) for more information.
///
/// [GitHub API docs for add_or_update_project_permissions_legacy](https://docs.github.com/rest/teams/teams#add-or-update-team-project-permissions-legacy)
///
/// ---
pub async fn add_or_update_project_permissions_legacy_async(&self, team_id: i32, project_id: i32, body: PutTeamsAddOrUpdateProjectPermissionsLegacy) -> Result<(), AdapterError> {
let request_uri = format!("{}/teams/{}/projects/{}", super::GITHUB_BASE_API_URL, team_id, project_id);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutTeamsAddOrUpdateProjectPermissionsLegacy>(body)?),
method: "PUT",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
403 => Err(TeamsAddOrUpdateProjectPermissionsLegacyError::Status403(github_response.to_json_async().await?).into()),
404 => Err(TeamsAddOrUpdateProjectPermissionsLegacyError::Status404(github_response.to_json_async().await?).into()),
422 => Err(TeamsAddOrUpdateProjectPermissionsLegacyError::Status422(github_response.to_json_async().await?).into()),
code => Err(TeamsAddOrUpdateProjectPermissionsLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Add or update team project permissions (Legacy)
///
/// > [!WARNING]
/// > **Closing down notice:** Projects (classic) is being deprecated in favor of the new Projects experience.
/// > See the [changelog](https://github.blog/changelog/2024-05-23-sunset-notice-projects-classic/) for more information.
///
/// [GitHub API docs for add_or_update_project_permissions_legacy](https://docs.github.com/rest/teams/teams#add-or-update-team-project-permissions-legacy)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn add_or_update_project_permissions_legacy(&self, team_id: i32, project_id: i32, body: PutTeamsAddOrUpdateProjectPermissionsLegacy) -> Result<(), AdapterError> {
let request_uri = format!("{}/teams/{}/projects/{}", super::GITHUB_BASE_API_URL, team_id, project_id);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutTeamsAddOrUpdateProjectPermissionsLegacy>(body)?),
method: "PUT",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
403 => Err(TeamsAddOrUpdateProjectPermissionsLegacyError::Status403(github_response.to_json()?).into()),
404 => Err(TeamsAddOrUpdateProjectPermissionsLegacyError::Status404(github_response.to_json()?).into()),
422 => Err(TeamsAddOrUpdateProjectPermissionsLegacyError::Status422(github_response.to_json()?).into()),
code => Err(TeamsAddOrUpdateProjectPermissionsLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Add or update team repository permissions
///
/// To add a repository to a team or update the team's permission on a repository, the authenticated user must have admin access to the repository, and must be able to see the team. The repository must be owned by the organization, or a direct fork of a repository owned by the organization. You will get a `422 Unprocessable Entity` status if you attempt to add a repository to a team that is not owned by the organization. Note that, if you choose not to pass any parameters, you'll need to set `Content-Length` to zero when calling out to this endpoint. For more information, see "[HTTP method](https://docs.github.com/rest/guides/getting-started-with-the-rest-api#http-method)."
///
/// > [!NOTE]
/// > You can also specify a team by `org_id` and `team_id` using the route `PUT /organizations/{org_id}/team/{team_id}/repos/{owner}/{repo}`.
///
/// For more information about the permission levels, see "[Repository permission levels for an organization](https://docs.github.com/github/setting-up-and-managing-organizations-and-teams/repository-permission-levels-for-an-organization#permission-levels-for-repositories-owned-by-an-organization)".
///
/// [GitHub API docs for add_or_update_repo_permissions_in_org](https://docs.github.com/rest/teams/teams#add-or-update-team-repository-permissions)
///
/// ---
pub async fn add_or_update_repo_permissions_in_org_async(&self, org: &str, team_slug: &str, owner: &str, repo: &str, body: PutTeamsAddOrUpdateRepoPermissionsInOrg) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/teams/{}/repos/{}/{}", super::GITHUB_BASE_API_URL, org, team_slug, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutTeamsAddOrUpdateRepoPermissionsInOrg>(body)?),
method: "PUT",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
code => Err(TeamsAddOrUpdateRepoPermissionsInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Add or update team repository permissions
///
/// To add a repository to a team or update the team's permission on a repository, the authenticated user must have admin access to the repository, and must be able to see the team. The repository must be owned by the organization, or a direct fork of a repository owned by the organization. You will get a `422 Unprocessable Entity` status if you attempt to add a repository to a team that is not owned by the organization. Note that, if you choose not to pass any parameters, you'll need to set `Content-Length` to zero when calling out to this endpoint. For more information, see "[HTTP method](https://docs.github.com/rest/guides/getting-started-with-the-rest-api#http-method)."
///
/// > [!NOTE]
/// > You can also specify a team by `org_id` and `team_id` using the route `PUT /organizations/{org_id}/team/{team_id}/repos/{owner}/{repo}`.
///
/// For more information about the permission levels, see "[Repository permission levels for an organization](https://docs.github.com/github/setting-up-and-managing-organizations-and-teams/repository-permission-levels-for-an-organization#permission-levels-for-repositories-owned-by-an-organization)".
///
/// [GitHub API docs for add_or_update_repo_permissions_in_org](https://docs.github.com/rest/teams/teams#add-or-update-team-repository-permissions)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn add_or_update_repo_permissions_in_org(&self, org: &str, team_slug: &str, owner: &str, repo: &str, body: PutTeamsAddOrUpdateRepoPermissionsInOrg) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/teams/{}/repos/{}/{}", super::GITHUB_BASE_API_URL, org, team_slug, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutTeamsAddOrUpdateRepoPermissionsInOrg>(body)?),
method: "PUT",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
code => Err(TeamsAddOrUpdateRepoPermissionsInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Add or update team repository permissions (Legacy)
///
/// > [!WARNING]
/// > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new "[Add or update team repository permissions](https://docs.github.com/rest/teams/teams#add-or-update-team-repository-permissions)" endpoint.
///
/// To add a repository to a team or update the team's permission on a repository, the authenticated user must have admin access to the repository, and must be able to see the team. The repository must be owned by the organization, or a direct fork of a repository owned by the organization. You will get a `422 Unprocessable Entity` status if you attempt to add a repository to a team that is not owned by the organization.
///
/// Note that, if you choose not to pass any parameters, you'll need to set `Content-Length` to zero when calling out to this endpoint. For more information, see "[HTTP method](https://docs.github.com/rest/guides/getting-started-with-the-rest-api#http-method)."
///
/// [GitHub API docs for add_or_update_repo_permissions_legacy](https://docs.github.com/rest/teams/teams#add-or-update-team-repository-permissions-legacy)
///
/// ---
pub async fn add_or_update_repo_permissions_legacy_async(&self, team_id: i32, owner: &str, repo: &str, body: PutTeamsAddOrUpdateRepoPermissionsLegacy) -> Result<(), AdapterError> {
let request_uri = format!("{}/teams/{}/repos/{}/{}", super::GITHUB_BASE_API_URL, team_id, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutTeamsAddOrUpdateRepoPermissionsLegacy>(body)?),
method: "PUT",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
403 => Err(TeamsAddOrUpdateRepoPermissionsLegacyError::Status403(github_response.to_json_async().await?).into()),
422 => Err(TeamsAddOrUpdateRepoPermissionsLegacyError::Status422(github_response.to_json_async().await?).into()),
code => Err(TeamsAddOrUpdateRepoPermissionsLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Add or update team repository permissions (Legacy)
///
/// > [!WARNING]
/// > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new "[Add or update team repository permissions](https://docs.github.com/rest/teams/teams#add-or-update-team-repository-permissions)" endpoint.
///
/// To add a repository to a team or update the team's permission on a repository, the authenticated user must have admin access to the repository, and must be able to see the team. The repository must be owned by the organization, or a direct fork of a repository owned by the organization. You will get a `422 Unprocessable Entity` status if you attempt to add a repository to a team that is not owned by the organization.
///
/// Note that, if you choose not to pass any parameters, you'll need to set `Content-Length` to zero when calling out to this endpoint. For more information, see "[HTTP method](https://docs.github.com/rest/guides/getting-started-with-the-rest-api#http-method)."
///
/// [GitHub API docs for add_or_update_repo_permissions_legacy](https://docs.github.com/rest/teams/teams#add-or-update-team-repository-permissions-legacy)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn add_or_update_repo_permissions_legacy(&self, team_id: i32, owner: &str, repo: &str, body: PutTeamsAddOrUpdateRepoPermissionsLegacy) -> Result<(), AdapterError> {
let request_uri = format!("{}/teams/{}/repos/{}/{}", super::GITHUB_BASE_API_URL, team_id, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutTeamsAddOrUpdateRepoPermissionsLegacy>(body)?),
method: "PUT",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
403 => Err(TeamsAddOrUpdateRepoPermissionsLegacyError::Status403(github_response.to_json()?).into()),
422 => Err(TeamsAddOrUpdateRepoPermissionsLegacyError::Status422(github_response.to_json()?).into()),
code => Err(TeamsAddOrUpdateRepoPermissionsLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Check team permissions for a project
///
/// > [!WARNING]
/// > **Closing down notice:** Projects (classic) is being deprecated in favor of the new Projects experience.
/// > See the [changelog](https://github.blog/changelog/2024-05-23-sunset-notice-projects-classic/) for more information.
///
/// [GitHub API docs for check_permissions_for_project_in_org](https://docs.github.com/rest/teams/teams#check-team-permissions-for-a-project)
///
/// ---
pub async fn check_permissions_for_project_in_org_async(&self, org: &str, team_slug: &str, project_id: i32) -> Result<TeamProject, AdapterError> {
let request_uri = format!("{}/orgs/{}/teams/{}/projects/{}", super::GITHUB_BASE_API_URL, org, team_slug, project_id);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
404 => Err(TeamsCheckPermissionsForProjectInOrgError::Status404.into()),
code => Err(TeamsCheckPermissionsForProjectInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Check team permissions for a project
///
/// > [!WARNING]
/// > **Closing down notice:** Projects (classic) is being deprecated in favor of the new Projects experience.
/// > See the [changelog](https://github.blog/changelog/2024-05-23-sunset-notice-projects-classic/) for more information.
///
/// [GitHub API docs for check_permissions_for_project_in_org](https://docs.github.com/rest/teams/teams#check-team-permissions-for-a-project)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn check_permissions_for_project_in_org(&self, org: &str, team_slug: &str, project_id: i32) -> Result<TeamProject, AdapterError> {
let request_uri = format!("{}/orgs/{}/teams/{}/projects/{}", super::GITHUB_BASE_API_URL, org, team_slug, project_id);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
404 => Err(TeamsCheckPermissionsForProjectInOrgError::Status404.into()),
code => Err(TeamsCheckPermissionsForProjectInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Check team permissions for a project (Legacy)
///
/// > [!WARNING]
/// > **Closing down notice:** Projects (classic) is being deprecated in favor of the new Projects experience.
/// > See the [changelog](https://github.blog/changelog/2024-05-23-sunset-notice-projects-classic/) for more information.
///
/// [GitHub API docs for check_permissions_for_project_legacy](https://docs.github.com/rest/teams/teams#check-team-permissions-for-a-project-legacy)
///
/// ---
pub async fn check_permissions_for_project_legacy_async(&self, team_id: i32, project_id: i32) -> Result<TeamProject, AdapterError> {
let request_uri = format!("{}/teams/{}/projects/{}", super::GITHUB_BASE_API_URL, team_id, project_id);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
404 => Err(TeamsCheckPermissionsForProjectLegacyError::Status404.into()),
code => Err(TeamsCheckPermissionsForProjectLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Check team permissions for a project (Legacy)
///
/// > [!WARNING]
/// > **Closing down notice:** Projects (classic) is being deprecated in favor of the new Projects experience.
/// > See the [changelog](https://github.blog/changelog/2024-05-23-sunset-notice-projects-classic/) for more information.
///
/// [GitHub API docs for check_permissions_for_project_legacy](https://docs.github.com/rest/teams/teams#check-team-permissions-for-a-project-legacy)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn check_permissions_for_project_legacy(&self, team_id: i32, project_id: i32) -> Result<TeamProject, AdapterError> {
let request_uri = format!("{}/teams/{}/projects/{}", super::GITHUB_BASE_API_URL, team_id, project_id);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
404 => Err(TeamsCheckPermissionsForProjectLegacyError::Status404.into()),
code => Err(TeamsCheckPermissionsForProjectLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Check team permissions for a repository
///
/// Checks whether a team has `admin`, `push`, `maintain`, `triage`, or `pull` permission for a repository. Repositories inherited through a parent team will also be checked.
///
/// You can also get information about the specified repository, including what permissions the team grants on it, by passing the following custom [media type](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types/) via the `application/vnd.github.v3.repository+json` accept header.
///
/// If a team doesn't have permission for the repository, you will receive a `404 Not Found` response status.
///
/// If the repository is private, you must have at least `read` permission for that repository, and your token must have the `repo` or `admin:org` scope. Otherwise, you will receive a `404 Not Found` response status.
///
/// > [!NOTE]
/// > You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/{org_id}/team/{team_id}/repos/{owner}/{repo}`.
///
/// [GitHub API docs for check_permissions_for_repo_in_org](https://docs.github.com/rest/teams/teams#check-team-permissions-for-a-repository)
///
/// ---
pub async fn check_permissions_for_repo_in_org_async(&self, org: &str, team_slug: &str, owner: &str, repo: &str) -> Result<TeamRepository, AdapterError> {
let request_uri = format!("{}/orgs/{}/teams/{}/repos/{}/{}", super::GITHUB_BASE_API_URL, org, team_slug, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
204 => Err(TeamsCheckPermissionsForRepoInOrgError::Status204.into()),
404 => Err(TeamsCheckPermissionsForRepoInOrgError::Status404.into()),
code => Err(TeamsCheckPermissionsForRepoInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Check team permissions for a repository
///
/// Checks whether a team has `admin`, `push`, `maintain`, `triage`, or `pull` permission for a repository. Repositories inherited through a parent team will also be checked.
///
/// You can also get information about the specified repository, including what permissions the team grants on it, by passing the following custom [media type](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types/) via the `application/vnd.github.v3.repository+json` accept header.
///
/// If a team doesn't have permission for the repository, you will receive a `404 Not Found` response status.
///
/// If the repository is private, you must have at least `read` permission for that repository, and your token must have the `repo` or `admin:org` scope. Otherwise, you will receive a `404 Not Found` response status.
///
/// > [!NOTE]
/// > You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/{org_id}/team/{team_id}/repos/{owner}/{repo}`.
///
/// [GitHub API docs for check_permissions_for_repo_in_org](https://docs.github.com/rest/teams/teams#check-team-permissions-for-a-repository)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn check_permissions_for_repo_in_org(&self, org: &str, team_slug: &str, owner: &str, repo: &str) -> Result<TeamRepository, AdapterError> {
let request_uri = format!("{}/orgs/{}/teams/{}/repos/{}/{}", super::GITHUB_BASE_API_URL, org, team_slug, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
204 => Err(TeamsCheckPermissionsForRepoInOrgError::Status204.into()),
404 => Err(TeamsCheckPermissionsForRepoInOrgError::Status404.into()),
code => Err(TeamsCheckPermissionsForRepoInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Check team permissions for a repository (Legacy)
///
/// > [!WARNING]
/// > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [Check team permissions for a repository](https://docs.github.com/rest/teams/teams#check-team-permissions-for-a-repository) endpoint.
///
/// > [!NOTE]
/// > Repositories inherited through a parent team will also be checked.
///
/// You can also get information about the specified repository, including what permissions the team grants on it, by passing the following custom [media type](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types/) via the `Accept` header:
///
/// [GitHub API docs for check_permissions_for_repo_legacy](https://docs.github.com/rest/teams/teams#check-team-permissions-for-a-repository-legacy)
///
/// ---
pub async fn check_permissions_for_repo_legacy_async(&self, team_id: i32, owner: &str, repo: &str) -> Result<TeamRepository, AdapterError> {
let request_uri = format!("{}/teams/{}/repos/{}/{}", super::GITHUB_BASE_API_URL, team_id, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
204 => Err(TeamsCheckPermissionsForRepoLegacyError::Status204.into()),
404 => Err(TeamsCheckPermissionsForRepoLegacyError::Status404.into()),
code => Err(TeamsCheckPermissionsForRepoLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Check team permissions for a repository (Legacy)
///
/// > [!WARNING]
/// > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [Check team permissions for a repository](https://docs.github.com/rest/teams/teams#check-team-permissions-for-a-repository) endpoint.
///
/// > [!NOTE]
/// > Repositories inherited through a parent team will also be checked.
///
/// You can also get information about the specified repository, including what permissions the team grants on it, by passing the following custom [media type](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types/) via the `Accept` header:
///
/// [GitHub API docs for check_permissions_for_repo_legacy](https://docs.github.com/rest/teams/teams#check-team-permissions-for-a-repository-legacy)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn check_permissions_for_repo_legacy(&self, team_id: i32, owner: &str, repo: &str) -> Result<TeamRepository, AdapterError> {
let request_uri = format!("{}/teams/{}/repos/{}/{}", super::GITHUB_BASE_API_URL, team_id, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
204 => Err(TeamsCheckPermissionsForRepoLegacyError::Status204.into()),
404 => Err(TeamsCheckPermissionsForRepoLegacyError::Status404.into()),
code => Err(TeamsCheckPermissionsForRepoLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a team
///
/// To create a team, the authenticated user must be a member or owner of `{org}`. By default, organization members can create teams. Organization owners can limit team creation to organization owners. For more information, see "[Setting team creation permissions](https://docs.github.com/articles/setting-team-creation-permissions-in-your-organization)."
///
/// When you create a new team, you automatically become a team maintainer without explicitly adding yourself to the optional array of `maintainers`. For more information, see "[About teams](https://docs.github.com/github/setting-up-and-managing-organizations-and-teams/about-teams)".
///
/// [GitHub API docs for create](https://docs.github.com/rest/teams/teams#create-a-team)
///
/// ---
pub async fn create_async(&self, org: &str, body: PostTeamsCreate) -> Result<TeamFull, AdapterError> {
let request_uri = format!("{}/orgs/{}/teams", super::GITHUB_BASE_API_URL, org);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostTeamsCreate>(body)?),
method: "POST",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
422 => Err(TeamsCreateError::Status422(github_response.to_json_async().await?).into()),
403 => Err(TeamsCreateError::Status403(github_response.to_json_async().await?).into()),
code => Err(TeamsCreateError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a team
///
/// To create a team, the authenticated user must be a member or owner of `{org}`. By default, organization members can create teams. Organization owners can limit team creation to organization owners. For more information, see "[Setting team creation permissions](https://docs.github.com/articles/setting-team-creation-permissions-in-your-organization)."
///
/// When you create a new team, you automatically become a team maintainer without explicitly adding yourself to the optional array of `maintainers`. For more information, see "[About teams](https://docs.github.com/github/setting-up-and-managing-organizations-and-teams/about-teams)".
///
/// [GitHub API docs for create](https://docs.github.com/rest/teams/teams#create-a-team)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn create(&self, org: &str, body: PostTeamsCreate) -> Result<TeamFull, AdapterError> {
let request_uri = format!("{}/orgs/{}/teams", super::GITHUB_BASE_API_URL, org);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostTeamsCreate>(body)?),
method: "POST",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
422 => Err(TeamsCreateError::Status422(github_response.to_json()?).into()),
403 => Err(TeamsCreateError::Status403(github_response.to_json()?).into()),
code => Err(TeamsCreateError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a discussion comment
///
/// Creates a new comment on a team discussion.
///
/// This endpoint triggers [notifications](https://docs.github.com/github/managing-subscriptions-and-notifications-on-github/about-notifications). Creating content too quickly using this endpoint may result in secondary rate limiting. For more information, see "[Rate limits for the API](https://docs.github.com/rest/using-the-rest-api/rate-limits-for-the-rest-api#about-secondary-rate-limits)" and "[Best practices for using the REST API](https://docs.github.com/rest/guides/best-practices-for-using-the-rest-api)."
///
/// > [!NOTE]
/// > You can also specify a team by `org_id` and `team_id` using the route `POST /organizations/{org_id}/team/{team_id}/discussions/{discussion_number}/comments`.
///
/// OAuth app tokens and personal access tokens (classic) need the `write:discussion` scope to use this endpoint.
///
/// [GitHub API docs for create_discussion_comment_in_org](https://docs.github.com/rest/teams/discussion-comments#create-a-discussion-comment)
///
/// ---
pub async fn create_discussion_comment_in_org_async(&self, org: &str, team_slug: &str, discussion_number: i32, body: PostTeamsCreateDiscussionCommentInOrg) -> Result<TeamDiscussionComment, AdapterError> {
let request_uri = format!("{}/orgs/{}/teams/{}/discussions/{}/comments", super::GITHUB_BASE_API_URL, org, team_slug, discussion_number);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostTeamsCreateDiscussionCommentInOrg>(body)?),
method: "POST",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
code => Err(TeamsCreateDiscussionCommentInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a discussion comment
///
/// Creates a new comment on a team discussion.
///
/// This endpoint triggers [notifications](https://docs.github.com/github/managing-subscriptions-and-notifications-on-github/about-notifications). Creating content too quickly using this endpoint may result in secondary rate limiting. For more information, see "[Rate limits for the API](https://docs.github.com/rest/using-the-rest-api/rate-limits-for-the-rest-api#about-secondary-rate-limits)" and "[Best practices for using the REST API](https://docs.github.com/rest/guides/best-practices-for-using-the-rest-api)."
///
/// > [!NOTE]
/// > You can also specify a team by `org_id` and `team_id` using the route `POST /organizations/{org_id}/team/{team_id}/discussions/{discussion_number}/comments`.
///
/// OAuth app tokens and personal access tokens (classic) need the `write:discussion` scope to use this endpoint.
///
/// [GitHub API docs for create_discussion_comment_in_org](https://docs.github.com/rest/teams/discussion-comments#create-a-discussion-comment)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn create_discussion_comment_in_org(&self, org: &str, team_slug: &str, discussion_number: i32, body: PostTeamsCreateDiscussionCommentInOrg) -> Result<TeamDiscussionComment, AdapterError> {
let request_uri = format!("{}/orgs/{}/teams/{}/discussions/{}/comments", super::GITHUB_BASE_API_URL, org, team_slug, discussion_number);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostTeamsCreateDiscussionCommentInOrg>(body)?),
method: "POST",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
code => Err(TeamsCreateDiscussionCommentInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a discussion comment (Legacy)
///
/// > [!WARNING]
/// > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [Create a discussion comment](https://docs.github.com/rest/teams/discussion-comments#create-a-discussion-comment) endpoint.
///
/// Creates a new comment on a team discussion.
///
/// This endpoint triggers [notifications](https://docs.github.com/github/managing-subscriptions-and-notifications-on-github/about-notifications). Creating content too quickly using this endpoint may result in secondary rate limiting. For more information, see "[Rate limits for the API](https://docs.github.com/rest/using-the-rest-api/rate-limits-for-the-rest-api#about-secondary-rate-limits)" and "[Best practices for using the REST API](https://docs.github.com/rest/guides/best-practices-for-using-the-rest-api)."
///
/// OAuth app tokens and personal access tokens (classic) need the `write:discussion` scope to use this endpoint.
///
/// [GitHub API docs for create_discussion_comment_legacy](https://docs.github.com/rest/teams/discussion-comments#create-a-discussion-comment-legacy)
///
/// ---
pub async fn create_discussion_comment_legacy_async(&self, team_id: i32, discussion_number: i32, body: PostTeamsCreateDiscussionCommentLegacy) -> Result<TeamDiscussionComment, AdapterError> {
let request_uri = format!("{}/teams/{}/discussions/{}/comments", super::GITHUB_BASE_API_URL, team_id, discussion_number);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostTeamsCreateDiscussionCommentLegacy>(body)?),
method: "POST",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
code => Err(TeamsCreateDiscussionCommentLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a discussion comment (Legacy)
///
/// > [!WARNING]
/// > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [Create a discussion comment](https://docs.github.com/rest/teams/discussion-comments#create-a-discussion-comment) endpoint.
///
/// Creates a new comment on a team discussion.
///
/// This endpoint triggers [notifications](https://docs.github.com/github/managing-subscriptions-and-notifications-on-github/about-notifications). Creating content too quickly using this endpoint may result in secondary rate limiting. For more information, see "[Rate limits for the API](https://docs.github.com/rest/using-the-rest-api/rate-limits-for-the-rest-api#about-secondary-rate-limits)" and "[Best practices for using the REST API](https://docs.github.com/rest/guides/best-practices-for-using-the-rest-api)."
///
/// OAuth app tokens and personal access tokens (classic) need the `write:discussion` scope to use this endpoint.
///
/// [GitHub API docs for create_discussion_comment_legacy](https://docs.github.com/rest/teams/discussion-comments#create-a-discussion-comment-legacy)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn create_discussion_comment_legacy(&self, team_id: i32, discussion_number: i32, body: PostTeamsCreateDiscussionCommentLegacy) -> Result<TeamDiscussionComment, AdapterError> {
let request_uri = format!("{}/teams/{}/discussions/{}/comments", super::GITHUB_BASE_API_URL, team_id, discussion_number);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostTeamsCreateDiscussionCommentLegacy>(body)?),
method: "POST",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
code => Err(TeamsCreateDiscussionCommentLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a discussion
///
/// Creates a new discussion post on a team's page.
///
/// This endpoint triggers [notifications](https://docs.github.com/github/managing-subscriptions-and-notifications-on-github/about-notifications). Creating content too quickly using this endpoint may result in secondary rate limiting. For more information, see "[Rate limits for the API](https://docs.github.com/rest/using-the-rest-api/rate-limits-for-the-rest-api#about-secondary-rate-limits)" and "[Best practices for using the REST API](https://docs.github.com/rest/guides/best-practices-for-using-the-rest-api)."
///
/// > [!NOTE]
/// > You can also specify a team by `org_id` and `team_id` using the route `POST /organizations/{org_id}/team/{team_id}/discussions`.
///
/// OAuth app tokens and personal access tokens (classic) need the `write:discussion` scope to use this endpoint.
///
/// [GitHub API docs for create_discussion_in_org](https://docs.github.com/rest/teams/discussions#create-a-discussion)
///
/// ---
pub async fn create_discussion_in_org_async(&self, org: &str, team_slug: &str, body: PostTeamsCreateDiscussionInOrg) -> Result<TeamDiscussion, AdapterError> {
let request_uri = format!("{}/orgs/{}/teams/{}/discussions", super::GITHUB_BASE_API_URL, org, team_slug);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostTeamsCreateDiscussionInOrg>(body)?),
method: "POST",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
code => Err(TeamsCreateDiscussionInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a discussion
///
/// Creates a new discussion post on a team's page.
///
/// This endpoint triggers [notifications](https://docs.github.com/github/managing-subscriptions-and-notifications-on-github/about-notifications). Creating content too quickly using this endpoint may result in secondary rate limiting. For more information, see "[Rate limits for the API](https://docs.github.com/rest/using-the-rest-api/rate-limits-for-the-rest-api#about-secondary-rate-limits)" and "[Best practices for using the REST API](https://docs.github.com/rest/guides/best-practices-for-using-the-rest-api)."
///
/// > [!NOTE]
/// > You can also specify a team by `org_id` and `team_id` using the route `POST /organizations/{org_id}/team/{team_id}/discussions`.
///
/// OAuth app tokens and personal access tokens (classic) need the `write:discussion` scope to use this endpoint.
///
/// [GitHub API docs for create_discussion_in_org](https://docs.github.com/rest/teams/discussions#create-a-discussion)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn create_discussion_in_org(&self, org: &str, team_slug: &str, body: PostTeamsCreateDiscussionInOrg) -> Result<TeamDiscussion, AdapterError> {
let request_uri = format!("{}/orgs/{}/teams/{}/discussions", super::GITHUB_BASE_API_URL, org, team_slug);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostTeamsCreateDiscussionInOrg>(body)?),
method: "POST",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
code => Err(TeamsCreateDiscussionInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a discussion (Legacy)
///
/// > [!WARNING]
/// > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [`Create a discussion`](https://docs.github.com/rest/teams/discussions#create-a-discussion) endpoint.
///
/// Creates a new discussion post on a team's page.
///
/// This endpoint triggers [notifications](https://docs.github.com/github/managing-subscriptions-and-notifications-on-github/about-notifications). Creating content too quickly using this endpoint may result in secondary rate limiting. For more information, see "[Rate limits for the API](https://docs.github.com/rest/using-the-rest-api/rate-limits-for-the-rest-api#about-secondary-rate-limits)" and "[Best practices for using the REST API](https://docs.github.com/rest/guides/best-practices-for-using-the-rest-api)."
///
/// OAuth app tokens and personal access tokens (classic) need the `write:discussion` scope to use this endpoint.
///
/// [GitHub API docs for create_discussion_legacy](https://docs.github.com/rest/teams/discussions#create-a-discussion-legacy)
///
/// ---
pub async fn create_discussion_legacy_async(&self, team_id: i32, body: PostTeamsCreateDiscussionLegacy) -> Result<TeamDiscussion, AdapterError> {
let request_uri = format!("{}/teams/{}/discussions", super::GITHUB_BASE_API_URL, team_id);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostTeamsCreateDiscussionLegacy>(body)?),
method: "POST",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
code => Err(TeamsCreateDiscussionLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a discussion (Legacy)
///
/// > [!WARNING]
/// > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [`Create a discussion`](https://docs.github.com/rest/teams/discussions#create-a-discussion) endpoint.
///
/// Creates a new discussion post on a team's page.
///
/// This endpoint triggers [notifications](https://docs.github.com/github/managing-subscriptions-and-notifications-on-github/about-notifications). Creating content too quickly using this endpoint may result in secondary rate limiting. For more information, see "[Rate limits for the API](https://docs.github.com/rest/using-the-rest-api/rate-limits-for-the-rest-api#about-secondary-rate-limits)" and "[Best practices for using the REST API](https://docs.github.com/rest/guides/best-practices-for-using-the-rest-api)."
///
/// OAuth app tokens and personal access tokens (classic) need the `write:discussion` scope to use this endpoint.
///
/// [GitHub API docs for create_discussion_legacy](https://docs.github.com/rest/teams/discussions#create-a-discussion-legacy)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn create_discussion_legacy(&self, team_id: i32, body: PostTeamsCreateDiscussionLegacy) -> Result<TeamDiscussion, AdapterError> {
let request_uri = format!("{}/teams/{}/discussions", super::GITHUB_BASE_API_URL, team_id);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostTeamsCreateDiscussionLegacy>(body)?),
method: "POST",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
code => Err(TeamsCreateDiscussionLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a discussion comment
///
/// Deletes a comment on a team discussion.
///
/// > [!NOTE]
/// > You can also specify a team by `org_id` and `team_id` using the route `DELETE /organizations/{org_id}/team/{team_id}/discussions/{discussion_number}/comments/{comment_number}`.
///
/// OAuth app tokens and personal access tokens (classic) need the `write:discussion` scope to use this endpoint.
///
/// [GitHub API docs for delete_discussion_comment_in_org](https://docs.github.com/rest/teams/discussion-comments#delete-a-discussion-comment)
///
/// ---
pub async fn delete_discussion_comment_in_org_async(&self, org: &str, team_slug: &str, discussion_number: i32, comment_number: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/teams/{}/discussions/{}/comments/{}", super::GITHUB_BASE_API_URL, org, team_slug, discussion_number, comment_number);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
code => Err(TeamsDeleteDiscussionCommentInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a discussion comment
///
/// Deletes a comment on a team discussion.
///
/// > [!NOTE]
/// > You can also specify a team by `org_id` and `team_id` using the route `DELETE /organizations/{org_id}/team/{team_id}/discussions/{discussion_number}/comments/{comment_number}`.
///
/// OAuth app tokens and personal access tokens (classic) need the `write:discussion` scope to use this endpoint.
///
/// [GitHub API docs for delete_discussion_comment_in_org](https://docs.github.com/rest/teams/discussion-comments#delete-a-discussion-comment)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete_discussion_comment_in_org(&self, org: &str, team_slug: &str, discussion_number: i32, comment_number: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/teams/{}/discussions/{}/comments/{}", super::GITHUB_BASE_API_URL, org, team_slug, discussion_number, comment_number);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
code => Err(TeamsDeleteDiscussionCommentInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a discussion comment (Legacy)
///
/// > [!WARNING]
/// > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [Delete a discussion comment](https://docs.github.com/rest/teams/discussion-comments#delete-a-discussion-comment) endpoint.
///
/// Deletes a comment on a team discussion.
///
/// OAuth app tokens and personal access tokens (classic) need the `write:discussion` scope to use this endpoint.
///
/// [GitHub API docs for delete_discussion_comment_legacy](https://docs.github.com/rest/teams/discussion-comments#delete-a-discussion-comment-legacy)
///
/// ---
pub async fn delete_discussion_comment_legacy_async(&self, team_id: i32, discussion_number: i32, comment_number: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/teams/{}/discussions/{}/comments/{}", super::GITHUB_BASE_API_URL, team_id, discussion_number, comment_number);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
code => Err(TeamsDeleteDiscussionCommentLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a discussion comment (Legacy)
///
/// > [!WARNING]
/// > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [Delete a discussion comment](https://docs.github.com/rest/teams/discussion-comments#delete-a-discussion-comment) endpoint.
///
/// Deletes a comment on a team discussion.
///
/// OAuth app tokens and personal access tokens (classic) need the `write:discussion` scope to use this endpoint.
///
/// [GitHub API docs for delete_discussion_comment_legacy](https://docs.github.com/rest/teams/discussion-comments#delete-a-discussion-comment-legacy)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete_discussion_comment_legacy(&self, team_id: i32, discussion_number: i32, comment_number: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/teams/{}/discussions/{}/comments/{}", super::GITHUB_BASE_API_URL, team_id, discussion_number, comment_number);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
code => Err(TeamsDeleteDiscussionCommentLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a discussion
///
/// Delete a discussion from a team's page.
///
/// > [!NOTE]
/// > You can also specify a team by `org_id` and `team_id` using the route `DELETE /organizations/{org_id}/team/{team_id}/discussions/{discussion_number}`.
///
/// OAuth app tokens and personal access tokens (classic) need the `write:discussion` scope to use this endpoint.
///
/// [GitHub API docs for delete_discussion_in_org](https://docs.github.com/rest/teams/discussions#delete-a-discussion)
///
/// ---
pub async fn delete_discussion_in_org_async(&self, org: &str, team_slug: &str, discussion_number: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/teams/{}/discussions/{}", super::GITHUB_BASE_API_URL, org, team_slug, discussion_number);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
code => Err(TeamsDeleteDiscussionInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a discussion
///
/// Delete a discussion from a team's page.
///
/// > [!NOTE]
/// > You can also specify a team by `org_id` and `team_id` using the route `DELETE /organizations/{org_id}/team/{team_id}/discussions/{discussion_number}`.
///
/// OAuth app tokens and personal access tokens (classic) need the `write:discussion` scope to use this endpoint.
///
/// [GitHub API docs for delete_discussion_in_org](https://docs.github.com/rest/teams/discussions#delete-a-discussion)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete_discussion_in_org(&self, org: &str, team_slug: &str, discussion_number: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/teams/{}/discussions/{}", super::GITHUB_BASE_API_URL, org, team_slug, discussion_number);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
code => Err(TeamsDeleteDiscussionInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a discussion (Legacy)
///
/// > [!WARNING]
/// > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [`Delete a discussion`](https://docs.github.com/rest/teams/discussions#delete-a-discussion) endpoint.
///
/// Delete a discussion from a team's page.
///
/// OAuth app tokens and personal access tokens (classic) need the `write:discussion` scope to use this endpoint.
///
/// [GitHub API docs for delete_discussion_legacy](https://docs.github.com/rest/teams/discussions#delete-a-discussion-legacy)
///
/// ---
pub async fn delete_discussion_legacy_async(&self, team_id: i32, discussion_number: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/teams/{}/discussions/{}", super::GITHUB_BASE_API_URL, team_id, discussion_number);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
code => Err(TeamsDeleteDiscussionLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a discussion (Legacy)
///
/// > [!WARNING]
/// > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [`Delete a discussion`](https://docs.github.com/rest/teams/discussions#delete-a-discussion) endpoint.
///
/// Delete a discussion from a team's page.
///
/// OAuth app tokens and personal access tokens (classic) need the `write:discussion` scope to use this endpoint.
///
/// [GitHub API docs for delete_discussion_legacy](https://docs.github.com/rest/teams/discussions#delete-a-discussion-legacy)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete_discussion_legacy(&self, team_id: i32, discussion_number: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/teams/{}/discussions/{}", super::GITHUB_BASE_API_URL, team_id, discussion_number);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
code => Err(TeamsDeleteDiscussionLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a team
///
/// To delete a team, the authenticated user must be an organization owner or team maintainer.
///
/// If you are an organization owner, deleting a parent team will delete all of its child teams as well.
///
/// > [!NOTE]
/// > You can also specify a team by `org_id` and `team_id` using the route `DELETE /organizations/{org_id}/team/{team_id}`.
///
/// [GitHub API docs for delete_in_org](https://docs.github.com/rest/teams/teams#delete-a-team)
///
/// ---
pub async fn delete_in_org_async(&self, org: &str, team_slug: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/teams/{}", super::GITHUB_BASE_API_URL, org, team_slug);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
code => Err(TeamsDeleteInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a team
///
/// To delete a team, the authenticated user must be an organization owner or team maintainer.
///
/// If you are an organization owner, deleting a parent team will delete all of its child teams as well.
///
/// > [!NOTE]
/// > You can also specify a team by `org_id` and `team_id` using the route `DELETE /organizations/{org_id}/team/{team_id}`.
///
/// [GitHub API docs for delete_in_org](https://docs.github.com/rest/teams/teams#delete-a-team)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete_in_org(&self, org: &str, team_slug: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/teams/{}", super::GITHUB_BASE_API_URL, org, team_slug);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
code => Err(TeamsDeleteInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a team (Legacy)
///
/// > [!WARNING]
/// > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [Delete a team](https://docs.github.com/rest/teams/teams#delete-a-team) endpoint.
///
/// To delete a team, the authenticated user must be an organization owner or team maintainer.
///
/// If you are an organization owner, deleting a parent team will delete all of its child teams as well.
///
/// [GitHub API docs for delete_legacy](https://docs.github.com/rest/teams/teams#delete-a-team-legacy)
///
/// ---
pub async fn delete_legacy_async(&self, team_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/teams/{}", super::GITHUB_BASE_API_URL, team_id);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
404 => Err(TeamsDeleteLegacyError::Status404(github_response.to_json_async().await?).into()),
422 => Err(TeamsDeleteLegacyError::Status422(github_response.to_json_async().await?).into()),
code => Err(TeamsDeleteLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a team (Legacy)
///
/// > [!WARNING]
/// > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [Delete a team](https://docs.github.com/rest/teams/teams#delete-a-team) endpoint.
///
/// To delete a team, the authenticated user must be an organization owner or team maintainer.
///
/// If you are an organization owner, deleting a parent team will delete all of its child teams as well.
///
/// [GitHub API docs for delete_legacy](https://docs.github.com/rest/teams/teams#delete-a-team-legacy)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete_legacy(&self, team_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/teams/{}", super::GITHUB_BASE_API_URL, team_id);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
404 => Err(TeamsDeleteLegacyError::Status404(github_response.to_json()?).into()),
422 => Err(TeamsDeleteLegacyError::Status422(github_response.to_json()?).into()),
code => Err(TeamsDeleteLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a team by name
///
/// Gets a team using the team's `slug`. To create the `slug`, GitHub replaces special characters in the `name` string, changes all words to lowercase, and replaces spaces with a `-` separator. For example, `"My TEam Näme"` would become `my-team-name`.
///
/// > [!NOTE]
/// > You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/{org_id}/team/{team_id}`.
///
/// [GitHub API docs for get_by_name](https://docs.github.com/rest/teams/teams#get-a-team-by-name)
///
/// ---
pub async fn get_by_name_async(&self, org: &str, team_slug: &str) -> Result<TeamFull, AdapterError> {
let request_uri = format!("{}/orgs/{}/teams/{}", super::GITHUB_BASE_API_URL, org, team_slug);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
404 => Err(TeamsGetByNameError::Status404(github_response.to_json_async().await?).into()),
code => Err(TeamsGetByNameError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a team by name
///
/// Gets a team using the team's `slug`. To create the `slug`, GitHub replaces special characters in the `name` string, changes all words to lowercase, and replaces spaces with a `-` separator. For example, `"My TEam Näme"` would become `my-team-name`.
///
/// > [!NOTE]
/// > You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/{org_id}/team/{team_id}`.
///
/// [GitHub API docs for get_by_name](https://docs.github.com/rest/teams/teams#get-a-team-by-name)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_by_name(&self, org: &str, team_slug: &str) -> Result<TeamFull, AdapterError> {
let request_uri = format!("{}/orgs/{}/teams/{}", super::GITHUB_BASE_API_URL, org, team_slug);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
404 => Err(TeamsGetByNameError::Status404(github_response.to_json()?).into()),
code => Err(TeamsGetByNameError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a discussion comment
///
/// Get a specific comment on a team discussion.
///
/// > [!NOTE]
/// > You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/{org_id}/team/{team_id}/discussions/{discussion_number}/comments/{comment_number}`.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:discussion` scope to use this endpoint.
///
/// [GitHub API docs for get_discussion_comment_in_org](https://docs.github.com/rest/teams/discussion-comments#get-a-discussion-comment)
///
/// ---
pub async fn get_discussion_comment_in_org_async(&self, org: &str, team_slug: &str, discussion_number: i32, comment_number: i32) -> Result<TeamDiscussionComment, AdapterError> {
let request_uri = format!("{}/orgs/{}/teams/{}/discussions/{}/comments/{}", super::GITHUB_BASE_API_URL, org, team_slug, discussion_number, comment_number);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
code => Err(TeamsGetDiscussionCommentInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a discussion comment
///
/// Get a specific comment on a team discussion.
///
/// > [!NOTE]
/// > You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/{org_id}/team/{team_id}/discussions/{discussion_number}/comments/{comment_number}`.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:discussion` scope to use this endpoint.
///
/// [GitHub API docs for get_discussion_comment_in_org](https://docs.github.com/rest/teams/discussion-comments#get-a-discussion-comment)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_discussion_comment_in_org(&self, org: &str, team_slug: &str, discussion_number: i32, comment_number: i32) -> Result<TeamDiscussionComment, AdapterError> {
let request_uri = format!("{}/orgs/{}/teams/{}/discussions/{}/comments/{}", super::GITHUB_BASE_API_URL, org, team_slug, discussion_number, comment_number);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
code => Err(TeamsGetDiscussionCommentInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a discussion comment (Legacy)
///
/// > [!WARNING]
/// > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [Get a discussion comment](https://docs.github.com/rest/teams/discussion-comments#get-a-discussion-comment) endpoint.
///
/// Get a specific comment on a team discussion.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:discussion` scope to use this endpoint.
///
/// [GitHub API docs for get_discussion_comment_legacy](https://docs.github.com/rest/teams/discussion-comments#get-a-discussion-comment-legacy)
///
/// ---
pub async fn get_discussion_comment_legacy_async(&self, team_id: i32, discussion_number: i32, comment_number: i32) -> Result<TeamDiscussionComment, AdapterError> {
let request_uri = format!("{}/teams/{}/discussions/{}/comments/{}", super::GITHUB_BASE_API_URL, team_id, discussion_number, comment_number);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
code => Err(TeamsGetDiscussionCommentLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a discussion comment (Legacy)
///
/// > [!WARNING]
/// > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [Get a discussion comment](https://docs.github.com/rest/teams/discussion-comments#get-a-discussion-comment) endpoint.
///
/// Get a specific comment on a team discussion.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:discussion` scope to use this endpoint.
///
/// [GitHub API docs for get_discussion_comment_legacy](https://docs.github.com/rest/teams/discussion-comments#get-a-discussion-comment-legacy)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_discussion_comment_legacy(&self, team_id: i32, discussion_number: i32, comment_number: i32) -> Result<TeamDiscussionComment, AdapterError> {
let request_uri = format!("{}/teams/{}/discussions/{}/comments/{}", super::GITHUB_BASE_API_URL, team_id, discussion_number, comment_number);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
code => Err(TeamsGetDiscussionCommentLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a discussion
///
/// Get a specific discussion on a team's page.
///
/// > [!NOTE]
/// > You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/{org_id}/team/{team_id}/discussions/{discussion_number}`.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:discussion` scope to use this endpoint.
///
/// [GitHub API docs for get_discussion_in_org](https://docs.github.com/rest/teams/discussions#get-a-discussion)
///
/// ---
pub async fn get_discussion_in_org_async(&self, org: &str, team_slug: &str, discussion_number: i32) -> Result<TeamDiscussion, AdapterError> {
let request_uri = format!("{}/orgs/{}/teams/{}/discussions/{}", super::GITHUB_BASE_API_URL, org, team_slug, discussion_number);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
code => Err(TeamsGetDiscussionInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a discussion
///
/// Get a specific discussion on a team's page.
///
/// > [!NOTE]
/// > You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/{org_id}/team/{team_id}/discussions/{discussion_number}`.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:discussion` scope to use this endpoint.
///
/// [GitHub API docs for get_discussion_in_org](https://docs.github.com/rest/teams/discussions#get-a-discussion)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_discussion_in_org(&self, org: &str, team_slug: &str, discussion_number: i32) -> Result<TeamDiscussion, AdapterError> {
let request_uri = format!("{}/orgs/{}/teams/{}/discussions/{}", super::GITHUB_BASE_API_URL, org, team_slug, discussion_number);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
code => Err(TeamsGetDiscussionInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a discussion (Legacy)
///
/// > [!WARNING]
/// > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [Get a discussion](https://docs.github.com/rest/teams/discussions#get-a-discussion) endpoint.
///
/// Get a specific discussion on a team's page.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:discussion` scope to use this endpoint.
///
/// [GitHub API docs for get_discussion_legacy](https://docs.github.com/rest/teams/discussions#get-a-discussion-legacy)
///
/// ---
pub async fn get_discussion_legacy_async(&self, team_id: i32, discussion_number: i32) -> Result<TeamDiscussion, AdapterError> {
let request_uri = format!("{}/teams/{}/discussions/{}", super::GITHUB_BASE_API_URL, team_id, discussion_number);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
code => Err(TeamsGetDiscussionLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a discussion (Legacy)
///
/// > [!WARNING]
/// > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [Get a discussion](https://docs.github.com/rest/teams/discussions#get-a-discussion) endpoint.
///
/// Get a specific discussion on a team's page.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:discussion` scope to use this endpoint.
///
/// [GitHub API docs for get_discussion_legacy](https://docs.github.com/rest/teams/discussions#get-a-discussion-legacy)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_discussion_legacy(&self, team_id: i32, discussion_number: i32) -> Result<TeamDiscussion, AdapterError> {
let request_uri = format!("{}/teams/{}/discussions/{}", super::GITHUB_BASE_API_URL, team_id, discussion_number);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
code => Err(TeamsGetDiscussionLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a team (Legacy)
///
/// > [!WARNING]
/// > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the [Get a team by name](https://docs.github.com/rest/teams/teams#get-a-team-by-name) endpoint.
///
/// [GitHub API docs for get_legacy](https://docs.github.com/rest/teams/teams#get-a-team-legacy)
///
/// ---
pub async fn get_legacy_async(&self, team_id: i32) -> Result<TeamFull, AdapterError> {
let request_uri = format!("{}/teams/{}", super::GITHUB_BASE_API_URL, team_id);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
404 => Err(TeamsGetLegacyError::Status404(github_response.to_json_async().await?).into()),
code => Err(TeamsGetLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a team (Legacy)
///
/// > [!WARNING]
/// > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the [Get a team by name](https://docs.github.com/rest/teams/teams#get-a-team-by-name) endpoint.
///
/// [GitHub API docs for get_legacy](https://docs.github.com/rest/teams/teams#get-a-team-legacy)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_legacy(&self, team_id: i32) -> Result<TeamFull, AdapterError> {
let request_uri = format!("{}/teams/{}", super::GITHUB_BASE_API_URL, team_id);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
404 => Err(TeamsGetLegacyError::Status404(github_response.to_json()?).into()),
code => Err(TeamsGetLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get team member (Legacy)
///
/// The "Get team member" endpoint (described below) is closing down.
///
/// We recommend using the [Get team membership for a user](https://docs.github.com/rest/teams/members#get-team-membership-for-a-user) endpoint instead. It allows you to get both active and pending memberships.
///
/// To list members in a team, the team must be visible to the authenticated user.
///
/// [GitHub API docs for get_member_legacy](https://docs.github.com/rest/teams/members#get-team-member-legacy)
///
/// ---
pub async fn get_member_legacy_async(&self, team_id: i32, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/teams/{}/members/{}", super::GITHUB_BASE_API_URL, team_id, username);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
404 => Err(TeamsGetMemberLegacyError::Status404.into()),
code => Err(TeamsGetMemberLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get team member (Legacy)
///
/// The "Get team member" endpoint (described below) is closing down.
///
/// We recommend using the [Get team membership for a user](https://docs.github.com/rest/teams/members#get-team-membership-for-a-user) endpoint instead. It allows you to get both active and pending memberships.
///
/// To list members in a team, the team must be visible to the authenticated user.
///
/// [GitHub API docs for get_member_legacy](https://docs.github.com/rest/teams/members#get-team-member-legacy)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_member_legacy(&self, team_id: i32, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/teams/{}/members/{}", super::GITHUB_BASE_API_URL, team_id, username);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
404 => Err(TeamsGetMemberLegacyError::Status404.into()),
code => Err(TeamsGetMemberLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get team membership for a user
///
/// Team members will include the members of child teams.
///
/// To get a user's membership with a team, the team must be visible to the authenticated user.
///
/// > [!NOTE]
/// > You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/{org_id}/team/{team_id}/memberships/{username}`.
///
/// > [!NOTE]
/// > The response contains the `state` of the membership and the member's `role`.
///
/// The `role` for organization owners is set to `maintainer`. For more information about `maintainer` roles, see [Create a team](https://docs.github.com/rest/teams/teams#create-a-team).
///
/// [GitHub API docs for get_membership_for_user_in_org](https://docs.github.com/rest/teams/members#get-team-membership-for-a-user)
///
/// ---
pub async fn get_membership_for_user_in_org_async(&self, org: &str, team_slug: &str, username: &str) -> Result<TeamMembership, AdapterError> {
let request_uri = format!("{}/orgs/{}/teams/{}/memberships/{}", super::GITHUB_BASE_API_URL, org, team_slug, username);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
404 => Err(TeamsGetMembershipForUserInOrgError::Status404.into()),
code => Err(TeamsGetMembershipForUserInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get team membership for a user
///
/// Team members will include the members of child teams.
///
/// To get a user's membership with a team, the team must be visible to the authenticated user.
///
/// > [!NOTE]
/// > You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/{org_id}/team/{team_id}/memberships/{username}`.
///
/// > [!NOTE]
/// > The response contains the `state` of the membership and the member's `role`.
///
/// The `role` for organization owners is set to `maintainer`. For more information about `maintainer` roles, see [Create a team](https://docs.github.com/rest/teams/teams#create-a-team).
///
/// [GitHub API docs for get_membership_for_user_in_org](https://docs.github.com/rest/teams/members#get-team-membership-for-a-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_membership_for_user_in_org(&self, org: &str, team_slug: &str, username: &str) -> Result<TeamMembership, AdapterError> {
let request_uri = format!("{}/orgs/{}/teams/{}/memberships/{}", super::GITHUB_BASE_API_URL, org, team_slug, username);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
404 => Err(TeamsGetMembershipForUserInOrgError::Status404.into()),
code => Err(TeamsGetMembershipForUserInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get team membership for a user (Legacy)
///
/// > [!WARNING]
/// > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [Get team membership for a user](https://docs.github.com/rest/teams/members#get-team-membership-for-a-user) endpoint.
///
/// Team members will include the members of child teams.
///
/// To get a user's membership with a team, the team must be visible to the authenticated user.
///
/// **Note:**
/// The response contains the `state` of the membership and the member's `role`.
///
/// The `role` for organization owners is set to `maintainer`. For more information about `maintainer` roles, see [Create a team](https://docs.github.com/rest/teams/teams#create-a-team).
///
/// [GitHub API docs for get_membership_for_user_legacy](https://docs.github.com/rest/teams/members#get-team-membership-for-a-user-legacy)
///
/// ---
pub async fn get_membership_for_user_legacy_async(&self, team_id: i32, username: &str) -> Result<TeamMembership, AdapterError> {
let request_uri = format!("{}/teams/{}/memberships/{}", super::GITHUB_BASE_API_URL, team_id, username);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
404 => Err(TeamsGetMembershipForUserLegacyError::Status404(github_response.to_json_async().await?).into()),
code => Err(TeamsGetMembershipForUserLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get team membership for a user (Legacy)
///
/// > [!WARNING]
/// > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [Get team membership for a user](https://docs.github.com/rest/teams/members#get-team-membership-for-a-user) endpoint.
///
/// Team members will include the members of child teams.
///
/// To get a user's membership with a team, the team must be visible to the authenticated user.
///
/// **Note:**
/// The response contains the `state` of the membership and the member's `role`.
///
/// The `role` for organization owners is set to `maintainer`. For more information about `maintainer` roles, see [Create a team](https://docs.github.com/rest/teams/teams#create-a-team).
///
/// [GitHub API docs for get_membership_for_user_legacy](https://docs.github.com/rest/teams/members#get-team-membership-for-a-user-legacy)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_membership_for_user_legacy(&self, team_id: i32, username: &str) -> Result<TeamMembership, AdapterError> {
let request_uri = format!("{}/teams/{}/memberships/{}", super::GITHUB_BASE_API_URL, team_id, username);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
404 => Err(TeamsGetMembershipForUserLegacyError::Status404(github_response.to_json()?).into()),
code => Err(TeamsGetMembershipForUserLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List teams
///
/// Lists all teams in an organization that are visible to the authenticated user.
///
/// [GitHub API docs for list](https://docs.github.com/rest/teams/teams#list-teams)
///
/// ---
pub async fn list_async(&self, org: &str, query_params: Option<impl Into<TeamsListParams>>) -> Result<Vec<Team>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/teams", super::GITHUB_BASE_API_URL, org);
if let Some(params) = query_params {
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(params.into())?);
}
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
403 => Err(TeamsListError::Status403(github_response.to_json_async().await?).into()),
code => Err(TeamsListError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List teams
///
/// Lists all teams in an organization that are visible to the authenticated user.
///
/// [GitHub API docs for list](https://docs.github.com/rest/teams/teams#list-teams)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list(&self, org: &str, query_params: Option<impl Into<TeamsListParams>>) -> Result<Vec<Team>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/teams", super::GITHUB_BASE_API_URL, org);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: TeamsListParams = params.into();
request_uri.push_str(&serde_urlencoded::to_string(qp)?);
}
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
403 => Err(TeamsListError::Status403(github_response.to_json()?).into()),
code => Err(TeamsListError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List child teams
///
/// Lists the child teams of the team specified by `{team_slug}`.
///
/// > [!NOTE]
/// > You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/{org_id}/team/{team_id}/teams`.
///
/// [GitHub API docs for list_child_in_org](https://docs.github.com/rest/teams/teams#list-child-teams)
///
/// ---
pub async fn list_child_in_org_async(&self, org: &str, team_slug: &str, query_params: Option<impl Into<TeamsListChildInOrgParams>>) -> Result<Vec<Team>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/teams/{}/teams", super::GITHUB_BASE_API_URL, org, team_slug);
if let Some(params) = query_params {
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(params.into())?);
}
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
code => Err(TeamsListChildInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List child teams
///
/// Lists the child teams of the team specified by `{team_slug}`.
///
/// > [!NOTE]
/// > You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/{org_id}/team/{team_id}/teams`.
///
/// [GitHub API docs for list_child_in_org](https://docs.github.com/rest/teams/teams#list-child-teams)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_child_in_org(&self, org: &str, team_slug: &str, query_params: Option<impl Into<TeamsListChildInOrgParams>>) -> Result<Vec<Team>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/teams/{}/teams", super::GITHUB_BASE_API_URL, org, team_slug);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: TeamsListChildInOrgParams = params.into();
request_uri.push_str(&serde_urlencoded::to_string(qp)?);
}
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
code => Err(TeamsListChildInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List child teams (Legacy)
///
/// > [!WARNING]
/// > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [`List child teams`](https://docs.github.com/rest/teams/teams#list-child-teams) endpoint.
///
/// [GitHub API docs for list_child_legacy](https://docs.github.com/rest/teams/teams#list-child-teams-legacy)
///
/// ---
pub async fn list_child_legacy_async(&self, team_id: i32, query_params: Option<impl Into<TeamsListChildLegacyParams>>) -> Result<Vec<Team>, AdapterError> {
let mut request_uri = format!("{}/teams/{}/teams", super::GITHUB_BASE_API_URL, team_id);
if let Some(params) = query_params {
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(params.into())?);
}
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
404 => Err(TeamsListChildLegacyError::Status404(github_response.to_json_async().await?).into()),
403 => Err(TeamsListChildLegacyError::Status403(github_response.to_json_async().await?).into()),
422 => Err(TeamsListChildLegacyError::Status422(github_response.to_json_async().await?).into()),
code => Err(TeamsListChildLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List child teams (Legacy)
///
/// > [!WARNING]
/// > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [`List child teams`](https://docs.github.com/rest/teams/teams#list-child-teams) endpoint.
///
/// [GitHub API docs for list_child_legacy](https://docs.github.com/rest/teams/teams#list-child-teams-legacy)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_child_legacy(&self, team_id: i32, query_params: Option<impl Into<TeamsListChildLegacyParams>>) -> Result<Vec<Team>, AdapterError> {
let mut request_uri = format!("{}/teams/{}/teams", super::GITHUB_BASE_API_URL, team_id);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: TeamsListChildLegacyParams = params.into();
request_uri.push_str(&serde_urlencoded::to_string(qp)?);
}
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
404 => Err(TeamsListChildLegacyError::Status404(github_response.to_json()?).into()),
403 => Err(TeamsListChildLegacyError::Status403(github_response.to_json()?).into()),
422 => Err(TeamsListChildLegacyError::Status422(github_response.to_json()?).into()),
code => Err(TeamsListChildLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List discussion comments
///
/// List all comments on a team discussion.
///
/// > [!NOTE]
/// > You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/{org_id}/team/{team_id}/discussions/{discussion_number}/comments`.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:discussion` scope to use this endpoint.
///
/// [GitHub API docs for list_discussion_comments_in_org](https://docs.github.com/rest/teams/discussion-comments#list-discussion-comments)
///
/// ---
pub async fn list_discussion_comments_in_org_async(&self, org: &str, team_slug: &str, discussion_number: i32, query_params: Option<impl Into<TeamsListDiscussionCommentsInOrgParams<'api>>>) -> Result<Vec<TeamDiscussionComment>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/teams/{}/discussions/{}/comments", super::GITHUB_BASE_API_URL, org, team_slug, discussion_number);
if let Some(params) = query_params {
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(params.into())?);
}
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
code => Err(TeamsListDiscussionCommentsInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List discussion comments
///
/// List all comments on a team discussion.
///
/// > [!NOTE]
/// > You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/{org_id}/team/{team_id}/discussions/{discussion_number}/comments`.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:discussion` scope to use this endpoint.
///
/// [GitHub API docs for list_discussion_comments_in_org](https://docs.github.com/rest/teams/discussion-comments#list-discussion-comments)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_discussion_comments_in_org(&self, org: &str, team_slug: &str, discussion_number: i32, query_params: Option<impl Into<TeamsListDiscussionCommentsInOrgParams<'api>>>) -> Result<Vec<TeamDiscussionComment>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/teams/{}/discussions/{}/comments", super::GITHUB_BASE_API_URL, org, team_slug, discussion_number);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: TeamsListDiscussionCommentsInOrgParams = params.into();
request_uri.push_str(&serde_urlencoded::to_string(qp)?);
}
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
code => Err(TeamsListDiscussionCommentsInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List discussion comments (Legacy)
///
/// > [!WARNING]
/// > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [List discussion comments](https://docs.github.com/rest/teams/discussion-comments#list-discussion-comments) endpoint.
///
/// List all comments on a team discussion.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:discussion` scope to use this endpoint.
///
/// [GitHub API docs for list_discussion_comments_legacy](https://docs.github.com/rest/teams/discussion-comments#list-discussion-comments-legacy)
///
/// ---
pub async fn list_discussion_comments_legacy_async(&self, team_id: i32, discussion_number: i32, query_params: Option<impl Into<TeamsListDiscussionCommentsLegacyParams<'api>>>) -> Result<Vec<TeamDiscussionComment>, AdapterError> {
let mut request_uri = format!("{}/teams/{}/discussions/{}/comments", super::GITHUB_BASE_API_URL, team_id, discussion_number);
if let Some(params) = query_params {
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(params.into())?);
}
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
code => Err(TeamsListDiscussionCommentsLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List discussion comments (Legacy)
///
/// > [!WARNING]
/// > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [List discussion comments](https://docs.github.com/rest/teams/discussion-comments#list-discussion-comments) endpoint.
///
/// List all comments on a team discussion.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:discussion` scope to use this endpoint.
///
/// [GitHub API docs for list_discussion_comments_legacy](https://docs.github.com/rest/teams/discussion-comments#list-discussion-comments-legacy)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_discussion_comments_legacy(&self, team_id: i32, discussion_number: i32, query_params: Option<impl Into<TeamsListDiscussionCommentsLegacyParams<'api>>>) -> Result<Vec<TeamDiscussionComment>, AdapterError> {
let mut request_uri = format!("{}/teams/{}/discussions/{}/comments", super::GITHUB_BASE_API_URL, team_id, discussion_number);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: TeamsListDiscussionCommentsLegacyParams = params.into();
request_uri.push_str(&serde_urlencoded::to_string(qp)?);
}
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
code => Err(TeamsListDiscussionCommentsLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List discussions
///
/// List all discussions on a team's page.
///
/// > [!NOTE]
/// > You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/{org_id}/team/{team_id}/discussions`.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:discussion` scope to use this endpoint.
///
/// [GitHub API docs for list_discussions_in_org](https://docs.github.com/rest/teams/discussions#list-discussions)
///
/// ---
pub async fn list_discussions_in_org_async(&self, org: &str, team_slug: &str, query_params: Option<impl Into<TeamsListDiscussionsInOrgParams<'api>>>) -> Result<Vec<TeamDiscussion>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/teams/{}/discussions", super::GITHUB_BASE_API_URL, org, team_slug);
if let Some(params) = query_params {
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(params.into())?);
}
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
code => Err(TeamsListDiscussionsInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List discussions
///
/// List all discussions on a team's page.
///
/// > [!NOTE]
/// > You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/{org_id}/team/{team_id}/discussions`.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:discussion` scope to use this endpoint.
///
/// [GitHub API docs for list_discussions_in_org](https://docs.github.com/rest/teams/discussions#list-discussions)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_discussions_in_org(&self, org: &str, team_slug: &str, query_params: Option<impl Into<TeamsListDiscussionsInOrgParams<'api>>>) -> Result<Vec<TeamDiscussion>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/teams/{}/discussions", super::GITHUB_BASE_API_URL, org, team_slug);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: TeamsListDiscussionsInOrgParams = params.into();
request_uri.push_str(&serde_urlencoded::to_string(qp)?);
}
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
code => Err(TeamsListDiscussionsInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List discussions (Legacy)
///
/// > [!WARNING]
/// > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [`List discussions`](https://docs.github.com/rest/teams/discussions#list-discussions) endpoint.
///
/// List all discussions on a team's page.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:discussion` scope to use this endpoint.
///
/// [GitHub API docs for list_discussions_legacy](https://docs.github.com/rest/teams/discussions#list-discussions-legacy)
///
/// ---
pub async fn list_discussions_legacy_async(&self, team_id: i32, query_params: Option<impl Into<TeamsListDiscussionsLegacyParams<'api>>>) -> Result<Vec<TeamDiscussion>, AdapterError> {
let mut request_uri = format!("{}/teams/{}/discussions", super::GITHUB_BASE_API_URL, team_id);
if let Some(params) = query_params {
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(params.into())?);
}
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
code => Err(TeamsListDiscussionsLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List discussions (Legacy)
///
/// > [!WARNING]
/// > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [`List discussions`](https://docs.github.com/rest/teams/discussions#list-discussions) endpoint.
///
/// List all discussions on a team's page.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:discussion` scope to use this endpoint.
///
/// [GitHub API docs for list_discussions_legacy](https://docs.github.com/rest/teams/discussions#list-discussions-legacy)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_discussions_legacy(&self, team_id: i32, query_params: Option<impl Into<TeamsListDiscussionsLegacyParams<'api>>>) -> Result<Vec<TeamDiscussion>, AdapterError> {
let mut request_uri = format!("{}/teams/{}/discussions", super::GITHUB_BASE_API_URL, team_id);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: TeamsListDiscussionsLegacyParams = params.into();
request_uri.push_str(&serde_urlencoded::to_string(qp)?);
}
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
code => Err(TeamsListDiscussionsLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List teams for the authenticated user
///
/// List all of the teams across all of the organizations to which the authenticated
/// user belongs.
///
/// OAuth app tokens and personal access tokens (classic) need the `user`, `repo`, or `read:org` scope to use this endpoint.
///
/// When using a fine-grained personal access token, the resource owner of the token must be a single organization, and the response will only include the teams from that organization.
///
/// [GitHub API docs for list_for_authenticated_user](https://docs.github.com/rest/teams/teams#list-teams-for-the-authenticated-user)
///
/// ---
pub async fn list_for_authenticated_user_async(&self, query_params: Option<impl Into<TeamsListForAuthenticatedUserParams>>) -> Result<Vec<TeamFull>, AdapterError> {
let mut request_uri = format!("{}/user/teams", super::GITHUB_BASE_API_URL);
if let Some(params) = query_params {
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(params.into())?);
}
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
304 => Err(TeamsListForAuthenticatedUserError::Status304.into()),
404 => Err(TeamsListForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()),
403 => Err(TeamsListForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()),
code => Err(TeamsListForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List teams for the authenticated user
///
/// List all of the teams across all of the organizations to which the authenticated
/// user belongs.
///
/// OAuth app tokens and personal access tokens (classic) need the `user`, `repo`, or `read:org` scope to use this endpoint.
///
/// When using a fine-grained personal access token, the resource owner of the token must be a single organization, and the response will only include the teams from that organization.
///
/// [GitHub API docs for list_for_authenticated_user](https://docs.github.com/rest/teams/teams#list-teams-for-the-authenticated-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_for_authenticated_user(&self, query_params: Option<impl Into<TeamsListForAuthenticatedUserParams>>) -> Result<Vec<TeamFull>, AdapterError> {
let mut request_uri = format!("{}/user/teams", super::GITHUB_BASE_API_URL);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: TeamsListForAuthenticatedUserParams = params.into();
request_uri.push_str(&serde_urlencoded::to_string(qp)?);
}
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
304 => Err(TeamsListForAuthenticatedUserError::Status304.into()),
404 => Err(TeamsListForAuthenticatedUserError::Status404(github_response.to_json()?).into()),
403 => Err(TeamsListForAuthenticatedUserError::Status403(github_response.to_json()?).into()),
code => Err(TeamsListForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List team members
///
/// Team members will include the members of child teams.
///
/// To list members in a team, the team must be visible to the authenticated user.
///
/// [GitHub API docs for list_members_in_org](https://docs.github.com/rest/teams/members#list-team-members)
///
/// ---
pub async fn list_members_in_org_async(&self, org: &str, team_slug: &str, query_params: Option<impl Into<TeamsListMembersInOrgParams<'api>>>) -> Result<Vec<SimpleUser>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/teams/{}/members", super::GITHUB_BASE_API_URL, org, team_slug);
if let Some(params) = query_params {
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(params.into())?);
}
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
code => Err(TeamsListMembersInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List team members
///
/// Team members will include the members of child teams.
///
/// To list members in a team, the team must be visible to the authenticated user.
///
/// [GitHub API docs for list_members_in_org](https://docs.github.com/rest/teams/members#list-team-members)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_members_in_org(&self, org: &str, team_slug: &str, query_params: Option<impl Into<TeamsListMembersInOrgParams<'api>>>) -> Result<Vec<SimpleUser>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/teams/{}/members", super::GITHUB_BASE_API_URL, org, team_slug);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: TeamsListMembersInOrgParams = params.into();
request_uri.push_str(&serde_urlencoded::to_string(qp)?);
}
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
code => Err(TeamsListMembersInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List team members (Legacy)
///
/// > [!WARNING]
/// > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [`List team members`](https://docs.github.com/rest/teams/members#list-team-members) endpoint.
///
/// Team members will include the members of child teams.
///
/// [GitHub API docs for list_members_legacy](https://docs.github.com/rest/teams/members#list-team-members-legacy)
///
/// ---
pub async fn list_members_legacy_async(&self, team_id: i32, query_params: Option<impl Into<TeamsListMembersLegacyParams<'api>>>) -> Result<Vec<SimpleUser>, AdapterError> {
let mut request_uri = format!("{}/teams/{}/members", super::GITHUB_BASE_API_URL, team_id);
if let Some(params) = query_params {
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(params.into())?);
}
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
404 => Err(TeamsListMembersLegacyError::Status404(github_response.to_json_async().await?).into()),
code => Err(TeamsListMembersLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List team members (Legacy)
///
/// > [!WARNING]
/// > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [`List team members`](https://docs.github.com/rest/teams/members#list-team-members) endpoint.
///
/// Team members will include the members of child teams.
///
/// [GitHub API docs for list_members_legacy](https://docs.github.com/rest/teams/members#list-team-members-legacy)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_members_legacy(&self, team_id: i32, query_params: Option<impl Into<TeamsListMembersLegacyParams<'api>>>) -> Result<Vec<SimpleUser>, AdapterError> {
let mut request_uri = format!("{}/teams/{}/members", super::GITHUB_BASE_API_URL, team_id);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: TeamsListMembersLegacyParams = params.into();
request_uri.push_str(&serde_urlencoded::to_string(qp)?);
}
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
404 => Err(TeamsListMembersLegacyError::Status404(github_response.to_json()?).into()),
code => Err(TeamsListMembersLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List pending team invitations
///
/// The return hash contains a `role` field which refers to the Organization Invitation role and will be one of the following values: `direct_member`, `admin`, `billing_manager`, `hiring_manager`, or `reinstate`. If the invitee is not a GitHub member, the `login` field in the return hash will be `null`.
///
/// > [!NOTE]
/// > You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/{org_id}/team/{team_id}/invitations`.
///
/// [GitHub API docs for list_pending_invitations_in_org](https://docs.github.com/rest/teams/members#list-pending-team-invitations)
///
/// ---
pub async fn list_pending_invitations_in_org_async(&self, org: &str, team_slug: &str, query_params: Option<impl Into<TeamsListPendingInvitationsInOrgParams>>) -> Result<Vec<OrganizationInvitation>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/teams/{}/invitations", super::GITHUB_BASE_API_URL, org, team_slug);
if let Some(params) = query_params {
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(params.into())?);
}
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
code => Err(TeamsListPendingInvitationsInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List pending team invitations
///
/// The return hash contains a `role` field which refers to the Organization Invitation role and will be one of the following values: `direct_member`, `admin`, `billing_manager`, `hiring_manager`, or `reinstate`. If the invitee is not a GitHub member, the `login` field in the return hash will be `null`.
///
/// > [!NOTE]
/// > You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/{org_id}/team/{team_id}/invitations`.
///
/// [GitHub API docs for list_pending_invitations_in_org](https://docs.github.com/rest/teams/members#list-pending-team-invitations)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_pending_invitations_in_org(&self, org: &str, team_slug: &str, query_params: Option<impl Into<TeamsListPendingInvitationsInOrgParams>>) -> Result<Vec<OrganizationInvitation>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/teams/{}/invitations", super::GITHUB_BASE_API_URL, org, team_slug);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: TeamsListPendingInvitationsInOrgParams = params.into();
request_uri.push_str(&serde_urlencoded::to_string(qp)?);
}
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
code => Err(TeamsListPendingInvitationsInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List pending team invitations (Legacy)
///
/// > [!WARNING]
/// > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [`List pending team invitations`](https://docs.github.com/rest/teams/members#list-pending-team-invitations) endpoint.
///
/// The return hash contains a `role` field which refers to the Organization Invitation role and will be one of the following values: `direct_member`, `admin`, `billing_manager`, `hiring_manager`, or `reinstate`. If the invitee is not a GitHub member, the `login` field in the return hash will be `null`.
///
/// [GitHub API docs for list_pending_invitations_legacy](https://docs.github.com/rest/teams/members#list-pending-team-invitations-legacy)
///
/// ---
pub async fn list_pending_invitations_legacy_async(&self, team_id: i32, query_params: Option<impl Into<TeamsListPendingInvitationsLegacyParams>>) -> Result<Vec<OrganizationInvitation>, AdapterError> {
let mut request_uri = format!("{}/teams/{}/invitations", super::GITHUB_BASE_API_URL, team_id);
if let Some(params) = query_params {
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(params.into())?);
}
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
code => Err(TeamsListPendingInvitationsLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List pending team invitations (Legacy)
///
/// > [!WARNING]
/// > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [`List pending team invitations`](https://docs.github.com/rest/teams/members#list-pending-team-invitations) endpoint.
///
/// The return hash contains a `role` field which refers to the Organization Invitation role and will be one of the following values: `direct_member`, `admin`, `billing_manager`, `hiring_manager`, or `reinstate`. If the invitee is not a GitHub member, the `login` field in the return hash will be `null`.
///
/// [GitHub API docs for list_pending_invitations_legacy](https://docs.github.com/rest/teams/members#list-pending-team-invitations-legacy)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_pending_invitations_legacy(&self, team_id: i32, query_params: Option<impl Into<TeamsListPendingInvitationsLegacyParams>>) -> Result<Vec<OrganizationInvitation>, AdapterError> {
let mut request_uri = format!("{}/teams/{}/invitations", super::GITHUB_BASE_API_URL, team_id);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: TeamsListPendingInvitationsLegacyParams = params.into();
request_uri.push_str(&serde_urlencoded::to_string(qp)?);
}
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
code => Err(TeamsListPendingInvitationsLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List team projects
///
/// > [!WARNING]
/// > **Closing down notice:** Projects (classic) is being deprecated in favor of the new Projects experience.
/// > See the [changelog](https://github.blog/changelog/2024-05-23-sunset-notice-projects-classic/) for more information.
///
/// [GitHub API docs for list_projects_in_org](https://docs.github.com/rest/teams/teams#list-team-projects)
///
/// ---
pub async fn list_projects_in_org_async(&self, org: &str, team_slug: &str, query_params: Option<impl Into<TeamsListProjectsInOrgParams>>) -> Result<Vec<TeamProject>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/teams/{}/projects", super::GITHUB_BASE_API_URL, org, team_slug);
if let Some(params) = query_params {
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(params.into())?);
}
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
code => Err(TeamsListProjectsInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List team projects
///
/// > [!WARNING]
/// > **Closing down notice:** Projects (classic) is being deprecated in favor of the new Projects experience.
/// > See the [changelog](https://github.blog/changelog/2024-05-23-sunset-notice-projects-classic/) for more information.
///
/// [GitHub API docs for list_projects_in_org](https://docs.github.com/rest/teams/teams#list-team-projects)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_projects_in_org(&self, org: &str, team_slug: &str, query_params: Option<impl Into<TeamsListProjectsInOrgParams>>) -> Result<Vec<TeamProject>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/teams/{}/projects", super::GITHUB_BASE_API_URL, org, team_slug);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: TeamsListProjectsInOrgParams = params.into();
request_uri.push_str(&serde_urlencoded::to_string(qp)?);
}
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
code => Err(TeamsListProjectsInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List team projects (Legacy)
///
/// > [!WARNING]
/// > **Closing down notice:** Projects (classic) is being deprecated in favor of the new Projects experience.
/// > See the [changelog](https://github.blog/changelog/2024-05-23-sunset-notice-projects-classic/) for more information.
///
/// [GitHub API docs for list_projects_legacy](https://docs.github.com/rest/teams/teams#list-team-projects-legacy)
///
/// ---
pub async fn list_projects_legacy_async(&self, team_id: i32, query_params: Option<impl Into<TeamsListProjectsLegacyParams>>) -> Result<Vec<TeamProject>, AdapterError> {
let mut request_uri = format!("{}/teams/{}/projects", super::GITHUB_BASE_API_URL, team_id);
if let Some(params) = query_params {
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(params.into())?);
}
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
404 => Err(TeamsListProjectsLegacyError::Status404(github_response.to_json_async().await?).into()),
code => Err(TeamsListProjectsLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List team projects (Legacy)
///
/// > [!WARNING]
/// > **Closing down notice:** Projects (classic) is being deprecated in favor of the new Projects experience.
/// > See the [changelog](https://github.blog/changelog/2024-05-23-sunset-notice-projects-classic/) for more information.
///
/// [GitHub API docs for list_projects_legacy](https://docs.github.com/rest/teams/teams#list-team-projects-legacy)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_projects_legacy(&self, team_id: i32, query_params: Option<impl Into<TeamsListProjectsLegacyParams>>) -> Result<Vec<TeamProject>, AdapterError> {
let mut request_uri = format!("{}/teams/{}/projects", super::GITHUB_BASE_API_URL, team_id);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: TeamsListProjectsLegacyParams = params.into();
request_uri.push_str(&serde_urlencoded::to_string(qp)?);
}
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
404 => Err(TeamsListProjectsLegacyError::Status404(github_response.to_json()?).into()),
code => Err(TeamsListProjectsLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List team repositories
///
/// Lists a team's repositories visible to the authenticated user.
///
/// > [!NOTE]
/// > You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/{org_id}/team/{team_id}/repos`.
///
/// [GitHub API docs for list_repos_in_org](https://docs.github.com/rest/teams/teams#list-team-repositories)
///
/// ---
pub async fn list_repos_in_org_async(&self, org: &str, team_slug: &str, query_params: Option<impl Into<TeamsListReposInOrgParams>>) -> Result<Vec<MinimalRepository>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/teams/{}/repos", super::GITHUB_BASE_API_URL, org, team_slug);
if let Some(params) = query_params {
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(params.into())?);
}
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
code => Err(TeamsListReposInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List team repositories
///
/// Lists a team's repositories visible to the authenticated user.
///
/// > [!NOTE]
/// > You can also specify a team by `org_id` and `team_id` using the route `GET /organizations/{org_id}/team/{team_id}/repos`.
///
/// [GitHub API docs for list_repos_in_org](https://docs.github.com/rest/teams/teams#list-team-repositories)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_repos_in_org(&self, org: &str, team_slug: &str, query_params: Option<impl Into<TeamsListReposInOrgParams>>) -> Result<Vec<MinimalRepository>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/teams/{}/repos", super::GITHUB_BASE_API_URL, org, team_slug);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: TeamsListReposInOrgParams = params.into();
request_uri.push_str(&serde_urlencoded::to_string(qp)?);
}
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
code => Err(TeamsListReposInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List team repositories (Legacy)
///
/// > [!WARNING]
/// > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [List team repositories](https://docs.github.com/rest/teams/teams#list-team-repositories) endpoint.
///
/// [GitHub API docs for list_repos_legacy](https://docs.github.com/rest/teams/teams#list-team-repositories-legacy)
///
/// ---
pub async fn list_repos_legacy_async(&self, team_id: i32, query_params: Option<impl Into<TeamsListReposLegacyParams>>) -> Result<Vec<MinimalRepository>, AdapterError> {
let mut request_uri = format!("{}/teams/{}/repos", super::GITHUB_BASE_API_URL, team_id);
if let Some(params) = query_params {
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(params.into())?);
}
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
404 => Err(TeamsListReposLegacyError::Status404(github_response.to_json_async().await?).into()),
code => Err(TeamsListReposLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List team repositories (Legacy)
///
/// > [!WARNING]
/// > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [List team repositories](https://docs.github.com/rest/teams/teams#list-team-repositories) endpoint.
///
/// [GitHub API docs for list_repos_legacy](https://docs.github.com/rest/teams/teams#list-team-repositories-legacy)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_repos_legacy(&self, team_id: i32, query_params: Option<impl Into<TeamsListReposLegacyParams>>) -> Result<Vec<MinimalRepository>, AdapterError> {
let mut request_uri = format!("{}/teams/{}/repos", super::GITHUB_BASE_API_URL, team_id);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: TeamsListReposLegacyParams = params.into();
request_uri.push_str(&serde_urlencoded::to_string(qp)?);
}
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
404 => Err(TeamsListReposLegacyError::Status404(github_response.to_json()?).into()),
code => Err(TeamsListReposLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Remove team member (Legacy)
///
/// The "Remove team member" endpoint (described below) is closing down.
///
/// We recommend using the [Remove team membership for a user](https://docs.github.com/rest/teams/members#remove-team-membership-for-a-user) endpoint instead. It allows you to remove both active and pending memberships.
///
/// Team synchronization is available for organizations using GitHub Enterprise Cloud. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// To remove a team member, the authenticated user must have 'admin' permissions to the team or be an owner of the org that the team is associated with. Removing a team member does not delete the user, it just removes them from the team.
///
/// > [!NOTE]
/// > When you have team synchronization set up for a team with your organization's identity provider (IdP), you will see an error if you attempt to use the API for making changes to the team's membership. If you have access to manage group membership in your IdP, you can manage GitHub team membership through your identity provider, which automatically adds and removes team members in an organization. For more information, see "[Synchronizing teams between your identity provider and GitHub](https://docs.github.com/articles/synchronizing-teams-between-your-identity-provider-and-github/)."
///
/// [GitHub API docs for remove_member_legacy](https://docs.github.com/rest/teams/members#remove-team-member-legacy)
///
/// ---
pub async fn remove_member_legacy_async(&self, team_id: i32, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/teams/{}/members/{}", super::GITHUB_BASE_API_URL, team_id, username);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
404 => Err(TeamsRemoveMemberLegacyError::Status404.into()),
code => Err(TeamsRemoveMemberLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Remove team member (Legacy)
///
/// The "Remove team member" endpoint (described below) is closing down.
///
/// We recommend using the [Remove team membership for a user](https://docs.github.com/rest/teams/members#remove-team-membership-for-a-user) endpoint instead. It allows you to remove both active and pending memberships.
///
/// Team synchronization is available for organizations using GitHub Enterprise Cloud. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// To remove a team member, the authenticated user must have 'admin' permissions to the team or be an owner of the org that the team is associated with. Removing a team member does not delete the user, it just removes them from the team.
///
/// > [!NOTE]
/// > When you have team synchronization set up for a team with your organization's identity provider (IdP), you will see an error if you attempt to use the API for making changes to the team's membership. If you have access to manage group membership in your IdP, you can manage GitHub team membership through your identity provider, which automatically adds and removes team members in an organization. For more information, see "[Synchronizing teams between your identity provider and GitHub](https://docs.github.com/articles/synchronizing-teams-between-your-identity-provider-and-github/)."
///
/// [GitHub API docs for remove_member_legacy](https://docs.github.com/rest/teams/members#remove-team-member-legacy)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn remove_member_legacy(&self, team_id: i32, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/teams/{}/members/{}", super::GITHUB_BASE_API_URL, team_id, username);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
404 => Err(TeamsRemoveMemberLegacyError::Status404.into()),
code => Err(TeamsRemoveMemberLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Remove team membership for a user
///
/// To remove a membership between a user and a team, the authenticated user must have 'admin' permissions to the team or be an owner of the organization that the team is associated with. Removing team membership does not delete the user, it just removes their membership from the team.
///
/// Team synchronization is available for organizations using GitHub Enterprise Cloud. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// > [!NOTE]
/// > When you have team synchronization set up for a team with your organization's identity provider (IdP), you will see an error if you attempt to use the API for making changes to the team's membership. If you have access to manage group membership in your IdP, you can manage GitHub team membership through your identity provider, which automatically adds and removes team members in an organization. For more information, see "[Synchronizing teams between your identity provider and GitHub](https://docs.github.com/articles/synchronizing-teams-between-your-identity-provider-and-github/)."
///
/// > [!NOTE]
/// > You can also specify a team by `org_id` and `team_id` using the route `DELETE /organizations/{org_id}/team/{team_id}/memberships/{username}`.
///
/// [GitHub API docs for remove_membership_for_user_in_org](https://docs.github.com/rest/teams/members#remove-team-membership-for-a-user)
///
/// ---
pub async fn remove_membership_for_user_in_org_async(&self, org: &str, team_slug: &str, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/teams/{}/memberships/{}", super::GITHUB_BASE_API_URL, org, team_slug, username);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
403 => Err(TeamsRemoveMembershipForUserInOrgError::Status403.into()),
code => Err(TeamsRemoveMembershipForUserInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Remove team membership for a user
///
/// To remove a membership between a user and a team, the authenticated user must have 'admin' permissions to the team or be an owner of the organization that the team is associated with. Removing team membership does not delete the user, it just removes their membership from the team.
///
/// Team synchronization is available for organizations using GitHub Enterprise Cloud. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// > [!NOTE]
/// > When you have team synchronization set up for a team with your organization's identity provider (IdP), you will see an error if you attempt to use the API for making changes to the team's membership. If you have access to manage group membership in your IdP, you can manage GitHub team membership through your identity provider, which automatically adds and removes team members in an organization. For more information, see "[Synchronizing teams between your identity provider and GitHub](https://docs.github.com/articles/synchronizing-teams-between-your-identity-provider-and-github/)."
///
/// > [!NOTE]
/// > You can also specify a team by `org_id` and `team_id` using the route `DELETE /organizations/{org_id}/team/{team_id}/memberships/{username}`.
///
/// [GitHub API docs for remove_membership_for_user_in_org](https://docs.github.com/rest/teams/members#remove-team-membership-for-a-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn remove_membership_for_user_in_org(&self, org: &str, team_slug: &str, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/teams/{}/memberships/{}", super::GITHUB_BASE_API_URL, org, team_slug, username);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
403 => Err(TeamsRemoveMembershipForUserInOrgError::Status403.into()),
code => Err(TeamsRemoveMembershipForUserInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Remove team membership for a user (Legacy)
///
/// > [!WARNING]
/// > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [Remove team membership for a user](https://docs.github.com/rest/teams/members#remove-team-membership-for-a-user) endpoint.
///
/// Team synchronization is available for organizations using GitHub Enterprise Cloud. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// To remove a membership between a user and a team, the authenticated user must have 'admin' permissions to the team or be an owner of the organization that the team is associated with. Removing team membership does not delete the user, it just removes their membership from the team.
///
/// > [!NOTE]
/// > When you have team synchronization set up for a team with your organization's identity provider (IdP), you will see an error if you attempt to use the API for making changes to the team's membership. If you have access to manage group membership in your IdP, you can manage GitHub team membership through your identity provider, which automatically adds and removes team members in an organization. For more information, see "[Synchronizing teams between your identity provider and GitHub](https://docs.github.com/articles/synchronizing-teams-between-your-identity-provider-and-github/)."
///
/// [GitHub API docs for remove_membership_for_user_legacy](https://docs.github.com/rest/teams/members#remove-team-membership-for-a-user-legacy)
///
/// ---
pub async fn remove_membership_for_user_legacy_async(&self, team_id: i32, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/teams/{}/memberships/{}", super::GITHUB_BASE_API_URL, team_id, username);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
403 => Err(TeamsRemoveMembershipForUserLegacyError::Status403.into()),
code => Err(TeamsRemoveMembershipForUserLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Remove team membership for a user (Legacy)
///
/// > [!WARNING]
/// > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [Remove team membership for a user](https://docs.github.com/rest/teams/members#remove-team-membership-for-a-user) endpoint.
///
/// Team synchronization is available for organizations using GitHub Enterprise Cloud. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// To remove a membership between a user and a team, the authenticated user must have 'admin' permissions to the team or be an owner of the organization that the team is associated with. Removing team membership does not delete the user, it just removes their membership from the team.
///
/// > [!NOTE]
/// > When you have team synchronization set up for a team with your organization's identity provider (IdP), you will see an error if you attempt to use the API for making changes to the team's membership. If you have access to manage group membership in your IdP, you can manage GitHub team membership through your identity provider, which automatically adds and removes team members in an organization. For more information, see "[Synchronizing teams between your identity provider and GitHub](https://docs.github.com/articles/synchronizing-teams-between-your-identity-provider-and-github/)."
///
/// [GitHub API docs for remove_membership_for_user_legacy](https://docs.github.com/rest/teams/members#remove-team-membership-for-a-user-legacy)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn remove_membership_for_user_legacy(&self, team_id: i32, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/teams/{}/memberships/{}", super::GITHUB_BASE_API_URL, team_id, username);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
403 => Err(TeamsRemoveMembershipForUserLegacyError::Status403.into()),
code => Err(TeamsRemoveMembershipForUserLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Remove a project from a team
///
/// > [!WARNING]
/// > **Closing down notice:** Projects (classic) is being deprecated in favor of the new Projects experience.
/// > See the [changelog](https://github.blog/changelog/2024-05-23-sunset-notice-projects-classic/) for more information.
///
/// [GitHub API docs for remove_project_in_org](https://docs.github.com/rest/teams/teams#remove-a-project-from-a-team)
///
/// ---
pub async fn remove_project_in_org_async(&self, org: &str, team_slug: &str, project_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/teams/{}/projects/{}", super::GITHUB_BASE_API_URL, org, team_slug, project_id);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
code => Err(TeamsRemoveProjectInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Remove a project from a team
///
/// > [!WARNING]
/// > **Closing down notice:** Projects (classic) is being deprecated in favor of the new Projects experience.
/// > See the [changelog](https://github.blog/changelog/2024-05-23-sunset-notice-projects-classic/) for more information.
///
/// [GitHub API docs for remove_project_in_org](https://docs.github.com/rest/teams/teams#remove-a-project-from-a-team)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn remove_project_in_org(&self, org: &str, team_slug: &str, project_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/teams/{}/projects/{}", super::GITHUB_BASE_API_URL, org, team_slug, project_id);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
code => Err(TeamsRemoveProjectInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Remove a project from a team (Legacy)
///
/// > [!WARNING]
/// > **Closing down notice:** Projects (classic) is being deprecated in favor of the new Projects experience.
/// > See the [changelog](https://github.blog/changelog/2024-05-23-sunset-notice-projects-classic/) for more information.
///
/// [GitHub API docs for remove_project_legacy](https://docs.github.com/rest/teams/teams#remove-a-project-from-a-team-legacy)
///
/// ---
pub async fn remove_project_legacy_async(&self, team_id: i32, project_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/teams/{}/projects/{}", super::GITHUB_BASE_API_URL, team_id, project_id);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
404 => Err(TeamsRemoveProjectLegacyError::Status404(github_response.to_json_async().await?).into()),
422 => Err(TeamsRemoveProjectLegacyError::Status422(github_response.to_json_async().await?).into()),
code => Err(TeamsRemoveProjectLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Remove a project from a team (Legacy)
///
/// > [!WARNING]
/// > **Closing down notice:** Projects (classic) is being deprecated in favor of the new Projects experience.
/// > See the [changelog](https://github.blog/changelog/2024-05-23-sunset-notice-projects-classic/) for more information.
///
/// [GitHub API docs for remove_project_legacy](https://docs.github.com/rest/teams/teams#remove-a-project-from-a-team-legacy)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn remove_project_legacy(&self, team_id: i32, project_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/teams/{}/projects/{}", super::GITHUB_BASE_API_URL, team_id, project_id);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
404 => Err(TeamsRemoveProjectLegacyError::Status404(github_response.to_json()?).into()),
422 => Err(TeamsRemoveProjectLegacyError::Status422(github_response.to_json()?).into()),
code => Err(TeamsRemoveProjectLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Remove a repository from a team
///
/// If the authenticated user is an organization owner or a team maintainer, they can remove any repositories from the team. To remove a repository from a team as an organization member, the authenticated user must have admin access to the repository and must be able to see the team. This does not delete the repository, it just removes it from the team.
///
/// > [!NOTE]
/// > You can also specify a team by `org_id` and `team_id` using the route `DELETE /organizations/{org_id}/team/{team_id}/repos/{owner}/{repo}`.
///
/// [GitHub API docs for remove_repo_in_org](https://docs.github.com/rest/teams/teams#remove-a-repository-from-a-team)
///
/// ---
pub async fn remove_repo_in_org_async(&self, org: &str, team_slug: &str, owner: &str, repo: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/teams/{}/repos/{}/{}", super::GITHUB_BASE_API_URL, org, team_slug, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
code => Err(TeamsRemoveRepoInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Remove a repository from a team
///
/// If the authenticated user is an organization owner or a team maintainer, they can remove any repositories from the team. To remove a repository from a team as an organization member, the authenticated user must have admin access to the repository and must be able to see the team. This does not delete the repository, it just removes it from the team.
///
/// > [!NOTE]
/// > You can also specify a team by `org_id` and `team_id` using the route `DELETE /organizations/{org_id}/team/{team_id}/repos/{owner}/{repo}`.
///
/// [GitHub API docs for remove_repo_in_org](https://docs.github.com/rest/teams/teams#remove-a-repository-from-a-team)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn remove_repo_in_org(&self, org: &str, team_slug: &str, owner: &str, repo: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/teams/{}/repos/{}/{}", super::GITHUB_BASE_API_URL, org, team_slug, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
code => Err(TeamsRemoveRepoInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Remove a repository from a team (Legacy)
///
/// > [!WARNING]
/// > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [Remove a repository from a team](https://docs.github.com/rest/teams/teams#remove-a-repository-from-a-team) endpoint.
///
/// If the authenticated user is an organization owner or a team maintainer, they can remove any repositories from the team. To remove a repository from a team as an organization member, the authenticated user must have admin access to the repository and must be able to see the team. NOTE: This does not delete the repository, it just removes it from the team.
///
/// [GitHub API docs for remove_repo_legacy](https://docs.github.com/rest/teams/teams#remove-a-repository-from-a-team-legacy)
///
/// ---
pub async fn remove_repo_legacy_async(&self, team_id: i32, owner: &str, repo: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/teams/{}/repos/{}/{}", super::GITHUB_BASE_API_URL, team_id, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
code => Err(TeamsRemoveRepoLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Remove a repository from a team (Legacy)
///
/// > [!WARNING]
/// > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [Remove a repository from a team](https://docs.github.com/rest/teams/teams#remove-a-repository-from-a-team) endpoint.
///
/// If the authenticated user is an organization owner or a team maintainer, they can remove any repositories from the team. To remove a repository from a team as an organization member, the authenticated user must have admin access to the repository and must be able to see the team. NOTE: This does not delete the repository, it just removes it from the team.
///
/// [GitHub API docs for remove_repo_legacy](https://docs.github.com/rest/teams/teams#remove-a-repository-from-a-team-legacy)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn remove_repo_legacy(&self, team_id: i32, owner: &str, repo: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/teams/{}/repos/{}/{}", super::GITHUB_BASE_API_URL, team_id, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
code => Err(TeamsRemoveRepoLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update a discussion comment
///
/// Edits the body text of a discussion comment.
///
/// > [!NOTE]
/// > You can also specify a team by `org_id` and `team_id` using the route `PATCH /organizations/{org_id}/team/{team_id}/discussions/{discussion_number}/comments/{comment_number}`.
///
/// OAuth app tokens and personal access tokens (classic) need the `write:discussion` scope to use this endpoint.
///
/// [GitHub API docs for update_discussion_comment_in_org](https://docs.github.com/rest/teams/discussion-comments#update-a-discussion-comment)
///
/// ---
pub async fn update_discussion_comment_in_org_async(&self, org: &str, team_slug: &str, discussion_number: i32, comment_number: i32, body: PatchTeamsUpdateDiscussionCommentInOrg) -> Result<TeamDiscussionComment, AdapterError> {
let request_uri = format!("{}/orgs/{}/teams/{}/discussions/{}/comments/{}", super::GITHUB_BASE_API_URL, org, team_slug, discussion_number, comment_number);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchTeamsUpdateDiscussionCommentInOrg>(body)?),
method: "PATCH",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
code => Err(TeamsUpdateDiscussionCommentInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update a discussion comment
///
/// Edits the body text of a discussion comment.
///
/// > [!NOTE]
/// > You can also specify a team by `org_id` and `team_id` using the route `PATCH /organizations/{org_id}/team/{team_id}/discussions/{discussion_number}/comments/{comment_number}`.
///
/// OAuth app tokens and personal access tokens (classic) need the `write:discussion` scope to use this endpoint.
///
/// [GitHub API docs for update_discussion_comment_in_org](https://docs.github.com/rest/teams/discussion-comments#update-a-discussion-comment)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn update_discussion_comment_in_org(&self, org: &str, team_slug: &str, discussion_number: i32, comment_number: i32, body: PatchTeamsUpdateDiscussionCommentInOrg) -> Result<TeamDiscussionComment, AdapterError> {
let request_uri = format!("{}/orgs/{}/teams/{}/discussions/{}/comments/{}", super::GITHUB_BASE_API_URL, org, team_slug, discussion_number, comment_number);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchTeamsUpdateDiscussionCommentInOrg>(body)?),
method: "PATCH",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
code => Err(TeamsUpdateDiscussionCommentInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update a discussion comment (Legacy)
///
/// > [!WARNING]
/// > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [Update a discussion comment](https://docs.github.com/rest/teams/discussion-comments#update-a-discussion-comment) endpoint.
///
/// Edits the body text of a discussion comment.
///
/// OAuth app tokens and personal access tokens (classic) need the `write:discussion` scope to use this endpoint.
///
/// [GitHub API docs for update_discussion_comment_legacy](https://docs.github.com/rest/teams/discussion-comments#update-a-discussion-comment-legacy)
///
/// ---
pub async fn update_discussion_comment_legacy_async(&self, team_id: i32, discussion_number: i32, comment_number: i32, body: PatchTeamsUpdateDiscussionCommentLegacy) -> Result<TeamDiscussionComment, AdapterError> {
let request_uri = format!("{}/teams/{}/discussions/{}/comments/{}", super::GITHUB_BASE_API_URL, team_id, discussion_number, comment_number);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchTeamsUpdateDiscussionCommentLegacy>(body)?),
method: "PATCH",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
code => Err(TeamsUpdateDiscussionCommentLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update a discussion comment (Legacy)
///
/// > [!WARNING]
/// > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [Update a discussion comment](https://docs.github.com/rest/teams/discussion-comments#update-a-discussion-comment) endpoint.
///
/// Edits the body text of a discussion comment.
///
/// OAuth app tokens and personal access tokens (classic) need the `write:discussion` scope to use this endpoint.
///
/// [GitHub API docs for update_discussion_comment_legacy](https://docs.github.com/rest/teams/discussion-comments#update-a-discussion-comment-legacy)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn update_discussion_comment_legacy(&self, team_id: i32, discussion_number: i32, comment_number: i32, body: PatchTeamsUpdateDiscussionCommentLegacy) -> Result<TeamDiscussionComment, AdapterError> {
let request_uri = format!("{}/teams/{}/discussions/{}/comments/{}", super::GITHUB_BASE_API_URL, team_id, discussion_number, comment_number);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchTeamsUpdateDiscussionCommentLegacy>(body)?),
method: "PATCH",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
code => Err(TeamsUpdateDiscussionCommentLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update a discussion
///
/// Edits the title and body text of a discussion post. Only the parameters you provide are updated.
///
/// > [!NOTE]
/// > You can also specify a team by `org_id` and `team_id` using the route `PATCH /organizations/{org_id}/team/{team_id}/discussions/{discussion_number}`.
///
/// OAuth app tokens and personal access tokens (classic) need the `write:discussion` scope to use this endpoint.
///
/// [GitHub API docs for update_discussion_in_org](https://docs.github.com/rest/teams/discussions#update-a-discussion)
///
/// ---
pub async fn update_discussion_in_org_async(&self, org: &str, team_slug: &str, discussion_number: i32, body: PatchTeamsUpdateDiscussionInOrg) -> Result<TeamDiscussion, AdapterError> {
let request_uri = format!("{}/orgs/{}/teams/{}/discussions/{}", super::GITHUB_BASE_API_URL, org, team_slug, discussion_number);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchTeamsUpdateDiscussionInOrg>(body)?),
method: "PATCH",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
code => Err(TeamsUpdateDiscussionInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update a discussion
///
/// Edits the title and body text of a discussion post. Only the parameters you provide are updated.
///
/// > [!NOTE]
/// > You can also specify a team by `org_id` and `team_id` using the route `PATCH /organizations/{org_id}/team/{team_id}/discussions/{discussion_number}`.
///
/// OAuth app tokens and personal access tokens (classic) need the `write:discussion` scope to use this endpoint.
///
/// [GitHub API docs for update_discussion_in_org](https://docs.github.com/rest/teams/discussions#update-a-discussion)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn update_discussion_in_org(&self, org: &str, team_slug: &str, discussion_number: i32, body: PatchTeamsUpdateDiscussionInOrg) -> Result<TeamDiscussion, AdapterError> {
let request_uri = format!("{}/orgs/{}/teams/{}/discussions/{}", super::GITHUB_BASE_API_URL, org, team_slug, discussion_number);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchTeamsUpdateDiscussionInOrg>(body)?),
method: "PATCH",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
code => Err(TeamsUpdateDiscussionInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update a discussion (Legacy)
///
/// > [!WARNING]
/// > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [Update a discussion](https://docs.github.com/rest/teams/discussions#update-a-discussion) endpoint.
///
/// Edits the title and body text of a discussion post. Only the parameters you provide are updated.
///
/// OAuth app tokens and personal access tokens (classic) need the `write:discussion` scope to use this endpoint.
///
/// [GitHub API docs for update_discussion_legacy](https://docs.github.com/rest/teams/discussions#update-a-discussion-legacy)
///
/// ---
pub async fn update_discussion_legacy_async(&self, team_id: i32, discussion_number: i32, body: PatchTeamsUpdateDiscussionLegacy) -> Result<TeamDiscussion, AdapterError> {
let request_uri = format!("{}/teams/{}/discussions/{}", super::GITHUB_BASE_API_URL, team_id, discussion_number);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchTeamsUpdateDiscussionLegacy>(body)?),
method: "PATCH",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
code => Err(TeamsUpdateDiscussionLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update a discussion (Legacy)
///
/// > [!WARNING]
/// > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [Update a discussion](https://docs.github.com/rest/teams/discussions#update-a-discussion) endpoint.
///
/// Edits the title and body text of a discussion post. Only the parameters you provide are updated.
///
/// OAuth app tokens and personal access tokens (classic) need the `write:discussion` scope to use this endpoint.
///
/// [GitHub API docs for update_discussion_legacy](https://docs.github.com/rest/teams/discussions#update-a-discussion-legacy)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn update_discussion_legacy(&self, team_id: i32, discussion_number: i32, body: PatchTeamsUpdateDiscussionLegacy) -> Result<TeamDiscussion, AdapterError> {
let request_uri = format!("{}/teams/{}/discussions/{}", super::GITHUB_BASE_API_URL, team_id, discussion_number);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchTeamsUpdateDiscussionLegacy>(body)?),
method: "PATCH",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
code => Err(TeamsUpdateDiscussionLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update a team
///
/// To edit a team, the authenticated user must either be an organization owner or a team maintainer.
///
/// > [!NOTE]
/// > You can also specify a team by `org_id` and `team_id` using the route `PATCH /organizations/{org_id}/team/{team_id}`.
///
/// [GitHub API docs for update_in_org](https://docs.github.com/rest/teams/teams#update-a-team)
///
/// ---
pub async fn update_in_org_async(&self, org: &str, team_slug: &str, body: PatchTeamsUpdateInOrg) -> Result<TeamFull, AdapterError> {
let request_uri = format!("{}/orgs/{}/teams/{}", super::GITHUB_BASE_API_URL, org, team_slug);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchTeamsUpdateInOrg>(body)?),
method: "PATCH",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
201 => Err(TeamsUpdateInOrgError::Status201(github_response.to_json_async().await?).into()),
404 => Err(TeamsUpdateInOrgError::Status404(github_response.to_json_async().await?).into()),
422 => Err(TeamsUpdateInOrgError::Status422(github_response.to_json_async().await?).into()),
403 => Err(TeamsUpdateInOrgError::Status403(github_response.to_json_async().await?).into()),
code => Err(TeamsUpdateInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update a team
///
/// To edit a team, the authenticated user must either be an organization owner or a team maintainer.
///
/// > [!NOTE]
/// > You can also specify a team by `org_id` and `team_id` using the route `PATCH /organizations/{org_id}/team/{team_id}`.
///
/// [GitHub API docs for update_in_org](https://docs.github.com/rest/teams/teams#update-a-team)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn update_in_org(&self, org: &str, team_slug: &str, body: PatchTeamsUpdateInOrg) -> Result<TeamFull, AdapterError> {
let request_uri = format!("{}/orgs/{}/teams/{}", super::GITHUB_BASE_API_URL, org, team_slug);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchTeamsUpdateInOrg>(body)?),
method: "PATCH",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
201 => Err(TeamsUpdateInOrgError::Status201(github_response.to_json()?).into()),
404 => Err(TeamsUpdateInOrgError::Status404(github_response.to_json()?).into()),
422 => Err(TeamsUpdateInOrgError::Status422(github_response.to_json()?).into()),
403 => Err(TeamsUpdateInOrgError::Status403(github_response.to_json()?).into()),
code => Err(TeamsUpdateInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update a team (Legacy)
///
/// > [!WARNING]
/// > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [Update a team](https://docs.github.com/rest/teams/teams#update-a-team) endpoint.
///
/// To edit a team, the authenticated user must either be an organization owner or a team maintainer.
///
/// > [!NOTE]
/// > With nested teams, the `privacy` for parent teams cannot be `secret`.
///
/// [GitHub API docs for update_legacy](https://docs.github.com/rest/teams/teams#update-a-team-legacy)
///
/// ---
pub async fn update_legacy_async(&self, team_id: i32, body: PatchTeamsUpdateLegacy) -> Result<TeamFull, AdapterError> {
let request_uri = format!("{}/teams/{}", super::GITHUB_BASE_API_URL, team_id);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchTeamsUpdateLegacy>(body)?),
method: "PATCH",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
201 => Err(TeamsUpdateLegacyError::Status201(github_response.to_json_async().await?).into()),
404 => Err(TeamsUpdateLegacyError::Status404(github_response.to_json_async().await?).into()),
422 => Err(TeamsUpdateLegacyError::Status422(github_response.to_json_async().await?).into()),
403 => Err(TeamsUpdateLegacyError::Status403(github_response.to_json_async().await?).into()),
code => Err(TeamsUpdateLegacyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update a team (Legacy)
///
/// > [!WARNING]
/// > **Endpoint closing down notice:** This endpoint route is closing down and will be removed from the Teams API. We recommend migrating your existing code to use the new [Update a team](https://docs.github.com/rest/teams/teams#update-a-team) endpoint.
///
/// To edit a team, the authenticated user must either be an organization owner or a team maintainer.
///
/// > [!NOTE]
/// > With nested teams, the `privacy` for parent teams cannot be `secret`.
///
/// [GitHub API docs for update_legacy](https://docs.github.com/rest/teams/teams#update-a-team-legacy)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn update_legacy(&self, team_id: i32, body: PatchTeamsUpdateLegacy) -> Result<TeamFull, AdapterError> {
let request_uri = format!("{}/teams/{}", super::GITHUB_BASE_API_URL, team_id);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchTeamsUpdateLegacy>(body)?),
method: "PATCH",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
201 => Err(TeamsUpdateLegacyError::Status201(github_response.to_json()?).into()),
404 => Err(TeamsUpdateLegacyError::Status404(github_response.to_json()?).into()),
422 => Err(TeamsUpdateLegacyError::Status422(github_response.to_json()?).into()),
403 => Err(TeamsUpdateLegacyError::Status403(github_response.to_json()?).into()),
code => Err(TeamsUpdateLegacyError::Generic { code }.into()),
}
}
}
}