//! Method, error and parameter types for the Orgs 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 Orgs<'api, C: Client> where AdapterError: From<<C as Client>::Err> {
client: &'api C
}
pub fn new<C: Client>(client: &C) -> Orgs<C> where AdapterError: From<<C as Client>::Err> {
Orgs { client }
}
/// Errors for the [Add a security manager team](Orgs::add_security_manager_team_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsAddSecurityManagerTeamError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsAddSecurityManagerTeamError> for AdapterError {
fn from(err: OrgsAddSecurityManagerTeamError) -> Self {
let (description, status_code) = match err {
OrgsAddSecurityManagerTeamError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Assign an organization role to a team](Orgs::assign_team_to_org_role_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsAssignTeamToOrgRoleError {
#[error("Response if the organization, team or role does not exist.")]
Status404,
#[error("Response if the organization roles feature is not enabled for the organization, or validation failed.")]
Status422,
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsAssignTeamToOrgRoleError> for AdapterError {
fn from(err: OrgsAssignTeamToOrgRoleError) -> Self {
let (description, status_code) = match err {
OrgsAssignTeamToOrgRoleError::Status404 => (String::from("Response if the organization, team or role does not exist."), 404),
OrgsAssignTeamToOrgRoleError::Status422 => (String::from("Response if the organization roles feature is not enabled for the organization, or validation failed."), 422),
OrgsAssignTeamToOrgRoleError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Assign an organization role to a user](Orgs::assign_user_to_org_role_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsAssignUserToOrgRoleError {
#[error("Response if the organization, user or role does not exist.")]
Status404,
#[error("Response if the organization roles feature is not enabled enabled for the organization, the validation failed, or the user is not an organization member.")]
Status422,
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsAssignUserToOrgRoleError> for AdapterError {
fn from(err: OrgsAssignUserToOrgRoleError) -> Self {
let (description, status_code) = match err {
OrgsAssignUserToOrgRoleError::Status404 => (String::from("Response if the organization, user or role does not exist."), 404),
OrgsAssignUserToOrgRoleError::Status422 => (String::from("Response if the organization roles feature is not enabled enabled for the organization, the validation failed, or the user is not an organization member."), 422),
OrgsAssignUserToOrgRoleError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Block a user from an organization](Orgs::block_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsBlockUserError {
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsBlockUserError> for AdapterError {
fn from(err: OrgsBlockUserError) -> Self {
let (description, status_code) = match err {
OrgsBlockUserError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
OrgsBlockUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Cancel an organization invitation](Orgs::cancel_invitation_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsCancelInvitationError {
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsCancelInvitationError> for AdapterError {
fn from(err: OrgsCancelInvitationError) -> Self {
let (description, status_code) = match err {
OrgsCancelInvitationError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
OrgsCancelInvitationError::Status404(_) => (String::from("Resource not found"), 404),
OrgsCancelInvitationError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Check if a user is blocked by an organization](Orgs::check_blocked_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsCheckBlockedUserError {
#[error("If the user is not blocked")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsCheckBlockedUserError> for AdapterError {
fn from(err: OrgsCheckBlockedUserError) -> Self {
let (description, status_code) = match err {
OrgsCheckBlockedUserError::Status404(_) => (String::from("If the user is not blocked"), 404),
OrgsCheckBlockedUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Check organization membership for a user](Orgs::check_membership_for_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsCheckMembershipForUserError {
#[error("Response if requester is not an organization member")]
Status302,
#[error("Not Found if requester is an organization member and user is not a member")]
Status404,
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsCheckMembershipForUserError> for AdapterError {
fn from(err: OrgsCheckMembershipForUserError) -> Self {
let (description, status_code) = match err {
OrgsCheckMembershipForUserError::Status302 => (String::from("Response if requester is not an organization member"), 302),
OrgsCheckMembershipForUserError::Status404 => (String::from("Not Found if requester is an organization member and user is not a member"), 404),
OrgsCheckMembershipForUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Check public organization membership for a user](Orgs::check_public_membership_for_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsCheckPublicMembershipForUserError {
#[error("Not Found if user is not a public member")]
Status404,
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsCheckPublicMembershipForUserError> for AdapterError {
fn from(err: OrgsCheckPublicMembershipForUserError) -> Self {
let (description, status_code) = match err {
OrgsCheckPublicMembershipForUserError::Status404 => (String::from("Not Found if user is not a public member"), 404),
OrgsCheckPublicMembershipForUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Convert an organization member to outside collaborator](Orgs::convert_member_to_outside_collaborator_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsConvertMemberToOutsideCollaboratorError {
#[error("User was converted")]
Status204,
#[error("Forbidden if user is the last owner of the organization, not a member of the organization, or if the enterprise enforces a policy for inviting outside collaborators. For more information, see \"[Enforcing repository management policies in your enterprise](https://docs.github.com/admin/policies/enforcing-policies-for-your-enterprise/enforcing-repository-management-policies-in-your-enterprise#enforcing-a-policy-for-inviting-outside-collaborators-to-repositories).\"")]
Status403,
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsConvertMemberToOutsideCollaboratorError> for AdapterError {
fn from(err: OrgsConvertMemberToOutsideCollaboratorError) -> Self {
let (description, status_code) = match err {
OrgsConvertMemberToOutsideCollaboratorError::Status204 => (String::from("User was converted"), 204),
OrgsConvertMemberToOutsideCollaboratorError::Status403 => (String::from("Forbidden if user is the last owner of the organization, not a member of the organization, or if the enterprise enforces a policy for inviting outside collaborators. For more information, see \"[Enforcing repository management policies in your enterprise](https://docs.github.com/admin/policies/enforcing-policies-for-your-enterprise/enforcing-repository-management-policies-in-your-enterprise#enforcing-a-policy-for-inviting-outside-collaborators-to-repositories).\""), 403),
OrgsConvertMemberToOutsideCollaboratorError::Status404(_) => (String::from("Resource not found"), 404),
OrgsConvertMemberToOutsideCollaboratorError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Create an organization invitation](Orgs::create_invitation_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsCreateInvitationError {
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsCreateInvitationError> for AdapterError {
fn from(err: OrgsCreateInvitationError) -> Self {
let (description, status_code) = match err {
OrgsCreateInvitationError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
OrgsCreateInvitationError::Status404(_) => (String::from("Resource not found"), 404),
OrgsCreateInvitationError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Create issue type for an organization](Orgs::create_issue_type_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsCreateIssueTypeError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationErrorSimple),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsCreateIssueTypeError> for AdapterError {
fn from(err: OrgsCreateIssueTypeError) -> Self {
let (description, status_code) = match err {
OrgsCreateIssueTypeError::Status404(_) => (String::from("Resource not found"), 404),
OrgsCreateIssueTypeError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
OrgsCreateIssueTypeError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Create or update custom properties for an organization](Orgs::create_or_update_custom_properties_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsCreateOrUpdateCustomPropertiesError {
#[error("Forbidden")]
Status403(BasicError),
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsCreateOrUpdateCustomPropertiesError> for AdapterError {
fn from(err: OrgsCreateOrUpdateCustomPropertiesError) -> Self {
let (description, status_code) = match err {
OrgsCreateOrUpdateCustomPropertiesError::Status403(_) => (String::from("Forbidden"), 403),
OrgsCreateOrUpdateCustomPropertiesError::Status404(_) => (String::from("Resource not found"), 404),
OrgsCreateOrUpdateCustomPropertiesError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Create or update custom property values for organization repositories](Orgs::create_or_update_custom_properties_values_for_repos_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsCreateOrUpdateCustomPropertiesValuesForReposError {
#[error("Forbidden")]
Status403(BasicError),
#[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<OrgsCreateOrUpdateCustomPropertiesValuesForReposError> for AdapterError {
fn from(err: OrgsCreateOrUpdateCustomPropertiesValuesForReposError) -> Self {
let (description, status_code) = match err {
OrgsCreateOrUpdateCustomPropertiesValuesForReposError::Status403(_) => (String::from("Forbidden"), 403),
OrgsCreateOrUpdateCustomPropertiesValuesForReposError::Status404(_) => (String::from("Resource not found"), 404),
OrgsCreateOrUpdateCustomPropertiesValuesForReposError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
OrgsCreateOrUpdateCustomPropertiesValuesForReposError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Create or update a custom property for an organization](Orgs::create_or_update_custom_property_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsCreateOrUpdateCustomPropertyError {
#[error("Forbidden")]
Status403(BasicError),
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsCreateOrUpdateCustomPropertyError> for AdapterError {
fn from(err: OrgsCreateOrUpdateCustomPropertyError) -> Self {
let (description, status_code) = match err {
OrgsCreateOrUpdateCustomPropertyError::Status403(_) => (String::from("Forbidden"), 403),
OrgsCreateOrUpdateCustomPropertyError::Status404(_) => (String::from("Resource not found"), 404),
OrgsCreateOrUpdateCustomPropertyError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Create an organization webhook](Orgs::create_webhook_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsCreateWebhookError {
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsCreateWebhookError> for AdapterError {
fn from(err: OrgsCreateWebhookError) -> Self {
let (description, status_code) = match err {
OrgsCreateWebhookError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
OrgsCreateWebhookError::Status404(_) => (String::from("Resource not found"), 404),
OrgsCreateWebhookError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Delete an organization](Orgs::delete_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsDeleteError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsDeleteError> for AdapterError {
fn from(err: OrgsDeleteError) -> Self {
let (description, status_code) = match err {
OrgsDeleteError::Status404(_) => (String::from("Resource not found"), 404),
OrgsDeleteError::Status403(_) => (String::from("Forbidden"), 403),
OrgsDeleteError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Delete attestations in bulk](Orgs::delete_attestations_bulk_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsDeleteAttestationsBulkError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsDeleteAttestationsBulkError> for AdapterError {
fn from(err: OrgsDeleteAttestationsBulkError) -> Self {
let (description, status_code) = match err {
OrgsDeleteAttestationsBulkError::Status404(_) => (String::from("Resource not found"), 404),
OrgsDeleteAttestationsBulkError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Delete attestations by ID](Orgs::delete_attestations_by_id_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsDeleteAttestationsByIdError {
#[error("Response")]
Status204,
#[error("Forbidden")]
Status403(BasicError),
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsDeleteAttestationsByIdError> for AdapterError {
fn from(err: OrgsDeleteAttestationsByIdError) -> Self {
let (description, status_code) = match err {
OrgsDeleteAttestationsByIdError::Status204 => (String::from("Response"), 204),
OrgsDeleteAttestationsByIdError::Status403(_) => (String::from("Forbidden"), 403),
OrgsDeleteAttestationsByIdError::Status404(_) => (String::from("Resource not found"), 404),
OrgsDeleteAttestationsByIdError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Delete attestations by subject digest](Orgs::delete_attestations_by_subject_digest_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsDeleteAttestationsBySubjectDigestError {
#[error("Response")]
Status204,
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsDeleteAttestationsBySubjectDigestError> for AdapterError {
fn from(err: OrgsDeleteAttestationsBySubjectDigestError) -> Self {
let (description, status_code) = match err {
OrgsDeleteAttestationsBySubjectDigestError::Status204 => (String::from("Response"), 204),
OrgsDeleteAttestationsBySubjectDigestError::Status404(_) => (String::from("Resource not found"), 404),
OrgsDeleteAttestationsBySubjectDigestError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Delete issue type for an organization](Orgs::delete_issue_type_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsDeleteIssueTypeError {
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationErrorSimple),
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsDeleteIssueTypeError> for AdapterError {
fn from(err: OrgsDeleteIssueTypeError) -> Self {
let (description, status_code) = match err {
OrgsDeleteIssueTypeError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
OrgsDeleteIssueTypeError::Status404(_) => (String::from("Resource not found"), 404),
OrgsDeleteIssueTypeError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Delete an organization webhook](Orgs::delete_webhook_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsDeleteWebhookError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsDeleteWebhookError> for AdapterError {
fn from(err: OrgsDeleteWebhookError) -> Self {
let (description, status_code) = match err {
OrgsDeleteWebhookError::Status404(_) => (String::from("Resource not found"), 404),
OrgsDeleteWebhookError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Enable or disable a security feature for an organization](Orgs::enable_or_disable_security_product_on_all_org_repos_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsEnableOrDisableSecurityProductOnAllOrgReposError {
#[error("The action could not be taken due to an in progress enablement, or a policy is preventing enablement")]
Status422,
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsEnableOrDisableSecurityProductOnAllOrgReposError> for AdapterError {
fn from(err: OrgsEnableOrDisableSecurityProductOnAllOrgReposError) -> Self {
let (description, status_code) = match err {
OrgsEnableOrDisableSecurityProductOnAllOrgReposError::Status422 => (String::from("The action could not be taken due to an in progress enablement, or a policy is preventing enablement"), 422),
OrgsEnableOrDisableSecurityProductOnAllOrgReposError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get an organization](Orgs::get_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsGetError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsGetError> for AdapterError {
fn from(err: OrgsGetError) -> Self {
let (description, status_code) = match err {
OrgsGetError::Status404(_) => (String::from("Resource not found"), 404),
OrgsGetError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get all custom properties for an organization](Orgs::get_all_custom_properties_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsGetAllCustomPropertiesError {
#[error("Forbidden")]
Status403(BasicError),
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsGetAllCustomPropertiesError> for AdapterError {
fn from(err: OrgsGetAllCustomPropertiesError) -> Self {
let (description, status_code) = match err {
OrgsGetAllCustomPropertiesError::Status403(_) => (String::from("Forbidden"), 403),
OrgsGetAllCustomPropertiesError::Status404(_) => (String::from("Resource not found"), 404),
OrgsGetAllCustomPropertiesError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get a custom property for an organization](Orgs::get_custom_property_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsGetCustomPropertyError {
#[error("Forbidden")]
Status403(BasicError),
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsGetCustomPropertyError> for AdapterError {
fn from(err: OrgsGetCustomPropertyError) -> Self {
let (description, status_code) = match err {
OrgsGetCustomPropertyError::Status403(_) => (String::from("Forbidden"), 403),
OrgsGetCustomPropertyError::Status404(_) => (String::from("Resource not found"), 404),
OrgsGetCustomPropertyError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get an organization membership for the authenticated user](Orgs::get_membership_for_authenticated_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsGetMembershipForAuthenticatedUserError {
#[error("Forbidden")]
Status403(BasicError),
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsGetMembershipForAuthenticatedUserError> for AdapterError {
fn from(err: OrgsGetMembershipForAuthenticatedUserError) -> Self {
let (description, status_code) = match err {
OrgsGetMembershipForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403),
OrgsGetMembershipForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404),
OrgsGetMembershipForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get organization membership for a user](Orgs::get_membership_for_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsGetMembershipForUserError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsGetMembershipForUserError> for AdapterError {
fn from(err: OrgsGetMembershipForUserError) -> Self {
let (description, status_code) = match err {
OrgsGetMembershipForUserError::Status404(_) => (String::from("Resource not found"), 404),
OrgsGetMembershipForUserError::Status403(_) => (String::from("Forbidden"), 403),
OrgsGetMembershipForUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get an organization role](Orgs::get_org_role_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsGetOrgRoleError {
#[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<OrgsGetOrgRoleError> for AdapterError {
fn from(err: OrgsGetOrgRoleError) -> Self {
let (description, status_code) = match err {
OrgsGetOrgRoleError::Status404(_) => (String::from("Resource not found"), 404),
OrgsGetOrgRoleError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
OrgsGetOrgRoleError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get organization ruleset history](Orgs::get_org_ruleset_history_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsGetOrgRulesetHistoryError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Internal Error")]
Status500(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsGetOrgRulesetHistoryError> for AdapterError {
fn from(err: OrgsGetOrgRulesetHistoryError) -> Self {
let (description, status_code) = match err {
OrgsGetOrgRulesetHistoryError::Status404(_) => (String::from("Resource not found"), 404),
OrgsGetOrgRulesetHistoryError::Status500(_) => (String::from("Internal Error"), 500),
OrgsGetOrgRulesetHistoryError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get organization ruleset version](Orgs::get_org_ruleset_version_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsGetOrgRulesetVersionError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Internal Error")]
Status500(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsGetOrgRulesetVersionError> for AdapterError {
fn from(err: OrgsGetOrgRulesetVersionError) -> Self {
let (description, status_code) = match err {
OrgsGetOrgRulesetVersionError::Status404(_) => (String::from("Resource not found"), 404),
OrgsGetOrgRulesetVersionError::Status500(_) => (String::from("Internal Error"), 500),
OrgsGetOrgRulesetVersionError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get route stats by actor](Orgs::get_route_stats_by_actor_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsGetRouteStatsByActorError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsGetRouteStatsByActorError> for AdapterError {
fn from(err: OrgsGetRouteStatsByActorError) -> Self {
let (description, status_code) = match err {
OrgsGetRouteStatsByActorError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get subject stats](Orgs::get_subject_stats_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsGetSubjectStatsError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsGetSubjectStatsError> for AdapterError {
fn from(err: OrgsGetSubjectStatsError) -> Self {
let (description, status_code) = match err {
OrgsGetSubjectStatsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get summary stats](Orgs::get_summary_stats_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsGetSummaryStatsError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsGetSummaryStatsError> for AdapterError {
fn from(err: OrgsGetSummaryStatsError) -> Self {
let (description, status_code) = match err {
OrgsGetSummaryStatsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get summary stats by actor](Orgs::get_summary_stats_by_actor_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsGetSummaryStatsByActorError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsGetSummaryStatsByActorError> for AdapterError {
fn from(err: OrgsGetSummaryStatsByActorError) -> Self {
let (description, status_code) = match err {
OrgsGetSummaryStatsByActorError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get summary stats by user](Orgs::get_summary_stats_by_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsGetSummaryStatsByUserError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsGetSummaryStatsByUserError> for AdapterError {
fn from(err: OrgsGetSummaryStatsByUserError) -> Self {
let (description, status_code) = match err {
OrgsGetSummaryStatsByUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get time stats](Orgs::get_time_stats_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsGetTimeStatsError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsGetTimeStatsError> for AdapterError {
fn from(err: OrgsGetTimeStatsError) -> Self {
let (description, status_code) = match err {
OrgsGetTimeStatsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get time stats by actor](Orgs::get_time_stats_by_actor_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsGetTimeStatsByActorError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsGetTimeStatsByActorError> for AdapterError {
fn from(err: OrgsGetTimeStatsByActorError) -> Self {
let (description, status_code) = match err {
OrgsGetTimeStatsByActorError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get time stats by user](Orgs::get_time_stats_by_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsGetTimeStatsByUserError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsGetTimeStatsByUserError> for AdapterError {
fn from(err: OrgsGetTimeStatsByUserError) -> Self {
let (description, status_code) = match err {
OrgsGetTimeStatsByUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get user stats](Orgs::get_user_stats_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsGetUserStatsError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsGetUserStatsError> for AdapterError {
fn from(err: OrgsGetUserStatsError) -> Self {
let (description, status_code) = match err {
OrgsGetUserStatsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get an organization webhook](Orgs::get_webhook_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsGetWebhookError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsGetWebhookError> for AdapterError {
fn from(err: OrgsGetWebhookError) -> Self {
let (description, status_code) = match err {
OrgsGetWebhookError::Status404(_) => (String::from("Resource not found"), 404),
OrgsGetWebhookError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get a webhook configuration for an organization](Orgs::get_webhook_config_for_org_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsGetWebhookConfigForOrgError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsGetWebhookConfigForOrgError> for AdapterError {
fn from(err: OrgsGetWebhookConfigForOrgError) -> Self {
let (description, status_code) = match err {
OrgsGetWebhookConfigForOrgError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get a webhook delivery for an organization webhook](Orgs::get_webhook_delivery_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsGetWebhookDeliveryError {
#[error("Bad Request")]
Status400(BasicError),
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsGetWebhookDeliveryError> for AdapterError {
fn from(err: OrgsGetWebhookDeliveryError) -> Self {
let (description, status_code) = match err {
OrgsGetWebhookDeliveryError::Status400(_) => (String::from("Bad Request"), 400),
OrgsGetWebhookDeliveryError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
OrgsGetWebhookDeliveryError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List organizations](Orgs::list_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsListError {
#[error("Not modified")]
Status304,
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsListError> for AdapterError {
fn from(err: OrgsListError) -> Self {
let (description, status_code) = match err {
OrgsListError::Status304 => (String::from("Not modified"), 304),
OrgsListError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List app installations for an organization](Orgs::list_app_installations_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsListAppInstallationsError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsListAppInstallationsError> for AdapterError {
fn from(err: OrgsListAppInstallationsError) -> Self {
let (description, status_code) = match err {
OrgsListAppInstallationsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List attestations](Orgs::list_attestations_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsListAttestationsError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsListAttestationsError> for AdapterError {
fn from(err: OrgsListAttestationsError) -> Self {
let (description, status_code) = match err {
OrgsListAttestationsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List attestations by bulk subject digests](Orgs::list_attestations_bulk_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsListAttestationsBulkError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsListAttestationsBulkError> for AdapterError {
fn from(err: OrgsListAttestationsBulkError) -> Self {
let (description, status_code) = match err {
OrgsListAttestationsBulkError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List users blocked by an organization](Orgs::list_blocked_users_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsListBlockedUsersError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsListBlockedUsersError> for AdapterError {
fn from(err: OrgsListBlockedUsersError) -> Self {
let (description, status_code) = match err {
OrgsListBlockedUsersError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List custom property values for organization repositories](Orgs::list_custom_properties_values_for_repos_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsListCustomPropertiesValuesForReposError {
#[error("Forbidden")]
Status403(BasicError),
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsListCustomPropertiesValuesForReposError> for AdapterError {
fn from(err: OrgsListCustomPropertiesValuesForReposError) -> Self {
let (description, status_code) = match err {
OrgsListCustomPropertiesValuesForReposError::Status403(_) => (String::from("Forbidden"), 403),
OrgsListCustomPropertiesValuesForReposError::Status404(_) => (String::from("Resource not found"), 404),
OrgsListCustomPropertiesValuesForReposError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List failed organization invitations](Orgs::list_failed_invitations_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsListFailedInvitationsError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsListFailedInvitationsError> for AdapterError {
fn from(err: OrgsListFailedInvitationsError) -> Self {
let (description, status_code) = match err {
OrgsListFailedInvitationsError::Status404(_) => (String::from("Resource not found"), 404),
OrgsListFailedInvitationsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List organizations for the authenticated user](Orgs::list_for_authenticated_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsListForAuthenticatedUserError {
#[error("Not modified")]
Status304,
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsListForAuthenticatedUserError> for AdapterError {
fn from(err: OrgsListForAuthenticatedUserError) -> Self {
let (description, status_code) = match err {
OrgsListForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304),
OrgsListForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403),
OrgsListForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401),
OrgsListForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List organizations for a user](Orgs::list_for_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsListForUserError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsListForUserError> for AdapterError {
fn from(err: OrgsListForUserError) -> Self {
let (description, status_code) = match err {
OrgsListForUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List organization invitation teams](Orgs::list_invitation_teams_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsListInvitationTeamsError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsListInvitationTeamsError> for AdapterError {
fn from(err: OrgsListInvitationTeamsError) -> Self {
let (description, status_code) = match err {
OrgsListInvitationTeamsError::Status404(_) => (String::from("Resource not found"), 404),
OrgsListInvitationTeamsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List issue types for an organization](Orgs::list_issue_types_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsListIssueTypesError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsListIssueTypesError> for AdapterError {
fn from(err: OrgsListIssueTypesError) -> Self {
let (description, status_code) = match err {
OrgsListIssueTypesError::Status404(_) => (String::from("Resource not found"), 404),
OrgsListIssueTypesError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List organization members](Orgs::list_members_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsListMembersError {
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsListMembersError> for AdapterError {
fn from(err: OrgsListMembersError) -> Self {
let (description, status_code) = match err {
OrgsListMembersError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
OrgsListMembersError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List organization memberships for the authenticated user](Orgs::list_memberships_for_authenticated_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsListMembershipsForAuthenticatedUserError {
#[error("Not modified")]
Status304,
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsListMembershipsForAuthenticatedUserError> for AdapterError {
fn from(err: OrgsListMembershipsForAuthenticatedUserError) -> Self {
let (description, status_code) = match err {
OrgsListMembershipsForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304),
OrgsListMembershipsForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403),
OrgsListMembershipsForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401),
OrgsListMembershipsForAuthenticatedUserError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
OrgsListMembershipsForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List teams that are assigned to an organization role](Orgs::list_org_role_teams_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsListOrgRoleTeamsError {
#[error("Response if the organization or role does not exist.")]
Status404,
#[error("Response if the organization roles feature is not enabled or validation failed.")]
Status422,
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsListOrgRoleTeamsError> for AdapterError {
fn from(err: OrgsListOrgRoleTeamsError) -> Self {
let (description, status_code) = match err {
OrgsListOrgRoleTeamsError::Status404 => (String::from("Response if the organization or role does not exist."), 404),
OrgsListOrgRoleTeamsError::Status422 => (String::from("Response if the organization roles feature is not enabled or validation failed."), 422),
OrgsListOrgRoleTeamsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List users that are assigned to an organization role](Orgs::list_org_role_users_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsListOrgRoleUsersError {
#[error("Response if the organization or role does not exist.")]
Status404,
#[error("Response if the organization roles feature is not enabled or validation failed.")]
Status422,
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsListOrgRoleUsersError> for AdapterError {
fn from(err: OrgsListOrgRoleUsersError) -> Self {
let (description, status_code) = match err {
OrgsListOrgRoleUsersError::Status404 => (String::from("Response if the organization or role does not exist."), 404),
OrgsListOrgRoleUsersError::Status422 => (String::from("Response if the organization roles feature is not enabled or validation failed."), 422),
OrgsListOrgRoleUsersError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get all organization roles for an organization](Orgs::list_org_roles_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsListOrgRolesError {
#[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<OrgsListOrgRolesError> for AdapterError {
fn from(err: OrgsListOrgRolesError) -> Self {
let (description, status_code) = match err {
OrgsListOrgRolesError::Status404(_) => (String::from("Resource not found"), 404),
OrgsListOrgRolesError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
OrgsListOrgRolesError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List outside collaborators for an organization](Orgs::list_outside_collaborators_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsListOutsideCollaboratorsError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsListOutsideCollaboratorsError> for AdapterError {
fn from(err: OrgsListOutsideCollaboratorsError) -> Self {
let (description, status_code) = match err {
OrgsListOutsideCollaboratorsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List repositories a fine-grained personal access token has access to](Orgs::list_pat_grant_repositories_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsListPatGrantRepositoriesError {
#[error("Internal Error")]
Status500(BasicError),
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsListPatGrantRepositoriesError> for AdapterError {
fn from(err: OrgsListPatGrantRepositoriesError) -> Self {
let (description, status_code) = match err {
OrgsListPatGrantRepositoriesError::Status500(_) => (String::from("Internal Error"), 500),
OrgsListPatGrantRepositoriesError::Status404(_) => (String::from("Resource not found"), 404),
OrgsListPatGrantRepositoriesError::Status403(_) => (String::from("Forbidden"), 403),
OrgsListPatGrantRepositoriesError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List repositories requested to be accessed by a fine-grained personal access token](Orgs::list_pat_grant_request_repositories_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsListPatGrantRequestRepositoriesError {
#[error("Internal Error")]
Status500(BasicError),
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsListPatGrantRequestRepositoriesError> for AdapterError {
fn from(err: OrgsListPatGrantRequestRepositoriesError) -> Self {
let (description, status_code) = match err {
OrgsListPatGrantRequestRepositoriesError::Status500(_) => (String::from("Internal Error"), 500),
OrgsListPatGrantRequestRepositoriesError::Status404(_) => (String::from("Resource not found"), 404),
OrgsListPatGrantRequestRepositoriesError::Status403(_) => (String::from("Forbidden"), 403),
OrgsListPatGrantRequestRepositoriesError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List requests to access organization resources with fine-grained personal access tokens](Orgs::list_pat_grant_requests_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsListPatGrantRequestsError {
#[error("Internal Error")]
Status500(BasicError),
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsListPatGrantRequestsError> for AdapterError {
fn from(err: OrgsListPatGrantRequestsError) -> Self {
let (description, status_code) = match err {
OrgsListPatGrantRequestsError::Status500(_) => (String::from("Internal Error"), 500),
OrgsListPatGrantRequestsError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
OrgsListPatGrantRequestsError::Status404(_) => (String::from("Resource not found"), 404),
OrgsListPatGrantRequestsError::Status403(_) => (String::from("Forbidden"), 403),
OrgsListPatGrantRequestsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List fine-grained personal access tokens with access to organization resources](Orgs::list_pat_grants_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsListPatGrantsError {
#[error("Internal Error")]
Status500(BasicError),
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsListPatGrantsError> for AdapterError {
fn from(err: OrgsListPatGrantsError) -> Self {
let (description, status_code) = match err {
OrgsListPatGrantsError::Status500(_) => (String::from("Internal Error"), 500),
OrgsListPatGrantsError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
OrgsListPatGrantsError::Status404(_) => (String::from("Resource not found"), 404),
OrgsListPatGrantsError::Status403(_) => (String::from("Forbidden"), 403),
OrgsListPatGrantsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List pending organization invitations](Orgs::list_pending_invitations_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsListPendingInvitationsError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsListPendingInvitationsError> for AdapterError {
fn from(err: OrgsListPendingInvitationsError) -> Self {
let (description, status_code) = match err {
OrgsListPendingInvitationsError::Status404(_) => (String::from("Resource not found"), 404),
OrgsListPendingInvitationsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List public organization members](Orgs::list_public_members_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsListPublicMembersError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsListPublicMembersError> for AdapterError {
fn from(err: OrgsListPublicMembersError) -> Self {
let (description, status_code) = match err {
OrgsListPublicMembersError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List security manager teams](Orgs::list_security_manager_teams_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsListSecurityManagerTeamsError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsListSecurityManagerTeamsError> for AdapterError {
fn from(err: OrgsListSecurityManagerTeamsError) -> Self {
let (description, status_code) = match err {
OrgsListSecurityManagerTeamsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List deliveries for an organization webhook](Orgs::list_webhook_deliveries_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsListWebhookDeliveriesError {
#[error("Bad Request")]
Status400(BasicError),
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsListWebhookDeliveriesError> for AdapterError {
fn from(err: OrgsListWebhookDeliveriesError) -> Self {
let (description, status_code) = match err {
OrgsListWebhookDeliveriesError::Status400(_) => (String::from("Bad Request"), 400),
OrgsListWebhookDeliveriesError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
OrgsListWebhookDeliveriesError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List organization webhooks](Orgs::list_webhooks_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsListWebhooksError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsListWebhooksError> for AdapterError {
fn from(err: OrgsListWebhooksError) -> Self {
let (description, status_code) = match err {
OrgsListWebhooksError::Status404(_) => (String::from("Resource not found"), 404),
OrgsListWebhooksError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Ping an organization webhook](Orgs::ping_webhook_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsPingWebhookError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsPingWebhookError> for AdapterError {
fn from(err: OrgsPingWebhookError) -> Self {
let (description, status_code) = match err {
OrgsPingWebhookError::Status404(_) => (String::from("Resource not found"), 404),
OrgsPingWebhookError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Redeliver a delivery for an organization webhook](Orgs::redeliver_webhook_delivery_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsRedeliverWebhookDeliveryError {
#[error("Bad Request")]
Status400(BasicError),
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsRedeliverWebhookDeliveryError> for AdapterError {
fn from(err: OrgsRedeliverWebhookDeliveryError) -> Self {
let (description, status_code) = match err {
OrgsRedeliverWebhookDeliveryError::Status400(_) => (String::from("Bad Request"), 400),
OrgsRedeliverWebhookDeliveryError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
OrgsRedeliverWebhookDeliveryError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Remove a custom property for an organization](Orgs::remove_custom_property_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsRemoveCustomPropertyError {
#[error("Forbidden")]
Status403(BasicError),
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsRemoveCustomPropertyError> for AdapterError {
fn from(err: OrgsRemoveCustomPropertyError) -> Self {
let (description, status_code) = match err {
OrgsRemoveCustomPropertyError::Status403(_) => (String::from("Forbidden"), 403),
OrgsRemoveCustomPropertyError::Status404(_) => (String::from("Resource not found"), 404),
OrgsRemoveCustomPropertyError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Remove an organization member](Orgs::remove_member_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsRemoveMemberError {
#[error("Forbidden")]
Status403(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsRemoveMemberError> for AdapterError {
fn from(err: OrgsRemoveMemberError) -> Self {
let (description, status_code) = match err {
OrgsRemoveMemberError::Status403(_) => (String::from("Forbidden"), 403),
OrgsRemoveMemberError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Remove organization membership for a user](Orgs::remove_membership_for_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsRemoveMembershipForUserError {
#[error("Forbidden")]
Status403(BasicError),
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsRemoveMembershipForUserError> for AdapterError {
fn from(err: OrgsRemoveMembershipForUserError) -> Self {
let (description, status_code) = match err {
OrgsRemoveMembershipForUserError::Status403(_) => (String::from("Forbidden"), 403),
OrgsRemoveMembershipForUserError::Status404(_) => (String::from("Resource not found"), 404),
OrgsRemoveMembershipForUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Remove outside collaborator from an organization](Orgs::remove_outside_collaborator_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsRemoveOutsideCollaboratorError {
#[error("Unprocessable Entity if user is a member of the organization")]
Status422(PutTeamsAddOrUpdateProjectPermissionsLegacyResponse403),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsRemoveOutsideCollaboratorError> for AdapterError {
fn from(err: OrgsRemoveOutsideCollaboratorError) -> Self {
let (description, status_code) = match err {
OrgsRemoveOutsideCollaboratorError::Status422(_) => (String::from("Unprocessable Entity if user is a member of the organization"), 422),
OrgsRemoveOutsideCollaboratorError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Remove public organization membership for the authenticated user](Orgs::remove_public_membership_for_authenticated_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsRemovePublicMembershipForAuthenticatedUserError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsRemovePublicMembershipForAuthenticatedUserError> for AdapterError {
fn from(err: OrgsRemovePublicMembershipForAuthenticatedUserError) -> Self {
let (description, status_code) = match err {
OrgsRemovePublicMembershipForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Remove a security manager team](Orgs::remove_security_manager_team_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsRemoveSecurityManagerTeamError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsRemoveSecurityManagerTeamError> for AdapterError {
fn from(err: OrgsRemoveSecurityManagerTeamError) -> Self {
let (description, status_code) = match err {
OrgsRemoveSecurityManagerTeamError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Review a request to access organization resources with a fine-grained personal access token](Orgs::review_pat_grant_request_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsReviewPatGrantRequestError {
#[error("Internal Error")]
Status500(BasicError),
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsReviewPatGrantRequestError> for AdapterError {
fn from(err: OrgsReviewPatGrantRequestError) -> Self {
let (description, status_code) = match err {
OrgsReviewPatGrantRequestError::Status500(_) => (String::from("Internal Error"), 500),
OrgsReviewPatGrantRequestError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
OrgsReviewPatGrantRequestError::Status404(_) => (String::from("Resource not found"), 404),
OrgsReviewPatGrantRequestError::Status403(_) => (String::from("Forbidden"), 403),
OrgsReviewPatGrantRequestError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Review requests to access organization resources with fine-grained personal access tokens](Orgs::review_pat_grant_requests_in_bulk_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsReviewPatGrantRequestsInBulkError {
#[error("Internal Error")]
Status500(BasicError),
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsReviewPatGrantRequestsInBulkError> for AdapterError {
fn from(err: OrgsReviewPatGrantRequestsInBulkError) -> Self {
let (description, status_code) = match err {
OrgsReviewPatGrantRequestsInBulkError::Status500(_) => (String::from("Internal Error"), 500),
OrgsReviewPatGrantRequestsInBulkError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
OrgsReviewPatGrantRequestsInBulkError::Status404(_) => (String::from("Resource not found"), 404),
OrgsReviewPatGrantRequestsInBulkError::Status403(_) => (String::from("Forbidden"), 403),
OrgsReviewPatGrantRequestsInBulkError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Remove all organization roles for a team](Orgs::revoke_all_org_roles_team_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsRevokeAllOrgRolesTeamError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsRevokeAllOrgRolesTeamError> for AdapterError {
fn from(err: OrgsRevokeAllOrgRolesTeamError) -> Self {
let (description, status_code) = match err {
OrgsRevokeAllOrgRolesTeamError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Remove all organization roles for a user](Orgs::revoke_all_org_roles_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsRevokeAllOrgRolesUserError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsRevokeAllOrgRolesUserError> for AdapterError {
fn from(err: OrgsRevokeAllOrgRolesUserError) -> Self {
let (description, status_code) = match err {
OrgsRevokeAllOrgRolesUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Remove an organization role from a team](Orgs::revoke_org_role_team_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsRevokeOrgRoleTeamError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsRevokeOrgRoleTeamError> for AdapterError {
fn from(err: OrgsRevokeOrgRoleTeamError) -> Self {
let (description, status_code) = match err {
OrgsRevokeOrgRoleTeamError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Remove an organization role from a user](Orgs::revoke_org_role_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsRevokeOrgRoleUserError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsRevokeOrgRoleUserError> for AdapterError {
fn from(err: OrgsRevokeOrgRoleUserError) -> Self {
let (description, status_code) = match err {
OrgsRevokeOrgRoleUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Set organization membership for a user](Orgs::set_membership_for_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsSetMembershipForUserError {
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsSetMembershipForUserError> for AdapterError {
fn from(err: OrgsSetMembershipForUserError) -> Self {
let (description, status_code) = match err {
OrgsSetMembershipForUserError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
OrgsSetMembershipForUserError::Status403(_) => (String::from("Forbidden"), 403),
OrgsSetMembershipForUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Set public organization membership for the authenticated user](Orgs::set_public_membership_for_authenticated_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsSetPublicMembershipForAuthenticatedUserError {
#[error("Forbidden")]
Status403(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsSetPublicMembershipForAuthenticatedUserError> for AdapterError {
fn from(err: OrgsSetPublicMembershipForAuthenticatedUserError) -> Self {
let (description, status_code) = match err {
OrgsSetPublicMembershipForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403),
OrgsSetPublicMembershipForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Unblock a user from an organization](Orgs::unblock_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsUnblockUserError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsUnblockUserError> for AdapterError {
fn from(err: OrgsUnblockUserError) -> Self {
let (description, status_code) = match err {
OrgsUnblockUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Update an organization](Orgs::update_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsUpdateError {
#[error("Validation failed")]
Status422(PostProjectsClassicCreateCardResponse422),
#[error("Conflict")]
Status409(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsUpdateError> for AdapterError {
fn from(err: OrgsUpdateError) -> Self {
let (description, status_code) = match err {
OrgsUpdateError::Status422(_) => (String::from("Validation failed"), 422),
OrgsUpdateError::Status409(_) => (String::from("Conflict"), 409),
OrgsUpdateError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Update issue type for an organization](Orgs::update_issue_type_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsUpdateIssueTypeError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationErrorSimple),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsUpdateIssueTypeError> for AdapterError {
fn from(err: OrgsUpdateIssueTypeError) -> Self {
let (description, status_code) = match err {
OrgsUpdateIssueTypeError::Status404(_) => (String::from("Resource not found"), 404),
OrgsUpdateIssueTypeError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
OrgsUpdateIssueTypeError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Update an organization membership for the authenticated user](Orgs::update_membership_for_authenticated_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsUpdateMembershipForAuthenticatedUserError {
#[error("Forbidden")]
Status403(BasicError),
#[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<OrgsUpdateMembershipForAuthenticatedUserError> for AdapterError {
fn from(err: OrgsUpdateMembershipForAuthenticatedUserError) -> Self {
let (description, status_code) = match err {
OrgsUpdateMembershipForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403),
OrgsUpdateMembershipForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404),
OrgsUpdateMembershipForAuthenticatedUserError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
OrgsUpdateMembershipForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Update the access a fine-grained personal access token has to organization resources](Orgs::update_pat_access_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsUpdatePatAccessError {
#[error("Internal Error")]
Status500(BasicError),
#[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<OrgsUpdatePatAccessError> for AdapterError {
fn from(err: OrgsUpdatePatAccessError) -> Self {
let (description, status_code) = match err {
OrgsUpdatePatAccessError::Status500(_) => (String::from("Internal Error"), 500),
OrgsUpdatePatAccessError::Status404(_) => (String::from("Resource not found"), 404),
OrgsUpdatePatAccessError::Status403(_) => (String::from("Forbidden"), 403),
OrgsUpdatePatAccessError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
OrgsUpdatePatAccessError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Update the access to organization resources via fine-grained personal access tokens](Orgs::update_pat_accesses_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsUpdatePatAccessesError {
#[error("Internal Error")]
Status500(BasicError),
#[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<OrgsUpdatePatAccessesError> for AdapterError {
fn from(err: OrgsUpdatePatAccessesError) -> Self {
let (description, status_code) = match err {
OrgsUpdatePatAccessesError::Status500(_) => (String::from("Internal Error"), 500),
OrgsUpdatePatAccessesError::Status404(_) => (String::from("Resource not found"), 404),
OrgsUpdatePatAccessesError::Status403(_) => (String::from("Forbidden"), 403),
OrgsUpdatePatAccessesError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
OrgsUpdatePatAccessesError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Update an organization webhook](Orgs::update_webhook_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsUpdateWebhookError {
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsUpdateWebhookError> for AdapterError {
fn from(err: OrgsUpdateWebhookError) -> Self {
let (description, status_code) = match err {
OrgsUpdateWebhookError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
OrgsUpdateWebhookError::Status404(_) => (String::from("Resource not found"), 404),
OrgsUpdateWebhookError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Update a webhook configuration for an organization](Orgs::update_webhook_config_for_org_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum OrgsUpdateWebhookConfigForOrgError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<OrgsUpdateWebhookConfigForOrgError> for AdapterError {
fn from(err: OrgsUpdateWebhookConfigForOrgError) -> Self {
let (description, status_code) = match err {
OrgsUpdateWebhookConfigForOrgError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Query parameters for the [Get organization ruleset history](Orgs::get_org_ruleset_history_async()) endpoint.
#[derive(Default, Serialize)]
pub struct OrgsGetOrgRulesetHistoryParams {
/// 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 OrgsGetOrgRulesetHistoryParams {
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 OrgsGetOrgRulesetHistoryParams {
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 [Get route stats by actor](Orgs::get_route_stats_by_actor_async()) endpoint.
#[derive(Default, Serialize)]
pub struct OrgsGetRouteStatsByActorParams<'req> {
/// The minimum timestamp to query for stats. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
min_timestamp: &'req str,
/// The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
max_timestamp: Option<&'req str>,
/// 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>,
/// 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 direction to sort the results by.
direction: Option<&'req str>,
/// The property to sort the results by.
sort: Option<Vec<String>>,
/// Providing a substring will filter results where the API route contains the substring. This is a case-insensitive search.
api_route_substring: Option<&'req str>
}
impl<'req> OrgsGetRouteStatsByActorParams<'req> {
pub fn new() -> Self {
Self::default()
}
/// The minimum timestamp to query for stats. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
pub fn min_timestamp(self, min_timestamp: &'req str) -> Self {
Self {
min_timestamp: min_timestamp,
max_timestamp: self.max_timestamp,
page: self.page,
per_page: self.per_page,
direction: self.direction,
sort: self.sort,
api_route_substring: self.api_route_substring,
}
}
/// The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
pub fn max_timestamp(self, max_timestamp: &'req str) -> Self {
Self {
min_timestamp: self.min_timestamp,
max_timestamp: Some(max_timestamp),
page: self.page,
per_page: self.per_page,
direction: self.direction,
sort: self.sort,
api_route_substring: self.api_route_substring,
}
}
/// 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 {
min_timestamp: self.min_timestamp,
max_timestamp: self.max_timestamp,
page: Some(page),
per_page: self.per_page,
direction: self.direction,
sort: self.sort,
api_route_substring: self.api_route_substring,
}
}
/// 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 {
min_timestamp: self.min_timestamp,
max_timestamp: self.max_timestamp,
page: self.page,
per_page: Some(per_page),
direction: self.direction,
sort: self.sort,
api_route_substring: self.api_route_substring,
}
}
/// The direction to sort the results by.
pub fn direction(self, direction: &'req str) -> Self {
Self {
min_timestamp: self.min_timestamp,
max_timestamp: self.max_timestamp,
page: self.page,
per_page: self.per_page,
direction: Some(direction),
sort: self.sort,
api_route_substring: self.api_route_substring,
}
}
/// The property to sort the results by.
pub fn sort(self, sort: Vec<String>) -> Self {
Self {
min_timestamp: self.min_timestamp,
max_timestamp: self.max_timestamp,
page: self.page,
per_page: self.per_page,
direction: self.direction,
sort: Some(sort),
api_route_substring: self.api_route_substring,
}
}
/// Providing a substring will filter results where the API route contains the substring. This is a case-insensitive search.
pub fn api_route_substring(self, api_route_substring: &'req str) -> Self {
Self {
min_timestamp: self.min_timestamp,
max_timestamp: self.max_timestamp,
page: self.page,
per_page: self.per_page,
direction: self.direction,
sort: self.sort,
api_route_substring: Some(api_route_substring),
}
}
}
impl<'enc> From<&'enc PerPage> for OrgsGetRouteStatsByActorParams<'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 [Get subject stats](Orgs::get_subject_stats_async()) endpoint.
#[derive(Default, Serialize)]
pub struct OrgsGetSubjectStatsParams<'req> {
/// The minimum timestamp to query for stats. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
min_timestamp: &'req str,
/// The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
max_timestamp: Option<&'req str>,
/// 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>,
/// 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 direction to sort the results by.
direction: Option<&'req str>,
/// The property to sort the results by.
sort: Option<Vec<String>>,
/// Providing a substring will filter results where the subject name contains the substring. This is a case-insensitive search.
subject_name_substring: Option<&'req str>
}
impl<'req> OrgsGetSubjectStatsParams<'req> {
pub fn new() -> Self {
Self::default()
}
/// The minimum timestamp to query for stats. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
pub fn min_timestamp(self, min_timestamp: &'req str) -> Self {
Self {
min_timestamp: min_timestamp,
max_timestamp: self.max_timestamp,
page: self.page,
per_page: self.per_page,
direction: self.direction,
sort: self.sort,
subject_name_substring: self.subject_name_substring,
}
}
/// The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
pub fn max_timestamp(self, max_timestamp: &'req str) -> Self {
Self {
min_timestamp: self.min_timestamp,
max_timestamp: Some(max_timestamp),
page: self.page,
per_page: self.per_page,
direction: self.direction,
sort: self.sort,
subject_name_substring: self.subject_name_substring,
}
}
/// 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 {
min_timestamp: self.min_timestamp,
max_timestamp: self.max_timestamp,
page: Some(page),
per_page: self.per_page,
direction: self.direction,
sort: self.sort,
subject_name_substring: self.subject_name_substring,
}
}
/// 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 {
min_timestamp: self.min_timestamp,
max_timestamp: self.max_timestamp,
page: self.page,
per_page: Some(per_page),
direction: self.direction,
sort: self.sort,
subject_name_substring: self.subject_name_substring,
}
}
/// The direction to sort the results by.
pub fn direction(self, direction: &'req str) -> Self {
Self {
min_timestamp: self.min_timestamp,
max_timestamp: self.max_timestamp,
page: self.page,
per_page: self.per_page,
direction: Some(direction),
sort: self.sort,
subject_name_substring: self.subject_name_substring,
}
}
/// The property to sort the results by.
pub fn sort(self, sort: Vec<String>) -> Self {
Self {
min_timestamp: self.min_timestamp,
max_timestamp: self.max_timestamp,
page: self.page,
per_page: self.per_page,
direction: self.direction,
sort: Some(sort),
subject_name_substring: self.subject_name_substring,
}
}
/// Providing a substring will filter results where the subject name contains the substring. This is a case-insensitive search.
pub fn subject_name_substring(self, subject_name_substring: &'req str) -> Self {
Self {
min_timestamp: self.min_timestamp,
max_timestamp: self.max_timestamp,
page: self.page,
per_page: self.per_page,
direction: self.direction,
sort: self.sort,
subject_name_substring: Some(subject_name_substring),
}
}
}
impl<'enc> From<&'enc PerPage> for OrgsGetSubjectStatsParams<'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 [Get summary stats](Orgs::get_summary_stats_async()) endpoint.
#[derive(Default, Serialize)]
pub struct OrgsGetSummaryStatsParams<'req> {
/// The minimum timestamp to query for stats. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
min_timestamp: &'req str,
/// The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
max_timestamp: Option<&'req str>
}
impl<'req> OrgsGetSummaryStatsParams<'req> {
pub fn new() -> Self {
Self::default()
}
/// The minimum timestamp to query for stats. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
pub fn min_timestamp(self, min_timestamp: &'req str) -> Self {
Self {
min_timestamp: min_timestamp,
max_timestamp: self.max_timestamp,
}
}
/// The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
pub fn max_timestamp(self, max_timestamp: &'req str) -> Self {
Self {
min_timestamp: self.min_timestamp,
max_timestamp: Some(max_timestamp),
}
}
}
/// Query parameters for the [Get summary stats by actor](Orgs::get_summary_stats_by_actor_async()) endpoint.
#[derive(Default, Serialize)]
pub struct OrgsGetSummaryStatsByActorParams<'req> {
/// The minimum timestamp to query for stats. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
min_timestamp: &'req str,
/// The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
max_timestamp: Option<&'req str>
}
impl<'req> OrgsGetSummaryStatsByActorParams<'req> {
pub fn new() -> Self {
Self::default()
}
/// The minimum timestamp to query for stats. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
pub fn min_timestamp(self, min_timestamp: &'req str) -> Self {
Self {
min_timestamp: min_timestamp,
max_timestamp: self.max_timestamp,
}
}
/// The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
pub fn max_timestamp(self, max_timestamp: &'req str) -> Self {
Self {
min_timestamp: self.min_timestamp,
max_timestamp: Some(max_timestamp),
}
}
}
/// Query parameters for the [Get summary stats by user](Orgs::get_summary_stats_by_user_async()) endpoint.
#[derive(Default, Serialize)]
pub struct OrgsGetSummaryStatsByUserParams<'req> {
/// The minimum timestamp to query for stats. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
min_timestamp: &'req str,
/// The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
max_timestamp: Option<&'req str>
}
impl<'req> OrgsGetSummaryStatsByUserParams<'req> {
pub fn new() -> Self {
Self::default()
}
/// The minimum timestamp to query for stats. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
pub fn min_timestamp(self, min_timestamp: &'req str) -> Self {
Self {
min_timestamp: min_timestamp,
max_timestamp: self.max_timestamp,
}
}
/// The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
pub fn max_timestamp(self, max_timestamp: &'req str) -> Self {
Self {
min_timestamp: self.min_timestamp,
max_timestamp: Some(max_timestamp),
}
}
}
/// Query parameters for the [Get time stats](Orgs::get_time_stats_async()) endpoint.
#[derive(Default, Serialize)]
pub struct OrgsGetTimeStatsParams<'req> {
/// The minimum timestamp to query for stats. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
min_timestamp: &'req str,
/// The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
max_timestamp: Option<&'req str>,
/// The increment of time used to breakdown the query results (5m, 10m, 1h, etc.)
timestamp_increment: &'req str
}
impl<'req> OrgsGetTimeStatsParams<'req> {
pub fn new() -> Self {
Self::default()
}
/// The minimum timestamp to query for stats. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
pub fn min_timestamp(self, min_timestamp: &'req str) -> Self {
Self {
min_timestamp: min_timestamp,
max_timestamp: self.max_timestamp,
timestamp_increment: self.timestamp_increment,
}
}
/// The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
pub fn max_timestamp(self, max_timestamp: &'req str) -> Self {
Self {
min_timestamp: self.min_timestamp,
max_timestamp: Some(max_timestamp),
timestamp_increment: self.timestamp_increment,
}
}
/// The increment of time used to breakdown the query results (5m, 10m, 1h, etc.)
pub fn timestamp_increment(self, timestamp_increment: &'req str) -> Self {
Self {
min_timestamp: self.min_timestamp,
max_timestamp: self.max_timestamp,
timestamp_increment: timestamp_increment,
}
}
}
/// Query parameters for the [Get time stats by actor](Orgs::get_time_stats_by_actor_async()) endpoint.
#[derive(Default, Serialize)]
pub struct OrgsGetTimeStatsByActorParams<'req> {
/// The minimum timestamp to query for stats. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
min_timestamp: &'req str,
/// The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
max_timestamp: Option<&'req str>,
/// The increment of time used to breakdown the query results (5m, 10m, 1h, etc.)
timestamp_increment: &'req str
}
impl<'req> OrgsGetTimeStatsByActorParams<'req> {
pub fn new() -> Self {
Self::default()
}
/// The minimum timestamp to query for stats. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
pub fn min_timestamp(self, min_timestamp: &'req str) -> Self {
Self {
min_timestamp: min_timestamp,
max_timestamp: self.max_timestamp,
timestamp_increment: self.timestamp_increment,
}
}
/// The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
pub fn max_timestamp(self, max_timestamp: &'req str) -> Self {
Self {
min_timestamp: self.min_timestamp,
max_timestamp: Some(max_timestamp),
timestamp_increment: self.timestamp_increment,
}
}
/// The increment of time used to breakdown the query results (5m, 10m, 1h, etc.)
pub fn timestamp_increment(self, timestamp_increment: &'req str) -> Self {
Self {
min_timestamp: self.min_timestamp,
max_timestamp: self.max_timestamp,
timestamp_increment: timestamp_increment,
}
}
}
/// Query parameters for the [Get time stats by user](Orgs::get_time_stats_by_user_async()) endpoint.
#[derive(Default, Serialize)]
pub struct OrgsGetTimeStatsByUserParams<'req> {
/// The minimum timestamp to query for stats. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
min_timestamp: &'req str,
/// The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
max_timestamp: Option<&'req str>,
/// The increment of time used to breakdown the query results (5m, 10m, 1h, etc.)
timestamp_increment: &'req str
}
impl<'req> OrgsGetTimeStatsByUserParams<'req> {
pub fn new() -> Self {
Self::default()
}
/// The minimum timestamp to query for stats. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
pub fn min_timestamp(self, min_timestamp: &'req str) -> Self {
Self {
min_timestamp: min_timestamp,
max_timestamp: self.max_timestamp,
timestamp_increment: self.timestamp_increment,
}
}
/// The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
pub fn max_timestamp(self, max_timestamp: &'req str) -> Self {
Self {
min_timestamp: self.min_timestamp,
max_timestamp: Some(max_timestamp),
timestamp_increment: self.timestamp_increment,
}
}
/// The increment of time used to breakdown the query results (5m, 10m, 1h, etc.)
pub fn timestamp_increment(self, timestamp_increment: &'req str) -> Self {
Self {
min_timestamp: self.min_timestamp,
max_timestamp: self.max_timestamp,
timestamp_increment: timestamp_increment,
}
}
}
/// Query parameters for the [Get user stats](Orgs::get_user_stats_async()) endpoint.
#[derive(Default, Serialize)]
pub struct OrgsGetUserStatsParams<'req> {
/// The minimum timestamp to query for stats. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
min_timestamp: &'req str,
/// The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
max_timestamp: Option<&'req str>,
/// 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>,
/// 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 direction to sort the results by.
direction: Option<&'req str>,
/// The property to sort the results by.
sort: Option<Vec<String>>,
/// Providing a substring will filter results where the actor name contains the substring. This is a case-insensitive search.
actor_name_substring: Option<&'req str>
}
impl<'req> OrgsGetUserStatsParams<'req> {
pub fn new() -> Self {
Self::default()
}
/// The minimum timestamp to query for stats. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
pub fn min_timestamp(self, min_timestamp: &'req str) -> Self {
Self {
min_timestamp: min_timestamp,
max_timestamp: self.max_timestamp,
page: self.page,
per_page: self.per_page,
direction: self.direction,
sort: self.sort,
actor_name_substring: self.actor_name_substring,
}
}
/// The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
pub fn max_timestamp(self, max_timestamp: &'req str) -> Self {
Self {
min_timestamp: self.min_timestamp,
max_timestamp: Some(max_timestamp),
page: self.page,
per_page: self.per_page,
direction: self.direction,
sort: self.sort,
actor_name_substring: self.actor_name_substring,
}
}
/// 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 {
min_timestamp: self.min_timestamp,
max_timestamp: self.max_timestamp,
page: Some(page),
per_page: self.per_page,
direction: self.direction,
sort: self.sort,
actor_name_substring: self.actor_name_substring,
}
}
/// 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 {
min_timestamp: self.min_timestamp,
max_timestamp: self.max_timestamp,
page: self.page,
per_page: Some(per_page),
direction: self.direction,
sort: self.sort,
actor_name_substring: self.actor_name_substring,
}
}
/// The direction to sort the results by.
pub fn direction(self, direction: &'req str) -> Self {
Self {
min_timestamp: self.min_timestamp,
max_timestamp: self.max_timestamp,
page: self.page,
per_page: self.per_page,
direction: Some(direction),
sort: self.sort,
actor_name_substring: self.actor_name_substring,
}
}
/// The property to sort the results by.
pub fn sort(self, sort: Vec<String>) -> Self {
Self {
min_timestamp: self.min_timestamp,
max_timestamp: self.max_timestamp,
page: self.page,
per_page: self.per_page,
direction: self.direction,
sort: Some(sort),
actor_name_substring: self.actor_name_substring,
}
}
/// Providing a substring will filter results where the actor name contains the substring. This is a case-insensitive search.
pub fn actor_name_substring(self, actor_name_substring: &'req str) -> Self {
Self {
min_timestamp: self.min_timestamp,
max_timestamp: self.max_timestamp,
page: self.page,
per_page: self.per_page,
direction: self.direction,
sort: self.sort,
actor_name_substring: Some(actor_name_substring),
}
}
}
impl<'enc> From<&'enc PerPage> for OrgsGetUserStatsParams<'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 organizations](Orgs::list_async()) endpoint.
#[derive(Default, Serialize)]
pub struct OrgsListParams {
/// An organization ID. Only return organizations with an ID greater than this ID.
since: Option<i32>,
/// 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>
}
impl OrgsListParams {
pub fn new() -> Self {
Self::default()
}
/// An organization ID. Only return organizations with an ID greater than this ID.
pub fn since(self, since: i32) -> Self {
Self {
since: Some(since),
per_page: self.per_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 {
since: self.since,
per_page: Some(per_page),
}
}
}
/// Query parameters for the [List app installations for an organization](Orgs::list_app_installations_async()) endpoint.
#[derive(Default, Serialize)]
pub struct OrgsListAppInstallationsParams {
/// 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 OrgsListAppInstallationsParams {
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 OrgsListAppInstallationsParams {
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 attestations](Orgs::list_attestations_async()) endpoint.
#[derive(Default, Serialize)]
pub struct OrgsListAttestationsParams<'req> {
/// 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>,
/// A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results before this cursor. 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).\"
before: Option<&'req str>,
/// A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results after this cursor. 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).\"
after: Option<&'req str>,
/// Optional filter for fetching attestations with a given predicate type. This option accepts `provenance`, `sbom`, or freeform text for custom predicate types.
predicate_type: Option<&'req str>
}
impl<'req> OrgsListAttestationsParams<'req> {
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),
before: self.before,
after: self.after,
predicate_type: self.predicate_type,
}
}
/// A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results before this cursor. 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 before(self, before: &'req str) -> Self {
Self {
per_page: self.per_page,
before: Some(before),
after: self.after,
predicate_type: self.predicate_type,
}
}
/// A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results after this cursor. 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 after(self, after: &'req str) -> Self {
Self {
per_page: self.per_page,
before: self.before,
after: Some(after),
predicate_type: self.predicate_type,
}
}
/// Optional filter for fetching attestations with a given predicate type. This option accepts `provenance`, `sbom`, or freeform text for custom predicate types.
pub fn predicate_type(self, predicate_type: &'req str) -> Self {
Self {
per_page: self.per_page,
before: self.before,
after: self.after,
predicate_type: Some(predicate_type),
}
}
}
/// Query parameters for the [List attestations by bulk subject digests](Orgs::list_attestations_bulk_async()) endpoint.
#[derive(Default, Serialize)]
pub struct OrgsListAttestationsBulkParams<'req> {
/// 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>,
/// A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results before this cursor. 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).\"
before: Option<&'req str>,
/// A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results after this cursor. 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).\"
after: Option<&'req str>
}
impl<'req> OrgsListAttestationsBulkParams<'req> {
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),
before: self.before,
after: self.after,
}
}
/// A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results before this cursor. 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 before(self, before: &'req str) -> Self {
Self {
per_page: self.per_page,
before: Some(before),
after: self.after,
}
}
/// A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results after this cursor. 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 after(self, after: &'req str) -> Self {
Self {
per_page: self.per_page,
before: self.before,
after: Some(after),
}
}
}
/// Query parameters for the [List users blocked by an organization](Orgs::list_blocked_users_async()) endpoint.
#[derive(Default, Serialize)]
pub struct OrgsListBlockedUsersParams {
/// 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 OrgsListBlockedUsersParams {
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 OrgsListBlockedUsersParams {
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 custom property values for organization repositories](Orgs::list_custom_properties_values_for_repos_async()) endpoint.
#[derive(Default, Serialize)]
pub struct OrgsListCustomPropertiesValuesForReposParams<'req> {
/// 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>,
/// Finds repositories in the organization with a query containing one or more search keywords and qualifiers. Qualifiers allow you to limit your search to specific areas of GitHub. The REST API supports the same qualifiers as the web interface for GitHub. To learn more about the format of the query, see [Constructing a search query](https://docs.github.com/rest/search/search#constructing-a-search-query). See \"[Searching for repositories](https://docs.github.com/articles/searching-for-repositories/)\" for a detailed list of qualifiers.
repository_query: Option<&'req str>
}
impl<'req> OrgsListCustomPropertiesValuesForReposParams<'req> {
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,
repository_query: self.repository_query,
}
}
/// 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),
repository_query: self.repository_query,
}
}
/// Finds repositories in the organization with a query containing one or more search keywords and qualifiers. Qualifiers allow you to limit your search to specific areas of GitHub. The REST API supports the same qualifiers as the web interface for GitHub. To learn more about the format of the query, see [Constructing a search query](https://docs.github.com/rest/search/search#constructing-a-search-query). See \"[Searching for repositories](https://docs.github.com/articles/searching-for-repositories/)\" for a detailed list of qualifiers.
pub fn repository_query(self, repository_query: &'req str) -> Self {
Self {
per_page: self.per_page,
page: self.page,
repository_query: Some(repository_query),
}
}
}
impl<'enc> From<&'enc PerPage> for OrgsListCustomPropertiesValuesForReposParams<'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 failed organization invitations](Orgs::list_failed_invitations_async()) endpoint.
#[derive(Default, Serialize)]
pub struct OrgsListFailedInvitationsParams {
/// 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 OrgsListFailedInvitationsParams {
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 OrgsListFailedInvitationsParams {
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 organizations for the authenticated user](Orgs::list_for_authenticated_user_async()) endpoint.
#[derive(Default, Serialize)]
pub struct OrgsListForAuthenticatedUserParams {
/// 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 OrgsListForAuthenticatedUserParams {
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 OrgsListForAuthenticatedUserParams {
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 organizations for a user](Orgs::list_for_user_async()) endpoint.
#[derive(Default, Serialize)]
pub struct OrgsListForUserParams {
/// 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 OrgsListForUserParams {
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 OrgsListForUserParams {
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 organization invitation teams](Orgs::list_invitation_teams_async()) endpoint.
#[derive(Default, Serialize)]
pub struct OrgsListInvitationTeamsParams {
/// 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 OrgsListInvitationTeamsParams {
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 OrgsListInvitationTeamsParams {
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 organization members](Orgs::list_members_async()) endpoint.
#[derive(Default, Serialize)]
pub struct OrgsListMembersParams<'req> {
/// Filter members returned in the list. `2fa_disabled` means that only members without [two-factor authentication](https://github.com/blog/1614-two-factor-authentication) enabled will be returned. `2fa_insecure` means that only members with [insecure 2FA methods](https://docs.github.com/organizations/keeping-your-organization-secure/managing-two-factor-authentication-for-your-organization/requiring-two-factor-authentication-in-your-organization#requiring-secure-methods-of-two-factor-authentication-in-your-organization) will be returned. These options are only available for organization owners.
filter: Option<&'req str>,
/// Filter members returned by their role.
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> OrgsListMembersParams<'req> {
pub fn new() -> Self {
Self::default()
}
/// Filter members returned in the list. `2fa_disabled` means that only members without [two-factor authentication](https://github.com/blog/1614-two-factor-authentication) enabled will be returned. `2fa_insecure` means that only members with [insecure 2FA methods](https://docs.github.com/organizations/keeping-your-organization-secure/managing-two-factor-authentication-for-your-organization/requiring-two-factor-authentication-in-your-organization#requiring-secure-methods-of-two-factor-authentication-in-your-organization) will be returned. These options are only available for organization owners.
pub fn filter(self, filter: &'req str) -> Self {
Self {
filter: Some(filter),
role: self.role,
per_page: self.per_page,
page: self.page,
}
}
/// Filter members returned by their role.
pub fn role(self, role: &'req str) -> Self {
Self {
filter: self.filter,
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 {
filter: self.filter,
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 {
filter: self.filter,
role: self.role,
per_page: self.per_page,
page: Some(page),
}
}
}
impl<'enc> From<&'enc PerPage> for OrgsListMembersParams<'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 organization memberships for the authenticated user](Orgs::list_memberships_for_authenticated_user_async()) endpoint.
#[derive(Default, Serialize)]
pub struct OrgsListMembershipsForAuthenticatedUserParams<'req> {
/// Indicates the state of the memberships to return. If not specified, the API returns both active and pending memberships.
state: 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> OrgsListMembershipsForAuthenticatedUserParams<'req> {
pub fn new() -> Self {
Self::default()
}
/// Indicates the state of the memberships to return. If not specified, the API returns both active and pending memberships.
pub fn state(self, state: &'req str) -> Self {
Self {
state: Some(state),
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 {
state: self.state,
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 {
state: self.state,
per_page: self.per_page,
page: Some(page),
}
}
}
impl<'enc> From<&'enc PerPage> for OrgsListMembershipsForAuthenticatedUserParams<'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 that are assigned to an organization role](Orgs::list_org_role_teams_async()) endpoint.
#[derive(Default, Serialize)]
pub struct OrgsListOrgRoleTeamsParams {
/// 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 OrgsListOrgRoleTeamsParams {
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 OrgsListOrgRoleTeamsParams {
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 users that are assigned to an organization role](Orgs::list_org_role_users_async()) endpoint.
#[derive(Default, Serialize)]
pub struct OrgsListOrgRoleUsersParams {
/// 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 OrgsListOrgRoleUsersParams {
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 OrgsListOrgRoleUsersParams {
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 outside collaborators for an organization](Orgs::list_outside_collaborators_async()) endpoint.
#[derive(Default, Serialize)]
pub struct OrgsListOutsideCollaboratorsParams<'req> {
/// Filter the list of outside collaborators. `2fa_disabled` means that only outside collaborators without [two-factor authentication](https://github.com/blog/1614-two-factor-authentication) enabled will be returned. `2fa_insecure` means that only outside collaborators with [insecure 2FA methods](https://docs.github.com/organizations/keeping-your-organization-secure/managing-two-factor-authentication-for-your-organization/requiring-two-factor-authentication-in-your-organization#requiring-secure-methods-of-two-factor-authentication-in-your-organization) will be returned.
filter: 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> OrgsListOutsideCollaboratorsParams<'req> {
pub fn new() -> Self {
Self::default()
}
/// Filter the list of outside collaborators. `2fa_disabled` means that only outside collaborators without [two-factor authentication](https://github.com/blog/1614-two-factor-authentication) enabled will be returned. `2fa_insecure` means that only outside collaborators with [insecure 2FA methods](https://docs.github.com/organizations/keeping-your-organization-secure/managing-two-factor-authentication-for-your-organization/requiring-two-factor-authentication-in-your-organization#requiring-secure-methods-of-two-factor-authentication-in-your-organization) will be returned.
pub fn filter(self, filter: &'req str) -> Self {
Self {
filter: Some(filter),
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 {
filter: self.filter,
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 {
filter: self.filter,
per_page: self.per_page,
page: Some(page),
}
}
}
impl<'enc> From<&'enc PerPage> for OrgsListOutsideCollaboratorsParams<'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 repositories a fine-grained personal access token has access to](Orgs::list_pat_grant_repositories_async()) endpoint.
#[derive(Default, Serialize)]
pub struct OrgsListPatGrantRepositoriesParams {
/// 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 OrgsListPatGrantRepositoriesParams {
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 OrgsListPatGrantRepositoriesParams {
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 repositories requested to be accessed by a fine-grained personal access token](Orgs::list_pat_grant_request_repositories_async()) endpoint.
#[derive(Default, Serialize)]
pub struct OrgsListPatGrantRequestRepositoriesParams {
/// 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 OrgsListPatGrantRequestRepositoriesParams {
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 OrgsListPatGrantRequestRepositoriesParams {
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 requests to access organization resources with fine-grained personal access tokens](Orgs::list_pat_grant_requests_async()) endpoint.
#[derive(Default, Serialize)]
pub struct OrgsListPatGrantRequestsParams<'req> {
/// 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>,
/// The property by which to sort the results.
sort: Option<&'req str>,
/// The direction to sort the results by.
direction: Option<&'req str>,
/// A list of owner usernames to use to filter the results.
owner: Option<Vec<String>>,
/// The name of the repository to use to filter the results.
repository: Option<&'req str>,
/// The permission to use to filter the results.
permission: Option<&'req str>,
/// Only show fine-grained personal access tokens used before the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
last_used_before: Option<chrono::DateTime<chrono::Utc>>,
/// Only show fine-grained personal access tokens used after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
last_used_after: Option<chrono::DateTime<chrono::Utc>>,
/// The ID of the token
token_id: Option<Vec<String>>
}
impl<'req> OrgsListPatGrantRequestsParams<'req> {
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,
sort: self.sort,
direction: self.direction,
owner: self.owner,
repository: self.repository,
permission: self.permission,
last_used_before: self.last_used_before,
last_used_after: self.last_used_after,
token_id: self.token_id,
}
}
/// 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),
sort: self.sort,
direction: self.direction,
owner: self.owner,
repository: self.repository,
permission: self.permission,
last_used_before: self.last_used_before,
last_used_after: self.last_used_after,
token_id: self.token_id,
}
}
/// The property by which to sort the results.
pub fn sort(self, sort: &'req str) -> Self {
Self {
per_page: self.per_page,
page: self.page,
sort: Some(sort),
direction: self.direction,
owner: self.owner,
repository: self.repository,
permission: self.permission,
last_used_before: self.last_used_before,
last_used_after: self.last_used_after,
token_id: self.token_id,
}
}
/// The direction to sort the results by.
pub fn direction(self, direction: &'req str) -> Self {
Self {
per_page: self.per_page,
page: self.page,
sort: self.sort,
direction: Some(direction),
owner: self.owner,
repository: self.repository,
permission: self.permission,
last_used_before: self.last_used_before,
last_used_after: self.last_used_after,
token_id: self.token_id,
}
}
/// A list of owner usernames to use to filter the results.
pub fn owner(self, owner: Vec<String>) -> Self {
Self {
per_page: self.per_page,
page: self.page,
sort: self.sort,
direction: self.direction,
owner: Some(owner),
repository: self.repository,
permission: self.permission,
last_used_before: self.last_used_before,
last_used_after: self.last_used_after,
token_id: self.token_id,
}
}
/// The name of the repository to use to filter the results.
pub fn repository(self, repository: &'req str) -> Self {
Self {
per_page: self.per_page,
page: self.page,
sort: self.sort,
direction: self.direction,
owner: self.owner,
repository: Some(repository),
permission: self.permission,
last_used_before: self.last_used_before,
last_used_after: self.last_used_after,
token_id: self.token_id,
}
}
/// The permission to use to filter the results.
pub fn permission(self, permission: &'req str) -> Self {
Self {
per_page: self.per_page,
page: self.page,
sort: self.sort,
direction: self.direction,
owner: self.owner,
repository: self.repository,
permission: Some(permission),
last_used_before: self.last_used_before,
last_used_after: self.last_used_after,
token_id: self.token_id,
}
}
/// Only show fine-grained personal access tokens used before the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
pub fn last_used_before(self, last_used_before: chrono::DateTime<chrono::Utc>) -> Self {
Self {
per_page: self.per_page,
page: self.page,
sort: self.sort,
direction: self.direction,
owner: self.owner,
repository: self.repository,
permission: self.permission,
last_used_before: Some(last_used_before),
last_used_after: self.last_used_after,
token_id: self.token_id,
}
}
/// Only show fine-grained personal access tokens used after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
pub fn last_used_after(self, last_used_after: chrono::DateTime<chrono::Utc>) -> Self {
Self {
per_page: self.per_page,
page: self.page,
sort: self.sort,
direction: self.direction,
owner: self.owner,
repository: self.repository,
permission: self.permission,
last_used_before: self.last_used_before,
last_used_after: Some(last_used_after),
token_id: self.token_id,
}
}
/// The ID of the token
pub fn token_id(self, token_id: Vec<String>) -> Self {
Self {
per_page: self.per_page,
page: self.page,
sort: self.sort,
direction: self.direction,
owner: self.owner,
repository: self.repository,
permission: self.permission,
last_used_before: self.last_used_before,
last_used_after: self.last_used_after,
token_id: Some(token_id),
}
}
}
impl<'enc> From<&'enc PerPage> for OrgsListPatGrantRequestsParams<'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 fine-grained personal access tokens with access to organization resources](Orgs::list_pat_grants_async()) endpoint.
#[derive(Default, Serialize)]
pub struct OrgsListPatGrantsParams<'req> {
/// 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>,
/// The property by which to sort the results.
sort: Option<&'req str>,
/// The direction to sort the results by.
direction: Option<&'req str>,
/// A list of owner usernames to use to filter the results.
owner: Option<Vec<String>>,
/// The name of the repository to use to filter the results.
repository: Option<&'req str>,
/// The permission to use to filter the results.
permission: Option<&'req str>,
/// Only show fine-grained personal access tokens used before the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
last_used_before: Option<chrono::DateTime<chrono::Utc>>,
/// Only show fine-grained personal access tokens used after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
last_used_after: Option<chrono::DateTime<chrono::Utc>>,
/// The ID of the token
token_id: Option<Vec<String>>
}
impl<'req> OrgsListPatGrantsParams<'req> {
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,
sort: self.sort,
direction: self.direction,
owner: self.owner,
repository: self.repository,
permission: self.permission,
last_used_before: self.last_used_before,
last_used_after: self.last_used_after,
token_id: self.token_id,
}
}
/// 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),
sort: self.sort,
direction: self.direction,
owner: self.owner,
repository: self.repository,
permission: self.permission,
last_used_before: self.last_used_before,
last_used_after: self.last_used_after,
token_id: self.token_id,
}
}
/// The property by which to sort the results.
pub fn sort(self, sort: &'req str) -> Self {
Self {
per_page: self.per_page,
page: self.page,
sort: Some(sort),
direction: self.direction,
owner: self.owner,
repository: self.repository,
permission: self.permission,
last_used_before: self.last_used_before,
last_used_after: self.last_used_after,
token_id: self.token_id,
}
}
/// The direction to sort the results by.
pub fn direction(self, direction: &'req str) -> Self {
Self {
per_page: self.per_page,
page: self.page,
sort: self.sort,
direction: Some(direction),
owner: self.owner,
repository: self.repository,
permission: self.permission,
last_used_before: self.last_used_before,
last_used_after: self.last_used_after,
token_id: self.token_id,
}
}
/// A list of owner usernames to use to filter the results.
pub fn owner(self, owner: Vec<String>) -> Self {
Self {
per_page: self.per_page,
page: self.page,
sort: self.sort,
direction: self.direction,
owner: Some(owner),
repository: self.repository,
permission: self.permission,
last_used_before: self.last_used_before,
last_used_after: self.last_used_after,
token_id: self.token_id,
}
}
/// The name of the repository to use to filter the results.
pub fn repository(self, repository: &'req str) -> Self {
Self {
per_page: self.per_page,
page: self.page,
sort: self.sort,
direction: self.direction,
owner: self.owner,
repository: Some(repository),
permission: self.permission,
last_used_before: self.last_used_before,
last_used_after: self.last_used_after,
token_id: self.token_id,
}
}
/// The permission to use to filter the results.
pub fn permission(self, permission: &'req str) -> Self {
Self {
per_page: self.per_page,
page: self.page,
sort: self.sort,
direction: self.direction,
owner: self.owner,
repository: self.repository,
permission: Some(permission),
last_used_before: self.last_used_before,
last_used_after: self.last_used_after,
token_id: self.token_id,
}
}
/// Only show fine-grained personal access tokens used before the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
pub fn last_used_before(self, last_used_before: chrono::DateTime<chrono::Utc>) -> Self {
Self {
per_page: self.per_page,
page: self.page,
sort: self.sort,
direction: self.direction,
owner: self.owner,
repository: self.repository,
permission: self.permission,
last_used_before: Some(last_used_before),
last_used_after: self.last_used_after,
token_id: self.token_id,
}
}
/// Only show fine-grained personal access tokens used after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
pub fn last_used_after(self, last_used_after: chrono::DateTime<chrono::Utc>) -> Self {
Self {
per_page: self.per_page,
page: self.page,
sort: self.sort,
direction: self.direction,
owner: self.owner,
repository: self.repository,
permission: self.permission,
last_used_before: self.last_used_before,
last_used_after: Some(last_used_after),
token_id: self.token_id,
}
}
/// The ID of the token
pub fn token_id(self, token_id: Vec<String>) -> Self {
Self {
per_page: self.per_page,
page: self.page,
sort: self.sort,
direction: self.direction,
owner: self.owner,
repository: self.repository,
permission: self.permission,
last_used_before: self.last_used_before,
last_used_after: self.last_used_after,
token_id: Some(token_id),
}
}
}
impl<'enc> From<&'enc PerPage> for OrgsListPatGrantsParams<'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 organization invitations](Orgs::list_pending_invitations_async()) endpoint.
#[derive(Default, Serialize)]
pub struct OrgsListPendingInvitationsParams<'req> {
/// 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>,
/// Filter invitations by their member role.
role: Option<&'req str>,
/// Filter invitations by their invitation source.
invitation_source: Option<&'req str>
}
impl<'req> OrgsListPendingInvitationsParams<'req> {
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,
role: self.role,
invitation_source: self.invitation_source,
}
}
/// 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),
role: self.role,
invitation_source: self.invitation_source,
}
}
/// Filter invitations by their member role.
pub fn role(self, role: &'req str) -> Self {
Self {
per_page: self.per_page,
page: self.page,
role: Some(role),
invitation_source: self.invitation_source,
}
}
/// Filter invitations by their invitation source.
pub fn invitation_source(self, invitation_source: &'req str) -> Self {
Self {
per_page: self.per_page,
page: self.page,
role: self.role,
invitation_source: Some(invitation_source),
}
}
}
impl<'enc> From<&'enc PerPage> for OrgsListPendingInvitationsParams<'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 public organization members](Orgs::list_public_members_async()) endpoint.
#[derive(Default, Serialize)]
pub struct OrgsListPublicMembersParams {
/// 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 OrgsListPublicMembersParams {
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 OrgsListPublicMembersParams {
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 deliveries for an organization webhook](Orgs::list_webhook_deliveries_async()) endpoint.
#[derive(Default, Serialize)]
pub struct OrgsListWebhookDeliveriesParams<'req> {
/// 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>,
/// Used for pagination: the starting delivery from which the page of deliveries is fetched. Refer to the `link` header for the next and previous page cursors.
cursor: Option<&'req str>
}
impl<'req> OrgsListWebhookDeliveriesParams<'req> {
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),
cursor: self.cursor,
}
}
/// Used for pagination: the starting delivery from which the page of deliveries is fetched. Refer to the `link` header for the next and previous page cursors.
pub fn cursor(self, cursor: &'req str) -> Self {
Self {
per_page: self.per_page,
cursor: Some(cursor),
}
}
}
/// Query parameters for the [List organization webhooks](Orgs::list_webhooks_async()) endpoint.
#[derive(Default, Serialize)]
pub struct OrgsListWebhooksParams {
/// 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 OrgsListWebhooksParams {
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 OrgsListWebhooksParams {
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> Orgs<'api, C> where AdapterError: From<<C as Client>::Err> {
/// ---
///
/// # Add a security manager team
///
/// > [!WARNING]
/// > **Closing down notice:** This operation is closing down and will be removed starting January 1, 2026. Please use the "[Organization Roles](https://docs.github.com/rest/orgs/organization-roles)" endpoints instead.
///
/// [GitHub API docs for add_security_manager_team](https://docs.github.com/rest/orgs/security-managers#add-a-security-manager-team)
///
/// ---
pub async fn add_security_manager_team_async(&self, org: &str, team_slug: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/security-managers/teams/{}", super::GITHUB_BASE_API_URL, org, team_slug);
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() {
code => Err(OrgsAddSecurityManagerTeamError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Add a security manager team
///
/// > [!WARNING]
/// > **Closing down notice:** This operation is closing down and will be removed starting January 1, 2026. Please use the "[Organization Roles](https://docs.github.com/rest/orgs/organization-roles)" endpoints instead.
///
/// [GitHub API docs for add_security_manager_team](https://docs.github.com/rest/orgs/security-managers#add-a-security-manager-team)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn add_security_manager_team(&self, org: &str, team_slug: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/security-managers/teams/{}", super::GITHUB_BASE_API_URL, org, team_slug);
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() {
code => Err(OrgsAddSecurityManagerTeamError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Assign an organization role to a team
///
/// Assigns an organization role to a team in an organization. For more information on organization roles, see "[Using organization roles](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/using-organization-roles)."
///
/// The authenticated user must be an administrator for the organization to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint.
///
/// [GitHub API docs for assign_team_to_org_role](https://docs.github.com/rest/orgs/organization-roles#assign-an-organization-role-to-a-team)
///
/// ---
pub async fn assign_team_to_org_role_async(&self, org: &str, team_slug: &str, role_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/organization-roles/teams/{}/{}", super::GITHUB_BASE_API_URL, org, team_slug, role_id);
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(OrgsAssignTeamToOrgRoleError::Status404.into()),
422 => Err(OrgsAssignTeamToOrgRoleError::Status422.into()),
code => Err(OrgsAssignTeamToOrgRoleError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Assign an organization role to a team
///
/// Assigns an organization role to a team in an organization. For more information on organization roles, see "[Using organization roles](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/using-organization-roles)."
///
/// The authenticated user must be an administrator for the organization to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint.
///
/// [GitHub API docs for assign_team_to_org_role](https://docs.github.com/rest/orgs/organization-roles#assign-an-organization-role-to-a-team)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn assign_team_to_org_role(&self, org: &str, team_slug: &str, role_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/organization-roles/teams/{}/{}", super::GITHUB_BASE_API_URL, org, team_slug, role_id);
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(OrgsAssignTeamToOrgRoleError::Status404.into()),
422 => Err(OrgsAssignTeamToOrgRoleError::Status422.into()),
code => Err(OrgsAssignTeamToOrgRoleError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Assign an organization role to a user
///
/// Assigns an organization role to a member of an organization. For more information on organization roles, see "[Using organization roles](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/using-organization-roles)."
///
/// The authenticated user must be an administrator for the organization to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint.
///
/// [GitHub API docs for assign_user_to_org_role](https://docs.github.com/rest/orgs/organization-roles#assign-an-organization-role-to-a-user)
///
/// ---
pub async fn assign_user_to_org_role_async(&self, org: &str, username: &str, role_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/organization-roles/users/{}/{}", super::GITHUB_BASE_API_URL, org, username, role_id);
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(OrgsAssignUserToOrgRoleError::Status404.into()),
422 => Err(OrgsAssignUserToOrgRoleError::Status422.into()),
code => Err(OrgsAssignUserToOrgRoleError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Assign an organization role to a user
///
/// Assigns an organization role to a member of an organization. For more information on organization roles, see "[Using organization roles](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/using-organization-roles)."
///
/// The authenticated user must be an administrator for the organization to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint.
///
/// [GitHub API docs for assign_user_to_org_role](https://docs.github.com/rest/orgs/organization-roles#assign-an-organization-role-to-a-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn assign_user_to_org_role(&self, org: &str, username: &str, role_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/organization-roles/users/{}/{}", super::GITHUB_BASE_API_URL, org, username, role_id);
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(OrgsAssignUserToOrgRoleError::Status404.into()),
422 => Err(OrgsAssignUserToOrgRoleError::Status422.into()),
code => Err(OrgsAssignUserToOrgRoleError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Block a user from an organization
///
/// Blocks the given user on behalf of the specified organization and returns a 204. If the organization cannot block the given user a 422 is returned.
///
/// [GitHub API docs for block_user](https://docs.github.com/rest/orgs/blocking#block-a-user-from-an-organization)
///
/// ---
pub async fn block_user_async(&self, org: &str, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/blocks/{}", super::GITHUB_BASE_API_URL, org, 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() {
422 => Err(OrgsBlockUserError::Status422(github_response.to_json_async().await?).into()),
code => Err(OrgsBlockUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Block a user from an organization
///
/// Blocks the given user on behalf of the specified organization and returns a 204. If the organization cannot block the given user a 422 is returned.
///
/// [GitHub API docs for block_user](https://docs.github.com/rest/orgs/blocking#block-a-user-from-an-organization)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn block_user(&self, org: &str, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/blocks/{}", super::GITHUB_BASE_API_URL, org, 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() {
422 => Err(OrgsBlockUserError::Status422(github_response.to_json()?).into()),
code => Err(OrgsBlockUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Cancel an organization invitation
///
/// Cancel an organization invitation. In order to cancel an organization invitation, the authenticated user must be an organization owner.
///
/// This endpoint triggers [notifications](https://docs.github.com/github/managing-subscriptions-and-notifications-on-github/about-notifications).
///
/// [GitHub API docs for cancel_invitation](https://docs.github.com/rest/orgs/members#cancel-an-organization-invitation)
///
/// ---
pub async fn cancel_invitation_async(&self, org: &str, invitation_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/invitations/{}", super::GITHUB_BASE_API_URL, org, invitation_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() {
422 => Err(OrgsCancelInvitationError::Status422(github_response.to_json_async().await?).into()),
404 => Err(OrgsCancelInvitationError::Status404(github_response.to_json_async().await?).into()),
code => Err(OrgsCancelInvitationError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Cancel an organization invitation
///
/// Cancel an organization invitation. In order to cancel an organization invitation, the authenticated user must be an organization owner.
///
/// This endpoint triggers [notifications](https://docs.github.com/github/managing-subscriptions-and-notifications-on-github/about-notifications).
///
/// [GitHub API docs for cancel_invitation](https://docs.github.com/rest/orgs/members#cancel-an-organization-invitation)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn cancel_invitation(&self, org: &str, invitation_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/invitations/{}", super::GITHUB_BASE_API_URL, org, invitation_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() {
422 => Err(OrgsCancelInvitationError::Status422(github_response.to_json()?).into()),
404 => Err(OrgsCancelInvitationError::Status404(github_response.to_json()?).into()),
code => Err(OrgsCancelInvitationError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Check if a user is blocked by an organization
///
/// Returns a 204 if the given user is blocked by the given organization. Returns a 404 if the organization is not blocking the user, or if the user account has been identified as spam by GitHub.
///
/// [GitHub API docs for check_blocked_user](https://docs.github.com/rest/orgs/blocking#check-if-a-user-is-blocked-by-an-organization)
///
/// ---
pub async fn check_blocked_user_async(&self, org: &str, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/blocks/{}", super::GITHUB_BASE_API_URL, org, 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(OrgsCheckBlockedUserError::Status404(github_response.to_json_async().await?).into()),
code => Err(OrgsCheckBlockedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Check if a user is blocked by an organization
///
/// Returns a 204 if the given user is blocked by the given organization. Returns a 404 if the organization is not blocking the user, or if the user account has been identified as spam by GitHub.
///
/// [GitHub API docs for check_blocked_user](https://docs.github.com/rest/orgs/blocking#check-if-a-user-is-blocked-by-an-organization)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn check_blocked_user(&self, org: &str, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/blocks/{}", super::GITHUB_BASE_API_URL, org, 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(OrgsCheckBlockedUserError::Status404(github_response.to_json()?).into()),
code => Err(OrgsCheckBlockedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Check organization membership for a user
///
/// Check if a user is, publicly or privately, a member of the organization.
///
/// [GitHub API docs for check_membership_for_user](https://docs.github.com/rest/orgs/members#check-organization-membership-for-a-user)
///
/// ---
pub async fn check_membership_for_user_async(&self, org: &str, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/members/{}", super::GITHUB_BASE_API_URL, org, 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() {
302 => Err(OrgsCheckMembershipForUserError::Status302.into()),
404 => Err(OrgsCheckMembershipForUserError::Status404.into()),
code => Err(OrgsCheckMembershipForUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Check organization membership for a user
///
/// Check if a user is, publicly or privately, a member of the organization.
///
/// [GitHub API docs for check_membership_for_user](https://docs.github.com/rest/orgs/members#check-organization-membership-for-a-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn check_membership_for_user(&self, org: &str, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/members/{}", super::GITHUB_BASE_API_URL, org, 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() {
302 => Err(OrgsCheckMembershipForUserError::Status302.into()),
404 => Err(OrgsCheckMembershipForUserError::Status404.into()),
code => Err(OrgsCheckMembershipForUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Check public organization membership for a user
///
/// Check if the provided user is a public member of the organization.
///
/// [GitHub API docs for check_public_membership_for_user](https://docs.github.com/rest/orgs/members#check-public-organization-membership-for-a-user)
///
/// ---
pub async fn check_public_membership_for_user_async(&self, org: &str, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/public_members/{}", super::GITHUB_BASE_API_URL, org, 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(OrgsCheckPublicMembershipForUserError::Status404.into()),
code => Err(OrgsCheckPublicMembershipForUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Check public organization membership for a user
///
/// Check if the provided user is a public member of the organization.
///
/// [GitHub API docs for check_public_membership_for_user](https://docs.github.com/rest/orgs/members#check-public-organization-membership-for-a-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn check_public_membership_for_user(&self, org: &str, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/public_members/{}", super::GITHUB_BASE_API_URL, org, 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(OrgsCheckPublicMembershipForUserError::Status404.into()),
code => Err(OrgsCheckPublicMembershipForUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Convert an organization member to outside collaborator
///
/// When an organization member is converted to an outside collaborator, they'll only have access to the repositories that their current team membership allows. The user will no longer be a member of the organization. For more information, see "[Converting an organization member to an outside collaborator](https://docs.github.com/articles/converting-an-organization-member-to-an-outside-collaborator/)". Converting an organization member to an outside collaborator may be restricted by enterprise administrators. For more information, see "[Enforcing repository management policies in your enterprise](https://docs.github.com/admin/policies/enforcing-policies-for-your-enterprise/enforcing-repository-management-policies-in-your-enterprise#enforcing-a-policy-for-inviting-outside-collaborators-to-repositories)."
///
/// [GitHub API docs for convert_member_to_outside_collaborator](https://docs.github.com/rest/orgs/outside-collaborators#convert-an-organization-member-to-outside-collaborator)
///
/// ---
pub async fn convert_member_to_outside_collaborator_async(&self, org: &str, username: &str, body: PutOrgsConvertMemberToOutsideCollaborator) -> Result<HashMap<String, Value>, AdapterError> {
let request_uri = format!("{}/orgs/{}/outside_collaborators/{}", super::GITHUB_BASE_API_URL, org, username);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutOrgsConvertMemberToOutsideCollaborator>(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() {
204 => Err(OrgsConvertMemberToOutsideCollaboratorError::Status204.into()),
403 => Err(OrgsConvertMemberToOutsideCollaboratorError::Status403.into()),
404 => Err(OrgsConvertMemberToOutsideCollaboratorError::Status404(github_response.to_json_async().await?).into()),
code => Err(OrgsConvertMemberToOutsideCollaboratorError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Convert an organization member to outside collaborator
///
/// When an organization member is converted to an outside collaborator, they'll only have access to the repositories that their current team membership allows. The user will no longer be a member of the organization. For more information, see "[Converting an organization member to an outside collaborator](https://docs.github.com/articles/converting-an-organization-member-to-an-outside-collaborator/)". Converting an organization member to an outside collaborator may be restricted by enterprise administrators. For more information, see "[Enforcing repository management policies in your enterprise](https://docs.github.com/admin/policies/enforcing-policies-for-your-enterprise/enforcing-repository-management-policies-in-your-enterprise#enforcing-a-policy-for-inviting-outside-collaborators-to-repositories)."
///
/// [GitHub API docs for convert_member_to_outside_collaborator](https://docs.github.com/rest/orgs/outside-collaborators#convert-an-organization-member-to-outside-collaborator)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn convert_member_to_outside_collaborator(&self, org: &str, username: &str, body: PutOrgsConvertMemberToOutsideCollaborator) -> Result<HashMap<String, Value>, AdapterError> {
let request_uri = format!("{}/orgs/{}/outside_collaborators/{}", super::GITHUB_BASE_API_URL, org, username);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutOrgsConvertMemberToOutsideCollaborator>(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() {
204 => Err(OrgsConvertMemberToOutsideCollaboratorError::Status204.into()),
403 => Err(OrgsConvertMemberToOutsideCollaboratorError::Status403.into()),
404 => Err(OrgsConvertMemberToOutsideCollaboratorError::Status404(github_response.to_json()?).into()),
code => Err(OrgsConvertMemberToOutsideCollaboratorError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create an organization invitation
///
/// Invite people to an organization by using their GitHub user ID or their email address. In order to create invitations in an organization, the authenticated user must be an organization owner.
///
/// 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)."
///
/// [GitHub API docs for create_invitation](https://docs.github.com/rest/orgs/members#create-an-organization-invitation)
///
/// ---
pub async fn create_invitation_async(&self, org: &str, body: PostOrgsCreateInvitation) -> Result<OrganizationInvitation, AdapterError> {
let request_uri = format!("{}/orgs/{}/invitations", super::GITHUB_BASE_API_URL, org);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostOrgsCreateInvitation>(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(OrgsCreateInvitationError::Status422(github_response.to_json_async().await?).into()),
404 => Err(OrgsCreateInvitationError::Status404(github_response.to_json_async().await?).into()),
code => Err(OrgsCreateInvitationError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create an organization invitation
///
/// Invite people to an organization by using their GitHub user ID or their email address. In order to create invitations in an organization, the authenticated user must be an organization owner.
///
/// 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)."
///
/// [GitHub API docs for create_invitation](https://docs.github.com/rest/orgs/members#create-an-organization-invitation)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn create_invitation(&self, org: &str, body: PostOrgsCreateInvitation) -> Result<OrganizationInvitation, AdapterError> {
let request_uri = format!("{}/orgs/{}/invitations", super::GITHUB_BASE_API_URL, org);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostOrgsCreateInvitation>(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(OrgsCreateInvitationError::Status422(github_response.to_json()?).into()),
404 => Err(OrgsCreateInvitationError::Status404(github_response.to_json()?).into()),
code => Err(OrgsCreateInvitationError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create issue type for an organization
///
/// Create a new issue type for an organization.
///
/// You can find out more about issue types in [Managing issue types in an organization](https://docs.github.com/issues/tracking-your-work-with-issues/configuring-issues/managing-issue-types-in-an-organization).
///
/// To use this endpoint, the authenticated user must be an administrator for the organization. OAuth app tokens and
/// personal access tokens (classic) need the `admin:org` scope to use this endpoint.
///
/// [GitHub API docs for create_issue_type](https://docs.github.com/rest/orgs/issue-types#create-issue-type-for-an-organization)
///
/// ---
pub async fn create_issue_type_async(&self, org: &str, body: PostOrgsCreateIssueType) -> Result<IssueType, AdapterError> {
let request_uri = format!("{}/orgs/{}/issue-types", super::GITHUB_BASE_API_URL, org);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostOrgsCreateIssueType>(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() {
404 => Err(OrgsCreateIssueTypeError::Status404(github_response.to_json_async().await?).into()),
422 => Err(OrgsCreateIssueTypeError::Status422(github_response.to_json_async().await?).into()),
code => Err(OrgsCreateIssueTypeError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create issue type for an organization
///
/// Create a new issue type for an organization.
///
/// You can find out more about issue types in [Managing issue types in an organization](https://docs.github.com/issues/tracking-your-work-with-issues/configuring-issues/managing-issue-types-in-an-organization).
///
/// To use this endpoint, the authenticated user must be an administrator for the organization. OAuth app tokens and
/// personal access tokens (classic) need the `admin:org` scope to use this endpoint.
///
/// [GitHub API docs for create_issue_type](https://docs.github.com/rest/orgs/issue-types#create-issue-type-for-an-organization)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn create_issue_type(&self, org: &str, body: PostOrgsCreateIssueType) -> Result<IssueType, AdapterError> {
let request_uri = format!("{}/orgs/{}/issue-types", super::GITHUB_BASE_API_URL, org);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostOrgsCreateIssueType>(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() {
404 => Err(OrgsCreateIssueTypeError::Status404(github_response.to_json()?).into()),
422 => Err(OrgsCreateIssueTypeError::Status422(github_response.to_json()?).into()),
code => Err(OrgsCreateIssueTypeError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create or update custom properties for an organization
///
/// Creates new or updates existing custom properties defined for an organization in a batch.
///
/// If the property already exists, the existing property will be replaced with the new values.
/// Missing optional values will fall back to default values, previous values will be overwritten.
/// E.g. if a property exists with `values_editable_by: org_and_repo_actors` and it's updated without specifying `values_editable_by`, it will be updated to default value `org_actors`.
///
/// To use this endpoint, the authenticated user must be one of:
/// - An administrator for the organization.
/// - A user, or a user on a team, with the fine-grained permission of `custom_properties_org_definitions_manager` in the organization.
///
/// [GitHub API docs for create_or_update_custom_properties](https://docs.github.com/rest/orgs/custom-properties#create-or-update-custom-properties-for-an-organization)
///
/// ---
pub async fn create_or_update_custom_properties_async(&self, org: &str, body: PatchOrgsCreateOrUpdateCustomProperties) -> Result<Vec<CustomProperty>, AdapterError> {
let request_uri = format!("{}/orgs/{}/properties/schema", super::GITHUB_BASE_API_URL, org);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchOrgsCreateOrUpdateCustomProperties>(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() {
403 => Err(OrgsCreateOrUpdateCustomPropertiesError::Status403(github_response.to_json_async().await?).into()),
404 => Err(OrgsCreateOrUpdateCustomPropertiesError::Status404(github_response.to_json_async().await?).into()),
code => Err(OrgsCreateOrUpdateCustomPropertiesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create or update custom properties for an organization
///
/// Creates new or updates existing custom properties defined for an organization in a batch.
///
/// If the property already exists, the existing property will be replaced with the new values.
/// Missing optional values will fall back to default values, previous values will be overwritten.
/// E.g. if a property exists with `values_editable_by: org_and_repo_actors` and it's updated without specifying `values_editable_by`, it will be updated to default value `org_actors`.
///
/// To use this endpoint, the authenticated user must be one of:
/// - An administrator for the organization.
/// - A user, or a user on a team, with the fine-grained permission of `custom_properties_org_definitions_manager` in the organization.
///
/// [GitHub API docs for create_or_update_custom_properties](https://docs.github.com/rest/orgs/custom-properties#create-or-update-custom-properties-for-an-organization)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn create_or_update_custom_properties(&self, org: &str, body: PatchOrgsCreateOrUpdateCustomProperties) -> Result<Vec<CustomProperty>, AdapterError> {
let request_uri = format!("{}/orgs/{}/properties/schema", super::GITHUB_BASE_API_URL, org);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchOrgsCreateOrUpdateCustomProperties>(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() {
403 => Err(OrgsCreateOrUpdateCustomPropertiesError::Status403(github_response.to_json()?).into()),
404 => Err(OrgsCreateOrUpdateCustomPropertiesError::Status404(github_response.to_json()?).into()),
code => Err(OrgsCreateOrUpdateCustomPropertiesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create or update custom property values for organization repositories
///
/// Create new or update existing custom property values for repositories in a batch that belong to an organization.
/// Each target repository will have its custom property values updated to match the values provided in the request.
///
/// A maximum of 30 repositories can be updated in a single request.
///
/// Using a value of `null` for a custom property will remove or 'unset' the property value from the repository.
///
/// To use this endpoint, the authenticated user must be one of:
/// - An administrator for the organization.
/// - A user, or a user on a team, with the fine-grained permission of `custom_properties_org_values_editor` in the organization.
///
/// [GitHub API docs for create_or_update_custom_properties_values_for_repos](https://docs.github.com/rest/orgs/custom-properties#create-or-update-custom-property-values-for-organization-repositories)
///
/// ---
pub async fn create_or_update_custom_properties_values_for_repos_async(&self, org: &str, body: PatchOrgsCreateOrUpdateCustomPropertiesValuesForRepos) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/properties/values", super::GITHUB_BASE_API_URL, org);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchOrgsCreateOrUpdateCustomPropertiesValuesForRepos>(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(())
} else {
match github_response.status_code() {
403 => Err(OrgsCreateOrUpdateCustomPropertiesValuesForReposError::Status403(github_response.to_json_async().await?).into()),
404 => Err(OrgsCreateOrUpdateCustomPropertiesValuesForReposError::Status404(github_response.to_json_async().await?).into()),
422 => Err(OrgsCreateOrUpdateCustomPropertiesValuesForReposError::Status422(github_response.to_json_async().await?).into()),
code => Err(OrgsCreateOrUpdateCustomPropertiesValuesForReposError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create or update custom property values for organization repositories
///
/// Create new or update existing custom property values for repositories in a batch that belong to an organization.
/// Each target repository will have its custom property values updated to match the values provided in the request.
///
/// A maximum of 30 repositories can be updated in a single request.
///
/// Using a value of `null` for a custom property will remove or 'unset' the property value from the repository.
///
/// To use this endpoint, the authenticated user must be one of:
/// - An administrator for the organization.
/// - A user, or a user on a team, with the fine-grained permission of `custom_properties_org_values_editor` in the organization.
///
/// [GitHub API docs for create_or_update_custom_properties_values_for_repos](https://docs.github.com/rest/orgs/custom-properties#create-or-update-custom-property-values-for-organization-repositories)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn create_or_update_custom_properties_values_for_repos(&self, org: &str, body: PatchOrgsCreateOrUpdateCustomPropertiesValuesForRepos) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/properties/values", super::GITHUB_BASE_API_URL, org);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchOrgsCreateOrUpdateCustomPropertiesValuesForRepos>(body)?),
method: "PATCH",
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(OrgsCreateOrUpdateCustomPropertiesValuesForReposError::Status403(github_response.to_json()?).into()),
404 => Err(OrgsCreateOrUpdateCustomPropertiesValuesForReposError::Status404(github_response.to_json()?).into()),
422 => Err(OrgsCreateOrUpdateCustomPropertiesValuesForReposError::Status422(github_response.to_json()?).into()),
code => Err(OrgsCreateOrUpdateCustomPropertiesValuesForReposError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create or update a custom property for an organization
///
/// Creates a new or updates an existing custom property that is defined for an organization.
///
/// To use this endpoint, the authenticated user must be one of:
/// - An administrator for the organization.
/// - A user, or a user on a team, with the fine-grained permission of `custom_properties_org_definitions_manager` in the organization.
///
/// [GitHub API docs for create_or_update_custom_property](https://docs.github.com/rest/orgs/custom-properties#create-or-update-a-custom-property-for-an-organization)
///
/// ---
pub async fn create_or_update_custom_property_async(&self, org: &str, custom_property_name: &str, body: PutOrgsCreateOrUpdateCustomProperty) -> Result<CustomProperty, AdapterError> {
let request_uri = format!("{}/orgs/{}/properties/schema/{}", super::GITHUB_BASE_API_URL, org, custom_property_name);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutOrgsCreateOrUpdateCustomProperty>(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(OrgsCreateOrUpdateCustomPropertyError::Status403(github_response.to_json_async().await?).into()),
404 => Err(OrgsCreateOrUpdateCustomPropertyError::Status404(github_response.to_json_async().await?).into()),
code => Err(OrgsCreateOrUpdateCustomPropertyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create or update a custom property for an organization
///
/// Creates a new or updates an existing custom property that is defined for an organization.
///
/// To use this endpoint, the authenticated user must be one of:
/// - An administrator for the organization.
/// - A user, or a user on a team, with the fine-grained permission of `custom_properties_org_definitions_manager` in the organization.
///
/// [GitHub API docs for create_or_update_custom_property](https://docs.github.com/rest/orgs/custom-properties#create-or-update-a-custom-property-for-an-organization)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn create_or_update_custom_property(&self, org: &str, custom_property_name: &str, body: PutOrgsCreateOrUpdateCustomProperty) -> Result<CustomProperty, AdapterError> {
let request_uri = format!("{}/orgs/{}/properties/schema/{}", super::GITHUB_BASE_API_URL, org, custom_property_name);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutOrgsCreateOrUpdateCustomProperty>(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(OrgsCreateOrUpdateCustomPropertyError::Status403(github_response.to_json()?).into()),
404 => Err(OrgsCreateOrUpdateCustomPropertyError::Status404(github_response.to_json()?).into()),
code => Err(OrgsCreateOrUpdateCustomPropertyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create an organization webhook
///
/// Create a hook that posts payloads in JSON format.
///
/// You must be an organization owner to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need `admin:org_hook` scope. OAuth apps cannot list, view, or
/// edit webhooks that they did not create and users cannot list, view, or edit webhooks that were created by OAuth apps.
///
/// [GitHub API docs for create_webhook](https://docs.github.com/rest/orgs/webhooks#create-an-organization-webhook)
///
/// ---
pub async fn create_webhook_async(&self, org: &str, body: PostOrgsCreateWebhook) -> Result<OrgHook, AdapterError> {
let request_uri = format!("{}/orgs/{}/hooks", super::GITHUB_BASE_API_URL, org);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostOrgsCreateWebhook>(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(OrgsCreateWebhookError::Status422(github_response.to_json_async().await?).into()),
404 => Err(OrgsCreateWebhookError::Status404(github_response.to_json_async().await?).into()),
code => Err(OrgsCreateWebhookError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create an organization webhook
///
/// Create a hook that posts payloads in JSON format.
///
/// You must be an organization owner to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need `admin:org_hook` scope. OAuth apps cannot list, view, or
/// edit webhooks that they did not create and users cannot list, view, or edit webhooks that were created by OAuth apps.
///
/// [GitHub API docs for create_webhook](https://docs.github.com/rest/orgs/webhooks#create-an-organization-webhook)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn create_webhook(&self, org: &str, body: PostOrgsCreateWebhook) -> Result<OrgHook, AdapterError> {
let request_uri = format!("{}/orgs/{}/hooks", super::GITHUB_BASE_API_URL, org);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostOrgsCreateWebhook>(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(OrgsCreateWebhookError::Status422(github_response.to_json()?).into()),
404 => Err(OrgsCreateWebhookError::Status404(github_response.to_json()?).into()),
code => Err(OrgsCreateWebhookError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete an organization
///
/// Deletes an organization and all its repositories.
///
/// The organization login will be unavailable for 90 days after deletion.
///
/// Please review the Terms of Service regarding account deletion before using this endpoint:
///
/// https://docs.github.com/site-policy/github-terms/github-terms-of-service
///
/// [GitHub API docs for delete](https://docs.github.com/rest/orgs/orgs#delete-an-organization)
///
/// ---
pub async fn delete_async(&self, org: &str) -> Result<HashMap<String, Value>, AdapterError> {
let request_uri = format!("{}/orgs/{}", super::GITHUB_BASE_API_URL, org);
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(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
404 => Err(OrgsDeleteError::Status404(github_response.to_json_async().await?).into()),
403 => Err(OrgsDeleteError::Status403(github_response.to_json_async().await?).into()),
code => Err(OrgsDeleteError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete an organization
///
/// Deletes an organization and all its repositories.
///
/// The organization login will be unavailable for 90 days after deletion.
///
/// Please review the Terms of Service regarding account deletion before using this endpoint:
///
/// https://docs.github.com/site-policy/github-terms/github-terms-of-service
///
/// [GitHub API docs for delete](https://docs.github.com/rest/orgs/orgs#delete-an-organization)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete(&self, org: &str) -> Result<HashMap<String, Value>, AdapterError> {
let request_uri = format!("{}/orgs/{}", super::GITHUB_BASE_API_URL, org);
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(github_response.to_json()?)
} else {
match github_response.status_code() {
404 => Err(OrgsDeleteError::Status404(github_response.to_json()?).into()),
403 => Err(OrgsDeleteError::Status403(github_response.to_json()?).into()),
code => Err(OrgsDeleteError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete attestations in bulk
///
/// Delete artifact attestations in bulk by either subject digests or unique ID.
///
/// [GitHub API docs for delete_attestations_bulk](https://docs.github.com/rest/orgs/attestations#delete-attestations-in-bulk)
///
/// ---
pub async fn delete_attestations_bulk_async(&self, org: &str, body: PostOrgsDeleteAttestationsBulk) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/attestations/delete-request", super::GITHUB_BASE_API_URL, org);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostOrgsDeleteAttestationsBulk>(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(())
} else {
match github_response.status_code() {
404 => Err(OrgsDeleteAttestationsBulkError::Status404(github_response.to_json_async().await?).into()),
code => Err(OrgsDeleteAttestationsBulkError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete attestations in bulk
///
/// Delete artifact attestations in bulk by either subject digests or unique ID.
///
/// [GitHub API docs for delete_attestations_bulk](https://docs.github.com/rest/orgs/attestations#delete-attestations-in-bulk)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete_attestations_bulk(&self, org: &str, body: PostOrgsDeleteAttestationsBulk) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/attestations/delete-request", super::GITHUB_BASE_API_URL, org);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostOrgsDeleteAttestationsBulk>(body)?),
method: "POST",
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(OrgsDeleteAttestationsBulkError::Status404(github_response.to_json()?).into()),
code => Err(OrgsDeleteAttestationsBulkError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete attestations by ID
///
/// Delete an artifact attestation by unique ID that is associated with a repository owned by an org.
///
/// [GitHub API docs for delete_attestations_by_id](https://docs.github.com/rest/orgs/attestations#delete-attestations-by-id)
///
/// ---
pub async fn delete_attestations_by_id_async(&self, org: &str, attestation_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/attestations/{}", super::GITHUB_BASE_API_URL, org, attestation_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() {
204 => Err(OrgsDeleteAttestationsByIdError::Status204.into()),
403 => Err(OrgsDeleteAttestationsByIdError::Status403(github_response.to_json_async().await?).into()),
404 => Err(OrgsDeleteAttestationsByIdError::Status404(github_response.to_json_async().await?).into()),
code => Err(OrgsDeleteAttestationsByIdError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete attestations by ID
///
/// Delete an artifact attestation by unique ID that is associated with a repository owned by an org.
///
/// [GitHub API docs for delete_attestations_by_id](https://docs.github.com/rest/orgs/attestations#delete-attestations-by-id)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete_attestations_by_id(&self, org: &str, attestation_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/attestations/{}", super::GITHUB_BASE_API_URL, org, attestation_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() {
204 => Err(OrgsDeleteAttestationsByIdError::Status204.into()),
403 => Err(OrgsDeleteAttestationsByIdError::Status403(github_response.to_json()?).into()),
404 => Err(OrgsDeleteAttestationsByIdError::Status404(github_response.to_json()?).into()),
code => Err(OrgsDeleteAttestationsByIdError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete attestations by subject digest
///
/// Delete an artifact attestation by subject digest.
///
/// [GitHub API docs for delete_attestations_by_subject_digest](https://docs.github.com/rest/orgs/attestations#delete-attestations-by-subject-digest)
///
/// ---
pub async fn delete_attestations_by_subject_digest_async(&self, org: &str, subject_digest: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/attestations/digest/{}", super::GITHUB_BASE_API_URL, org, subject_digest);
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() {
204 => Err(OrgsDeleteAttestationsBySubjectDigestError::Status204.into()),
404 => Err(OrgsDeleteAttestationsBySubjectDigestError::Status404(github_response.to_json_async().await?).into()),
code => Err(OrgsDeleteAttestationsBySubjectDigestError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete attestations by subject digest
///
/// Delete an artifact attestation by subject digest.
///
/// [GitHub API docs for delete_attestations_by_subject_digest](https://docs.github.com/rest/orgs/attestations#delete-attestations-by-subject-digest)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete_attestations_by_subject_digest(&self, org: &str, subject_digest: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/attestations/digest/{}", super::GITHUB_BASE_API_URL, org, subject_digest);
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() {
204 => Err(OrgsDeleteAttestationsBySubjectDigestError::Status204.into()),
404 => Err(OrgsDeleteAttestationsBySubjectDigestError::Status404(github_response.to_json()?).into()),
code => Err(OrgsDeleteAttestationsBySubjectDigestError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete issue type for an organization
///
/// Deletes an issue type for an organization.
///
/// You can find out more about issue types in [Managing issue types in an organization](https://docs.github.com/issues/tracking-your-work-with-issues/configuring-issues/managing-issue-types-in-an-organization).
///
/// To use this endpoint, the authenticated user must be an administrator for the organization. OAuth app tokens and
/// personal access tokens (classic) need the `admin:org` scope to use this endpoint.
///
/// [GitHub API docs for delete_issue_type](https://docs.github.com/rest/orgs/issue-types#delete-issue-type-for-an-organization)
///
/// ---
pub async fn delete_issue_type_async(&self, org: &str, issue_type_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/issue-types/{}", super::GITHUB_BASE_API_URL, org, issue_type_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() {
422 => Err(OrgsDeleteIssueTypeError::Status422(github_response.to_json_async().await?).into()),
404 => Err(OrgsDeleteIssueTypeError::Status404(github_response.to_json_async().await?).into()),
code => Err(OrgsDeleteIssueTypeError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete issue type for an organization
///
/// Deletes an issue type for an organization.
///
/// You can find out more about issue types in [Managing issue types in an organization](https://docs.github.com/issues/tracking-your-work-with-issues/configuring-issues/managing-issue-types-in-an-organization).
///
/// To use this endpoint, the authenticated user must be an administrator for the organization. OAuth app tokens and
/// personal access tokens (classic) need the `admin:org` scope to use this endpoint.
///
/// [GitHub API docs for delete_issue_type](https://docs.github.com/rest/orgs/issue-types#delete-issue-type-for-an-organization)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete_issue_type(&self, org: &str, issue_type_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/issue-types/{}", super::GITHUB_BASE_API_URL, org, issue_type_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() {
422 => Err(OrgsDeleteIssueTypeError::Status422(github_response.to_json()?).into()),
404 => Err(OrgsDeleteIssueTypeError::Status404(github_response.to_json()?).into()),
code => Err(OrgsDeleteIssueTypeError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete an organization webhook
///
/// Delete a webhook for an organization.
///
/// The authenticated user must be an organization owner to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need `admin:org_hook` scope. OAuth apps cannot list, view, or edit
/// webhooks that they did not create and users cannot list, view, or edit webhooks that were created by OAuth apps.
///
/// [GitHub API docs for delete_webhook](https://docs.github.com/rest/orgs/webhooks#delete-an-organization-webhook)
///
/// ---
pub async fn delete_webhook_async(&self, org: &str, hook_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/hooks/{}", super::GITHUB_BASE_API_URL, org, hook_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(OrgsDeleteWebhookError::Status404(github_response.to_json_async().await?).into()),
code => Err(OrgsDeleteWebhookError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete an organization webhook
///
/// Delete a webhook for an organization.
///
/// The authenticated user must be an organization owner to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need `admin:org_hook` scope. OAuth apps cannot list, view, or edit
/// webhooks that they did not create and users cannot list, view, or edit webhooks that were created by OAuth apps.
///
/// [GitHub API docs for delete_webhook](https://docs.github.com/rest/orgs/webhooks#delete-an-organization-webhook)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete_webhook(&self, org: &str, hook_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/hooks/{}", super::GITHUB_BASE_API_URL, org, hook_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(OrgsDeleteWebhookError::Status404(github_response.to_json()?).into()),
code => Err(OrgsDeleteWebhookError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Enable or disable a security feature for an organization
///
/// > [!WARNING]
/// > **Closing down notice:** The ability to enable or disable a security feature for all eligible repositories in an organization is closing down. Please use [code security configurations](https://docs.github.com/rest/code-security/configurations) instead. For more information, see the [changelog](https://github.blog/changelog/2024-07-22-deprecation-of-api-endpoint-to-enable-or-disable-a-security-feature-for-an-organization/).
///
/// Enables or disables the specified security feature for all eligible repositories in an organization. For more information, see "[Managing security managers in your organization](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/managing-security-managers-in-your-organization)."
///
/// The authenticated user must be an organization owner or be member of a team with the security manager role to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need the `admin:org`, `write:org`, or `repo` scopes to use this endpoint.
///
/// [GitHub API docs for enable_or_disable_security_product_on_all_org_repos](https://docs.github.com/rest/orgs/orgs#enable-or-disable-a-security-feature-for-an-organization)
///
/// ---
pub async fn enable_or_disable_security_product_on_all_org_repos_async(&self, org: &str, security_product: &str, enablement: &str, body: PostOrgsEnableOrDisableSecurityProductOnAllOrgRepos) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/{}/{}", super::GITHUB_BASE_API_URL, org, security_product, enablement);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostOrgsEnableOrDisableSecurityProductOnAllOrgRepos>(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(())
} else {
match github_response.status_code() {
422 => Err(OrgsEnableOrDisableSecurityProductOnAllOrgReposError::Status422.into()),
code => Err(OrgsEnableOrDisableSecurityProductOnAllOrgReposError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Enable or disable a security feature for an organization
///
/// > [!WARNING]
/// > **Closing down notice:** The ability to enable or disable a security feature for all eligible repositories in an organization is closing down. Please use [code security configurations](https://docs.github.com/rest/code-security/configurations) instead. For more information, see the [changelog](https://github.blog/changelog/2024-07-22-deprecation-of-api-endpoint-to-enable-or-disable-a-security-feature-for-an-organization/).
///
/// Enables or disables the specified security feature for all eligible repositories in an organization. For more information, see "[Managing security managers in your organization](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/managing-security-managers-in-your-organization)."
///
/// The authenticated user must be an organization owner or be member of a team with the security manager role to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need the `admin:org`, `write:org`, or `repo` scopes to use this endpoint.
///
/// [GitHub API docs for enable_or_disable_security_product_on_all_org_repos](https://docs.github.com/rest/orgs/orgs#enable-or-disable-a-security-feature-for-an-organization)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn enable_or_disable_security_product_on_all_org_repos(&self, org: &str, security_product: &str, enablement: &str, body: PostOrgsEnableOrDisableSecurityProductOnAllOrgRepos) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/{}/{}", super::GITHUB_BASE_API_URL, org, security_product, enablement);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostOrgsEnableOrDisableSecurityProductOnAllOrgRepos>(body)?),
method: "POST",
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() {
422 => Err(OrgsEnableOrDisableSecurityProductOnAllOrgReposError::Status422.into()),
code => Err(OrgsEnableOrDisableSecurityProductOnAllOrgReposError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get an organization
///
/// Gets information about an organization.
///
/// When the value of `two_factor_requirement_enabled` is `true`, the organization requires all members, billing managers, outside collaborators, guest collaborators, repository collaborators, or everyone with access to any repository within the organization to enable [two-factor authentication](https://docs.github.com/articles/securing-your-account-with-two-factor-authentication-2fa/).
///
/// To see the full details about an organization, the authenticated user must be an organization owner.
///
/// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to see the full details about an organization.
///
/// To see information about an organization's GitHub plan, GitHub Apps need the `Organization plan` permission.
///
/// [GitHub API docs for get](https://docs.github.com/rest/orgs/orgs#get-an-organization)
///
/// ---
pub async fn get_async(&self, org: &str) -> Result<OrganizationFull, AdapterError> {
let request_uri = format!("{}/orgs/{}", super::GITHUB_BASE_API_URL, org);
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(OrgsGetError::Status404(github_response.to_json_async().await?).into()),
code => Err(OrgsGetError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get an organization
///
/// Gets information about an organization.
///
/// When the value of `two_factor_requirement_enabled` is `true`, the organization requires all members, billing managers, outside collaborators, guest collaborators, repository collaborators, or everyone with access to any repository within the organization to enable [two-factor authentication](https://docs.github.com/articles/securing-your-account-with-two-factor-authentication-2fa/).
///
/// To see the full details about an organization, the authenticated user must be an organization owner.
///
/// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to see the full details about an organization.
///
/// To see information about an organization's GitHub plan, GitHub Apps need the `Organization plan` permission.
///
/// [GitHub API docs for get](https://docs.github.com/rest/orgs/orgs#get-an-organization)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get(&self, org: &str) -> Result<OrganizationFull, AdapterError> {
let request_uri = format!("{}/orgs/{}", super::GITHUB_BASE_API_URL, org);
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(OrgsGetError::Status404(github_response.to_json()?).into()),
code => Err(OrgsGetError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get all custom properties for an organization
///
/// Gets all custom properties defined for an organization.
/// Organization members can read these properties.
///
/// [GitHub API docs for get_all_custom_properties](https://docs.github.com/rest/orgs/custom-properties#get-all-custom-properties-for-an-organization)
///
/// ---
pub async fn get_all_custom_properties_async(&self, org: &str) -> Result<Vec<CustomProperty>, AdapterError> {
let request_uri = format!("{}/orgs/{}/properties/schema", super::GITHUB_BASE_API_URL, org);
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(OrgsGetAllCustomPropertiesError::Status403(github_response.to_json_async().await?).into()),
404 => Err(OrgsGetAllCustomPropertiesError::Status404(github_response.to_json_async().await?).into()),
code => Err(OrgsGetAllCustomPropertiesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get all custom properties for an organization
///
/// Gets all custom properties defined for an organization.
/// Organization members can read these properties.
///
/// [GitHub API docs for get_all_custom_properties](https://docs.github.com/rest/orgs/custom-properties#get-all-custom-properties-for-an-organization)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_all_custom_properties(&self, org: &str) -> Result<Vec<CustomProperty>, AdapterError> {
let request_uri = format!("{}/orgs/{}/properties/schema", super::GITHUB_BASE_API_URL, org);
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(OrgsGetAllCustomPropertiesError::Status403(github_response.to_json()?).into()),
404 => Err(OrgsGetAllCustomPropertiesError::Status404(github_response.to_json()?).into()),
code => Err(OrgsGetAllCustomPropertiesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a custom property for an organization
///
/// Gets a custom property that is defined for an organization.
/// Organization members can read these properties.
///
/// [GitHub API docs for get_custom_property](https://docs.github.com/rest/orgs/custom-properties#get-a-custom-property-for-an-organization)
///
/// ---
pub async fn get_custom_property_async(&self, org: &str, custom_property_name: &str) -> Result<CustomProperty, AdapterError> {
let request_uri = format!("{}/orgs/{}/properties/schema/{}", super::GITHUB_BASE_API_URL, org, custom_property_name);
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(OrgsGetCustomPropertyError::Status403(github_response.to_json_async().await?).into()),
404 => Err(OrgsGetCustomPropertyError::Status404(github_response.to_json_async().await?).into()),
code => Err(OrgsGetCustomPropertyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a custom property for an organization
///
/// Gets a custom property that is defined for an organization.
/// Organization members can read these properties.
///
/// [GitHub API docs for get_custom_property](https://docs.github.com/rest/orgs/custom-properties#get-a-custom-property-for-an-organization)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_custom_property(&self, org: &str, custom_property_name: &str) -> Result<CustomProperty, AdapterError> {
let request_uri = format!("{}/orgs/{}/properties/schema/{}", super::GITHUB_BASE_API_URL, org, custom_property_name);
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(OrgsGetCustomPropertyError::Status403(github_response.to_json()?).into()),
404 => Err(OrgsGetCustomPropertyError::Status404(github_response.to_json()?).into()),
code => Err(OrgsGetCustomPropertyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get an organization membership for the authenticated user
///
/// If the authenticated user is an active or pending member of the organization, this endpoint will return the user's membership. If the authenticated user is not affiliated with the organization, a `404` is returned. This endpoint will return a `403` if the request is made by a GitHub App that is blocked by the organization.
///
/// [GitHub API docs for get_membership_for_authenticated_user](https://docs.github.com/rest/orgs/members#get-an-organization-membership-for-the-authenticated-user)
///
/// ---
pub async fn get_membership_for_authenticated_user_async(&self, org: &str) -> Result<OrgMembership, AdapterError> {
let request_uri = format!("{}/user/memberships/orgs/{}", super::GITHUB_BASE_API_URL, org);
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(OrgsGetMembershipForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()),
404 => Err(OrgsGetMembershipForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()),
code => Err(OrgsGetMembershipForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get an organization membership for the authenticated user
///
/// If the authenticated user is an active or pending member of the organization, this endpoint will return the user's membership. If the authenticated user is not affiliated with the organization, a `404` is returned. This endpoint will return a `403` if the request is made by a GitHub App that is blocked by the organization.
///
/// [GitHub API docs for get_membership_for_authenticated_user](https://docs.github.com/rest/orgs/members#get-an-organization-membership-for-the-authenticated-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_membership_for_authenticated_user(&self, org: &str) -> Result<OrgMembership, AdapterError> {
let request_uri = format!("{}/user/memberships/orgs/{}", super::GITHUB_BASE_API_URL, org);
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(OrgsGetMembershipForAuthenticatedUserError::Status403(github_response.to_json()?).into()),
404 => Err(OrgsGetMembershipForAuthenticatedUserError::Status404(github_response.to_json()?).into()),
code => Err(OrgsGetMembershipForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get organization membership for a user
///
/// In order to get a user's membership with an organization, the authenticated user must be an organization member. The `state` parameter in the response can be used to identify the user's membership status.
///
/// [GitHub API docs for get_membership_for_user](https://docs.github.com/rest/orgs/members#get-organization-membership-for-a-user)
///
/// ---
pub async fn get_membership_for_user_async(&self, org: &str, username: &str) -> Result<OrgMembership, AdapterError> {
let request_uri = format!("{}/orgs/{}/memberships/{}", super::GITHUB_BASE_API_URL, org, 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(OrgsGetMembershipForUserError::Status404(github_response.to_json_async().await?).into()),
403 => Err(OrgsGetMembershipForUserError::Status403(github_response.to_json_async().await?).into()),
code => Err(OrgsGetMembershipForUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get organization membership for a user
///
/// In order to get a user's membership with an organization, the authenticated user must be an organization member. The `state` parameter in the response can be used to identify the user's membership status.
///
/// [GitHub API docs for get_membership_for_user](https://docs.github.com/rest/orgs/members#get-organization-membership-for-a-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_membership_for_user(&self, org: &str, username: &str) -> Result<OrgMembership, AdapterError> {
let request_uri = format!("{}/orgs/{}/memberships/{}", super::GITHUB_BASE_API_URL, org, 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(OrgsGetMembershipForUserError::Status404(github_response.to_json()?).into()),
403 => Err(OrgsGetMembershipForUserError::Status403(github_response.to_json()?).into()),
code => Err(OrgsGetMembershipForUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get an organization role
///
/// Gets an organization role that is available to this organization. For more information on organization roles, see "[Using organization roles](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/using-organization-roles)."
///
/// To use this endpoint, the authenticated user must be one of:
///
/// - An administrator for the organization.
/// - A user, or a user on a team, with the fine-grained permissions of `read_organization_custom_org_role` in the organization.
///
/// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint.
///
/// [GitHub API docs for get_org_role](https://docs.github.com/rest/orgs/organization-roles#get-an-organization-role)
///
/// ---
pub async fn get_org_role_async(&self, org: &str, role_id: i32) -> Result<OrganizationRole, AdapterError> {
let request_uri = format!("{}/orgs/{}/organization-roles/{}", super::GITHUB_BASE_API_URL, org, role_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(OrgsGetOrgRoleError::Status404(github_response.to_json_async().await?).into()),
422 => Err(OrgsGetOrgRoleError::Status422(github_response.to_json_async().await?).into()),
code => Err(OrgsGetOrgRoleError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get an organization role
///
/// Gets an organization role that is available to this organization. For more information on organization roles, see "[Using organization roles](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/using-organization-roles)."
///
/// To use this endpoint, the authenticated user must be one of:
///
/// - An administrator for the organization.
/// - A user, or a user on a team, with the fine-grained permissions of `read_organization_custom_org_role` in the organization.
///
/// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint.
///
/// [GitHub API docs for get_org_role](https://docs.github.com/rest/orgs/organization-roles#get-an-organization-role)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_org_role(&self, org: &str, role_id: i32) -> Result<OrganizationRole, AdapterError> {
let request_uri = format!("{}/orgs/{}/organization-roles/{}", super::GITHUB_BASE_API_URL, org, role_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(OrgsGetOrgRoleError::Status404(github_response.to_json()?).into()),
422 => Err(OrgsGetOrgRoleError::Status422(github_response.to_json()?).into()),
code => Err(OrgsGetOrgRoleError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get organization ruleset history
///
/// Get the history of an organization ruleset.
///
/// [GitHub API docs for get_org_ruleset_history](https://docs.github.com/rest/orgs/rules#get-organization-ruleset-history)
///
/// ---
pub async fn get_org_ruleset_history_async(&self, org: &str, ruleset_id: i32, query_params: Option<impl Into<OrgsGetOrgRulesetHistoryParams>>) -> Result<Vec<RulesetVersion>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/rulesets/{}/history", super::GITHUB_BASE_API_URL, org, ruleset_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(OrgsGetOrgRulesetHistoryError::Status404(github_response.to_json_async().await?).into()),
500 => Err(OrgsGetOrgRulesetHistoryError::Status500(github_response.to_json_async().await?).into()),
code => Err(OrgsGetOrgRulesetHistoryError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get organization ruleset history
///
/// Get the history of an organization ruleset.
///
/// [GitHub API docs for get_org_ruleset_history](https://docs.github.com/rest/orgs/rules#get-organization-ruleset-history)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_org_ruleset_history(&self, org: &str, ruleset_id: i32, query_params: Option<impl Into<OrgsGetOrgRulesetHistoryParams>>) -> Result<Vec<RulesetVersion>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/rulesets/{}/history", super::GITHUB_BASE_API_URL, org, ruleset_id);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: OrgsGetOrgRulesetHistoryParams = 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(OrgsGetOrgRulesetHistoryError::Status404(github_response.to_json()?).into()),
500 => Err(OrgsGetOrgRulesetHistoryError::Status500(github_response.to_json()?).into()),
code => Err(OrgsGetOrgRulesetHistoryError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get organization ruleset version
///
/// Get a version of an organization ruleset.
///
/// [GitHub API docs for get_org_ruleset_version](https://docs.github.com/rest/orgs/rules#get-organization-ruleset-version)
///
/// ---
pub async fn get_org_ruleset_version_async(&self, org: &str, ruleset_id: i32, version_id: i32) -> Result<RulesetVersionWithState, AdapterError> {
let request_uri = format!("{}/orgs/{}/rulesets/{}/history/{}", super::GITHUB_BASE_API_URL, org, ruleset_id, version_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(OrgsGetOrgRulesetVersionError::Status404(github_response.to_json_async().await?).into()),
500 => Err(OrgsGetOrgRulesetVersionError::Status500(github_response.to_json_async().await?).into()),
code => Err(OrgsGetOrgRulesetVersionError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get organization ruleset version
///
/// Get a version of an organization ruleset.
///
/// [GitHub API docs for get_org_ruleset_version](https://docs.github.com/rest/orgs/rules#get-organization-ruleset-version)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_org_ruleset_version(&self, org: &str, ruleset_id: i32, version_id: i32) -> Result<RulesetVersionWithState, AdapterError> {
let request_uri = format!("{}/orgs/{}/rulesets/{}/history/{}", super::GITHUB_BASE_API_URL, org, ruleset_id, version_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(OrgsGetOrgRulesetVersionError::Status404(github_response.to_json()?).into()),
500 => Err(OrgsGetOrgRulesetVersionError::Status500(github_response.to_json()?).into()),
code => Err(OrgsGetOrgRulesetVersionError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get route stats by actor
///
/// Get API request count statistics for an actor broken down by route within a specified time frame.
///
/// [GitHub API docs for get_route_stats_by_actor](https://docs.github.com/rest/orgs/api-insights#get-route-stats-by-actor)
///
/// ---
pub async fn get_route_stats_by_actor_async(&self, org: &str, actor_type: &str, actor_id: i32, query_params: impl Into<OrgsGetRouteStatsByActorParams<'api>>) -> Result<ApiInsightsRouteStats, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/insights/api/route-stats/{}/{}", super::GITHUB_BASE_API_URL, org, actor_type, actor_id);
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(query_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(OrgsGetRouteStatsByActorError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get route stats by actor
///
/// Get API request count statistics for an actor broken down by route within a specified time frame.
///
/// [GitHub API docs for get_route_stats_by_actor](https://docs.github.com/rest/orgs/api-insights#get-route-stats-by-actor)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_route_stats_by_actor(&self, org: &str, actor_type: &str, actor_id: i32, query_params: impl Into<OrgsGetRouteStatsByActorParams<'api>>) -> Result<ApiInsightsRouteStats, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/insights/api/route-stats/{}/{}", super::GITHUB_BASE_API_URL, org, actor_type, actor_id);
request_uri.push_str("?");
let qp: OrgsGetRouteStatsByActorParams = query_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(OrgsGetRouteStatsByActorError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get subject stats
///
/// Get API request statistics for all subjects within an organization within a specified time frame. Subjects can be users or GitHub Apps.
///
/// [GitHub API docs for get_subject_stats](https://docs.github.com/rest/orgs/api-insights#get-subject-stats)
///
/// ---
pub async fn get_subject_stats_async(&self, org: &str, query_params: impl Into<OrgsGetSubjectStatsParams<'api>>) -> Result<ApiInsightsSubjectStats, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/insights/api/subject-stats", super::GITHUB_BASE_API_URL, org);
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(query_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(OrgsGetSubjectStatsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get subject stats
///
/// Get API request statistics for all subjects within an organization within a specified time frame. Subjects can be users or GitHub Apps.
///
/// [GitHub API docs for get_subject_stats](https://docs.github.com/rest/orgs/api-insights#get-subject-stats)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_subject_stats(&self, org: &str, query_params: impl Into<OrgsGetSubjectStatsParams<'api>>) -> Result<ApiInsightsSubjectStats, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/insights/api/subject-stats", super::GITHUB_BASE_API_URL, org);
request_uri.push_str("?");
let qp: OrgsGetSubjectStatsParams = query_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(OrgsGetSubjectStatsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get summary stats
///
/// Get overall statistics of API requests made within an organization by all users and apps within a specified time frame.
///
/// [GitHub API docs for get_summary_stats](https://docs.github.com/rest/orgs/api-insights#get-summary-stats)
///
/// ---
pub async fn get_summary_stats_async(&self, org: &str, query_params: impl Into<OrgsGetSummaryStatsParams<'api>>) -> Result<ApiInsightsSummaryStats, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/insights/api/summary-stats", super::GITHUB_BASE_API_URL, org);
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(query_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(OrgsGetSummaryStatsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get summary stats
///
/// Get overall statistics of API requests made within an organization by all users and apps within a specified time frame.
///
/// [GitHub API docs for get_summary_stats](https://docs.github.com/rest/orgs/api-insights#get-summary-stats)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_summary_stats(&self, org: &str, query_params: impl Into<OrgsGetSummaryStatsParams<'api>>) -> Result<ApiInsightsSummaryStats, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/insights/api/summary-stats", super::GITHUB_BASE_API_URL, org);
request_uri.push_str("?");
let qp: OrgsGetSummaryStatsParams = query_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(OrgsGetSummaryStatsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get summary stats by actor
///
/// Get overall statistics of API requests within the organization made by a specific actor. Actors can be GitHub App installations, OAuth apps or other tokens on behalf of a user.
///
/// [GitHub API docs for get_summary_stats_by_actor](https://docs.github.com/rest/orgs/api-insights#get-summary-stats-by-actor)
///
/// ---
pub async fn get_summary_stats_by_actor_async(&self, org: &str, actor_type: &str, actor_id: i32, query_params: impl Into<OrgsGetSummaryStatsByActorParams<'api>>) -> Result<ApiInsightsSummaryStats, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/insights/api/summary-stats/{}/{}", super::GITHUB_BASE_API_URL, org, actor_type, actor_id);
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(query_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(OrgsGetSummaryStatsByActorError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get summary stats by actor
///
/// Get overall statistics of API requests within the organization made by a specific actor. Actors can be GitHub App installations, OAuth apps or other tokens on behalf of a user.
///
/// [GitHub API docs for get_summary_stats_by_actor](https://docs.github.com/rest/orgs/api-insights#get-summary-stats-by-actor)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_summary_stats_by_actor(&self, org: &str, actor_type: &str, actor_id: i32, query_params: impl Into<OrgsGetSummaryStatsByActorParams<'api>>) -> Result<ApiInsightsSummaryStats, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/insights/api/summary-stats/{}/{}", super::GITHUB_BASE_API_URL, org, actor_type, actor_id);
request_uri.push_str("?");
let qp: OrgsGetSummaryStatsByActorParams = query_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(OrgsGetSummaryStatsByActorError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get summary stats by user
///
/// Get overall statistics of API requests within the organization for a user.
///
/// [GitHub API docs for get_summary_stats_by_user](https://docs.github.com/rest/orgs/api-insights#get-summary-stats-by-user)
///
/// ---
pub async fn get_summary_stats_by_user_async(&self, org: &str, user_id: &str, query_params: impl Into<OrgsGetSummaryStatsByUserParams<'api>>) -> Result<ApiInsightsSummaryStats, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/insights/api/summary-stats/users/{}", super::GITHUB_BASE_API_URL, org, user_id);
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(query_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(OrgsGetSummaryStatsByUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get summary stats by user
///
/// Get overall statistics of API requests within the organization for a user.
///
/// [GitHub API docs for get_summary_stats_by_user](https://docs.github.com/rest/orgs/api-insights#get-summary-stats-by-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_summary_stats_by_user(&self, org: &str, user_id: &str, query_params: impl Into<OrgsGetSummaryStatsByUserParams<'api>>) -> Result<ApiInsightsSummaryStats, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/insights/api/summary-stats/users/{}", super::GITHUB_BASE_API_URL, org, user_id);
request_uri.push_str("?");
let qp: OrgsGetSummaryStatsByUserParams = query_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(OrgsGetSummaryStatsByUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get time stats
///
/// Get the number of API requests and rate-limited requests made within an organization over a specified time period.
///
/// [GitHub API docs for get_time_stats](https://docs.github.com/rest/orgs/api-insights#get-time-stats)
///
/// ---
pub async fn get_time_stats_async(&self, org: &str, query_params: impl Into<OrgsGetTimeStatsParams<'api>>) -> Result<ApiInsightsTimeStats, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/insights/api/time-stats", super::GITHUB_BASE_API_URL, org);
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(query_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(OrgsGetTimeStatsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get time stats
///
/// Get the number of API requests and rate-limited requests made within an organization over a specified time period.
///
/// [GitHub API docs for get_time_stats](https://docs.github.com/rest/orgs/api-insights#get-time-stats)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_time_stats(&self, org: &str, query_params: impl Into<OrgsGetTimeStatsParams<'api>>) -> Result<ApiInsightsTimeStats, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/insights/api/time-stats", super::GITHUB_BASE_API_URL, org);
request_uri.push_str("?");
let qp: OrgsGetTimeStatsParams = query_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(OrgsGetTimeStatsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get time stats by actor
///
/// Get the number of API requests and rate-limited requests made within an organization by a specific actor within a specified time period.
///
/// [GitHub API docs for get_time_stats_by_actor](https://docs.github.com/rest/orgs/api-insights#get-time-stats-by-actor)
///
/// ---
pub async fn get_time_stats_by_actor_async(&self, org: &str, actor_type: &str, actor_id: i32, query_params: impl Into<OrgsGetTimeStatsByActorParams<'api>>) -> Result<ApiInsightsTimeStats, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/insights/api/time-stats/{}/{}", super::GITHUB_BASE_API_URL, org, actor_type, actor_id);
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(query_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(OrgsGetTimeStatsByActorError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get time stats by actor
///
/// Get the number of API requests and rate-limited requests made within an organization by a specific actor within a specified time period.
///
/// [GitHub API docs for get_time_stats_by_actor](https://docs.github.com/rest/orgs/api-insights#get-time-stats-by-actor)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_time_stats_by_actor(&self, org: &str, actor_type: &str, actor_id: i32, query_params: impl Into<OrgsGetTimeStatsByActorParams<'api>>) -> Result<ApiInsightsTimeStats, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/insights/api/time-stats/{}/{}", super::GITHUB_BASE_API_URL, org, actor_type, actor_id);
request_uri.push_str("?");
let qp: OrgsGetTimeStatsByActorParams = query_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(OrgsGetTimeStatsByActorError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get time stats by user
///
/// Get the number of API requests and rate-limited requests made within an organization by a specific user over a specified time period.
///
/// [GitHub API docs for get_time_stats_by_user](https://docs.github.com/rest/orgs/api-insights#get-time-stats-by-user)
///
/// ---
pub async fn get_time_stats_by_user_async(&self, org: &str, user_id: &str, query_params: impl Into<OrgsGetTimeStatsByUserParams<'api>>) -> Result<ApiInsightsTimeStats, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/insights/api/time-stats/users/{}", super::GITHUB_BASE_API_URL, org, user_id);
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(query_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(OrgsGetTimeStatsByUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get time stats by user
///
/// Get the number of API requests and rate-limited requests made within an organization by a specific user over a specified time period.
///
/// [GitHub API docs for get_time_stats_by_user](https://docs.github.com/rest/orgs/api-insights#get-time-stats-by-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_time_stats_by_user(&self, org: &str, user_id: &str, query_params: impl Into<OrgsGetTimeStatsByUserParams<'api>>) -> Result<ApiInsightsTimeStats, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/insights/api/time-stats/users/{}", super::GITHUB_BASE_API_URL, org, user_id);
request_uri.push_str("?");
let qp: OrgsGetTimeStatsByUserParams = query_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(OrgsGetTimeStatsByUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get user stats
///
/// Get API usage statistics within an organization for a user broken down by the type of access.
///
/// [GitHub API docs for get_user_stats](https://docs.github.com/rest/orgs/api-insights#get-user-stats)
///
/// ---
pub async fn get_user_stats_async(&self, org: &str, user_id: &str, query_params: impl Into<OrgsGetUserStatsParams<'api>>) -> Result<ApiInsightsUserStats, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/insights/api/user-stats/{}", super::GITHUB_BASE_API_URL, org, user_id);
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(query_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(OrgsGetUserStatsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get user stats
///
/// Get API usage statistics within an organization for a user broken down by the type of access.
///
/// [GitHub API docs for get_user_stats](https://docs.github.com/rest/orgs/api-insights#get-user-stats)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_user_stats(&self, org: &str, user_id: &str, query_params: impl Into<OrgsGetUserStatsParams<'api>>) -> Result<ApiInsightsUserStats, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/insights/api/user-stats/{}", super::GITHUB_BASE_API_URL, org, user_id);
request_uri.push_str("?");
let qp: OrgsGetUserStatsParams = query_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(OrgsGetUserStatsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get an organization webhook
///
/// Returns a webhook configured in an organization. To get only the webhook
/// `config` properties, see "[Get a webhook configuration for an organization](/rest/orgs/webhooks#get-a-webhook-configuration-for-an-organization).
///
/// You must be an organization owner to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need `admin:org_hook` scope. OAuth apps cannot list, view, or edit
/// webhooks that they did not create and users cannot list, view, or edit webhooks that were created by OAuth apps.
///
/// [GitHub API docs for get_webhook](https://docs.github.com/rest/orgs/webhooks#get-an-organization-webhook)
///
/// ---
pub async fn get_webhook_async(&self, org: &str, hook_id: i32) -> Result<OrgHook, AdapterError> {
let request_uri = format!("{}/orgs/{}/hooks/{}", super::GITHUB_BASE_API_URL, org, hook_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(OrgsGetWebhookError::Status404(github_response.to_json_async().await?).into()),
code => Err(OrgsGetWebhookError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get an organization webhook
///
/// Returns a webhook configured in an organization. To get only the webhook
/// `config` properties, see "[Get a webhook configuration for an organization](/rest/orgs/webhooks#get-a-webhook-configuration-for-an-organization).
///
/// You must be an organization owner to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need `admin:org_hook` scope. OAuth apps cannot list, view, or edit
/// webhooks that they did not create and users cannot list, view, or edit webhooks that were created by OAuth apps.
///
/// [GitHub API docs for get_webhook](https://docs.github.com/rest/orgs/webhooks#get-an-organization-webhook)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_webhook(&self, org: &str, hook_id: i32) -> Result<OrgHook, AdapterError> {
let request_uri = format!("{}/orgs/{}/hooks/{}", super::GITHUB_BASE_API_URL, org, hook_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(OrgsGetWebhookError::Status404(github_response.to_json()?).into()),
code => Err(OrgsGetWebhookError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a webhook configuration for an organization
///
/// Returns the webhook configuration for an organization. To get more information about the webhook, including the `active` state and `events`, use "[Get an organization webhook ](/rest/orgs/webhooks#get-an-organization-webhook)."
///
/// You must be an organization owner to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need `admin:org_hook` scope. OAuth apps cannot list, view, or edit
/// webhooks that they did not create and users cannot list, view, or edit webhooks that were created by OAuth apps.
///
/// [GitHub API docs for get_webhook_config_for_org](https://docs.github.com/rest/orgs/webhooks#get-a-webhook-configuration-for-an-organization)
///
/// ---
pub async fn get_webhook_config_for_org_async(&self, org: &str, hook_id: i32) -> Result<WebhookConfig, AdapterError> {
let request_uri = format!("{}/orgs/{}/hooks/{}/config", super::GITHUB_BASE_API_URL, org, hook_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() {
code => Err(OrgsGetWebhookConfigForOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a webhook configuration for an organization
///
/// Returns the webhook configuration for an organization. To get more information about the webhook, including the `active` state and `events`, use "[Get an organization webhook ](/rest/orgs/webhooks#get-an-organization-webhook)."
///
/// You must be an organization owner to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need `admin:org_hook` scope. OAuth apps cannot list, view, or edit
/// webhooks that they did not create and users cannot list, view, or edit webhooks that were created by OAuth apps.
///
/// [GitHub API docs for get_webhook_config_for_org](https://docs.github.com/rest/orgs/webhooks#get-a-webhook-configuration-for-an-organization)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_webhook_config_for_org(&self, org: &str, hook_id: i32) -> Result<WebhookConfig, AdapterError> {
let request_uri = format!("{}/orgs/{}/hooks/{}/config", super::GITHUB_BASE_API_URL, org, hook_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() {
code => Err(OrgsGetWebhookConfigForOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a webhook delivery for an organization webhook
///
/// Returns a delivery for a webhook configured in an organization.
///
/// You must be an organization owner to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need `admin:org_hook` scope. OAuth apps cannot list, view, or edit
/// webhooks that they did not create and users cannot list, view, or edit webhooks that were created by OAuth apps.
///
/// [GitHub API docs for get_webhook_delivery](https://docs.github.com/rest/orgs/webhooks#get-a-webhook-delivery-for-an-organization-webhook)
///
/// ---
pub async fn get_webhook_delivery_async(&self, org: &str, hook_id: i32, delivery_id: i32) -> Result<HookDelivery, AdapterError> {
let request_uri = format!("{}/orgs/{}/hooks/{}/deliveries/{}", super::GITHUB_BASE_API_URL, org, hook_id, delivery_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() {
400 => Err(OrgsGetWebhookDeliveryError::Status400(github_response.to_json_async().await?).into()),
422 => Err(OrgsGetWebhookDeliveryError::Status422(github_response.to_json_async().await?).into()),
code => Err(OrgsGetWebhookDeliveryError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a webhook delivery for an organization webhook
///
/// Returns a delivery for a webhook configured in an organization.
///
/// You must be an organization owner to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need `admin:org_hook` scope. OAuth apps cannot list, view, or edit
/// webhooks that they did not create and users cannot list, view, or edit webhooks that were created by OAuth apps.
///
/// [GitHub API docs for get_webhook_delivery](https://docs.github.com/rest/orgs/webhooks#get-a-webhook-delivery-for-an-organization-webhook)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_webhook_delivery(&self, org: &str, hook_id: i32, delivery_id: i32) -> Result<HookDelivery, AdapterError> {
let request_uri = format!("{}/orgs/{}/hooks/{}/deliveries/{}", super::GITHUB_BASE_API_URL, org, hook_id, delivery_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() {
400 => Err(OrgsGetWebhookDeliveryError::Status400(github_response.to_json()?).into()),
422 => Err(OrgsGetWebhookDeliveryError::Status422(github_response.to_json()?).into()),
code => Err(OrgsGetWebhookDeliveryError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List organizations
///
/// Lists all organizations, in the order that they were created.
///
/// > [!NOTE]
/// > Pagination is powered exclusively by the `since` parameter. Use the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers) to get the URL for the next page of organizations.
///
/// [GitHub API docs for list](https://docs.github.com/rest/orgs/orgs#list-organizations)
///
/// ---
pub async fn list_async(&self, query_params: Option<impl Into<OrgsListParams>>) -> Result<Vec<OrganizationSimple>, AdapterError> {
let mut request_uri = format!("{}/organizations", 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(OrgsListError::Status304.into()),
code => Err(OrgsListError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List organizations
///
/// Lists all organizations, in the order that they were created.
///
/// > [!NOTE]
/// > Pagination is powered exclusively by the `since` parameter. Use the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers) to get the URL for the next page of organizations.
///
/// [GitHub API docs for list](https://docs.github.com/rest/orgs/orgs#list-organizations)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list(&self, query_params: Option<impl Into<OrgsListParams>>) -> Result<Vec<OrganizationSimple>, AdapterError> {
let mut request_uri = format!("{}/organizations", super::GITHUB_BASE_API_URL);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: OrgsListParams = 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(OrgsListError::Status304.into()),
code => Err(OrgsListError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List app installations for an organization
///
/// Lists all GitHub Apps in an organization. The installation count includes
/// all GitHub Apps installed on repositories in the organization.
///
/// The authenticated user must be an organization owner to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need the `admin:read` scope to use this endpoint.
///
/// [GitHub API docs for list_app_installations](https://docs.github.com/rest/orgs/orgs#list-app-installations-for-an-organization)
///
/// ---
pub async fn list_app_installations_async(&self, org: &str, query_params: Option<impl Into<OrgsListAppInstallationsParams>>) -> Result<GetAppsListInstallationsForAuthenticatedUserResponse200, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/installations", 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() {
code => Err(OrgsListAppInstallationsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List app installations for an organization
///
/// Lists all GitHub Apps in an organization. The installation count includes
/// all GitHub Apps installed on repositories in the organization.
///
/// The authenticated user must be an organization owner to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need the `admin:read` scope to use this endpoint.
///
/// [GitHub API docs for list_app_installations](https://docs.github.com/rest/orgs/orgs#list-app-installations-for-an-organization)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_app_installations(&self, org: &str, query_params: Option<impl Into<OrgsListAppInstallationsParams>>) -> Result<GetAppsListInstallationsForAuthenticatedUserResponse200, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/installations", super::GITHUB_BASE_API_URL, org);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: OrgsListAppInstallationsParams = 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(OrgsListAppInstallationsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List attestations
///
/// List a collection of artifact attestations with a given subject digest that are associated with repositories owned by an organization.
///
/// The collection of attestations returned by this endpoint is filtered according to the authenticated user's permissions; if the authenticated user cannot read a repository, the attestations associated with that repository will not be included in the response. In addition, when using a fine-grained access token the `attestations:read` permission is required.
///
/// **Please note:** in order to offer meaningful security benefits, an attestation's signature and timestamps **must** be cryptographically verified, and the identity of the attestation signer **must** be validated. Attestations can be verified using the [GitHub CLI `attestation verify` command](https://cli.github.com/manual/gh_attestation_verify). For more information, see [our guide on how to use artifact attestations to establish a build's provenance](https://docs.github.com/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds).
///
/// [GitHub API docs for list_attestations](https://docs.github.com/rest/orgs/orgs#list-attestations)
///
/// ---
pub async fn list_attestations_async(&self, org: &str, subject_digest: &str, query_params: Option<impl Into<OrgsListAttestationsParams<'api>>>) -> Result<GetUsersListAttestationsResponse200, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/attestations/{}", super::GITHUB_BASE_API_URL, org, subject_digest);
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(OrgsListAttestationsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List attestations
///
/// List a collection of artifact attestations with a given subject digest that are associated with repositories owned by an organization.
///
/// The collection of attestations returned by this endpoint is filtered according to the authenticated user's permissions; if the authenticated user cannot read a repository, the attestations associated with that repository will not be included in the response. In addition, when using a fine-grained access token the `attestations:read` permission is required.
///
/// **Please note:** in order to offer meaningful security benefits, an attestation's signature and timestamps **must** be cryptographically verified, and the identity of the attestation signer **must** be validated. Attestations can be verified using the [GitHub CLI `attestation verify` command](https://cli.github.com/manual/gh_attestation_verify). For more information, see [our guide on how to use artifact attestations to establish a build's provenance](https://docs.github.com/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds).
///
/// [GitHub API docs for list_attestations](https://docs.github.com/rest/orgs/orgs#list-attestations)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_attestations(&self, org: &str, subject_digest: &str, query_params: Option<impl Into<OrgsListAttestationsParams<'api>>>) -> Result<GetUsersListAttestationsResponse200, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/attestations/{}", super::GITHUB_BASE_API_URL, org, subject_digest);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: OrgsListAttestationsParams = 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(OrgsListAttestationsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List attestations by bulk subject digests
///
/// List a collection of artifact attestations associated with any entry in a list of subject digests owned by an organization.
///
/// The collection of attestations returned by this endpoint is filtered according to the authenticated user's permissions; if the authenticated user cannot read a repository, the attestations associated with that repository will not be included in the response. In addition, when using a fine-grained access token the `attestations:read` permission is required.
///
/// **Please note:** in order to offer meaningful security benefits, an attestation's signature and timestamps **must** be cryptographically verified, and the identity of the attestation signer **must** be validated. Attestations can be verified using the [GitHub CLI `attestation verify` command](https://cli.github.com/manual/gh_attestation_verify). For more information, see [our guide on how to use artifact attestations to establish a build's provenance](https://docs.github.com/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds).
///
/// [GitHub API docs for list_attestations_bulk](https://docs.github.com/rest/orgs/orgs#list-attestations-by-bulk-subject-digests)
///
/// ---
pub async fn list_attestations_bulk_async(&self, org: &str, query_params: Option<impl Into<OrgsListAttestationsBulkParams<'api>>>, body: PostOrgsListAttestationsBulk) -> Result<PostUsersListAttestationsBulkResponse200, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/attestations/bulk-list", 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: Some(C::from_json::<PostOrgsListAttestationsBulk>(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(OrgsListAttestationsBulkError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List attestations by bulk subject digests
///
/// List a collection of artifact attestations associated with any entry in a list of subject digests owned by an organization.
///
/// The collection of attestations returned by this endpoint is filtered according to the authenticated user's permissions; if the authenticated user cannot read a repository, the attestations associated with that repository will not be included in the response. In addition, when using a fine-grained access token the `attestations:read` permission is required.
///
/// **Please note:** in order to offer meaningful security benefits, an attestation's signature and timestamps **must** be cryptographically verified, and the identity of the attestation signer **must** be validated. Attestations can be verified using the [GitHub CLI `attestation verify` command](https://cli.github.com/manual/gh_attestation_verify). For more information, see [our guide on how to use artifact attestations to establish a build's provenance](https://docs.github.com/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds).
///
/// [GitHub API docs for list_attestations_bulk](https://docs.github.com/rest/orgs/orgs#list-attestations-by-bulk-subject-digests)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_attestations_bulk(&self, org: &str, query_params: Option<impl Into<OrgsListAttestationsBulkParams<'api>>>, body: PostOrgsListAttestationsBulk) -> Result<PostUsersListAttestationsBulkResponse200, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/attestations/bulk-list", super::GITHUB_BASE_API_URL, org);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: OrgsListAttestationsBulkParams = params.into();
request_uri.push_str(&serde_urlencoded::to_string(qp)?);
}
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostOrgsListAttestationsBulk>(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(OrgsListAttestationsBulkError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List users blocked by an organization
///
/// List the users blocked by an organization.
///
/// [GitHub API docs for list_blocked_users](https://docs.github.com/rest/orgs/blocking#list-users-blocked-by-an-organization)
///
/// ---
pub async fn list_blocked_users_async(&self, org: &str, query_params: Option<impl Into<OrgsListBlockedUsersParams>>) -> Result<Vec<SimpleUser>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/blocks", 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() {
code => Err(OrgsListBlockedUsersError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List users blocked by an organization
///
/// List the users blocked by an organization.
///
/// [GitHub API docs for list_blocked_users](https://docs.github.com/rest/orgs/blocking#list-users-blocked-by-an-organization)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_blocked_users(&self, org: &str, query_params: Option<impl Into<OrgsListBlockedUsersParams>>) -> Result<Vec<SimpleUser>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/blocks", super::GITHUB_BASE_API_URL, org);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: OrgsListBlockedUsersParams = 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(OrgsListBlockedUsersError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List custom property values for organization repositories
///
/// Lists organization repositories with all of their custom property values.
/// Organization members can read these properties.
///
/// [GitHub API docs for list_custom_properties_values_for_repos](https://docs.github.com/rest/orgs/custom-properties#list-custom-property-values-for-organization-repositories)
///
/// ---
pub async fn list_custom_properties_values_for_repos_async(&self, org: &str, query_params: Option<impl Into<OrgsListCustomPropertiesValuesForReposParams<'api>>>) -> Result<Vec<OrgRepoCustomPropertyValues>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/properties/values", 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(OrgsListCustomPropertiesValuesForReposError::Status403(github_response.to_json_async().await?).into()),
404 => Err(OrgsListCustomPropertiesValuesForReposError::Status404(github_response.to_json_async().await?).into()),
code => Err(OrgsListCustomPropertiesValuesForReposError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List custom property values for organization repositories
///
/// Lists organization repositories with all of their custom property values.
/// Organization members can read these properties.
///
/// [GitHub API docs for list_custom_properties_values_for_repos](https://docs.github.com/rest/orgs/custom-properties#list-custom-property-values-for-organization-repositories)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_custom_properties_values_for_repos(&self, org: &str, query_params: Option<impl Into<OrgsListCustomPropertiesValuesForReposParams<'api>>>) -> Result<Vec<OrgRepoCustomPropertyValues>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/properties/values", super::GITHUB_BASE_API_URL, org);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: OrgsListCustomPropertiesValuesForReposParams = 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(OrgsListCustomPropertiesValuesForReposError::Status403(github_response.to_json()?).into()),
404 => Err(OrgsListCustomPropertiesValuesForReposError::Status404(github_response.to_json()?).into()),
code => Err(OrgsListCustomPropertiesValuesForReposError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List failed organization invitations
///
/// The return hash contains `failed_at` and `failed_reason` fields which represent the time at which the invitation failed and the reason for the failure.
///
/// [GitHub API docs for list_failed_invitations](https://docs.github.com/rest/orgs/members#list-failed-organization-invitations)
///
/// ---
pub async fn list_failed_invitations_async(&self, org: &str, query_params: Option<impl Into<OrgsListFailedInvitationsParams>>) -> Result<Vec<OrganizationInvitation>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/failed_invitations", 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() {
404 => Err(OrgsListFailedInvitationsError::Status404(github_response.to_json_async().await?).into()),
code => Err(OrgsListFailedInvitationsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List failed organization invitations
///
/// The return hash contains `failed_at` and `failed_reason` fields which represent the time at which the invitation failed and the reason for the failure.
///
/// [GitHub API docs for list_failed_invitations](https://docs.github.com/rest/orgs/members#list-failed-organization-invitations)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_failed_invitations(&self, org: &str, query_params: Option<impl Into<OrgsListFailedInvitationsParams>>) -> Result<Vec<OrganizationInvitation>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/failed_invitations", super::GITHUB_BASE_API_URL, org);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: OrgsListFailedInvitationsParams = 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(OrgsListFailedInvitationsError::Status404(github_response.to_json()?).into()),
code => Err(OrgsListFailedInvitationsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List organizations for the authenticated user
///
/// List organizations for the authenticated user.
///
/// For OAuth app tokens and personal access tokens (classic), this endpoint only lists organizations that your authorization allows you to operate on in some way (e.g., you can list teams with `read:org` scope, you can publicize your organization membership with `user` scope, etc.). Therefore, this API requires at least `user` or `read:org` scope for OAuth app tokens and personal access tokens (classic). Requests with insufficient scope will receive a `403 Forbidden` response.
///
/// > [!NOTE]
/// > Requests using a fine-grained access token will receive a `200 Success` response with an empty list.
///
/// [GitHub API docs for list_for_authenticated_user](https://docs.github.com/rest/orgs/orgs#list-organizations-for-the-authenticated-user)
///
/// ---
pub async fn list_for_authenticated_user_async(&self, query_params: Option<impl Into<OrgsListForAuthenticatedUserParams>>) -> Result<Vec<OrganizationSimple>, AdapterError> {
let mut request_uri = format!("{}/user/orgs", 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(OrgsListForAuthenticatedUserError::Status304.into()),
403 => Err(OrgsListForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()),
401 => Err(OrgsListForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()),
code => Err(OrgsListForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List organizations for the authenticated user
///
/// List organizations for the authenticated user.
///
/// For OAuth app tokens and personal access tokens (classic), this endpoint only lists organizations that your authorization allows you to operate on in some way (e.g., you can list teams with `read:org` scope, you can publicize your organization membership with `user` scope, etc.). Therefore, this API requires at least `user` or `read:org` scope for OAuth app tokens and personal access tokens (classic). Requests with insufficient scope will receive a `403 Forbidden` response.
///
/// > [!NOTE]
/// > Requests using a fine-grained access token will receive a `200 Success` response with an empty list.
///
/// [GitHub API docs for list_for_authenticated_user](https://docs.github.com/rest/orgs/orgs#list-organizations-for-the-authenticated-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_for_authenticated_user(&self, query_params: Option<impl Into<OrgsListForAuthenticatedUserParams>>) -> Result<Vec<OrganizationSimple>, AdapterError> {
let mut request_uri = format!("{}/user/orgs", super::GITHUB_BASE_API_URL);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: OrgsListForAuthenticatedUserParams = 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(OrgsListForAuthenticatedUserError::Status304.into()),
403 => Err(OrgsListForAuthenticatedUserError::Status403(github_response.to_json()?).into()),
401 => Err(OrgsListForAuthenticatedUserError::Status401(github_response.to_json()?).into()),
code => Err(OrgsListForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List organizations for a user
///
/// List [public organization memberships](https://docs.github.com/articles/publicizing-or-concealing-organization-membership) for the specified user.
///
/// This method only lists _public_ memberships, regardless of authentication. If you need to fetch all of the organization memberships (public and private) for the authenticated user, use the [List organizations for the authenticated user](https://docs.github.com/rest/orgs/orgs#list-organizations-for-the-authenticated-user) API instead.
///
/// [GitHub API docs for list_for_user](https://docs.github.com/rest/orgs/orgs#list-organizations-for-a-user)
///
/// ---
pub async fn list_for_user_async(&self, username: &str, query_params: Option<impl Into<OrgsListForUserParams>>) -> Result<Vec<OrganizationSimple>, AdapterError> {
let mut request_uri = format!("{}/users/{}/orgs", super::GITHUB_BASE_API_URL, username);
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(OrgsListForUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List organizations for a user
///
/// List [public organization memberships](https://docs.github.com/articles/publicizing-or-concealing-organization-membership) for the specified user.
///
/// This method only lists _public_ memberships, regardless of authentication. If you need to fetch all of the organization memberships (public and private) for the authenticated user, use the [List organizations for the authenticated user](https://docs.github.com/rest/orgs/orgs#list-organizations-for-the-authenticated-user) API instead.
///
/// [GitHub API docs for list_for_user](https://docs.github.com/rest/orgs/orgs#list-organizations-for-a-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_for_user(&self, username: &str, query_params: Option<impl Into<OrgsListForUserParams>>) -> Result<Vec<OrganizationSimple>, AdapterError> {
let mut request_uri = format!("{}/users/{}/orgs", super::GITHUB_BASE_API_URL, username);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: OrgsListForUserParams = 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(OrgsListForUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List organization invitation teams
///
/// List all teams associated with an invitation. In order to see invitations in an organization, the authenticated user must be an organization owner.
///
/// [GitHub API docs for list_invitation_teams](https://docs.github.com/rest/orgs/members#list-organization-invitation-teams)
///
/// ---
pub async fn list_invitation_teams_async(&self, org: &str, invitation_id: i32, query_params: Option<impl Into<OrgsListInvitationTeamsParams>>) -> Result<Vec<Team>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/invitations/{}/teams", super::GITHUB_BASE_API_URL, org, invitation_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(OrgsListInvitationTeamsError::Status404(github_response.to_json_async().await?).into()),
code => Err(OrgsListInvitationTeamsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List organization invitation teams
///
/// List all teams associated with an invitation. In order to see invitations in an organization, the authenticated user must be an organization owner.
///
/// [GitHub API docs for list_invitation_teams](https://docs.github.com/rest/orgs/members#list-organization-invitation-teams)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_invitation_teams(&self, org: &str, invitation_id: i32, query_params: Option<impl Into<OrgsListInvitationTeamsParams>>) -> Result<Vec<Team>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/invitations/{}/teams", super::GITHUB_BASE_API_URL, org, invitation_id);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: OrgsListInvitationTeamsParams = 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(OrgsListInvitationTeamsError::Status404(github_response.to_json()?).into()),
code => Err(OrgsListInvitationTeamsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List issue types for an organization
///
/// Lists all issue types for an organization. OAuth app tokens and personal access tokens (classic) need the read:org scope to use this endpoint.
///
/// [GitHub API docs for list_issue_types](https://docs.github.com/rest/orgs/issue-types#list-issue-types-for-an-organization)
///
/// ---
pub async fn list_issue_types_async(&self, org: &str) -> Result<Vec<IssueType>, AdapterError> {
let request_uri = format!("{}/orgs/{}/issue-types", super::GITHUB_BASE_API_URL, org);
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(OrgsListIssueTypesError::Status404(github_response.to_json_async().await?).into()),
code => Err(OrgsListIssueTypesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List issue types for an organization
///
/// Lists all issue types for an organization. OAuth app tokens and personal access tokens (classic) need the read:org scope to use this endpoint.
///
/// [GitHub API docs for list_issue_types](https://docs.github.com/rest/orgs/issue-types#list-issue-types-for-an-organization)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_issue_types(&self, org: &str) -> Result<Vec<IssueType>, AdapterError> {
let request_uri = format!("{}/orgs/{}/issue-types", super::GITHUB_BASE_API_URL, org);
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(OrgsListIssueTypesError::Status404(github_response.to_json()?).into()),
code => Err(OrgsListIssueTypesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List organization members
///
/// List all users who are members of an organization. If the authenticated user is also a member of this organization then both concealed and public members will be returned.
///
/// [GitHub API docs for list_members](https://docs.github.com/rest/orgs/members#list-organization-members)
///
/// ---
pub async fn list_members_async(&self, org: &str, query_params: Option<impl Into<OrgsListMembersParams<'api>>>) -> Result<Vec<SimpleUser>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/members", 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() {
422 => Err(OrgsListMembersError::Status422(github_response.to_json_async().await?).into()),
code => Err(OrgsListMembersError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List organization members
///
/// List all users who are members of an organization. If the authenticated user is also a member of this organization then both concealed and public members will be returned.
///
/// [GitHub API docs for list_members](https://docs.github.com/rest/orgs/members#list-organization-members)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_members(&self, org: &str, query_params: Option<impl Into<OrgsListMembersParams<'api>>>) -> Result<Vec<SimpleUser>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/members", super::GITHUB_BASE_API_URL, org);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: OrgsListMembersParams = 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() {
422 => Err(OrgsListMembersError::Status422(github_response.to_json()?).into()),
code => Err(OrgsListMembersError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List organization memberships for the authenticated user
///
/// Lists all of the authenticated user's organization memberships.
///
/// [GitHub API docs for list_memberships_for_authenticated_user](https://docs.github.com/rest/orgs/members#list-organization-memberships-for-the-authenticated-user)
///
/// ---
pub async fn list_memberships_for_authenticated_user_async(&self, query_params: Option<impl Into<OrgsListMembershipsForAuthenticatedUserParams<'api>>>) -> Result<Vec<OrgMembership>, AdapterError> {
let mut request_uri = format!("{}/user/memberships/orgs", 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(OrgsListMembershipsForAuthenticatedUserError::Status304.into()),
403 => Err(OrgsListMembershipsForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()),
401 => Err(OrgsListMembershipsForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()),
422 => Err(OrgsListMembershipsForAuthenticatedUserError::Status422(github_response.to_json_async().await?).into()),
code => Err(OrgsListMembershipsForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List organization memberships for the authenticated user
///
/// Lists all of the authenticated user's organization memberships.
///
/// [GitHub API docs for list_memberships_for_authenticated_user](https://docs.github.com/rest/orgs/members#list-organization-memberships-for-the-authenticated-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_memberships_for_authenticated_user(&self, query_params: Option<impl Into<OrgsListMembershipsForAuthenticatedUserParams<'api>>>) -> Result<Vec<OrgMembership>, AdapterError> {
let mut request_uri = format!("{}/user/memberships/orgs", super::GITHUB_BASE_API_URL);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: OrgsListMembershipsForAuthenticatedUserParams = 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(OrgsListMembershipsForAuthenticatedUserError::Status304.into()),
403 => Err(OrgsListMembershipsForAuthenticatedUserError::Status403(github_response.to_json()?).into()),
401 => Err(OrgsListMembershipsForAuthenticatedUserError::Status401(github_response.to_json()?).into()),
422 => Err(OrgsListMembershipsForAuthenticatedUserError::Status422(github_response.to_json()?).into()),
code => Err(OrgsListMembershipsForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List teams that are assigned to an organization role
///
/// Lists the teams that are assigned to an organization role. For more information on organization roles, see "[Using organization roles](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/using-organization-roles)."
///
/// To use this endpoint, you must be an administrator for the organization.
///
/// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint.
///
/// [GitHub API docs for list_org_role_teams](https://docs.github.com/rest/orgs/organization-roles#list-teams-that-are-assigned-to-an-organization-role)
///
/// ---
pub async fn list_org_role_teams_async(&self, org: &str, role_id: i32, query_params: Option<impl Into<OrgsListOrgRoleTeamsParams>>) -> Result<Vec<TeamRoleAssignment>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/organization-roles/{}/teams", super::GITHUB_BASE_API_URL, org, role_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(OrgsListOrgRoleTeamsError::Status404.into()),
422 => Err(OrgsListOrgRoleTeamsError::Status422.into()),
code => Err(OrgsListOrgRoleTeamsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List teams that are assigned to an organization role
///
/// Lists the teams that are assigned to an organization role. For more information on organization roles, see "[Using organization roles](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/using-organization-roles)."
///
/// To use this endpoint, you must be an administrator for the organization.
///
/// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint.
///
/// [GitHub API docs for list_org_role_teams](https://docs.github.com/rest/orgs/organization-roles#list-teams-that-are-assigned-to-an-organization-role)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_org_role_teams(&self, org: &str, role_id: i32, query_params: Option<impl Into<OrgsListOrgRoleTeamsParams>>) -> Result<Vec<TeamRoleAssignment>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/organization-roles/{}/teams", super::GITHUB_BASE_API_URL, org, role_id);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: OrgsListOrgRoleTeamsParams = 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(OrgsListOrgRoleTeamsError::Status404.into()),
422 => Err(OrgsListOrgRoleTeamsError::Status422.into()),
code => Err(OrgsListOrgRoleTeamsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List users that are assigned to an organization role
///
/// Lists organization members that are assigned to an organization role. For more information on organization roles, see "[Using organization roles](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/using-organization-roles)."
///
/// To use this endpoint, you must be an administrator for the organization.
///
/// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint.
///
/// [GitHub API docs for list_org_role_users](https://docs.github.com/rest/orgs/organization-roles#list-users-that-are-assigned-to-an-organization-role)
///
/// ---
pub async fn list_org_role_users_async(&self, org: &str, role_id: i32, query_params: Option<impl Into<OrgsListOrgRoleUsersParams>>) -> Result<Vec<UserRoleAssignment>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/organization-roles/{}/users", super::GITHUB_BASE_API_URL, org, role_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(OrgsListOrgRoleUsersError::Status404.into()),
422 => Err(OrgsListOrgRoleUsersError::Status422.into()),
code => Err(OrgsListOrgRoleUsersError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List users that are assigned to an organization role
///
/// Lists organization members that are assigned to an organization role. For more information on organization roles, see "[Using organization roles](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/using-organization-roles)."
///
/// To use this endpoint, you must be an administrator for the organization.
///
/// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint.
///
/// [GitHub API docs for list_org_role_users](https://docs.github.com/rest/orgs/organization-roles#list-users-that-are-assigned-to-an-organization-role)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_org_role_users(&self, org: &str, role_id: i32, query_params: Option<impl Into<OrgsListOrgRoleUsersParams>>) -> Result<Vec<UserRoleAssignment>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/organization-roles/{}/users", super::GITHUB_BASE_API_URL, org, role_id);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: OrgsListOrgRoleUsersParams = 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(OrgsListOrgRoleUsersError::Status404.into()),
422 => Err(OrgsListOrgRoleUsersError::Status422.into()),
code => Err(OrgsListOrgRoleUsersError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get all organization roles for an organization
///
/// Lists the organization roles available in this organization. For more information on organization roles, see "[Using organization roles](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/using-organization-roles)."
///
/// To use this endpoint, the authenticated user must be one of:
///
/// - An administrator for the organization.
/// - A user, or a user on a team, with the fine-grained permissions of `read_organization_custom_org_role` in the organization.
///
/// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint.
///
/// [GitHub API docs for list_org_roles](https://docs.github.com/rest/orgs/organization-roles#get-all-organization-roles-for-an-organization)
///
/// ---
pub async fn list_org_roles_async(&self, org: &str) -> Result<GetOrgsListOrgRolesResponse200, AdapterError> {
let request_uri = format!("{}/orgs/{}/organization-roles", super::GITHUB_BASE_API_URL, org);
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(OrgsListOrgRolesError::Status404(github_response.to_json_async().await?).into()),
422 => Err(OrgsListOrgRolesError::Status422(github_response.to_json_async().await?).into()),
code => Err(OrgsListOrgRolesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get all organization roles for an organization
///
/// Lists the organization roles available in this organization. For more information on organization roles, see "[Using organization roles](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/using-organization-roles)."
///
/// To use this endpoint, the authenticated user must be one of:
///
/// - An administrator for the organization.
/// - A user, or a user on a team, with the fine-grained permissions of `read_organization_custom_org_role` in the organization.
///
/// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint.
///
/// [GitHub API docs for list_org_roles](https://docs.github.com/rest/orgs/organization-roles#get-all-organization-roles-for-an-organization)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_org_roles(&self, org: &str) -> Result<GetOrgsListOrgRolesResponse200, AdapterError> {
let request_uri = format!("{}/orgs/{}/organization-roles", super::GITHUB_BASE_API_URL, org);
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(OrgsListOrgRolesError::Status404(github_response.to_json()?).into()),
422 => Err(OrgsListOrgRolesError::Status422(github_response.to_json()?).into()),
code => Err(OrgsListOrgRolesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List outside collaborators for an organization
///
/// List all users who are outside collaborators of an organization.
///
/// [GitHub API docs for list_outside_collaborators](https://docs.github.com/rest/orgs/outside-collaborators#list-outside-collaborators-for-an-organization)
///
/// ---
pub async fn list_outside_collaborators_async(&self, org: &str, query_params: Option<impl Into<OrgsListOutsideCollaboratorsParams<'api>>>) -> Result<Vec<SimpleUser>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/outside_collaborators", 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() {
code => Err(OrgsListOutsideCollaboratorsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List outside collaborators for an organization
///
/// List all users who are outside collaborators of an organization.
///
/// [GitHub API docs for list_outside_collaborators](https://docs.github.com/rest/orgs/outside-collaborators#list-outside-collaborators-for-an-organization)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_outside_collaborators(&self, org: &str, query_params: Option<impl Into<OrgsListOutsideCollaboratorsParams<'api>>>) -> Result<Vec<SimpleUser>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/outside_collaborators", super::GITHUB_BASE_API_URL, org);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: OrgsListOutsideCollaboratorsParams = 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(OrgsListOutsideCollaboratorsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List repositories a fine-grained personal access token has access to
///
/// Lists the repositories a fine-grained personal access token has access to.
///
/// Only GitHub Apps can use this endpoint.
///
/// [GitHub API docs for list_pat_grant_repositories](https://docs.github.com/rest/orgs/personal-access-tokens#list-repositories-a-fine-grained-personal-access-token-has-access-to)
///
/// ---
pub async fn list_pat_grant_repositories_async(&self, org: &str, pat_id: i32, query_params: Option<impl Into<OrgsListPatGrantRepositoriesParams>>) -> Result<Vec<MinimalRepository>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/personal-access-tokens/{}/repositories", super::GITHUB_BASE_API_URL, org, pat_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() {
500 => Err(OrgsListPatGrantRepositoriesError::Status500(github_response.to_json_async().await?).into()),
404 => Err(OrgsListPatGrantRepositoriesError::Status404(github_response.to_json_async().await?).into()),
403 => Err(OrgsListPatGrantRepositoriesError::Status403(github_response.to_json_async().await?).into()),
code => Err(OrgsListPatGrantRepositoriesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List repositories a fine-grained personal access token has access to
///
/// Lists the repositories a fine-grained personal access token has access to.
///
/// Only GitHub Apps can use this endpoint.
///
/// [GitHub API docs for list_pat_grant_repositories](https://docs.github.com/rest/orgs/personal-access-tokens#list-repositories-a-fine-grained-personal-access-token-has-access-to)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_pat_grant_repositories(&self, org: &str, pat_id: i32, query_params: Option<impl Into<OrgsListPatGrantRepositoriesParams>>) -> Result<Vec<MinimalRepository>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/personal-access-tokens/{}/repositories", super::GITHUB_BASE_API_URL, org, pat_id);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: OrgsListPatGrantRepositoriesParams = 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() {
500 => Err(OrgsListPatGrantRepositoriesError::Status500(github_response.to_json()?).into()),
404 => Err(OrgsListPatGrantRepositoriesError::Status404(github_response.to_json()?).into()),
403 => Err(OrgsListPatGrantRepositoriesError::Status403(github_response.to_json()?).into()),
code => Err(OrgsListPatGrantRepositoriesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List repositories requested to be accessed by a fine-grained personal access token
///
/// Lists the repositories a fine-grained personal access token request is requesting access to.
///
/// Only GitHub Apps can use this endpoint.
///
/// [GitHub API docs for list_pat_grant_request_repositories](https://docs.github.com/rest/orgs/personal-access-tokens#list-repositories-requested-to-be-accessed-by-a-fine-grained-personal-access-token)
///
/// ---
pub async fn list_pat_grant_request_repositories_async(&self, org: &str, pat_request_id: i32, query_params: Option<impl Into<OrgsListPatGrantRequestRepositoriesParams>>) -> Result<Vec<MinimalRepository>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/personal-access-token-requests/{}/repositories", super::GITHUB_BASE_API_URL, org, pat_request_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() {
500 => Err(OrgsListPatGrantRequestRepositoriesError::Status500(github_response.to_json_async().await?).into()),
404 => Err(OrgsListPatGrantRequestRepositoriesError::Status404(github_response.to_json_async().await?).into()),
403 => Err(OrgsListPatGrantRequestRepositoriesError::Status403(github_response.to_json_async().await?).into()),
code => Err(OrgsListPatGrantRequestRepositoriesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List repositories requested to be accessed by a fine-grained personal access token
///
/// Lists the repositories a fine-grained personal access token request is requesting access to.
///
/// Only GitHub Apps can use this endpoint.
///
/// [GitHub API docs for list_pat_grant_request_repositories](https://docs.github.com/rest/orgs/personal-access-tokens#list-repositories-requested-to-be-accessed-by-a-fine-grained-personal-access-token)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_pat_grant_request_repositories(&self, org: &str, pat_request_id: i32, query_params: Option<impl Into<OrgsListPatGrantRequestRepositoriesParams>>) -> Result<Vec<MinimalRepository>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/personal-access-token-requests/{}/repositories", super::GITHUB_BASE_API_URL, org, pat_request_id);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: OrgsListPatGrantRequestRepositoriesParams = 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() {
500 => Err(OrgsListPatGrantRequestRepositoriesError::Status500(github_response.to_json()?).into()),
404 => Err(OrgsListPatGrantRequestRepositoriesError::Status404(github_response.to_json()?).into()),
403 => Err(OrgsListPatGrantRequestRepositoriesError::Status403(github_response.to_json()?).into()),
code => Err(OrgsListPatGrantRequestRepositoriesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List requests to access organization resources with fine-grained personal access tokens
///
/// Lists requests from organization members to access organization resources with a fine-grained personal access token.
///
/// Only GitHub Apps can use this endpoint.
///
/// [GitHub API docs for list_pat_grant_requests](https://docs.github.com/rest/orgs/personal-access-tokens#list-requests-to-access-organization-resources-with-fine-grained-personal-access-tokens)
///
/// ---
pub async fn list_pat_grant_requests_async(&self, org: &str, query_params: Option<impl Into<OrgsListPatGrantRequestsParams<'api>>>) -> Result<Vec<OrganizationProgrammaticAccessGrantRequest>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/personal-access-token-requests", 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() {
500 => Err(OrgsListPatGrantRequestsError::Status500(github_response.to_json_async().await?).into()),
422 => Err(OrgsListPatGrantRequestsError::Status422(github_response.to_json_async().await?).into()),
404 => Err(OrgsListPatGrantRequestsError::Status404(github_response.to_json_async().await?).into()),
403 => Err(OrgsListPatGrantRequestsError::Status403(github_response.to_json_async().await?).into()),
code => Err(OrgsListPatGrantRequestsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List requests to access organization resources with fine-grained personal access tokens
///
/// Lists requests from organization members to access organization resources with a fine-grained personal access token.
///
/// Only GitHub Apps can use this endpoint.
///
/// [GitHub API docs for list_pat_grant_requests](https://docs.github.com/rest/orgs/personal-access-tokens#list-requests-to-access-organization-resources-with-fine-grained-personal-access-tokens)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_pat_grant_requests(&self, org: &str, query_params: Option<impl Into<OrgsListPatGrantRequestsParams<'api>>>) -> Result<Vec<OrganizationProgrammaticAccessGrantRequest>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/personal-access-token-requests", super::GITHUB_BASE_API_URL, org);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: OrgsListPatGrantRequestsParams = 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() {
500 => Err(OrgsListPatGrantRequestsError::Status500(github_response.to_json()?).into()),
422 => Err(OrgsListPatGrantRequestsError::Status422(github_response.to_json()?).into()),
404 => Err(OrgsListPatGrantRequestsError::Status404(github_response.to_json()?).into()),
403 => Err(OrgsListPatGrantRequestsError::Status403(github_response.to_json()?).into()),
code => Err(OrgsListPatGrantRequestsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List fine-grained personal access tokens with access to organization resources
///
/// Lists approved fine-grained personal access tokens owned by organization members that can access organization resources.
///
/// Only GitHub Apps can use this endpoint.
///
/// [GitHub API docs for list_pat_grants](https://docs.github.com/rest/orgs/personal-access-tokens#list-fine-grained-personal-access-tokens-with-access-to-organization-resources)
///
/// ---
pub async fn list_pat_grants_async(&self, org: &str, query_params: Option<impl Into<OrgsListPatGrantsParams<'api>>>) -> Result<Vec<OrganizationProgrammaticAccessGrant>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/personal-access-tokens", 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() {
500 => Err(OrgsListPatGrantsError::Status500(github_response.to_json_async().await?).into()),
422 => Err(OrgsListPatGrantsError::Status422(github_response.to_json_async().await?).into()),
404 => Err(OrgsListPatGrantsError::Status404(github_response.to_json_async().await?).into()),
403 => Err(OrgsListPatGrantsError::Status403(github_response.to_json_async().await?).into()),
code => Err(OrgsListPatGrantsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List fine-grained personal access tokens with access to organization resources
///
/// Lists approved fine-grained personal access tokens owned by organization members that can access organization resources.
///
/// Only GitHub Apps can use this endpoint.
///
/// [GitHub API docs for list_pat_grants](https://docs.github.com/rest/orgs/personal-access-tokens#list-fine-grained-personal-access-tokens-with-access-to-organization-resources)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_pat_grants(&self, org: &str, query_params: Option<impl Into<OrgsListPatGrantsParams<'api>>>) -> Result<Vec<OrganizationProgrammaticAccessGrant>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/personal-access-tokens", super::GITHUB_BASE_API_URL, org);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: OrgsListPatGrantsParams = 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() {
500 => Err(OrgsListPatGrantsError::Status500(github_response.to_json()?).into()),
422 => Err(OrgsListPatGrantsError::Status422(github_response.to_json()?).into()),
404 => Err(OrgsListPatGrantsError::Status404(github_response.to_json()?).into()),
403 => Err(OrgsListPatGrantsError::Status403(github_response.to_json()?).into()),
code => Err(OrgsListPatGrantsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List pending organization 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`, or `hiring_manager`. 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](https://docs.github.com/rest/orgs/members#list-pending-organization-invitations)
///
/// ---
pub async fn list_pending_invitations_async(&self, org: &str, query_params: Option<impl Into<OrgsListPendingInvitationsParams<'api>>>) -> Result<Vec<OrganizationInvitation>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/invitations", 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() {
404 => Err(OrgsListPendingInvitationsError::Status404(github_response.to_json_async().await?).into()),
code => Err(OrgsListPendingInvitationsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List pending organization 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`, or `hiring_manager`. 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](https://docs.github.com/rest/orgs/members#list-pending-organization-invitations)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_pending_invitations(&self, org: &str, query_params: Option<impl Into<OrgsListPendingInvitationsParams<'api>>>) -> Result<Vec<OrganizationInvitation>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/invitations", super::GITHUB_BASE_API_URL, org);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: OrgsListPendingInvitationsParams = 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(OrgsListPendingInvitationsError::Status404(github_response.to_json()?).into()),
code => Err(OrgsListPendingInvitationsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List public organization members
///
/// Members of an organization can choose to have their membership publicized or not.
///
/// [GitHub API docs for list_public_members](https://docs.github.com/rest/orgs/members#list-public-organization-members)
///
/// ---
pub async fn list_public_members_async(&self, org: &str, query_params: Option<impl Into<OrgsListPublicMembersParams>>) -> Result<Vec<SimpleUser>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/public_members", 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() {
code => Err(OrgsListPublicMembersError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List public organization members
///
/// Members of an organization can choose to have their membership publicized or not.
///
/// [GitHub API docs for list_public_members](https://docs.github.com/rest/orgs/members#list-public-organization-members)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_public_members(&self, org: &str, query_params: Option<impl Into<OrgsListPublicMembersParams>>) -> Result<Vec<SimpleUser>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/public_members", super::GITHUB_BASE_API_URL, org);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: OrgsListPublicMembersParams = 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(OrgsListPublicMembersError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List security manager teams
///
/// > [!WARNING]
/// > **Closing down notice:** This operation is closing down and will be removed starting January 1, 2026. Please use the "[Organization Roles](https://docs.github.com/rest/orgs/organization-roles)" endpoints instead.
///
/// [GitHub API docs for list_security_manager_teams](https://docs.github.com/rest/orgs/security-managers#list-security-manager-teams)
///
/// ---
pub async fn list_security_manager_teams_async(&self, org: &str) -> Result<Vec<TeamSimple>, AdapterError> {
let request_uri = format!("{}/orgs/{}/security-managers", super::GITHUB_BASE_API_URL, org);
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(OrgsListSecurityManagerTeamsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List security manager teams
///
/// > [!WARNING]
/// > **Closing down notice:** This operation is closing down and will be removed starting January 1, 2026. Please use the "[Organization Roles](https://docs.github.com/rest/orgs/organization-roles)" endpoints instead.
///
/// [GitHub API docs for list_security_manager_teams](https://docs.github.com/rest/orgs/security-managers#list-security-manager-teams)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_security_manager_teams(&self, org: &str) -> Result<Vec<TeamSimple>, AdapterError> {
let request_uri = format!("{}/orgs/{}/security-managers", super::GITHUB_BASE_API_URL, org);
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(OrgsListSecurityManagerTeamsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List deliveries for an organization webhook
///
/// Returns a list of webhook deliveries for a webhook configured in an organization.
///
/// You must be an organization owner to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need `admin:org_hook` scope. OAuth apps cannot list, view, or edit
/// webhooks that they did not create and users cannot list, view, or edit webhooks that were created by OAuth apps.
///
/// [GitHub API docs for list_webhook_deliveries](https://docs.github.com/rest/orgs/webhooks#list-deliveries-for-an-organization-webhook)
///
/// ---
pub async fn list_webhook_deliveries_async(&self, org: &str, hook_id: i32, query_params: Option<impl Into<OrgsListWebhookDeliveriesParams<'api>>>) -> Result<Vec<HookDeliveryItem>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/hooks/{}/deliveries", super::GITHUB_BASE_API_URL, org, hook_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() {
400 => Err(OrgsListWebhookDeliveriesError::Status400(github_response.to_json_async().await?).into()),
422 => Err(OrgsListWebhookDeliveriesError::Status422(github_response.to_json_async().await?).into()),
code => Err(OrgsListWebhookDeliveriesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List deliveries for an organization webhook
///
/// Returns a list of webhook deliveries for a webhook configured in an organization.
///
/// You must be an organization owner to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need `admin:org_hook` scope. OAuth apps cannot list, view, or edit
/// webhooks that they did not create and users cannot list, view, or edit webhooks that were created by OAuth apps.
///
/// [GitHub API docs for list_webhook_deliveries](https://docs.github.com/rest/orgs/webhooks#list-deliveries-for-an-organization-webhook)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_webhook_deliveries(&self, org: &str, hook_id: i32, query_params: Option<impl Into<OrgsListWebhookDeliveriesParams<'api>>>) -> Result<Vec<HookDeliveryItem>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/hooks/{}/deliveries", super::GITHUB_BASE_API_URL, org, hook_id);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: OrgsListWebhookDeliveriesParams = 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() {
400 => Err(OrgsListWebhookDeliveriesError::Status400(github_response.to_json()?).into()),
422 => Err(OrgsListWebhookDeliveriesError::Status422(github_response.to_json()?).into()),
code => Err(OrgsListWebhookDeliveriesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List organization webhooks
///
/// List webhooks for an organization.
///
/// The authenticated user must be an organization owner to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need `admin:org_hook` scope. OAuth apps cannot list, view, or edit
/// webhooks that they did not create and users cannot list, view, or edit webhooks that were created by OAuth apps.
///
/// [GitHub API docs for list_webhooks](https://docs.github.com/rest/orgs/webhooks#list-organization-webhooks)
///
/// ---
pub async fn list_webhooks_async(&self, org: &str, query_params: Option<impl Into<OrgsListWebhooksParams>>) -> Result<Vec<OrgHook>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/hooks", 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() {
404 => Err(OrgsListWebhooksError::Status404(github_response.to_json_async().await?).into()),
code => Err(OrgsListWebhooksError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List organization webhooks
///
/// List webhooks for an organization.
///
/// The authenticated user must be an organization owner to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need `admin:org_hook` scope. OAuth apps cannot list, view, or edit
/// webhooks that they did not create and users cannot list, view, or edit webhooks that were created by OAuth apps.
///
/// [GitHub API docs for list_webhooks](https://docs.github.com/rest/orgs/webhooks#list-organization-webhooks)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_webhooks(&self, org: &str, query_params: Option<impl Into<OrgsListWebhooksParams>>) -> Result<Vec<OrgHook>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/hooks", super::GITHUB_BASE_API_URL, org);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: OrgsListWebhooksParams = 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(OrgsListWebhooksError::Status404(github_response.to_json()?).into()),
code => Err(OrgsListWebhooksError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Ping an organization webhook
///
/// This will trigger a [ping event](https://docs.github.com/webhooks/#ping-event)
/// to be sent to the hook.
///
/// You must be an organization owner to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need `admin:org_hook` scope. OAuth apps cannot list, view, or edit
/// webhooks that they did not create and users cannot list, view, or edit webhooks that were created by OAuth apps.
///
/// [GitHub API docs for ping_webhook](https://docs.github.com/rest/orgs/webhooks#ping-an-organization-webhook)
///
/// ---
pub async fn ping_webhook_async(&self, org: &str, hook_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/hooks/{}/pings", super::GITHUB_BASE_API_URL, org, hook_id);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::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(())
} else {
match github_response.status_code() {
404 => Err(OrgsPingWebhookError::Status404(github_response.to_json_async().await?).into()),
code => Err(OrgsPingWebhookError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Ping an organization webhook
///
/// This will trigger a [ping event](https://docs.github.com/webhooks/#ping-event)
/// to be sent to the hook.
///
/// You must be an organization owner to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need `admin:org_hook` scope. OAuth apps cannot list, view, or edit
/// webhooks that they did not create and users cannot list, view, or edit webhooks that were created by OAuth apps.
///
/// [GitHub API docs for ping_webhook](https://docs.github.com/rest/orgs/webhooks#ping-an-organization-webhook)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn ping_webhook(&self, org: &str, hook_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/hooks/{}/pings", super::GITHUB_BASE_API_URL, org, hook_id);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "POST",
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(OrgsPingWebhookError::Status404(github_response.to_json()?).into()),
code => Err(OrgsPingWebhookError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Redeliver a delivery for an organization webhook
///
/// Redeliver a delivery for a webhook configured in an organization.
///
/// You must be an organization owner to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need `admin:org_hook` scope. OAuth apps cannot list, view, or edit
/// webhooks that they did not create and users cannot list, view, or edit webhooks that were created by OAuth apps.
///
/// [GitHub API docs for redeliver_webhook_delivery](https://docs.github.com/rest/orgs/webhooks#redeliver-a-delivery-for-an-organization-webhook)
///
/// ---
pub async fn redeliver_webhook_delivery_async(&self, org: &str, hook_id: i32, delivery_id: i32) -> Result<HashMap<String, Value>, AdapterError> {
let request_uri = format!("{}/orgs/{}/hooks/{}/deliveries/{}/attempts", super::GITHUB_BASE_API_URL, org, hook_id, delivery_id);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::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() {
400 => Err(OrgsRedeliverWebhookDeliveryError::Status400(github_response.to_json_async().await?).into()),
422 => Err(OrgsRedeliverWebhookDeliveryError::Status422(github_response.to_json_async().await?).into()),
code => Err(OrgsRedeliverWebhookDeliveryError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Redeliver a delivery for an organization webhook
///
/// Redeliver a delivery for a webhook configured in an organization.
///
/// You must be an organization owner to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need `admin:org_hook` scope. OAuth apps cannot list, view, or edit
/// webhooks that they did not create and users cannot list, view, or edit webhooks that were created by OAuth apps.
///
/// [GitHub API docs for redeliver_webhook_delivery](https://docs.github.com/rest/orgs/webhooks#redeliver-a-delivery-for-an-organization-webhook)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn redeliver_webhook_delivery(&self, org: &str, hook_id: i32, delivery_id: i32) -> Result<HashMap<String, Value>, AdapterError> {
let request_uri = format!("{}/orgs/{}/hooks/{}/deliveries/{}/attempts", super::GITHUB_BASE_API_URL, org, hook_id, delivery_id);
let req = GitHubRequest {
uri: request_uri,
body: None,
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() {
400 => Err(OrgsRedeliverWebhookDeliveryError::Status400(github_response.to_json()?).into()),
422 => Err(OrgsRedeliverWebhookDeliveryError::Status422(github_response.to_json()?).into()),
code => Err(OrgsRedeliverWebhookDeliveryError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Remove a custom property for an organization
///
/// Removes a custom property that is defined for an organization.
///
/// To use this endpoint, the authenticated user must be one of:
/// - An administrator for the organization.
/// - A user, or a user on a team, with the fine-grained permission of `custom_properties_org_definitions_manager` in the organization.
///
/// [GitHub API docs for remove_custom_property](https://docs.github.com/rest/orgs/custom-properties#remove-a-custom-property-for-an-organization)
///
/// ---
pub async fn remove_custom_property_async(&self, org: &str, custom_property_name: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/properties/schema/{}", super::GITHUB_BASE_API_URL, org, custom_property_name);
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(OrgsRemoveCustomPropertyError::Status403(github_response.to_json_async().await?).into()),
404 => Err(OrgsRemoveCustomPropertyError::Status404(github_response.to_json_async().await?).into()),
code => Err(OrgsRemoveCustomPropertyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Remove a custom property for an organization
///
/// Removes a custom property that is defined for an organization.
///
/// To use this endpoint, the authenticated user must be one of:
/// - An administrator for the organization.
/// - A user, or a user on a team, with the fine-grained permission of `custom_properties_org_definitions_manager` in the organization.
///
/// [GitHub API docs for remove_custom_property](https://docs.github.com/rest/orgs/custom-properties#remove-a-custom-property-for-an-organization)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn remove_custom_property(&self, org: &str, custom_property_name: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/properties/schema/{}", super::GITHUB_BASE_API_URL, org, custom_property_name);
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(OrgsRemoveCustomPropertyError::Status403(github_response.to_json()?).into()),
404 => Err(OrgsRemoveCustomPropertyError::Status404(github_response.to_json()?).into()),
code => Err(OrgsRemoveCustomPropertyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Remove an organization member
///
/// Removing a user from this list will remove them from all teams and they will no longer have any access to the organization's repositories.
///
/// > [!NOTE]
/// > If a user has both direct membership in the organization as well as indirect membership via an enterprise team, only their direct membership will be removed. Their indirect membership via an enterprise team remains until the user is removed from the enterprise team.
///
/// [GitHub API docs for remove_member](https://docs.github.com/rest/orgs/members#remove-an-organization-member)
///
/// ---
pub async fn remove_member_async(&self, org: &str, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/members/{}", super::GITHUB_BASE_API_URL, org, 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(OrgsRemoveMemberError::Status403(github_response.to_json_async().await?).into()),
code => Err(OrgsRemoveMemberError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Remove an organization member
///
/// Removing a user from this list will remove them from all teams and they will no longer have any access to the organization's repositories.
///
/// > [!NOTE]
/// > If a user has both direct membership in the organization as well as indirect membership via an enterprise team, only their direct membership will be removed. Their indirect membership via an enterprise team remains until the user is removed from the enterprise team.
///
/// [GitHub API docs for remove_member](https://docs.github.com/rest/orgs/members#remove-an-organization-member)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn remove_member(&self, org: &str, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/members/{}", super::GITHUB_BASE_API_URL, org, 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(OrgsRemoveMemberError::Status403(github_response.to_json()?).into()),
code => Err(OrgsRemoveMemberError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Remove organization membership for a user
///
/// In order to remove a user's membership with an organization, the authenticated user must be an organization owner.
///
/// If the specified user is an active member of the organization, this will remove them from the organization. If the specified user has been invited to the organization, this will cancel their invitation. The specified user will receive an email notification in both cases.
///
/// > [!NOTE]
/// > If a user has both direct membership in the organization as well as indirect membership via an enterprise team, only their direct membership will be removed. Their indirect membership via an enterprise team remains until the user is removed from the enterprise team.
///
/// [GitHub API docs for remove_membership_for_user](https://docs.github.com/rest/orgs/members#remove-organization-membership-for-a-user)
///
/// ---
pub async fn remove_membership_for_user_async(&self, org: &str, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/memberships/{}", super::GITHUB_BASE_API_URL, org, 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(OrgsRemoveMembershipForUserError::Status403(github_response.to_json_async().await?).into()),
404 => Err(OrgsRemoveMembershipForUserError::Status404(github_response.to_json_async().await?).into()),
code => Err(OrgsRemoveMembershipForUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Remove organization membership for a user
///
/// In order to remove a user's membership with an organization, the authenticated user must be an organization owner.
///
/// If the specified user is an active member of the organization, this will remove them from the organization. If the specified user has been invited to the organization, this will cancel their invitation. The specified user will receive an email notification in both cases.
///
/// > [!NOTE]
/// > If a user has both direct membership in the organization as well as indirect membership via an enterprise team, only their direct membership will be removed. Their indirect membership via an enterprise team remains until the user is removed from the enterprise team.
///
/// [GitHub API docs for remove_membership_for_user](https://docs.github.com/rest/orgs/members#remove-organization-membership-for-a-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn remove_membership_for_user(&self, org: &str, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/memberships/{}", super::GITHUB_BASE_API_URL, org, 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(OrgsRemoveMembershipForUserError::Status403(github_response.to_json()?).into()),
404 => Err(OrgsRemoveMembershipForUserError::Status404(github_response.to_json()?).into()),
code => Err(OrgsRemoveMembershipForUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Remove outside collaborator from an organization
///
/// Removing a user from this list will remove them from all the organization's repositories.
///
/// [GitHub API docs for remove_outside_collaborator](https://docs.github.com/rest/orgs/outside-collaborators#remove-outside-collaborator-from-an-organization)
///
/// ---
pub async fn remove_outside_collaborator_async(&self, org: &str, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/outside_collaborators/{}", super::GITHUB_BASE_API_URL, org, 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() {
422 => Err(OrgsRemoveOutsideCollaboratorError::Status422(github_response.to_json_async().await?).into()),
code => Err(OrgsRemoveOutsideCollaboratorError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Remove outside collaborator from an organization
///
/// Removing a user from this list will remove them from all the organization's repositories.
///
/// [GitHub API docs for remove_outside_collaborator](https://docs.github.com/rest/orgs/outside-collaborators#remove-outside-collaborator-from-an-organization)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn remove_outside_collaborator(&self, org: &str, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/outside_collaborators/{}", super::GITHUB_BASE_API_URL, org, 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() {
422 => Err(OrgsRemoveOutsideCollaboratorError::Status422(github_response.to_json()?).into()),
code => Err(OrgsRemoveOutsideCollaboratorError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Remove public organization membership for the authenticated user
///
/// Removes the public membership for the authenticated user from the specified organization, unless public visibility is enforced by default.
///
/// [GitHub API docs for remove_public_membership_for_authenticated_user](https://docs.github.com/rest/orgs/members#remove-public-organization-membership-for-the-authenticated-user)
///
/// ---
pub async fn remove_public_membership_for_authenticated_user_async(&self, org: &str, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/public_members/{}", super::GITHUB_BASE_API_URL, org, 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() {
code => Err(OrgsRemovePublicMembershipForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Remove public organization membership for the authenticated user
///
/// Removes the public membership for the authenticated user from the specified organization, unless public visibility is enforced by default.
///
/// [GitHub API docs for remove_public_membership_for_authenticated_user](https://docs.github.com/rest/orgs/members#remove-public-organization-membership-for-the-authenticated-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn remove_public_membership_for_authenticated_user(&self, org: &str, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/public_members/{}", super::GITHUB_BASE_API_URL, org, 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() {
code => Err(OrgsRemovePublicMembershipForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Remove a security manager team
///
/// > [!WARNING]
/// > **Closing down notice:** This operation is closing down and will be removed starting January 1, 2026. Please use the "[Organization Roles](https://docs.github.com/rest/orgs/organization-roles)" endpoints instead.
///
/// [GitHub API docs for remove_security_manager_team](https://docs.github.com/rest/orgs/security-managers#remove-a-security-manager-team)
///
/// ---
pub async fn remove_security_manager_team_async(&self, org: &str, team_slug: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/security-managers/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(OrgsRemoveSecurityManagerTeamError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Remove a security manager team
///
/// > [!WARNING]
/// > **Closing down notice:** This operation is closing down and will be removed starting January 1, 2026. Please use the "[Organization Roles](https://docs.github.com/rest/orgs/organization-roles)" endpoints instead.
///
/// [GitHub API docs for remove_security_manager_team](https://docs.github.com/rest/orgs/security-managers#remove-a-security-manager-team)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn remove_security_manager_team(&self, org: &str, team_slug: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/security-managers/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(OrgsRemoveSecurityManagerTeamError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Review a request to access organization resources with a fine-grained personal access token
///
/// Approves or denies a pending request to access organization resources via a fine-grained personal access token.
///
/// Only GitHub Apps can use this endpoint.
///
/// [GitHub API docs for review_pat_grant_request](https://docs.github.com/rest/orgs/personal-access-tokens#review-a-request-to-access-organization-resources-with-a-fine-grained-personal-access-token)
///
/// ---
pub async fn review_pat_grant_request_async(&self, org: &str, pat_request_id: i32, body: PostOrgsReviewPatGrantRequest) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/personal-access-token-requests/{}", super::GITHUB_BASE_API_URL, org, pat_request_id);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostOrgsReviewPatGrantRequest>(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(())
} else {
match github_response.status_code() {
500 => Err(OrgsReviewPatGrantRequestError::Status500(github_response.to_json_async().await?).into()),
422 => Err(OrgsReviewPatGrantRequestError::Status422(github_response.to_json_async().await?).into()),
404 => Err(OrgsReviewPatGrantRequestError::Status404(github_response.to_json_async().await?).into()),
403 => Err(OrgsReviewPatGrantRequestError::Status403(github_response.to_json_async().await?).into()),
code => Err(OrgsReviewPatGrantRequestError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Review a request to access organization resources with a fine-grained personal access token
///
/// Approves or denies a pending request to access organization resources via a fine-grained personal access token.
///
/// Only GitHub Apps can use this endpoint.
///
/// [GitHub API docs for review_pat_grant_request](https://docs.github.com/rest/orgs/personal-access-tokens#review-a-request-to-access-organization-resources-with-a-fine-grained-personal-access-token)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn review_pat_grant_request(&self, org: &str, pat_request_id: i32, body: PostOrgsReviewPatGrantRequest) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/personal-access-token-requests/{}", super::GITHUB_BASE_API_URL, org, pat_request_id);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostOrgsReviewPatGrantRequest>(body)?),
method: "POST",
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() {
500 => Err(OrgsReviewPatGrantRequestError::Status500(github_response.to_json()?).into()),
422 => Err(OrgsReviewPatGrantRequestError::Status422(github_response.to_json()?).into()),
404 => Err(OrgsReviewPatGrantRequestError::Status404(github_response.to_json()?).into()),
403 => Err(OrgsReviewPatGrantRequestError::Status403(github_response.to_json()?).into()),
code => Err(OrgsReviewPatGrantRequestError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Review requests to access organization resources with fine-grained personal access tokens
///
/// Approves or denies multiple pending requests to access organization resources via a fine-grained personal access token.
///
/// Only GitHub Apps can use this endpoint.
///
/// [GitHub API docs for review_pat_grant_requests_in_bulk](https://docs.github.com/rest/orgs/personal-access-tokens#review-requests-to-access-organization-resources-with-fine-grained-personal-access-tokens)
///
/// ---
pub async fn review_pat_grant_requests_in_bulk_async(&self, org: &str, body: PostOrgsReviewPatGrantRequestsInBulk) -> Result<HashMap<String, Value>, AdapterError> {
let request_uri = format!("{}/orgs/{}/personal-access-token-requests", super::GITHUB_BASE_API_URL, org);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostOrgsReviewPatGrantRequestsInBulk>(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() {
500 => Err(OrgsReviewPatGrantRequestsInBulkError::Status500(github_response.to_json_async().await?).into()),
422 => Err(OrgsReviewPatGrantRequestsInBulkError::Status422(github_response.to_json_async().await?).into()),
404 => Err(OrgsReviewPatGrantRequestsInBulkError::Status404(github_response.to_json_async().await?).into()),
403 => Err(OrgsReviewPatGrantRequestsInBulkError::Status403(github_response.to_json_async().await?).into()),
code => Err(OrgsReviewPatGrantRequestsInBulkError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Review requests to access organization resources with fine-grained personal access tokens
///
/// Approves or denies multiple pending requests to access organization resources via a fine-grained personal access token.
///
/// Only GitHub Apps can use this endpoint.
///
/// [GitHub API docs for review_pat_grant_requests_in_bulk](https://docs.github.com/rest/orgs/personal-access-tokens#review-requests-to-access-organization-resources-with-fine-grained-personal-access-tokens)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn review_pat_grant_requests_in_bulk(&self, org: &str, body: PostOrgsReviewPatGrantRequestsInBulk) -> Result<HashMap<String, Value>, AdapterError> {
let request_uri = format!("{}/orgs/{}/personal-access-token-requests", super::GITHUB_BASE_API_URL, org);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostOrgsReviewPatGrantRequestsInBulk>(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() {
500 => Err(OrgsReviewPatGrantRequestsInBulkError::Status500(github_response.to_json()?).into()),
422 => Err(OrgsReviewPatGrantRequestsInBulkError::Status422(github_response.to_json()?).into()),
404 => Err(OrgsReviewPatGrantRequestsInBulkError::Status404(github_response.to_json()?).into()),
403 => Err(OrgsReviewPatGrantRequestsInBulkError::Status403(github_response.to_json()?).into()),
code => Err(OrgsReviewPatGrantRequestsInBulkError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Remove all organization roles for a team
///
/// Removes all assigned organization roles from a team. For more information on organization roles, see "[Using organization roles](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/using-organization-roles)."
///
/// The authenticated user must be an administrator for the organization to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint.
///
/// [GitHub API docs for revoke_all_org_roles_team](https://docs.github.com/rest/orgs/organization-roles#remove-all-organization-roles-for-a-team)
///
/// ---
pub async fn revoke_all_org_roles_team_async(&self, org: &str, team_slug: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/organization-roles/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(OrgsRevokeAllOrgRolesTeamError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Remove all organization roles for a team
///
/// Removes all assigned organization roles from a team. For more information on organization roles, see "[Using organization roles](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/using-organization-roles)."
///
/// The authenticated user must be an administrator for the organization to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint.
///
/// [GitHub API docs for revoke_all_org_roles_team](https://docs.github.com/rest/orgs/organization-roles#remove-all-organization-roles-for-a-team)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn revoke_all_org_roles_team(&self, org: &str, team_slug: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/organization-roles/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(OrgsRevokeAllOrgRolesTeamError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Remove all organization roles for a user
///
/// Revokes all assigned organization roles from a user. For more information on organization roles, see "[Using organization roles](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/using-organization-roles)."
///
/// The authenticated user must be an administrator for the organization to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint.
///
/// [GitHub API docs for revoke_all_org_roles_user](https://docs.github.com/rest/orgs/organization-roles#remove-all-organization-roles-for-a-user)
///
/// ---
pub async fn revoke_all_org_roles_user_async(&self, org: &str, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/organization-roles/users/{}", super::GITHUB_BASE_API_URL, org, 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() {
code => Err(OrgsRevokeAllOrgRolesUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Remove all organization roles for a user
///
/// Revokes all assigned organization roles from a user. For more information on organization roles, see "[Using organization roles](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/using-organization-roles)."
///
/// The authenticated user must be an administrator for the organization to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint.
///
/// [GitHub API docs for revoke_all_org_roles_user](https://docs.github.com/rest/orgs/organization-roles#remove-all-organization-roles-for-a-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn revoke_all_org_roles_user(&self, org: &str, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/organization-roles/users/{}", super::GITHUB_BASE_API_URL, org, 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() {
code => Err(OrgsRevokeAllOrgRolesUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Remove an organization role from a team
///
/// Removes an organization role from a team. For more information on organization roles, see "[Using organization roles](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/using-organization-roles)."
///
/// The authenticated user must be an administrator for the organization to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint.
///
/// [GitHub API docs for revoke_org_role_team](https://docs.github.com/rest/orgs/organization-roles#remove-an-organization-role-from-a-team)
///
/// ---
pub async fn revoke_org_role_team_async(&self, org: &str, team_slug: &str, role_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/organization-roles/teams/{}/{}", super::GITHUB_BASE_API_URL, org, team_slug, role_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(OrgsRevokeOrgRoleTeamError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Remove an organization role from a team
///
/// Removes an organization role from a team. For more information on organization roles, see "[Using organization roles](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/using-organization-roles)."
///
/// The authenticated user must be an administrator for the organization to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint.
///
/// [GitHub API docs for revoke_org_role_team](https://docs.github.com/rest/orgs/organization-roles#remove-an-organization-role-from-a-team)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn revoke_org_role_team(&self, org: &str, team_slug: &str, role_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/organization-roles/teams/{}/{}", super::GITHUB_BASE_API_URL, org, team_slug, role_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(OrgsRevokeOrgRoleTeamError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Remove an organization role from a user
///
/// Remove an organization role from a user. For more information on organization roles, see "[Using organization roles](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/using-organization-roles)."
///
/// The authenticated user must be an administrator for the organization to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint.
///
/// [GitHub API docs for revoke_org_role_user](https://docs.github.com/rest/orgs/organization-roles#remove-an-organization-role-from-a-user)
///
/// ---
pub async fn revoke_org_role_user_async(&self, org: &str, username: &str, role_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/organization-roles/users/{}/{}", super::GITHUB_BASE_API_URL, org, username, role_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(OrgsRevokeOrgRoleUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Remove an organization role from a user
///
/// Remove an organization role from a user. For more information on organization roles, see "[Using organization roles](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/using-organization-roles)."
///
/// The authenticated user must be an administrator for the organization to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint.
///
/// [GitHub API docs for revoke_org_role_user](https://docs.github.com/rest/orgs/organization-roles#remove-an-organization-role-from-a-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn revoke_org_role_user(&self, org: &str, username: &str, role_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/organization-roles/users/{}/{}", super::GITHUB_BASE_API_URL, org, username, role_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(OrgsRevokeOrgRoleUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Set organization membership for a user
///
/// Only authenticated organization owners can add a member to the organization or update the member's role.
///
/// * If the authenticated user is _adding_ a member to the organization, the invited user will receive an email inviting them to the organization. The user's [membership status](https://docs.github.com/rest/orgs/members#get-organization-membership-for-a-user) will be `pending` until they accept the invitation.
///
/// * Authenticated users can _update_ a user's membership by passing the `role` parameter. If the authenticated user changes a member's role to `admin`, the affected user will receive an email notifying them that they've been made an organization owner. If the authenticated user changes an owner's role to `member`, no email will be sent.
///
/// **Rate limits**
///
/// To prevent abuse, organization owners are limited to creating 50 organization invitations for an organization within a 24 hour period. If the organization is more than one month old or on a paid plan, the limit is 500 invitations per 24 hour period.
///
/// [GitHub API docs for set_membership_for_user](https://docs.github.com/rest/orgs/members#set-organization-membership-for-a-user)
///
/// ---
pub async fn set_membership_for_user_async(&self, org: &str, username: &str, body: PutOrgsSetMembershipForUser) -> Result<OrgMembership, AdapterError> {
let request_uri = format!("{}/orgs/{}/memberships/{}", super::GITHUB_BASE_API_URL, org, username);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutOrgsSetMembershipForUser>(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() {
422 => Err(OrgsSetMembershipForUserError::Status422(github_response.to_json_async().await?).into()),
403 => Err(OrgsSetMembershipForUserError::Status403(github_response.to_json_async().await?).into()),
code => Err(OrgsSetMembershipForUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Set organization membership for a user
///
/// Only authenticated organization owners can add a member to the organization or update the member's role.
///
/// * If the authenticated user is _adding_ a member to the organization, the invited user will receive an email inviting them to the organization. The user's [membership status](https://docs.github.com/rest/orgs/members#get-organization-membership-for-a-user) will be `pending` until they accept the invitation.
///
/// * Authenticated users can _update_ a user's membership by passing the `role` parameter. If the authenticated user changes a member's role to `admin`, the affected user will receive an email notifying them that they've been made an organization owner. If the authenticated user changes an owner's role to `member`, no email will be sent.
///
/// **Rate limits**
///
/// To prevent abuse, organization owners are limited to creating 50 organization invitations for an organization within a 24 hour period. If the organization is more than one month old or on a paid plan, the limit is 500 invitations per 24 hour period.
///
/// [GitHub API docs for set_membership_for_user](https://docs.github.com/rest/orgs/members#set-organization-membership-for-a-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn set_membership_for_user(&self, org: &str, username: &str, body: PutOrgsSetMembershipForUser) -> Result<OrgMembership, AdapterError> {
let request_uri = format!("{}/orgs/{}/memberships/{}", super::GITHUB_BASE_API_URL, org, username);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutOrgsSetMembershipForUser>(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() {
422 => Err(OrgsSetMembershipForUserError::Status422(github_response.to_json()?).into()),
403 => Err(OrgsSetMembershipForUserError::Status403(github_response.to_json()?).into()),
code => Err(OrgsSetMembershipForUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Set public organization membership for the authenticated user
///
/// The user can publicize their own membership. (A user cannot publicize the membership for another user.)
///
/// 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 set_public_membership_for_authenticated_user](https://docs.github.com/rest/orgs/members#set-public-organization-membership-for-the-authenticated-user)
///
/// ---
pub async fn set_public_membership_for_authenticated_user_async(&self, org: &str, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/public_members/{}", super::GITHUB_BASE_API_URL, org, 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() {
403 => Err(OrgsSetPublicMembershipForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()),
code => Err(OrgsSetPublicMembershipForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Set public organization membership for the authenticated user
///
/// The user can publicize their own membership. (A user cannot publicize the membership for another user.)
///
/// 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 set_public_membership_for_authenticated_user](https://docs.github.com/rest/orgs/members#set-public-organization-membership-for-the-authenticated-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn set_public_membership_for_authenticated_user(&self, org: &str, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/public_members/{}", super::GITHUB_BASE_API_URL, org, 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() {
403 => Err(OrgsSetPublicMembershipForAuthenticatedUserError::Status403(github_response.to_json()?).into()),
code => Err(OrgsSetPublicMembershipForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Unblock a user from an organization
///
/// Unblocks the given user on behalf of the specified organization.
///
/// [GitHub API docs for unblock_user](https://docs.github.com/rest/orgs/blocking#unblock-a-user-from-an-organization)
///
/// ---
pub async fn unblock_user_async(&self, org: &str, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/blocks/{}", super::GITHUB_BASE_API_URL, org, 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() {
code => Err(OrgsUnblockUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Unblock a user from an organization
///
/// Unblocks the given user on behalf of the specified organization.
///
/// [GitHub API docs for unblock_user](https://docs.github.com/rest/orgs/blocking#unblock-a-user-from-an-organization)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn unblock_user(&self, org: &str, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/blocks/{}", super::GITHUB_BASE_API_URL, org, 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() {
code => Err(OrgsUnblockUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update an organization
///
/// > [!WARNING]
/// > **Closing down notice:** GitHub will replace and discontinue `members_allowed_repository_creation_type` in favor of more granular permissions. The new input parameters are `members_can_create_public_repositories`, `members_can_create_private_repositories` for all organizations and `members_can_create_internal_repositories` for organizations associated with an enterprise account using GitHub Enterprise Cloud or GitHub Enterprise Server 2.20+. For more information, see the [blog post](https://developer.github.com/changes/2019-12-03-internal-visibility-changes).
///
/// > [!WARNING]
/// > **Closing down notice:** Code security product enablement for new repositories through the organization API is closing down. Please use [code security configurations](https://docs.github.com/rest/code-security/configurations#set-a-code-security-configuration-as-a-default-for-an-organization) to set defaults instead. For more information on setting a default security configuration, see the [changelog](https://github.blog/changelog/2024-07-09-sunsetting-security-settings-defaults-parameters-in-the-organizations-rest-api/).
///
/// Updates the organization's profile and member privileges.
///
/// The authenticated user must be an organization owner to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need the `admin:org` or `repo` scope to use this endpoint.
///
/// [GitHub API docs for update](https://docs.github.com/rest/orgs/orgs#update-an-organization)
///
/// ---
pub async fn update_async(&self, org: &str, body: PatchOrgsUpdate) -> Result<OrganizationFull, AdapterError> {
let request_uri = format!("{}/orgs/{}", super::GITHUB_BASE_API_URL, org);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchOrgsUpdate>(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() {
422 => Err(OrgsUpdateError::Status422(github_response.to_json_async().await?).into()),
409 => Err(OrgsUpdateError::Status409(github_response.to_json_async().await?).into()),
code => Err(OrgsUpdateError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update an organization
///
/// > [!WARNING]
/// > **Closing down notice:** GitHub will replace and discontinue `members_allowed_repository_creation_type` in favor of more granular permissions. The new input parameters are `members_can_create_public_repositories`, `members_can_create_private_repositories` for all organizations and `members_can_create_internal_repositories` for organizations associated with an enterprise account using GitHub Enterprise Cloud or GitHub Enterprise Server 2.20+. For more information, see the [blog post](https://developer.github.com/changes/2019-12-03-internal-visibility-changes).
///
/// > [!WARNING]
/// > **Closing down notice:** Code security product enablement for new repositories through the organization API is closing down. Please use [code security configurations](https://docs.github.com/rest/code-security/configurations#set-a-code-security-configuration-as-a-default-for-an-organization) to set defaults instead. For more information on setting a default security configuration, see the [changelog](https://github.blog/changelog/2024-07-09-sunsetting-security-settings-defaults-parameters-in-the-organizations-rest-api/).
///
/// Updates the organization's profile and member privileges.
///
/// The authenticated user must be an organization owner to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need the `admin:org` or `repo` scope to use this endpoint.
///
/// [GitHub API docs for update](https://docs.github.com/rest/orgs/orgs#update-an-organization)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn update(&self, org: &str, body: PatchOrgsUpdate) -> Result<OrganizationFull, AdapterError> {
let request_uri = format!("{}/orgs/{}", super::GITHUB_BASE_API_URL, org);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchOrgsUpdate>(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() {
422 => Err(OrgsUpdateError::Status422(github_response.to_json()?).into()),
409 => Err(OrgsUpdateError::Status409(github_response.to_json()?).into()),
code => Err(OrgsUpdateError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update issue type for an organization
///
/// Updates an issue type for an organization.
///
/// You can find out more about issue types in [Managing issue types in an organization](https://docs.github.com/issues/tracking-your-work-with-issues/configuring-issues/managing-issue-types-in-an-organization).
///
/// To use this endpoint, the authenticated user must be an administrator for the organization. OAuth app tokens and
/// personal access tokens (classic) need the `admin:org` scope to use this endpoint.
///
/// [GitHub API docs for update_issue_type](https://docs.github.com/rest/orgs/issue-types#update-issue-type-for-an-organization)
///
/// ---
pub async fn update_issue_type_async(&self, org: &str, issue_type_id: i32, body: PutOrgsUpdateIssueType) -> Result<IssueType, AdapterError> {
let request_uri = format!("{}/orgs/{}/issue-types/{}", super::GITHUB_BASE_API_URL, org, issue_type_id);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutOrgsUpdateIssueType>(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() {
404 => Err(OrgsUpdateIssueTypeError::Status404(github_response.to_json_async().await?).into()),
422 => Err(OrgsUpdateIssueTypeError::Status422(github_response.to_json_async().await?).into()),
code => Err(OrgsUpdateIssueTypeError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update issue type for an organization
///
/// Updates an issue type for an organization.
///
/// You can find out more about issue types in [Managing issue types in an organization](https://docs.github.com/issues/tracking-your-work-with-issues/configuring-issues/managing-issue-types-in-an-organization).
///
/// To use this endpoint, the authenticated user must be an administrator for the organization. OAuth app tokens and
/// personal access tokens (classic) need the `admin:org` scope to use this endpoint.
///
/// [GitHub API docs for update_issue_type](https://docs.github.com/rest/orgs/issue-types#update-issue-type-for-an-organization)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn update_issue_type(&self, org: &str, issue_type_id: i32, body: PutOrgsUpdateIssueType) -> Result<IssueType, AdapterError> {
let request_uri = format!("{}/orgs/{}/issue-types/{}", super::GITHUB_BASE_API_URL, org, issue_type_id);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutOrgsUpdateIssueType>(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() {
404 => Err(OrgsUpdateIssueTypeError::Status404(github_response.to_json()?).into()),
422 => Err(OrgsUpdateIssueTypeError::Status422(github_response.to_json()?).into()),
code => Err(OrgsUpdateIssueTypeError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update an organization membership for the authenticated user
///
/// Converts the authenticated user to an active member of the organization, if that user has a pending invitation from the organization.
///
/// [GitHub API docs for update_membership_for_authenticated_user](https://docs.github.com/rest/orgs/members#update-an-organization-membership-for-the-authenticated-user)
///
/// ---
pub async fn update_membership_for_authenticated_user_async(&self, org: &str, body: PatchOrgsUpdateMembershipForAuthenticatedUser) -> Result<OrgMembership, AdapterError> {
let request_uri = format!("{}/user/memberships/orgs/{}", super::GITHUB_BASE_API_URL, org);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchOrgsUpdateMembershipForAuthenticatedUser>(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() {
403 => Err(OrgsUpdateMembershipForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()),
404 => Err(OrgsUpdateMembershipForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()),
422 => Err(OrgsUpdateMembershipForAuthenticatedUserError::Status422(github_response.to_json_async().await?).into()),
code => Err(OrgsUpdateMembershipForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update an organization membership for the authenticated user
///
/// Converts the authenticated user to an active member of the organization, if that user has a pending invitation from the organization.
///
/// [GitHub API docs for update_membership_for_authenticated_user](https://docs.github.com/rest/orgs/members#update-an-organization-membership-for-the-authenticated-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn update_membership_for_authenticated_user(&self, org: &str, body: PatchOrgsUpdateMembershipForAuthenticatedUser) -> Result<OrgMembership, AdapterError> {
let request_uri = format!("{}/user/memberships/orgs/{}", super::GITHUB_BASE_API_URL, org);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchOrgsUpdateMembershipForAuthenticatedUser>(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() {
403 => Err(OrgsUpdateMembershipForAuthenticatedUserError::Status403(github_response.to_json()?).into()),
404 => Err(OrgsUpdateMembershipForAuthenticatedUserError::Status404(github_response.to_json()?).into()),
422 => Err(OrgsUpdateMembershipForAuthenticatedUserError::Status422(github_response.to_json()?).into()),
code => Err(OrgsUpdateMembershipForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update the access a fine-grained personal access token has to organization resources
///
/// Updates the access an organization member has to organization resources via a fine-grained personal access token. Limited to revoking the token's existing access. Limited to revoking a token's existing access.
///
/// Only GitHub Apps can use this endpoint.
///
/// [GitHub API docs for update_pat_access](https://docs.github.com/rest/orgs/personal-access-tokens#update-the-access-a-fine-grained-personal-access-token-has-to-organization-resources)
///
/// ---
pub async fn update_pat_access_async(&self, org: &str, pat_id: i32, body: PostOrgsUpdatePatAccess) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/personal-access-tokens/{}", super::GITHUB_BASE_API_URL, org, pat_id);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostOrgsUpdatePatAccess>(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(())
} else {
match github_response.status_code() {
500 => Err(OrgsUpdatePatAccessError::Status500(github_response.to_json_async().await?).into()),
404 => Err(OrgsUpdatePatAccessError::Status404(github_response.to_json_async().await?).into()),
403 => Err(OrgsUpdatePatAccessError::Status403(github_response.to_json_async().await?).into()),
422 => Err(OrgsUpdatePatAccessError::Status422(github_response.to_json_async().await?).into()),
code => Err(OrgsUpdatePatAccessError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update the access a fine-grained personal access token has to organization resources
///
/// Updates the access an organization member has to organization resources via a fine-grained personal access token. Limited to revoking the token's existing access. Limited to revoking a token's existing access.
///
/// Only GitHub Apps can use this endpoint.
///
/// [GitHub API docs for update_pat_access](https://docs.github.com/rest/orgs/personal-access-tokens#update-the-access-a-fine-grained-personal-access-token-has-to-organization-resources)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn update_pat_access(&self, org: &str, pat_id: i32, body: PostOrgsUpdatePatAccess) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/personal-access-tokens/{}", super::GITHUB_BASE_API_URL, org, pat_id);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostOrgsUpdatePatAccess>(body)?),
method: "POST",
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() {
500 => Err(OrgsUpdatePatAccessError::Status500(github_response.to_json()?).into()),
404 => Err(OrgsUpdatePatAccessError::Status404(github_response.to_json()?).into()),
403 => Err(OrgsUpdatePatAccessError::Status403(github_response.to_json()?).into()),
422 => Err(OrgsUpdatePatAccessError::Status422(github_response.to_json()?).into()),
code => Err(OrgsUpdatePatAccessError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update the access to organization resources via fine-grained personal access tokens
///
/// Updates the access organization members have to organization resources via fine-grained personal access tokens. Limited to revoking a token's existing access.
///
/// Only GitHub Apps can use this endpoint.
///
/// [GitHub API docs for update_pat_accesses](https://docs.github.com/rest/orgs/personal-access-tokens#update-the-access-to-organization-resources-via-fine-grained-personal-access-tokens)
///
/// ---
pub async fn update_pat_accesses_async(&self, org: &str, body: PostOrgsUpdatePatAccesses) -> Result<HashMap<String, Value>, AdapterError> {
let request_uri = format!("{}/orgs/{}/personal-access-tokens", super::GITHUB_BASE_API_URL, org);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostOrgsUpdatePatAccesses>(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() {
500 => Err(OrgsUpdatePatAccessesError::Status500(github_response.to_json_async().await?).into()),
404 => Err(OrgsUpdatePatAccessesError::Status404(github_response.to_json_async().await?).into()),
403 => Err(OrgsUpdatePatAccessesError::Status403(github_response.to_json_async().await?).into()),
422 => Err(OrgsUpdatePatAccessesError::Status422(github_response.to_json_async().await?).into()),
code => Err(OrgsUpdatePatAccessesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update the access to organization resources via fine-grained personal access tokens
///
/// Updates the access organization members have to organization resources via fine-grained personal access tokens. Limited to revoking a token's existing access.
///
/// Only GitHub Apps can use this endpoint.
///
/// [GitHub API docs for update_pat_accesses](https://docs.github.com/rest/orgs/personal-access-tokens#update-the-access-to-organization-resources-via-fine-grained-personal-access-tokens)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn update_pat_accesses(&self, org: &str, body: PostOrgsUpdatePatAccesses) -> Result<HashMap<String, Value>, AdapterError> {
let request_uri = format!("{}/orgs/{}/personal-access-tokens", super::GITHUB_BASE_API_URL, org);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostOrgsUpdatePatAccesses>(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() {
500 => Err(OrgsUpdatePatAccessesError::Status500(github_response.to_json()?).into()),
404 => Err(OrgsUpdatePatAccessesError::Status404(github_response.to_json()?).into()),
403 => Err(OrgsUpdatePatAccessesError::Status403(github_response.to_json()?).into()),
422 => Err(OrgsUpdatePatAccessesError::Status422(github_response.to_json()?).into()),
code => Err(OrgsUpdatePatAccessesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update an organization webhook
///
/// Updates a webhook configured in an organization. When you update a webhook,
/// the `secret` will be overwritten. If you previously had a `secret` set, you must
/// provide the same `secret` or set a new `secret` or the secret will be removed. If
/// you are only updating individual webhook `config` properties, use "[Update a webhook
/// configuration for an organization](/rest/orgs/webhooks#update-a-webhook-configuration-for-an-organization)".
///
/// You must be an organization owner to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need `admin:org_hook` scope. OAuth apps cannot list, view, or edit
/// webhooks that they did not create and users cannot list, view, or edit webhooks that were created by OAuth apps.
///
/// [GitHub API docs for update_webhook](https://docs.github.com/rest/orgs/webhooks#update-an-organization-webhook)
///
/// ---
pub async fn update_webhook_async(&self, org: &str, hook_id: i32, body: PatchOrgsUpdateWebhook) -> Result<OrgHook, AdapterError> {
let request_uri = format!("{}/orgs/{}/hooks/{}", super::GITHUB_BASE_API_URL, org, hook_id);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchOrgsUpdateWebhook>(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() {
422 => Err(OrgsUpdateWebhookError::Status422(github_response.to_json_async().await?).into()),
404 => Err(OrgsUpdateWebhookError::Status404(github_response.to_json_async().await?).into()),
code => Err(OrgsUpdateWebhookError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update an organization webhook
///
/// Updates a webhook configured in an organization. When you update a webhook,
/// the `secret` will be overwritten. If you previously had a `secret` set, you must
/// provide the same `secret` or set a new `secret` or the secret will be removed. If
/// you are only updating individual webhook `config` properties, use "[Update a webhook
/// configuration for an organization](/rest/orgs/webhooks#update-a-webhook-configuration-for-an-organization)".
///
/// You must be an organization owner to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need `admin:org_hook` scope. OAuth apps cannot list, view, or edit
/// webhooks that they did not create and users cannot list, view, or edit webhooks that were created by OAuth apps.
///
/// [GitHub API docs for update_webhook](https://docs.github.com/rest/orgs/webhooks#update-an-organization-webhook)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn update_webhook(&self, org: &str, hook_id: i32, body: PatchOrgsUpdateWebhook) -> Result<OrgHook, AdapterError> {
let request_uri = format!("{}/orgs/{}/hooks/{}", super::GITHUB_BASE_API_URL, org, hook_id);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchOrgsUpdateWebhook>(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() {
422 => Err(OrgsUpdateWebhookError::Status422(github_response.to_json()?).into()),
404 => Err(OrgsUpdateWebhookError::Status404(github_response.to_json()?).into()),
code => Err(OrgsUpdateWebhookError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update a webhook configuration for an organization
///
/// Updates the webhook configuration for an organization. To update more information about the webhook, including the `active` state and `events`, use "[Update an organization webhook ](/rest/orgs/webhooks#update-an-organization-webhook)."
///
/// You must be an organization owner to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need `admin:org_hook` scope. OAuth apps cannot list, view, or edit
/// webhooks that they did not create and users cannot list, view, or edit webhooks that were created by OAuth apps.
///
/// [GitHub API docs for update_webhook_config_for_org](https://docs.github.com/rest/orgs/webhooks#update-a-webhook-configuration-for-an-organization)
///
/// ---
pub async fn update_webhook_config_for_org_async(&self, org: &str, hook_id: i32, body: PatchOrgsUpdateWebhookConfigForOrg) -> Result<WebhookConfig, AdapterError> {
let request_uri = format!("{}/orgs/{}/hooks/{}/config", super::GITHUB_BASE_API_URL, org, hook_id);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchOrgsUpdateWebhookConfigForOrg>(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(OrgsUpdateWebhookConfigForOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update a webhook configuration for an organization
///
/// Updates the webhook configuration for an organization. To update more information about the webhook, including the `active` state and `events`, use "[Update an organization webhook ](/rest/orgs/webhooks#update-an-organization-webhook)."
///
/// You must be an organization owner to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need `admin:org_hook` scope. OAuth apps cannot list, view, or edit
/// webhooks that they did not create and users cannot list, view, or edit webhooks that were created by OAuth apps.
///
/// [GitHub API docs for update_webhook_config_for_org](https://docs.github.com/rest/orgs/webhooks#update-a-webhook-configuration-for-an-organization)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn update_webhook_config_for_org(&self, org: &str, hook_id: i32, body: PatchOrgsUpdateWebhookConfigForOrg) -> Result<WebhookConfig, AdapterError> {
let request_uri = format!("{}/orgs/{}/hooks/{}/config", super::GITHUB_BASE_API_URL, org, hook_id);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchOrgsUpdateWebhookConfigForOrg>(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(OrgsUpdateWebhookConfigForOrgError::Generic { code }.into()),
}
}
}
}