//! Method, error and parameter types for the Repos 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 Repos<'api, C: Client> where AdapterError: From<<C as Client>::Err> {
client: &'api C
}
pub fn new<C: Client>(client: &C) -> Repos<C> where AdapterError: From<<C as Client>::Err> {
Repos { client }
}
/// Errors for the [Accept a repository invitation](Repos::accept_invitation_for_authenticated_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposAcceptInvitationForAuthenticatedUserError {
#[error("Forbidden")]
Status403(BasicError),
#[error("Conflict")]
Status409(BasicError),
#[error("Resource not found")]
Status404(BasicError),
#[error("Not modified")]
Status304,
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposAcceptInvitationForAuthenticatedUserError> for AdapterError {
fn from(err: ReposAcceptInvitationForAuthenticatedUserError) -> Self {
let (description, status_code) = match err {
ReposAcceptInvitationForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403),
ReposAcceptInvitationForAuthenticatedUserError::Status409(_) => (String::from("Conflict"), 409),
ReposAcceptInvitationForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404),
ReposAcceptInvitationForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304),
ReposAcceptInvitationForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Add app access restrictions](Repos::add_app_access_restrictions_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposAddAppAccessRestrictionsError {
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposAddAppAccessRestrictionsError> for AdapterError {
fn from(err: ReposAddAppAccessRestrictionsError) -> Self {
let (description, status_code) = match err {
ReposAddAppAccessRestrictionsError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposAddAppAccessRestrictionsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Add a repository collaborator](Repos::add_collaborator_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposAddCollaboratorError {
#[error("Response when: - an existing collaborator is added as a collaborator - an organization member is added as an individual collaborator - an existing team member (whose team is also a repository collaborator) is added as an individual collaborator")]
Status204,
#[error("Response when: - validation failed, or the endpoint has been spammed - an Enterprise Managed User (EMU) account was invited to a repository in an enterprise with personal user accounts")]
Status422(ValidationError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposAddCollaboratorError> for AdapterError {
fn from(err: ReposAddCollaboratorError) -> Self {
let (description, status_code) = match err {
ReposAddCollaboratorError::Status204 => (String::from("Response when: - an existing collaborator is added as a collaborator - an organization member is added as an individual collaborator - an existing team member (whose team is also a repository collaborator) is added as an individual collaborator"), 204),
ReposAddCollaboratorError::Status422(_) => (String::from("Response when: - validation failed, or the endpoint has been spammed - an Enterprise Managed User (EMU) account was invited to a repository in an enterprise with personal user accounts"), 422),
ReposAddCollaboratorError::Status403(_) => (String::from("Forbidden"), 403),
ReposAddCollaboratorError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Add status check contexts](Repos::add_status_check_contexts_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposAddStatusCheckContextsError {
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposAddStatusCheckContextsError> for AdapterError {
fn from(err: ReposAddStatusCheckContextsError) -> Self {
let (description, status_code) = match err {
ReposAddStatusCheckContextsError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposAddStatusCheckContextsError::Status403(_) => (String::from("Forbidden"), 403),
ReposAddStatusCheckContextsError::Status404(_) => (String::from("Resource not found"), 404),
ReposAddStatusCheckContextsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Add team access restrictions](Repos::add_team_access_restrictions_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposAddTeamAccessRestrictionsError {
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposAddTeamAccessRestrictionsError> for AdapterError {
fn from(err: ReposAddTeamAccessRestrictionsError) -> Self {
let (description, status_code) = match err {
ReposAddTeamAccessRestrictionsError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposAddTeamAccessRestrictionsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Add user access restrictions](Repos::add_user_access_restrictions_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposAddUserAccessRestrictionsError {
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposAddUserAccessRestrictionsError> for AdapterError {
fn from(err: ReposAddUserAccessRestrictionsError) -> Self {
let (description, status_code) = match err {
ReposAddUserAccessRestrictionsError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposAddUserAccessRestrictionsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Cancel a GitHub Pages deployment](Repos::cancel_pages_deployment_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposCancelPagesDeploymentError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposCancelPagesDeploymentError> for AdapterError {
fn from(err: ReposCancelPagesDeploymentError) -> Self {
let (description, status_code) = match err {
ReposCancelPagesDeploymentError::Status404(_) => (String::from("Resource not found"), 404),
ReposCancelPagesDeploymentError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Check if Dependabot security updates are enabled for a repository](Repos::check_automated_security_fixes_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposCheckAutomatedSecurityFixesError {
#[error("Not Found if Dependabot is not enabled for the repository")]
Status404,
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposCheckAutomatedSecurityFixesError> for AdapterError {
fn from(err: ReposCheckAutomatedSecurityFixesError) -> Self {
let (description, status_code) = match err {
ReposCheckAutomatedSecurityFixesError::Status404 => (String::from("Not Found if Dependabot is not enabled for the repository"), 404),
ReposCheckAutomatedSecurityFixesError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Check if a user is a repository collaborator](Repos::check_collaborator_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposCheckCollaboratorError {
#[error("Not Found if user is not a collaborator")]
Status404,
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposCheckCollaboratorError> for AdapterError {
fn from(err: ReposCheckCollaboratorError) -> Self {
let (description, status_code) = match err {
ReposCheckCollaboratorError::Status404 => (String::from("Not Found if user is not a collaborator"), 404),
ReposCheckCollaboratorError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Check if private vulnerability reporting is enabled for a repository](Repos::check_private_vulnerability_reporting_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposCheckPrivateVulnerabilityReportingError {
#[error("Bad Request")]
Status422(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposCheckPrivateVulnerabilityReportingError> for AdapterError {
fn from(err: ReposCheckPrivateVulnerabilityReportingError) -> Self {
let (description, status_code) = match err {
ReposCheckPrivateVulnerabilityReportingError::Status422(_) => (String::from("Bad Request"), 422),
ReposCheckPrivateVulnerabilityReportingError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Check if vulnerability alerts are enabled for a repository](Repos::check_vulnerability_alerts_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposCheckVulnerabilityAlertsError {
#[error("Not Found if repository is not enabled with vulnerability alerts")]
Status404,
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposCheckVulnerabilityAlertsError> for AdapterError {
fn from(err: ReposCheckVulnerabilityAlertsError) -> Self {
let (description, status_code) = match err {
ReposCheckVulnerabilityAlertsError::Status404 => (String::from("Not Found if repository is not enabled with vulnerability alerts"), 404),
ReposCheckVulnerabilityAlertsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List CODEOWNERS errors](Repos::codeowners_errors_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposCodeownersErrorsError {
#[error("Resource not found")]
Status404,
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposCodeownersErrorsError> for AdapterError {
fn from(err: ReposCodeownersErrorsError) -> Self {
let (description, status_code) = match err {
ReposCodeownersErrorsError::Status404 => (String::from("Resource not found"), 404),
ReposCodeownersErrorsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Compare two commits](Repos::compare_commits_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposCompareCommitsError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Internal Error")]
Status500(BasicError),
#[error("Service unavailable")]
Status503(GetBillingGetGithubBillingUsageReportUserResponse503),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposCompareCommitsError> for AdapterError {
fn from(err: ReposCompareCommitsError) -> Self {
let (description, status_code) = match err {
ReposCompareCommitsError::Status404(_) => (String::from("Resource not found"), 404),
ReposCompareCommitsError::Status500(_) => (String::from("Internal Error"), 500),
ReposCompareCommitsError::Status503(_) => (String::from("Service unavailable"), 503),
ReposCompareCommitsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Create an attestation](Repos::create_attestation_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposCreateAttestationError {
#[error("Forbidden")]
Status403(BasicError),
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposCreateAttestationError> for AdapterError {
fn from(err: ReposCreateAttestationError) -> Self {
let (description, status_code) = match err {
ReposCreateAttestationError::Status403(_) => (String::from("Forbidden"), 403),
ReposCreateAttestationError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposCreateAttestationError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Create an autolink reference for a repository](Repos::create_autolink_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposCreateAutolinkError {
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposCreateAutolinkError> for AdapterError {
fn from(err: ReposCreateAutolinkError) -> Self {
let (description, status_code) = match err {
ReposCreateAutolinkError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposCreateAutolinkError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Create a commit comment](Repos::create_commit_comment_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposCreateCommitCommentError {
#[error("Forbidden")]
Status403(BasicError),
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposCreateCommitCommentError> for AdapterError {
fn from(err: ReposCreateCommitCommentError) -> Self {
let (description, status_code) = match err {
ReposCreateCommitCommentError::Status403(_) => (String::from("Forbidden"), 403),
ReposCreateCommitCommentError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposCreateCommitCommentError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Create commit signature protection](Repos::create_commit_signature_protection_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposCreateCommitSignatureProtectionError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposCreateCommitSignatureProtectionError> for AdapterError {
fn from(err: ReposCreateCommitSignatureProtectionError) -> Self {
let (description, status_code) = match err {
ReposCreateCommitSignatureProtectionError::Status404(_) => (String::from("Resource not found"), 404),
ReposCreateCommitSignatureProtectionError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Create a commit status](Repos::create_commit_status_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposCreateCommitStatusError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposCreateCommitStatusError> for AdapterError {
fn from(err: ReposCreateCommitStatusError) -> Self {
let (description, status_code) = match err {
ReposCreateCommitStatusError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Create a deploy key](Repos::create_deploy_key_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposCreateDeployKeyError {
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposCreateDeployKeyError> for AdapterError {
fn from(err: ReposCreateDeployKeyError) -> Self {
let (description, status_code) = match err {
ReposCreateDeployKeyError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposCreateDeployKeyError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Create a deployment](Repos::create_deployment_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposCreateDeploymentError {
#[error("Merged branch response")]
Status202(PostReposCreateDeploymentResponse202),
#[error("Conflict when there is a merge conflict or the commit's status checks failed")]
Status409,
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposCreateDeploymentError> for AdapterError {
fn from(err: ReposCreateDeploymentError) -> Self {
let (description, status_code) = match err {
ReposCreateDeploymentError::Status202(_) => (String::from("Merged branch response"), 202),
ReposCreateDeploymentError::Status409 => (String::from("Conflict when there is a merge conflict or the commit's status checks failed"), 409),
ReposCreateDeploymentError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposCreateDeploymentError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Create a deployment branch policy](Repos::create_deployment_branch_policy_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposCreateDeploymentBranchPolicyError {
#[error("Not Found or `deployment_branch_policy.custom_branch_policies` property for the environment is set to false")]
Status404,
#[error("Response if the same branch name pattern already exists")]
Status303,
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposCreateDeploymentBranchPolicyError> for AdapterError {
fn from(err: ReposCreateDeploymentBranchPolicyError) -> Self {
let (description, status_code) = match err {
ReposCreateDeploymentBranchPolicyError::Status404 => (String::from("Not Found or `deployment_branch_policy.custom_branch_policies` property for the environment is set to false"), 404),
ReposCreateDeploymentBranchPolicyError::Status303 => (String::from("Response if the same branch name pattern already exists"), 303),
ReposCreateDeploymentBranchPolicyError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Create a custom deployment protection rule on an environment](Repos::create_deployment_protection_rule_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposCreateDeploymentProtectionRuleError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposCreateDeploymentProtectionRuleError> for AdapterError {
fn from(err: ReposCreateDeploymentProtectionRuleError) -> Self {
let (description, status_code) = match err {
ReposCreateDeploymentProtectionRuleError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Create a deployment status](Repos::create_deployment_status_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposCreateDeploymentStatusError {
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposCreateDeploymentStatusError> for AdapterError {
fn from(err: ReposCreateDeploymentStatusError) -> Self {
let (description, status_code) = match err {
ReposCreateDeploymentStatusError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposCreateDeploymentStatusError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Create a repository dispatch event](Repos::create_dispatch_event_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposCreateDispatchEventError {
#[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<ReposCreateDispatchEventError> for AdapterError {
fn from(err: ReposCreateDispatchEventError) -> Self {
let (description, status_code) = match err {
ReposCreateDispatchEventError::Status404(_) => (String::from("Resource not found"), 404),
ReposCreateDispatchEventError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposCreateDispatchEventError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Create a repository for the authenticated user](Repos::create_for_authenticated_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposCreateForAuthenticatedUserError {
#[error("Requires authentication")]
Status401(BasicError),
#[error("Not modified")]
Status304,
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Bad Request")]
Status400(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposCreateForAuthenticatedUserError> for AdapterError {
fn from(err: ReposCreateForAuthenticatedUserError) -> Self {
let (description, status_code) = match err {
ReposCreateForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401),
ReposCreateForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304),
ReposCreateForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404),
ReposCreateForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403),
ReposCreateForAuthenticatedUserError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposCreateForAuthenticatedUserError::Status400(_) => (String::from("Bad Request"), 400),
ReposCreateForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Create a fork](Repos::create_fork_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposCreateForkError {
#[error("Bad Request")]
Status400(BasicError),
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposCreateForkError> for AdapterError {
fn from(err: ReposCreateForkError) -> Self {
let (description, status_code) = match err {
ReposCreateForkError::Status400(_) => (String::from("Bad Request"), 400),
ReposCreateForkError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposCreateForkError::Status403(_) => (String::from("Forbidden"), 403),
ReposCreateForkError::Status404(_) => (String::from("Resource not found"), 404),
ReposCreateForkError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Create an organization repository](Repos::create_in_org_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposCreateInOrgError {
#[error("Forbidden")]
Status403(BasicError),
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposCreateInOrgError> for AdapterError {
fn from(err: ReposCreateInOrgError) -> Self {
let (description, status_code) = match err {
ReposCreateInOrgError::Status403(_) => (String::from("Forbidden"), 403),
ReposCreateInOrgError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposCreateInOrgError::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 a repository](Repos::create_or_update_custom_properties_values_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposCreateOrUpdateCustomPropertiesValuesError {
#[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<ReposCreateOrUpdateCustomPropertiesValuesError> for AdapterError {
fn from(err: ReposCreateOrUpdateCustomPropertiesValuesError) -> Self {
let (description, status_code) = match err {
ReposCreateOrUpdateCustomPropertiesValuesError::Status403(_) => (String::from("Forbidden"), 403),
ReposCreateOrUpdateCustomPropertiesValuesError::Status404(_) => (String::from("Resource not found"), 404),
ReposCreateOrUpdateCustomPropertiesValuesError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposCreateOrUpdateCustomPropertiesValuesError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Create or update an environment](Repos::create_or_update_environment_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposCreateOrUpdateEnvironmentError {
#[error("Validation error when the environment name is invalid or when `protected_branches` and `custom_branch_policies` in `deployment_branch_policy` are set to the same value")]
Status422(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposCreateOrUpdateEnvironmentError> for AdapterError {
fn from(err: ReposCreateOrUpdateEnvironmentError) -> Self {
let (description, status_code) = match err {
ReposCreateOrUpdateEnvironmentError::Status422(_) => (String::from("Validation error when the environment name is invalid or when `protected_branches` and `custom_branch_policies` in `deployment_branch_policy` are set to the same value"), 422),
ReposCreateOrUpdateEnvironmentError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Create or update file contents](Repos::create_or_update_file_contents_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposCreateOrUpdateFileContentsError {
#[error("Response")]
Status201(FileCommit),
#[error("Resource not found")]
Status404(BasicError),
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Conflict")]
Status409(PutReposCreateOrUpdateFileContentsResponse409),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposCreateOrUpdateFileContentsError> for AdapterError {
fn from(err: ReposCreateOrUpdateFileContentsError) -> Self {
let (description, status_code) = match err {
ReposCreateOrUpdateFileContentsError::Status201(_) => (String::from("Response"), 201),
ReposCreateOrUpdateFileContentsError::Status404(_) => (String::from("Resource not found"), 404),
ReposCreateOrUpdateFileContentsError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposCreateOrUpdateFileContentsError::Status409(_) => (String::from("Conflict"), 409),
ReposCreateOrUpdateFileContentsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Create an organization repository ruleset](Repos::create_org_ruleset_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposCreateOrgRulesetError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Internal Error")]
Status500(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposCreateOrgRulesetError> for AdapterError {
fn from(err: ReposCreateOrgRulesetError) -> Self {
let (description, status_code) = match err {
ReposCreateOrgRulesetError::Status404(_) => (String::from("Resource not found"), 404),
ReposCreateOrgRulesetError::Status500(_) => (String::from("Internal Error"), 500),
ReposCreateOrgRulesetError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Create a GitHub Pages deployment](Repos::create_pages_deployment_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposCreatePagesDeploymentError {
#[error("Bad Request")]
Status400(BasicError),
#[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<ReposCreatePagesDeploymentError> for AdapterError {
fn from(err: ReposCreatePagesDeploymentError) -> Self {
let (description, status_code) = match err {
ReposCreatePagesDeploymentError::Status400(_) => (String::from("Bad Request"), 400),
ReposCreatePagesDeploymentError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposCreatePagesDeploymentError::Status404(_) => (String::from("Resource not found"), 404),
ReposCreatePagesDeploymentError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Create a GitHub Pages site](Repos::create_pages_site_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposCreatePagesSiteError {
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Conflict")]
Status409(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposCreatePagesSiteError> for AdapterError {
fn from(err: ReposCreatePagesSiteError) -> Self {
let (description, status_code) = match err {
ReposCreatePagesSiteError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposCreatePagesSiteError::Status409(_) => (String::from("Conflict"), 409),
ReposCreatePagesSiteError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Create a release](Repos::create_release_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposCreateReleaseError {
#[error("Not Found if the discussion category name is invalid")]
Status404(BasicError),
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposCreateReleaseError> for AdapterError {
fn from(err: ReposCreateReleaseError) -> Self {
let (description, status_code) = match err {
ReposCreateReleaseError::Status404(_) => (String::from("Not Found if the discussion category name is invalid"), 404),
ReposCreateReleaseError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposCreateReleaseError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Create a repository ruleset](Repos::create_repo_ruleset_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposCreateRepoRulesetError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Internal Error")]
Status500(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposCreateRepoRulesetError> for AdapterError {
fn from(err: ReposCreateRepoRulesetError) -> Self {
let (description, status_code) = match err {
ReposCreateRepoRulesetError::Status404(_) => (String::from("Resource not found"), 404),
ReposCreateRepoRulesetError::Status500(_) => (String::from("Internal Error"), 500),
ReposCreateRepoRulesetError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Closing down - Create a tag protection state for a repository](Repos::create_tag_protection_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposCreateTagProtectionError {
#[error("Forbidden")]
Status403(BasicError),
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposCreateTagProtectionError> for AdapterError {
fn from(err: ReposCreateTagProtectionError) -> Self {
let (description, status_code) = match err {
ReposCreateTagProtectionError::Status403(_) => (String::from("Forbidden"), 403),
ReposCreateTagProtectionError::Status404(_) => (String::from("Resource not found"), 404),
ReposCreateTagProtectionError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Create a repository using a template](Repos::create_using_template_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposCreateUsingTemplateError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposCreateUsingTemplateError> for AdapterError {
fn from(err: ReposCreateUsingTemplateError) -> Self {
let (description, status_code) = match err {
ReposCreateUsingTemplateError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Create a repository webhook](Repos::create_webhook_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposCreateWebhookError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposCreateWebhookError> for AdapterError {
fn from(err: ReposCreateWebhookError) -> Self {
let (description, status_code) = match err {
ReposCreateWebhookError::Status404(_) => (String::from("Resource not found"), 404),
ReposCreateWebhookError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposCreateWebhookError::Status403(_) => (String::from("Forbidden"), 403),
ReposCreateWebhookError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Decline a repository invitation](Repos::decline_invitation_for_authenticated_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposDeclineInvitationForAuthenticatedUserError {
#[error("Conflict")]
Status409(BasicError),
#[error("Not modified")]
Status304,
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposDeclineInvitationForAuthenticatedUserError> for AdapterError {
fn from(err: ReposDeclineInvitationForAuthenticatedUserError) -> Self {
let (description, status_code) = match err {
ReposDeclineInvitationForAuthenticatedUserError::Status409(_) => (String::from("Conflict"), 409),
ReposDeclineInvitationForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304),
ReposDeclineInvitationForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404),
ReposDeclineInvitationForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403),
ReposDeclineInvitationForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Delete a repository](Repos::delete_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposDeleteError {
#[error("If an organization owner has configured the organization to prevent members from deleting organization-owned repositories, a member will get this response:")]
Status403(PutTeamsAddOrUpdateProjectPermissionsLegacyResponse403),
#[error("Temporary Redirect")]
Status307(BasicError),
#[error("Resource not found")]
Status404(BasicError),
#[error("Conflict")]
Status409(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposDeleteError> for AdapterError {
fn from(err: ReposDeleteError) -> Self {
let (description, status_code) = match err {
ReposDeleteError::Status403(_) => (String::from("If an organization owner has configured the organization to prevent members from deleting organization-owned repositories, a member will get this response:"), 403),
ReposDeleteError::Status307(_) => (String::from("Temporary Redirect"), 307),
ReposDeleteError::Status404(_) => (String::from("Resource not found"), 404),
ReposDeleteError::Status409(_) => (String::from("Conflict"), 409),
ReposDeleteError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Delete access restrictions](Repos::delete_access_restrictions_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposDeleteAccessRestrictionsError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposDeleteAccessRestrictionsError> for AdapterError {
fn from(err: ReposDeleteAccessRestrictionsError) -> Self {
let (description, status_code) = match err {
ReposDeleteAccessRestrictionsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Delete admin branch protection](Repos::delete_admin_branch_protection_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposDeleteAdminBranchProtectionError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposDeleteAdminBranchProtectionError> for AdapterError {
fn from(err: ReposDeleteAdminBranchProtectionError) -> Self {
let (description, status_code) = match err {
ReposDeleteAdminBranchProtectionError::Status404(_) => (String::from("Resource not found"), 404),
ReposDeleteAdminBranchProtectionError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Delete an environment](Repos::delete_an_environment_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposDeleteAnEnvironmentError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposDeleteAnEnvironmentError> for AdapterError {
fn from(err: ReposDeleteAnEnvironmentError) -> Self {
let (description, status_code) = match err {
ReposDeleteAnEnvironmentError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Delete an autolink reference from a repository](Repos::delete_autolink_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposDeleteAutolinkError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposDeleteAutolinkError> for AdapterError {
fn from(err: ReposDeleteAutolinkError) -> Self {
let (description, status_code) = match err {
ReposDeleteAutolinkError::Status404(_) => (String::from("Resource not found"), 404),
ReposDeleteAutolinkError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Delete branch protection](Repos::delete_branch_protection_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposDeleteBranchProtectionError {
#[error("Forbidden")]
Status403(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposDeleteBranchProtectionError> for AdapterError {
fn from(err: ReposDeleteBranchProtectionError) -> Self {
let (description, status_code) = match err {
ReposDeleteBranchProtectionError::Status403(_) => (String::from("Forbidden"), 403),
ReposDeleteBranchProtectionError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Delete a commit comment](Repos::delete_commit_comment_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposDeleteCommitCommentError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposDeleteCommitCommentError> for AdapterError {
fn from(err: ReposDeleteCommitCommentError) -> Self {
let (description, status_code) = match err {
ReposDeleteCommitCommentError::Status404(_) => (String::from("Resource not found"), 404),
ReposDeleteCommitCommentError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Delete commit signature protection](Repos::delete_commit_signature_protection_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposDeleteCommitSignatureProtectionError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposDeleteCommitSignatureProtectionError> for AdapterError {
fn from(err: ReposDeleteCommitSignatureProtectionError) -> Self {
let (description, status_code) = match err {
ReposDeleteCommitSignatureProtectionError::Status404(_) => (String::from("Resource not found"), 404),
ReposDeleteCommitSignatureProtectionError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Delete a deploy key](Repos::delete_deploy_key_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposDeleteDeployKeyError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposDeleteDeployKeyError> for AdapterError {
fn from(err: ReposDeleteDeployKeyError) -> Self {
let (description, status_code) = match err {
ReposDeleteDeployKeyError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Delete a deployment](Repos::delete_deployment_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposDeleteDeploymentError {
#[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<ReposDeleteDeploymentError> for AdapterError {
fn from(err: ReposDeleteDeploymentError) -> Self {
let (description, status_code) = match err {
ReposDeleteDeploymentError::Status404(_) => (String::from("Resource not found"), 404),
ReposDeleteDeploymentError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposDeleteDeploymentError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Delete a deployment branch policy](Repos::delete_deployment_branch_policy_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposDeleteDeploymentBranchPolicyError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposDeleteDeploymentBranchPolicyError> for AdapterError {
fn from(err: ReposDeleteDeploymentBranchPolicyError) -> Self {
let (description, status_code) = match err {
ReposDeleteDeploymentBranchPolicyError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Delete a file](Repos::delete_file_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposDeleteFileError {
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Resource not found")]
Status404(BasicError),
#[error("Conflict")]
Status409(BasicError),
#[error("Service unavailable")]
Status503(GetBillingGetGithubBillingUsageReportUserResponse503),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposDeleteFileError> for AdapterError {
fn from(err: ReposDeleteFileError) -> Self {
let (description, status_code) = match err {
ReposDeleteFileError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposDeleteFileError::Status404(_) => (String::from("Resource not found"), 404),
ReposDeleteFileError::Status409(_) => (String::from("Conflict"), 409),
ReposDeleteFileError::Status503(_) => (String::from("Service unavailable"), 503),
ReposDeleteFileError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Delete a repository invitation](Repos::delete_invitation_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposDeleteInvitationError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposDeleteInvitationError> for AdapterError {
fn from(err: ReposDeleteInvitationError) -> Self {
let (description, status_code) = match err {
ReposDeleteInvitationError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Delete an organization repository ruleset](Repos::delete_org_ruleset_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposDeleteOrgRulesetError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Internal Error")]
Status500(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposDeleteOrgRulesetError> for AdapterError {
fn from(err: ReposDeleteOrgRulesetError) -> Self {
let (description, status_code) = match err {
ReposDeleteOrgRulesetError::Status404(_) => (String::from("Resource not found"), 404),
ReposDeleteOrgRulesetError::Status500(_) => (String::from("Internal Error"), 500),
ReposDeleteOrgRulesetError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Delete a GitHub Pages site](Repos::delete_pages_site_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposDeletePagesSiteError {
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Resource not found")]
Status404(BasicError),
#[error("Conflict")]
Status409(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposDeletePagesSiteError> for AdapterError {
fn from(err: ReposDeletePagesSiteError) -> Self {
let (description, status_code) = match err {
ReposDeletePagesSiteError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposDeletePagesSiteError::Status404(_) => (String::from("Resource not found"), 404),
ReposDeletePagesSiteError::Status409(_) => (String::from("Conflict"), 409),
ReposDeletePagesSiteError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Delete pull request review protection](Repos::delete_pull_request_review_protection_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposDeletePullRequestReviewProtectionError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposDeletePullRequestReviewProtectionError> for AdapterError {
fn from(err: ReposDeletePullRequestReviewProtectionError) -> Self {
let (description, status_code) = match err {
ReposDeletePullRequestReviewProtectionError::Status404(_) => (String::from("Resource not found"), 404),
ReposDeletePullRequestReviewProtectionError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Delete a release](Repos::delete_release_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposDeleteReleaseError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposDeleteReleaseError> for AdapterError {
fn from(err: ReposDeleteReleaseError) -> Self {
let (description, status_code) = match err {
ReposDeleteReleaseError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Delete a release asset](Repos::delete_release_asset_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposDeleteReleaseAssetError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposDeleteReleaseAssetError> for AdapterError {
fn from(err: ReposDeleteReleaseAssetError) -> Self {
let (description, status_code) = match err {
ReposDeleteReleaseAssetError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Delete a repository ruleset](Repos::delete_repo_ruleset_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposDeleteRepoRulesetError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Internal Error")]
Status500(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposDeleteRepoRulesetError> for AdapterError {
fn from(err: ReposDeleteRepoRulesetError) -> Self {
let (description, status_code) = match err {
ReposDeleteRepoRulesetError::Status404(_) => (String::from("Resource not found"), 404),
ReposDeleteRepoRulesetError::Status500(_) => (String::from("Internal Error"), 500),
ReposDeleteRepoRulesetError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Closing down - Delete a tag protection state for a repository](Repos::delete_tag_protection_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposDeleteTagProtectionError {
#[error("Forbidden")]
Status403(BasicError),
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposDeleteTagProtectionError> for AdapterError {
fn from(err: ReposDeleteTagProtectionError) -> Self {
let (description, status_code) = match err {
ReposDeleteTagProtectionError::Status403(_) => (String::from("Forbidden"), 403),
ReposDeleteTagProtectionError::Status404(_) => (String::from("Resource not found"), 404),
ReposDeleteTagProtectionError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Delete a repository webhook](Repos::delete_webhook_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposDeleteWebhookError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposDeleteWebhookError> for AdapterError {
fn from(err: ReposDeleteWebhookError) -> Self {
let (description, status_code) = match err {
ReposDeleteWebhookError::Status404(_) => (String::from("Resource not found"), 404),
ReposDeleteWebhookError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Disable Dependabot security updates](Repos::disable_automated_security_fixes_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposDisableAutomatedSecurityFixesError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposDisableAutomatedSecurityFixesError> for AdapterError {
fn from(err: ReposDisableAutomatedSecurityFixesError) -> Self {
let (description, status_code) = match err {
ReposDisableAutomatedSecurityFixesError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Disable a custom protection rule for an environment](Repos::disable_deployment_protection_rule_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposDisableDeploymentProtectionRuleError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposDisableDeploymentProtectionRuleError> for AdapterError {
fn from(err: ReposDisableDeploymentProtectionRuleError) -> Self {
let (description, status_code) = match err {
ReposDisableDeploymentProtectionRuleError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Disable private vulnerability reporting for a repository](Repos::disable_private_vulnerability_reporting_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposDisablePrivateVulnerabilityReportingError {
#[error("Bad Request")]
Status422(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposDisablePrivateVulnerabilityReportingError> for AdapterError {
fn from(err: ReposDisablePrivateVulnerabilityReportingError) -> Self {
let (description, status_code) = match err {
ReposDisablePrivateVulnerabilityReportingError::Status422(_) => (String::from("Bad Request"), 422),
ReposDisablePrivateVulnerabilityReportingError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Disable vulnerability alerts](Repos::disable_vulnerability_alerts_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposDisableVulnerabilityAlertsError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposDisableVulnerabilityAlertsError> for AdapterError {
fn from(err: ReposDisableVulnerabilityAlertsError) -> Self {
let (description, status_code) = match err {
ReposDisableVulnerabilityAlertsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Download a repository archive (tar)](Repos::download_tarball_archive_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposDownloadTarballArchiveError {
#[error("Response")]
Status302,
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposDownloadTarballArchiveError> for AdapterError {
fn from(err: ReposDownloadTarballArchiveError) -> Self {
let (description, status_code) = match err {
ReposDownloadTarballArchiveError::Status302 => (String::from("Response"), 302),
ReposDownloadTarballArchiveError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Download a repository archive (zip)](Repos::download_zipball_archive_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposDownloadZipballArchiveError {
#[error("Response")]
Status302,
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposDownloadZipballArchiveError> for AdapterError {
fn from(err: ReposDownloadZipballArchiveError) -> Self {
let (description, status_code) = match err {
ReposDownloadZipballArchiveError::Status302 => (String::from("Response"), 302),
ReposDownloadZipballArchiveError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Enable Dependabot security updates](Repos::enable_automated_security_fixes_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposEnableAutomatedSecurityFixesError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposEnableAutomatedSecurityFixesError> for AdapterError {
fn from(err: ReposEnableAutomatedSecurityFixesError) -> Self {
let (description, status_code) = match err {
ReposEnableAutomatedSecurityFixesError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Enable private vulnerability reporting for a repository](Repos::enable_private_vulnerability_reporting_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposEnablePrivateVulnerabilityReportingError {
#[error("Bad Request")]
Status422(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposEnablePrivateVulnerabilityReportingError> for AdapterError {
fn from(err: ReposEnablePrivateVulnerabilityReportingError) -> Self {
let (description, status_code) = match err {
ReposEnablePrivateVulnerabilityReportingError::Status422(_) => (String::from("Bad Request"), 422),
ReposEnablePrivateVulnerabilityReportingError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Enable vulnerability alerts](Repos::enable_vulnerability_alerts_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposEnableVulnerabilityAlertsError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposEnableVulnerabilityAlertsError> for AdapterError {
fn from(err: ReposEnableVulnerabilityAlertsError) -> Self {
let (description, status_code) = match err {
ReposEnableVulnerabilityAlertsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Generate release notes content for a release](Repos::generate_release_notes_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGenerateReleaseNotesError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGenerateReleaseNotesError> for AdapterError {
fn from(err: ReposGenerateReleaseNotesError) -> Self {
let (description, status_code) = match err {
ReposGenerateReleaseNotesError::Status404(_) => (String::from("Resource not found"), 404),
ReposGenerateReleaseNotesError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get a repository](Repos::get_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetError {
#[error("Forbidden")]
Status403(BasicError),
#[error("Resource not found")]
Status404(BasicError),
#[error("Moved permanently")]
Status301(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetError> for AdapterError {
fn from(err: ReposGetError) -> Self {
let (description, status_code) = match err {
ReposGetError::Status403(_) => (String::from("Forbidden"), 403),
ReposGetError::Status404(_) => (String::from("Resource not found"), 404),
ReposGetError::Status301(_) => (String::from("Moved permanently"), 301),
ReposGetError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get access restrictions](Repos::get_access_restrictions_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetAccessRestrictionsError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetAccessRestrictionsError> for AdapterError {
fn from(err: ReposGetAccessRestrictionsError) -> Self {
let (description, status_code) = match err {
ReposGetAccessRestrictionsError::Status404(_) => (String::from("Resource not found"), 404),
ReposGetAccessRestrictionsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get admin branch protection](Repos::get_admin_branch_protection_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetAdminBranchProtectionError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetAdminBranchProtectionError> for AdapterError {
fn from(err: ReposGetAdminBranchProtectionError) -> Self {
let (description, status_code) = match err {
ReposGetAdminBranchProtectionError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get all deployment protection rules for an environment](Repos::get_all_deployment_protection_rules_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetAllDeploymentProtectionRulesError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetAllDeploymentProtectionRulesError> for AdapterError {
fn from(err: ReposGetAllDeploymentProtectionRulesError) -> Self {
let (description, status_code) = match err {
ReposGetAllDeploymentProtectionRulesError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List environments](Repos::get_all_environments_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetAllEnvironmentsError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetAllEnvironmentsError> for AdapterError {
fn from(err: ReposGetAllEnvironmentsError) -> Self {
let (description, status_code) = match err {
ReposGetAllEnvironmentsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get all status check contexts](Repos::get_all_status_check_contexts_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetAllStatusCheckContextsError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetAllStatusCheckContextsError> for AdapterError {
fn from(err: ReposGetAllStatusCheckContextsError) -> Self {
let (description, status_code) = match err {
ReposGetAllStatusCheckContextsError::Status404(_) => (String::from("Resource not found"), 404),
ReposGetAllStatusCheckContextsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get all repository topics](Repos::get_all_topics_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetAllTopicsError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetAllTopicsError> for AdapterError {
fn from(err: ReposGetAllTopicsError) -> Self {
let (description, status_code) = match err {
ReposGetAllTopicsError::Status404(_) => (String::from("Resource not found"), 404),
ReposGetAllTopicsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get apps with access to the protected branch](Repos::get_apps_with_access_to_protected_branch_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetAppsWithAccessToProtectedBranchError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetAppsWithAccessToProtectedBranchError> for AdapterError {
fn from(err: ReposGetAppsWithAccessToProtectedBranchError) -> Self {
let (description, status_code) = match err {
ReposGetAppsWithAccessToProtectedBranchError::Status404(_) => (String::from("Resource not found"), 404),
ReposGetAppsWithAccessToProtectedBranchError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get an autolink reference of a repository](Repos::get_autolink_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetAutolinkError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetAutolinkError> for AdapterError {
fn from(err: ReposGetAutolinkError) -> Self {
let (description, status_code) = match err {
ReposGetAutolinkError::Status404(_) => (String::from("Resource not found"), 404),
ReposGetAutolinkError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get a branch](Repos::get_branch_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetBranchError {
#[error("Moved permanently")]
Status301(BasicError),
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetBranchError> for AdapterError {
fn from(err: ReposGetBranchError) -> Self {
let (description, status_code) = match err {
ReposGetBranchError::Status301(_) => (String::from("Moved permanently"), 301),
ReposGetBranchError::Status404(_) => (String::from("Resource not found"), 404),
ReposGetBranchError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get branch protection](Repos::get_branch_protection_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetBranchProtectionError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetBranchProtectionError> for AdapterError {
fn from(err: ReposGetBranchProtectionError) -> Self {
let (description, status_code) = match err {
ReposGetBranchProtectionError::Status404(_) => (String::from("Resource not found"), 404),
ReposGetBranchProtectionError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get rules for a branch](Repos::get_branch_rules_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetBranchRulesError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetBranchRulesError> for AdapterError {
fn from(err: ReposGetBranchRulesError) -> Self {
let (description, status_code) = match err {
ReposGetBranchRulesError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get repository clones](Repos::get_clones_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetClonesError {
#[error("Forbidden")]
Status403(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetClonesError> for AdapterError {
fn from(err: ReposGetClonesError) -> Self {
let (description, status_code) = match err {
ReposGetClonesError::Status403(_) => (String::from("Forbidden"), 403),
ReposGetClonesError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get the weekly commit activity](Repos::get_code_frequency_stats_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetCodeFrequencyStatsError {
#[error("Accepted")]
Status202(HashMap<String, Value>),
#[error("A header with no content is returned.")]
Status204,
#[error("Repository contains more than 10,000 commits")]
Status422,
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetCodeFrequencyStatsError> for AdapterError {
fn from(err: ReposGetCodeFrequencyStatsError) -> Self {
let (description, status_code) = match err {
ReposGetCodeFrequencyStatsError::Status202(_) => (String::from("Accepted"), 202),
ReposGetCodeFrequencyStatsError::Status204 => (String::from("A header with no content is returned."), 204),
ReposGetCodeFrequencyStatsError::Status422 => (String::from("Repository contains more than 10,000 commits"), 422),
ReposGetCodeFrequencyStatsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get repository permissions for a user](Repos::get_collaborator_permission_level_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetCollaboratorPermissionLevelError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetCollaboratorPermissionLevelError> for AdapterError {
fn from(err: ReposGetCollaboratorPermissionLevelError) -> Self {
let (description, status_code) = match err {
ReposGetCollaboratorPermissionLevelError::Status404(_) => (String::from("Resource not found"), 404),
ReposGetCollaboratorPermissionLevelError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get the combined status for a specific reference](Repos::get_combined_status_for_ref_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetCombinedStatusForRefError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetCombinedStatusForRefError> for AdapterError {
fn from(err: ReposGetCombinedStatusForRefError) -> Self {
let (description, status_code) = match err {
ReposGetCombinedStatusForRefError::Status404(_) => (String::from("Resource not found"), 404),
ReposGetCombinedStatusForRefError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get a commit](Repos::get_commit_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetCommitError {
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Resource not found")]
Status404(BasicError),
#[error("Internal Error")]
Status500(BasicError),
#[error("Service unavailable")]
Status503(GetBillingGetGithubBillingUsageReportUserResponse503),
#[error("Conflict")]
Status409(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetCommitError> for AdapterError {
fn from(err: ReposGetCommitError) -> Self {
let (description, status_code) = match err {
ReposGetCommitError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposGetCommitError::Status404(_) => (String::from("Resource not found"), 404),
ReposGetCommitError::Status500(_) => (String::from("Internal Error"), 500),
ReposGetCommitError::Status503(_) => (String::from("Service unavailable"), 503),
ReposGetCommitError::Status409(_) => (String::from("Conflict"), 409),
ReposGetCommitError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get the last year of commit activity](Repos::get_commit_activity_stats_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetCommitActivityStatsError {
#[error("Accepted")]
Status202(HashMap<String, Value>),
#[error("A header with no content is returned.")]
Status204,
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetCommitActivityStatsError> for AdapterError {
fn from(err: ReposGetCommitActivityStatsError) -> Self {
let (description, status_code) = match err {
ReposGetCommitActivityStatsError::Status202(_) => (String::from("Accepted"), 202),
ReposGetCommitActivityStatsError::Status204 => (String::from("A header with no content is returned."), 204),
ReposGetCommitActivityStatsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get a commit comment](Repos::get_commit_comment_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetCommitCommentError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetCommitCommentError> for AdapterError {
fn from(err: ReposGetCommitCommentError) -> Self {
let (description, status_code) = match err {
ReposGetCommitCommentError::Status404(_) => (String::from("Resource not found"), 404),
ReposGetCommitCommentError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get commit signature protection](Repos::get_commit_signature_protection_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetCommitSignatureProtectionError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetCommitSignatureProtectionError> for AdapterError {
fn from(err: ReposGetCommitSignatureProtectionError) -> Self {
let (description, status_code) = match err {
ReposGetCommitSignatureProtectionError::Status404(_) => (String::from("Resource not found"), 404),
ReposGetCommitSignatureProtectionError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get community profile metrics](Repos::get_community_profile_metrics_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetCommunityProfileMetricsError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetCommunityProfileMetricsError> for AdapterError {
fn from(err: ReposGetCommunityProfileMetricsError) -> Self {
let (description, status_code) = match err {
ReposGetCommunityProfileMetricsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get repository content](Repos::get_content_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetContentError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Found")]
Status302,
#[error("Not modified")]
Status304,
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetContentError> for AdapterError {
fn from(err: ReposGetContentError) -> Self {
let (description, status_code) = match err {
ReposGetContentError::Status404(_) => (String::from("Resource not found"), 404),
ReposGetContentError::Status403(_) => (String::from("Forbidden"), 403),
ReposGetContentError::Status302 => (String::from("Found"), 302),
ReposGetContentError::Status304 => (String::from("Not modified"), 304),
ReposGetContentError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get all contributor commit activity](Repos::get_contributors_stats_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetContributorsStatsError {
#[error("Accepted")]
Status202(HashMap<String, Value>),
#[error("A header with no content is returned.")]
Status204,
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetContributorsStatsError> for AdapterError {
fn from(err: ReposGetContributorsStatsError) -> Self {
let (description, status_code) = match err {
ReposGetContributorsStatsError::Status202(_) => (String::from("Accepted"), 202),
ReposGetContributorsStatsError::Status204 => (String::from("A header with no content is returned."), 204),
ReposGetContributorsStatsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get a custom deployment protection rule](Repos::get_custom_deployment_protection_rule_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetCustomDeploymentProtectionRuleError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetCustomDeploymentProtectionRuleError> for AdapterError {
fn from(err: ReposGetCustomDeploymentProtectionRuleError) -> Self {
let (description, status_code) = match err {
ReposGetCustomDeploymentProtectionRuleError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get all custom property values for a repository](Repos::get_custom_properties_values_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetCustomPropertiesValuesError {
#[error("Forbidden")]
Status403(BasicError),
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetCustomPropertiesValuesError> for AdapterError {
fn from(err: ReposGetCustomPropertiesValuesError) -> Self {
let (description, status_code) = match err {
ReposGetCustomPropertiesValuesError::Status403(_) => (String::from("Forbidden"), 403),
ReposGetCustomPropertiesValuesError::Status404(_) => (String::from("Resource not found"), 404),
ReposGetCustomPropertiesValuesError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get a deploy key](Repos::get_deploy_key_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetDeployKeyError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetDeployKeyError> for AdapterError {
fn from(err: ReposGetDeployKeyError) -> Self {
let (description, status_code) = match err {
ReposGetDeployKeyError::Status404(_) => (String::from("Resource not found"), 404),
ReposGetDeployKeyError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get a deployment](Repos::get_deployment_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetDeploymentError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetDeploymentError> for AdapterError {
fn from(err: ReposGetDeploymentError) -> Self {
let (description, status_code) = match err {
ReposGetDeploymentError::Status404(_) => (String::from("Resource not found"), 404),
ReposGetDeploymentError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get a deployment branch policy](Repos::get_deployment_branch_policy_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetDeploymentBranchPolicyError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetDeploymentBranchPolicyError> for AdapterError {
fn from(err: ReposGetDeploymentBranchPolicyError) -> Self {
let (description, status_code) = match err {
ReposGetDeploymentBranchPolicyError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get a deployment status](Repos::get_deployment_status_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetDeploymentStatusError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetDeploymentStatusError> for AdapterError {
fn from(err: ReposGetDeploymentStatusError) -> Self {
let (description, status_code) = match err {
ReposGetDeploymentStatusError::Status404(_) => (String::from("Resource not found"), 404),
ReposGetDeploymentStatusError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get an environment](Repos::get_environment_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetEnvironmentError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetEnvironmentError> for AdapterError {
fn from(err: ReposGetEnvironmentError) -> Self {
let (description, status_code) = match err {
ReposGetEnvironmentError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get latest Pages build](Repos::get_latest_pages_build_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetLatestPagesBuildError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetLatestPagesBuildError> for AdapterError {
fn from(err: ReposGetLatestPagesBuildError) -> Self {
let (description, status_code) = match err {
ReposGetLatestPagesBuildError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get the latest release](Repos::get_latest_release_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetLatestReleaseError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetLatestReleaseError> for AdapterError {
fn from(err: ReposGetLatestReleaseError) -> Self {
let (description, status_code) = match err {
ReposGetLatestReleaseError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get an organization rule suite](Repos::get_org_rule_suite_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetOrgRuleSuiteError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Internal Error")]
Status500(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetOrgRuleSuiteError> for AdapterError {
fn from(err: ReposGetOrgRuleSuiteError) -> Self {
let (description, status_code) = match err {
ReposGetOrgRuleSuiteError::Status404(_) => (String::from("Resource not found"), 404),
ReposGetOrgRuleSuiteError::Status500(_) => (String::from("Internal Error"), 500),
ReposGetOrgRuleSuiteError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List organization rule suites](Repos::get_org_rule_suites_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetOrgRuleSuitesError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Internal Error")]
Status500(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetOrgRuleSuitesError> for AdapterError {
fn from(err: ReposGetOrgRuleSuitesError) -> Self {
let (description, status_code) = match err {
ReposGetOrgRuleSuitesError::Status404(_) => (String::from("Resource not found"), 404),
ReposGetOrgRuleSuitesError::Status500(_) => (String::from("Internal Error"), 500),
ReposGetOrgRuleSuitesError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get an organization repository ruleset](Repos::get_org_ruleset_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetOrgRulesetError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Internal Error")]
Status500(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetOrgRulesetError> for AdapterError {
fn from(err: ReposGetOrgRulesetError) -> Self {
let (description, status_code) = match err {
ReposGetOrgRulesetError::Status404(_) => (String::from("Resource not found"), 404),
ReposGetOrgRulesetError::Status500(_) => (String::from("Internal Error"), 500),
ReposGetOrgRulesetError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get all organization repository rulesets](Repos::get_org_rulesets_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetOrgRulesetsError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Internal Error")]
Status500(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetOrgRulesetsError> for AdapterError {
fn from(err: ReposGetOrgRulesetsError) -> Self {
let (description, status_code) = match err {
ReposGetOrgRulesetsError::Status404(_) => (String::from("Resource not found"), 404),
ReposGetOrgRulesetsError::Status500(_) => (String::from("Internal Error"), 500),
ReposGetOrgRulesetsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get a GitHub Pages site](Repos::get_pages_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetPagesError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetPagesError> for AdapterError {
fn from(err: ReposGetPagesError) -> Self {
let (description, status_code) = match err {
ReposGetPagesError::Status404(_) => (String::from("Resource not found"), 404),
ReposGetPagesError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get GitHub Pages build](Repos::get_pages_build_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetPagesBuildError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetPagesBuildError> for AdapterError {
fn from(err: ReposGetPagesBuildError) -> Self {
let (description, status_code) = match err {
ReposGetPagesBuildError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get the status of a GitHub Pages deployment](Repos::get_pages_deployment_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetPagesDeploymentError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetPagesDeploymentError> for AdapterError {
fn from(err: ReposGetPagesDeploymentError) -> Self {
let (description, status_code) = match err {
ReposGetPagesDeploymentError::Status404(_) => (String::from("Resource not found"), 404),
ReposGetPagesDeploymentError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get a DNS health check for GitHub Pages](Repos::get_pages_health_check_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetPagesHealthCheckError {
#[error("Empty response")]
Status202(EmptyObject),
#[error("Custom domains are not available for GitHub Pages")]
Status400,
#[error("There isn't a CNAME for this page")]
Status422,
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetPagesHealthCheckError> for AdapterError {
fn from(err: ReposGetPagesHealthCheckError) -> Self {
let (description, status_code) = match err {
ReposGetPagesHealthCheckError::Status202(_) => (String::from("Empty response"), 202),
ReposGetPagesHealthCheckError::Status400 => (String::from("Custom domains are not available for GitHub Pages"), 400),
ReposGetPagesHealthCheckError::Status422 => (String::from("There isn't a CNAME for this page"), 422),
ReposGetPagesHealthCheckError::Status404(_) => (String::from("Resource not found"), 404),
ReposGetPagesHealthCheckError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get the weekly commit count](Repos::get_participation_stats_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetParticipationStatsError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetParticipationStatsError> for AdapterError {
fn from(err: ReposGetParticipationStatsError) -> Self {
let (description, status_code) = match err {
ReposGetParticipationStatsError::Status404(_) => (String::from("Resource not found"), 404),
ReposGetParticipationStatsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get pull request review protection](Repos::get_pull_request_review_protection_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetPullRequestReviewProtectionError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetPullRequestReviewProtectionError> for AdapterError {
fn from(err: ReposGetPullRequestReviewProtectionError) -> Self {
let (description, status_code) = match err {
ReposGetPullRequestReviewProtectionError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get the hourly commit count for each day](Repos::get_punch_card_stats_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetPunchCardStatsError {
#[error("A header with no content is returned.")]
Status204,
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetPunchCardStatsError> for AdapterError {
fn from(err: ReposGetPunchCardStatsError) -> Self {
let (description, status_code) = match err {
ReposGetPunchCardStatsError::Status204 => (String::from("A header with no content is returned."), 204),
ReposGetPunchCardStatsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get a repository README](Repos::get_readme_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetReadmeError {
#[error("Not modified")]
Status304,
#[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<ReposGetReadmeError> for AdapterError {
fn from(err: ReposGetReadmeError) -> Self {
let (description, status_code) = match err {
ReposGetReadmeError::Status304 => (String::from("Not modified"), 304),
ReposGetReadmeError::Status404(_) => (String::from("Resource not found"), 404),
ReposGetReadmeError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposGetReadmeError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get a repository README for a directory](Repos::get_readme_in_directory_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetReadmeInDirectoryError {
#[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<ReposGetReadmeInDirectoryError> for AdapterError {
fn from(err: ReposGetReadmeInDirectoryError) -> Self {
let (description, status_code) = match err {
ReposGetReadmeInDirectoryError::Status404(_) => (String::from("Resource not found"), 404),
ReposGetReadmeInDirectoryError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposGetReadmeInDirectoryError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get a release](Repos::get_release_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetReleaseError {
#[error("Unauthorized")]
Status401,
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetReleaseError> for AdapterError {
fn from(err: ReposGetReleaseError) -> Self {
let (description, status_code) = match err {
ReposGetReleaseError::Status401 => (String::from("Unauthorized"), 401),
ReposGetReleaseError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get a release asset](Repos::get_release_asset_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetReleaseAssetError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Found")]
Status302,
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetReleaseAssetError> for AdapterError {
fn from(err: ReposGetReleaseAssetError) -> Self {
let (description, status_code) = match err {
ReposGetReleaseAssetError::Status404(_) => (String::from("Resource not found"), 404),
ReposGetReleaseAssetError::Status302 => (String::from("Found"), 302),
ReposGetReleaseAssetError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get a release by tag name](Repos::get_release_by_tag_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetReleaseByTagError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetReleaseByTagError> for AdapterError {
fn from(err: ReposGetReleaseByTagError) -> Self {
let (description, status_code) = match err {
ReposGetReleaseByTagError::Status404(_) => (String::from("Resource not found"), 404),
ReposGetReleaseByTagError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get a repository rule suite](Repos::get_repo_rule_suite_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetRepoRuleSuiteError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Internal Error")]
Status500(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetRepoRuleSuiteError> for AdapterError {
fn from(err: ReposGetRepoRuleSuiteError) -> Self {
let (description, status_code) = match err {
ReposGetRepoRuleSuiteError::Status404(_) => (String::from("Resource not found"), 404),
ReposGetRepoRuleSuiteError::Status500(_) => (String::from("Internal Error"), 500),
ReposGetRepoRuleSuiteError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List repository rule suites](Repos::get_repo_rule_suites_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetRepoRuleSuitesError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Internal Error")]
Status500(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetRepoRuleSuitesError> for AdapterError {
fn from(err: ReposGetRepoRuleSuitesError) -> Self {
let (description, status_code) = match err {
ReposGetRepoRuleSuitesError::Status404(_) => (String::from("Resource not found"), 404),
ReposGetRepoRuleSuitesError::Status500(_) => (String::from("Internal Error"), 500),
ReposGetRepoRuleSuitesError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get a repository ruleset](Repos::get_repo_ruleset_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetRepoRulesetError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Internal Error")]
Status500(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetRepoRulesetError> for AdapterError {
fn from(err: ReposGetRepoRulesetError) -> Self {
let (description, status_code) = match err {
ReposGetRepoRulesetError::Status404(_) => (String::from("Resource not found"), 404),
ReposGetRepoRulesetError::Status500(_) => (String::from("Internal Error"), 500),
ReposGetRepoRulesetError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get repository ruleset history](Repos::get_repo_ruleset_history_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetRepoRulesetHistoryError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Internal Error")]
Status500(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetRepoRulesetHistoryError> for AdapterError {
fn from(err: ReposGetRepoRulesetHistoryError) -> Self {
let (description, status_code) = match err {
ReposGetRepoRulesetHistoryError::Status404(_) => (String::from("Resource not found"), 404),
ReposGetRepoRulesetHistoryError::Status500(_) => (String::from("Internal Error"), 500),
ReposGetRepoRulesetHistoryError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get repository ruleset version](Repos::get_repo_ruleset_version_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetRepoRulesetVersionError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Internal Error")]
Status500(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetRepoRulesetVersionError> for AdapterError {
fn from(err: ReposGetRepoRulesetVersionError) -> Self {
let (description, status_code) = match err {
ReposGetRepoRulesetVersionError::Status404(_) => (String::from("Resource not found"), 404),
ReposGetRepoRulesetVersionError::Status500(_) => (String::from("Internal Error"), 500),
ReposGetRepoRulesetVersionError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get all repository rulesets](Repos::get_repo_rulesets_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetRepoRulesetsError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Internal Error")]
Status500(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetRepoRulesetsError> for AdapterError {
fn from(err: ReposGetRepoRulesetsError) -> Self {
let (description, status_code) = match err {
ReposGetRepoRulesetsError::Status404(_) => (String::from("Resource not found"), 404),
ReposGetRepoRulesetsError::Status500(_) => (String::from("Internal Error"), 500),
ReposGetRepoRulesetsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get status checks protection](Repos::get_status_checks_protection_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetStatusChecksProtectionError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetStatusChecksProtectionError> for AdapterError {
fn from(err: ReposGetStatusChecksProtectionError) -> Self {
let (description, status_code) = match err {
ReposGetStatusChecksProtectionError::Status404(_) => (String::from("Resource not found"), 404),
ReposGetStatusChecksProtectionError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get teams with access to the protected branch](Repos::get_teams_with_access_to_protected_branch_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetTeamsWithAccessToProtectedBranchError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetTeamsWithAccessToProtectedBranchError> for AdapterError {
fn from(err: ReposGetTeamsWithAccessToProtectedBranchError) -> Self {
let (description, status_code) = match err {
ReposGetTeamsWithAccessToProtectedBranchError::Status404(_) => (String::from("Resource not found"), 404),
ReposGetTeamsWithAccessToProtectedBranchError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get top referral paths](Repos::get_top_paths_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetTopPathsError {
#[error("Forbidden")]
Status403(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetTopPathsError> for AdapterError {
fn from(err: ReposGetTopPathsError) -> Self {
let (description, status_code) = match err {
ReposGetTopPathsError::Status403(_) => (String::from("Forbidden"), 403),
ReposGetTopPathsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get top referral sources](Repos::get_top_referrers_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetTopReferrersError {
#[error("Forbidden")]
Status403(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetTopReferrersError> for AdapterError {
fn from(err: ReposGetTopReferrersError) -> Self {
let (description, status_code) = match err {
ReposGetTopReferrersError::Status403(_) => (String::from("Forbidden"), 403),
ReposGetTopReferrersError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get users with access to the protected branch](Repos::get_users_with_access_to_protected_branch_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetUsersWithAccessToProtectedBranchError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetUsersWithAccessToProtectedBranchError> for AdapterError {
fn from(err: ReposGetUsersWithAccessToProtectedBranchError) -> Self {
let (description, status_code) = match err {
ReposGetUsersWithAccessToProtectedBranchError::Status404(_) => (String::from("Resource not found"), 404),
ReposGetUsersWithAccessToProtectedBranchError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get page views](Repos::get_views_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetViewsError {
#[error("Forbidden")]
Status403(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetViewsError> for AdapterError {
fn from(err: ReposGetViewsError) -> Self {
let (description, status_code) = match err {
ReposGetViewsError::Status403(_) => (String::from("Forbidden"), 403),
ReposGetViewsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get a repository webhook](Repos::get_webhook_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetWebhookError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetWebhookError> for AdapterError {
fn from(err: ReposGetWebhookError) -> Self {
let (description, status_code) = match err {
ReposGetWebhookError::Status404(_) => (String::from("Resource not found"), 404),
ReposGetWebhookError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get a webhook configuration for a repository](Repos::get_webhook_config_for_repo_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetWebhookConfigForRepoError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposGetWebhookConfigForRepoError> for AdapterError {
fn from(err: ReposGetWebhookConfigForRepoError) -> Self {
let (description, status_code) = match err {
ReposGetWebhookConfigForRepoError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get a delivery for a repository webhook](Repos::get_webhook_delivery_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposGetWebhookDeliveryError {
#[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<ReposGetWebhookDeliveryError> for AdapterError {
fn from(err: ReposGetWebhookDeliveryError) -> Self {
let (description, status_code) = match err {
ReposGetWebhookDeliveryError::Status400(_) => (String::from("Bad Request"), 400),
ReposGetWebhookDeliveryError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposGetWebhookDeliveryError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List repository activities](Repos::list_activities_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposListActivitiesError {
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationErrorSimple),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposListActivitiesError> for AdapterError {
fn from(err: ReposListActivitiesError) -> Self {
let (description, status_code) = match err {
ReposListActivitiesError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposListActivitiesError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List attestations](Repos::list_attestations_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposListAttestationsError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposListAttestationsError> for AdapterError {
fn from(err: ReposListAttestationsError) -> Self {
let (description, status_code) = match err {
ReposListAttestationsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get all autolinks of a repository](Repos::list_autolinks_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposListAutolinksError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposListAutolinksError> for AdapterError {
fn from(err: ReposListAutolinksError) -> Self {
let (description, status_code) = match err {
ReposListAutolinksError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List branches](Repos::list_branches_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposListBranchesError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposListBranchesError> for AdapterError {
fn from(err: ReposListBranchesError) -> Self {
let (description, status_code) = match err {
ReposListBranchesError::Status404(_) => (String::from("Resource not found"), 404),
ReposListBranchesError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List branches for HEAD commit](Repos::list_branches_for_head_commit_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposListBranchesForHeadCommitError {
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Conflict")]
Status409(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposListBranchesForHeadCommitError> for AdapterError {
fn from(err: ReposListBranchesForHeadCommitError) -> Self {
let (description, status_code) = match err {
ReposListBranchesForHeadCommitError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposListBranchesForHeadCommitError::Status409(_) => (String::from("Conflict"), 409),
ReposListBranchesForHeadCommitError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List repository collaborators](Repos::list_collaborators_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposListCollaboratorsError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposListCollaboratorsError> for AdapterError {
fn from(err: ReposListCollaboratorsError) -> Self {
let (description, status_code) = match err {
ReposListCollaboratorsError::Status404(_) => (String::from("Resource not found"), 404),
ReposListCollaboratorsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List commit comments](Repos::list_comments_for_commit_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposListCommentsForCommitError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposListCommentsForCommitError> for AdapterError {
fn from(err: ReposListCommentsForCommitError) -> Self {
let (description, status_code) = match err {
ReposListCommentsForCommitError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List commit comments for a repository](Repos::list_commit_comments_for_repo_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposListCommitCommentsForRepoError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposListCommitCommentsForRepoError> for AdapterError {
fn from(err: ReposListCommitCommentsForRepoError) -> Self {
let (description, status_code) = match err {
ReposListCommitCommentsForRepoError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List commit statuses for a reference](Repos::list_commit_statuses_for_ref_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposListCommitStatusesForRefError {
#[error("Moved permanently")]
Status301(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposListCommitStatusesForRefError> for AdapterError {
fn from(err: ReposListCommitStatusesForRefError) -> Self {
let (description, status_code) = match err {
ReposListCommitStatusesForRefError::Status301(_) => (String::from("Moved permanently"), 301),
ReposListCommitStatusesForRefError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List commits](Repos::list_commits_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposListCommitsError {
#[error("Internal Error")]
Status500(BasicError),
#[error("Bad Request")]
Status400(BasicError),
#[error("Resource not found")]
Status404(BasicError),
#[error("Conflict")]
Status409(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposListCommitsError> for AdapterError {
fn from(err: ReposListCommitsError) -> Self {
let (description, status_code) = match err {
ReposListCommitsError::Status500(_) => (String::from("Internal Error"), 500),
ReposListCommitsError::Status400(_) => (String::from("Bad Request"), 400),
ReposListCommitsError::Status404(_) => (String::from("Resource not found"), 404),
ReposListCommitsError::Status409(_) => (String::from("Conflict"), 409),
ReposListCommitsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List repository contributors](Repos::list_contributors_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposListContributorsError {
#[error("Response if repository is empty")]
Status204,
#[error("Forbidden")]
Status403(BasicError),
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposListContributorsError> for AdapterError {
fn from(err: ReposListContributorsError) -> Self {
let (description, status_code) = match err {
ReposListContributorsError::Status204 => (String::from("Response if repository is empty"), 204),
ReposListContributorsError::Status403(_) => (String::from("Forbidden"), 403),
ReposListContributorsError::Status404(_) => (String::from("Resource not found"), 404),
ReposListContributorsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List custom deployment rule integrations available for an environment](Repos::list_custom_deployment_rule_integrations_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposListCustomDeploymentRuleIntegrationsError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposListCustomDeploymentRuleIntegrationsError> for AdapterError {
fn from(err: ReposListCustomDeploymentRuleIntegrationsError) -> Self {
let (description, status_code) = match err {
ReposListCustomDeploymentRuleIntegrationsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List deploy keys](Repos::list_deploy_keys_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposListDeployKeysError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposListDeployKeysError> for AdapterError {
fn from(err: ReposListDeployKeysError) -> Self {
let (description, status_code) = match err {
ReposListDeployKeysError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List deployment branch policies](Repos::list_deployment_branch_policies_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposListDeploymentBranchPoliciesError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposListDeploymentBranchPoliciesError> for AdapterError {
fn from(err: ReposListDeploymentBranchPoliciesError) -> Self {
let (description, status_code) = match err {
ReposListDeploymentBranchPoliciesError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List deployment statuses](Repos::list_deployment_statuses_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposListDeploymentStatusesError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposListDeploymentStatusesError> for AdapterError {
fn from(err: ReposListDeploymentStatusesError) -> Self {
let (description, status_code) = match err {
ReposListDeploymentStatusesError::Status404(_) => (String::from("Resource not found"), 404),
ReposListDeploymentStatusesError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List deployments](Repos::list_deployments_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposListDeploymentsError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposListDeploymentsError> for AdapterError {
fn from(err: ReposListDeploymentsError) -> Self {
let (description, status_code) = match err {
ReposListDeploymentsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List repositories for the authenticated user](Repos::list_for_authenticated_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposListForAuthenticatedUserError {
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Not modified")]
Status304,
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposListForAuthenticatedUserError> for AdapterError {
fn from(err: ReposListForAuthenticatedUserError) -> Self {
let (description, status_code) = match err {
ReposListForAuthenticatedUserError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposListForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304),
ReposListForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403),
ReposListForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401),
ReposListForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List organization repositories](Repos::list_for_org_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposListForOrgError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposListForOrgError> for AdapterError {
fn from(err: ReposListForOrgError) -> Self {
let (description, status_code) = match err {
ReposListForOrgError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List repositories for a user](Repos::list_for_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposListForUserError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposListForUserError> for AdapterError {
fn from(err: ReposListForUserError) -> Self {
let (description, status_code) = match err {
ReposListForUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List forks](Repos::list_forks_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposListForksError {
#[error("Bad Request")]
Status400(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposListForksError> for AdapterError {
fn from(err: ReposListForksError) -> Self {
let (description, status_code) = match err {
ReposListForksError::Status400(_) => (String::from("Bad Request"), 400),
ReposListForksError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List repository invitations](Repos::list_invitations_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposListInvitationsError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposListInvitationsError> for AdapterError {
fn from(err: ReposListInvitationsError) -> Self {
let (description, status_code) = match err {
ReposListInvitationsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List repository invitations for the authenticated user](Repos::list_invitations_for_authenticated_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposListInvitationsForAuthenticatedUserError {
#[error("Not modified")]
Status304,
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposListInvitationsForAuthenticatedUserError> for AdapterError {
fn from(err: ReposListInvitationsForAuthenticatedUserError) -> Self {
let (description, status_code) = match err {
ReposListInvitationsForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304),
ReposListInvitationsForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404),
ReposListInvitationsForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403),
ReposListInvitationsForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401),
ReposListInvitationsForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List repository languages](Repos::list_languages_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposListLanguagesError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposListLanguagesError> for AdapterError {
fn from(err: ReposListLanguagesError) -> Self {
let (description, status_code) = match err {
ReposListLanguagesError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List GitHub Pages builds](Repos::list_pages_builds_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposListPagesBuildsError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposListPagesBuildsError> for AdapterError {
fn from(err: ReposListPagesBuildsError) -> Self {
let (description, status_code) = match err {
ReposListPagesBuildsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List public repositories](Repos::list_public_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposListPublicError {
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Not modified")]
Status304,
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposListPublicError> for AdapterError {
fn from(err: ReposListPublicError) -> Self {
let (description, status_code) = match err {
ReposListPublicError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposListPublicError::Status304 => (String::from("Not modified"), 304),
ReposListPublicError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List pull requests associated with a commit](Repos::list_pull_requests_associated_with_commit_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposListPullRequestsAssociatedWithCommitError {
#[error("Conflict")]
Status409(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposListPullRequestsAssociatedWithCommitError> for AdapterError {
fn from(err: ReposListPullRequestsAssociatedWithCommitError) -> Self {
let (description, status_code) = match err {
ReposListPullRequestsAssociatedWithCommitError::Status409(_) => (String::from("Conflict"), 409),
ReposListPullRequestsAssociatedWithCommitError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List release assets](Repos::list_release_assets_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposListReleaseAssetsError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposListReleaseAssetsError> for AdapterError {
fn from(err: ReposListReleaseAssetsError) -> Self {
let (description, status_code) = match err {
ReposListReleaseAssetsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List releases](Repos::list_releases_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposListReleasesError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposListReleasesError> for AdapterError {
fn from(err: ReposListReleasesError) -> Self {
let (description, status_code) = match err {
ReposListReleasesError::Status404(_) => (String::from("Resource not found"), 404),
ReposListReleasesError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Closing down - List tag protection states for a repository](Repos::list_tag_protection_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposListTagProtectionError {
#[error("Forbidden")]
Status403(BasicError),
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposListTagProtectionError> for AdapterError {
fn from(err: ReposListTagProtectionError) -> Self {
let (description, status_code) = match err {
ReposListTagProtectionError::Status403(_) => (String::from("Forbidden"), 403),
ReposListTagProtectionError::Status404(_) => (String::from("Resource not found"), 404),
ReposListTagProtectionError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List repository tags](Repos::list_tags_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposListTagsError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposListTagsError> for AdapterError {
fn from(err: ReposListTagsError) -> Self {
let (description, status_code) = match err {
ReposListTagsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List repository teams](Repos::list_teams_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposListTeamsError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposListTeamsError> for AdapterError {
fn from(err: ReposListTeamsError) -> Self {
let (description, status_code) = match err {
ReposListTeamsError::Status404(_) => (String::from("Resource not found"), 404),
ReposListTeamsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List deliveries for a repository webhook](Repos::list_webhook_deliveries_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposListWebhookDeliveriesError {
#[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<ReposListWebhookDeliveriesError> for AdapterError {
fn from(err: ReposListWebhookDeliveriesError) -> Self {
let (description, status_code) = match err {
ReposListWebhookDeliveriesError::Status400(_) => (String::from("Bad Request"), 400),
ReposListWebhookDeliveriesError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposListWebhookDeliveriesError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List repository webhooks](Repos::list_webhooks_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposListWebhooksError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposListWebhooksError> for AdapterError {
fn from(err: ReposListWebhooksError) -> Self {
let (description, status_code) = match err {
ReposListWebhooksError::Status404(_) => (String::from("Resource not found"), 404),
ReposListWebhooksError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Merge a branch](Repos::merge_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposMergeError {
#[error("Response when already merged")]
Status204,
#[error("Not Found when the base or head does not exist")]
Status404,
#[error("Conflict when there is a merge conflict")]
Status409,
#[error("Forbidden")]
Status403(BasicError),
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposMergeError> for AdapterError {
fn from(err: ReposMergeError) -> Self {
let (description, status_code) = match err {
ReposMergeError::Status204 => (String::from("Response when already merged"), 204),
ReposMergeError::Status404 => (String::from("Not Found when the base or head does not exist"), 404),
ReposMergeError::Status409 => (String::from("Conflict when there is a merge conflict"), 409),
ReposMergeError::Status403(_) => (String::from("Forbidden"), 403),
ReposMergeError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposMergeError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Sync a fork branch with the upstream repository](Repos::merge_upstream_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposMergeUpstreamError {
#[error("The branch could not be synced because of a merge conflict")]
Status409,
#[error("The branch could not be synced for some other reason")]
Status422,
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposMergeUpstreamError> for AdapterError {
fn from(err: ReposMergeUpstreamError) -> Self {
let (description, status_code) = match err {
ReposMergeUpstreamError::Status409 => (String::from("The branch could not be synced because of a merge conflict"), 409),
ReposMergeUpstreamError::Status422 => (String::from("The branch could not be synced for some other reason"), 422),
ReposMergeUpstreamError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Ping a repository webhook](Repos::ping_webhook_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposPingWebhookError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposPingWebhookError> for AdapterError {
fn from(err: ReposPingWebhookError) -> Self {
let (description, status_code) = match err {
ReposPingWebhookError::Status404(_) => (String::from("Resource not found"), 404),
ReposPingWebhookError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Redeliver a delivery for a repository webhook](Repos::redeliver_webhook_delivery_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposRedeliverWebhookDeliveryError {
#[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<ReposRedeliverWebhookDeliveryError> for AdapterError {
fn from(err: ReposRedeliverWebhookDeliveryError) -> Self {
let (description, status_code) = match err {
ReposRedeliverWebhookDeliveryError::Status400(_) => (String::from("Bad Request"), 400),
ReposRedeliverWebhookDeliveryError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposRedeliverWebhookDeliveryError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Remove app access restrictions](Repos::remove_app_access_restrictions_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposRemoveAppAccessRestrictionsError {
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposRemoveAppAccessRestrictionsError> for AdapterError {
fn from(err: ReposRemoveAppAccessRestrictionsError) -> Self {
let (description, status_code) = match err {
ReposRemoveAppAccessRestrictionsError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposRemoveAppAccessRestrictionsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Remove a repository collaborator](Repos::remove_collaborator_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposRemoveCollaboratorError {
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposRemoveCollaboratorError> for AdapterError {
fn from(err: ReposRemoveCollaboratorError) -> Self {
let (description, status_code) = match err {
ReposRemoveCollaboratorError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposRemoveCollaboratorError::Status403(_) => (String::from("Forbidden"), 403),
ReposRemoveCollaboratorError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Remove status check contexts](Repos::remove_status_check_contexts_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposRemoveStatusCheckContextsError {
#[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<ReposRemoveStatusCheckContextsError> for AdapterError {
fn from(err: ReposRemoveStatusCheckContextsError) -> Self {
let (description, status_code) = match err {
ReposRemoveStatusCheckContextsError::Status404(_) => (String::from("Resource not found"), 404),
ReposRemoveStatusCheckContextsError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposRemoveStatusCheckContextsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Remove status check protection](Repos::remove_status_check_protection_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposRemoveStatusCheckProtectionError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposRemoveStatusCheckProtectionError> for AdapterError {
fn from(err: ReposRemoveStatusCheckProtectionError) -> Self {
let (description, status_code) = match err {
ReposRemoveStatusCheckProtectionError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Remove team access restrictions](Repos::remove_team_access_restrictions_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposRemoveTeamAccessRestrictionsError {
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposRemoveTeamAccessRestrictionsError> for AdapterError {
fn from(err: ReposRemoveTeamAccessRestrictionsError) -> Self {
let (description, status_code) = match err {
ReposRemoveTeamAccessRestrictionsError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposRemoveTeamAccessRestrictionsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Remove user access restrictions](Repos::remove_user_access_restrictions_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposRemoveUserAccessRestrictionsError {
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposRemoveUserAccessRestrictionsError> for AdapterError {
fn from(err: ReposRemoveUserAccessRestrictionsError) -> Self {
let (description, status_code) = match err {
ReposRemoveUserAccessRestrictionsError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposRemoveUserAccessRestrictionsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Rename a branch](Repos::rename_branch_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposRenameBranchError {
#[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<ReposRenameBranchError> for AdapterError {
fn from(err: ReposRenameBranchError) -> Self {
let (description, status_code) = match err {
ReposRenameBranchError::Status403(_) => (String::from("Forbidden"), 403),
ReposRenameBranchError::Status404(_) => (String::from("Resource not found"), 404),
ReposRenameBranchError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposRenameBranchError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Replace all repository topics](Repos::replace_all_topics_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposReplaceAllTopicsError {
#[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<ReposReplaceAllTopicsError> for AdapterError {
fn from(err: ReposReplaceAllTopicsError) -> Self {
let (description, status_code) = match err {
ReposReplaceAllTopicsError::Status404(_) => (String::from("Resource not found"), 404),
ReposReplaceAllTopicsError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposReplaceAllTopicsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Request a GitHub Pages build](Repos::request_pages_build_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposRequestPagesBuildError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposRequestPagesBuildError> for AdapterError {
fn from(err: ReposRequestPagesBuildError) -> Self {
let (description, status_code) = match err {
ReposRequestPagesBuildError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Set admin branch protection](Repos::set_admin_branch_protection_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposSetAdminBranchProtectionError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposSetAdminBranchProtectionError> for AdapterError {
fn from(err: ReposSetAdminBranchProtectionError) -> Self {
let (description, status_code) = match err {
ReposSetAdminBranchProtectionError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Set app access restrictions](Repos::set_app_access_restrictions_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposSetAppAccessRestrictionsError {
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposSetAppAccessRestrictionsError> for AdapterError {
fn from(err: ReposSetAppAccessRestrictionsError) -> Self {
let (description, status_code) = match err {
ReposSetAppAccessRestrictionsError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposSetAppAccessRestrictionsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Set status check contexts](Repos::set_status_check_contexts_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposSetStatusCheckContextsError {
#[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<ReposSetStatusCheckContextsError> for AdapterError {
fn from(err: ReposSetStatusCheckContextsError) -> Self {
let (description, status_code) = match err {
ReposSetStatusCheckContextsError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposSetStatusCheckContextsError::Status404(_) => (String::from("Resource not found"), 404),
ReposSetStatusCheckContextsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Set team access restrictions](Repos::set_team_access_restrictions_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposSetTeamAccessRestrictionsError {
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposSetTeamAccessRestrictionsError> for AdapterError {
fn from(err: ReposSetTeamAccessRestrictionsError) -> Self {
let (description, status_code) = match err {
ReposSetTeamAccessRestrictionsError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposSetTeamAccessRestrictionsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Set user access restrictions](Repos::set_user_access_restrictions_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposSetUserAccessRestrictionsError {
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposSetUserAccessRestrictionsError> for AdapterError {
fn from(err: ReposSetUserAccessRestrictionsError) -> Self {
let (description, status_code) = match err {
ReposSetUserAccessRestrictionsError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposSetUserAccessRestrictionsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Test the push repository webhook](Repos::test_push_webhook_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposTestPushWebhookError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposTestPushWebhookError> for AdapterError {
fn from(err: ReposTestPushWebhookError) -> Self {
let (description, status_code) = match err {
ReposTestPushWebhookError::Status404(_) => (String::from("Resource not found"), 404),
ReposTestPushWebhookError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Transfer a repository](Repos::transfer_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposTransferError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposTransferError> for AdapterError {
fn from(err: ReposTransferError) -> Self {
let (description, status_code) = match err {
ReposTransferError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Update a repository](Repos::update_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposUpdateError {
#[error("Temporary Redirect")]
Status307(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[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<ReposUpdateError> for AdapterError {
fn from(err: ReposUpdateError) -> Self {
let (description, status_code) = match err {
ReposUpdateError::Status307(_) => (String::from("Temporary Redirect"), 307),
ReposUpdateError::Status403(_) => (String::from("Forbidden"), 403),
ReposUpdateError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposUpdateError::Status404(_) => (String::from("Resource not found"), 404),
ReposUpdateError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Update branch protection](Repos::update_branch_protection_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposUpdateBranchProtectionError {
#[error("Forbidden")]
Status403(BasicError),
#[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<ReposUpdateBranchProtectionError> for AdapterError {
fn from(err: ReposUpdateBranchProtectionError) -> Self {
let (description, status_code) = match err {
ReposUpdateBranchProtectionError::Status403(_) => (String::from("Forbidden"), 403),
ReposUpdateBranchProtectionError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposUpdateBranchProtectionError::Status404(_) => (String::from("Resource not found"), 404),
ReposUpdateBranchProtectionError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Update a commit comment](Repos::update_commit_comment_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposUpdateCommitCommentError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposUpdateCommitCommentError> for AdapterError {
fn from(err: ReposUpdateCommitCommentError) -> Self {
let (description, status_code) = match err {
ReposUpdateCommitCommentError::Status404(_) => (String::from("Resource not found"), 404),
ReposUpdateCommitCommentError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Update a deployment branch policy](Repos::update_deployment_branch_policy_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposUpdateDeploymentBranchPolicyError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposUpdateDeploymentBranchPolicyError> for AdapterError {
fn from(err: ReposUpdateDeploymentBranchPolicyError) -> Self {
let (description, status_code) = match err {
ReposUpdateDeploymentBranchPolicyError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Update information about a GitHub Pages site](Repos::update_information_about_pages_site_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposUpdateInformationAboutPagesSiteError {
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Bad Request")]
Status400(BasicError),
#[error("Conflict")]
Status409(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposUpdateInformationAboutPagesSiteError> for AdapterError {
fn from(err: ReposUpdateInformationAboutPagesSiteError) -> Self {
let (description, status_code) = match err {
ReposUpdateInformationAboutPagesSiteError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposUpdateInformationAboutPagesSiteError::Status400(_) => (String::from("Bad Request"), 400),
ReposUpdateInformationAboutPagesSiteError::Status409(_) => (String::from("Conflict"), 409),
ReposUpdateInformationAboutPagesSiteError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Update a repository invitation](Repos::update_invitation_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposUpdateInvitationError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposUpdateInvitationError> for AdapterError {
fn from(err: ReposUpdateInvitationError) -> Self {
let (description, status_code) = match err {
ReposUpdateInvitationError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Update an organization repository ruleset](Repos::update_org_ruleset_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposUpdateOrgRulesetError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Internal Error")]
Status500(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposUpdateOrgRulesetError> for AdapterError {
fn from(err: ReposUpdateOrgRulesetError) -> Self {
let (description, status_code) = match err {
ReposUpdateOrgRulesetError::Status404(_) => (String::from("Resource not found"), 404),
ReposUpdateOrgRulesetError::Status500(_) => (String::from("Internal Error"), 500),
ReposUpdateOrgRulesetError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Update pull request review protection](Repos::update_pull_request_review_protection_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposUpdatePullRequestReviewProtectionError {
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposUpdatePullRequestReviewProtectionError> for AdapterError {
fn from(err: ReposUpdatePullRequestReviewProtectionError) -> Self {
let (description, status_code) = match err {
ReposUpdatePullRequestReviewProtectionError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposUpdatePullRequestReviewProtectionError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Update a release](Repos::update_release_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposUpdateReleaseError {
#[error("Not Found if the discussion category name is invalid")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposUpdateReleaseError> for AdapterError {
fn from(err: ReposUpdateReleaseError) -> Self {
let (description, status_code) = match err {
ReposUpdateReleaseError::Status404(_) => (String::from("Not Found if the discussion category name is invalid"), 404),
ReposUpdateReleaseError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Update a release asset](Repos::update_release_asset_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposUpdateReleaseAssetError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposUpdateReleaseAssetError> for AdapterError {
fn from(err: ReposUpdateReleaseAssetError) -> Self {
let (description, status_code) = match err {
ReposUpdateReleaseAssetError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Update a repository ruleset](Repos::update_repo_ruleset_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposUpdateRepoRulesetError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Internal Error")]
Status500(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposUpdateRepoRulesetError> for AdapterError {
fn from(err: ReposUpdateRepoRulesetError) -> Self {
let (description, status_code) = match err {
ReposUpdateRepoRulesetError::Status404(_) => (String::from("Resource not found"), 404),
ReposUpdateRepoRulesetError::Status500(_) => (String::from("Internal Error"), 500),
ReposUpdateRepoRulesetError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Update status check protection](Repos::update_status_check_protection_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposUpdateStatusCheckProtectionError {
#[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<ReposUpdateStatusCheckProtectionError> for AdapterError {
fn from(err: ReposUpdateStatusCheckProtectionError) -> Self {
let (description, status_code) = match err {
ReposUpdateStatusCheckProtectionError::Status404(_) => (String::from("Resource not found"), 404),
ReposUpdateStatusCheckProtectionError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposUpdateStatusCheckProtectionError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Update a repository webhook](Repos::update_webhook_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposUpdateWebhookError {
#[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<ReposUpdateWebhookError> for AdapterError {
fn from(err: ReposUpdateWebhookError) -> Self {
let (description, status_code) = match err {
ReposUpdateWebhookError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
ReposUpdateWebhookError::Status404(_) => (String::from("Resource not found"), 404),
ReposUpdateWebhookError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Update a webhook configuration for a repository](Repos::update_webhook_config_for_repo_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposUpdateWebhookConfigForRepoError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposUpdateWebhookConfigForRepoError> for AdapterError {
fn from(err: ReposUpdateWebhookConfigForRepoError) -> Self {
let (description, status_code) = match err {
ReposUpdateWebhookConfigForRepoError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Upload a release asset](Repos::upload_release_asset_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum ReposUploadReleaseAssetError {
#[error("Response if you upload an asset with the same filename as another uploaded asset")]
Status422,
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<ReposUploadReleaseAssetError> for AdapterError {
fn from(err: ReposUploadReleaseAssetError) -> Self {
let (description, status_code) = match err {
ReposUploadReleaseAssetError::Status422 => (String::from("Response if you upload an asset with the same filename as another uploaded asset"), 422),
ReposUploadReleaseAssetError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Query parameters for the [List CODEOWNERS errors](Repos::codeowners_errors_async()) endpoint.
#[derive(Default, Serialize)]
pub struct ReposCodeownersErrorsParams<'req> {
/// A branch, tag or commit name used to determine which version of the CODEOWNERS file to use. Default: the repository's default branch (e.g. `main`)
git_ref: Option<&'req str>
}
impl<'req> ReposCodeownersErrorsParams<'req> {
pub fn new() -> Self {
Self::default()
}
/// A branch, tag or commit name used to determine which version of the CODEOWNERS file to use. Default: the repository's default branch (e.g. `main`)
pub fn git_ref(self, git_ref: &'req str) -> Self {
Self {
git_ref: Some(git_ref),
}
}
}
/// Query parameters for the [Compare two commits](Repos::compare_commits_async()) endpoint.
#[derive(Default, Serialize)]
pub struct ReposCompareCommitsParams {
/// 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>
}
impl ReposCompareCommitsParams {
pub fn new() -> Self {
Self::default()
}
/// 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 {
page: Some(page),
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 {
page: self.page,
per_page: Some(per_page),
}
}
}
impl<'enc> From<&'enc PerPage> for ReposCompareCommitsParams {
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 environments](Repos::get_all_environments_async()) endpoint.
#[derive(Default, Serialize)]
pub struct ReposGetAllEnvironmentsParams {
/// 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 ReposGetAllEnvironmentsParams {
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 ReposGetAllEnvironmentsParams {
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 all repository topics](Repos::get_all_topics_async()) endpoint.
#[derive(Default, Serialize)]
pub struct ReposGetAllTopicsParams {
/// 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>
}
impl ReposGetAllTopicsParams {
pub fn new() -> Self {
Self::default()
}
/// 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 {
page: Some(page),
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 {
page: self.page,
per_page: Some(per_page),
}
}
}
impl<'enc> From<&'enc PerPage> for ReposGetAllTopicsParams {
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 rules for a branch](Repos::get_branch_rules_async()) endpoint.
#[derive(Default, Serialize)]
pub struct ReposGetBranchRulesParams {
/// 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 ReposGetBranchRulesParams {
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 ReposGetBranchRulesParams {
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 repository clones](Repos::get_clones_async()) endpoint.
#[derive(Default, Serialize)]
pub struct ReposGetClonesParams<'req> {
/// The time frame to display results for.
per: Option<&'req str>
}
impl<'req> ReposGetClonesParams<'req> {
pub fn new() -> Self {
Self::default()
}
/// The time frame to display results for.
pub fn per(self, per: &'req str) -> Self {
Self {
per: Some(per),
}
}
}
/// Query parameters for the [Get the combined status for a specific reference](Repos::get_combined_status_for_ref_async()) endpoint.
#[derive(Default, Serialize)]
pub struct ReposGetCombinedStatusForRefParams {
/// 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 ReposGetCombinedStatusForRefParams {
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 ReposGetCombinedStatusForRefParams {
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 a commit](Repos::get_commit_async()) endpoint.
#[derive(Default, Serialize)]
pub struct ReposGetCommitParams {
/// 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>
}
impl ReposGetCommitParams {
pub fn new() -> Self {
Self::default()
}
/// 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 {
page: Some(page),
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 {
page: self.page,
per_page: Some(per_page),
}
}
}
impl<'enc> From<&'enc PerPage> for ReposGetCommitParams {
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 repository content](Repos::get_content_async()) endpoint.
#[derive(Default, Serialize)]
pub struct ReposGetContentParams<'req> {
/// The name of the commit/branch/tag. Default: the repository’s default branch.
git_ref: Option<&'req str>
}
impl<'req> ReposGetContentParams<'req> {
pub fn new() -> Self {
Self::default()
}
/// The name of the commit/branch/tag. Default: the repository’s default branch.
pub fn git_ref(self, git_ref: &'req str) -> Self {
Self {
git_ref: Some(git_ref),
}
}
}
/// Query parameters for the [List organization rule suites](Repos::get_org_rule_suites_async()) endpoint.
#[derive(Default, Serialize)]
pub struct ReposGetOrgRuleSuitesParams<'req> {
/// The name of the ref. Cannot contain wildcard characters. Optionally prefix with `refs/heads/` to limit to branches or `refs/tags/` to limit to tags. Omit the prefix to search across all refs. When specified, only rule evaluations triggered for this ref will be returned.
git_ref: Option<&'req str>,
/// The name of the repository to filter on.
repository_name: Option<&'req str>,
/// The time period to filter by. For example, `day` will filter for rule suites that occurred in the past 24 hours, and `week` will filter for rule suites that occurred in the past 7 days (168 hours).
time_period: Option<&'req str>,
/// The handle for the GitHub user account to filter on. When specified, only rule evaluations triggered by this actor will be returned.
actor_name: Option<&'req str>,
/// The rule suite results to filter on. When specified, only suites with this result will be returned.
rule_suite_result: 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> ReposGetOrgRuleSuitesParams<'req> {
pub fn new() -> Self {
Self::default()
}
/// The name of the ref. Cannot contain wildcard characters. Optionally prefix with `refs/heads/` to limit to branches or `refs/tags/` to limit to tags. Omit the prefix to search across all refs. When specified, only rule evaluations triggered for this ref will be returned.
pub fn git_ref(self, git_ref: &'req str) -> Self {
Self {
git_ref: Some(git_ref),
repository_name: self.repository_name,
time_period: self.time_period,
actor_name: self.actor_name,
rule_suite_result: self.rule_suite_result,
per_page: self.per_page,
page: self.page,
}
}
/// The name of the repository to filter on.
pub fn repository_name(self, repository_name: &'req str) -> Self {
Self {
git_ref: self.git_ref,
repository_name: Some(repository_name),
time_period: self.time_period,
actor_name: self.actor_name,
rule_suite_result: self.rule_suite_result,
per_page: self.per_page,
page: self.page,
}
}
/// The time period to filter by. For example, `day` will filter for rule suites that occurred in the past 24 hours, and `week` will filter for rule suites that occurred in the past 7 days (168 hours).
pub fn time_period(self, time_period: &'req str) -> Self {
Self {
git_ref: self.git_ref,
repository_name: self.repository_name,
time_period: Some(time_period),
actor_name: self.actor_name,
rule_suite_result: self.rule_suite_result,
per_page: self.per_page,
page: self.page,
}
}
/// The handle for the GitHub user account to filter on. When specified, only rule evaluations triggered by this actor will be returned.
pub fn actor_name(self, actor_name: &'req str) -> Self {
Self {
git_ref: self.git_ref,
repository_name: self.repository_name,
time_period: self.time_period,
actor_name: Some(actor_name),
rule_suite_result: self.rule_suite_result,
per_page: self.per_page,
page: self.page,
}
}
/// The rule suite results to filter on. When specified, only suites with this result will be returned.
pub fn rule_suite_result(self, rule_suite_result: &'req str) -> Self {
Self {
git_ref: self.git_ref,
repository_name: self.repository_name,
time_period: self.time_period,
actor_name: self.actor_name,
rule_suite_result: Some(rule_suite_result),
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 {
git_ref: self.git_ref,
repository_name: self.repository_name,
time_period: self.time_period,
actor_name: self.actor_name,
rule_suite_result: self.rule_suite_result,
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 {
git_ref: self.git_ref,
repository_name: self.repository_name,
time_period: self.time_period,
actor_name: self.actor_name,
rule_suite_result: self.rule_suite_result,
per_page: self.per_page,
page: Some(page),
}
}
}
impl<'enc> From<&'enc PerPage> for ReposGetOrgRuleSuitesParams<'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 all organization repository rulesets](Repos::get_org_rulesets_async()) endpoint.
#[derive(Default, Serialize)]
pub struct ReposGetOrgRulesetsParams<'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>,
/// A comma-separated list of rule targets to filter by. If provided, only rulesets that apply to the specified targets will be returned. For example, `branch,tag,push`.
targets: Option<&'req str>
}
impl<'req> ReposGetOrgRulesetsParams<'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,
targets: self.targets,
}
}
/// 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),
targets: self.targets,
}
}
/// A comma-separated list of rule targets to filter by. If provided, only rulesets that apply to the specified targets will be returned. For example, `branch,tag,push`.
pub fn targets(self, targets: &'req str) -> Self {
Self {
per_page: self.per_page,
page: self.page,
targets: Some(targets),
}
}
}
impl<'enc> From<&'enc PerPage> for ReposGetOrgRulesetsParams<'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 a repository README](Repos::get_readme_async()) endpoint.
#[derive(Default, Serialize)]
pub struct ReposGetReadmeParams<'req> {
/// The name of the commit/branch/tag. Default: the repository’s default branch.
git_ref: Option<&'req str>
}
impl<'req> ReposGetReadmeParams<'req> {
pub fn new() -> Self {
Self::default()
}
/// The name of the commit/branch/tag. Default: the repository’s default branch.
pub fn git_ref(self, git_ref: &'req str) -> Self {
Self {
git_ref: Some(git_ref),
}
}
}
/// Query parameters for the [Get a repository README for a directory](Repos::get_readme_in_directory_async()) endpoint.
#[derive(Default, Serialize)]
pub struct ReposGetReadmeInDirectoryParams<'req> {
/// The name of the commit/branch/tag. Default: the repository’s default branch.
git_ref: Option<&'req str>
}
impl<'req> ReposGetReadmeInDirectoryParams<'req> {
pub fn new() -> Self {
Self::default()
}
/// The name of the commit/branch/tag. Default: the repository’s default branch.
pub fn git_ref(self, git_ref: &'req str) -> Self {
Self {
git_ref: Some(git_ref),
}
}
}
/// Query parameters for the [List repository rule suites](Repos::get_repo_rule_suites_async()) endpoint.
#[derive(Default, Serialize)]
pub struct ReposGetRepoRuleSuitesParams<'req> {
/// The name of the ref. Cannot contain wildcard characters. Optionally prefix with `refs/heads/` to limit to branches or `refs/tags/` to limit to tags. Omit the prefix to search across all refs. When specified, only rule evaluations triggered for this ref will be returned.
git_ref: Option<&'req str>,
/// The time period to filter by. For example, `day` will filter for rule suites that occurred in the past 24 hours, and `week` will filter for rule suites that occurred in the past 7 days (168 hours).
time_period: Option<&'req str>,
/// The handle for the GitHub user account to filter on. When specified, only rule evaluations triggered by this actor will be returned.
actor_name: Option<&'req str>,
/// The rule suite results to filter on. When specified, only suites with this result will be returned.
rule_suite_result: 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> ReposGetRepoRuleSuitesParams<'req> {
pub fn new() -> Self {
Self::default()
}
/// The name of the ref. Cannot contain wildcard characters. Optionally prefix with `refs/heads/` to limit to branches or `refs/tags/` to limit to tags. Omit the prefix to search across all refs. When specified, only rule evaluations triggered for this ref will be returned.
pub fn git_ref(self, git_ref: &'req str) -> Self {
Self {
git_ref: Some(git_ref),
time_period: self.time_period,
actor_name: self.actor_name,
rule_suite_result: self.rule_suite_result,
per_page: self.per_page,
page: self.page,
}
}
/// The time period to filter by. For example, `day` will filter for rule suites that occurred in the past 24 hours, and `week` will filter for rule suites that occurred in the past 7 days (168 hours).
pub fn time_period(self, time_period: &'req str) -> Self {
Self {
git_ref: self.git_ref,
time_period: Some(time_period),
actor_name: self.actor_name,
rule_suite_result: self.rule_suite_result,
per_page: self.per_page,
page: self.page,
}
}
/// The handle for the GitHub user account to filter on. When specified, only rule evaluations triggered by this actor will be returned.
pub fn actor_name(self, actor_name: &'req str) -> Self {
Self {
git_ref: self.git_ref,
time_period: self.time_period,
actor_name: Some(actor_name),
rule_suite_result: self.rule_suite_result,
per_page: self.per_page,
page: self.page,
}
}
/// The rule suite results to filter on. When specified, only suites with this result will be returned.
pub fn rule_suite_result(self, rule_suite_result: &'req str) -> Self {
Self {
git_ref: self.git_ref,
time_period: self.time_period,
actor_name: self.actor_name,
rule_suite_result: Some(rule_suite_result),
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 {
git_ref: self.git_ref,
time_period: self.time_period,
actor_name: self.actor_name,
rule_suite_result: self.rule_suite_result,
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 {
git_ref: self.git_ref,
time_period: self.time_period,
actor_name: self.actor_name,
rule_suite_result: self.rule_suite_result,
per_page: self.per_page,
page: Some(page),
}
}
}
impl<'enc> From<&'enc PerPage> for ReposGetRepoRuleSuitesParams<'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 a repository ruleset](Repos::get_repo_ruleset_async()) endpoint.
#[derive(Default, Serialize)]
pub struct ReposGetRepoRulesetParams {
/// Include rulesets configured at higher levels that apply to this repository
includes_parents: Option<bool>
}
impl ReposGetRepoRulesetParams {
pub fn new() -> Self {
Self::default()
}
/// Include rulesets configured at higher levels that apply to this repository
pub fn includes_parents(self, includes_parents: bool) -> Self {
Self {
includes_parents: Some(includes_parents),
}
}
}
/// Query parameters for the [Get repository ruleset history](Repos::get_repo_ruleset_history_async()) endpoint.
#[derive(Default, Serialize)]
pub struct ReposGetRepoRulesetHistoryParams {
/// 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 ReposGetRepoRulesetHistoryParams {
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 ReposGetRepoRulesetHistoryParams {
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 all repository rulesets](Repos::get_repo_rulesets_async()) endpoint.
#[derive(Default, Serialize)]
pub struct ReposGetRepoRulesetsParams<'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>,
/// Include rulesets configured at higher levels that apply to this repository
includes_parents: Option<bool>,
/// A comma-separated list of rule targets to filter by. If provided, only rulesets that apply to the specified targets will be returned. For example, `branch,tag,push`.
targets: Option<&'req str>
}
impl<'req> ReposGetRepoRulesetsParams<'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,
includes_parents: self.includes_parents,
targets: self.targets,
}
}
/// 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),
includes_parents: self.includes_parents,
targets: self.targets,
}
}
/// Include rulesets configured at higher levels that apply to this repository
pub fn includes_parents(self, includes_parents: bool) -> Self {
Self {
per_page: self.per_page,
page: self.page,
includes_parents: Some(includes_parents),
targets: self.targets,
}
}
/// A comma-separated list of rule targets to filter by. If provided, only rulesets that apply to the specified targets will be returned. For example, `branch,tag,push`.
pub fn targets(self, targets: &'req str) -> Self {
Self {
per_page: self.per_page,
page: self.page,
includes_parents: self.includes_parents,
targets: Some(targets),
}
}
}
impl<'enc> From<&'enc PerPage> for ReposGetRepoRulesetsParams<'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 page views](Repos::get_views_async()) endpoint.
#[derive(Default, Serialize)]
pub struct ReposGetViewsParams<'req> {
/// The time frame to display results for.
per: Option<&'req str>
}
impl<'req> ReposGetViewsParams<'req> {
pub fn new() -> Self {
Self::default()
}
/// The time frame to display results for.
pub fn per(self, per: &'req str) -> Self {
Self {
per: Some(per),
}
}
}
/// Query parameters for the [List repository activities](Repos::list_activities_async()) endpoint.
#[derive(Default, Serialize)]
pub struct ReposListActivitiesParams<'req> {
/// The direction to sort the results by.
direction: Option<&'req str>,
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
per_page: Option<u16>,
/// 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>,
/// The Git reference for the activities you want to list. The `ref` for a branch can be formatted either as `refs/heads/BRANCH_NAME` or `BRANCH_NAME`, where `BRANCH_NAME` is the name of your branch.
git_ref: Option<&'req str>,
/// The GitHub username to use to filter by the actor who performed the activity.
actor: Option<&'req str>,
/// The time period to filter by. For example, `day` will filter for activity that occurred in the past 24 hours, and `week` will filter for activity that occurred in the past 7 days (168 hours).
time_period: Option<&'req str>,
/// The activity type to filter by. For example, you can choose to filter by \"force_push\", to see all force pushes to the repository.
activity_type: Option<&'req str>
}
impl<'req> ReposListActivitiesParams<'req> {
pub fn new() -> Self {
Self::default()
}
/// The direction to sort the results by.
pub fn direction(self, direction: &'req str) -> Self {
Self {
direction: Some(direction),
per_page: self.per_page,
before: self.before,
after: self.after,
git_ref: self.git_ref,
actor: self.actor,
time_period: self.time_period,
activity_type: self.activity_type,
}
}
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn per_page(self, per_page: u16) -> Self {
Self {
direction: self.direction,
per_page: Some(per_page),
before: self.before,
after: self.after,
git_ref: self.git_ref,
actor: self.actor,
time_period: self.time_period,
activity_type: self.activity_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 {
direction: self.direction,
per_page: self.per_page,
before: Some(before),
after: self.after,
git_ref: self.git_ref,
actor: self.actor,
time_period: self.time_period,
activity_type: self.activity_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 {
direction: self.direction,
per_page: self.per_page,
before: self.before,
after: Some(after),
git_ref: self.git_ref,
actor: self.actor,
time_period: self.time_period,
activity_type: self.activity_type,
}
}
/// The Git reference for the activities you want to list. The `ref` for a branch can be formatted either as `refs/heads/BRANCH_NAME` or `BRANCH_NAME`, where `BRANCH_NAME` is the name of your branch.
pub fn git_ref(self, git_ref: &'req str) -> Self {
Self {
direction: self.direction,
per_page: self.per_page,
before: self.before,
after: self.after,
git_ref: Some(git_ref),
actor: self.actor,
time_period: self.time_period,
activity_type: self.activity_type,
}
}
/// The GitHub username to use to filter by the actor who performed the activity.
pub fn actor(self, actor: &'req str) -> Self {
Self {
direction: self.direction,
per_page: self.per_page,
before: self.before,
after: self.after,
git_ref: self.git_ref,
actor: Some(actor),
time_period: self.time_period,
activity_type: self.activity_type,
}
}
/// The time period to filter by. For example, `day` will filter for activity that occurred in the past 24 hours, and `week` will filter for activity that occurred in the past 7 days (168 hours).
pub fn time_period(self, time_period: &'req str) -> Self {
Self {
direction: self.direction,
per_page: self.per_page,
before: self.before,
after: self.after,
git_ref: self.git_ref,
actor: self.actor,
time_period: Some(time_period),
activity_type: self.activity_type,
}
}
/// The activity type to filter by. For example, you can choose to filter by \"force_push\", to see all force pushes to the repository.
pub fn activity_type(self, activity_type: &'req str) -> Self {
Self {
direction: self.direction,
per_page: self.per_page,
before: self.before,
after: self.after,
git_ref: self.git_ref,
actor: self.actor,
time_period: self.time_period,
activity_type: Some(activity_type),
}
}
}
/// Query parameters for the [List attestations](Repos::list_attestations_async()) endpoint.
#[derive(Default, Serialize)]
pub struct ReposListAttestationsParams<'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> ReposListAttestationsParams<'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 branches](Repos::list_branches_async()) endpoint.
#[derive(Default, Serialize)]
pub struct ReposListBranchesParams {
/// Setting to `true` returns only branches protected by branch protections or rulesets. When set to `false`, only unprotected branches are returned. Omitting this parameter returns all branches.
protected: Option<bool>,
/// 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 ReposListBranchesParams {
pub fn new() -> Self {
Self::default()
}
/// Setting to `true` returns only branches protected by branch protections or rulesets. When set to `false`, only unprotected branches are returned. Omitting this parameter returns all branches.
pub fn protected(self, protected: bool) -> Self {
Self {
protected: Some(protected),
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 {
protected: self.protected,
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 {
protected: self.protected,
per_page: self.per_page,
page: Some(page),
}
}
}
impl<'enc> From<&'enc PerPage> for ReposListBranchesParams {
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 repository collaborators](Repos::list_collaborators_async()) endpoint.
#[derive(Default, Serialize)]
pub struct ReposListCollaboratorsParams<'req> {
/// Filter collaborators returned by their affiliation. `outside` means all outside collaborators of an organization-owned repository. `direct` means all collaborators with permissions to an organization-owned repository, regardless of organization membership status. `all` means all collaborators the authenticated user can see.
affiliation: Option<&'req str>,
/// Filter collaborators by the permissions they have on the repository. If not specified, all collaborators will be returned.
permission: 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> ReposListCollaboratorsParams<'req> {
pub fn new() -> Self {
Self::default()
}
/// Filter collaborators returned by their affiliation. `outside` means all outside collaborators of an organization-owned repository. `direct` means all collaborators with permissions to an organization-owned repository, regardless of organization membership status. `all` means all collaborators the authenticated user can see.
pub fn affiliation(self, affiliation: &'req str) -> Self {
Self {
affiliation: Some(affiliation),
permission: self.permission,
per_page: self.per_page,
page: self.page,
}
}
/// Filter collaborators by the permissions they have on the repository. If not specified, all collaborators will be returned.
pub fn permission(self, permission: &'req str) -> Self {
Self {
affiliation: self.affiliation,
permission: Some(permission),
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 {
affiliation: self.affiliation,
permission: self.permission,
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 {
affiliation: self.affiliation,
permission: self.permission,
per_page: self.per_page,
page: Some(page),
}
}
}
impl<'enc> From<&'enc PerPage> for ReposListCollaboratorsParams<'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 commit comments](Repos::list_comments_for_commit_async()) endpoint.
#[derive(Default, Serialize)]
pub struct ReposListCommentsForCommitParams {
/// 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 ReposListCommentsForCommitParams {
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 ReposListCommentsForCommitParams {
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 commit comments for a repository](Repos::list_commit_comments_for_repo_async()) endpoint.
#[derive(Default, Serialize)]
pub struct ReposListCommitCommentsForRepoParams {
/// 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 ReposListCommitCommentsForRepoParams {
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 ReposListCommitCommentsForRepoParams {
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 commit statuses for a reference](Repos::list_commit_statuses_for_ref_async()) endpoint.
#[derive(Default, Serialize)]
pub struct ReposListCommitStatusesForRefParams {
/// 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 ReposListCommitStatusesForRefParams {
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 ReposListCommitStatusesForRefParams {
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 commits](Repos::list_commits_async()) endpoint.
#[derive(Default, Serialize)]
pub struct ReposListCommitsParams<'req> {
/// SHA or branch to start listing commits from. Default: the repository’s default branch (usually `main`).
sha: Option<&'req str>,
/// Only commits containing this file path will be returned.
path: Option<&'req str>,
/// GitHub username or email address to use to filter by commit author.
author: Option<&'req str>,
/// GitHub username or email address to use to filter by commit committer.
committer: Option<&'req str>,
/// Only show results that were last updated after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. Due to limitations of Git, timestamps must be between 1970-01-01 and 2099-12-31 (inclusive) or unexpected results may be returned.
since: Option<chrono::DateTime<chrono::Utc>>,
/// Only commits before this date will be returned. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. Due to limitations of Git, timestamps must be between 1970-01-01 and 2099-12-31 (inclusive) or unexpected results may be returned.
until: Option<chrono::DateTime<chrono::Utc>>,
/// 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> ReposListCommitsParams<'req> {
pub fn new() -> Self {
Self::default()
}
/// SHA or branch to start listing commits from. Default: the repository’s default branch (usually `main`).
pub fn sha(self, sha: &'req str) -> Self {
Self {
sha: Some(sha),
path: self.path,
author: self.author,
committer: self.committer,
since: self.since,
until: self.until,
per_page: self.per_page,
page: self.page,
}
}
/// Only commits containing this file path will be returned.
pub fn path(self, path: &'req str) -> Self {
Self {
sha: self.sha,
path: Some(path),
author: self.author,
committer: self.committer,
since: self.since,
until: self.until,
per_page: self.per_page,
page: self.page,
}
}
/// GitHub username or email address to use to filter by commit author.
pub fn author(self, author: &'req str) -> Self {
Self {
sha: self.sha,
path: self.path,
author: Some(author),
committer: self.committer,
since: self.since,
until: self.until,
per_page: self.per_page,
page: self.page,
}
}
/// GitHub username or email address to use to filter by commit committer.
pub fn committer(self, committer: &'req str) -> Self {
Self {
sha: self.sha,
path: self.path,
author: self.author,
committer: Some(committer),
since: self.since,
until: self.until,
per_page: self.per_page,
page: self.page,
}
}
/// Only show results that were last updated after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. Due to limitations of Git, timestamps must be between 1970-01-01 and 2099-12-31 (inclusive) or unexpected results may be returned.
pub fn since(self, since: chrono::DateTime<chrono::Utc>) -> Self {
Self {
sha: self.sha,
path: self.path,
author: self.author,
committer: self.committer,
since: Some(since),
until: self.until,
per_page: self.per_page,
page: self.page,
}
}
/// Only commits before this date will be returned. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. Due to limitations of Git, timestamps must be between 1970-01-01 and 2099-12-31 (inclusive) or unexpected results may be returned.
pub fn until(self, until: chrono::DateTime<chrono::Utc>) -> Self {
Self {
sha: self.sha,
path: self.path,
author: self.author,
committer: self.committer,
since: self.since,
until: Some(until),
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 {
sha: self.sha,
path: self.path,
author: self.author,
committer: self.committer,
since: self.since,
until: self.until,
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 {
sha: self.sha,
path: self.path,
author: self.author,
committer: self.committer,
since: self.since,
until: self.until,
per_page: self.per_page,
page: Some(page),
}
}
}
impl<'enc> From<&'enc PerPage> for ReposListCommitsParams<'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 repository contributors](Repos::list_contributors_async()) endpoint.
#[derive(Default, Serialize)]
pub struct ReposListContributorsParams<'req> {
/// Set to `1` or `true` to include anonymous contributors in results.
anon: 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> ReposListContributorsParams<'req> {
pub fn new() -> Self {
Self::default()
}
/// Set to `1` or `true` to include anonymous contributors in results.
pub fn anon(self, anon: &'req str) -> Self {
Self {
anon: Some(anon),
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 {
anon: self.anon,
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 {
anon: self.anon,
per_page: self.per_page,
page: Some(page),
}
}
}
impl<'enc> From<&'enc PerPage> for ReposListContributorsParams<'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 custom deployment rule integrations available for an environment](Repos::list_custom_deployment_rule_integrations_async()) endpoint.
#[derive(Default, Serialize)]
pub struct ReposListCustomDeploymentRuleIntegrationsParams {
/// 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>
}
impl ReposListCustomDeploymentRuleIntegrationsParams {
pub fn new() -> Self {
Self::default()
}
/// 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 {
page: Some(page),
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 {
page: self.page,
per_page: Some(per_page),
}
}
}
impl<'enc> From<&'enc PerPage> for ReposListCustomDeploymentRuleIntegrationsParams {
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 deploy keys](Repos::list_deploy_keys_async()) endpoint.
#[derive(Default, Serialize)]
pub struct ReposListDeployKeysParams {
/// 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 ReposListDeployKeysParams {
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 ReposListDeployKeysParams {
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 deployment branch policies](Repos::list_deployment_branch_policies_async()) endpoint.
#[derive(Default, Serialize)]
pub struct ReposListDeploymentBranchPoliciesParams {
/// 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 ReposListDeploymentBranchPoliciesParams {
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 ReposListDeploymentBranchPoliciesParams {
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 deployment statuses](Repos::list_deployment_statuses_async()) endpoint.
#[derive(Default, Serialize)]
pub struct ReposListDeploymentStatusesParams {
/// 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 ReposListDeploymentStatusesParams {
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 ReposListDeploymentStatusesParams {
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 deployments](Repos::list_deployments_async()) endpoint.
#[derive(Default, Serialize)]
pub struct ReposListDeploymentsParams<'req> {
/// The SHA recorded at creation time.
sha: Option<&'req str>,
/// The name of the ref. This can be a branch, tag, or SHA.
git_ref: Option<&'req str>,
/// The name of the task for the deployment (e.g., `deploy` or `deploy:migrations`).
task: Option<&'req str>,
/// The name of the environment that was deployed to (e.g., `staging` or `production`).
environment: 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> ReposListDeploymentsParams<'req> {
pub fn new() -> Self {
Self::default()
}
/// The SHA recorded at creation time.
pub fn sha(self, sha: &'req str) -> Self {
Self {
sha: Some(sha),
git_ref: self.git_ref,
task: self.task,
environment: self.environment,
per_page: self.per_page,
page: self.page,
}
}
/// The name of the ref. This can be a branch, tag, or SHA.
pub fn git_ref(self, git_ref: &'req str) -> Self {
Self {
sha: self.sha,
git_ref: Some(git_ref),
task: self.task,
environment: self.environment,
per_page: self.per_page,
page: self.page,
}
}
/// The name of the task for the deployment (e.g., `deploy` or `deploy:migrations`).
pub fn task(self, task: &'req str) -> Self {
Self {
sha: self.sha,
git_ref: self.git_ref,
task: Some(task),
environment: self.environment,
per_page: self.per_page,
page: self.page,
}
}
/// The name of the environment that was deployed to (e.g., `staging` or `production`).
pub fn environment(self, environment: &'req str) -> Self {
Self {
sha: self.sha,
git_ref: self.git_ref,
task: self.task,
environment: Some(environment),
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 {
sha: self.sha,
git_ref: self.git_ref,
task: self.task,
environment: self.environment,
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 {
sha: self.sha,
git_ref: self.git_ref,
task: self.task,
environment: self.environment,
per_page: self.per_page,
page: Some(page),
}
}
}
impl<'enc> From<&'enc PerPage> for ReposListDeploymentsParams<'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 for the authenticated user](Repos::list_for_authenticated_user_async()) endpoint.
#[derive(Default, Serialize)]
pub struct ReposListForAuthenticatedUserParams<'req> {
/// Limit results to repositories with the specified visibility.
visibility: Option<&'req str>,
/// Comma-separated list of values. Can include: * `owner`: Repositories that are owned by the authenticated user. * `collaborator`: Repositories that the user has been added to as a collaborator. * `organization_member`: Repositories that the user has access to through being a member of an organization. This includes every repository on every team that the user is on.
affiliation: Option<&'req str>,
/// Limit results to repositories of the specified type. Will cause a `422` error if used in the same request as **visibility** or **affiliation**.
_type: Option<&'req str>,
/// The property to sort the results by.
sort: Option<&'req str>,
/// The order to sort by. Default: `asc` when using `full_name`, otherwise `desc`.
direction: Option<&'req str>,
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
per_page: Option<u16>,
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
page: Option<u16>,
/// Only show repositories updated after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
since: Option<chrono::DateTime<chrono::Utc>>,
/// Only show repositories updated before the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
before: Option<chrono::DateTime<chrono::Utc>>
}
impl<'req> ReposListForAuthenticatedUserParams<'req> {
pub fn new() -> Self {
Self::default()
}
/// Limit results to repositories with the specified visibility.
pub fn visibility(self, visibility: &'req str) -> Self {
Self {
visibility: Some(visibility),
affiliation: self.affiliation,
_type: self._type,
sort: self.sort,
direction: self.direction,
per_page: self.per_page,
page: self.page,
since: self.since,
before: self.before,
}
}
/// Comma-separated list of values. Can include: * `owner`: Repositories that are owned by the authenticated user. * `collaborator`: Repositories that the user has been added to as a collaborator. * `organization_member`: Repositories that the user has access to through being a member of an organization. This includes every repository on every team that the user is on.
pub fn affiliation(self, affiliation: &'req str) -> Self {
Self {
visibility: self.visibility,
affiliation: Some(affiliation),
_type: self._type,
sort: self.sort,
direction: self.direction,
per_page: self.per_page,
page: self.page,
since: self.since,
before: self.before,
}
}
/// Limit results to repositories of the specified type. Will cause a `422` error if used in the same request as **visibility** or **affiliation**.
pub fn _type(self, _type: &'req str) -> Self {
Self {
visibility: self.visibility,
affiliation: self.affiliation,
_type: Some(_type),
sort: self.sort,
direction: self.direction,
per_page: self.per_page,
page: self.page,
since: self.since,
before: self.before,
}
}
/// The property to sort the results by.
pub fn sort(self, sort: &'req str) -> Self {
Self {
visibility: self.visibility,
affiliation: self.affiliation,
_type: self._type,
sort: Some(sort),
direction: self.direction,
per_page: self.per_page,
page: self.page,
since: self.since,
before: self.before,
}
}
/// The order to sort by. Default: `asc` when using `full_name`, otherwise `desc`.
pub fn direction(self, direction: &'req str) -> Self {
Self {
visibility: self.visibility,
affiliation: self.affiliation,
_type: self._type,
sort: self.sort,
direction: Some(direction),
per_page: self.per_page,
page: self.page,
since: self.since,
before: self.before,
}
}
/// 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 {
visibility: self.visibility,
affiliation: self.affiliation,
_type: self._type,
sort: self.sort,
direction: self.direction,
per_page: Some(per_page),
page: self.page,
since: self.since,
before: self.before,
}
}
/// 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 {
visibility: self.visibility,
affiliation: self.affiliation,
_type: self._type,
sort: self.sort,
direction: self.direction,
per_page: self.per_page,
page: Some(page),
since: self.since,
before: self.before,
}
}
/// Only show repositories updated 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 since(self, since: chrono::DateTime<chrono::Utc>) -> Self {
Self {
visibility: self.visibility,
affiliation: self.affiliation,
_type: self._type,
sort: self.sort,
direction: self.direction,
per_page: self.per_page,
page: self.page,
since: Some(since),
before: self.before,
}
}
/// Only show repositories updated 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 before(self, before: chrono::DateTime<chrono::Utc>) -> Self {
Self {
visibility: self.visibility,
affiliation: self.affiliation,
_type: self._type,
sort: self.sort,
direction: self.direction,
per_page: self.per_page,
page: self.page,
since: self.since,
before: Some(before),
}
}
}
impl<'enc> From<&'enc PerPage> for ReposListForAuthenticatedUserParams<'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 repositories](Repos::list_for_org_async()) endpoint.
#[derive(Default, Serialize)]
pub struct ReposListForOrgParams<'req> {
/// Specifies the types of repositories you want returned.
_type: Option<&'req str>,
/// The property to sort the results by.
sort: Option<&'req str>,
/// The order to sort by. Default: `asc` when using `full_name`, otherwise `desc`.
direction: Option<&'req str>,
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
per_page: Option<u16>,
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
page: Option<u16>
}
impl<'req> ReposListForOrgParams<'req> {
pub fn new() -> Self {
Self::default()
}
/// Specifies the types of repositories you want returned.
pub fn _type(self, _type: &'req str) -> Self {
Self {
_type: Some(_type),
sort: self.sort,
direction: self.direction,
per_page: self.per_page,
page: self.page,
}
}
/// The property to sort the results by.
pub fn sort(self, sort: &'req str) -> Self {
Self {
_type: self._type,
sort: Some(sort),
direction: self.direction,
per_page: self.per_page,
page: self.page,
}
}
/// The order to sort by. Default: `asc` when using `full_name`, otherwise `desc`.
pub fn direction(self, direction: &'req str) -> Self {
Self {
_type: self._type,
sort: self.sort,
direction: Some(direction),
per_page: self.per_page,
page: self.page,
}
}
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn per_page(self, per_page: u16) -> Self {
Self {
_type: self._type,
sort: self.sort,
direction: self.direction,
per_page: Some(per_page),
page: self.page,
}
}
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn page(self, page: u16) -> Self {
Self {
_type: self._type,
sort: self.sort,
direction: self.direction,
per_page: self.per_page,
page: Some(page),
}
}
}
impl<'enc> From<&'enc PerPage> for ReposListForOrgParams<'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 for a user](Repos::list_for_user_async()) endpoint.
#[derive(Default, Serialize)]
pub struct ReposListForUserParams<'req> {
/// Limit results to repositories of the specified type.
_type: Option<&'req str>,
/// The property to sort the results by.
sort: Option<&'req str>,
/// The order to sort by. Default: `asc` when using `full_name`, otherwise `desc`.
direction: Option<&'req str>,
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
per_page: Option<u16>,
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
page: Option<u16>
}
impl<'req> ReposListForUserParams<'req> {
pub fn new() -> Self {
Self::default()
}
/// Limit results to repositories of the specified type.
pub fn _type(self, _type: &'req str) -> Self {
Self {
_type: Some(_type),
sort: self.sort,
direction: self.direction,
per_page: self.per_page,
page: self.page,
}
}
/// The property to sort the results by.
pub fn sort(self, sort: &'req str) -> Self {
Self {
_type: self._type,
sort: Some(sort),
direction: self.direction,
per_page: self.per_page,
page: self.page,
}
}
/// The order to sort by. Default: `asc` when using `full_name`, otherwise `desc`.
pub fn direction(self, direction: &'req str) -> Self {
Self {
_type: self._type,
sort: self.sort,
direction: Some(direction),
per_page: self.per_page,
page: self.page,
}
}
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn per_page(self, per_page: u16) -> Self {
Self {
_type: self._type,
sort: self.sort,
direction: self.direction,
per_page: Some(per_page),
page: self.page,
}
}
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn page(self, page: u16) -> Self {
Self {
_type: self._type,
sort: self.sort,
direction: self.direction,
per_page: self.per_page,
page: Some(page),
}
}
}
impl<'enc> From<&'enc PerPage> for ReposListForUserParams<'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 forks](Repos::list_forks_async()) endpoint.
#[derive(Default, Serialize)]
pub struct ReposListForksParams<'req> {
/// The sort order. `stargazers` will sort by star count.
sort: 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> ReposListForksParams<'req> {
pub fn new() -> Self {
Self::default()
}
/// The sort order. `stargazers` will sort by star count.
pub fn sort(self, sort: &'req str) -> Self {
Self {
sort: Some(sort),
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 {
sort: self.sort,
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 {
sort: self.sort,
per_page: self.per_page,
page: Some(page),
}
}
}
impl<'enc> From<&'enc PerPage> for ReposListForksParams<'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 repository invitations](Repos::list_invitations_async()) endpoint.
#[derive(Default, Serialize)]
pub struct ReposListInvitationsParams {
/// 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 ReposListInvitationsParams {
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 ReposListInvitationsParams {
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 repository invitations for the authenticated user](Repos::list_invitations_for_authenticated_user_async()) endpoint.
#[derive(Default, Serialize)]
pub struct ReposListInvitationsForAuthenticatedUserParams {
/// 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 ReposListInvitationsForAuthenticatedUserParams {
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 ReposListInvitationsForAuthenticatedUserParams {
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 GitHub Pages builds](Repos::list_pages_builds_async()) endpoint.
#[derive(Default, Serialize)]
pub struct ReposListPagesBuildsParams {
/// 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 ReposListPagesBuildsParams {
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 ReposListPagesBuildsParams {
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 repositories](Repos::list_public_async()) endpoint.
#[derive(Default, Serialize)]
pub struct ReposListPublicParams {
/// A repository ID. Only return repositories with an ID greater than this ID.
since: Option<i32>
}
impl ReposListPublicParams {
pub fn new() -> Self {
Self::default()
}
/// A repository ID. Only return repositories with an ID greater than this ID.
pub fn since(self, since: i32) -> Self {
Self {
since: Some(since),
}
}
}
/// Query parameters for the [List pull requests associated with a commit](Repos::list_pull_requests_associated_with_commit_async()) endpoint.
#[derive(Default, Serialize)]
pub struct ReposListPullRequestsAssociatedWithCommitParams {
/// 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 ReposListPullRequestsAssociatedWithCommitParams {
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 ReposListPullRequestsAssociatedWithCommitParams {
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 release assets](Repos::list_release_assets_async()) endpoint.
#[derive(Default, Serialize)]
pub struct ReposListReleaseAssetsParams {
/// 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 ReposListReleaseAssetsParams {
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 ReposListReleaseAssetsParams {
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 releases](Repos::list_releases_async()) endpoint.
#[derive(Default, Serialize)]
pub struct ReposListReleasesParams {
/// 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 ReposListReleasesParams {
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 ReposListReleasesParams {
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 repository tags](Repos::list_tags_async()) endpoint.
#[derive(Default, Serialize)]
pub struct ReposListTagsParams {
/// 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 ReposListTagsParams {
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 ReposListTagsParams {
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 repository teams](Repos::list_teams_async()) endpoint.
#[derive(Default, Serialize)]
pub struct ReposListTeamsParams {
/// 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 ReposListTeamsParams {
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 ReposListTeamsParams {
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 a repository webhook](Repos::list_webhook_deliveries_async()) endpoint.
#[derive(Default, Serialize)]
pub struct ReposListWebhookDeliveriesParams<'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> ReposListWebhookDeliveriesParams<'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 repository webhooks](Repos::list_webhooks_async()) endpoint.
#[derive(Default, Serialize)]
pub struct ReposListWebhooksParams {
/// 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 ReposListWebhooksParams {
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 ReposListWebhooksParams {
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 [Upload a release asset](Repos::upload_release_asset_async()) endpoint.
#[derive(Default, Serialize)]
pub struct ReposUploadReleaseAssetParams<'req> {
name: &'req str,
label: Option<&'req str>
}
impl<'req> ReposUploadReleaseAssetParams<'req> {
pub fn new() -> Self {
Self::default()
}
pub fn name(self, name: &'req str) -> Self {
Self {
name: name,
label: self.label,
}
}
pub fn label(self, label: &'req str) -> Self {
Self {
name: self.name,
label: Some(label),
}
}
}
impl<'api, C: Client> Repos<'api, C> where AdapterError: From<<C as Client>::Err> {
/// ---
///
/// # Accept a repository invitation
///
/// [GitHub API docs for accept_invitation_for_authenticated_user](https://docs.github.com/rest/collaborators/invitations#accept-a-repository-invitation)
///
/// ---
pub async fn accept_invitation_for_authenticated_user_async(&self, invitation_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/user/repository_invitations/{}", super::GITHUB_BASE_API_URL, invitation_id);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::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(ReposAcceptInvitationForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()),
409 => Err(ReposAcceptInvitationForAuthenticatedUserError::Status409(github_response.to_json_async().await?).into()),
404 => Err(ReposAcceptInvitationForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()),
304 => Err(ReposAcceptInvitationForAuthenticatedUserError::Status304.into()),
code => Err(ReposAcceptInvitationForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Accept a repository invitation
///
/// [GitHub API docs for accept_invitation_for_authenticated_user](https://docs.github.com/rest/collaborators/invitations#accept-a-repository-invitation)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn accept_invitation_for_authenticated_user(&self, invitation_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/user/repository_invitations/{}", super::GITHUB_BASE_API_URL, invitation_id);
let req = GitHubRequest {
uri: request_uri,
body: None,
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(ReposAcceptInvitationForAuthenticatedUserError::Status403(github_response.to_json()?).into()),
409 => Err(ReposAcceptInvitationForAuthenticatedUserError::Status409(github_response.to_json()?).into()),
404 => Err(ReposAcceptInvitationForAuthenticatedUserError::Status404(github_response.to_json()?).into()),
304 => Err(ReposAcceptInvitationForAuthenticatedUserError::Status304.into()),
code => Err(ReposAcceptInvitationForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Add app access restrictions
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// Grants the specified apps push access for this branch. Only GitHub Apps that are installed on the repository and that have been granted write access to the repository contents can be added as authorized actors on a protected branch.
///
/// [GitHub API docs for add_app_access_restrictions](https://docs.github.com/rest/branches/branch-protection#add-app-access-restrictions)
///
/// ---
pub async fn add_app_access_restrictions_async(&self, owner: &str, repo: &str, branch: &str, body: PostReposAddAppAccessRestrictions) -> Result<Vec<Integration>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions/apps", super::GITHUB_BASE_API_URL, owner, repo, branch);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposAddAppAccessRestrictions>(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(ReposAddAppAccessRestrictionsError::Status422(github_response.to_json_async().await?).into()),
code => Err(ReposAddAppAccessRestrictionsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Add app access restrictions
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// Grants the specified apps push access for this branch. Only GitHub Apps that are installed on the repository and that have been granted write access to the repository contents can be added as authorized actors on a protected branch.
///
/// [GitHub API docs for add_app_access_restrictions](https://docs.github.com/rest/branches/branch-protection#add-app-access-restrictions)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn add_app_access_restrictions(&self, owner: &str, repo: &str, branch: &str, body: PostReposAddAppAccessRestrictions) -> Result<Vec<Integration>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions/apps", super::GITHUB_BASE_API_URL, owner, repo, branch);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposAddAppAccessRestrictions>(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(ReposAddAppAccessRestrictionsError::Status422(github_response.to_json()?).into()),
code => Err(ReposAddAppAccessRestrictionsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Add a repository collaborator
///
/// Add a user to a repository with a specified level of access. If the repository is owned by an organization, this API does not add the user to the organization - a user that has repository access without being an organization member is called an "outside collaborator" (if they are not an Enterprise Managed User) or a "repository collaborator" if they are an Enterprise Managed User. These users are exempt from some organization policies - see "[Adding outside collaborators to repositories](https://docs.github.com/organizations/managing-user-access-to-your-organizations-repositories/managing-outside-collaborators/adding-outside-collaborators-to-repositories-in-your-organization)" to learn more about these collaborator types.
///
/// This endpoint triggers [notifications](https://docs.github.com/github/managing-subscriptions-and-notifications-on-github/about-notifications).
///
/// Adding an outside collaborator may be restricted by enterprise and organization 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)" and "[Setting permissions for adding outside collaborators](https://docs.github.com/organizations/managing-organization-settings/setting-permissions-for-adding-outside-collaborators)" for organization settings.
///
/// For more information on permission levels, see "[Repository permission levels for an organization](https://docs.github.com/github/setting-up-and-managing-organizations-and-teams/repository-permission-levels-for-an-organization#permission-levels-for-repositories-owned-by-an-organization)". There are restrictions on which permissions can be granted to organization members when an organization base role is in place. In this case, the role being given must be equal to or higher than the org base permission. Otherwise, the request will fail with:
///
/// ```nocompile
/// Cannot assign {member} permission of {role name}
/// ```
///
/// Note that, if you choose not to pass any parameters, you'll need to set `Content-Length` to zero when calling out to this endpoint. For more information, see "[HTTP method](https://docs.github.com/rest/guides/getting-started-with-the-rest-api#http-method)."
///
/// The invitee will receive a notification that they have been invited to the repository, which they must accept or decline. They may do this via the notifications page, the email they receive, or by using the [API](https://docs.github.com/rest/collaborators/invitations).
///
/// For Enterprise Managed Users, this endpoint does not send invitations - these users are automatically added to organizations and repositories. Enterprise Managed Users can only be added to organizations and repositories within their enterprise.
///
/// **Updating an existing collaborator's permission level**
///
/// The endpoint can also be used to change the permissions of an existing collaborator without first removing and re-adding the collaborator. To change the permissions, use the same endpoint and pass a different `permission` parameter. The response will be a `204`, with no other indication that the permission level changed.
///
/// **Rate limits**
///
/// You are limited to sending 50 invitations to a repository per 24 hour period. Note there is no limit if you are inviting organization members to an organization repository.
///
/// [GitHub API docs for add_collaborator](https://docs.github.com/rest/collaborators/collaborators#add-a-repository-collaborator)
///
/// ---
pub async fn add_collaborator_async(&self, owner: &str, repo: &str, username: &str, body: PutReposAddCollaborator) -> Result<RepositoryInvitation, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/collaborators/{}", super::GITHUB_BASE_API_URL, owner, repo, username);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutReposAddCollaborator>(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(ReposAddCollaboratorError::Status204.into()),
422 => Err(ReposAddCollaboratorError::Status422(github_response.to_json_async().await?).into()),
403 => Err(ReposAddCollaboratorError::Status403(github_response.to_json_async().await?).into()),
code => Err(ReposAddCollaboratorError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Add a repository collaborator
///
/// Add a user to a repository with a specified level of access. If the repository is owned by an organization, this API does not add the user to the organization - a user that has repository access without being an organization member is called an "outside collaborator" (if they are not an Enterprise Managed User) or a "repository collaborator" if they are an Enterprise Managed User. These users are exempt from some organization policies - see "[Adding outside collaborators to repositories](https://docs.github.com/organizations/managing-user-access-to-your-organizations-repositories/managing-outside-collaborators/adding-outside-collaborators-to-repositories-in-your-organization)" to learn more about these collaborator types.
///
/// This endpoint triggers [notifications](https://docs.github.com/github/managing-subscriptions-and-notifications-on-github/about-notifications).
///
/// Adding an outside collaborator may be restricted by enterprise and organization 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)" and "[Setting permissions for adding outside collaborators](https://docs.github.com/organizations/managing-organization-settings/setting-permissions-for-adding-outside-collaborators)" for organization settings.
///
/// For more information on permission levels, see "[Repository permission levels for an organization](https://docs.github.com/github/setting-up-and-managing-organizations-and-teams/repository-permission-levels-for-an-organization#permission-levels-for-repositories-owned-by-an-organization)". There are restrictions on which permissions can be granted to organization members when an organization base role is in place. In this case, the role being given must be equal to or higher than the org base permission. Otherwise, the request will fail with:
///
/// ```nocompile
/// Cannot assign {member} permission of {role name}
/// ```
///
/// Note that, if you choose not to pass any parameters, you'll need to set `Content-Length` to zero when calling out to this endpoint. For more information, see "[HTTP method](https://docs.github.com/rest/guides/getting-started-with-the-rest-api#http-method)."
///
/// The invitee will receive a notification that they have been invited to the repository, which they must accept or decline. They may do this via the notifications page, the email they receive, or by using the [API](https://docs.github.com/rest/collaborators/invitations).
///
/// For Enterprise Managed Users, this endpoint does not send invitations - these users are automatically added to organizations and repositories. Enterprise Managed Users can only be added to organizations and repositories within their enterprise.
///
/// **Updating an existing collaborator's permission level**
///
/// The endpoint can also be used to change the permissions of an existing collaborator without first removing and re-adding the collaborator. To change the permissions, use the same endpoint and pass a different `permission` parameter. The response will be a `204`, with no other indication that the permission level changed.
///
/// **Rate limits**
///
/// You are limited to sending 50 invitations to a repository per 24 hour period. Note there is no limit if you are inviting organization members to an organization repository.
///
/// [GitHub API docs for add_collaborator](https://docs.github.com/rest/collaborators/collaborators#add-a-repository-collaborator)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn add_collaborator(&self, owner: &str, repo: &str, username: &str, body: PutReposAddCollaborator) -> Result<RepositoryInvitation, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/collaborators/{}", super::GITHUB_BASE_API_URL, owner, repo, username);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutReposAddCollaborator>(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(ReposAddCollaboratorError::Status204.into()),
422 => Err(ReposAddCollaboratorError::Status422(github_response.to_json()?).into()),
403 => Err(ReposAddCollaboratorError::Status403(github_response.to_json()?).into()),
code => Err(ReposAddCollaboratorError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Add status check contexts
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// [GitHub API docs for add_status_check_contexts](https://docs.github.com/rest/branches/branch-protection#add-status-check-contexts)
///
/// ---
pub async fn add_status_check_contexts_async(&self, owner: &str, repo: &str, branch: &str, body: PostReposAddStatusCheckContexts) -> Result<Vec<String>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_status_checks/contexts", super::GITHUB_BASE_API_URL, owner, repo, branch);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposAddStatusCheckContexts>(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(ReposAddStatusCheckContextsError::Status422(github_response.to_json_async().await?).into()),
403 => Err(ReposAddStatusCheckContextsError::Status403(github_response.to_json_async().await?).into()),
404 => Err(ReposAddStatusCheckContextsError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposAddStatusCheckContextsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Add status check contexts
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// [GitHub API docs for add_status_check_contexts](https://docs.github.com/rest/branches/branch-protection#add-status-check-contexts)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn add_status_check_contexts(&self, owner: &str, repo: &str, branch: &str, body: PostReposAddStatusCheckContexts) -> Result<Vec<String>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_status_checks/contexts", super::GITHUB_BASE_API_URL, owner, repo, branch);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposAddStatusCheckContexts>(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(ReposAddStatusCheckContextsError::Status422(github_response.to_json()?).into()),
403 => Err(ReposAddStatusCheckContextsError::Status403(github_response.to_json()?).into()),
404 => Err(ReposAddStatusCheckContextsError::Status404(github_response.to_json()?).into()),
code => Err(ReposAddStatusCheckContextsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Add team access restrictions
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// Grants the specified teams push access for this branch. You can also give push access to child teams.
///
/// [GitHub API docs for add_team_access_restrictions](https://docs.github.com/rest/branches/branch-protection#add-team-access-restrictions)
///
/// ---
pub async fn add_team_access_restrictions_async(&self, owner: &str, repo: &str, branch: &str, body: PostReposAddTeamAccessRestrictions) -> Result<Vec<Team>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions/teams", super::GITHUB_BASE_API_URL, owner, repo, branch);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposAddTeamAccessRestrictions>(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(ReposAddTeamAccessRestrictionsError::Status422(github_response.to_json_async().await?).into()),
code => Err(ReposAddTeamAccessRestrictionsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Add team access restrictions
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// Grants the specified teams push access for this branch. You can also give push access to child teams.
///
/// [GitHub API docs for add_team_access_restrictions](https://docs.github.com/rest/branches/branch-protection#add-team-access-restrictions)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn add_team_access_restrictions(&self, owner: &str, repo: &str, branch: &str, body: PostReposAddTeamAccessRestrictions) -> Result<Vec<Team>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions/teams", super::GITHUB_BASE_API_URL, owner, repo, branch);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposAddTeamAccessRestrictions>(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(ReposAddTeamAccessRestrictionsError::Status422(github_response.to_json()?).into()),
code => Err(ReposAddTeamAccessRestrictionsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Add user access restrictions
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// Grants the specified people push access for this branch.
///
/// | Type | Description |
/// | ------- | ----------------------------------------------------------------------------------------------------------------------------- |
/// | `array` | Usernames for people who can have push access. **Note**: The list of users, apps, and teams in total is limited to 100 items. |
///
/// [GitHub API docs for add_user_access_restrictions](https://docs.github.com/rest/branches/branch-protection#add-user-access-restrictions)
///
/// ---
pub async fn add_user_access_restrictions_async(&self, owner: &str, repo: &str, branch: &str, body: PostReposAddUserAccessRestrictions) -> Result<Vec<SimpleUser>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions/users", super::GITHUB_BASE_API_URL, owner, repo, branch);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposAddUserAccessRestrictions>(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(ReposAddUserAccessRestrictionsError::Status422(github_response.to_json_async().await?).into()),
code => Err(ReposAddUserAccessRestrictionsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Add user access restrictions
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// Grants the specified people push access for this branch.
///
/// | Type | Description |
/// | ------- | ----------------------------------------------------------------------------------------------------------------------------- |
/// | `array` | Usernames for people who can have push access. **Note**: The list of users, apps, and teams in total is limited to 100 items. |
///
/// [GitHub API docs for add_user_access_restrictions](https://docs.github.com/rest/branches/branch-protection#add-user-access-restrictions)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn add_user_access_restrictions(&self, owner: &str, repo: &str, branch: &str, body: PostReposAddUserAccessRestrictions) -> Result<Vec<SimpleUser>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions/users", super::GITHUB_BASE_API_URL, owner, repo, branch);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposAddUserAccessRestrictions>(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(ReposAddUserAccessRestrictionsError::Status422(github_response.to_json()?).into()),
code => Err(ReposAddUserAccessRestrictionsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Cancel a GitHub Pages deployment
///
/// Cancels a GitHub Pages deployment.
///
/// The authenticated user must have write permissions for the GitHub Pages site.
///
/// [GitHub API docs for cancel_pages_deployment](https://docs.github.com/rest/pages/pages#cancel-a-github-pages-deployment)
///
/// ---
pub async fn cancel_pages_deployment_async(&self, owner: &str, repo: &str, pages_deployment_id: PagesDeploymentId) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pages/deployments/{}/cancel", super::GITHUB_BASE_API_URL, owner, repo, pages_deployment_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(ReposCancelPagesDeploymentError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposCancelPagesDeploymentError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Cancel a GitHub Pages deployment
///
/// Cancels a GitHub Pages deployment.
///
/// The authenticated user must have write permissions for the GitHub Pages site.
///
/// [GitHub API docs for cancel_pages_deployment](https://docs.github.com/rest/pages/pages#cancel-a-github-pages-deployment)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn cancel_pages_deployment(&self, owner: &str, repo: &str, pages_deployment_id: PagesDeploymentId) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pages/deployments/{}/cancel", super::GITHUB_BASE_API_URL, owner, repo, pages_deployment_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(ReposCancelPagesDeploymentError::Status404(github_response.to_json()?).into()),
code => Err(ReposCancelPagesDeploymentError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Check if Dependabot security updates are enabled for a repository
///
/// Shows whether Dependabot security updates are enabled, disabled or paused for a repository. The authenticated user must have admin read access to the repository. For more information, see "[Configuring Dependabot security updates](https://docs.github.com/articles/configuring-automated-security-fixes)".
///
/// [GitHub API docs for check_automated_security_fixes](https://docs.github.com/rest/repos/repos#check-if-dependabot-security-updates-are-enabled-for-a-repository)
///
/// ---
pub async fn check_automated_security_fixes_async(&self, owner: &str, repo: &str) -> Result<CheckAutomatedSecurityFixes, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/automated-security-fixes", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
404 => Err(ReposCheckAutomatedSecurityFixesError::Status404.into()),
code => Err(ReposCheckAutomatedSecurityFixesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Check if Dependabot security updates are enabled for a repository
///
/// Shows whether Dependabot security updates are enabled, disabled or paused for a repository. The authenticated user must have admin read access to the repository. For more information, see "[Configuring Dependabot security updates](https://docs.github.com/articles/configuring-automated-security-fixes)".
///
/// [GitHub API docs for check_automated_security_fixes](https://docs.github.com/rest/repos/repos#check-if-dependabot-security-updates-are-enabled-for-a-repository)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn check_automated_security_fixes(&self, owner: &str, repo: &str) -> Result<CheckAutomatedSecurityFixes, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/automated-security-fixes", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
404 => Err(ReposCheckAutomatedSecurityFixesError::Status404.into()),
code => Err(ReposCheckAutomatedSecurityFixesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Check if a user is a repository collaborator
///
/// For organization-owned repositories, the list of collaborators includes outside collaborators, organization members that are direct collaborators, organization members with access through team memberships, organization members with access through default organization permissions, and organization owners.
///
/// Team members will include the members of child teams.
///
/// The authenticated user must have push access to the repository to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:org` and `repo` scopes to use this endpoint.
///
/// [GitHub API docs for check_collaborator](https://docs.github.com/rest/collaborators/collaborators#check-if-a-user-is-a-repository-collaborator)
///
/// ---
pub async fn check_collaborator_async(&self, owner: &str, repo: &str, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/collaborators/{}", super::GITHUB_BASE_API_URL, owner, repo, 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(ReposCheckCollaboratorError::Status404.into()),
code => Err(ReposCheckCollaboratorError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Check if a user is a repository collaborator
///
/// For organization-owned repositories, the list of collaborators includes outside collaborators, organization members that are direct collaborators, organization members with access through team memberships, organization members with access through default organization permissions, and organization owners.
///
/// Team members will include the members of child teams.
///
/// The authenticated user must have push access to the repository to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:org` and `repo` scopes to use this endpoint.
///
/// [GitHub API docs for check_collaborator](https://docs.github.com/rest/collaborators/collaborators#check-if-a-user-is-a-repository-collaborator)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn check_collaborator(&self, owner: &str, repo: &str, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/collaborators/{}", super::GITHUB_BASE_API_URL, owner, repo, 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(ReposCheckCollaboratorError::Status404.into()),
code => Err(ReposCheckCollaboratorError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Check if private vulnerability reporting is enabled for a repository
///
/// Returns a boolean indicating whether or not private vulnerability reporting is enabled for the repository. For more information, see "[Evaluating the security settings of a repository](https://docs.github.com/code-security/security-advisories/working-with-repository-security-advisories/evaluating-the-security-settings-of-a-repository)".
///
/// [GitHub API docs for check_private_vulnerability_reporting](https://docs.github.com/rest/repos/repos#check-if-private-vulnerability-reporting-is-enabled-for-a-repository)
///
/// ---
pub async fn check_private_vulnerability_reporting_async(&self, owner: &str, repo: &str) -> Result<GetReposCheckPrivateVulnerabilityReportingResponse200, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/private-vulnerability-reporting", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
422 => Err(ReposCheckPrivateVulnerabilityReportingError::Status422(github_response.to_json_async().await?).into()),
code => Err(ReposCheckPrivateVulnerabilityReportingError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Check if private vulnerability reporting is enabled for a repository
///
/// Returns a boolean indicating whether or not private vulnerability reporting is enabled for the repository. For more information, see "[Evaluating the security settings of a repository](https://docs.github.com/code-security/security-advisories/working-with-repository-security-advisories/evaluating-the-security-settings-of-a-repository)".
///
/// [GitHub API docs for check_private_vulnerability_reporting](https://docs.github.com/rest/repos/repos#check-if-private-vulnerability-reporting-is-enabled-for-a-repository)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn check_private_vulnerability_reporting(&self, owner: &str, repo: &str) -> Result<GetReposCheckPrivateVulnerabilityReportingResponse200, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/private-vulnerability-reporting", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
422 => Err(ReposCheckPrivateVulnerabilityReportingError::Status422(github_response.to_json()?).into()),
code => Err(ReposCheckPrivateVulnerabilityReportingError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Check if vulnerability alerts are enabled for a repository
///
/// Shows whether dependency alerts are enabled or disabled for a repository. The authenticated user must have admin read access to the repository. For more information, see "[About security alerts for vulnerable dependencies](https://docs.github.com/articles/about-security-alerts-for-vulnerable-dependencies)".
///
/// [GitHub API docs for check_vulnerability_alerts](https://docs.github.com/rest/repos/repos#check-if-vulnerability-alerts-are-enabled-for-a-repository)
///
/// ---
pub async fn check_vulnerability_alerts_async(&self, owner: &str, repo: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/vulnerability-alerts", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
404 => Err(ReposCheckVulnerabilityAlertsError::Status404.into()),
code => Err(ReposCheckVulnerabilityAlertsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Check if vulnerability alerts are enabled for a repository
///
/// Shows whether dependency alerts are enabled or disabled for a repository. The authenticated user must have admin read access to the repository. For more information, see "[About security alerts for vulnerable dependencies](https://docs.github.com/articles/about-security-alerts-for-vulnerable-dependencies)".
///
/// [GitHub API docs for check_vulnerability_alerts](https://docs.github.com/rest/repos/repos#check-if-vulnerability-alerts-are-enabled-for-a-repository)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn check_vulnerability_alerts(&self, owner: &str, repo: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/vulnerability-alerts", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
404 => Err(ReposCheckVulnerabilityAlertsError::Status404.into()),
code => Err(ReposCheckVulnerabilityAlertsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List CODEOWNERS errors
///
/// List any syntax errors that are detected in the CODEOWNERS
/// file.
///
/// For more information about the correct CODEOWNERS syntax,
/// see "[About code owners](https://docs.github.com/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners)."
///
/// [GitHub API docs for codeowners_errors](https://docs.github.com/rest/repos/repos#list-codeowners-errors)
///
/// ---
pub async fn codeowners_errors_async(&self, owner: &str, repo: &str, query_params: Option<impl Into<ReposCodeownersErrorsParams<'api>>>) -> Result<CodeownersErrors, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/codeowners/errors", super::GITHUB_BASE_API_URL, owner, repo);
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(ReposCodeownersErrorsError::Status404.into()),
code => Err(ReposCodeownersErrorsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List CODEOWNERS errors
///
/// List any syntax errors that are detected in the CODEOWNERS
/// file.
///
/// For more information about the correct CODEOWNERS syntax,
/// see "[About code owners](https://docs.github.com/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners)."
///
/// [GitHub API docs for codeowners_errors](https://docs.github.com/rest/repos/repos#list-codeowners-errors)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn codeowners_errors(&self, owner: &str, repo: &str, query_params: Option<impl Into<ReposCodeownersErrorsParams<'api>>>) -> Result<CodeownersErrors, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/codeowners/errors", super::GITHUB_BASE_API_URL, owner, repo);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: ReposCodeownersErrorsParams = 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(ReposCodeownersErrorsError::Status404.into()),
code => Err(ReposCodeownersErrorsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Compare two commits
///
/// Compares two commits against one another. You can compare refs (branches or tags) and commit SHAs in the same repository, or you can compare refs and commit SHAs that exist in different repositories within the same repository network, including fork branches. For more information about how to view a repository's network, see "[Understanding connections between repositories](https://docs.github.com/repositories/viewing-activity-and-data-for-your-repository/understanding-connections-between-repositories)."
///
/// This endpoint is equivalent to running the `git log BASE..HEAD` command, but it returns commits in a different order. The `git log BASE..HEAD` command returns commits in reverse chronological order, whereas the API returns commits in chronological order.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github.diff`**: Returns the diff of the commit.
/// - **`application/vnd.github.patch`**: Returns the patch of the commit. Diffs with binary data will have no `patch` property.
///
/// The API response includes details about the files that were changed between the two commits. This includes the status of the change (if a file was added, removed, modified, or renamed), and details of the change itself. For example, files with a `renamed` status have a `previous_filename` field showing the previous filename of the file, and files with a `modified` status have a `patch` field showing the changes made to the file.
///
/// When calling this endpoint without any paging parameter (`per_page` or `page`), the returned list is limited to 250 commits, and the last commit in the list is the most recent of the entire comparison.
///
/// **Working with large comparisons**
///
/// To process a response with a large number of commits, use a query parameter (`per_page` or `page`) to paginate the results. When using pagination:
///
/// - The list of changed files is only shown on the first page of results, and it includes up to 300 changed files for the entire comparison.
/// - The results are returned in chronological order, but the last commit in the returned list may not be the most recent one in the entire set if there are more pages of results.
///
/// For more information on working with pagination, see "[Using pagination in the REST API](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api)."
///
/// **Signature verification object**
///
/// The response will include a `verification` object that describes the result of verifying the commit's signature. The `verification` object includes the following fields:
///
/// | Name | Type | Description |
/// | ---- | ---- | ----------- |
/// | `verified` | `boolean` | Indicates whether GitHub considers the signature in this commit to be verified. |
/// | `reason` | `string` | The reason for verified value. Possible values and their meanings are enumerated in table below. |
/// | `signature` | `string` | The signature that was extracted from the commit. |
/// | `payload` | `string` | The value that was signed. |
/// | `verified_at` | `string` | The date the signature was verified by GitHub. |
///
/// These are the possible values for `reason` in the `verification` object:
///
/// | Value | Description |
/// | ----- | ----------- |
/// | `expired_key` | The key that made the signature is expired. |
/// | `not_signing_key` | The "signing" flag is not among the usage flags in the GPG key that made the signature. |
/// | `gpgverify_error` | There was an error communicating with the signature verification service. |
/// | `gpgverify_unavailable` | The signature verification service is currently unavailable. |
/// | `unsigned` | The object does not include a signature. |
/// | `unknown_signature_type` | A non-PGP signature was found in the commit. |
/// | `no_user` | No user was associated with the `committer` email address in the commit. |
/// | `unverified_email` | The `committer` email address in the commit was associated with a user, but the email address is not verified on their account. |
/// | `bad_email` | The `committer` email address in the commit is not included in the identities of the PGP key that made the signature. |
/// | `unknown_key` | The key that made the signature has not been registered with any user's account. |
/// | `malformed_signature` | There was an error parsing the signature. |
/// | `invalid` | The signature could not be cryptographically verified using the key whose key-id was found in the signature. |
/// | `valid` | None of the above errors applied, so the signature is considered to be verified. |
///
/// [GitHub API docs for compare_commits](https://docs.github.com/rest/commits/commits#compare-two-commits)
///
/// ---
pub async fn compare_commits_async(&self, owner: &str, repo: &str, basehead: &str, query_params: Option<impl Into<ReposCompareCommitsParams>>) -> Result<CommitComparison, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/compare/{}", super::GITHUB_BASE_API_URL, owner, repo, basehead);
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(ReposCompareCommitsError::Status404(github_response.to_json_async().await?).into()),
500 => Err(ReposCompareCommitsError::Status500(github_response.to_json_async().await?).into()),
503 => Err(ReposCompareCommitsError::Status503(github_response.to_json_async().await?).into()),
code => Err(ReposCompareCommitsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Compare two commits
///
/// Compares two commits against one another. You can compare refs (branches or tags) and commit SHAs in the same repository, or you can compare refs and commit SHAs that exist in different repositories within the same repository network, including fork branches. For more information about how to view a repository's network, see "[Understanding connections between repositories](https://docs.github.com/repositories/viewing-activity-and-data-for-your-repository/understanding-connections-between-repositories)."
///
/// This endpoint is equivalent to running the `git log BASE..HEAD` command, but it returns commits in a different order. The `git log BASE..HEAD` command returns commits in reverse chronological order, whereas the API returns commits in chronological order.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github.diff`**: Returns the diff of the commit.
/// - **`application/vnd.github.patch`**: Returns the patch of the commit. Diffs with binary data will have no `patch` property.
///
/// The API response includes details about the files that were changed between the two commits. This includes the status of the change (if a file was added, removed, modified, or renamed), and details of the change itself. For example, files with a `renamed` status have a `previous_filename` field showing the previous filename of the file, and files with a `modified` status have a `patch` field showing the changes made to the file.
///
/// When calling this endpoint without any paging parameter (`per_page` or `page`), the returned list is limited to 250 commits, and the last commit in the list is the most recent of the entire comparison.
///
/// **Working with large comparisons**
///
/// To process a response with a large number of commits, use a query parameter (`per_page` or `page`) to paginate the results. When using pagination:
///
/// - The list of changed files is only shown on the first page of results, and it includes up to 300 changed files for the entire comparison.
/// - The results are returned in chronological order, but the last commit in the returned list may not be the most recent one in the entire set if there are more pages of results.
///
/// For more information on working with pagination, see "[Using pagination in the REST API](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api)."
///
/// **Signature verification object**
///
/// The response will include a `verification` object that describes the result of verifying the commit's signature. The `verification` object includes the following fields:
///
/// | Name | Type | Description |
/// | ---- | ---- | ----------- |
/// | `verified` | `boolean` | Indicates whether GitHub considers the signature in this commit to be verified. |
/// | `reason` | `string` | The reason for verified value. Possible values and their meanings are enumerated in table below. |
/// | `signature` | `string` | The signature that was extracted from the commit. |
/// | `payload` | `string` | The value that was signed. |
/// | `verified_at` | `string` | The date the signature was verified by GitHub. |
///
/// These are the possible values for `reason` in the `verification` object:
///
/// | Value | Description |
/// | ----- | ----------- |
/// | `expired_key` | The key that made the signature is expired. |
/// | `not_signing_key` | The "signing" flag is not among the usage flags in the GPG key that made the signature. |
/// | `gpgverify_error` | There was an error communicating with the signature verification service. |
/// | `gpgverify_unavailable` | The signature verification service is currently unavailable. |
/// | `unsigned` | The object does not include a signature. |
/// | `unknown_signature_type` | A non-PGP signature was found in the commit. |
/// | `no_user` | No user was associated with the `committer` email address in the commit. |
/// | `unverified_email` | The `committer` email address in the commit was associated with a user, but the email address is not verified on their account. |
/// | `bad_email` | The `committer` email address in the commit is not included in the identities of the PGP key that made the signature. |
/// | `unknown_key` | The key that made the signature has not been registered with any user's account. |
/// | `malformed_signature` | There was an error parsing the signature. |
/// | `invalid` | The signature could not be cryptographically verified using the key whose key-id was found in the signature. |
/// | `valid` | None of the above errors applied, so the signature is considered to be verified. |
///
/// [GitHub API docs for compare_commits](https://docs.github.com/rest/commits/commits#compare-two-commits)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn compare_commits(&self, owner: &str, repo: &str, basehead: &str, query_params: Option<impl Into<ReposCompareCommitsParams>>) -> Result<CommitComparison, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/compare/{}", super::GITHUB_BASE_API_URL, owner, repo, basehead);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: ReposCompareCommitsParams = 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(ReposCompareCommitsError::Status404(github_response.to_json()?).into()),
500 => Err(ReposCompareCommitsError::Status500(github_response.to_json()?).into()),
503 => Err(ReposCompareCommitsError::Status503(github_response.to_json()?).into()),
code => Err(ReposCompareCommitsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create an attestation
///
/// Store an artifact attestation and associate it with a repository.
///
/// The authenticated user must have write permission to the repository and, if using a fine-grained access token, the `attestations:write` permission is required.
///
/// Artifact attestations are meant to be created using the [attest action](https://github.com/actions/attest). For more information, see our guide on [using 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 create_attestation](https://docs.github.com/rest/repos/repos#create-an-attestation)
///
/// ---
pub async fn create_attestation_async(&self, owner: &str, repo: &str, body: PostReposCreateAttestation) -> Result<PostReposCreateAttestationResponse201, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/attestations", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposCreateAttestation>(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() {
403 => Err(ReposCreateAttestationError::Status403(github_response.to_json_async().await?).into()),
422 => Err(ReposCreateAttestationError::Status422(github_response.to_json_async().await?).into()),
code => Err(ReposCreateAttestationError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create an attestation
///
/// Store an artifact attestation and associate it with a repository.
///
/// The authenticated user must have write permission to the repository and, if using a fine-grained access token, the `attestations:write` permission is required.
///
/// Artifact attestations are meant to be created using the [attest action](https://github.com/actions/attest). For more information, see our guide on [using 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 create_attestation](https://docs.github.com/rest/repos/repos#create-an-attestation)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn create_attestation(&self, owner: &str, repo: &str, body: PostReposCreateAttestation) -> Result<PostReposCreateAttestationResponse201, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/attestations", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposCreateAttestation>(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() {
403 => Err(ReposCreateAttestationError::Status403(github_response.to_json()?).into()),
422 => Err(ReposCreateAttestationError::Status422(github_response.to_json()?).into()),
code => Err(ReposCreateAttestationError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create an autolink reference for a repository
///
/// Users with admin access to the repository can create an autolink.
///
/// [GitHub API docs for create_autolink](https://docs.github.com/rest/repos/autolinks#create-an-autolink-reference-for-a-repository)
///
/// ---
pub async fn create_autolink_async(&self, owner: &str, repo: &str, body: PostReposCreateAutolink) -> Result<Autolink, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/autolinks", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposCreateAutolink>(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(ReposCreateAutolinkError::Status422(github_response.to_json_async().await?).into()),
code => Err(ReposCreateAutolinkError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create an autolink reference for a repository
///
/// Users with admin access to the repository can create an autolink.
///
/// [GitHub API docs for create_autolink](https://docs.github.com/rest/repos/autolinks#create-an-autolink-reference-for-a-repository)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn create_autolink(&self, owner: &str, repo: &str, body: PostReposCreateAutolink) -> Result<Autolink, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/autolinks", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposCreateAutolink>(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(ReposCreateAutolinkError::Status422(github_response.to_json()?).into()),
code => Err(ReposCreateAutolinkError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a commit comment
///
/// Create a comment for a commit using its `:commit_sha`.
///
/// 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)."
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
///
/// [GitHub API docs for create_commit_comment](https://docs.github.com/rest/commits/comments#create-a-commit-comment)
///
/// ---
pub async fn create_commit_comment_async(&self, owner: &str, repo: &str, commit_sha: &str, body: PostReposCreateCommitComment) -> Result<CommitComment, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/commits/{}/comments", super::GITHUB_BASE_API_URL, owner, repo, commit_sha);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposCreateCommitComment>(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() {
403 => Err(ReposCreateCommitCommentError::Status403(github_response.to_json_async().await?).into()),
422 => Err(ReposCreateCommitCommentError::Status422(github_response.to_json_async().await?).into()),
code => Err(ReposCreateCommitCommentError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a commit comment
///
/// Create a comment for a commit using its `:commit_sha`.
///
/// 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)."
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
///
/// [GitHub API docs for create_commit_comment](https://docs.github.com/rest/commits/comments#create-a-commit-comment)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn create_commit_comment(&self, owner: &str, repo: &str, commit_sha: &str, body: PostReposCreateCommitComment) -> Result<CommitComment, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/commits/{}/comments", super::GITHUB_BASE_API_URL, owner, repo, commit_sha);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposCreateCommitComment>(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() {
403 => Err(ReposCreateCommitCommentError::Status403(github_response.to_json()?).into()),
422 => Err(ReposCreateCommitCommentError::Status422(github_response.to_json()?).into()),
code => Err(ReposCreateCommitCommentError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create commit signature protection
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// When authenticated with admin or owner permissions to the repository, you can use this endpoint to require signed commits on a branch. You must enable branch protection to require signed commits.
///
/// [GitHub API docs for create_commit_signature_protection](https://docs.github.com/rest/branches/branch-protection#create-commit-signature-protection)
///
/// ---
pub async fn create_commit_signature_protection_async(&self, owner: &str, repo: &str, branch: &str) -> Result<ProtectedBranchAdminEnforced, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_signatures", super::GITHUB_BASE_API_URL, owner, repo, branch);
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() {
404 => Err(ReposCreateCommitSignatureProtectionError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposCreateCommitSignatureProtectionError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create commit signature protection
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// When authenticated with admin or owner permissions to the repository, you can use this endpoint to require signed commits on a branch. You must enable branch protection to require signed commits.
///
/// [GitHub API docs for create_commit_signature_protection](https://docs.github.com/rest/branches/branch-protection#create-commit-signature-protection)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn create_commit_signature_protection(&self, owner: &str, repo: &str, branch: &str) -> Result<ProtectedBranchAdminEnforced, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_signatures", super::GITHUB_BASE_API_URL, owner, repo, branch);
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() {
404 => Err(ReposCreateCommitSignatureProtectionError::Status404(github_response.to_json()?).into()),
code => Err(ReposCreateCommitSignatureProtectionError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a commit status
///
/// Users with push access in a repository can create commit statuses for a given SHA.
///
/// Note: there is a limit of 1000 statuses per `sha` and `context` within a repository. Attempts to create more than 1000 statuses will result in a validation error.
///
/// [GitHub API docs for create_commit_status](https://docs.github.com/rest/commits/statuses#create-a-commit-status)
///
/// ---
pub async fn create_commit_status_async(&self, owner: &str, repo: &str, sha: &str, body: PostReposCreateCommitStatus) -> Result<Status, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/statuses/{}", super::GITHUB_BASE_API_URL, owner, repo, sha);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposCreateCommitStatus>(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(ReposCreateCommitStatusError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a commit status
///
/// Users with push access in a repository can create commit statuses for a given SHA.
///
/// Note: there is a limit of 1000 statuses per `sha` and `context` within a repository. Attempts to create more than 1000 statuses will result in a validation error.
///
/// [GitHub API docs for create_commit_status](https://docs.github.com/rest/commits/statuses#create-a-commit-status)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn create_commit_status(&self, owner: &str, repo: &str, sha: &str, body: PostReposCreateCommitStatus) -> Result<Status, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/statuses/{}", super::GITHUB_BASE_API_URL, owner, repo, sha);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposCreateCommitStatus>(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(ReposCreateCommitStatusError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a deploy key
///
/// You can create a read-only deploy key.
///
/// [GitHub API docs for create_deploy_key](https://docs.github.com/rest/deploy-keys/deploy-keys#create-a-deploy-key)
///
/// ---
pub async fn create_deploy_key_async(&self, owner: &str, repo: &str, body: PostReposCreateDeployKey) -> Result<DeployKey, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/keys", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposCreateDeployKey>(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(ReposCreateDeployKeyError::Status422(github_response.to_json_async().await?).into()),
code => Err(ReposCreateDeployKeyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a deploy key
///
/// You can create a read-only deploy key.
///
/// [GitHub API docs for create_deploy_key](https://docs.github.com/rest/deploy-keys/deploy-keys#create-a-deploy-key)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn create_deploy_key(&self, owner: &str, repo: &str, body: PostReposCreateDeployKey) -> Result<DeployKey, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/keys", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposCreateDeployKey>(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(ReposCreateDeployKeyError::Status422(github_response.to_json()?).into()),
code => Err(ReposCreateDeployKeyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a deployment
///
/// Deployments offer a few configurable parameters with certain defaults.
///
/// The `ref` parameter can be any named branch, tag, or SHA. At GitHub we often deploy branches and verify them
/// before we merge a pull request.
///
/// The `environment` parameter allows deployments to be issued to different runtime environments. Teams often have
/// multiple environments for verifying their applications, such as `production`, `staging`, and `qa`. This parameter
/// makes it easier to track which environments have requested deployments. The default environment is `production`.
///
/// The `auto_merge` parameter is used to ensure that the requested ref is not behind the repository's default branch. If
/// the ref _is_ behind the default branch for the repository, we will attempt to merge it for you. If the merge succeeds,
/// the API will return a successful merge commit. If merge conflicts prevent the merge from succeeding, the API will
/// return a failure response.
///
/// By default, [commit statuses](https://docs.github.com/rest/commits/statuses) for every submitted context must be in a `success`
/// state. The `required_contexts` parameter allows you to specify a subset of contexts that must be `success`, or to
/// specify contexts that have not yet been submitted. You are not required to use commit statuses to deploy. If you do
/// not require any contexts or create any commit statuses, the deployment will always succeed.
///
/// The `payload` parameter is available for any extra information that a deployment system might need. It is a JSON text
/// field that will be passed on when a deployment event is dispatched.
///
/// The `task` parameter is used by the deployment system to allow different execution paths. In the web world this might
/// be `deploy:migrations` to run schema changes on the system. In the compiled world this could be a flag to compile an
/// application with debugging enabled.
///
/// Merged branch response:
///
/// You will see this response when GitHub automatically merges the base branch into the topic branch instead of creating
/// a deployment. This auto-merge happens when:
/// * Auto-merge option is enabled in the repository
/// * Topic branch does not include the latest changes on the base branch, which is `master` in the response example
/// * There are no merge conflicts
///
/// If there are no new commits in the base branch, a new request to create a deployment should give a successful
/// response.
///
/// Merge conflict response:
///
/// This error happens when the `auto_merge` option is enabled and when the default branch (in this case `master`), can't
/// be merged into the branch that's being deployed (in this case `topic-branch`), due to merge conflicts.
///
/// Failed commit status checks:
///
/// This error happens when the `required_contexts` parameter indicates that one or more contexts need to have a `success`
/// status for the commit to be deployed, but one or more of the required contexts do not have a state of `success`.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` or `repo_deployment` scope to use this endpoint.
///
/// [GitHub API docs for create_deployment](https://docs.github.com/rest/deployments/deployments#create-a-deployment)
///
/// ---
pub async fn create_deployment_async(&self, owner: &str, repo: &str, body: PostReposCreateDeployment) -> Result<Deployment, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/deployments", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposCreateDeployment>(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() {
202 => Err(ReposCreateDeploymentError::Status202(github_response.to_json_async().await?).into()),
409 => Err(ReposCreateDeploymentError::Status409.into()),
422 => Err(ReposCreateDeploymentError::Status422(github_response.to_json_async().await?).into()),
code => Err(ReposCreateDeploymentError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a deployment
///
/// Deployments offer a few configurable parameters with certain defaults.
///
/// The `ref` parameter can be any named branch, tag, or SHA. At GitHub we often deploy branches and verify them
/// before we merge a pull request.
///
/// The `environment` parameter allows deployments to be issued to different runtime environments. Teams often have
/// multiple environments for verifying their applications, such as `production`, `staging`, and `qa`. This parameter
/// makes it easier to track which environments have requested deployments. The default environment is `production`.
///
/// The `auto_merge` parameter is used to ensure that the requested ref is not behind the repository's default branch. If
/// the ref _is_ behind the default branch for the repository, we will attempt to merge it for you. If the merge succeeds,
/// the API will return a successful merge commit. If merge conflicts prevent the merge from succeeding, the API will
/// return a failure response.
///
/// By default, [commit statuses](https://docs.github.com/rest/commits/statuses) for every submitted context must be in a `success`
/// state. The `required_contexts` parameter allows you to specify a subset of contexts that must be `success`, or to
/// specify contexts that have not yet been submitted. You are not required to use commit statuses to deploy. If you do
/// not require any contexts or create any commit statuses, the deployment will always succeed.
///
/// The `payload` parameter is available for any extra information that a deployment system might need. It is a JSON text
/// field that will be passed on when a deployment event is dispatched.
///
/// The `task` parameter is used by the deployment system to allow different execution paths. In the web world this might
/// be `deploy:migrations` to run schema changes on the system. In the compiled world this could be a flag to compile an
/// application with debugging enabled.
///
/// Merged branch response:
///
/// You will see this response when GitHub automatically merges the base branch into the topic branch instead of creating
/// a deployment. This auto-merge happens when:
/// * Auto-merge option is enabled in the repository
/// * Topic branch does not include the latest changes on the base branch, which is `master` in the response example
/// * There are no merge conflicts
///
/// If there are no new commits in the base branch, a new request to create a deployment should give a successful
/// response.
///
/// Merge conflict response:
///
/// This error happens when the `auto_merge` option is enabled and when the default branch (in this case `master`), can't
/// be merged into the branch that's being deployed (in this case `topic-branch`), due to merge conflicts.
///
/// Failed commit status checks:
///
/// This error happens when the `required_contexts` parameter indicates that one or more contexts need to have a `success`
/// status for the commit to be deployed, but one or more of the required contexts do not have a state of `success`.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` or `repo_deployment` scope to use this endpoint.
///
/// [GitHub API docs for create_deployment](https://docs.github.com/rest/deployments/deployments#create-a-deployment)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn create_deployment(&self, owner: &str, repo: &str, body: PostReposCreateDeployment) -> Result<Deployment, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/deployments", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposCreateDeployment>(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() {
202 => Err(ReposCreateDeploymentError::Status202(github_response.to_json()?).into()),
409 => Err(ReposCreateDeploymentError::Status409.into()),
422 => Err(ReposCreateDeploymentError::Status422(github_response.to_json()?).into()),
code => Err(ReposCreateDeploymentError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a deployment branch policy
///
/// Creates a deployment branch or tag policy for an environment.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.
///
/// [GitHub API docs for create_deployment_branch_policy](https://docs.github.com/rest/deployments/branch-policies#create-a-deployment-branch-policy)
///
/// ---
pub async fn create_deployment_branch_policy_async(&self, owner: &str, repo: &str, environment_name: &str, body: PostReposCreateDeploymentBranchPolicy) -> Result<DeploymentBranchPolicy, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/environments/{}/deployment-branch-policies", super::GITHUB_BASE_API_URL, owner, repo, environment_name);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposCreateDeploymentBranchPolicy>(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(ReposCreateDeploymentBranchPolicyError::Status404.into()),
303 => Err(ReposCreateDeploymentBranchPolicyError::Status303.into()),
code => Err(ReposCreateDeploymentBranchPolicyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a deployment branch policy
///
/// Creates a deployment branch or tag policy for an environment.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.
///
/// [GitHub API docs for create_deployment_branch_policy](https://docs.github.com/rest/deployments/branch-policies#create-a-deployment-branch-policy)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn create_deployment_branch_policy(&self, owner: &str, repo: &str, environment_name: &str, body: PostReposCreateDeploymentBranchPolicy) -> Result<DeploymentBranchPolicy, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/environments/{}/deployment-branch-policies", super::GITHUB_BASE_API_URL, owner, repo, environment_name);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposCreateDeploymentBranchPolicy>(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(ReposCreateDeploymentBranchPolicyError::Status404.into()),
303 => Err(ReposCreateDeploymentBranchPolicyError::Status303.into()),
code => Err(ReposCreateDeploymentBranchPolicyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a custom deployment protection rule on an environment
///
/// Enable a custom deployment protection rule for an environment.
///
/// The authenticated user must have admin or owner permissions to the repository to use this endpoint.
///
/// For more information about the app that is providing this custom deployment rule, see the [documentation for the `GET /apps/{app_slug}` endpoint](https://docs.github.com/rest/apps/apps#get-an-app), as well as the [guide to creating custom deployment protection rules](https://docs.github.com/actions/managing-workflow-runs-and-deployments/managing-deployments/creating-custom-deployment-protection-rules).
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.
///
/// [GitHub API docs for create_deployment_protection_rule](https://docs.github.com/rest/deployments/protection-rules#create-a-custom-deployment-protection-rule-on-an-environment)
///
/// ---
pub async fn create_deployment_protection_rule_async(&self, environment_name: &str, repo: &str, owner: &str, body: PostReposCreateDeploymentProtectionRule) -> Result<DeploymentProtectionRule, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/environments/{}/deployment_protection_rules", super::GITHUB_BASE_API_URL, environment_name, repo, owner);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposCreateDeploymentProtectionRule>(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(ReposCreateDeploymentProtectionRuleError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a custom deployment protection rule on an environment
///
/// Enable a custom deployment protection rule for an environment.
///
/// The authenticated user must have admin or owner permissions to the repository to use this endpoint.
///
/// For more information about the app that is providing this custom deployment rule, see the [documentation for the `GET /apps/{app_slug}` endpoint](https://docs.github.com/rest/apps/apps#get-an-app), as well as the [guide to creating custom deployment protection rules](https://docs.github.com/actions/managing-workflow-runs-and-deployments/managing-deployments/creating-custom-deployment-protection-rules).
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.
///
/// [GitHub API docs for create_deployment_protection_rule](https://docs.github.com/rest/deployments/protection-rules#create-a-custom-deployment-protection-rule-on-an-environment)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn create_deployment_protection_rule(&self, environment_name: &str, repo: &str, owner: &str, body: PostReposCreateDeploymentProtectionRule) -> Result<DeploymentProtectionRule, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/environments/{}/deployment_protection_rules", super::GITHUB_BASE_API_URL, environment_name, repo, owner);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposCreateDeploymentProtectionRule>(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(ReposCreateDeploymentProtectionRuleError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a deployment status
///
/// Users with `push` access can create deployment statuses for a given deployment.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo_deployment` scope to use this endpoint.
///
/// [GitHub API docs for create_deployment_status](https://docs.github.com/rest/deployments/statuses#create-a-deployment-status)
///
/// ---
pub async fn create_deployment_status_async(&self, owner: &str, repo: &str, deployment_id: i32, body: PostReposCreateDeploymentStatus) -> Result<DeploymentStatus, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/deployments/{}/statuses", super::GITHUB_BASE_API_URL, owner, repo, deployment_id);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposCreateDeploymentStatus>(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(ReposCreateDeploymentStatusError::Status422(github_response.to_json_async().await?).into()),
code => Err(ReposCreateDeploymentStatusError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a deployment status
///
/// Users with `push` access can create deployment statuses for a given deployment.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo_deployment` scope to use this endpoint.
///
/// [GitHub API docs for create_deployment_status](https://docs.github.com/rest/deployments/statuses#create-a-deployment-status)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn create_deployment_status(&self, owner: &str, repo: &str, deployment_id: i32, body: PostReposCreateDeploymentStatus) -> Result<DeploymentStatus, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/deployments/{}/statuses", super::GITHUB_BASE_API_URL, owner, repo, deployment_id);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposCreateDeploymentStatus>(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(ReposCreateDeploymentStatusError::Status422(github_response.to_json()?).into()),
code => Err(ReposCreateDeploymentStatusError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a repository dispatch event
///
/// You can use this endpoint to trigger a webhook event called `repository_dispatch` when you want activity that happens outside of GitHub to trigger a GitHub Actions workflow or GitHub App webhook. You must configure your GitHub Actions workflow or GitHub App to run when the `repository_dispatch` event occurs. For an example `repository_dispatch` webhook payload, see "[RepositoryDispatchEvent](https://docs.github.com/webhooks/event-payloads/#repository_dispatch)."
///
/// The `client_payload` parameter is available for any extra information that your workflow might need. This parameter is a JSON payload that will be passed on when the webhook event is dispatched. For example, the `client_payload` can include a message that a user would like to send using a GitHub Actions workflow. Or the `client_payload` can be used as a test to debug your workflow.
///
/// This input example shows how you can use the `client_payload` as a test to debug your workflow.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.
///
/// [GitHub API docs for create_dispatch_event](https://docs.github.com/rest/repos/repos#create-a-repository-dispatch-event)
///
/// ---
pub async fn create_dispatch_event_async(&self, owner: &str, repo: &str, body: PostReposCreateDispatchEvent) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/dispatches", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposCreateDispatchEvent>(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(ReposCreateDispatchEventError::Status404(github_response.to_json_async().await?).into()),
422 => Err(ReposCreateDispatchEventError::Status422(github_response.to_json_async().await?).into()),
code => Err(ReposCreateDispatchEventError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a repository dispatch event
///
/// You can use this endpoint to trigger a webhook event called `repository_dispatch` when you want activity that happens outside of GitHub to trigger a GitHub Actions workflow or GitHub App webhook. You must configure your GitHub Actions workflow or GitHub App to run when the `repository_dispatch` event occurs. For an example `repository_dispatch` webhook payload, see "[RepositoryDispatchEvent](https://docs.github.com/webhooks/event-payloads/#repository_dispatch)."
///
/// The `client_payload` parameter is available for any extra information that your workflow might need. This parameter is a JSON payload that will be passed on when the webhook event is dispatched. For example, the `client_payload` can include a message that a user would like to send using a GitHub Actions workflow. Or the `client_payload` can be used as a test to debug your workflow.
///
/// This input example shows how you can use the `client_payload` as a test to debug your workflow.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.
///
/// [GitHub API docs for create_dispatch_event](https://docs.github.com/rest/repos/repos#create-a-repository-dispatch-event)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn create_dispatch_event(&self, owner: &str, repo: &str, body: PostReposCreateDispatchEvent) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/dispatches", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposCreateDispatchEvent>(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(ReposCreateDispatchEventError::Status404(github_response.to_json()?).into()),
422 => Err(ReposCreateDispatchEventError::Status422(github_response.to_json()?).into()),
code => Err(ReposCreateDispatchEventError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a repository for the authenticated user
///
/// Creates a new repository for the authenticated user.
///
/// OAuth app tokens and personal access tokens (classic) need the `public_repo` or `repo` scope to create a public repository, and `repo` scope to create a private repository.
///
/// [GitHub API docs for create_for_authenticated_user](https://docs.github.com/rest/repos/repos#create-a-repository-for-the-authenticated-user)
///
/// ---
pub async fn create_for_authenticated_user_async(&self, body: PostReposCreateForAuthenticatedUser) -> Result<FullRepository, AdapterError> {
let request_uri = format!("{}/user/repos", super::GITHUB_BASE_API_URL);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposCreateForAuthenticatedUser>(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() {
401 => Err(ReposCreateForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()),
304 => Err(ReposCreateForAuthenticatedUserError::Status304.into()),
404 => Err(ReposCreateForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()),
403 => Err(ReposCreateForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()),
422 => Err(ReposCreateForAuthenticatedUserError::Status422(github_response.to_json_async().await?).into()),
400 => Err(ReposCreateForAuthenticatedUserError::Status400(github_response.to_json_async().await?).into()),
code => Err(ReposCreateForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a repository for the authenticated user
///
/// Creates a new repository for the authenticated user.
///
/// OAuth app tokens and personal access tokens (classic) need the `public_repo` or `repo` scope to create a public repository, and `repo` scope to create a private repository.
///
/// [GitHub API docs for create_for_authenticated_user](https://docs.github.com/rest/repos/repos#create-a-repository-for-the-authenticated-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn create_for_authenticated_user(&self, body: PostReposCreateForAuthenticatedUser) -> Result<FullRepository, AdapterError> {
let request_uri = format!("{}/user/repos", super::GITHUB_BASE_API_URL);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposCreateForAuthenticatedUser>(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() {
401 => Err(ReposCreateForAuthenticatedUserError::Status401(github_response.to_json()?).into()),
304 => Err(ReposCreateForAuthenticatedUserError::Status304.into()),
404 => Err(ReposCreateForAuthenticatedUserError::Status404(github_response.to_json()?).into()),
403 => Err(ReposCreateForAuthenticatedUserError::Status403(github_response.to_json()?).into()),
422 => Err(ReposCreateForAuthenticatedUserError::Status422(github_response.to_json()?).into()),
400 => Err(ReposCreateForAuthenticatedUserError::Status400(github_response.to_json()?).into()),
code => Err(ReposCreateForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a fork
///
/// Create a fork for the authenticated user.
///
/// > [!NOTE]
/// > Forking a Repository happens asynchronously. You may have to wait a short period of time before you can access the git objects. If this takes longer than 5 minutes, be sure to contact [GitHub Support](https://support.github.com/contact?tags=dotcom-rest-api).
///
/// > [!NOTE]
/// > Although this endpoint works with GitHub Apps, the GitHub App must be installed on the destination account with access to all repositories and on the source account with access to the source repository.
///
/// [GitHub API docs for create_fork](https://docs.github.com/rest/repos/forks#create-a-fork)
///
/// ---
pub async fn create_fork_async(&self, owner: &str, repo: &str, body: PostReposCreateFork) -> Result<FullRepository, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/forks", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposCreateFork>(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(ReposCreateForkError::Status400(github_response.to_json_async().await?).into()),
422 => Err(ReposCreateForkError::Status422(github_response.to_json_async().await?).into()),
403 => Err(ReposCreateForkError::Status403(github_response.to_json_async().await?).into()),
404 => Err(ReposCreateForkError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposCreateForkError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a fork
///
/// Create a fork for the authenticated user.
///
/// > [!NOTE]
/// > Forking a Repository happens asynchronously. You may have to wait a short period of time before you can access the git objects. If this takes longer than 5 minutes, be sure to contact [GitHub Support](https://support.github.com/contact?tags=dotcom-rest-api).
///
/// > [!NOTE]
/// > Although this endpoint works with GitHub Apps, the GitHub App must be installed on the destination account with access to all repositories and on the source account with access to the source repository.
///
/// [GitHub API docs for create_fork](https://docs.github.com/rest/repos/forks#create-a-fork)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn create_fork(&self, owner: &str, repo: &str, body: PostReposCreateFork) -> Result<FullRepository, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/forks", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposCreateFork>(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() {
400 => Err(ReposCreateForkError::Status400(github_response.to_json()?).into()),
422 => Err(ReposCreateForkError::Status422(github_response.to_json()?).into()),
403 => Err(ReposCreateForkError::Status403(github_response.to_json()?).into()),
404 => Err(ReposCreateForkError::Status404(github_response.to_json()?).into()),
code => Err(ReposCreateForkError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create an organization repository
///
/// Creates a new repository in the specified organization. The authenticated user must be a member of the organization.
///
/// OAuth app tokens and personal access tokens (classic) need the `public_repo` or `repo` scope to create a public repository, and `repo` scope to create a private repository.
///
/// [GitHub API docs for create_in_org](https://docs.github.com/rest/repos/repos#create-an-organization-repository)
///
/// ---
pub async fn create_in_org_async(&self, org: &str, body: PostReposCreateInOrg) -> Result<FullRepository, AdapterError> {
let request_uri = format!("{}/orgs/{}/repos", super::GITHUB_BASE_API_URL, org);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposCreateInOrg>(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() {
403 => Err(ReposCreateInOrgError::Status403(github_response.to_json_async().await?).into()),
422 => Err(ReposCreateInOrgError::Status422(github_response.to_json_async().await?).into()),
code => Err(ReposCreateInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create an organization repository
///
/// Creates a new repository in the specified organization. The authenticated user must be a member of the organization.
///
/// OAuth app tokens and personal access tokens (classic) need the `public_repo` or `repo` scope to create a public repository, and `repo` scope to create a private repository.
///
/// [GitHub API docs for create_in_org](https://docs.github.com/rest/repos/repos#create-an-organization-repository)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn create_in_org(&self, org: &str, body: PostReposCreateInOrg) -> Result<FullRepository, AdapterError> {
let request_uri = format!("{}/orgs/{}/repos", super::GITHUB_BASE_API_URL, org);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposCreateInOrg>(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() {
403 => Err(ReposCreateInOrgError::Status403(github_response.to_json()?).into()),
422 => Err(ReposCreateInOrgError::Status422(github_response.to_json()?).into()),
code => Err(ReposCreateInOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create or update custom property values for a repository
///
/// Create new or update existing custom property values for a repository.
/// Using a value of `null` for a custom property will remove or 'unset' the property value from the repository.
///
/// Repository admins and other users with the repository-level "edit custom property values" fine-grained permission can use this endpoint.
///
/// [GitHub API docs for create_or_update_custom_properties_values](https://docs.github.com/rest/repos/custom-properties#create-or-update-custom-property-values-for-a-repository)
///
/// ---
pub async fn create_or_update_custom_properties_values_async(&self, owner: &str, repo: &str, body: PatchReposCreateOrUpdateCustomPropertiesValues) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/properties/values", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchReposCreateOrUpdateCustomPropertiesValues>(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(ReposCreateOrUpdateCustomPropertiesValuesError::Status403(github_response.to_json_async().await?).into()),
404 => Err(ReposCreateOrUpdateCustomPropertiesValuesError::Status404(github_response.to_json_async().await?).into()),
422 => Err(ReposCreateOrUpdateCustomPropertiesValuesError::Status422(github_response.to_json_async().await?).into()),
code => Err(ReposCreateOrUpdateCustomPropertiesValuesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create or update custom property values for a repository
///
/// Create new or update existing custom property values for a repository.
/// Using a value of `null` for a custom property will remove or 'unset' the property value from the repository.
///
/// Repository admins and other users with the repository-level "edit custom property values" fine-grained permission can use this endpoint.
///
/// [GitHub API docs for create_or_update_custom_properties_values](https://docs.github.com/rest/repos/custom-properties#create-or-update-custom-property-values-for-a-repository)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn create_or_update_custom_properties_values(&self, owner: &str, repo: &str, body: PatchReposCreateOrUpdateCustomPropertiesValues) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/properties/values", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchReposCreateOrUpdateCustomPropertiesValues>(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(ReposCreateOrUpdateCustomPropertiesValuesError::Status403(github_response.to_json()?).into()),
404 => Err(ReposCreateOrUpdateCustomPropertiesValuesError::Status404(github_response.to_json()?).into()),
422 => Err(ReposCreateOrUpdateCustomPropertiesValuesError::Status422(github_response.to_json()?).into()),
code => Err(ReposCreateOrUpdateCustomPropertiesValuesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create or update an environment
///
/// Create or update an environment with protection rules, such as required reviewers. For more information about environment protection rules, see "[Environments](/actions/reference/environments#environment-protection-rules)."
///
/// > [!NOTE]
/// > To create or update name patterns that branches must match in order to deploy to this environment, see "[Deployment branch policies](/rest/deployments/branch-policies)."
///
/// > [!NOTE]
/// > To create or update secrets for an environment, see "[GitHub Actions secrets](/rest/actions/secrets)."
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.
///
/// [GitHub API docs for create_or_update_environment](https://docs.github.com/rest/deployments/environments#create-or-update-an-environment)
///
/// ---
pub async fn create_or_update_environment_async(&self, owner: &str, repo: &str, environment_name: &str, body: PutReposCreateOrUpdateEnvironment) -> Result<Environment, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/environments/{}", super::GITHUB_BASE_API_URL, owner, repo, environment_name);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutReposCreateOrUpdateEnvironment>(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(ReposCreateOrUpdateEnvironmentError::Status422(github_response.to_json_async().await?).into()),
code => Err(ReposCreateOrUpdateEnvironmentError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create or update an environment
///
/// Create or update an environment with protection rules, such as required reviewers. For more information about environment protection rules, see "[Environments](/actions/reference/environments#environment-protection-rules)."
///
/// > [!NOTE]
/// > To create or update name patterns that branches must match in order to deploy to this environment, see "[Deployment branch policies](/rest/deployments/branch-policies)."
///
/// > [!NOTE]
/// > To create or update secrets for an environment, see "[GitHub Actions secrets](/rest/actions/secrets)."
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.
///
/// [GitHub API docs for create_or_update_environment](https://docs.github.com/rest/deployments/environments#create-or-update-an-environment)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn create_or_update_environment(&self, owner: &str, repo: &str, environment_name: &str, body: PutReposCreateOrUpdateEnvironment) -> Result<Environment, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/environments/{}", super::GITHUB_BASE_API_URL, owner, repo, environment_name);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutReposCreateOrUpdateEnvironment>(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(ReposCreateOrUpdateEnvironmentError::Status422(github_response.to_json()?).into()),
code => Err(ReposCreateOrUpdateEnvironmentError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create or update file contents
///
/// Creates a new file or replaces an existing file in a repository.
///
/// > [!NOTE]
/// > If you use this endpoint and the "[Delete a file](https://docs.github.com/rest/repos/contents/#delete-a-file)" endpoint in parallel, the concurrent requests will conflict and you will receive errors. You must use these endpoints serially instead.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. The `workflow` scope is also required in order to modify files in the `.github/workflows` directory.
///
/// [GitHub API docs for create_or_update_file_contents](https://docs.github.com/rest/repos/contents#create-or-update-file-contents)
///
/// ---
pub async fn create_or_update_file_contents_async(&self, owner: &str, repo: &str, path: &str, body: PutReposCreateOrUpdateFileContents) -> Result<FileCommit, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/contents/{}", super::GITHUB_BASE_API_URL, owner, repo, path);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutReposCreateOrUpdateFileContents>(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() {
201 => Err(ReposCreateOrUpdateFileContentsError::Status201(github_response.to_json_async().await?).into()),
404 => Err(ReposCreateOrUpdateFileContentsError::Status404(github_response.to_json_async().await?).into()),
422 => Err(ReposCreateOrUpdateFileContentsError::Status422(github_response.to_json_async().await?).into()),
409 => Err(ReposCreateOrUpdateFileContentsError::Status409(github_response.to_json_async().await?).into()),
code => Err(ReposCreateOrUpdateFileContentsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create or update file contents
///
/// Creates a new file or replaces an existing file in a repository.
///
/// > [!NOTE]
/// > If you use this endpoint and the "[Delete a file](https://docs.github.com/rest/repos/contents/#delete-a-file)" endpoint in parallel, the concurrent requests will conflict and you will receive errors. You must use these endpoints serially instead.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. The `workflow` scope is also required in order to modify files in the `.github/workflows` directory.
///
/// [GitHub API docs for create_or_update_file_contents](https://docs.github.com/rest/repos/contents#create-or-update-file-contents)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn create_or_update_file_contents(&self, owner: &str, repo: &str, path: &str, body: PutReposCreateOrUpdateFileContents) -> Result<FileCommit, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/contents/{}", super::GITHUB_BASE_API_URL, owner, repo, path);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutReposCreateOrUpdateFileContents>(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() {
201 => Err(ReposCreateOrUpdateFileContentsError::Status201(github_response.to_json()?).into()),
404 => Err(ReposCreateOrUpdateFileContentsError::Status404(github_response.to_json()?).into()),
422 => Err(ReposCreateOrUpdateFileContentsError::Status422(github_response.to_json()?).into()),
409 => Err(ReposCreateOrUpdateFileContentsError::Status409(github_response.to_json()?).into()),
code => Err(ReposCreateOrUpdateFileContentsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create an organization repository ruleset
///
/// Create a repository ruleset for an organization.
///
/// [GitHub API docs for create_org_ruleset](https://docs.github.com/rest/orgs/rules#create-an-organization-repository-ruleset)
///
/// ---
pub async fn create_org_ruleset_async(&self, org: &str, body: PostReposCreateOrgRuleset) -> Result<RepositoryRuleset, AdapterError> {
let request_uri = format!("{}/orgs/{}/rulesets", super::GITHUB_BASE_API_URL, org);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposCreateOrgRuleset>(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(ReposCreateOrgRulesetError::Status404(github_response.to_json_async().await?).into()),
500 => Err(ReposCreateOrgRulesetError::Status500(github_response.to_json_async().await?).into()),
code => Err(ReposCreateOrgRulesetError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create an organization repository ruleset
///
/// Create a repository ruleset for an organization.
///
/// [GitHub API docs for create_org_ruleset](https://docs.github.com/rest/orgs/rules#create-an-organization-repository-ruleset)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn create_org_ruleset(&self, org: &str, body: PostReposCreateOrgRuleset) -> Result<RepositoryRuleset, AdapterError> {
let request_uri = format!("{}/orgs/{}/rulesets", super::GITHUB_BASE_API_URL, org);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposCreateOrgRuleset>(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(ReposCreateOrgRulesetError::Status404(github_response.to_json()?).into()),
500 => Err(ReposCreateOrgRulesetError::Status500(github_response.to_json()?).into()),
code => Err(ReposCreateOrgRulesetError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a GitHub Pages deployment
///
/// Create a GitHub Pages deployment for a repository.
///
/// The authenticated user must have write permission to the repository.
///
/// [GitHub API docs for create_pages_deployment](https://docs.github.com/rest/pages/pages#create-a-github-pages-deployment)
///
/// ---
pub async fn create_pages_deployment_async(&self, owner: &str, repo: &str, body: PostReposCreatePagesDeployment) -> Result<PageDeployment, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pages/deployments", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposCreatePagesDeployment>(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(ReposCreatePagesDeploymentError::Status400(github_response.to_json_async().await?).into()),
422 => Err(ReposCreatePagesDeploymentError::Status422(github_response.to_json_async().await?).into()),
404 => Err(ReposCreatePagesDeploymentError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposCreatePagesDeploymentError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a GitHub Pages deployment
///
/// Create a GitHub Pages deployment for a repository.
///
/// The authenticated user must have write permission to the repository.
///
/// [GitHub API docs for create_pages_deployment](https://docs.github.com/rest/pages/pages#create-a-github-pages-deployment)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn create_pages_deployment(&self, owner: &str, repo: &str, body: PostReposCreatePagesDeployment) -> Result<PageDeployment, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pages/deployments", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposCreatePagesDeployment>(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() {
400 => Err(ReposCreatePagesDeploymentError::Status400(github_response.to_json()?).into()),
422 => Err(ReposCreatePagesDeploymentError::Status422(github_response.to_json()?).into()),
404 => Err(ReposCreatePagesDeploymentError::Status404(github_response.to_json()?).into()),
code => Err(ReposCreatePagesDeploymentError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a GitHub Pages site
///
/// Configures a GitHub Pages site. For more information, see "[About GitHub Pages](/github/working-with-github-pages/about-github-pages)."
///
/// The authenticated user must be a repository administrator, maintainer, or have the 'manage GitHub Pages settings' permission.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.
///
/// [GitHub API docs for create_pages_site](https://docs.github.com/rest/pages/pages#create-a-apiname-pages-site)
///
/// ---
pub async fn create_pages_site_async(&self, owner: &str, repo: &str, body: PostReposCreatePagesSite) -> Result<Page, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pages", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposCreatePagesSite>(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(ReposCreatePagesSiteError::Status422(github_response.to_json_async().await?).into()),
409 => Err(ReposCreatePagesSiteError::Status409(github_response.to_json_async().await?).into()),
code => Err(ReposCreatePagesSiteError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a GitHub Pages site
///
/// Configures a GitHub Pages site. For more information, see "[About GitHub Pages](/github/working-with-github-pages/about-github-pages)."
///
/// The authenticated user must be a repository administrator, maintainer, or have the 'manage GitHub Pages settings' permission.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.
///
/// [GitHub API docs for create_pages_site](https://docs.github.com/rest/pages/pages#create-a-apiname-pages-site)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn create_pages_site(&self, owner: &str, repo: &str, body: PostReposCreatePagesSite) -> Result<Page, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pages", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposCreatePagesSite>(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(ReposCreatePagesSiteError::Status422(github_response.to_json()?).into()),
409 => Err(ReposCreatePagesSiteError::Status409(github_response.to_json()?).into()),
code => Err(ReposCreatePagesSiteError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a release
///
/// Users with push access to the repository can create a release.
///
/// 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_release](https://docs.github.com/rest/releases/releases#create-a-release)
///
/// ---
pub async fn create_release_async(&self, owner: &str, repo: &str, body: PostReposCreateRelease) -> Result<Release, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/releases", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposCreateRelease>(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(ReposCreateReleaseError::Status404(github_response.to_json_async().await?).into()),
422 => Err(ReposCreateReleaseError::Status422(github_response.to_json_async().await?).into()),
code => Err(ReposCreateReleaseError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a release
///
/// Users with push access to the repository can create a release.
///
/// 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_release](https://docs.github.com/rest/releases/releases#create-a-release)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn create_release(&self, owner: &str, repo: &str, body: PostReposCreateRelease) -> Result<Release, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/releases", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposCreateRelease>(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(ReposCreateReleaseError::Status404(github_response.to_json()?).into()),
422 => Err(ReposCreateReleaseError::Status422(github_response.to_json()?).into()),
code => Err(ReposCreateReleaseError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a repository ruleset
///
/// Create a ruleset for a repository.
///
/// [GitHub API docs for create_repo_ruleset](https://docs.github.com/rest/repos/rules#create-a-repository-ruleset)
///
/// ---
pub async fn create_repo_ruleset_async(&self, owner: &str, repo: &str, body: PostReposCreateRepoRuleset) -> Result<RepositoryRuleset, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/rulesets", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposCreateRepoRuleset>(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(ReposCreateRepoRulesetError::Status404(github_response.to_json_async().await?).into()),
500 => Err(ReposCreateRepoRulesetError::Status500(github_response.to_json_async().await?).into()),
code => Err(ReposCreateRepoRulesetError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a repository ruleset
///
/// Create a ruleset for a repository.
///
/// [GitHub API docs for create_repo_ruleset](https://docs.github.com/rest/repos/rules#create-a-repository-ruleset)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn create_repo_ruleset(&self, owner: &str, repo: &str, body: PostReposCreateRepoRuleset) -> Result<RepositoryRuleset, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/rulesets", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposCreateRepoRuleset>(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(ReposCreateRepoRulesetError::Status404(github_response.to_json()?).into()),
500 => Err(ReposCreateRepoRulesetError::Status500(github_response.to_json()?).into()),
code => Err(ReposCreateRepoRulesetError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Closing down - Create a tag protection state for a repository
///
/// > [!WARNING]
/// > **Closing down notice:** This operation is closing down and will be removed after August 30, 2024. Use the "[Repository Rulesets](https://docs.github.com/rest/repos/rules#create-a-repository-ruleset)" endpoint instead.
///
/// This creates a tag protection state for a repository.
/// This endpoint is only available to repository administrators.
///
/// [GitHub API docs for create_tag_protection](https://docs.github.com/rest/repos/tags#closing-down---create-a-tag-protection-state-for-a-repository)
///
/// ---
pub async fn create_tag_protection_async(&self, owner: &str, repo: &str, body: PostReposCreateTagProtection) -> Result<TagProtection, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/tags/protection", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposCreateTagProtection>(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() {
403 => Err(ReposCreateTagProtectionError::Status403(github_response.to_json_async().await?).into()),
404 => Err(ReposCreateTagProtectionError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposCreateTagProtectionError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Closing down - Create a tag protection state for a repository
///
/// > [!WARNING]
/// > **Closing down notice:** This operation is closing down and will be removed after August 30, 2024. Use the "[Repository Rulesets](https://docs.github.com/rest/repos/rules#create-a-repository-ruleset)" endpoint instead.
///
/// This creates a tag protection state for a repository.
/// This endpoint is only available to repository administrators.
///
/// [GitHub API docs for create_tag_protection](https://docs.github.com/rest/repos/tags#closing-down---create-a-tag-protection-state-for-a-repository)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn create_tag_protection(&self, owner: &str, repo: &str, body: PostReposCreateTagProtection) -> Result<TagProtection, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/tags/protection", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposCreateTagProtection>(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() {
403 => Err(ReposCreateTagProtectionError::Status403(github_response.to_json()?).into()),
404 => Err(ReposCreateTagProtectionError::Status404(github_response.to_json()?).into()),
code => Err(ReposCreateTagProtectionError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a repository using a template
///
/// Creates a new repository using a repository template. Use the `template_owner` and `template_repo` route parameters to specify the repository to use as the template. If the repository is not public, the authenticated user must own or be a member of an organization that owns the repository. To check if a repository is available to use as a template, get the repository's information using the [Get a repository](https://docs.github.com/rest/repos/repos#get-a-repository) endpoint and check that the `is_template` key is `true`.
///
/// OAuth app tokens and personal access tokens (classic) need the `public_repo` or `repo` scope to create a public repository, and `repo` scope to create a private repository.
///
/// [GitHub API docs for create_using_template](https://docs.github.com/rest/repos/repos#create-a-repository-using-a-template)
///
/// ---
pub async fn create_using_template_async(&self, template_owner: &str, template_repo: &str, body: PostReposCreateUsingTemplate) -> Result<FullRepository, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/generate", super::GITHUB_BASE_API_URL, template_owner, template_repo);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposCreateUsingTemplate>(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(ReposCreateUsingTemplateError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a repository using a template
///
/// Creates a new repository using a repository template. Use the `template_owner` and `template_repo` route parameters to specify the repository to use as the template. If the repository is not public, the authenticated user must own or be a member of an organization that owns the repository. To check if a repository is available to use as a template, get the repository's information using the [Get a repository](https://docs.github.com/rest/repos/repos#get-a-repository) endpoint and check that the `is_template` key is `true`.
///
/// OAuth app tokens and personal access tokens (classic) need the `public_repo` or `repo` scope to create a public repository, and `repo` scope to create a private repository.
///
/// [GitHub API docs for create_using_template](https://docs.github.com/rest/repos/repos#create-a-repository-using-a-template)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn create_using_template(&self, template_owner: &str, template_repo: &str, body: PostReposCreateUsingTemplate) -> Result<FullRepository, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/generate", super::GITHUB_BASE_API_URL, template_owner, template_repo);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposCreateUsingTemplate>(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(ReposCreateUsingTemplateError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a repository webhook
///
/// Repositories can have multiple webhooks installed. Each webhook should have a unique `config`. Multiple webhooks can
/// share the same `config` as long as those webhooks do not have any `events` that overlap.
///
/// [GitHub API docs for create_webhook](https://docs.github.com/rest/repos/webhooks#create-a-repository-webhook)
///
/// ---
pub async fn create_webhook_async(&self, owner: &str, repo: &str, body: PostReposCreateWebhook) -> Result<Hook, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/hooks", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposCreateWebhook>(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(ReposCreateWebhookError::Status404(github_response.to_json_async().await?).into()),
422 => Err(ReposCreateWebhookError::Status422(github_response.to_json_async().await?).into()),
403 => Err(ReposCreateWebhookError::Status403(github_response.to_json_async().await?).into()),
code => Err(ReposCreateWebhookError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a repository webhook
///
/// Repositories can have multiple webhooks installed. Each webhook should have a unique `config`. Multiple webhooks can
/// share the same `config` as long as those webhooks do not have any `events` that overlap.
///
/// [GitHub API docs for create_webhook](https://docs.github.com/rest/repos/webhooks#create-a-repository-webhook)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn create_webhook(&self, owner: &str, repo: &str, body: PostReposCreateWebhook) -> Result<Hook, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/hooks", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposCreateWebhook>(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(ReposCreateWebhookError::Status404(github_response.to_json()?).into()),
422 => Err(ReposCreateWebhookError::Status422(github_response.to_json()?).into()),
403 => Err(ReposCreateWebhookError::Status403(github_response.to_json()?).into()),
code => Err(ReposCreateWebhookError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Decline a repository invitation
///
/// [GitHub API docs for decline_invitation_for_authenticated_user](https://docs.github.com/rest/collaborators/invitations#decline-a-repository-invitation)
///
/// ---
pub async fn decline_invitation_for_authenticated_user_async(&self, invitation_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/user/repository_invitations/{}", super::GITHUB_BASE_API_URL, 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() {
409 => Err(ReposDeclineInvitationForAuthenticatedUserError::Status409(github_response.to_json_async().await?).into()),
304 => Err(ReposDeclineInvitationForAuthenticatedUserError::Status304.into()),
404 => Err(ReposDeclineInvitationForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()),
403 => Err(ReposDeclineInvitationForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()),
code => Err(ReposDeclineInvitationForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Decline a repository invitation
///
/// [GitHub API docs for decline_invitation_for_authenticated_user](https://docs.github.com/rest/collaborators/invitations#decline-a-repository-invitation)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn decline_invitation_for_authenticated_user(&self, invitation_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/user/repository_invitations/{}", super::GITHUB_BASE_API_URL, 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() {
409 => Err(ReposDeclineInvitationForAuthenticatedUserError::Status409(github_response.to_json()?).into()),
304 => Err(ReposDeclineInvitationForAuthenticatedUserError::Status304.into()),
404 => Err(ReposDeclineInvitationForAuthenticatedUserError::Status404(github_response.to_json()?).into()),
403 => Err(ReposDeclineInvitationForAuthenticatedUserError::Status403(github_response.to_json()?).into()),
code => Err(ReposDeclineInvitationForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a repository
///
/// Deleting a repository requires admin access.
///
/// If an organization owner has configured the organization to prevent members from deleting organization-owned
/// repositories, you will get a `403 Forbidden` response.
///
/// OAuth app tokens and personal access tokens (classic) need the `delete_repo` scope to use this endpoint.
///
/// [GitHub API docs for delete](https://docs.github.com/rest/repos/repos#delete-a-repository)
///
/// ---
pub async fn delete_async(&self, owner: &str, repo: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
403 => Err(ReposDeleteError::Status403(github_response.to_json_async().await?).into()),
307 => Err(ReposDeleteError::Status307(github_response.to_json_async().await?).into()),
404 => Err(ReposDeleteError::Status404(github_response.to_json_async().await?).into()),
409 => Err(ReposDeleteError::Status409(github_response.to_json_async().await?).into()),
code => Err(ReposDeleteError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a repository
///
/// Deleting a repository requires admin access.
///
/// If an organization owner has configured the organization to prevent members from deleting organization-owned
/// repositories, you will get a `403 Forbidden` response.
///
/// OAuth app tokens and personal access tokens (classic) need the `delete_repo` scope to use this endpoint.
///
/// [GitHub API docs for delete](https://docs.github.com/rest/repos/repos#delete-a-repository)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete(&self, owner: &str, repo: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
403 => Err(ReposDeleteError::Status403(github_response.to_json()?).into()),
307 => Err(ReposDeleteError::Status307(github_response.to_json()?).into()),
404 => Err(ReposDeleteError::Status404(github_response.to_json()?).into()),
409 => Err(ReposDeleteError::Status409(github_response.to_json()?).into()),
code => Err(ReposDeleteError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete access restrictions
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// Disables the ability to restrict who can push to this branch.
///
/// [GitHub API docs for delete_access_restrictions](https://docs.github.com/rest/branches/branch-protection#delete-access-restrictions)
///
/// ---
pub async fn delete_access_restrictions_async(&self, owner: &str, repo: &str, branch: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions", super::GITHUB_BASE_API_URL, owner, repo, branch);
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(ReposDeleteAccessRestrictionsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete access restrictions
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// Disables the ability to restrict who can push to this branch.
///
/// [GitHub API docs for delete_access_restrictions](https://docs.github.com/rest/branches/branch-protection#delete-access-restrictions)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete_access_restrictions(&self, owner: &str, repo: &str, branch: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions", super::GITHUB_BASE_API_URL, owner, repo, branch);
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(ReposDeleteAccessRestrictionsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete admin branch protection
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// Removing admin enforcement requires admin or owner permissions to the repository and branch protection to be enabled.
///
/// [GitHub API docs for delete_admin_branch_protection](https://docs.github.com/rest/branches/branch-protection#delete-admin-branch-protection)
///
/// ---
pub async fn delete_admin_branch_protection_async(&self, owner: &str, repo: &str, branch: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/enforce_admins", super::GITHUB_BASE_API_URL, owner, repo, branch);
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(ReposDeleteAdminBranchProtectionError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposDeleteAdminBranchProtectionError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete admin branch protection
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// Removing admin enforcement requires admin or owner permissions to the repository and branch protection to be enabled.
///
/// [GitHub API docs for delete_admin_branch_protection](https://docs.github.com/rest/branches/branch-protection#delete-admin-branch-protection)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete_admin_branch_protection(&self, owner: &str, repo: &str, branch: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/enforce_admins", super::GITHUB_BASE_API_URL, owner, repo, branch);
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(ReposDeleteAdminBranchProtectionError::Status404(github_response.to_json()?).into()),
code => Err(ReposDeleteAdminBranchProtectionError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete an environment
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.
///
/// [GitHub API docs for delete_an_environment](https://docs.github.com/rest/deployments/environments#delete-an-environment)
///
/// ---
pub async fn delete_an_environment_async(&self, owner: &str, repo: &str, environment_name: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/environments/{}", super::GITHUB_BASE_API_URL, owner, repo, environment_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() {
code => Err(ReposDeleteAnEnvironmentError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete an environment
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.
///
/// [GitHub API docs for delete_an_environment](https://docs.github.com/rest/deployments/environments#delete-an-environment)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete_an_environment(&self, owner: &str, repo: &str, environment_name: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/environments/{}", super::GITHUB_BASE_API_URL, owner, repo, environment_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() {
code => Err(ReposDeleteAnEnvironmentError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete an autolink reference from a repository
///
/// This deletes a single autolink reference by ID that was configured for the given repository.
///
/// Information about autolinks are only available to repository administrators.
///
/// [GitHub API docs for delete_autolink](https://docs.github.com/rest/repos/autolinks#delete-an-autolink-reference-from-a-repository)
///
/// ---
pub async fn delete_autolink_async(&self, owner: &str, repo: &str, autolink_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/autolinks/{}", super::GITHUB_BASE_API_URL, owner, repo, autolink_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(ReposDeleteAutolinkError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposDeleteAutolinkError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete an autolink reference from a repository
///
/// This deletes a single autolink reference by ID that was configured for the given repository.
///
/// Information about autolinks are only available to repository administrators.
///
/// [GitHub API docs for delete_autolink](https://docs.github.com/rest/repos/autolinks#delete-an-autolink-reference-from-a-repository)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete_autolink(&self, owner: &str, repo: &str, autolink_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/autolinks/{}", super::GITHUB_BASE_API_URL, owner, repo, autolink_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(ReposDeleteAutolinkError::Status404(github_response.to_json()?).into()),
code => Err(ReposDeleteAutolinkError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete branch protection
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// [GitHub API docs for delete_branch_protection](https://docs.github.com/rest/branches/branch-protection#delete-branch-protection)
///
/// ---
pub async fn delete_branch_protection_async(&self, owner: &str, repo: &str, branch: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection", super::GITHUB_BASE_API_URL, owner, repo, branch);
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(ReposDeleteBranchProtectionError::Status403(github_response.to_json_async().await?).into()),
code => Err(ReposDeleteBranchProtectionError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete branch protection
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// [GitHub API docs for delete_branch_protection](https://docs.github.com/rest/branches/branch-protection#delete-branch-protection)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete_branch_protection(&self, owner: &str, repo: &str, branch: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection", super::GITHUB_BASE_API_URL, owner, repo, branch);
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(ReposDeleteBranchProtectionError::Status403(github_response.to_json()?).into()),
code => Err(ReposDeleteBranchProtectionError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a commit comment
///
/// [GitHub API docs for delete_commit_comment](https://docs.github.com/rest/commits/comments#delete-a-commit-comment)
///
/// ---
pub async fn delete_commit_comment_async(&self, owner: &str, repo: &str, comment_id: i64) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/comments/{}", super::GITHUB_BASE_API_URL, owner, repo, comment_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(ReposDeleteCommitCommentError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposDeleteCommitCommentError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a commit comment
///
/// [GitHub API docs for delete_commit_comment](https://docs.github.com/rest/commits/comments#delete-a-commit-comment)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete_commit_comment(&self, owner: &str, repo: &str, comment_id: i64) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/comments/{}", super::GITHUB_BASE_API_URL, owner, repo, comment_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(ReposDeleteCommitCommentError::Status404(github_response.to_json()?).into()),
code => Err(ReposDeleteCommitCommentError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete commit signature protection
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// When authenticated with admin or owner permissions to the repository, you can use this endpoint to disable required signed commits on a branch. You must enable branch protection to require signed commits.
///
/// [GitHub API docs for delete_commit_signature_protection](https://docs.github.com/rest/branches/branch-protection#delete-commit-signature-protection)
///
/// ---
pub async fn delete_commit_signature_protection_async(&self, owner: &str, repo: &str, branch: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_signatures", super::GITHUB_BASE_API_URL, owner, repo, branch);
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(ReposDeleteCommitSignatureProtectionError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposDeleteCommitSignatureProtectionError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete commit signature protection
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// When authenticated with admin or owner permissions to the repository, you can use this endpoint to disable required signed commits on a branch. You must enable branch protection to require signed commits.
///
/// [GitHub API docs for delete_commit_signature_protection](https://docs.github.com/rest/branches/branch-protection#delete-commit-signature-protection)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete_commit_signature_protection(&self, owner: &str, repo: &str, branch: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_signatures", super::GITHUB_BASE_API_URL, owner, repo, branch);
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(ReposDeleteCommitSignatureProtectionError::Status404(github_response.to_json()?).into()),
code => Err(ReposDeleteCommitSignatureProtectionError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a deploy key
///
/// Deploy keys are immutable. If you need to update a key, remove the key and create a new one instead.
///
/// [GitHub API docs for delete_deploy_key](https://docs.github.com/rest/deploy-keys/deploy-keys#delete-a-deploy-key)
///
/// ---
pub async fn delete_deploy_key_async(&self, owner: &str, repo: &str, key_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/keys/{}", super::GITHUB_BASE_API_URL, owner, repo, key_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(ReposDeleteDeployKeyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a deploy key
///
/// Deploy keys are immutable. If you need to update a key, remove the key and create a new one instead.
///
/// [GitHub API docs for delete_deploy_key](https://docs.github.com/rest/deploy-keys/deploy-keys#delete-a-deploy-key)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete_deploy_key(&self, owner: &str, repo: &str, key_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/keys/{}", super::GITHUB_BASE_API_URL, owner, repo, key_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(ReposDeleteDeployKeyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a deployment
///
/// If the repository only has one deployment, you can delete the deployment regardless of its status. If the repository has more than one deployment, you can only delete inactive deployments. This ensures that repositories with multiple deployments will always have an active deployment.
///
/// To set a deployment as inactive, you must:
///
/// * Create a new deployment that is active so that the system has a record of the current state, then delete the previously active deployment.
/// * Mark the active deployment as inactive by adding any non-successful deployment status.
///
/// For more information, see "[Create a deployment](https://docs.github.com/rest/deployments/deployments/#create-a-deployment)" and "[Create a deployment status](https://docs.github.com/rest/deployments/statuses#create-a-deployment-status)."
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` or `repo_deployment` scope to use this endpoint.
///
/// [GitHub API docs for delete_deployment](https://docs.github.com/rest/deployments/deployments#delete-a-deployment)
///
/// ---
pub async fn delete_deployment_async(&self, owner: &str, repo: &str, deployment_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/deployments/{}", super::GITHUB_BASE_API_URL, owner, repo, deployment_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(ReposDeleteDeploymentError::Status404(github_response.to_json_async().await?).into()),
422 => Err(ReposDeleteDeploymentError::Status422(github_response.to_json_async().await?).into()),
code => Err(ReposDeleteDeploymentError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a deployment
///
/// If the repository only has one deployment, you can delete the deployment regardless of its status. If the repository has more than one deployment, you can only delete inactive deployments. This ensures that repositories with multiple deployments will always have an active deployment.
///
/// To set a deployment as inactive, you must:
///
/// * Create a new deployment that is active so that the system has a record of the current state, then delete the previously active deployment.
/// * Mark the active deployment as inactive by adding any non-successful deployment status.
///
/// For more information, see "[Create a deployment](https://docs.github.com/rest/deployments/deployments/#create-a-deployment)" and "[Create a deployment status](https://docs.github.com/rest/deployments/statuses#create-a-deployment-status)."
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` or `repo_deployment` scope to use this endpoint.
///
/// [GitHub API docs for delete_deployment](https://docs.github.com/rest/deployments/deployments#delete-a-deployment)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete_deployment(&self, owner: &str, repo: &str, deployment_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/deployments/{}", super::GITHUB_BASE_API_URL, owner, repo, deployment_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(ReposDeleteDeploymentError::Status404(github_response.to_json()?).into()),
422 => Err(ReposDeleteDeploymentError::Status422(github_response.to_json()?).into()),
code => Err(ReposDeleteDeploymentError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a deployment branch policy
///
/// Deletes a deployment branch or tag policy for an environment.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.
///
/// [GitHub API docs for delete_deployment_branch_policy](https://docs.github.com/rest/deployments/branch-policies#delete-a-deployment-branch-policy)
///
/// ---
pub async fn delete_deployment_branch_policy_async(&self, owner: &str, repo: &str, environment_name: &str, branch_policy_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/environments/{}/deployment-branch-policies/{}", super::GITHUB_BASE_API_URL, owner, repo, environment_name, branch_policy_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(ReposDeleteDeploymentBranchPolicyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a deployment branch policy
///
/// Deletes a deployment branch or tag policy for an environment.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.
///
/// [GitHub API docs for delete_deployment_branch_policy](https://docs.github.com/rest/deployments/branch-policies#delete-a-deployment-branch-policy)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete_deployment_branch_policy(&self, owner: &str, repo: &str, environment_name: &str, branch_policy_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/environments/{}/deployment-branch-policies/{}", super::GITHUB_BASE_API_URL, owner, repo, environment_name, branch_policy_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(ReposDeleteDeploymentBranchPolicyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a file
///
/// Deletes a file in a repository.
///
/// You can provide an additional `committer` parameter, which is an object containing information about the committer. Or, you can provide an `author` parameter, which is an object containing information about the author.
///
/// The `author` section is optional and is filled in with the `committer` information if omitted. If the `committer` information is omitted, the authenticated user's information is used.
///
/// You must provide values for both `name` and `email`, whether you choose to use `author` or `committer`. Otherwise, you'll receive a `422` status code.
///
/// > [!NOTE]
/// > If you use this endpoint and the "[Create or update file contents](https://docs.github.com/rest/repos/contents/#create-or-update-file-contents)" endpoint in parallel, the concurrent requests will conflict and you will receive errors. You must use these endpoints serially instead.
///
/// [GitHub API docs for delete_file](https://docs.github.com/rest/repos/contents#delete-a-file)
///
/// ---
pub async fn delete_file_async(&self, owner: &str, repo: &str, path: &str, body: DeleteReposDeleteFile) -> Result<FileCommit, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/contents/{}", super::GITHUB_BASE_API_URL, owner, repo, path);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<DeleteReposDeleteFile>(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() {
422 => Err(ReposDeleteFileError::Status422(github_response.to_json_async().await?).into()),
404 => Err(ReposDeleteFileError::Status404(github_response.to_json_async().await?).into()),
409 => Err(ReposDeleteFileError::Status409(github_response.to_json_async().await?).into()),
503 => Err(ReposDeleteFileError::Status503(github_response.to_json_async().await?).into()),
code => Err(ReposDeleteFileError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a file
///
/// Deletes a file in a repository.
///
/// You can provide an additional `committer` parameter, which is an object containing information about the committer. Or, you can provide an `author` parameter, which is an object containing information about the author.
///
/// The `author` section is optional and is filled in with the `committer` information if omitted. If the `committer` information is omitted, the authenticated user's information is used.
///
/// You must provide values for both `name` and `email`, whether you choose to use `author` or `committer`. Otherwise, you'll receive a `422` status code.
///
/// > [!NOTE]
/// > If you use this endpoint and the "[Create or update file contents](https://docs.github.com/rest/repos/contents/#create-or-update-file-contents)" endpoint in parallel, the concurrent requests will conflict and you will receive errors. You must use these endpoints serially instead.
///
/// [GitHub API docs for delete_file](https://docs.github.com/rest/repos/contents#delete-a-file)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete_file(&self, owner: &str, repo: &str, path: &str, body: DeleteReposDeleteFile) -> Result<FileCommit, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/contents/{}", super::GITHUB_BASE_API_URL, owner, repo, path);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<DeleteReposDeleteFile>(body)?),
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() {
422 => Err(ReposDeleteFileError::Status422(github_response.to_json()?).into()),
404 => Err(ReposDeleteFileError::Status404(github_response.to_json()?).into()),
409 => Err(ReposDeleteFileError::Status409(github_response.to_json()?).into()),
503 => Err(ReposDeleteFileError::Status503(github_response.to_json()?).into()),
code => Err(ReposDeleteFileError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a repository invitation
///
/// [GitHub API docs for delete_invitation](https://docs.github.com/rest/collaborators/invitations#delete-a-repository-invitation)
///
/// ---
pub async fn delete_invitation_async(&self, owner: &str, repo: &str, invitation_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/invitations/{}", super::GITHUB_BASE_API_URL, owner, repo, 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() {
code => Err(ReposDeleteInvitationError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a repository invitation
///
/// [GitHub API docs for delete_invitation](https://docs.github.com/rest/collaborators/invitations#delete-a-repository-invitation)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete_invitation(&self, owner: &str, repo: &str, invitation_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/invitations/{}", super::GITHUB_BASE_API_URL, owner, repo, 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() {
code => Err(ReposDeleteInvitationError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete an organization repository ruleset
///
/// Delete a ruleset for an organization.
///
/// [GitHub API docs for delete_org_ruleset](https://docs.github.com/rest/orgs/rules#delete-an-organization-repository-ruleset)
///
/// ---
pub async fn delete_org_ruleset_async(&self, org: &str, ruleset_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/rulesets/{}", super::GITHUB_BASE_API_URL, org, ruleset_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(ReposDeleteOrgRulesetError::Status404(github_response.to_json_async().await?).into()),
500 => Err(ReposDeleteOrgRulesetError::Status500(github_response.to_json_async().await?).into()),
code => Err(ReposDeleteOrgRulesetError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete an organization repository ruleset
///
/// Delete a ruleset for an organization.
///
/// [GitHub API docs for delete_org_ruleset](https://docs.github.com/rest/orgs/rules#delete-an-organization-repository-ruleset)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete_org_ruleset(&self, org: &str, ruleset_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/rulesets/{}", super::GITHUB_BASE_API_URL, org, ruleset_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(ReposDeleteOrgRulesetError::Status404(github_response.to_json()?).into()),
500 => Err(ReposDeleteOrgRulesetError::Status500(github_response.to_json()?).into()),
code => Err(ReposDeleteOrgRulesetError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a GitHub Pages site
///
/// Deletes a GitHub Pages site. For more information, see "[About GitHub Pages](/github/working-with-github-pages/about-github-pages).
///
/// The authenticated user must be a repository administrator, maintainer, or have the 'manage GitHub Pages settings' permission.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.
///
/// [GitHub API docs for delete_pages_site](https://docs.github.com/rest/pages/pages#delete-a-apiname-pages-site)
///
/// ---
pub async fn delete_pages_site_async(&self, owner: &str, repo: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pages", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
422 => Err(ReposDeletePagesSiteError::Status422(github_response.to_json_async().await?).into()),
404 => Err(ReposDeletePagesSiteError::Status404(github_response.to_json_async().await?).into()),
409 => Err(ReposDeletePagesSiteError::Status409(github_response.to_json_async().await?).into()),
code => Err(ReposDeletePagesSiteError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a GitHub Pages site
///
/// Deletes a GitHub Pages site. For more information, see "[About GitHub Pages](/github/working-with-github-pages/about-github-pages).
///
/// The authenticated user must be a repository administrator, maintainer, or have the 'manage GitHub Pages settings' permission.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.
///
/// [GitHub API docs for delete_pages_site](https://docs.github.com/rest/pages/pages#delete-a-apiname-pages-site)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete_pages_site(&self, owner: &str, repo: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pages", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
422 => Err(ReposDeletePagesSiteError::Status422(github_response.to_json()?).into()),
404 => Err(ReposDeletePagesSiteError::Status404(github_response.to_json()?).into()),
409 => Err(ReposDeletePagesSiteError::Status409(github_response.to_json()?).into()),
code => Err(ReposDeletePagesSiteError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete pull request review protection
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// [GitHub API docs for delete_pull_request_review_protection](https://docs.github.com/rest/branches/branch-protection#delete-pull-request-review-protection)
///
/// ---
pub async fn delete_pull_request_review_protection_async(&self, owner: &str, repo: &str, branch: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_pull_request_reviews", super::GITHUB_BASE_API_URL, owner, repo, branch);
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(ReposDeletePullRequestReviewProtectionError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposDeletePullRequestReviewProtectionError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete pull request review protection
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// [GitHub API docs for delete_pull_request_review_protection](https://docs.github.com/rest/branches/branch-protection#delete-pull-request-review-protection)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete_pull_request_review_protection(&self, owner: &str, repo: &str, branch: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_pull_request_reviews", super::GITHUB_BASE_API_URL, owner, repo, branch);
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(ReposDeletePullRequestReviewProtectionError::Status404(github_response.to_json()?).into()),
code => Err(ReposDeletePullRequestReviewProtectionError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a release
///
/// Users with push access to the repository can delete a release.
///
/// [GitHub API docs for delete_release](https://docs.github.com/rest/releases/releases#delete-a-release)
///
/// ---
pub async fn delete_release_async(&self, owner: &str, repo: &str, release_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/releases/{}", super::GITHUB_BASE_API_URL, owner, repo, release_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(ReposDeleteReleaseError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a release
///
/// Users with push access to the repository can delete a release.
///
/// [GitHub API docs for delete_release](https://docs.github.com/rest/releases/releases#delete-a-release)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete_release(&self, owner: &str, repo: &str, release_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/releases/{}", super::GITHUB_BASE_API_URL, owner, repo, release_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(ReposDeleteReleaseError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a release asset
///
/// [GitHub API docs for delete_release_asset](https://docs.github.com/rest/releases/assets#delete-a-release-asset)
///
/// ---
pub async fn delete_release_asset_async(&self, owner: &str, repo: &str, asset_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/releases/assets/{}", super::GITHUB_BASE_API_URL, owner, repo, asset_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(ReposDeleteReleaseAssetError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a release asset
///
/// [GitHub API docs for delete_release_asset](https://docs.github.com/rest/releases/assets#delete-a-release-asset)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete_release_asset(&self, owner: &str, repo: &str, asset_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/releases/assets/{}", super::GITHUB_BASE_API_URL, owner, repo, asset_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(ReposDeleteReleaseAssetError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a repository ruleset
///
/// Delete a ruleset for a repository.
///
/// [GitHub API docs for delete_repo_ruleset](https://docs.github.com/rest/repos/rules#delete-a-repository-ruleset)
///
/// ---
pub async fn delete_repo_ruleset_async(&self, owner: &str, repo: &str, ruleset_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/rulesets/{}", super::GITHUB_BASE_API_URL, owner, repo, ruleset_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(ReposDeleteRepoRulesetError::Status404(github_response.to_json_async().await?).into()),
500 => Err(ReposDeleteRepoRulesetError::Status500(github_response.to_json_async().await?).into()),
code => Err(ReposDeleteRepoRulesetError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a repository ruleset
///
/// Delete a ruleset for a repository.
///
/// [GitHub API docs for delete_repo_ruleset](https://docs.github.com/rest/repos/rules#delete-a-repository-ruleset)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete_repo_ruleset(&self, owner: &str, repo: &str, ruleset_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/rulesets/{}", super::GITHUB_BASE_API_URL, owner, repo, ruleset_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(ReposDeleteRepoRulesetError::Status404(github_response.to_json()?).into()),
500 => Err(ReposDeleteRepoRulesetError::Status500(github_response.to_json()?).into()),
code => Err(ReposDeleteRepoRulesetError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Closing down - Delete a tag protection state for a repository
///
/// > [!WARNING]
/// > **Closing down notice:** This operation is closing down and will be removed after August 30, 2024. Use the "[Repository Rulesets](https://docs.github.com/rest/repos/rules#delete-a-repository-ruleset)" endpoint instead.
///
/// This deletes a tag protection state for a repository.
/// This endpoint is only available to repository administrators.
///
/// [GitHub API docs for delete_tag_protection](https://docs.github.com/rest/repos/tags#closing-down---delete-a-tag-protection-state-for-a-repository)
///
/// ---
pub async fn delete_tag_protection_async(&self, owner: &str, repo: &str, tag_protection_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/tags/protection/{}", super::GITHUB_BASE_API_URL, owner, repo, tag_protection_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() {
403 => Err(ReposDeleteTagProtectionError::Status403(github_response.to_json_async().await?).into()),
404 => Err(ReposDeleteTagProtectionError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposDeleteTagProtectionError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Closing down - Delete a tag protection state for a repository
///
/// > [!WARNING]
/// > **Closing down notice:** This operation is closing down and will be removed after August 30, 2024. Use the "[Repository Rulesets](https://docs.github.com/rest/repos/rules#delete-a-repository-ruleset)" endpoint instead.
///
/// This deletes a tag protection state for a repository.
/// This endpoint is only available to repository administrators.
///
/// [GitHub API docs for delete_tag_protection](https://docs.github.com/rest/repos/tags#closing-down---delete-a-tag-protection-state-for-a-repository)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete_tag_protection(&self, owner: &str, repo: &str, tag_protection_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/tags/protection/{}", super::GITHUB_BASE_API_URL, owner, repo, tag_protection_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() {
403 => Err(ReposDeleteTagProtectionError::Status403(github_response.to_json()?).into()),
404 => Err(ReposDeleteTagProtectionError::Status404(github_response.to_json()?).into()),
code => Err(ReposDeleteTagProtectionError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a repository webhook
///
/// Delete a webhook for an organization.
///
/// The authenticated user must be a repository owner, or have admin access in the repository, to delete the webhook.
///
/// [GitHub API docs for delete_webhook](https://docs.github.com/rest/repos/webhooks#delete-a-repository-webhook)
///
/// ---
pub async fn delete_webhook_async(&self, owner: &str, repo: &str, hook_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/hooks/{}", super::GITHUB_BASE_API_URL, owner, repo, 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(ReposDeleteWebhookError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposDeleteWebhookError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a repository webhook
///
/// Delete a webhook for an organization.
///
/// The authenticated user must be a repository owner, or have admin access in the repository, to delete the webhook.
///
/// [GitHub API docs for delete_webhook](https://docs.github.com/rest/repos/webhooks#delete-a-repository-webhook)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete_webhook(&self, owner: &str, repo: &str, hook_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/hooks/{}", super::GITHUB_BASE_API_URL, owner, repo, 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(ReposDeleteWebhookError::Status404(github_response.to_json()?).into()),
code => Err(ReposDeleteWebhookError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Disable Dependabot security updates
///
/// Disables Dependabot security updates for a repository. The authenticated user must have admin access to the repository. For more information, see "[Configuring Dependabot security updates](https://docs.github.com/articles/configuring-automated-security-fixes)".
///
/// [GitHub API docs for disable_automated_security_fixes](https://docs.github.com/rest/repos/repos#disable-dependabot-security-updates)
///
/// ---
pub async fn disable_automated_security_fixes_async(&self, owner: &str, repo: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/automated-security-fixes", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
code => Err(ReposDisableAutomatedSecurityFixesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Disable Dependabot security updates
///
/// Disables Dependabot security updates for a repository. The authenticated user must have admin access to the repository. For more information, see "[Configuring Dependabot security updates](https://docs.github.com/articles/configuring-automated-security-fixes)".
///
/// [GitHub API docs for disable_automated_security_fixes](https://docs.github.com/rest/repos/repos#disable-dependabot-security-updates)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn disable_automated_security_fixes(&self, owner: &str, repo: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/automated-security-fixes", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
code => Err(ReposDisableAutomatedSecurityFixesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Disable a custom protection rule for an environment
///
/// Disables a custom deployment protection rule for an environment.
///
/// The authenticated user must have admin or owner permissions to the repository to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.
///
/// [GitHub API docs for disable_deployment_protection_rule](https://docs.github.com/rest/deployments/protection-rules#disable-a-custom-protection-rule-for-an-environment)
///
/// ---
pub async fn disable_deployment_protection_rule_async(&self, environment_name: &str, repo: &str, owner: &str, protection_rule_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/environments/{}/deployment_protection_rules/{}", super::GITHUB_BASE_API_URL, environment_name, repo, owner, protection_rule_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(ReposDisableDeploymentProtectionRuleError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Disable a custom protection rule for an environment
///
/// Disables a custom deployment protection rule for an environment.
///
/// The authenticated user must have admin or owner permissions to the repository to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.
///
/// [GitHub API docs for disable_deployment_protection_rule](https://docs.github.com/rest/deployments/protection-rules#disable-a-custom-protection-rule-for-an-environment)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn disable_deployment_protection_rule(&self, environment_name: &str, repo: &str, owner: &str, protection_rule_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/environments/{}/deployment_protection_rules/{}", super::GITHUB_BASE_API_URL, environment_name, repo, owner, protection_rule_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(ReposDisableDeploymentProtectionRuleError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Disable private vulnerability reporting for a repository
///
/// Disables private vulnerability reporting for a repository. The authenticated user must have admin access to the repository. For more information, see "[Privately reporting a security vulnerability](https://docs.github.com/code-security/security-advisories/guidance-on-reporting-and-writing/privately-reporting-a-security-vulnerability)".
///
/// [GitHub API docs for disable_private_vulnerability_reporting](https://docs.github.com/rest/repos/repos#disable-private-vulnerability-reporting-for-a-repository)
///
/// ---
pub async fn disable_private_vulnerability_reporting_async(&self, owner: &str, repo: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/private-vulnerability-reporting", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
422 => Err(ReposDisablePrivateVulnerabilityReportingError::Status422(github_response.to_json_async().await?).into()),
code => Err(ReposDisablePrivateVulnerabilityReportingError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Disable private vulnerability reporting for a repository
///
/// Disables private vulnerability reporting for a repository. The authenticated user must have admin access to the repository. For more information, see "[Privately reporting a security vulnerability](https://docs.github.com/code-security/security-advisories/guidance-on-reporting-and-writing/privately-reporting-a-security-vulnerability)".
///
/// [GitHub API docs for disable_private_vulnerability_reporting](https://docs.github.com/rest/repos/repos#disable-private-vulnerability-reporting-for-a-repository)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn disable_private_vulnerability_reporting(&self, owner: &str, repo: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/private-vulnerability-reporting", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
422 => Err(ReposDisablePrivateVulnerabilityReportingError::Status422(github_response.to_json()?).into()),
code => Err(ReposDisablePrivateVulnerabilityReportingError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Disable vulnerability alerts
///
/// Disables dependency alerts and the dependency graph for a repository.
/// The authenticated user must have admin access to the repository. For more information,
/// see "[About security alerts for vulnerable dependencies](https://docs.github.com/articles/about-security-alerts-for-vulnerable-dependencies)".
///
/// [GitHub API docs for disable_vulnerability_alerts](https://docs.github.com/rest/repos/repos#disable-vulnerability-alerts)
///
/// ---
pub async fn disable_vulnerability_alerts_async(&self, owner: &str, repo: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/vulnerability-alerts", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
code => Err(ReposDisableVulnerabilityAlertsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Disable vulnerability alerts
///
/// Disables dependency alerts and the dependency graph for a repository.
/// The authenticated user must have admin access to the repository. For more information,
/// see "[About security alerts for vulnerable dependencies](https://docs.github.com/articles/about-security-alerts-for-vulnerable-dependencies)".
///
/// [GitHub API docs for disable_vulnerability_alerts](https://docs.github.com/rest/repos/repos#disable-vulnerability-alerts)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn disable_vulnerability_alerts(&self, owner: &str, repo: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/vulnerability-alerts", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
code => Err(ReposDisableVulnerabilityAlertsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Download a repository archive (tar)
///
/// Gets a redirect URL to download a tar archive for a repository. If you omit `:ref`, the repository’s default branch (usually
/// `main`) will be used. Please make sure your HTTP framework is configured to follow redirects or you will need to use
/// the `Location` header to make a second `GET` request.
///
/// > [!NOTE]
/// > For private repositories, these links are temporary and expire after five minutes.
///
/// [GitHub API docs for download_tarball_archive](https://docs.github.com/rest/repos/contents#download-a-repository-archive-tar)
///
/// ---
pub async fn download_tarball_archive_async(&self, owner: &str, repo: &str, git_ref: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/tarball/{}", super::GITHUB_BASE_API_URL, owner, repo, git_ref);
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(ReposDownloadTarballArchiveError::Status302.into()),
code => Err(ReposDownloadTarballArchiveError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Download a repository archive (tar)
///
/// Gets a redirect URL to download a tar archive for a repository. If you omit `:ref`, the repository’s default branch (usually
/// `main`) will be used. Please make sure your HTTP framework is configured to follow redirects or you will need to use
/// the `Location` header to make a second `GET` request.
///
/// > [!NOTE]
/// > For private repositories, these links are temporary and expire after five minutes.
///
/// [GitHub API docs for download_tarball_archive](https://docs.github.com/rest/repos/contents#download-a-repository-archive-tar)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn download_tarball_archive(&self, owner: &str, repo: &str, git_ref: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/tarball/{}", super::GITHUB_BASE_API_URL, owner, repo, git_ref);
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(ReposDownloadTarballArchiveError::Status302.into()),
code => Err(ReposDownloadTarballArchiveError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Download a repository archive (zip)
///
/// Gets a redirect URL to download a zip archive for a repository. If you omit `:ref`, the repository’s default branch (usually
/// `main`) will be used. Please make sure your HTTP framework is configured to follow redirects or you will need to use
/// the `Location` header to make a second `GET` request.
///
/// > [!NOTE]
/// > For private repositories, these links are temporary and expire after five minutes. If the repository is empty, you will receive a 404 when you follow the redirect.
///
/// [GitHub API docs for download_zipball_archive](https://docs.github.com/rest/repos/contents#download-a-repository-archive-zip)
///
/// ---
pub async fn download_zipball_archive_async(&self, owner: &str, repo: &str, git_ref: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/zipball/{}", super::GITHUB_BASE_API_URL, owner, repo, git_ref);
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(ReposDownloadZipballArchiveError::Status302.into()),
code => Err(ReposDownloadZipballArchiveError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Download a repository archive (zip)
///
/// Gets a redirect URL to download a zip archive for a repository. If you omit `:ref`, the repository’s default branch (usually
/// `main`) will be used. Please make sure your HTTP framework is configured to follow redirects or you will need to use
/// the `Location` header to make a second `GET` request.
///
/// > [!NOTE]
/// > For private repositories, these links are temporary and expire after five minutes. If the repository is empty, you will receive a 404 when you follow the redirect.
///
/// [GitHub API docs for download_zipball_archive](https://docs.github.com/rest/repos/contents#download-a-repository-archive-zip)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn download_zipball_archive(&self, owner: &str, repo: &str, git_ref: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/zipball/{}", super::GITHUB_BASE_API_URL, owner, repo, git_ref);
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(ReposDownloadZipballArchiveError::Status302.into()),
code => Err(ReposDownloadZipballArchiveError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Enable Dependabot security updates
///
/// Enables Dependabot security updates for a repository. The authenticated user must have admin access to the repository. For more information, see "[Configuring Dependabot security updates](https://docs.github.com/articles/configuring-automated-security-fixes)".
///
/// [GitHub API docs for enable_automated_security_fixes](https://docs.github.com/rest/repos/repos#enable-dependabot-security-updates)
///
/// ---
pub async fn enable_automated_security_fixes_async(&self, owner: &str, repo: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/automated-security-fixes", super::GITHUB_BASE_API_URL, owner, repo);
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(ReposEnableAutomatedSecurityFixesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Enable Dependabot security updates
///
/// Enables Dependabot security updates for a repository. The authenticated user must have admin access to the repository. For more information, see "[Configuring Dependabot security updates](https://docs.github.com/articles/configuring-automated-security-fixes)".
///
/// [GitHub API docs for enable_automated_security_fixes](https://docs.github.com/rest/repos/repos#enable-dependabot-security-updates)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn enable_automated_security_fixes(&self, owner: &str, repo: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/automated-security-fixes", super::GITHUB_BASE_API_URL, owner, repo);
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(ReposEnableAutomatedSecurityFixesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Enable private vulnerability reporting for a repository
///
/// Enables private vulnerability reporting for a repository. The authenticated user must have admin access to the repository. For more information, see "[Privately reporting a security vulnerability](https://docs.github.com/code-security/security-advisories/guidance-on-reporting-and-writing/privately-reporting-a-security-vulnerability)."
///
/// [GitHub API docs for enable_private_vulnerability_reporting](https://docs.github.com/rest/repos/repos#enable-private-vulnerability-reporting-for-a-repository)
///
/// ---
pub async fn enable_private_vulnerability_reporting_async(&self, owner: &str, repo: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/private-vulnerability-reporting", super::GITHUB_BASE_API_URL, owner, repo);
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(ReposEnablePrivateVulnerabilityReportingError::Status422(github_response.to_json_async().await?).into()),
code => Err(ReposEnablePrivateVulnerabilityReportingError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Enable private vulnerability reporting for a repository
///
/// Enables private vulnerability reporting for a repository. The authenticated user must have admin access to the repository. For more information, see "[Privately reporting a security vulnerability](https://docs.github.com/code-security/security-advisories/guidance-on-reporting-and-writing/privately-reporting-a-security-vulnerability)."
///
/// [GitHub API docs for enable_private_vulnerability_reporting](https://docs.github.com/rest/repos/repos#enable-private-vulnerability-reporting-for-a-repository)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn enable_private_vulnerability_reporting(&self, owner: &str, repo: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/private-vulnerability-reporting", super::GITHUB_BASE_API_URL, owner, repo);
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(ReposEnablePrivateVulnerabilityReportingError::Status422(github_response.to_json()?).into()),
code => Err(ReposEnablePrivateVulnerabilityReportingError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Enable vulnerability alerts
///
/// Enables dependency alerts and the dependency graph for a repository. The authenticated user must have admin access to the repository. For more information, see "[About security alerts for vulnerable dependencies](https://docs.github.com/articles/about-security-alerts-for-vulnerable-dependencies)".
///
/// [GitHub API docs for enable_vulnerability_alerts](https://docs.github.com/rest/repos/repos#enable-vulnerability-alerts)
///
/// ---
pub async fn enable_vulnerability_alerts_async(&self, owner: &str, repo: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/vulnerability-alerts", super::GITHUB_BASE_API_URL, owner, repo);
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(ReposEnableVulnerabilityAlertsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Enable vulnerability alerts
///
/// Enables dependency alerts and the dependency graph for a repository. The authenticated user must have admin access to the repository. For more information, see "[About security alerts for vulnerable dependencies](https://docs.github.com/articles/about-security-alerts-for-vulnerable-dependencies)".
///
/// [GitHub API docs for enable_vulnerability_alerts](https://docs.github.com/rest/repos/repos#enable-vulnerability-alerts)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn enable_vulnerability_alerts(&self, owner: &str, repo: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/vulnerability-alerts", super::GITHUB_BASE_API_URL, owner, repo);
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(ReposEnableVulnerabilityAlertsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Generate release notes content for a release
///
/// Generate a name and body describing a [release](https://docs.github.com/rest/releases/releases#get-a-release). The body content will be markdown formatted and contain information like the changes since last release and users who contributed. The generated release notes are not saved anywhere. They are intended to be generated and used when creating a new release.
///
/// [GitHub API docs for generate_release_notes](https://docs.github.com/rest/releases/releases#generate-release-notes-content-for-a-release)
///
/// ---
pub async fn generate_release_notes_async(&self, owner: &str, repo: &str, body: PostReposGenerateReleaseNotes) -> Result<ReleaseNotesContent, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/releases/generate-notes", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposGenerateReleaseNotes>(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(ReposGenerateReleaseNotesError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposGenerateReleaseNotesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Generate release notes content for a release
///
/// Generate a name and body describing a [release](https://docs.github.com/rest/releases/releases#get-a-release). The body content will be markdown formatted and contain information like the changes since last release and users who contributed. The generated release notes are not saved anywhere. They are intended to be generated and used when creating a new release.
///
/// [GitHub API docs for generate_release_notes](https://docs.github.com/rest/releases/releases#generate-release-notes-content-for-a-release)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn generate_release_notes(&self, owner: &str, repo: &str, body: PostReposGenerateReleaseNotes) -> Result<ReleaseNotesContent, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/releases/generate-notes", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposGenerateReleaseNotes>(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(ReposGenerateReleaseNotesError::Status404(github_response.to_json()?).into()),
code => Err(ReposGenerateReleaseNotesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a repository
///
/// The `parent` and `source` objects are present when the repository is a fork. `parent` is the repository this repository was forked from, `source` is the ultimate source for the network.
///
/// > [!NOTE]
/// > In order to see the `security_and_analysis` block for a repository you must have admin permissions for the repository or be an owner or security manager for the organization that owns the repository. 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)."
///
/// [GitHub API docs for get](https://docs.github.com/rest/repos/repos#get-a-repository)
///
/// ---
pub async fn get_async(&self, owner: &str, repo: &str) -> Result<FullRepository, AdapterError> {
let request_uri = format!("{}/repos/{}/{}", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
403 => Err(ReposGetError::Status403(github_response.to_json_async().await?).into()),
404 => Err(ReposGetError::Status404(github_response.to_json_async().await?).into()),
301 => Err(ReposGetError::Status301(github_response.to_json_async().await?).into()),
code => Err(ReposGetError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a repository
///
/// The `parent` and `source` objects are present when the repository is a fork. `parent` is the repository this repository was forked from, `source` is the ultimate source for the network.
///
/// > [!NOTE]
/// > In order to see the `security_and_analysis` block for a repository you must have admin permissions for the repository or be an owner or security manager for the organization that owns the repository. 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)."
///
/// [GitHub API docs for get](https://docs.github.com/rest/repos/repos#get-a-repository)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get(&self, owner: &str, repo: &str) -> Result<FullRepository, AdapterError> {
let request_uri = format!("{}/repos/{}/{}", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
403 => Err(ReposGetError::Status403(github_response.to_json()?).into()),
404 => Err(ReposGetError::Status404(github_response.to_json()?).into()),
301 => Err(ReposGetError::Status301(github_response.to_json()?).into()),
code => Err(ReposGetError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get access restrictions
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// Lists who has access to this protected branch.
///
/// > [!NOTE]
/// > Users, apps, and teams `restrictions` are only available for organization-owned repositories.
///
/// [GitHub API docs for get_access_restrictions](https://docs.github.com/rest/branches/branch-protection#get-access-restrictions)
///
/// ---
pub async fn get_access_restrictions_async(&self, owner: &str, repo: &str, branch: &str) -> Result<BranchRestrictionPolicy, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions", super::GITHUB_BASE_API_URL, owner, repo, branch);
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(ReposGetAccessRestrictionsError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposGetAccessRestrictionsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get access restrictions
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// Lists who has access to this protected branch.
///
/// > [!NOTE]
/// > Users, apps, and teams `restrictions` are only available for organization-owned repositories.
///
/// [GitHub API docs for get_access_restrictions](https://docs.github.com/rest/branches/branch-protection#get-access-restrictions)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_access_restrictions(&self, owner: &str, repo: &str, branch: &str) -> Result<BranchRestrictionPolicy, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions", super::GITHUB_BASE_API_URL, owner, repo, branch);
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(ReposGetAccessRestrictionsError::Status404(github_response.to_json()?).into()),
code => Err(ReposGetAccessRestrictionsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get admin branch protection
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// [GitHub API docs for get_admin_branch_protection](https://docs.github.com/rest/branches/branch-protection#get-admin-branch-protection)
///
/// ---
pub async fn get_admin_branch_protection_async(&self, owner: &str, repo: &str, branch: &str) -> Result<ProtectedBranchAdminEnforced, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/enforce_admins", super::GITHUB_BASE_API_URL, owner, repo, branch);
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(ReposGetAdminBranchProtectionError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get admin branch protection
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// [GitHub API docs for get_admin_branch_protection](https://docs.github.com/rest/branches/branch-protection#get-admin-branch-protection)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_admin_branch_protection(&self, owner: &str, repo: &str, branch: &str) -> Result<ProtectedBranchAdminEnforced, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/enforce_admins", super::GITHUB_BASE_API_URL, owner, repo, branch);
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(ReposGetAdminBranchProtectionError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get all deployment protection rules for an environment
///
/// Gets all custom deployment protection rules that are enabled for an environment. Anyone with read access to the repository can use this endpoint. For more information about environments, see "[Using environments for deployment](https://docs.github.com/actions/deployment/targeting-different-environments/using-environments-for-deployment)."
///
/// For more information about the app that is providing this custom deployment rule, see the [documentation for the `GET /apps/{app_slug}` endpoint](https://docs.github.com/rest/apps/apps#get-an-app).
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with a private repository.
///
/// [GitHub API docs for get_all_deployment_protection_rules](https://docs.github.com/rest/deployments/protection-rules#get-all-deployment-protection-rules-for-an-environment)
///
/// ---
pub async fn get_all_deployment_protection_rules_async(&self, environment_name: &str, repo: &str, owner: &str) -> Result<GetReposGetAllDeploymentProtectionRulesResponse200, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/environments/{}/deployment_protection_rules", super::GITHUB_BASE_API_URL, environment_name, repo, owner);
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(ReposGetAllDeploymentProtectionRulesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get all deployment protection rules for an environment
///
/// Gets all custom deployment protection rules that are enabled for an environment. Anyone with read access to the repository can use this endpoint. For more information about environments, see "[Using environments for deployment](https://docs.github.com/actions/deployment/targeting-different-environments/using-environments-for-deployment)."
///
/// For more information about the app that is providing this custom deployment rule, see the [documentation for the `GET /apps/{app_slug}` endpoint](https://docs.github.com/rest/apps/apps#get-an-app).
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with a private repository.
///
/// [GitHub API docs for get_all_deployment_protection_rules](https://docs.github.com/rest/deployments/protection-rules#get-all-deployment-protection-rules-for-an-environment)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_all_deployment_protection_rules(&self, environment_name: &str, repo: &str, owner: &str) -> Result<GetReposGetAllDeploymentProtectionRulesResponse200, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/environments/{}/deployment_protection_rules", super::GITHUB_BASE_API_URL, environment_name, repo, owner);
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(ReposGetAllDeploymentProtectionRulesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List environments
///
/// Lists the environments for a repository.
///
/// Anyone with read access to the repository can use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with a private repository.
///
/// [GitHub API docs for get_all_environments](https://docs.github.com/rest/deployments/environments#list-environments)
///
/// ---
pub async fn get_all_environments_async(&self, owner: &str, repo: &str, query_params: Option<impl Into<ReposGetAllEnvironmentsParams>>) -> Result<GetReposGetAllEnvironmentsResponse200, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/environments", super::GITHUB_BASE_API_URL, owner, repo);
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(ReposGetAllEnvironmentsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List environments
///
/// Lists the environments for a repository.
///
/// Anyone with read access to the repository can use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with a private repository.
///
/// [GitHub API docs for get_all_environments](https://docs.github.com/rest/deployments/environments#list-environments)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_all_environments(&self, owner: &str, repo: &str, query_params: Option<impl Into<ReposGetAllEnvironmentsParams>>) -> Result<GetReposGetAllEnvironmentsResponse200, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/environments", super::GITHUB_BASE_API_URL, owner, repo);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: ReposGetAllEnvironmentsParams = 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(ReposGetAllEnvironmentsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get all status check contexts
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// [GitHub API docs for get_all_status_check_contexts](https://docs.github.com/rest/branches/branch-protection#get-all-status-check-contexts)
///
/// ---
pub async fn get_all_status_check_contexts_async(&self, owner: &str, repo: &str, branch: &str) -> Result<Vec<String>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_status_checks/contexts", super::GITHUB_BASE_API_URL, owner, repo, branch);
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(ReposGetAllStatusCheckContextsError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposGetAllStatusCheckContextsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get all status check contexts
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// [GitHub API docs for get_all_status_check_contexts](https://docs.github.com/rest/branches/branch-protection#get-all-status-check-contexts)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_all_status_check_contexts(&self, owner: &str, repo: &str, branch: &str) -> Result<Vec<String>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_status_checks/contexts", super::GITHUB_BASE_API_URL, owner, repo, branch);
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(ReposGetAllStatusCheckContextsError::Status404(github_response.to_json()?).into()),
code => Err(ReposGetAllStatusCheckContextsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get all repository topics
///
/// [GitHub API docs for get_all_topics](https://docs.github.com/rest/repos/repos#get-all-repository-topics)
///
/// ---
pub async fn get_all_topics_async(&self, owner: &str, repo: &str, query_params: Option<impl Into<ReposGetAllTopicsParams>>) -> Result<Topic, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/topics", super::GITHUB_BASE_API_URL, owner, repo);
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(ReposGetAllTopicsError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposGetAllTopicsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get all repository topics
///
/// [GitHub API docs for get_all_topics](https://docs.github.com/rest/repos/repos#get-all-repository-topics)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_all_topics(&self, owner: &str, repo: &str, query_params: Option<impl Into<ReposGetAllTopicsParams>>) -> Result<Topic, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/topics", super::GITHUB_BASE_API_URL, owner, repo);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: ReposGetAllTopicsParams = 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(ReposGetAllTopicsError::Status404(github_response.to_json()?).into()),
code => Err(ReposGetAllTopicsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get apps with access to the protected branch
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// Lists the GitHub Apps that have push access to this branch. Only GitHub Apps that are installed on the repository and that have been granted write access to the repository contents can be added as authorized actors on a protected branch.
///
/// [GitHub API docs for get_apps_with_access_to_protected_branch](https://docs.github.com/rest/branches/branch-protection#get-apps-with-access-to-the-protected-branch)
///
/// ---
pub async fn get_apps_with_access_to_protected_branch_async(&self, owner: &str, repo: &str, branch: &str) -> Result<Vec<Integration>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions/apps", super::GITHUB_BASE_API_URL, owner, repo, branch);
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(ReposGetAppsWithAccessToProtectedBranchError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposGetAppsWithAccessToProtectedBranchError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get apps with access to the protected branch
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// Lists the GitHub Apps that have push access to this branch. Only GitHub Apps that are installed on the repository and that have been granted write access to the repository contents can be added as authorized actors on a protected branch.
///
/// [GitHub API docs for get_apps_with_access_to_protected_branch](https://docs.github.com/rest/branches/branch-protection#get-apps-with-access-to-the-protected-branch)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_apps_with_access_to_protected_branch(&self, owner: &str, repo: &str, branch: &str) -> Result<Vec<Integration>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions/apps", super::GITHUB_BASE_API_URL, owner, repo, branch);
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(ReposGetAppsWithAccessToProtectedBranchError::Status404(github_response.to_json()?).into()),
code => Err(ReposGetAppsWithAccessToProtectedBranchError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get an autolink reference of a repository
///
/// This returns a single autolink reference by ID that was configured for the given repository.
///
/// Information about autolinks are only available to repository administrators.
///
/// [GitHub API docs for get_autolink](https://docs.github.com/rest/repos/autolinks#get-an-autolink-reference-of-a-repository)
///
/// ---
pub async fn get_autolink_async(&self, owner: &str, repo: &str, autolink_id: i32) -> Result<Autolink, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/autolinks/{}", super::GITHUB_BASE_API_URL, owner, repo, autolink_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(ReposGetAutolinkError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposGetAutolinkError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get an autolink reference of a repository
///
/// This returns a single autolink reference by ID that was configured for the given repository.
///
/// Information about autolinks are only available to repository administrators.
///
/// [GitHub API docs for get_autolink](https://docs.github.com/rest/repos/autolinks#get-an-autolink-reference-of-a-repository)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_autolink(&self, owner: &str, repo: &str, autolink_id: i32) -> Result<Autolink, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/autolinks/{}", super::GITHUB_BASE_API_URL, owner, repo, autolink_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(ReposGetAutolinkError::Status404(github_response.to_json()?).into()),
code => Err(ReposGetAutolinkError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a branch
///
/// [GitHub API docs for get_branch](https://docs.github.com/rest/branches/branches#get-a-branch)
///
/// ---
pub async fn get_branch_async(&self, owner: &str, repo: &str, branch: &str) -> Result<BranchWithProtection, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}", super::GITHUB_BASE_API_URL, owner, repo, branch);
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() {
301 => Err(ReposGetBranchError::Status301(github_response.to_json_async().await?).into()),
404 => Err(ReposGetBranchError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposGetBranchError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a branch
///
/// [GitHub API docs for get_branch](https://docs.github.com/rest/branches/branches#get-a-branch)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_branch(&self, owner: &str, repo: &str, branch: &str) -> Result<BranchWithProtection, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}", super::GITHUB_BASE_API_URL, owner, repo, branch);
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() {
301 => Err(ReposGetBranchError::Status301(github_response.to_json()?).into()),
404 => Err(ReposGetBranchError::Status404(github_response.to_json()?).into()),
code => Err(ReposGetBranchError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get branch protection
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// [GitHub API docs for get_branch_protection](https://docs.github.com/rest/branches/branch-protection#get-branch-protection)
///
/// ---
pub async fn get_branch_protection_async(&self, owner: &str, repo: &str, branch: &str) -> Result<BranchProtection, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection", super::GITHUB_BASE_API_URL, owner, repo, branch);
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(ReposGetBranchProtectionError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposGetBranchProtectionError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get branch protection
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// [GitHub API docs for get_branch_protection](https://docs.github.com/rest/branches/branch-protection#get-branch-protection)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_branch_protection(&self, owner: &str, repo: &str, branch: &str) -> Result<BranchProtection, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection", super::GITHUB_BASE_API_URL, owner, repo, branch);
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(ReposGetBranchProtectionError::Status404(github_response.to_json()?).into()),
code => Err(ReposGetBranchProtectionError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get rules for a branch
///
/// Returns all active rules that apply to the specified branch. The branch does not need to exist; rules that would apply
/// to a branch with that name will be returned. All active rules that apply will be returned, regardless of the level
/// at which they are configured (e.g. repository or organization). Rules in rulesets with "evaluate" or "disabled"
/// enforcement statuses are not returned.
///
/// [GitHub API docs for get_branch_rules](https://docs.github.com/rest/repos/rules#get-rules-for-a-branch)
///
/// ---
pub async fn get_branch_rules_async(&self, owner: &str, repo: &str, branch: &str, query_params: Option<impl Into<ReposGetBranchRulesParams>>) -> Result<Vec<RepositoryRuleDetailed>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/rules/branches/{}", super::GITHUB_BASE_API_URL, owner, repo, branch);
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(ReposGetBranchRulesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get rules for a branch
///
/// Returns all active rules that apply to the specified branch. The branch does not need to exist; rules that would apply
/// to a branch with that name will be returned. All active rules that apply will be returned, regardless of the level
/// at which they are configured (e.g. repository or organization). Rules in rulesets with "evaluate" or "disabled"
/// enforcement statuses are not returned.
///
/// [GitHub API docs for get_branch_rules](https://docs.github.com/rest/repos/rules#get-rules-for-a-branch)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_branch_rules(&self, owner: &str, repo: &str, branch: &str, query_params: Option<impl Into<ReposGetBranchRulesParams>>) -> Result<Vec<RepositoryRuleDetailed>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/rules/branches/{}", super::GITHUB_BASE_API_URL, owner, repo, branch);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: ReposGetBranchRulesParams = 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(ReposGetBranchRulesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get repository clones
///
/// Get the total number of clones and breakdown per day or week for the last 14 days. Timestamps are aligned to UTC midnight of the beginning of the day or week. Week begins on Monday.
///
/// [GitHub API docs for get_clones](https://docs.github.com/rest/metrics/traffic#get-repository-clones)
///
/// ---
pub async fn get_clones_async(&self, owner: &str, repo: &str, query_params: Option<impl Into<ReposGetClonesParams<'api>>>) -> Result<CloneTraffic, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/traffic/clones", super::GITHUB_BASE_API_URL, owner, repo);
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(ReposGetClonesError::Status403(github_response.to_json_async().await?).into()),
code => Err(ReposGetClonesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get repository clones
///
/// Get the total number of clones and breakdown per day or week for the last 14 days. Timestamps are aligned to UTC midnight of the beginning of the day or week. Week begins on Monday.
///
/// [GitHub API docs for get_clones](https://docs.github.com/rest/metrics/traffic#get-repository-clones)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_clones(&self, owner: &str, repo: &str, query_params: Option<impl Into<ReposGetClonesParams<'api>>>) -> Result<CloneTraffic, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/traffic/clones", super::GITHUB_BASE_API_URL, owner, repo);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: ReposGetClonesParams = 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(ReposGetClonesError::Status403(github_response.to_json()?).into()),
code => Err(ReposGetClonesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get the weekly commit activity
///
/// Returns a weekly aggregate of the number of additions and deletions pushed to a repository.
///
/// > [!NOTE]
/// > This endpoint can only be used for repositories with fewer than 10,000 commits. If the repository contains 10,000 or more commits, a 422 status code will be returned.
///
/// [GitHub API docs for get_code_frequency_stats](https://docs.github.com/rest/metrics/statistics#get-the-weekly-commit-activity)
///
/// ---
pub async fn get_code_frequency_stats_async(&self, owner: &str, repo: &str) -> Result<Vec<CodeFrequencyStat>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/stats/code_frequency", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
202 => Err(ReposGetCodeFrequencyStatsError::Status202(github_response.to_json_async().await?).into()),
204 => Err(ReposGetCodeFrequencyStatsError::Status204.into()),
422 => Err(ReposGetCodeFrequencyStatsError::Status422.into()),
code => Err(ReposGetCodeFrequencyStatsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get the weekly commit activity
///
/// Returns a weekly aggregate of the number of additions and deletions pushed to a repository.
///
/// > [!NOTE]
/// > This endpoint can only be used for repositories with fewer than 10,000 commits. If the repository contains 10,000 or more commits, a 422 status code will be returned.
///
/// [GitHub API docs for get_code_frequency_stats](https://docs.github.com/rest/metrics/statistics#get-the-weekly-commit-activity)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_code_frequency_stats(&self, owner: &str, repo: &str) -> Result<Vec<CodeFrequencyStat>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/stats/code_frequency", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
202 => Err(ReposGetCodeFrequencyStatsError::Status202(github_response.to_json()?).into()),
204 => Err(ReposGetCodeFrequencyStatsError::Status204.into()),
422 => Err(ReposGetCodeFrequencyStatsError::Status422.into()),
code => Err(ReposGetCodeFrequencyStatsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get repository permissions for a user
///
/// Checks the repository permission and role of a collaborator.
///
/// The `permission` attribute provides the legacy base roles of `admin`, `write`, `read`, and `none`, where the
/// `maintain` role is mapped to `write` and the `triage` role is mapped to `read`.
/// The `role_name` attribute provides the name of the assigned role, including custom roles. The
/// `permission` can also be used to determine which base level of access the collaborator has to the repository.
///
/// The calculated permissions are the highest role assigned to the collaborator after considering all sources of grants, including: repo, teams, organization, and enterprise.
/// There is presently not a way to differentiate between an organization level grant and a repository level grant from this endpoint response.
///
/// [GitHub API docs for get_collaborator_permission_level](https://docs.github.com/rest/collaborators/collaborators#get-repository-permissions-for-a-user)
///
/// ---
pub async fn get_collaborator_permission_level_async(&self, owner: &str, repo: &str, username: &str) -> Result<RepositoryCollaboratorPermission, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/collaborators/{}/permission", super::GITHUB_BASE_API_URL, owner, repo, 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(ReposGetCollaboratorPermissionLevelError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposGetCollaboratorPermissionLevelError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get repository permissions for a user
///
/// Checks the repository permission and role of a collaborator.
///
/// The `permission` attribute provides the legacy base roles of `admin`, `write`, `read`, and `none`, where the
/// `maintain` role is mapped to `write` and the `triage` role is mapped to `read`.
/// The `role_name` attribute provides the name of the assigned role, including custom roles. The
/// `permission` can also be used to determine which base level of access the collaborator has to the repository.
///
/// The calculated permissions are the highest role assigned to the collaborator after considering all sources of grants, including: repo, teams, organization, and enterprise.
/// There is presently not a way to differentiate between an organization level grant and a repository level grant from this endpoint response.
///
/// [GitHub API docs for get_collaborator_permission_level](https://docs.github.com/rest/collaborators/collaborators#get-repository-permissions-for-a-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_collaborator_permission_level(&self, owner: &str, repo: &str, username: &str) -> Result<RepositoryCollaboratorPermission, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/collaborators/{}/permission", super::GITHUB_BASE_API_URL, owner, repo, 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(ReposGetCollaboratorPermissionLevelError::Status404(github_response.to_json()?).into()),
code => Err(ReposGetCollaboratorPermissionLevelError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get the combined status for a specific reference
///
/// Users with pull access in a repository can access a combined view of commit statuses for a given ref. The ref can be a SHA, a branch name, or a tag name.
///
///
/// Additionally, a combined `state` is returned. The `state` is one of:
///
/// * **failure** if any of the contexts report as `error` or `failure`
/// * **pending** if there are no statuses or a context is `pending`
/// * **success** if the latest status for all contexts is `success`
///
/// [GitHub API docs for get_combined_status_for_ref](https://docs.github.com/rest/commits/statuses#get-the-combined-status-for-a-specific-reference)
///
/// ---
pub async fn get_combined_status_for_ref_async(&self, owner: &str, repo: &str, git_ref: &str, query_params: Option<impl Into<ReposGetCombinedStatusForRefParams>>) -> Result<CombinedCommitStatus, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/commits/{}/status", super::GITHUB_BASE_API_URL, owner, repo, git_ref);
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(ReposGetCombinedStatusForRefError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposGetCombinedStatusForRefError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get the combined status for a specific reference
///
/// Users with pull access in a repository can access a combined view of commit statuses for a given ref. The ref can be a SHA, a branch name, or a tag name.
///
///
/// Additionally, a combined `state` is returned. The `state` is one of:
///
/// * **failure** if any of the contexts report as `error` or `failure`
/// * **pending** if there are no statuses or a context is `pending`
/// * **success** if the latest status for all contexts is `success`
///
/// [GitHub API docs for get_combined_status_for_ref](https://docs.github.com/rest/commits/statuses#get-the-combined-status-for-a-specific-reference)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_combined_status_for_ref(&self, owner: &str, repo: &str, git_ref: &str, query_params: Option<impl Into<ReposGetCombinedStatusForRefParams>>) -> Result<CombinedCommitStatus, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/commits/{}/status", super::GITHUB_BASE_API_URL, owner, repo, git_ref);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: ReposGetCombinedStatusForRefParams = 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(ReposGetCombinedStatusForRefError::Status404(github_response.to_json()?).into()),
code => Err(ReposGetCombinedStatusForRefError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a commit
///
/// Returns the contents of a single commit reference. You must have `read` access for the repository to use this endpoint.
///
/// > [!NOTE]
/// > If there are more than 300 files in the commit diff and the default JSON media type is requested, the response will include pagination link headers for the remaining files, up to a limit of 3000 files. Each page contains the static commit information, and the only changes are to the file listing.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." Pagination query parameters are not supported for these media types.
///
/// - **`application/vnd.github.diff`**: Returns the diff of the commit. Larger diffs may time out and return a 5xx status code.
/// - **`application/vnd.github.patch`**: Returns the patch of the commit. Diffs with binary data will have no `patch` property. Larger diffs may time out and return a 5xx status code.
/// - **`application/vnd.github.sha`**: Returns the commit's SHA-1 hash. You can use this endpoint to check if a remote reference's SHA-1 hash is the same as your local reference's SHA-1 hash by providing the local SHA-1 reference as the ETag.
///
/// **Signature verification object**
///
/// The response will include a `verification` object that describes the result of verifying the commit's signature. The following fields are included in the `verification` object:
///
/// | Name | Type | Description |
/// | ---- | ---- | ----------- |
/// | `verified` | `boolean` | Indicates whether GitHub considers the signature in this commit to be verified. |
/// | `reason` | `string` | The reason for verified value. Possible values and their meanings are enumerated in table below. |
/// | `signature` | `string` | The signature that was extracted from the commit. |
/// | `payload` | `string` | The value that was signed. |
/// | `verified_at` | `string` | The date the signature was verified by GitHub. |
///
/// These are the possible values for `reason` in the `verification` object:
///
/// | Value | Description |
/// | ----- | ----------- |
/// | `expired_key` | The key that made the signature is expired. |
/// | `not_signing_key` | The "signing" flag is not among the usage flags in the GPG key that made the signature. |
/// | `gpgverify_error` | There was an error communicating with the signature verification service. |
/// | `gpgverify_unavailable` | The signature verification service is currently unavailable. |
/// | `unsigned` | The object does not include a signature. |
/// | `unknown_signature_type` | A non-PGP signature was found in the commit. |
/// | `no_user` | No user was associated with the `committer` email address in the commit. |
/// | `unverified_email` | The `committer` email address in the commit was associated with a user, but the email address is not verified on their account. |
/// | `bad_email` | The `committer` email address in the commit is not included in the identities of the PGP key that made the signature. |
/// | `unknown_key` | The key that made the signature has not been registered with any user's account. |
/// | `malformed_signature` | There was an error parsing the signature. |
/// | `invalid` | The signature could not be cryptographically verified using the key whose key-id was found in the signature. |
/// | `valid` | None of the above errors applied, so the signature is considered to be verified. |
///
/// [GitHub API docs for get_commit](https://docs.github.com/rest/commits/commits#get-a-commit)
///
/// ---
pub async fn get_commit_async(&self, owner: &str, repo: &str, git_ref: &str, query_params: Option<impl Into<ReposGetCommitParams>>) -> Result<Commit, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/commits/{}", super::GITHUB_BASE_API_URL, owner, repo, git_ref);
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(ReposGetCommitError::Status422(github_response.to_json_async().await?).into()),
404 => Err(ReposGetCommitError::Status404(github_response.to_json_async().await?).into()),
500 => Err(ReposGetCommitError::Status500(github_response.to_json_async().await?).into()),
503 => Err(ReposGetCommitError::Status503(github_response.to_json_async().await?).into()),
409 => Err(ReposGetCommitError::Status409(github_response.to_json_async().await?).into()),
code => Err(ReposGetCommitError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a commit
///
/// Returns the contents of a single commit reference. You must have `read` access for the repository to use this endpoint.
///
/// > [!NOTE]
/// > If there are more than 300 files in the commit diff and the default JSON media type is requested, the response will include pagination link headers for the remaining files, up to a limit of 3000 files. Each page contains the static commit information, and the only changes are to the file listing.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)." Pagination query parameters are not supported for these media types.
///
/// - **`application/vnd.github.diff`**: Returns the diff of the commit. Larger diffs may time out and return a 5xx status code.
/// - **`application/vnd.github.patch`**: Returns the patch of the commit. Diffs with binary data will have no `patch` property. Larger diffs may time out and return a 5xx status code.
/// - **`application/vnd.github.sha`**: Returns the commit's SHA-1 hash. You can use this endpoint to check if a remote reference's SHA-1 hash is the same as your local reference's SHA-1 hash by providing the local SHA-1 reference as the ETag.
///
/// **Signature verification object**
///
/// The response will include a `verification` object that describes the result of verifying the commit's signature. The following fields are included in the `verification` object:
///
/// | Name | Type | Description |
/// | ---- | ---- | ----------- |
/// | `verified` | `boolean` | Indicates whether GitHub considers the signature in this commit to be verified. |
/// | `reason` | `string` | The reason for verified value. Possible values and their meanings are enumerated in table below. |
/// | `signature` | `string` | The signature that was extracted from the commit. |
/// | `payload` | `string` | The value that was signed. |
/// | `verified_at` | `string` | The date the signature was verified by GitHub. |
///
/// These are the possible values for `reason` in the `verification` object:
///
/// | Value | Description |
/// | ----- | ----------- |
/// | `expired_key` | The key that made the signature is expired. |
/// | `not_signing_key` | The "signing" flag is not among the usage flags in the GPG key that made the signature. |
/// | `gpgverify_error` | There was an error communicating with the signature verification service. |
/// | `gpgverify_unavailable` | The signature verification service is currently unavailable. |
/// | `unsigned` | The object does not include a signature. |
/// | `unknown_signature_type` | A non-PGP signature was found in the commit. |
/// | `no_user` | No user was associated with the `committer` email address in the commit. |
/// | `unverified_email` | The `committer` email address in the commit was associated with a user, but the email address is not verified on their account. |
/// | `bad_email` | The `committer` email address in the commit is not included in the identities of the PGP key that made the signature. |
/// | `unknown_key` | The key that made the signature has not been registered with any user's account. |
/// | `malformed_signature` | There was an error parsing the signature. |
/// | `invalid` | The signature could not be cryptographically verified using the key whose key-id was found in the signature. |
/// | `valid` | None of the above errors applied, so the signature is considered to be verified. |
///
/// [GitHub API docs for get_commit](https://docs.github.com/rest/commits/commits#get-a-commit)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_commit(&self, owner: &str, repo: &str, git_ref: &str, query_params: Option<impl Into<ReposGetCommitParams>>) -> Result<Commit, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/commits/{}", super::GITHUB_BASE_API_URL, owner, repo, git_ref);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: ReposGetCommitParams = 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(ReposGetCommitError::Status422(github_response.to_json()?).into()),
404 => Err(ReposGetCommitError::Status404(github_response.to_json()?).into()),
500 => Err(ReposGetCommitError::Status500(github_response.to_json()?).into()),
503 => Err(ReposGetCommitError::Status503(github_response.to_json()?).into()),
409 => Err(ReposGetCommitError::Status409(github_response.to_json()?).into()),
code => Err(ReposGetCommitError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get the last year of commit activity
///
/// Returns the last year of commit activity grouped by week. The `days` array is a group of commits per day, starting on `Sunday`.
///
/// [GitHub API docs for get_commit_activity_stats](https://docs.github.com/rest/metrics/statistics#get-the-last-year-of-commit-activity)
///
/// ---
pub async fn get_commit_activity_stats_async(&self, owner: &str, repo: &str) -> Result<Vec<CommitActivity>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/stats/commit_activity", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
202 => Err(ReposGetCommitActivityStatsError::Status202(github_response.to_json_async().await?).into()),
204 => Err(ReposGetCommitActivityStatsError::Status204.into()),
code => Err(ReposGetCommitActivityStatsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get the last year of commit activity
///
/// Returns the last year of commit activity grouped by week. The `days` array is a group of commits per day, starting on `Sunday`.
///
/// [GitHub API docs for get_commit_activity_stats](https://docs.github.com/rest/metrics/statistics#get-the-last-year-of-commit-activity)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_commit_activity_stats(&self, owner: &str, repo: &str) -> Result<Vec<CommitActivity>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/stats/commit_activity", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
202 => Err(ReposGetCommitActivityStatsError::Status202(github_response.to_json()?).into()),
204 => Err(ReposGetCommitActivityStatsError::Status204.into()),
code => Err(ReposGetCommitActivityStatsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a commit comment
///
/// Gets a specified commit comment.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
///
/// [GitHub API docs for get_commit_comment](https://docs.github.com/rest/commits/comments#get-a-commit-comment)
///
/// ---
pub async fn get_commit_comment_async(&self, owner: &str, repo: &str, comment_id: i64) -> Result<CommitComment, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/comments/{}", super::GITHUB_BASE_API_URL, owner, repo, comment_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(ReposGetCommitCommentError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposGetCommitCommentError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a commit comment
///
/// Gets a specified commit comment.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
///
/// [GitHub API docs for get_commit_comment](https://docs.github.com/rest/commits/comments#get-a-commit-comment)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_commit_comment(&self, owner: &str, repo: &str, comment_id: i64) -> Result<CommitComment, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/comments/{}", super::GITHUB_BASE_API_URL, owner, repo, comment_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(ReposGetCommitCommentError::Status404(github_response.to_json()?).into()),
code => Err(ReposGetCommitCommentError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get commit signature protection
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// When authenticated with admin or owner permissions to the repository, you can use this endpoint to check whether a branch requires signed commits. An enabled status of `true` indicates you must sign commits on this branch. For more information, see [Signing commits with GPG](https://docs.github.com/articles/signing-commits-with-gpg) in GitHub Help.
///
/// > [!NOTE]
/// > You must enable branch protection to require signed commits.
///
/// [GitHub API docs for get_commit_signature_protection](https://docs.github.com/rest/branches/branch-protection#get-commit-signature-protection)
///
/// ---
pub async fn get_commit_signature_protection_async(&self, owner: &str, repo: &str, branch: &str) -> Result<ProtectedBranchAdminEnforced, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_signatures", super::GITHUB_BASE_API_URL, owner, repo, branch);
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(ReposGetCommitSignatureProtectionError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposGetCommitSignatureProtectionError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get commit signature protection
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// When authenticated with admin or owner permissions to the repository, you can use this endpoint to check whether a branch requires signed commits. An enabled status of `true` indicates you must sign commits on this branch. For more information, see [Signing commits with GPG](https://docs.github.com/articles/signing-commits-with-gpg) in GitHub Help.
///
/// > [!NOTE]
/// > You must enable branch protection to require signed commits.
///
/// [GitHub API docs for get_commit_signature_protection](https://docs.github.com/rest/branches/branch-protection#get-commit-signature-protection)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_commit_signature_protection(&self, owner: &str, repo: &str, branch: &str) -> Result<ProtectedBranchAdminEnforced, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_signatures", super::GITHUB_BASE_API_URL, owner, repo, branch);
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(ReposGetCommitSignatureProtectionError::Status404(github_response.to_json()?).into()),
code => Err(ReposGetCommitSignatureProtectionError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get community profile metrics
///
/// Returns all community profile metrics for a repository. The repository cannot be a fork.
///
/// The returned metrics include an overall health score, the repository description, the presence of documentation, the
/// detected code of conduct, the detected license, and the presence of ISSUE\_TEMPLATE, PULL\_REQUEST\_TEMPLATE,
/// README, and CONTRIBUTING files.
///
/// The `health_percentage` score is defined as a percentage of how many of
/// the recommended community health files are present. For more information, see
/// "[About community profiles for public repositories](https://docs.github.com/communities/setting-up-your-project-for-healthy-contributions/about-community-profiles-for-public-repositories)."
///
/// `content_reports_enabled` is only returned for organization-owned repositories.
///
/// [GitHub API docs for get_community_profile_metrics](https://docs.github.com/rest/metrics/community#get-community-profile-metrics)
///
/// ---
pub async fn get_community_profile_metrics_async(&self, owner: &str, repo: &str) -> Result<CommunityProfile, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/community/profile", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
code => Err(ReposGetCommunityProfileMetricsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get community profile metrics
///
/// Returns all community profile metrics for a repository. The repository cannot be a fork.
///
/// The returned metrics include an overall health score, the repository description, the presence of documentation, the
/// detected code of conduct, the detected license, and the presence of ISSUE\_TEMPLATE, PULL\_REQUEST\_TEMPLATE,
/// README, and CONTRIBUTING files.
///
/// The `health_percentage` score is defined as a percentage of how many of
/// the recommended community health files are present. For more information, see
/// "[About community profiles for public repositories](https://docs.github.com/communities/setting-up-your-project-for-healthy-contributions/about-community-profiles-for-public-repositories)."
///
/// `content_reports_enabled` is only returned for organization-owned repositories.
///
/// [GitHub API docs for get_community_profile_metrics](https://docs.github.com/rest/metrics/community#get-community-profile-metrics)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_community_profile_metrics(&self, owner: &str, repo: &str) -> Result<CommunityProfile, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/community/profile", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
code => Err(ReposGetCommunityProfileMetricsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get repository content
///
/// Gets the contents of a file or directory in a repository. Specify the file path or directory with the `path` parameter. If you omit the `path` parameter, you will receive the contents of the repository's root directory.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github.raw+json`**: Returns the raw file contents for files and symlinks.
/// - **`application/vnd.github.html+json`**: Returns the file contents in HTML. Markup languages are rendered to HTML using GitHub's open-source [Markup library](https://github.com/github/markup).
/// - **`application/vnd.github.object+json`**: Returns the contents in a consistent object format regardless of the content type. For example, instead of an array of objects for a directory, the response will be an object with an `entries` attribute containing the array of objects.
///
/// If the content is a directory, the response will be an array of objects, one object for each item in the directory. When listing the contents of a directory, submodules have their "type" specified as "file". Logically, the value _should_ be "submodule". This behavior exists [for backwards compatibility purposes](https://git.io/v1YCW). In the next major version of the API, the type will be returned as "submodule".
///
/// If the content is a symlink and the symlink's target is a normal file in the repository, then the API responds with the content of the file. Otherwise, the API responds with an object describing the symlink itself.
///
/// If the content is a submodule, the `submodule_git_url` field identifies the location of the submodule repository, and the `sha` identifies a specific commit within the submodule repository. Git uses the given URL when cloning the submodule repository, and checks out the submodule at that specific commit. If the submodule repository is not hosted on github.com, the Git URLs (`git_url` and `_links["git"]`) and the github.com URLs (`html_url` and `_links["html"]`) will have null values.
///
/// **Notes**:
///
/// - To get a repository's contents recursively, you can [recursively get the tree](https://docs.github.com/rest/git/trees#get-a-tree).
/// - This API has an upper limit of 1,000 files for a directory. If you need to retrieve
/// more files, use the [Git Trees API](https://docs.github.com/rest/git/trees#get-a-tree).
/// - Download URLs expire and are meant to be used just once. To ensure the download URL does not expire, please use the contents API to obtain a fresh download URL for each download.
/// - If the requested file's size is:
/// - 1 MB or smaller: All features of this endpoint are supported.
/// - Between 1-100 MB: Only the `raw` or `object` custom media types are supported. Both will work as normal, except that when using the `object` media type, the `content` field will be an empty
/// string and the `encoding` field will be `"none"`. To get the contents of these larger files, use the `raw` media type.
/// - Greater than 100 MB: This endpoint is not supported.
///
/// [GitHub API docs for get_content](https://docs.github.com/rest/repos/contents#get-repository-content)
///
/// ---
pub async fn get_content_async(&self, owner: &str, repo: &str, path: &str, query_params: Option<impl Into<ReposGetContentParams<'api>>>) -> Result<ContentTree, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/contents/{}", super::GITHUB_BASE_API_URL, owner, repo, path);
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(ReposGetContentError::Status404(github_response.to_json_async().await?).into()),
403 => Err(ReposGetContentError::Status403(github_response.to_json_async().await?).into()),
302 => Err(ReposGetContentError::Status302.into()),
304 => Err(ReposGetContentError::Status304.into()),
code => Err(ReposGetContentError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get repository content
///
/// Gets the contents of a file or directory in a repository. Specify the file path or directory with the `path` parameter. If you omit the `path` parameter, you will receive the contents of the repository's root directory.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github.raw+json`**: Returns the raw file contents for files and symlinks.
/// - **`application/vnd.github.html+json`**: Returns the file contents in HTML. Markup languages are rendered to HTML using GitHub's open-source [Markup library](https://github.com/github/markup).
/// - **`application/vnd.github.object+json`**: Returns the contents in a consistent object format regardless of the content type. For example, instead of an array of objects for a directory, the response will be an object with an `entries` attribute containing the array of objects.
///
/// If the content is a directory, the response will be an array of objects, one object for each item in the directory. When listing the contents of a directory, submodules have their "type" specified as "file". Logically, the value _should_ be "submodule". This behavior exists [for backwards compatibility purposes](https://git.io/v1YCW). In the next major version of the API, the type will be returned as "submodule".
///
/// If the content is a symlink and the symlink's target is a normal file in the repository, then the API responds with the content of the file. Otherwise, the API responds with an object describing the symlink itself.
///
/// If the content is a submodule, the `submodule_git_url` field identifies the location of the submodule repository, and the `sha` identifies a specific commit within the submodule repository. Git uses the given URL when cloning the submodule repository, and checks out the submodule at that specific commit. If the submodule repository is not hosted on github.com, the Git URLs (`git_url` and `_links["git"]`) and the github.com URLs (`html_url` and `_links["html"]`) will have null values.
///
/// **Notes**:
///
/// - To get a repository's contents recursively, you can [recursively get the tree](https://docs.github.com/rest/git/trees#get-a-tree).
/// - This API has an upper limit of 1,000 files for a directory. If you need to retrieve
/// more files, use the [Git Trees API](https://docs.github.com/rest/git/trees#get-a-tree).
/// - Download URLs expire and are meant to be used just once. To ensure the download URL does not expire, please use the contents API to obtain a fresh download URL for each download.
/// - If the requested file's size is:
/// - 1 MB or smaller: All features of this endpoint are supported.
/// - Between 1-100 MB: Only the `raw` or `object` custom media types are supported. Both will work as normal, except that when using the `object` media type, the `content` field will be an empty
/// string and the `encoding` field will be `"none"`. To get the contents of these larger files, use the `raw` media type.
/// - Greater than 100 MB: This endpoint is not supported.
///
/// [GitHub API docs for get_content](https://docs.github.com/rest/repos/contents#get-repository-content)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_content(&self, owner: &str, repo: &str, path: &str, query_params: Option<impl Into<ReposGetContentParams<'api>>>) -> Result<ContentTree, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/contents/{}", super::GITHUB_BASE_API_URL, owner, repo, path);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: ReposGetContentParams = 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(ReposGetContentError::Status404(github_response.to_json()?).into()),
403 => Err(ReposGetContentError::Status403(github_response.to_json()?).into()),
302 => Err(ReposGetContentError::Status302.into()),
304 => Err(ReposGetContentError::Status304.into()),
code => Err(ReposGetContentError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get all contributor commit activity
///
///
/// Returns the `total` number of commits authored by the contributor. In addition, the response includes a Weekly Hash (`weeks` array) with the following information:
///
/// * `w` - Start of the week, given as a [Unix timestamp](https://en.wikipedia.org/wiki/Unix_time).
/// * `a` - Number of additions
/// * `d` - Number of deletions
/// * `c` - Number of commits
///
/// > [!NOTE]
/// > This endpoint will return `0` values for all addition and deletion counts in repositories with 10,000 or more commits.
///
/// [GitHub API docs for get_contributors_stats](https://docs.github.com/rest/metrics/statistics#get-all-contributor-commit-activity)
///
/// ---
pub async fn get_contributors_stats_async(&self, owner: &str, repo: &str) -> Result<Vec<ContributorActivity>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/stats/contributors", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
202 => Err(ReposGetContributorsStatsError::Status202(github_response.to_json_async().await?).into()),
204 => Err(ReposGetContributorsStatsError::Status204.into()),
code => Err(ReposGetContributorsStatsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get all contributor commit activity
///
///
/// Returns the `total` number of commits authored by the contributor. In addition, the response includes a Weekly Hash (`weeks` array) with the following information:
///
/// * `w` - Start of the week, given as a [Unix timestamp](https://en.wikipedia.org/wiki/Unix_time).
/// * `a` - Number of additions
/// * `d` - Number of deletions
/// * `c` - Number of commits
///
/// > [!NOTE]
/// > This endpoint will return `0` values for all addition and deletion counts in repositories with 10,000 or more commits.
///
/// [GitHub API docs for get_contributors_stats](https://docs.github.com/rest/metrics/statistics#get-all-contributor-commit-activity)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_contributors_stats(&self, owner: &str, repo: &str) -> Result<Vec<ContributorActivity>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/stats/contributors", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
202 => Err(ReposGetContributorsStatsError::Status202(github_response.to_json()?).into()),
204 => Err(ReposGetContributorsStatsError::Status204.into()),
code => Err(ReposGetContributorsStatsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a custom deployment protection rule
///
/// Gets an enabled custom deployment protection rule for an environment. Anyone with read access to the repository can use this endpoint. For more information about environments, see "[Using environments for deployment](https://docs.github.com/actions/deployment/targeting-different-environments/using-environments-for-deployment)."
///
/// For more information about the app that is providing this custom deployment rule, see [`GET /apps/{app_slug}`](https://docs.github.com/rest/apps/apps#get-an-app).
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with a private repository.
///
/// [GitHub API docs for get_custom_deployment_protection_rule](https://docs.github.com/rest/deployments/protection-rules#get-a-custom-deployment-protection-rule)
///
/// ---
pub async fn get_custom_deployment_protection_rule_async(&self, owner: &str, repo: &str, environment_name: &str, protection_rule_id: i32) -> Result<DeploymentProtectionRule, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/environments/{}/deployment_protection_rules/{}", super::GITHUB_BASE_API_URL, owner, repo, environment_name, protection_rule_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(ReposGetCustomDeploymentProtectionRuleError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a custom deployment protection rule
///
/// Gets an enabled custom deployment protection rule for an environment. Anyone with read access to the repository can use this endpoint. For more information about environments, see "[Using environments for deployment](https://docs.github.com/actions/deployment/targeting-different-environments/using-environments-for-deployment)."
///
/// For more information about the app that is providing this custom deployment rule, see [`GET /apps/{app_slug}`](https://docs.github.com/rest/apps/apps#get-an-app).
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with a private repository.
///
/// [GitHub API docs for get_custom_deployment_protection_rule](https://docs.github.com/rest/deployments/protection-rules#get-a-custom-deployment-protection-rule)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_custom_deployment_protection_rule(&self, owner: &str, repo: &str, environment_name: &str, protection_rule_id: i32) -> Result<DeploymentProtectionRule, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/environments/{}/deployment_protection_rules/{}", super::GITHUB_BASE_API_URL, owner, repo, environment_name, protection_rule_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(ReposGetCustomDeploymentProtectionRuleError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get all custom property values for a repository
///
/// Gets all custom property values that are set for a repository.
/// Users with read access to the repository can use this endpoint.
///
/// [GitHub API docs for get_custom_properties_values](https://docs.github.com/rest/repos/custom-properties#get-all-custom-property-values-for-a-repository)
///
/// ---
pub async fn get_custom_properties_values_async(&self, owner: &str, repo: &str) -> Result<Vec<CustomPropertyValue>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/properties/values", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
403 => Err(ReposGetCustomPropertiesValuesError::Status403(github_response.to_json_async().await?).into()),
404 => Err(ReposGetCustomPropertiesValuesError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposGetCustomPropertiesValuesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get all custom property values for a repository
///
/// Gets all custom property values that are set for a repository.
/// Users with read access to the repository can use this endpoint.
///
/// [GitHub API docs for get_custom_properties_values](https://docs.github.com/rest/repos/custom-properties#get-all-custom-property-values-for-a-repository)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_custom_properties_values(&self, owner: &str, repo: &str) -> Result<Vec<CustomPropertyValue>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/properties/values", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
403 => Err(ReposGetCustomPropertiesValuesError::Status403(github_response.to_json()?).into()),
404 => Err(ReposGetCustomPropertiesValuesError::Status404(github_response.to_json()?).into()),
code => Err(ReposGetCustomPropertiesValuesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a deploy key
///
/// [GitHub API docs for get_deploy_key](https://docs.github.com/rest/deploy-keys/deploy-keys#get-a-deploy-key)
///
/// ---
pub async fn get_deploy_key_async(&self, owner: &str, repo: &str, key_id: i32) -> Result<DeployKey, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/keys/{}", super::GITHUB_BASE_API_URL, owner, repo, key_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(ReposGetDeployKeyError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposGetDeployKeyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a deploy key
///
/// [GitHub API docs for get_deploy_key](https://docs.github.com/rest/deploy-keys/deploy-keys#get-a-deploy-key)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_deploy_key(&self, owner: &str, repo: &str, key_id: i32) -> Result<DeployKey, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/keys/{}", super::GITHUB_BASE_API_URL, owner, repo, key_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(ReposGetDeployKeyError::Status404(github_response.to_json()?).into()),
code => Err(ReposGetDeployKeyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a deployment
///
/// [GitHub API docs for get_deployment](https://docs.github.com/rest/deployments/deployments#get-a-deployment)
///
/// ---
pub async fn get_deployment_async(&self, owner: &str, repo: &str, deployment_id: i32) -> Result<Deployment, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/deployments/{}", super::GITHUB_BASE_API_URL, owner, repo, deployment_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(ReposGetDeploymentError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposGetDeploymentError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a deployment
///
/// [GitHub API docs for get_deployment](https://docs.github.com/rest/deployments/deployments#get-a-deployment)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_deployment(&self, owner: &str, repo: &str, deployment_id: i32) -> Result<Deployment, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/deployments/{}", super::GITHUB_BASE_API_URL, owner, repo, deployment_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(ReposGetDeploymentError::Status404(github_response.to_json()?).into()),
code => Err(ReposGetDeploymentError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a deployment branch policy
///
/// Gets a deployment branch or tag policy for an environment.
///
/// Anyone with read access to the repository can use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with a private repository.
///
/// [GitHub API docs for get_deployment_branch_policy](https://docs.github.com/rest/deployments/branch-policies#get-a-deployment-branch-policy)
///
/// ---
pub async fn get_deployment_branch_policy_async(&self, owner: &str, repo: &str, environment_name: &str, branch_policy_id: i32) -> Result<DeploymentBranchPolicy, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/environments/{}/deployment-branch-policies/{}", super::GITHUB_BASE_API_URL, owner, repo, environment_name, branch_policy_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(ReposGetDeploymentBranchPolicyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a deployment branch policy
///
/// Gets a deployment branch or tag policy for an environment.
///
/// Anyone with read access to the repository can use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with a private repository.
///
/// [GitHub API docs for get_deployment_branch_policy](https://docs.github.com/rest/deployments/branch-policies#get-a-deployment-branch-policy)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_deployment_branch_policy(&self, owner: &str, repo: &str, environment_name: &str, branch_policy_id: i32) -> Result<DeploymentBranchPolicy, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/environments/{}/deployment-branch-policies/{}", super::GITHUB_BASE_API_URL, owner, repo, environment_name, branch_policy_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(ReposGetDeploymentBranchPolicyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a deployment status
///
/// Users with pull access can view a deployment status for a deployment:
///
/// [GitHub API docs for get_deployment_status](https://docs.github.com/rest/deployments/statuses#get-a-deployment-status)
///
/// ---
pub async fn get_deployment_status_async(&self, owner: &str, repo: &str, deployment_id: i32, status_id: i32) -> Result<DeploymentStatus, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/deployments/{}/statuses/{}", super::GITHUB_BASE_API_URL, owner, repo, deployment_id, status_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(ReposGetDeploymentStatusError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposGetDeploymentStatusError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a deployment status
///
/// Users with pull access can view a deployment status for a deployment:
///
/// [GitHub API docs for get_deployment_status](https://docs.github.com/rest/deployments/statuses#get-a-deployment-status)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_deployment_status(&self, owner: &str, repo: &str, deployment_id: i32, status_id: i32) -> Result<DeploymentStatus, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/deployments/{}/statuses/{}", super::GITHUB_BASE_API_URL, owner, repo, deployment_id, status_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(ReposGetDeploymentStatusError::Status404(github_response.to_json()?).into()),
code => Err(ReposGetDeploymentStatusError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get an environment
///
/// > [!NOTE]
/// > To get information about name patterns that branches must match in order to deploy to this environment, see "[Get a deployment branch policy](/rest/deployments/branch-policies#get-a-deployment-branch-policy)."
///
/// Anyone with read access to the repository can use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with a private repository.
///
/// [GitHub API docs for get_environment](https://docs.github.com/rest/deployments/environments#get-an-environment)
///
/// ---
pub async fn get_environment_async(&self, owner: &str, repo: &str, environment_name: &str) -> Result<Environment, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/environments/{}", super::GITHUB_BASE_API_URL, owner, repo, environment_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() {
code => Err(ReposGetEnvironmentError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get an environment
///
/// > [!NOTE]
/// > To get information about name patterns that branches must match in order to deploy to this environment, see "[Get a deployment branch policy](/rest/deployments/branch-policies#get-a-deployment-branch-policy)."
///
/// Anyone with read access to the repository can use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with a private repository.
///
/// [GitHub API docs for get_environment](https://docs.github.com/rest/deployments/environments#get-an-environment)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_environment(&self, owner: &str, repo: &str, environment_name: &str) -> Result<Environment, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/environments/{}", super::GITHUB_BASE_API_URL, owner, repo, environment_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() {
code => Err(ReposGetEnvironmentError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get latest Pages build
///
/// Gets information about the single most recent build of a GitHub Pages site.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.
///
/// [GitHub API docs for get_latest_pages_build](https://docs.github.com/rest/pages/pages#get-latest-pages-build)
///
/// ---
pub async fn get_latest_pages_build_async(&self, owner: &str, repo: &str) -> Result<PageBuild, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pages/builds/latest", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
code => Err(ReposGetLatestPagesBuildError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get latest Pages build
///
/// Gets information about the single most recent build of a GitHub Pages site.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.
///
/// [GitHub API docs for get_latest_pages_build](https://docs.github.com/rest/pages/pages#get-latest-pages-build)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_latest_pages_build(&self, owner: &str, repo: &str) -> Result<PageBuild, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pages/builds/latest", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
code => Err(ReposGetLatestPagesBuildError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get the latest release
///
/// View the latest published full release for the repository.
///
/// The latest release is the most recent non-prerelease, non-draft release, sorted by the `created_at` attribute. The `created_at` attribute is the date of the commit used for the release, and not the date when the release was drafted or published.
///
/// [GitHub API docs for get_latest_release](https://docs.github.com/rest/releases/releases#get-the-latest-release)
///
/// ---
pub async fn get_latest_release_async(&self, owner: &str, repo: &str) -> Result<Release, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/releases/latest", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
code => Err(ReposGetLatestReleaseError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get the latest release
///
/// View the latest published full release for the repository.
///
/// The latest release is the most recent non-prerelease, non-draft release, sorted by the `created_at` attribute. The `created_at` attribute is the date of the commit used for the release, and not the date when the release was drafted or published.
///
/// [GitHub API docs for get_latest_release](https://docs.github.com/rest/releases/releases#get-the-latest-release)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_latest_release(&self, owner: &str, repo: &str) -> Result<Release, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/releases/latest", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
code => Err(ReposGetLatestReleaseError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get an organization rule suite
///
/// Gets information about a suite of rule evaluations from within an organization.
/// For more information, see "[Managing rulesets for repositories in your organization](https://docs.github.com/organizations/managing-organization-settings/managing-rulesets-for-repositories-in-your-organization#viewing-insights-for-rulesets)."
///
/// [GitHub API docs for get_org_rule_suite](https://docs.github.com/rest/orgs/rule-suites#get-an-organization-rule-suite)
///
/// ---
pub async fn get_org_rule_suite_async(&self, org: &str, rule_suite_id: i32) -> Result<RuleSuite, AdapterError> {
let request_uri = format!("{}/orgs/{}/rulesets/rule-suites/{}", super::GITHUB_BASE_API_URL, org, rule_suite_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(ReposGetOrgRuleSuiteError::Status404(github_response.to_json_async().await?).into()),
500 => Err(ReposGetOrgRuleSuiteError::Status500(github_response.to_json_async().await?).into()),
code => Err(ReposGetOrgRuleSuiteError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get an organization rule suite
///
/// Gets information about a suite of rule evaluations from within an organization.
/// For more information, see "[Managing rulesets for repositories in your organization](https://docs.github.com/organizations/managing-organization-settings/managing-rulesets-for-repositories-in-your-organization#viewing-insights-for-rulesets)."
///
/// [GitHub API docs for get_org_rule_suite](https://docs.github.com/rest/orgs/rule-suites#get-an-organization-rule-suite)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_org_rule_suite(&self, org: &str, rule_suite_id: i32) -> Result<RuleSuite, AdapterError> {
let request_uri = format!("{}/orgs/{}/rulesets/rule-suites/{}", super::GITHUB_BASE_API_URL, org, rule_suite_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(ReposGetOrgRuleSuiteError::Status404(github_response.to_json()?).into()),
500 => Err(ReposGetOrgRuleSuiteError::Status500(github_response.to_json()?).into()),
code => Err(ReposGetOrgRuleSuiteError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List organization rule suites
///
/// Lists suites of rule evaluations at the organization level.
/// For more information, see "[Managing rulesets for repositories in your organization](https://docs.github.com/organizations/managing-organization-settings/managing-rulesets-for-repositories-in-your-organization#viewing-insights-for-rulesets)."
///
/// [GitHub API docs for get_org_rule_suites](https://docs.github.com/rest/orgs/rule-suites#list-organization-rule-suites)
///
/// ---
pub async fn get_org_rule_suites_async(&self, org: &str, query_params: Option<impl Into<ReposGetOrgRuleSuitesParams<'api>>>) -> Result<RuleSuites, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/rulesets/rule-suites", 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(ReposGetOrgRuleSuitesError::Status404(github_response.to_json_async().await?).into()),
500 => Err(ReposGetOrgRuleSuitesError::Status500(github_response.to_json_async().await?).into()),
code => Err(ReposGetOrgRuleSuitesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List organization rule suites
///
/// Lists suites of rule evaluations at the organization level.
/// For more information, see "[Managing rulesets for repositories in your organization](https://docs.github.com/organizations/managing-organization-settings/managing-rulesets-for-repositories-in-your-organization#viewing-insights-for-rulesets)."
///
/// [GitHub API docs for get_org_rule_suites](https://docs.github.com/rest/orgs/rule-suites#list-organization-rule-suites)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_org_rule_suites(&self, org: &str, query_params: Option<impl Into<ReposGetOrgRuleSuitesParams<'api>>>) -> Result<RuleSuites, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/rulesets/rule-suites", super::GITHUB_BASE_API_URL, org);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: ReposGetOrgRuleSuitesParams = 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(ReposGetOrgRuleSuitesError::Status404(github_response.to_json()?).into()),
500 => Err(ReposGetOrgRuleSuitesError::Status500(github_response.to_json()?).into()),
code => Err(ReposGetOrgRuleSuitesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get an organization repository ruleset
///
/// Get a repository ruleset for an organization.
///
/// **Note:** To prevent leaking sensitive information, the `bypass_actors` property is only returned if the user
/// making the API request has write access to the ruleset.
///
/// [GitHub API docs for get_org_ruleset](https://docs.github.com/rest/orgs/rules#get-an-organization-repository-ruleset)
///
/// ---
pub async fn get_org_ruleset_async(&self, org: &str, ruleset_id: i32) -> Result<RepositoryRuleset, AdapterError> {
let request_uri = format!("{}/orgs/{}/rulesets/{}", super::GITHUB_BASE_API_URL, org, ruleset_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(ReposGetOrgRulesetError::Status404(github_response.to_json_async().await?).into()),
500 => Err(ReposGetOrgRulesetError::Status500(github_response.to_json_async().await?).into()),
code => Err(ReposGetOrgRulesetError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get an organization repository ruleset
///
/// Get a repository ruleset for an organization.
///
/// **Note:** To prevent leaking sensitive information, the `bypass_actors` property is only returned if the user
/// making the API request has write access to the ruleset.
///
/// [GitHub API docs for get_org_ruleset](https://docs.github.com/rest/orgs/rules#get-an-organization-repository-ruleset)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_org_ruleset(&self, org: &str, ruleset_id: i32) -> Result<RepositoryRuleset, AdapterError> {
let request_uri = format!("{}/orgs/{}/rulesets/{}", super::GITHUB_BASE_API_URL, org, ruleset_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(ReposGetOrgRulesetError::Status404(github_response.to_json()?).into()),
500 => Err(ReposGetOrgRulesetError::Status500(github_response.to_json()?).into()),
code => Err(ReposGetOrgRulesetError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get all organization repository rulesets
///
/// Get all the repository rulesets for an organization.
///
/// [GitHub API docs for get_org_rulesets](https://docs.github.com/rest/orgs/rules#get-all-organization-repository-rulesets)
///
/// ---
pub async fn get_org_rulesets_async(&self, org: &str, query_params: Option<impl Into<ReposGetOrgRulesetsParams<'api>>>) -> Result<Vec<RepositoryRuleset>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/rulesets", 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(ReposGetOrgRulesetsError::Status404(github_response.to_json_async().await?).into()),
500 => Err(ReposGetOrgRulesetsError::Status500(github_response.to_json_async().await?).into()),
code => Err(ReposGetOrgRulesetsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get all organization repository rulesets
///
/// Get all the repository rulesets for an organization.
///
/// [GitHub API docs for get_org_rulesets](https://docs.github.com/rest/orgs/rules#get-all-organization-repository-rulesets)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_org_rulesets(&self, org: &str, query_params: Option<impl Into<ReposGetOrgRulesetsParams<'api>>>) -> Result<Vec<RepositoryRuleset>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/rulesets", super::GITHUB_BASE_API_URL, org);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: ReposGetOrgRulesetsParams = 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(ReposGetOrgRulesetsError::Status404(github_response.to_json()?).into()),
500 => Err(ReposGetOrgRulesetsError::Status500(github_response.to_json()?).into()),
code => Err(ReposGetOrgRulesetsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a GitHub Pages site
///
/// Gets information about a GitHub Pages site.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.
///
/// [GitHub API docs for get_pages](https://docs.github.com/rest/pages/pages#get-a-apiname-pages-site)
///
/// ---
pub async fn get_pages_async(&self, owner: &str, repo: &str) -> Result<Page, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pages", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
404 => Err(ReposGetPagesError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposGetPagesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a GitHub Pages site
///
/// Gets information about a GitHub Pages site.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.
///
/// [GitHub API docs for get_pages](https://docs.github.com/rest/pages/pages#get-a-apiname-pages-site)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_pages(&self, owner: &str, repo: &str) -> Result<Page, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pages", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
404 => Err(ReposGetPagesError::Status404(github_response.to_json()?).into()),
code => Err(ReposGetPagesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get GitHub Pages build
///
/// Gets information about a GitHub Pages build.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.
///
/// [GitHub API docs for get_pages_build](https://docs.github.com/rest/pages/pages#get-apiname-pages-build)
///
/// ---
pub async fn get_pages_build_async(&self, owner: &str, repo: &str, build_id: i32) -> Result<PageBuild, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pages/builds/{}", super::GITHUB_BASE_API_URL, owner, repo, build_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(ReposGetPagesBuildError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get GitHub Pages build
///
/// Gets information about a GitHub Pages build.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.
///
/// [GitHub API docs for get_pages_build](https://docs.github.com/rest/pages/pages#get-apiname-pages-build)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_pages_build(&self, owner: &str, repo: &str, build_id: i32) -> Result<PageBuild, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pages/builds/{}", super::GITHUB_BASE_API_URL, owner, repo, build_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(ReposGetPagesBuildError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get the status of a GitHub Pages deployment
///
/// Gets the current status of a GitHub Pages deployment.
///
/// The authenticated user must have read permission for the GitHub Pages site.
///
/// [GitHub API docs for get_pages_deployment](https://docs.github.com/rest/pages/pages#get-the-status-of-a-github-pages-deployment)
///
/// ---
pub async fn get_pages_deployment_async(&self, owner: &str, repo: &str, pages_deployment_id: PagesDeploymentId) -> Result<PagesDeploymentStatus, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pages/deployments/{}", super::GITHUB_BASE_API_URL, owner, repo, pages_deployment_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(ReposGetPagesDeploymentError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposGetPagesDeploymentError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get the status of a GitHub Pages deployment
///
/// Gets the current status of a GitHub Pages deployment.
///
/// The authenticated user must have read permission for the GitHub Pages site.
///
/// [GitHub API docs for get_pages_deployment](https://docs.github.com/rest/pages/pages#get-the-status-of-a-github-pages-deployment)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_pages_deployment(&self, owner: &str, repo: &str, pages_deployment_id: PagesDeploymentId) -> Result<PagesDeploymentStatus, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pages/deployments/{}", super::GITHUB_BASE_API_URL, owner, repo, pages_deployment_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(ReposGetPagesDeploymentError::Status404(github_response.to_json()?).into()),
code => Err(ReposGetPagesDeploymentError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a DNS health check for GitHub Pages
///
/// Gets a health check of the DNS settings for the `CNAME` record configured for a repository's GitHub Pages.
///
/// The first request to this endpoint returns a `202 Accepted` status and starts an asynchronous background task to get the results for the domain. After the background task completes, subsequent requests to this endpoint return a `200 OK` status with the health check results in the response.
///
/// The authenticated user must be a repository administrator, maintainer, or have the 'manage GitHub Pages settings' permission to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.
///
/// [GitHub API docs for get_pages_health_check](https://docs.github.com/rest/pages/pages#get-a-dns-health-check-for-github-pages)
///
/// ---
pub async fn get_pages_health_check_async(&self, owner: &str, repo: &str) -> Result<PagesHealthCheck, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pages/health", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
202 => Err(ReposGetPagesHealthCheckError::Status202(github_response.to_json_async().await?).into()),
400 => Err(ReposGetPagesHealthCheckError::Status400.into()),
422 => Err(ReposGetPagesHealthCheckError::Status422.into()),
404 => Err(ReposGetPagesHealthCheckError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposGetPagesHealthCheckError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a DNS health check for GitHub Pages
///
/// Gets a health check of the DNS settings for the `CNAME` record configured for a repository's GitHub Pages.
///
/// The first request to this endpoint returns a `202 Accepted` status and starts an asynchronous background task to get the results for the domain. After the background task completes, subsequent requests to this endpoint return a `200 OK` status with the health check results in the response.
///
/// The authenticated user must be a repository administrator, maintainer, or have the 'manage GitHub Pages settings' permission to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.
///
/// [GitHub API docs for get_pages_health_check](https://docs.github.com/rest/pages/pages#get-a-dns-health-check-for-github-pages)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_pages_health_check(&self, owner: &str, repo: &str) -> Result<PagesHealthCheck, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pages/health", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
202 => Err(ReposGetPagesHealthCheckError::Status202(github_response.to_json()?).into()),
400 => Err(ReposGetPagesHealthCheckError::Status400.into()),
422 => Err(ReposGetPagesHealthCheckError::Status422.into()),
404 => Err(ReposGetPagesHealthCheckError::Status404(github_response.to_json()?).into()),
code => Err(ReposGetPagesHealthCheckError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get the weekly commit count
///
/// Returns the total commit counts for the `owner` and total commit counts in `all`. `all` is everyone combined, including the `owner` in the last 52 weeks. If you'd like to get the commit counts for non-owners, you can subtract `owner` from `all`.
///
/// The array order is oldest week (index 0) to most recent week.
///
/// The most recent week is seven days ago at UTC midnight to today at UTC midnight.
///
/// [GitHub API docs for get_participation_stats](https://docs.github.com/rest/metrics/statistics#get-the-weekly-commit-count)
///
/// ---
pub async fn get_participation_stats_async(&self, owner: &str, repo: &str) -> Result<ParticipationStats, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/stats/participation", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
404 => Err(ReposGetParticipationStatsError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposGetParticipationStatsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get the weekly commit count
///
/// Returns the total commit counts for the `owner` and total commit counts in `all`. `all` is everyone combined, including the `owner` in the last 52 weeks. If you'd like to get the commit counts for non-owners, you can subtract `owner` from `all`.
///
/// The array order is oldest week (index 0) to most recent week.
///
/// The most recent week is seven days ago at UTC midnight to today at UTC midnight.
///
/// [GitHub API docs for get_participation_stats](https://docs.github.com/rest/metrics/statistics#get-the-weekly-commit-count)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_participation_stats(&self, owner: &str, repo: &str) -> Result<ParticipationStats, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/stats/participation", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
404 => Err(ReposGetParticipationStatsError::Status404(github_response.to_json()?).into()),
code => Err(ReposGetParticipationStatsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get pull request review protection
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// [GitHub API docs for get_pull_request_review_protection](https://docs.github.com/rest/branches/branch-protection#get-pull-request-review-protection)
///
/// ---
pub async fn get_pull_request_review_protection_async(&self, owner: &str, repo: &str, branch: &str) -> Result<ProtectedBranchPullRequestReview, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_pull_request_reviews", super::GITHUB_BASE_API_URL, owner, repo, branch);
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(ReposGetPullRequestReviewProtectionError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get pull request review protection
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// [GitHub API docs for get_pull_request_review_protection](https://docs.github.com/rest/branches/branch-protection#get-pull-request-review-protection)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_pull_request_review_protection(&self, owner: &str, repo: &str, branch: &str) -> Result<ProtectedBranchPullRequestReview, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_pull_request_reviews", super::GITHUB_BASE_API_URL, owner, repo, branch);
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(ReposGetPullRequestReviewProtectionError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get the hourly commit count for each day
///
/// Each array contains the day number, hour number, and number of commits:
///
/// * `0-6`: Sunday - Saturday
/// * `0-23`: Hour of day
/// * Number of commits
///
/// For example, `[2, 14, 25]` indicates that there were 25 total commits, during the 2:00pm hour on Tuesdays. All times are based on the time zone of individual commits.
///
/// [GitHub API docs for get_punch_card_stats](https://docs.github.com/rest/metrics/statistics#get-the-hourly-commit-count-for-each-day)
///
/// ---
pub async fn get_punch_card_stats_async(&self, owner: &str, repo: &str) -> Result<Vec<CodeFrequencyStat>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/stats/punch_card", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
204 => Err(ReposGetPunchCardStatsError::Status204.into()),
code => Err(ReposGetPunchCardStatsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get the hourly commit count for each day
///
/// Each array contains the day number, hour number, and number of commits:
///
/// * `0-6`: Sunday - Saturday
/// * `0-23`: Hour of day
/// * Number of commits
///
/// For example, `[2, 14, 25]` indicates that there were 25 total commits, during the 2:00pm hour on Tuesdays. All times are based on the time zone of individual commits.
///
/// [GitHub API docs for get_punch_card_stats](https://docs.github.com/rest/metrics/statistics#get-the-hourly-commit-count-for-each-day)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_punch_card_stats(&self, owner: &str, repo: &str) -> Result<Vec<CodeFrequencyStat>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/stats/punch_card", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
204 => Err(ReposGetPunchCardStatsError::Status204.into()),
code => Err(ReposGetPunchCardStatsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a repository README
///
/// Gets the preferred README for a repository.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github.raw+json`**: Returns the raw file contents. This is the default if you do not specify a media type.
/// - **`application/vnd.github.html+json`**: Returns the README in HTML. Markup languages are rendered to HTML using GitHub's open-source [Markup library](https://github.com/github/markup).
///
/// [GitHub API docs for get_readme](https://docs.github.com/rest/repos/contents#get-a-repository-readme)
///
/// ---
pub async fn get_readme_async(&self, owner: &str, repo: &str, query_params: Option<impl Into<ReposGetReadmeParams<'api>>>) -> Result<ContentFile, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/readme", super::GITHUB_BASE_API_URL, owner, repo);
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(ReposGetReadmeError::Status304.into()),
404 => Err(ReposGetReadmeError::Status404(github_response.to_json_async().await?).into()),
422 => Err(ReposGetReadmeError::Status422(github_response.to_json_async().await?).into()),
code => Err(ReposGetReadmeError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a repository README
///
/// Gets the preferred README for a repository.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github.raw+json`**: Returns the raw file contents. This is the default if you do not specify a media type.
/// - **`application/vnd.github.html+json`**: Returns the README in HTML. Markup languages are rendered to HTML using GitHub's open-source [Markup library](https://github.com/github/markup).
///
/// [GitHub API docs for get_readme](https://docs.github.com/rest/repos/contents#get-a-repository-readme)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_readme(&self, owner: &str, repo: &str, query_params: Option<impl Into<ReposGetReadmeParams<'api>>>) -> Result<ContentFile, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/readme", super::GITHUB_BASE_API_URL, owner, repo);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: ReposGetReadmeParams = 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(ReposGetReadmeError::Status304.into()),
404 => Err(ReposGetReadmeError::Status404(github_response.to_json()?).into()),
422 => Err(ReposGetReadmeError::Status422(github_response.to_json()?).into()),
code => Err(ReposGetReadmeError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a repository README for a directory
///
/// Gets the README from a repository directory.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github.raw+json`**: Returns the raw file contents. This is the default if you do not specify a media type.
/// - **`application/vnd.github.html+json`**: Returns the README in HTML. Markup languages are rendered to HTML using GitHub's open-source [Markup library](https://github.com/github/markup).
///
/// [GitHub API docs for get_readme_in_directory](https://docs.github.com/rest/repos/contents#get-a-repository-readme-for-a-directory)
///
/// ---
pub async fn get_readme_in_directory_async(&self, owner: &str, repo: &str, dir: &str, query_params: Option<impl Into<ReposGetReadmeInDirectoryParams<'api>>>) -> Result<ContentFile, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/readme/{}", super::GITHUB_BASE_API_URL, owner, repo, dir);
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(ReposGetReadmeInDirectoryError::Status404(github_response.to_json_async().await?).into()),
422 => Err(ReposGetReadmeInDirectoryError::Status422(github_response.to_json_async().await?).into()),
code => Err(ReposGetReadmeInDirectoryError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a repository README for a directory
///
/// Gets the README from a repository directory.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github.raw+json`**: Returns the raw file contents. This is the default if you do not specify a media type.
/// - **`application/vnd.github.html+json`**: Returns the README in HTML. Markup languages are rendered to HTML using GitHub's open-source [Markup library](https://github.com/github/markup).
///
/// [GitHub API docs for get_readme_in_directory](https://docs.github.com/rest/repos/contents#get-a-repository-readme-for-a-directory)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_readme_in_directory(&self, owner: &str, repo: &str, dir: &str, query_params: Option<impl Into<ReposGetReadmeInDirectoryParams<'api>>>) -> Result<ContentFile, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/readme/{}", super::GITHUB_BASE_API_URL, owner, repo, dir);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: ReposGetReadmeInDirectoryParams = 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(ReposGetReadmeInDirectoryError::Status404(github_response.to_json()?).into()),
422 => Err(ReposGetReadmeInDirectoryError::Status422(github_response.to_json()?).into()),
code => Err(ReposGetReadmeInDirectoryError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a release
///
/// Gets a public release with the specified release ID.
///
/// > [!NOTE]
/// > This returns an `upload_url` key corresponding to the endpoint for uploading release assets. This key is a hypermedia resource. For more information, see "[Getting started with the REST API](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#hypermedia)."
///
/// [GitHub API docs for get_release](https://docs.github.com/rest/releases/releases#get-a-release)
///
/// ---
pub async fn get_release_async(&self, owner: &str, repo: &str, release_id: i32) -> Result<Release, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/releases/{}", super::GITHUB_BASE_API_URL, owner, repo, release_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() {
401 => Err(ReposGetReleaseError::Status401.into()),
code => Err(ReposGetReleaseError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a release
///
/// Gets a public release with the specified release ID.
///
/// > [!NOTE]
/// > This returns an `upload_url` key corresponding to the endpoint for uploading release assets. This key is a hypermedia resource. For more information, see "[Getting started with the REST API](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#hypermedia)."
///
/// [GitHub API docs for get_release](https://docs.github.com/rest/releases/releases#get-a-release)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_release(&self, owner: &str, repo: &str, release_id: i32) -> Result<Release, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/releases/{}", super::GITHUB_BASE_API_URL, owner, repo, release_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() {
401 => Err(ReposGetReleaseError::Status401.into()),
code => Err(ReposGetReleaseError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a release asset
///
/// To download the asset's binary content:
///
/// - If within a browser, fetch the location specified in the `browser_download_url` key provided in the response.
/// - Alternatively, set the `Accept` header of the request to
/// [`application/octet-stream`](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types).
/// The API will either redirect the client to the location, or stream it directly if possible.
/// API clients should handle both a `200` or `302` response.
///
/// [GitHub API docs for get_release_asset](https://docs.github.com/rest/releases/assets#get-a-release-asset)
///
/// ---
pub async fn get_release_asset_async(&self, owner: &str, repo: &str, asset_id: i32) -> Result<ReleaseAsset, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/releases/assets/{}", super::GITHUB_BASE_API_URL, owner, repo, asset_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(ReposGetReleaseAssetError::Status404(github_response.to_json_async().await?).into()),
302 => Err(ReposGetReleaseAssetError::Status302.into()),
code => Err(ReposGetReleaseAssetError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a release asset
///
/// To download the asset's binary content:
///
/// - If within a browser, fetch the location specified in the `browser_download_url` key provided in the response.
/// - Alternatively, set the `Accept` header of the request to
/// [`application/octet-stream`](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types).
/// The API will either redirect the client to the location, or stream it directly if possible.
/// API clients should handle both a `200` or `302` response.
///
/// [GitHub API docs for get_release_asset](https://docs.github.com/rest/releases/assets#get-a-release-asset)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_release_asset(&self, owner: &str, repo: &str, asset_id: i32) -> Result<ReleaseAsset, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/releases/assets/{}", super::GITHUB_BASE_API_URL, owner, repo, asset_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(ReposGetReleaseAssetError::Status404(github_response.to_json()?).into()),
302 => Err(ReposGetReleaseAssetError::Status302.into()),
code => Err(ReposGetReleaseAssetError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a release by tag name
///
/// Get a published release with the specified tag.
///
/// [GitHub API docs for get_release_by_tag](https://docs.github.com/rest/releases/releases#get-a-release-by-tag-name)
///
/// ---
pub async fn get_release_by_tag_async(&self, owner: &str, repo: &str, tag: &str) -> Result<Release, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/releases/tags/{}", super::GITHUB_BASE_API_URL, owner, repo, tag);
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(ReposGetReleaseByTagError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposGetReleaseByTagError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a release by tag name
///
/// Get a published release with the specified tag.
///
/// [GitHub API docs for get_release_by_tag](https://docs.github.com/rest/releases/releases#get-a-release-by-tag-name)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_release_by_tag(&self, owner: &str, repo: &str, tag: &str) -> Result<Release, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/releases/tags/{}", super::GITHUB_BASE_API_URL, owner, repo, tag);
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(ReposGetReleaseByTagError::Status404(github_response.to_json()?).into()),
code => Err(ReposGetReleaseByTagError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a repository rule suite
///
/// Gets information about a suite of rule evaluations from within a repository.
/// For more information, see "[Managing rulesets for a repository](https://docs.github.com/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/managing-rulesets-for-a-repository#viewing-insights-for-rulesets)."
///
/// [GitHub API docs for get_repo_rule_suite](https://docs.github.com/rest/repos/rule-suites#get-a-repository-rule-suite)
///
/// ---
pub async fn get_repo_rule_suite_async(&self, owner: &str, repo: &str, rule_suite_id: i32) -> Result<RuleSuite, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/rulesets/rule-suites/{}", super::GITHUB_BASE_API_URL, owner, repo, rule_suite_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(ReposGetRepoRuleSuiteError::Status404(github_response.to_json_async().await?).into()),
500 => Err(ReposGetRepoRuleSuiteError::Status500(github_response.to_json_async().await?).into()),
code => Err(ReposGetRepoRuleSuiteError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a repository rule suite
///
/// Gets information about a suite of rule evaluations from within a repository.
/// For more information, see "[Managing rulesets for a repository](https://docs.github.com/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/managing-rulesets-for-a-repository#viewing-insights-for-rulesets)."
///
/// [GitHub API docs for get_repo_rule_suite](https://docs.github.com/rest/repos/rule-suites#get-a-repository-rule-suite)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_repo_rule_suite(&self, owner: &str, repo: &str, rule_suite_id: i32) -> Result<RuleSuite, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/rulesets/rule-suites/{}", super::GITHUB_BASE_API_URL, owner, repo, rule_suite_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(ReposGetRepoRuleSuiteError::Status404(github_response.to_json()?).into()),
500 => Err(ReposGetRepoRuleSuiteError::Status500(github_response.to_json()?).into()),
code => Err(ReposGetRepoRuleSuiteError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List repository rule suites
///
/// Lists suites of rule evaluations at the repository level.
/// For more information, see "[Managing rulesets for a repository](https://docs.github.com/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/managing-rulesets-for-a-repository#viewing-insights-for-rulesets)."
///
/// [GitHub API docs for get_repo_rule_suites](https://docs.github.com/rest/repos/rule-suites#list-repository-rule-suites)
///
/// ---
pub async fn get_repo_rule_suites_async(&self, owner: &str, repo: &str, query_params: Option<impl Into<ReposGetRepoRuleSuitesParams<'api>>>) -> Result<RuleSuites, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/rulesets/rule-suites", super::GITHUB_BASE_API_URL, owner, repo);
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(ReposGetRepoRuleSuitesError::Status404(github_response.to_json_async().await?).into()),
500 => Err(ReposGetRepoRuleSuitesError::Status500(github_response.to_json_async().await?).into()),
code => Err(ReposGetRepoRuleSuitesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List repository rule suites
///
/// Lists suites of rule evaluations at the repository level.
/// For more information, see "[Managing rulesets for a repository](https://docs.github.com/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/managing-rulesets-for-a-repository#viewing-insights-for-rulesets)."
///
/// [GitHub API docs for get_repo_rule_suites](https://docs.github.com/rest/repos/rule-suites#list-repository-rule-suites)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_repo_rule_suites(&self, owner: &str, repo: &str, query_params: Option<impl Into<ReposGetRepoRuleSuitesParams<'api>>>) -> Result<RuleSuites, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/rulesets/rule-suites", super::GITHUB_BASE_API_URL, owner, repo);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: ReposGetRepoRuleSuitesParams = 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(ReposGetRepoRuleSuitesError::Status404(github_response.to_json()?).into()),
500 => Err(ReposGetRepoRuleSuitesError::Status500(github_response.to_json()?).into()),
code => Err(ReposGetRepoRuleSuitesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a repository ruleset
///
/// Get a ruleset for a repository.
///
/// **Note:** To prevent leaking sensitive information, the `bypass_actors` property is only returned if the user
/// making the API request has write access to the ruleset.
///
/// [GitHub API docs for get_repo_ruleset](https://docs.github.com/rest/repos/rules#get-a-repository-ruleset)
///
/// ---
pub async fn get_repo_ruleset_async(&self, owner: &str, repo: &str, ruleset_id: i32, query_params: Option<impl Into<ReposGetRepoRulesetParams>>) -> Result<RepositoryRuleset, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/rulesets/{}", super::GITHUB_BASE_API_URL, owner, repo, 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(ReposGetRepoRulesetError::Status404(github_response.to_json_async().await?).into()),
500 => Err(ReposGetRepoRulesetError::Status500(github_response.to_json_async().await?).into()),
code => Err(ReposGetRepoRulesetError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a repository ruleset
///
/// Get a ruleset for a repository.
///
/// **Note:** To prevent leaking sensitive information, the `bypass_actors` property is only returned if the user
/// making the API request has write access to the ruleset.
///
/// [GitHub API docs for get_repo_ruleset](https://docs.github.com/rest/repos/rules#get-a-repository-ruleset)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_repo_ruleset(&self, owner: &str, repo: &str, ruleset_id: i32, query_params: Option<impl Into<ReposGetRepoRulesetParams>>) -> Result<RepositoryRuleset, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/rulesets/{}", super::GITHUB_BASE_API_URL, owner, repo, ruleset_id);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: ReposGetRepoRulesetParams = 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(ReposGetRepoRulesetError::Status404(github_response.to_json()?).into()),
500 => Err(ReposGetRepoRulesetError::Status500(github_response.to_json()?).into()),
code => Err(ReposGetRepoRulesetError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get repository ruleset history
///
/// Get the history of a repository ruleset.
///
/// [GitHub API docs for get_repo_ruleset_history](https://docs.github.com/rest/repos/rules#get-repository-ruleset-history)
///
/// ---
pub async fn get_repo_ruleset_history_async(&self, owner: &str, repo: &str, ruleset_id: i32, query_params: Option<impl Into<ReposGetRepoRulesetHistoryParams>>) -> Result<Vec<RulesetVersion>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/rulesets/{}/history", super::GITHUB_BASE_API_URL, owner, repo, 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(ReposGetRepoRulesetHistoryError::Status404(github_response.to_json_async().await?).into()),
500 => Err(ReposGetRepoRulesetHistoryError::Status500(github_response.to_json_async().await?).into()),
code => Err(ReposGetRepoRulesetHistoryError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get repository ruleset history
///
/// Get the history of a repository ruleset.
///
/// [GitHub API docs for get_repo_ruleset_history](https://docs.github.com/rest/repos/rules#get-repository-ruleset-history)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_repo_ruleset_history(&self, owner: &str, repo: &str, ruleset_id: i32, query_params: Option<impl Into<ReposGetRepoRulesetHistoryParams>>) -> Result<Vec<RulesetVersion>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/rulesets/{}/history", super::GITHUB_BASE_API_URL, owner, repo, ruleset_id);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: ReposGetRepoRulesetHistoryParams = 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(ReposGetRepoRulesetHistoryError::Status404(github_response.to_json()?).into()),
500 => Err(ReposGetRepoRulesetHistoryError::Status500(github_response.to_json()?).into()),
code => Err(ReposGetRepoRulesetHistoryError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get repository ruleset version
///
/// Get a version of a repository ruleset.
///
/// [GitHub API docs for get_repo_ruleset_version](https://docs.github.com/rest/repos/rules#get-repository-ruleset-version)
///
/// ---
pub async fn get_repo_ruleset_version_async(&self, owner: &str, repo: &str, ruleset_id: i32, version_id: i32) -> Result<RulesetVersionWithState, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/rulesets/{}/history/{}", super::GITHUB_BASE_API_URL, owner, repo, 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(ReposGetRepoRulesetVersionError::Status404(github_response.to_json_async().await?).into()),
500 => Err(ReposGetRepoRulesetVersionError::Status500(github_response.to_json_async().await?).into()),
code => Err(ReposGetRepoRulesetVersionError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get repository ruleset version
///
/// Get a version of a repository ruleset.
///
/// [GitHub API docs for get_repo_ruleset_version](https://docs.github.com/rest/repos/rules#get-repository-ruleset-version)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_repo_ruleset_version(&self, owner: &str, repo: &str, ruleset_id: i32, version_id: i32) -> Result<RulesetVersionWithState, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/rulesets/{}/history/{}", super::GITHUB_BASE_API_URL, owner, repo, 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(ReposGetRepoRulesetVersionError::Status404(github_response.to_json()?).into()),
500 => Err(ReposGetRepoRulesetVersionError::Status500(github_response.to_json()?).into()),
code => Err(ReposGetRepoRulesetVersionError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get all repository rulesets
///
/// Get all the rulesets for a repository.
///
/// [GitHub API docs for get_repo_rulesets](https://docs.github.com/rest/repos/rules#get-all-repository-rulesets)
///
/// ---
pub async fn get_repo_rulesets_async(&self, owner: &str, repo: &str, query_params: Option<impl Into<ReposGetRepoRulesetsParams<'api>>>) -> Result<Vec<RepositoryRuleset>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/rulesets", super::GITHUB_BASE_API_URL, owner, repo);
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(ReposGetRepoRulesetsError::Status404(github_response.to_json_async().await?).into()),
500 => Err(ReposGetRepoRulesetsError::Status500(github_response.to_json_async().await?).into()),
code => Err(ReposGetRepoRulesetsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get all repository rulesets
///
/// Get all the rulesets for a repository.
///
/// [GitHub API docs for get_repo_rulesets](https://docs.github.com/rest/repos/rules#get-all-repository-rulesets)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_repo_rulesets(&self, owner: &str, repo: &str, query_params: Option<impl Into<ReposGetRepoRulesetsParams<'api>>>) -> Result<Vec<RepositoryRuleset>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/rulesets", super::GITHUB_BASE_API_URL, owner, repo);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: ReposGetRepoRulesetsParams = 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(ReposGetRepoRulesetsError::Status404(github_response.to_json()?).into()),
500 => Err(ReposGetRepoRulesetsError::Status500(github_response.to_json()?).into()),
code => Err(ReposGetRepoRulesetsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get status checks protection
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// [GitHub API docs for get_status_checks_protection](https://docs.github.com/rest/branches/branch-protection#get-status-checks-protection)
///
/// ---
pub async fn get_status_checks_protection_async(&self, owner: &str, repo: &str, branch: &str) -> Result<StatusCheckPolicy, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_status_checks", super::GITHUB_BASE_API_URL, owner, repo, branch);
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(ReposGetStatusChecksProtectionError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposGetStatusChecksProtectionError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get status checks protection
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// [GitHub API docs for get_status_checks_protection](https://docs.github.com/rest/branches/branch-protection#get-status-checks-protection)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_status_checks_protection(&self, owner: &str, repo: &str, branch: &str) -> Result<StatusCheckPolicy, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_status_checks", super::GITHUB_BASE_API_URL, owner, repo, branch);
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(ReposGetStatusChecksProtectionError::Status404(github_response.to_json()?).into()),
code => Err(ReposGetStatusChecksProtectionError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get teams with access to the protected branch
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// Lists the teams who have push access to this branch. The list includes child teams.
///
/// [GitHub API docs for get_teams_with_access_to_protected_branch](https://docs.github.com/rest/branches/branch-protection#get-teams-with-access-to-the-protected-branch)
///
/// ---
pub async fn get_teams_with_access_to_protected_branch_async(&self, owner: &str, repo: &str, branch: &str) -> Result<Vec<Team>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions/teams", super::GITHUB_BASE_API_URL, owner, repo, branch);
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(ReposGetTeamsWithAccessToProtectedBranchError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposGetTeamsWithAccessToProtectedBranchError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get teams with access to the protected branch
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// Lists the teams who have push access to this branch. The list includes child teams.
///
/// [GitHub API docs for get_teams_with_access_to_protected_branch](https://docs.github.com/rest/branches/branch-protection#get-teams-with-access-to-the-protected-branch)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_teams_with_access_to_protected_branch(&self, owner: &str, repo: &str, branch: &str) -> Result<Vec<Team>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions/teams", super::GITHUB_BASE_API_URL, owner, repo, branch);
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(ReposGetTeamsWithAccessToProtectedBranchError::Status404(github_response.to_json()?).into()),
code => Err(ReposGetTeamsWithAccessToProtectedBranchError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get top referral paths
///
/// Get the top 10 popular contents over the last 14 days.
///
/// [GitHub API docs for get_top_paths](https://docs.github.com/rest/metrics/traffic#get-top-referral-paths)
///
/// ---
pub async fn get_top_paths_async(&self, owner: &str, repo: &str) -> Result<Vec<ContentTraffic>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/traffic/popular/paths", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
403 => Err(ReposGetTopPathsError::Status403(github_response.to_json_async().await?).into()),
code => Err(ReposGetTopPathsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get top referral paths
///
/// Get the top 10 popular contents over the last 14 days.
///
/// [GitHub API docs for get_top_paths](https://docs.github.com/rest/metrics/traffic#get-top-referral-paths)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_top_paths(&self, owner: &str, repo: &str) -> Result<Vec<ContentTraffic>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/traffic/popular/paths", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
403 => Err(ReposGetTopPathsError::Status403(github_response.to_json()?).into()),
code => Err(ReposGetTopPathsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get top referral sources
///
/// Get the top 10 referrers over the last 14 days.
///
/// [GitHub API docs for get_top_referrers](https://docs.github.com/rest/metrics/traffic#get-top-referral-sources)
///
/// ---
pub async fn get_top_referrers_async(&self, owner: &str, repo: &str) -> Result<Vec<ReferrerTraffic>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/traffic/popular/referrers", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
403 => Err(ReposGetTopReferrersError::Status403(github_response.to_json_async().await?).into()),
code => Err(ReposGetTopReferrersError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get top referral sources
///
/// Get the top 10 referrers over the last 14 days.
///
/// [GitHub API docs for get_top_referrers](https://docs.github.com/rest/metrics/traffic#get-top-referral-sources)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_top_referrers(&self, owner: &str, repo: &str) -> Result<Vec<ReferrerTraffic>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/traffic/popular/referrers", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
403 => Err(ReposGetTopReferrersError::Status403(github_response.to_json()?).into()),
code => Err(ReposGetTopReferrersError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get users with access to the protected branch
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// Lists the people who have push access to this branch.
///
/// [GitHub API docs for get_users_with_access_to_protected_branch](https://docs.github.com/rest/branches/branch-protection#get-users-with-access-to-the-protected-branch)
///
/// ---
pub async fn get_users_with_access_to_protected_branch_async(&self, owner: &str, repo: &str, branch: &str) -> Result<Vec<SimpleUser>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions/users", super::GITHUB_BASE_API_URL, owner, repo, branch);
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(ReposGetUsersWithAccessToProtectedBranchError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposGetUsersWithAccessToProtectedBranchError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get users with access to the protected branch
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// Lists the people who have push access to this branch.
///
/// [GitHub API docs for get_users_with_access_to_protected_branch](https://docs.github.com/rest/branches/branch-protection#get-users-with-access-to-the-protected-branch)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_users_with_access_to_protected_branch(&self, owner: &str, repo: &str, branch: &str) -> Result<Vec<SimpleUser>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions/users", super::GITHUB_BASE_API_URL, owner, repo, branch);
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(ReposGetUsersWithAccessToProtectedBranchError::Status404(github_response.to_json()?).into()),
code => Err(ReposGetUsersWithAccessToProtectedBranchError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get page views
///
/// Get the total number of views and breakdown per day or week for the last 14 days. Timestamps are aligned to UTC midnight of the beginning of the day or week. Week begins on Monday.
///
/// [GitHub API docs for get_views](https://docs.github.com/rest/metrics/traffic#get-page-views)
///
/// ---
pub async fn get_views_async(&self, owner: &str, repo: &str, query_params: Option<impl Into<ReposGetViewsParams<'api>>>) -> Result<ViewTraffic, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/traffic/views", super::GITHUB_BASE_API_URL, owner, repo);
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(ReposGetViewsError::Status403(github_response.to_json_async().await?).into()),
code => Err(ReposGetViewsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get page views
///
/// Get the total number of views and breakdown per day or week for the last 14 days. Timestamps are aligned to UTC midnight of the beginning of the day or week. Week begins on Monday.
///
/// [GitHub API docs for get_views](https://docs.github.com/rest/metrics/traffic#get-page-views)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_views(&self, owner: &str, repo: &str, query_params: Option<impl Into<ReposGetViewsParams<'api>>>) -> Result<ViewTraffic, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/traffic/views", super::GITHUB_BASE_API_URL, owner, repo);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: ReposGetViewsParams = 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(ReposGetViewsError::Status403(github_response.to_json()?).into()),
code => Err(ReposGetViewsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a repository webhook
///
/// Returns a webhook configured in a repository. To get only the webhook `config` properties, see "[Get a webhook configuration for a repository](/rest/webhooks/repo-config#get-a-webhook-configuration-for-a-repository)."
///
/// [GitHub API docs for get_webhook](https://docs.github.com/rest/repos/webhooks#get-a-repository-webhook)
///
/// ---
pub async fn get_webhook_async(&self, owner: &str, repo: &str, hook_id: i32) -> Result<Hook, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/hooks/{}", super::GITHUB_BASE_API_URL, owner, repo, 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(ReposGetWebhookError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposGetWebhookError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a repository webhook
///
/// Returns a webhook configured in a repository. To get only the webhook `config` properties, see "[Get a webhook configuration for a repository](/rest/webhooks/repo-config#get-a-webhook-configuration-for-a-repository)."
///
/// [GitHub API docs for get_webhook](https://docs.github.com/rest/repos/webhooks#get-a-repository-webhook)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_webhook(&self, owner: &str, repo: &str, hook_id: i32) -> Result<Hook, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/hooks/{}", super::GITHUB_BASE_API_URL, owner, repo, 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(ReposGetWebhookError::Status404(github_response.to_json()?).into()),
code => Err(ReposGetWebhookError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a webhook configuration for a repository
///
/// Returns the webhook configuration for a repository. To get more information about the webhook, including the `active` state and `events`, use "[Get a repository webhook](/rest/webhooks/repos#get-a-repository-webhook)."
///
/// OAuth app tokens and personal access tokens (classic) need the `read:repo_hook` or `repo` scope to use this endpoint.
///
/// [GitHub API docs for get_webhook_config_for_repo](https://docs.github.com/rest/repos/webhooks#get-a-webhook-configuration-for-a-repository)
///
/// ---
pub async fn get_webhook_config_for_repo_async(&self, owner: &str, repo: &str, hook_id: i32) -> Result<WebhookConfig, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/hooks/{}/config", super::GITHUB_BASE_API_URL, owner, repo, 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(ReposGetWebhookConfigForRepoError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a webhook configuration for a repository
///
/// Returns the webhook configuration for a repository. To get more information about the webhook, including the `active` state and `events`, use "[Get a repository webhook](/rest/webhooks/repos#get-a-repository-webhook)."
///
/// OAuth app tokens and personal access tokens (classic) need the `read:repo_hook` or `repo` scope to use this endpoint.
///
/// [GitHub API docs for get_webhook_config_for_repo](https://docs.github.com/rest/repos/webhooks#get-a-webhook-configuration-for-a-repository)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_webhook_config_for_repo(&self, owner: &str, repo: &str, hook_id: i32) -> Result<WebhookConfig, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/hooks/{}/config", super::GITHUB_BASE_API_URL, owner, repo, 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(ReposGetWebhookConfigForRepoError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a delivery for a repository webhook
///
/// Returns a delivery for a webhook configured in a repository.
///
/// [GitHub API docs for get_webhook_delivery](https://docs.github.com/rest/repos/webhooks#get-a-delivery-for-a-repository-webhook)
///
/// ---
pub async fn get_webhook_delivery_async(&self, owner: &str, repo: &str, hook_id: i32, delivery_id: i32) -> Result<HookDelivery, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/hooks/{}/deliveries/{}", super::GITHUB_BASE_API_URL, owner, repo, 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(ReposGetWebhookDeliveryError::Status400(github_response.to_json_async().await?).into()),
422 => Err(ReposGetWebhookDeliveryError::Status422(github_response.to_json_async().await?).into()),
code => Err(ReposGetWebhookDeliveryError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a delivery for a repository webhook
///
/// Returns a delivery for a webhook configured in a repository.
///
/// [GitHub API docs for get_webhook_delivery](https://docs.github.com/rest/repos/webhooks#get-a-delivery-for-a-repository-webhook)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_webhook_delivery(&self, owner: &str, repo: &str, hook_id: i32, delivery_id: i32) -> Result<HookDelivery, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/hooks/{}/deliveries/{}", super::GITHUB_BASE_API_URL, owner, repo, 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(ReposGetWebhookDeliveryError::Status400(github_response.to_json()?).into()),
422 => Err(ReposGetWebhookDeliveryError::Status422(github_response.to_json()?).into()),
code => Err(ReposGetWebhookDeliveryError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List repository activities
///
/// Lists a detailed history of changes to a repository, such as pushes, merges, force pushes, and branch changes, and associates these changes with commits and users.
///
/// For more information about viewing repository activity,
/// see "[Viewing activity and data for your repository](https://docs.github.com/repositories/viewing-activity-and-data-for-your-repository)."
///
/// [GitHub API docs for list_activities](https://docs.github.com/rest/repos/repos#list-repository-activities)
///
/// ---
pub async fn list_activities_async(&self, owner: &str, repo: &str, query_params: Option<impl Into<ReposListActivitiesParams<'api>>>) -> Result<Vec<Activity>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/activity", super::GITHUB_BASE_API_URL, owner, repo);
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(ReposListActivitiesError::Status422(github_response.to_json_async().await?).into()),
code => Err(ReposListActivitiesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List repository activities
///
/// Lists a detailed history of changes to a repository, such as pushes, merges, force pushes, and branch changes, and associates these changes with commits and users.
///
/// For more information about viewing repository activity,
/// see "[Viewing activity and data for your repository](https://docs.github.com/repositories/viewing-activity-and-data-for-your-repository)."
///
/// [GitHub API docs for list_activities](https://docs.github.com/rest/repos/repos#list-repository-activities)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_activities(&self, owner: &str, repo: &str, query_params: Option<impl Into<ReposListActivitiesParams<'api>>>) -> Result<Vec<Activity>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/activity", super::GITHUB_BASE_API_URL, owner, repo);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: ReposListActivitiesParams = 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(ReposListActivitiesError::Status422(github_response.to_json()?).into()),
code => Err(ReposListActivitiesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List attestations
///
/// List a collection of artifact attestations with a given subject digest that are associated with a repository.
///
/// The authenticated user making the request must have read access to the repository. 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/repos/repos#list-attestations)
///
/// ---
pub async fn list_attestations_async(&self, owner: &str, repo: &str, subject_digest: &str, query_params: Option<impl Into<ReposListAttestationsParams<'api>>>) -> Result<GetUsersListAttestationsResponse200, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/attestations/{}", super::GITHUB_BASE_API_URL, owner, repo, 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(ReposListAttestationsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List attestations
///
/// List a collection of artifact attestations with a given subject digest that are associated with a repository.
///
/// The authenticated user making the request must have read access to the repository. 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/repos/repos#list-attestations)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_attestations(&self, owner: &str, repo: &str, subject_digest: &str, query_params: Option<impl Into<ReposListAttestationsParams<'api>>>) -> Result<GetUsersListAttestationsResponse200, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/attestations/{}", super::GITHUB_BASE_API_URL, owner, repo, subject_digest);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: ReposListAttestationsParams = 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(ReposListAttestationsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get all autolinks of a repository
///
/// Gets all autolinks that are configured for a repository.
///
/// Information about autolinks are only available to repository administrators.
///
/// [GitHub API docs for list_autolinks](https://docs.github.com/rest/repos/autolinks#get-all-autolinks-of-a-repository)
///
/// ---
pub async fn list_autolinks_async(&self, owner: &str, repo: &str) -> Result<Vec<Autolink>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/autolinks", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
code => Err(ReposListAutolinksError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get all autolinks of a repository
///
/// Gets all autolinks that are configured for a repository.
///
/// Information about autolinks are only available to repository administrators.
///
/// [GitHub API docs for list_autolinks](https://docs.github.com/rest/repos/autolinks#get-all-autolinks-of-a-repository)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_autolinks(&self, owner: &str, repo: &str) -> Result<Vec<Autolink>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/autolinks", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
code => Err(ReposListAutolinksError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List branches
///
/// [GitHub API docs for list_branches](https://docs.github.com/rest/branches/branches#list-branches)
///
/// ---
pub async fn list_branches_async(&self, owner: &str, repo: &str, query_params: Option<impl Into<ReposListBranchesParams>>) -> Result<Vec<ShortBranch>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/branches", super::GITHUB_BASE_API_URL, owner, repo);
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(ReposListBranchesError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposListBranchesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List branches
///
/// [GitHub API docs for list_branches](https://docs.github.com/rest/branches/branches#list-branches)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_branches(&self, owner: &str, repo: &str, query_params: Option<impl Into<ReposListBranchesParams>>) -> Result<Vec<ShortBranch>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/branches", super::GITHUB_BASE_API_URL, owner, repo);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: ReposListBranchesParams = 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(ReposListBranchesError::Status404(github_response.to_json()?).into()),
code => Err(ReposListBranchesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List branches for HEAD commit
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// Returns all branches where the given commit SHA is the HEAD, or latest commit for the branch.
///
/// [GitHub API docs for list_branches_for_head_commit](https://docs.github.com/rest/commits/commits#list-branches-for-head-commit)
///
/// ---
pub async fn list_branches_for_head_commit_async(&self, owner: &str, repo: &str, commit_sha: &str) -> Result<Vec<BranchShort>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/commits/{}/branches-where-head", super::GITHUB_BASE_API_URL, owner, repo, commit_sha);
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(ReposListBranchesForHeadCommitError::Status422(github_response.to_json_async().await?).into()),
409 => Err(ReposListBranchesForHeadCommitError::Status409(github_response.to_json_async().await?).into()),
code => Err(ReposListBranchesForHeadCommitError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List branches for HEAD commit
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// Returns all branches where the given commit SHA is the HEAD, or latest commit for the branch.
///
/// [GitHub API docs for list_branches_for_head_commit](https://docs.github.com/rest/commits/commits#list-branches-for-head-commit)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_branches_for_head_commit(&self, owner: &str, repo: &str, commit_sha: &str) -> Result<Vec<BranchShort>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/commits/{}/branches-where-head", super::GITHUB_BASE_API_URL, owner, repo, commit_sha);
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(ReposListBranchesForHeadCommitError::Status422(github_response.to_json()?).into()),
409 => Err(ReposListBranchesForHeadCommitError::Status409(github_response.to_json()?).into()),
code => Err(ReposListBranchesForHeadCommitError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List repository collaborators
///
/// For organization-owned repositories, the list of collaborators includes outside collaborators, organization members that are direct collaborators, organization members with access through team memberships, organization members with access through default organization permissions, and organization owners.
/// The `permissions` hash returned in the response contains the base role permissions of the collaborator. The `role_name` is the highest role assigned to the collaborator after considering all sources of grants, including: repo, teams, organization, and enterprise.
/// There is presently not a way to differentiate between an organization level grant and a repository level grant from this endpoint response.
///
/// Team members will include the members of child teams.
///
/// The authenticated user must have write, maintain, or admin privileges on the repository to use this endpoint. For organization-owned repositories, the authenticated user needs to be a member of the organization.
/// OAuth app tokens and personal access tokens (classic) need the `read:org` and `repo` scopes to use this endpoint.
///
/// [GitHub API docs for list_collaborators](https://docs.github.com/rest/collaborators/collaborators#list-repository-collaborators)
///
/// ---
pub async fn list_collaborators_async(&self, owner: &str, repo: &str, query_params: Option<impl Into<ReposListCollaboratorsParams<'api>>>) -> Result<Vec<Collaborator>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/collaborators", super::GITHUB_BASE_API_URL, owner, repo);
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(ReposListCollaboratorsError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposListCollaboratorsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List repository collaborators
///
/// For organization-owned repositories, the list of collaborators includes outside collaborators, organization members that are direct collaborators, organization members with access through team memberships, organization members with access through default organization permissions, and organization owners.
/// The `permissions` hash returned in the response contains the base role permissions of the collaborator. The `role_name` is the highest role assigned to the collaborator after considering all sources of grants, including: repo, teams, organization, and enterprise.
/// There is presently not a way to differentiate between an organization level grant and a repository level grant from this endpoint response.
///
/// Team members will include the members of child teams.
///
/// The authenticated user must have write, maintain, or admin privileges on the repository to use this endpoint. For organization-owned repositories, the authenticated user needs to be a member of the organization.
/// OAuth app tokens and personal access tokens (classic) need the `read:org` and `repo` scopes to use this endpoint.
///
/// [GitHub API docs for list_collaborators](https://docs.github.com/rest/collaborators/collaborators#list-repository-collaborators)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_collaborators(&self, owner: &str, repo: &str, query_params: Option<impl Into<ReposListCollaboratorsParams<'api>>>) -> Result<Vec<Collaborator>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/collaborators", super::GITHUB_BASE_API_URL, owner, repo);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: ReposListCollaboratorsParams = 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(ReposListCollaboratorsError::Status404(github_response.to_json()?).into()),
code => Err(ReposListCollaboratorsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List commit comments
///
/// Lists the comments for a specified commit.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
///
/// [GitHub API docs for list_comments_for_commit](https://docs.github.com/rest/commits/comments#list-commit-comments)
///
/// ---
pub async fn list_comments_for_commit_async(&self, owner: &str, repo: &str, commit_sha: &str, query_params: Option<impl Into<ReposListCommentsForCommitParams>>) -> Result<Vec<CommitComment>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/commits/{}/comments", super::GITHUB_BASE_API_URL, owner, repo, commit_sha);
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(ReposListCommentsForCommitError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List commit comments
///
/// Lists the comments for a specified commit.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
///
/// [GitHub API docs for list_comments_for_commit](https://docs.github.com/rest/commits/comments#list-commit-comments)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_comments_for_commit(&self, owner: &str, repo: &str, commit_sha: &str, query_params: Option<impl Into<ReposListCommentsForCommitParams>>) -> Result<Vec<CommitComment>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/commits/{}/comments", super::GITHUB_BASE_API_URL, owner, repo, commit_sha);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: ReposListCommentsForCommitParams = 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(ReposListCommentsForCommitError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List commit comments for a repository
///
/// Lists the commit comments for a specified repository. Comments are ordered by ascending ID.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
///
/// [GitHub API docs for list_commit_comments_for_repo](https://docs.github.com/rest/commits/comments#list-commit-comments-for-a-repository)
///
/// ---
pub async fn list_commit_comments_for_repo_async(&self, owner: &str, repo: &str, query_params: Option<impl Into<ReposListCommitCommentsForRepoParams>>) -> Result<Vec<CommitComment>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/comments", super::GITHUB_BASE_API_URL, owner, repo);
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(ReposListCommitCommentsForRepoError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List commit comments for a repository
///
/// Lists the commit comments for a specified repository. Comments are ordered by ascending ID.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
///
/// [GitHub API docs for list_commit_comments_for_repo](https://docs.github.com/rest/commits/comments#list-commit-comments-for-a-repository)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_commit_comments_for_repo(&self, owner: &str, repo: &str, query_params: Option<impl Into<ReposListCommitCommentsForRepoParams>>) -> Result<Vec<CommitComment>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/comments", super::GITHUB_BASE_API_URL, owner, repo);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: ReposListCommitCommentsForRepoParams = 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(ReposListCommitCommentsForRepoError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List commit statuses for a reference
///
/// Users with pull access in a repository can view commit statuses for a given ref. The ref can be a SHA, a branch name, or a tag name. Statuses are returned in reverse chronological order. The first status in the list will be the latest one.
///
/// This resource is also available via a legacy route: `GET /repos/:owner/:repo/statuses/:ref`.
///
/// [GitHub API docs for list_commit_statuses_for_ref](https://docs.github.com/rest/commits/statuses#list-commit-statuses-for-a-reference)
///
/// ---
pub async fn list_commit_statuses_for_ref_async(&self, owner: &str, repo: &str, git_ref: &str, query_params: Option<impl Into<ReposListCommitStatusesForRefParams>>) -> Result<Vec<Status>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/commits/{}/statuses", super::GITHUB_BASE_API_URL, owner, repo, git_ref);
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() {
301 => Err(ReposListCommitStatusesForRefError::Status301(github_response.to_json_async().await?).into()),
code => Err(ReposListCommitStatusesForRefError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List commit statuses for a reference
///
/// Users with pull access in a repository can view commit statuses for a given ref. The ref can be a SHA, a branch name, or a tag name. Statuses are returned in reverse chronological order. The first status in the list will be the latest one.
///
/// This resource is also available via a legacy route: `GET /repos/:owner/:repo/statuses/:ref`.
///
/// [GitHub API docs for list_commit_statuses_for_ref](https://docs.github.com/rest/commits/statuses#list-commit-statuses-for-a-reference)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_commit_statuses_for_ref(&self, owner: &str, repo: &str, git_ref: &str, query_params: Option<impl Into<ReposListCommitStatusesForRefParams>>) -> Result<Vec<Status>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/commits/{}/statuses", super::GITHUB_BASE_API_URL, owner, repo, git_ref);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: ReposListCommitStatusesForRefParams = 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() {
301 => Err(ReposListCommitStatusesForRefError::Status301(github_response.to_json()?).into()),
code => Err(ReposListCommitStatusesForRefError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List commits
///
/// **Signature verification object**
///
/// The response will include a `verification` object that describes the result of verifying the commit's signature. The following fields are included in the `verification` object:
///
/// | Name | Type | Description |
/// | ---- | ---- | ----------- |
/// | `verified` | `boolean` | Indicates whether GitHub considers the signature in this commit to be verified. |
/// | `reason` | `string` | The reason for verified value. Possible values and their meanings are enumerated in table below. |
/// | `signature` | `string` | The signature that was extracted from the commit. |
/// | `payload` | `string` | The value that was signed. |
/// | `verified_at` | `string` | The date the signature was verified by GitHub. |
///
/// These are the possible values for `reason` in the `verification` object:
///
/// | Value | Description |
/// | ----- | ----------- |
/// | `expired_key` | The key that made the signature is expired. |
/// | `not_signing_key` | The "signing" flag is not among the usage flags in the GPG key that made the signature. |
/// | `gpgverify_error` | There was an error communicating with the signature verification service. |
/// | `gpgverify_unavailable` | The signature verification service is currently unavailable. |
/// | `unsigned` | The object does not include a signature. |
/// | `unknown_signature_type` | A non-PGP signature was found in the commit. |
/// | `no_user` | No user was associated with the `committer` email address in the commit. |
/// | `unverified_email` | The `committer` email address in the commit was associated with a user, but the email address is not verified on their account. |
/// | `bad_email` | The `committer` email address in the commit is not included in the identities of the PGP key that made the signature. |
/// | `unknown_key` | The key that made the signature has not been registered with any user's account. |
/// | `malformed_signature` | There was an error parsing the signature. |
/// | `invalid` | The signature could not be cryptographically verified using the key whose key-id was found in the signature. |
/// | `valid` | None of the above errors applied, so the signature is considered to be verified. |
///
/// [GitHub API docs for list_commits](https://docs.github.com/rest/commits/commits#list-commits)
///
/// ---
pub async fn list_commits_async(&self, owner: &str, repo: &str, query_params: Option<impl Into<ReposListCommitsParams<'api>>>) -> Result<Vec<Commit>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/commits", super::GITHUB_BASE_API_URL, owner, repo);
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(ReposListCommitsError::Status500(github_response.to_json_async().await?).into()),
400 => Err(ReposListCommitsError::Status400(github_response.to_json_async().await?).into()),
404 => Err(ReposListCommitsError::Status404(github_response.to_json_async().await?).into()),
409 => Err(ReposListCommitsError::Status409(github_response.to_json_async().await?).into()),
code => Err(ReposListCommitsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List commits
///
/// **Signature verification object**
///
/// The response will include a `verification` object that describes the result of verifying the commit's signature. The following fields are included in the `verification` object:
///
/// | Name | Type | Description |
/// | ---- | ---- | ----------- |
/// | `verified` | `boolean` | Indicates whether GitHub considers the signature in this commit to be verified. |
/// | `reason` | `string` | The reason for verified value. Possible values and their meanings are enumerated in table below. |
/// | `signature` | `string` | The signature that was extracted from the commit. |
/// | `payload` | `string` | The value that was signed. |
/// | `verified_at` | `string` | The date the signature was verified by GitHub. |
///
/// These are the possible values for `reason` in the `verification` object:
///
/// | Value | Description |
/// | ----- | ----------- |
/// | `expired_key` | The key that made the signature is expired. |
/// | `not_signing_key` | The "signing" flag is not among the usage flags in the GPG key that made the signature. |
/// | `gpgverify_error` | There was an error communicating with the signature verification service. |
/// | `gpgverify_unavailable` | The signature verification service is currently unavailable. |
/// | `unsigned` | The object does not include a signature. |
/// | `unknown_signature_type` | A non-PGP signature was found in the commit. |
/// | `no_user` | No user was associated with the `committer` email address in the commit. |
/// | `unverified_email` | The `committer` email address in the commit was associated with a user, but the email address is not verified on their account. |
/// | `bad_email` | The `committer` email address in the commit is not included in the identities of the PGP key that made the signature. |
/// | `unknown_key` | The key that made the signature has not been registered with any user's account. |
/// | `malformed_signature` | There was an error parsing the signature. |
/// | `invalid` | The signature could not be cryptographically verified using the key whose key-id was found in the signature. |
/// | `valid` | None of the above errors applied, so the signature is considered to be verified. |
///
/// [GitHub API docs for list_commits](https://docs.github.com/rest/commits/commits#list-commits)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_commits(&self, owner: &str, repo: &str, query_params: Option<impl Into<ReposListCommitsParams<'api>>>) -> Result<Vec<Commit>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/commits", super::GITHUB_BASE_API_URL, owner, repo);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: ReposListCommitsParams = 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(ReposListCommitsError::Status500(github_response.to_json()?).into()),
400 => Err(ReposListCommitsError::Status400(github_response.to_json()?).into()),
404 => Err(ReposListCommitsError::Status404(github_response.to_json()?).into()),
409 => Err(ReposListCommitsError::Status409(github_response.to_json()?).into()),
code => Err(ReposListCommitsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List repository contributors
///
/// Lists contributors to the specified repository and sorts them by the number of commits per contributor in descending order. This endpoint may return information that is a few hours old because the GitHub REST API caches contributor data to improve performance.
///
/// GitHub identifies contributors by author email address. This endpoint groups contribution counts by GitHub user, which includes all associated email addresses. To improve performance, only the first 500 author email addresses in the repository link to GitHub users. The rest will appear as anonymous contributors without associated GitHub user information.
///
/// [GitHub API docs for list_contributors](https://docs.github.com/rest/repos/repos#list-repository-contributors)
///
/// ---
pub async fn list_contributors_async(&self, owner: &str, repo: &str, query_params: Option<impl Into<ReposListContributorsParams<'api>>>) -> Result<Vec<Contributor>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/contributors", super::GITHUB_BASE_API_URL, owner, repo);
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() {
204 => Err(ReposListContributorsError::Status204.into()),
403 => Err(ReposListContributorsError::Status403(github_response.to_json_async().await?).into()),
404 => Err(ReposListContributorsError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposListContributorsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List repository contributors
///
/// Lists contributors to the specified repository and sorts them by the number of commits per contributor in descending order. This endpoint may return information that is a few hours old because the GitHub REST API caches contributor data to improve performance.
///
/// GitHub identifies contributors by author email address. This endpoint groups contribution counts by GitHub user, which includes all associated email addresses. To improve performance, only the first 500 author email addresses in the repository link to GitHub users. The rest will appear as anonymous contributors without associated GitHub user information.
///
/// [GitHub API docs for list_contributors](https://docs.github.com/rest/repos/repos#list-repository-contributors)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_contributors(&self, owner: &str, repo: &str, query_params: Option<impl Into<ReposListContributorsParams<'api>>>) -> Result<Vec<Contributor>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/contributors", super::GITHUB_BASE_API_URL, owner, repo);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: ReposListContributorsParams = 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() {
204 => Err(ReposListContributorsError::Status204.into()),
403 => Err(ReposListContributorsError::Status403(github_response.to_json()?).into()),
404 => Err(ReposListContributorsError::Status404(github_response.to_json()?).into()),
code => Err(ReposListContributorsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List custom deployment rule integrations available for an environment
///
/// Gets all custom deployment protection rule integrations that are available for an environment.
///
/// The authenticated user must have admin or owner permissions to the repository to use this endpoint.
///
/// For more information about environments, see "[Using environments for deployment](https://docs.github.com/actions/deployment/targeting-different-environments/using-environments-for-deployment)."
///
/// For more information about the app that is providing this custom deployment rule, see "[GET an app](https://docs.github.com/rest/apps/apps#get-an-app)".
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with a private repository.
///
/// [GitHub API docs for list_custom_deployment_rule_integrations](https://docs.github.com/rest/deployments/protection-rules#list-custom-deployment-rule-integrations-available-for-an-environment)
///
/// ---
pub async fn list_custom_deployment_rule_integrations_async(&self, environment_name: &str, repo: &str, owner: &str, query_params: Option<impl Into<ReposListCustomDeploymentRuleIntegrationsParams>>) -> Result<GetReposListCustomDeploymentRuleIntegrationsResponse200, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/environments/{}/deployment_protection_rules/apps", super::GITHUB_BASE_API_URL, environment_name, repo, owner);
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(ReposListCustomDeploymentRuleIntegrationsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List custom deployment rule integrations available for an environment
///
/// Gets all custom deployment protection rule integrations that are available for an environment.
///
/// The authenticated user must have admin or owner permissions to the repository to use this endpoint.
///
/// For more information about environments, see "[Using environments for deployment](https://docs.github.com/actions/deployment/targeting-different-environments/using-environments-for-deployment)."
///
/// For more information about the app that is providing this custom deployment rule, see "[GET an app](https://docs.github.com/rest/apps/apps#get-an-app)".
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with a private repository.
///
/// [GitHub API docs for list_custom_deployment_rule_integrations](https://docs.github.com/rest/deployments/protection-rules#list-custom-deployment-rule-integrations-available-for-an-environment)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_custom_deployment_rule_integrations(&self, environment_name: &str, repo: &str, owner: &str, query_params: Option<impl Into<ReposListCustomDeploymentRuleIntegrationsParams>>) -> Result<GetReposListCustomDeploymentRuleIntegrationsResponse200, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/environments/{}/deployment_protection_rules/apps", super::GITHUB_BASE_API_URL, environment_name, repo, owner);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: ReposListCustomDeploymentRuleIntegrationsParams = 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(ReposListCustomDeploymentRuleIntegrationsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List deploy keys
///
/// [GitHub API docs for list_deploy_keys](https://docs.github.com/rest/deploy-keys/deploy-keys#list-deploy-keys)
///
/// ---
pub async fn list_deploy_keys_async(&self, owner: &str, repo: &str, query_params: Option<impl Into<ReposListDeployKeysParams>>) -> Result<Vec<DeployKey>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/keys", super::GITHUB_BASE_API_URL, owner, repo);
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(ReposListDeployKeysError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List deploy keys
///
/// [GitHub API docs for list_deploy_keys](https://docs.github.com/rest/deploy-keys/deploy-keys#list-deploy-keys)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_deploy_keys(&self, owner: &str, repo: &str, query_params: Option<impl Into<ReposListDeployKeysParams>>) -> Result<Vec<DeployKey>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/keys", super::GITHUB_BASE_API_URL, owner, repo);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: ReposListDeployKeysParams = 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(ReposListDeployKeysError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List deployment branch policies
///
/// Lists the deployment branch policies for an environment.
///
/// Anyone with read access to the repository can use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with a private repository.
///
/// [GitHub API docs for list_deployment_branch_policies](https://docs.github.com/rest/deployments/branch-policies#list-deployment-branch-policies)
///
/// ---
pub async fn list_deployment_branch_policies_async(&self, owner: &str, repo: &str, environment_name: &str, query_params: Option<impl Into<ReposListDeploymentBranchPoliciesParams>>) -> Result<GetReposListDeploymentBranchPoliciesResponse200, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/environments/{}/deployment-branch-policies", super::GITHUB_BASE_API_URL, owner, repo, environment_name);
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(ReposListDeploymentBranchPoliciesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List deployment branch policies
///
/// Lists the deployment branch policies for an environment.
///
/// Anyone with read access to the repository can use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with a private repository.
///
/// [GitHub API docs for list_deployment_branch_policies](https://docs.github.com/rest/deployments/branch-policies#list-deployment-branch-policies)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_deployment_branch_policies(&self, owner: &str, repo: &str, environment_name: &str, query_params: Option<impl Into<ReposListDeploymentBranchPoliciesParams>>) -> Result<GetReposListDeploymentBranchPoliciesResponse200, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/environments/{}/deployment-branch-policies", super::GITHUB_BASE_API_URL, owner, repo, environment_name);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: ReposListDeploymentBranchPoliciesParams = 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(ReposListDeploymentBranchPoliciesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List deployment statuses
///
/// Users with pull access can view deployment statuses for a deployment:
///
/// [GitHub API docs for list_deployment_statuses](https://docs.github.com/rest/deployments/statuses#list-deployment-statuses)
///
/// ---
pub async fn list_deployment_statuses_async(&self, owner: &str, repo: &str, deployment_id: i32, query_params: Option<impl Into<ReposListDeploymentStatusesParams>>) -> Result<Vec<DeploymentStatus>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/deployments/{}/statuses", super::GITHUB_BASE_API_URL, owner, repo, deployment_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(ReposListDeploymentStatusesError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposListDeploymentStatusesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List deployment statuses
///
/// Users with pull access can view deployment statuses for a deployment:
///
/// [GitHub API docs for list_deployment_statuses](https://docs.github.com/rest/deployments/statuses#list-deployment-statuses)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_deployment_statuses(&self, owner: &str, repo: &str, deployment_id: i32, query_params: Option<impl Into<ReposListDeploymentStatusesParams>>) -> Result<Vec<DeploymentStatus>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/deployments/{}/statuses", super::GITHUB_BASE_API_URL, owner, repo, deployment_id);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: ReposListDeploymentStatusesParams = 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(ReposListDeploymentStatusesError::Status404(github_response.to_json()?).into()),
code => Err(ReposListDeploymentStatusesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List deployments
///
/// Simple filtering of deployments is available via query parameters:
///
/// [GitHub API docs for list_deployments](https://docs.github.com/rest/deployments/deployments#list-deployments)
///
/// ---
pub async fn list_deployments_async(&self, owner: &str, repo: &str, query_params: Option<impl Into<ReposListDeploymentsParams<'api>>>) -> Result<Vec<Deployment>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/deployments", super::GITHUB_BASE_API_URL, owner, repo);
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(ReposListDeploymentsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List deployments
///
/// Simple filtering of deployments is available via query parameters:
///
/// [GitHub API docs for list_deployments](https://docs.github.com/rest/deployments/deployments#list-deployments)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_deployments(&self, owner: &str, repo: &str, query_params: Option<impl Into<ReposListDeploymentsParams<'api>>>) -> Result<Vec<Deployment>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/deployments", super::GITHUB_BASE_API_URL, owner, repo);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: ReposListDeploymentsParams = 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(ReposListDeploymentsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List repositories for the authenticated user
///
/// Lists repositories that the authenticated user has explicit permission (`:read`, `:write`, or `:admin`) to access.
///
/// The authenticated user has explicit permission to access repositories they own, repositories where they are a collaborator, and repositories that they can access through an organization membership.
///
/// [GitHub API docs for list_for_authenticated_user](https://docs.github.com/rest/repos/repos#list-repositories-for-the-authenticated-user)
///
/// ---
pub async fn list_for_authenticated_user_async(&self, query_params: Option<impl Into<ReposListForAuthenticatedUserParams<'api>>>) -> Result<Vec<Repository>, AdapterError> {
let mut request_uri = format!("{}/user/repos", 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() {
422 => Err(ReposListForAuthenticatedUserError::Status422(github_response.to_json_async().await?).into()),
304 => Err(ReposListForAuthenticatedUserError::Status304.into()),
403 => Err(ReposListForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()),
401 => Err(ReposListForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()),
code => Err(ReposListForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List repositories for the authenticated user
///
/// Lists repositories that the authenticated user has explicit permission (`:read`, `:write`, or `:admin`) to access.
///
/// The authenticated user has explicit permission to access repositories they own, repositories where they are a collaborator, and repositories that they can access through an organization membership.
///
/// [GitHub API docs for list_for_authenticated_user](https://docs.github.com/rest/repos/repos#list-repositories-for-the-authenticated-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_for_authenticated_user(&self, query_params: Option<impl Into<ReposListForAuthenticatedUserParams<'api>>>) -> Result<Vec<Repository>, AdapterError> {
let mut request_uri = format!("{}/user/repos", super::GITHUB_BASE_API_URL);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: ReposListForAuthenticatedUserParams = 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(ReposListForAuthenticatedUserError::Status422(github_response.to_json()?).into()),
304 => Err(ReposListForAuthenticatedUserError::Status304.into()),
403 => Err(ReposListForAuthenticatedUserError::Status403(github_response.to_json()?).into()),
401 => Err(ReposListForAuthenticatedUserError::Status401(github_response.to_json()?).into()),
code => Err(ReposListForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List organization repositories
///
/// Lists repositories for the specified organization.
///
/// > [!NOTE]
/// > In order to see the `security_and_analysis` block for a repository you must have admin permissions for the repository or be an owner or security manager for the organization that owns the repository. 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)."
///
/// [GitHub API docs for list_for_org](https://docs.github.com/rest/repos/repos#list-organization-repositories)
///
/// ---
pub async fn list_for_org_async(&self, org: &str, query_params: Option<impl Into<ReposListForOrgParams<'api>>>) -> Result<Vec<MinimalRepository>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/repos", 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(ReposListForOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List organization repositories
///
/// Lists repositories for the specified organization.
///
/// > [!NOTE]
/// > In order to see the `security_and_analysis` block for a repository you must have admin permissions for the repository or be an owner or security manager for the organization that owns the repository. 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)."
///
/// [GitHub API docs for list_for_org](https://docs.github.com/rest/repos/repos#list-organization-repositories)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_for_org(&self, org: &str, query_params: Option<impl Into<ReposListForOrgParams<'api>>>) -> Result<Vec<MinimalRepository>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/repos", super::GITHUB_BASE_API_URL, org);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: ReposListForOrgParams = 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(ReposListForOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List repositories for a user
///
/// Lists public repositories for the specified user.
///
/// [GitHub API docs for list_for_user](https://docs.github.com/rest/repos/repos#list-repositories-for-a-user)
///
/// ---
pub async fn list_for_user_async(&self, username: &str, query_params: Option<impl Into<ReposListForUserParams<'api>>>) -> Result<Vec<MinimalRepository>, AdapterError> {
let mut request_uri = format!("{}/users/{}/repos", 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(ReposListForUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List repositories for a user
///
/// Lists public repositories for the specified user.
///
/// [GitHub API docs for list_for_user](https://docs.github.com/rest/repos/repos#list-repositories-for-a-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_for_user(&self, username: &str, query_params: Option<impl Into<ReposListForUserParams<'api>>>) -> Result<Vec<MinimalRepository>, AdapterError> {
let mut request_uri = format!("{}/users/{}/repos", super::GITHUB_BASE_API_URL, username);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: ReposListForUserParams = 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(ReposListForUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List forks
///
/// [GitHub API docs for list_forks](https://docs.github.com/rest/repos/forks#list-forks)
///
/// ---
pub async fn list_forks_async(&self, owner: &str, repo: &str, query_params: Option<impl Into<ReposListForksParams<'api>>>) -> Result<Vec<MinimalRepository>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/forks", super::GITHUB_BASE_API_URL, owner, repo);
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(ReposListForksError::Status400(github_response.to_json_async().await?).into()),
code => Err(ReposListForksError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List forks
///
/// [GitHub API docs for list_forks](https://docs.github.com/rest/repos/forks#list-forks)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_forks(&self, owner: &str, repo: &str, query_params: Option<impl Into<ReposListForksParams<'api>>>) -> Result<Vec<MinimalRepository>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/forks", super::GITHUB_BASE_API_URL, owner, repo);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: ReposListForksParams = 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(ReposListForksError::Status400(github_response.to_json()?).into()),
code => Err(ReposListForksError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List repository invitations
///
/// When authenticating as a user with admin rights to a repository, this endpoint will list all currently open repository invitations.
///
/// [GitHub API docs for list_invitations](https://docs.github.com/rest/collaborators/invitations#list-repository-invitations)
///
/// ---
pub async fn list_invitations_async(&self, owner: &str, repo: &str, query_params: Option<impl Into<ReposListInvitationsParams>>) -> Result<Vec<RepositoryInvitation>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/invitations", super::GITHUB_BASE_API_URL, owner, repo);
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(ReposListInvitationsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List repository invitations
///
/// When authenticating as a user with admin rights to a repository, this endpoint will list all currently open repository invitations.
///
/// [GitHub API docs for list_invitations](https://docs.github.com/rest/collaborators/invitations#list-repository-invitations)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_invitations(&self, owner: &str, repo: &str, query_params: Option<impl Into<ReposListInvitationsParams>>) -> Result<Vec<RepositoryInvitation>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/invitations", super::GITHUB_BASE_API_URL, owner, repo);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: ReposListInvitationsParams = 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(ReposListInvitationsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List repository invitations for the authenticated user
///
/// When authenticating as a user, this endpoint will list all currently open repository invitations for that user.
///
/// [GitHub API docs for list_invitations_for_authenticated_user](https://docs.github.com/rest/collaborators/invitations#list-repository-invitations-for-the-authenticated-user)
///
/// ---
pub async fn list_invitations_for_authenticated_user_async(&self, query_params: Option<impl Into<ReposListInvitationsForAuthenticatedUserParams>>) -> Result<Vec<RepositoryInvitation>, AdapterError> {
let mut request_uri = format!("{}/user/repository_invitations", 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(ReposListInvitationsForAuthenticatedUserError::Status304.into()),
404 => Err(ReposListInvitationsForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()),
403 => Err(ReposListInvitationsForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()),
401 => Err(ReposListInvitationsForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()),
code => Err(ReposListInvitationsForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List repository invitations for the authenticated user
///
/// When authenticating as a user, this endpoint will list all currently open repository invitations for that user.
///
/// [GitHub API docs for list_invitations_for_authenticated_user](https://docs.github.com/rest/collaborators/invitations#list-repository-invitations-for-the-authenticated-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_invitations_for_authenticated_user(&self, query_params: Option<impl Into<ReposListInvitationsForAuthenticatedUserParams>>) -> Result<Vec<RepositoryInvitation>, AdapterError> {
let mut request_uri = format!("{}/user/repository_invitations", super::GITHUB_BASE_API_URL);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: ReposListInvitationsForAuthenticatedUserParams = 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(ReposListInvitationsForAuthenticatedUserError::Status304.into()),
404 => Err(ReposListInvitationsForAuthenticatedUserError::Status404(github_response.to_json()?).into()),
403 => Err(ReposListInvitationsForAuthenticatedUserError::Status403(github_response.to_json()?).into()),
401 => Err(ReposListInvitationsForAuthenticatedUserError::Status401(github_response.to_json()?).into()),
code => Err(ReposListInvitationsForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List repository languages
///
/// Lists languages for the specified repository. The value shown for each language is the number of bytes of code written in that language.
///
/// [GitHub API docs for list_languages](https://docs.github.com/rest/repos/repos#list-repository-languages)
///
/// ---
pub async fn list_languages_async(&self, owner: &str, repo: &str) -> Result<Language, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/languages", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
code => Err(ReposListLanguagesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List repository languages
///
/// Lists languages for the specified repository. The value shown for each language is the number of bytes of code written in that language.
///
/// [GitHub API docs for list_languages](https://docs.github.com/rest/repos/repos#list-repository-languages)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_languages(&self, owner: &str, repo: &str) -> Result<Language, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/languages", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
code => Err(ReposListLanguagesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List GitHub Pages builds
///
/// Lists builts of a GitHub Pages site.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.
///
/// [GitHub API docs for list_pages_builds](https://docs.github.com/rest/pages/pages#list-apiname-pages-builds)
///
/// ---
pub async fn list_pages_builds_async(&self, owner: &str, repo: &str, query_params: Option<impl Into<ReposListPagesBuildsParams>>) -> Result<Vec<PageBuild>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/pages/builds", super::GITHUB_BASE_API_URL, owner, repo);
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(ReposListPagesBuildsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List GitHub Pages builds
///
/// Lists builts of a GitHub Pages site.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.
///
/// [GitHub API docs for list_pages_builds](https://docs.github.com/rest/pages/pages#list-apiname-pages-builds)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_pages_builds(&self, owner: &str, repo: &str, query_params: Option<impl Into<ReposListPagesBuildsParams>>) -> Result<Vec<PageBuild>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/pages/builds", super::GITHUB_BASE_API_URL, owner, repo);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: ReposListPagesBuildsParams = 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(ReposListPagesBuildsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List public repositories
///
/// Lists all public repositories in the order that they were created.
///
/// Note:
/// - For GitHub Enterprise Server, this endpoint will only list repositories available to all users on the enterprise.
/// - 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 repositories.
///
/// [GitHub API docs for list_public](https://docs.github.com/rest/repos/repos#list-public-repositories)
///
/// ---
pub async fn list_public_async(&self, query_params: Option<impl Into<ReposListPublicParams>>) -> Result<Vec<MinimalRepository>, AdapterError> {
let mut request_uri = format!("{}/repositories", 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() {
422 => Err(ReposListPublicError::Status422(github_response.to_json_async().await?).into()),
304 => Err(ReposListPublicError::Status304.into()),
code => Err(ReposListPublicError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List public repositories
///
/// Lists all public repositories in the order that they were created.
///
/// Note:
/// - For GitHub Enterprise Server, this endpoint will only list repositories available to all users on the enterprise.
/// - 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 repositories.
///
/// [GitHub API docs for list_public](https://docs.github.com/rest/repos/repos#list-public-repositories)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_public(&self, query_params: Option<impl Into<ReposListPublicParams>>) -> Result<Vec<MinimalRepository>, AdapterError> {
let mut request_uri = format!("{}/repositories", super::GITHUB_BASE_API_URL);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: ReposListPublicParams = 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(ReposListPublicError::Status422(github_response.to_json()?).into()),
304 => Err(ReposListPublicError::Status304.into()),
code => Err(ReposListPublicError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List pull requests associated with a commit
///
/// Lists the merged pull request that introduced the commit to the repository. If the commit is not present in the default branch, it will return merged and open pull requests associated with the commit.
///
/// To list the open or merged pull requests associated with a branch, you can set the `commit_sha` parameter to the branch name.
///
/// [GitHub API docs for list_pull_requests_associated_with_commit](https://docs.github.com/rest/commits/commits#list-pull-requests-associated-with-a-commit)
///
/// ---
pub async fn list_pull_requests_associated_with_commit_async(&self, owner: &str, repo: &str, commit_sha: &str, query_params: Option<impl Into<ReposListPullRequestsAssociatedWithCommitParams>>) -> Result<Vec<PullRequestSimple>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/commits/{}/pulls", super::GITHUB_BASE_API_URL, owner, repo, commit_sha);
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() {
409 => Err(ReposListPullRequestsAssociatedWithCommitError::Status409(github_response.to_json_async().await?).into()),
code => Err(ReposListPullRequestsAssociatedWithCommitError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List pull requests associated with a commit
///
/// Lists the merged pull request that introduced the commit to the repository. If the commit is not present in the default branch, it will return merged and open pull requests associated with the commit.
///
/// To list the open or merged pull requests associated with a branch, you can set the `commit_sha` parameter to the branch name.
///
/// [GitHub API docs for list_pull_requests_associated_with_commit](https://docs.github.com/rest/commits/commits#list-pull-requests-associated-with-a-commit)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_pull_requests_associated_with_commit(&self, owner: &str, repo: &str, commit_sha: &str, query_params: Option<impl Into<ReposListPullRequestsAssociatedWithCommitParams>>) -> Result<Vec<PullRequestSimple>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/commits/{}/pulls", super::GITHUB_BASE_API_URL, owner, repo, commit_sha);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: ReposListPullRequestsAssociatedWithCommitParams = 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() {
409 => Err(ReposListPullRequestsAssociatedWithCommitError::Status409(github_response.to_json()?).into()),
code => Err(ReposListPullRequestsAssociatedWithCommitError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List release assets
///
/// [GitHub API docs for list_release_assets](https://docs.github.com/rest/releases/assets#list-release-assets)
///
/// ---
pub async fn list_release_assets_async(&self, owner: &str, repo: &str, release_id: i32, query_params: Option<impl Into<ReposListReleaseAssetsParams>>) -> Result<Vec<ReleaseAsset>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/releases/{}/assets", super::GITHUB_BASE_API_URL, owner, repo, release_id);
if let Some(params) = query_params {
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(params.into())?);
}
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
code => Err(ReposListReleaseAssetsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List release assets
///
/// [GitHub API docs for list_release_assets](https://docs.github.com/rest/releases/assets#list-release-assets)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_release_assets(&self, owner: &str, repo: &str, release_id: i32, query_params: Option<impl Into<ReposListReleaseAssetsParams>>) -> Result<Vec<ReleaseAsset>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/releases/{}/assets", super::GITHUB_BASE_API_URL, owner, repo, release_id);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: ReposListReleaseAssetsParams = 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(ReposListReleaseAssetsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List releases
///
/// This returns a list of releases, which does not include regular Git tags that have not been associated with a release. To get a list of Git tags, use the [Repository Tags API](https://docs.github.com/rest/repos/repos#list-repository-tags).
///
/// Information about published releases are available to everyone. Only users with push access will receive listings for draft releases.
///
/// [GitHub API docs for list_releases](https://docs.github.com/rest/releases/releases#list-releases)
///
/// ---
pub async fn list_releases_async(&self, owner: &str, repo: &str, query_params: Option<impl Into<ReposListReleasesParams>>) -> Result<Vec<Release>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/releases", super::GITHUB_BASE_API_URL, owner, repo);
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(ReposListReleasesError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposListReleasesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List releases
///
/// This returns a list of releases, which does not include regular Git tags that have not been associated with a release. To get a list of Git tags, use the [Repository Tags API](https://docs.github.com/rest/repos/repos#list-repository-tags).
///
/// Information about published releases are available to everyone. Only users with push access will receive listings for draft releases.
///
/// [GitHub API docs for list_releases](https://docs.github.com/rest/releases/releases#list-releases)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_releases(&self, owner: &str, repo: &str, query_params: Option<impl Into<ReposListReleasesParams>>) -> Result<Vec<Release>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/releases", super::GITHUB_BASE_API_URL, owner, repo);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: ReposListReleasesParams = 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(ReposListReleasesError::Status404(github_response.to_json()?).into()),
code => Err(ReposListReleasesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Closing down - List tag protection states for a repository
///
/// > [!WARNING]
/// > **Closing down notice:** This operation is closing down and will be removed after August 30, 2024. Use the "[Repository Rulesets](https://docs.github.com/rest/repos/rules#get-all-repository-rulesets)" endpoint instead.
///
/// This returns the tag protection states of a repository.
///
/// This information is only available to repository administrators.
///
/// [GitHub API docs for list_tag_protection](https://docs.github.com/rest/repos/tags#closing-down---list-tag-protection-states-for-a-repository)
///
/// ---
pub async fn list_tag_protection_async(&self, owner: &str, repo: &str) -> Result<Vec<TagProtection>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/tags/protection", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
403 => Err(ReposListTagProtectionError::Status403(github_response.to_json_async().await?).into()),
404 => Err(ReposListTagProtectionError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposListTagProtectionError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Closing down - List tag protection states for a repository
///
/// > [!WARNING]
/// > **Closing down notice:** This operation is closing down and will be removed after August 30, 2024. Use the "[Repository Rulesets](https://docs.github.com/rest/repos/rules#get-all-repository-rulesets)" endpoint instead.
///
/// This returns the tag protection states of a repository.
///
/// This information is only available to repository administrators.
///
/// [GitHub API docs for list_tag_protection](https://docs.github.com/rest/repos/tags#closing-down---list-tag-protection-states-for-a-repository)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_tag_protection(&self, owner: &str, repo: &str) -> Result<Vec<TagProtection>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/tags/protection", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
403 => Err(ReposListTagProtectionError::Status403(github_response.to_json()?).into()),
404 => Err(ReposListTagProtectionError::Status404(github_response.to_json()?).into()),
code => Err(ReposListTagProtectionError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List repository tags
///
/// [GitHub API docs for list_tags](https://docs.github.com/rest/repos/repos#list-repository-tags)
///
/// ---
pub async fn list_tags_async(&self, owner: &str, repo: &str, query_params: Option<impl Into<ReposListTagsParams>>) -> Result<Vec<Tag>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/tags", super::GITHUB_BASE_API_URL, owner, repo);
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(ReposListTagsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List repository tags
///
/// [GitHub API docs for list_tags](https://docs.github.com/rest/repos/repos#list-repository-tags)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_tags(&self, owner: &str, repo: &str, query_params: Option<impl Into<ReposListTagsParams>>) -> Result<Vec<Tag>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/tags", super::GITHUB_BASE_API_URL, owner, repo);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: ReposListTagsParams = 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(ReposListTagsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List repository teams
///
/// Lists the teams that have access to the specified repository and that are also visible to the authenticated user.
///
/// For a public repository, a team is listed only if that team added the public repository explicitly.
///
/// OAuth app tokens and personal access tokens (classic) need the `public_repo` or `repo` scope to use this endpoint with a public repository, and `repo` scope to use this endpoint with a private repository.
///
/// [GitHub API docs for list_teams](https://docs.github.com/rest/repos/repos#list-repository-teams)
///
/// ---
pub async fn list_teams_async(&self, owner: &str, repo: &str, query_params: Option<impl Into<ReposListTeamsParams>>) -> Result<Vec<Team>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/teams", super::GITHUB_BASE_API_URL, owner, repo);
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(ReposListTeamsError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposListTeamsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List repository teams
///
/// Lists the teams that have access to the specified repository and that are also visible to the authenticated user.
///
/// For a public repository, a team is listed only if that team added the public repository explicitly.
///
/// OAuth app tokens and personal access tokens (classic) need the `public_repo` or `repo` scope to use this endpoint with a public repository, and `repo` scope to use this endpoint with a private repository.
///
/// [GitHub API docs for list_teams](https://docs.github.com/rest/repos/repos#list-repository-teams)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_teams(&self, owner: &str, repo: &str, query_params: Option<impl Into<ReposListTeamsParams>>) -> Result<Vec<Team>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/teams", super::GITHUB_BASE_API_URL, owner, repo);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: ReposListTeamsParams = 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(ReposListTeamsError::Status404(github_response.to_json()?).into()),
code => Err(ReposListTeamsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List deliveries for a repository webhook
///
/// Returns a list of webhook deliveries for a webhook configured in a repository.
///
/// [GitHub API docs for list_webhook_deliveries](https://docs.github.com/rest/repos/webhooks#list-deliveries-for-a-repository-webhook)
///
/// ---
pub async fn list_webhook_deliveries_async(&self, owner: &str, repo: &str, hook_id: i32, query_params: Option<impl Into<ReposListWebhookDeliveriesParams<'api>>>) -> Result<Vec<HookDeliveryItem>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/hooks/{}/deliveries", super::GITHUB_BASE_API_URL, owner, repo, 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(ReposListWebhookDeliveriesError::Status400(github_response.to_json_async().await?).into()),
422 => Err(ReposListWebhookDeliveriesError::Status422(github_response.to_json_async().await?).into()),
code => Err(ReposListWebhookDeliveriesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List deliveries for a repository webhook
///
/// Returns a list of webhook deliveries for a webhook configured in a repository.
///
/// [GitHub API docs for list_webhook_deliveries](https://docs.github.com/rest/repos/webhooks#list-deliveries-for-a-repository-webhook)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_webhook_deliveries(&self, owner: &str, repo: &str, hook_id: i32, query_params: Option<impl Into<ReposListWebhookDeliveriesParams<'api>>>) -> Result<Vec<HookDeliveryItem>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/hooks/{}/deliveries", super::GITHUB_BASE_API_URL, owner, repo, hook_id);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: ReposListWebhookDeliveriesParams = 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(ReposListWebhookDeliveriesError::Status400(github_response.to_json()?).into()),
422 => Err(ReposListWebhookDeliveriesError::Status422(github_response.to_json()?).into()),
code => Err(ReposListWebhookDeliveriesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List repository webhooks
///
/// Lists webhooks for a repository. `last response` may return null if there have not been any deliveries within 30 days.
///
/// [GitHub API docs for list_webhooks](https://docs.github.com/rest/repos/webhooks#list-repository-webhooks)
///
/// ---
pub async fn list_webhooks_async(&self, owner: &str, repo: &str, query_params: Option<impl Into<ReposListWebhooksParams>>) -> Result<Vec<Hook>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/hooks", super::GITHUB_BASE_API_URL, owner, repo);
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(ReposListWebhooksError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposListWebhooksError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List repository webhooks
///
/// Lists webhooks for a repository. `last response` may return null if there have not been any deliveries within 30 days.
///
/// [GitHub API docs for list_webhooks](https://docs.github.com/rest/repos/webhooks#list-repository-webhooks)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_webhooks(&self, owner: &str, repo: &str, query_params: Option<impl Into<ReposListWebhooksParams>>) -> Result<Vec<Hook>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/hooks", super::GITHUB_BASE_API_URL, owner, repo);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: ReposListWebhooksParams = 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(ReposListWebhooksError::Status404(github_response.to_json()?).into()),
code => Err(ReposListWebhooksError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Merge a branch
///
/// [GitHub API docs for merge](https://docs.github.com/rest/branches/branches#merge-a-branch)
///
/// ---
pub async fn merge_async(&self, owner: &str, repo: &str, body: PostReposMerge) -> Result<Commit, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/merges", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposMerge>(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() {
204 => Err(ReposMergeError::Status204.into()),
404 => Err(ReposMergeError::Status404.into()),
409 => Err(ReposMergeError::Status409.into()),
403 => Err(ReposMergeError::Status403(github_response.to_json_async().await?).into()),
422 => Err(ReposMergeError::Status422(github_response.to_json_async().await?).into()),
code => Err(ReposMergeError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Merge a branch
///
/// [GitHub API docs for merge](https://docs.github.com/rest/branches/branches#merge-a-branch)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn merge(&self, owner: &str, repo: &str, body: PostReposMerge) -> Result<Commit, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/merges", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposMerge>(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() {
204 => Err(ReposMergeError::Status204.into()),
404 => Err(ReposMergeError::Status404.into()),
409 => Err(ReposMergeError::Status409.into()),
403 => Err(ReposMergeError::Status403(github_response.to_json()?).into()),
422 => Err(ReposMergeError::Status422(github_response.to_json()?).into()),
code => Err(ReposMergeError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Sync a fork branch with the upstream repository
///
/// Sync a branch of a forked repository to keep it up-to-date with the upstream repository.
///
/// [GitHub API docs for merge_upstream](https://docs.github.com/rest/branches/branches#sync-a-fork-branch-with-the-upstream-repository)
///
/// ---
pub async fn merge_upstream_async(&self, owner: &str, repo: &str, body: PostReposMergeUpstream) -> Result<MergedUpstream, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/merge-upstream", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposMergeUpstream>(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() {
409 => Err(ReposMergeUpstreamError::Status409.into()),
422 => Err(ReposMergeUpstreamError::Status422.into()),
code => Err(ReposMergeUpstreamError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Sync a fork branch with the upstream repository
///
/// Sync a branch of a forked repository to keep it up-to-date with the upstream repository.
///
/// [GitHub API docs for merge_upstream](https://docs.github.com/rest/branches/branches#sync-a-fork-branch-with-the-upstream-repository)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn merge_upstream(&self, owner: &str, repo: &str, body: PostReposMergeUpstream) -> Result<MergedUpstream, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/merge-upstream", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposMergeUpstream>(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() {
409 => Err(ReposMergeUpstreamError::Status409.into()),
422 => Err(ReposMergeUpstreamError::Status422.into()),
code => Err(ReposMergeUpstreamError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Ping a repository webhook
///
/// This will trigger a [ping event](https://docs.github.com/webhooks/#ping-event) to be sent to the hook.
///
/// [GitHub API docs for ping_webhook](https://docs.github.com/rest/repos/webhooks#ping-a-repository-webhook)
///
/// ---
pub async fn ping_webhook_async(&self, owner: &str, repo: &str, hook_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/hooks/{}/pings", super::GITHUB_BASE_API_URL, owner, repo, 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(ReposPingWebhookError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposPingWebhookError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Ping a repository webhook
///
/// This will trigger a [ping event](https://docs.github.com/webhooks/#ping-event) to be sent to the hook.
///
/// [GitHub API docs for ping_webhook](https://docs.github.com/rest/repos/webhooks#ping-a-repository-webhook)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn ping_webhook(&self, owner: &str, repo: &str, hook_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/hooks/{}/pings", super::GITHUB_BASE_API_URL, owner, repo, 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(ReposPingWebhookError::Status404(github_response.to_json()?).into()),
code => Err(ReposPingWebhookError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Redeliver a delivery for a repository webhook
///
/// Redeliver a webhook delivery for a webhook configured in a repository.
///
/// [GitHub API docs for redeliver_webhook_delivery](https://docs.github.com/rest/repos/webhooks#redeliver-a-delivery-for-a-repository-webhook)
///
/// ---
pub async fn redeliver_webhook_delivery_async(&self, owner: &str, repo: &str, hook_id: i32, delivery_id: i32) -> Result<HashMap<String, Value>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/hooks/{}/deliveries/{}/attempts", super::GITHUB_BASE_API_URL, owner, repo, 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(ReposRedeliverWebhookDeliveryError::Status400(github_response.to_json_async().await?).into()),
422 => Err(ReposRedeliverWebhookDeliveryError::Status422(github_response.to_json_async().await?).into()),
code => Err(ReposRedeliverWebhookDeliveryError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Redeliver a delivery for a repository webhook
///
/// Redeliver a webhook delivery for a webhook configured in a repository.
///
/// [GitHub API docs for redeliver_webhook_delivery](https://docs.github.com/rest/repos/webhooks#redeliver-a-delivery-for-a-repository-webhook)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn redeliver_webhook_delivery(&self, owner: &str, repo: &str, hook_id: i32, delivery_id: i32) -> Result<HashMap<String, Value>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/hooks/{}/deliveries/{}/attempts", super::GITHUB_BASE_API_URL, owner, repo, 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(ReposRedeliverWebhookDeliveryError::Status400(github_response.to_json()?).into()),
422 => Err(ReposRedeliverWebhookDeliveryError::Status422(github_response.to_json()?).into()),
code => Err(ReposRedeliverWebhookDeliveryError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Remove app access restrictions
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// Removes the ability of an app to push to this branch. Only GitHub Apps that are installed on the repository and that have been granted write access to the repository contents can be added as authorized actors on a protected branch.
///
/// [GitHub API docs for remove_app_access_restrictions](https://docs.github.com/rest/branches/branch-protection#remove-app-access-restrictions)
///
/// ---
pub async fn remove_app_access_restrictions_async(&self, owner: &str, repo: &str, branch: &str, body: DeleteReposRemoveAppAccessRestrictions) -> Result<Vec<Integration>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions/apps", super::GITHUB_BASE_API_URL, owner, repo, branch);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<DeleteReposRemoveAppAccessRestrictions>(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() {
422 => Err(ReposRemoveAppAccessRestrictionsError::Status422(github_response.to_json_async().await?).into()),
code => Err(ReposRemoveAppAccessRestrictionsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Remove app access restrictions
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// Removes the ability of an app to push to this branch. Only GitHub Apps that are installed on the repository and that have been granted write access to the repository contents can be added as authorized actors on a protected branch.
///
/// [GitHub API docs for remove_app_access_restrictions](https://docs.github.com/rest/branches/branch-protection#remove-app-access-restrictions)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn remove_app_access_restrictions(&self, owner: &str, repo: &str, branch: &str, body: DeleteReposRemoveAppAccessRestrictions) -> Result<Vec<Integration>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions/apps", super::GITHUB_BASE_API_URL, owner, repo, branch);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<DeleteReposRemoveAppAccessRestrictions>(body)?),
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() {
422 => Err(ReposRemoveAppAccessRestrictionsError::Status422(github_response.to_json()?).into()),
code => Err(ReposRemoveAppAccessRestrictionsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Remove a repository collaborator
///
/// Removes a collaborator from a repository.
///
/// To use this endpoint, the authenticated user must either be an administrator of the repository or target themselves for removal.
///
/// This endpoint also:
/// - Cancels any outstanding invitations sent by the collaborator
/// - Unassigns the user from any issues
/// - Removes access to organization projects if the user is not an organization member and is not a collaborator on any other organization repositories.
/// - Unstars the repository
/// - Updates access permissions to packages
///
/// Removing a user as a collaborator has the following effects on forks:
/// - If the user had access to a fork through their membership to this repository, the user will also be removed from the fork.
/// - If the user had their own fork of the repository, the fork will be deleted.
/// - If the user still has read access to the repository, open pull requests by this user from a fork will be denied.
///
/// > [!NOTE]
/// > A user can still have access to the repository through organization permissions like base repository permissions.
///
/// Although the API responds immediately, the additional permission updates might take some extra time to complete in the background.
///
/// For more information on fork permissions, see "[About permissions and visibility of forks](https://docs.github.com/pull-requests/collaborating-with-pull-requests/working-with-forks/about-permissions-and-visibility-of-forks)".
///
/// [GitHub API docs for remove_collaborator](https://docs.github.com/rest/collaborators/collaborators#remove-a-repository-collaborator)
///
/// ---
pub async fn remove_collaborator_async(&self, owner: &str, repo: &str, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/collaborators/{}", super::GITHUB_BASE_API_URL, owner, repo, 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(ReposRemoveCollaboratorError::Status422(github_response.to_json_async().await?).into()),
403 => Err(ReposRemoveCollaboratorError::Status403(github_response.to_json_async().await?).into()),
code => Err(ReposRemoveCollaboratorError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Remove a repository collaborator
///
/// Removes a collaborator from a repository.
///
/// To use this endpoint, the authenticated user must either be an administrator of the repository or target themselves for removal.
///
/// This endpoint also:
/// - Cancels any outstanding invitations sent by the collaborator
/// - Unassigns the user from any issues
/// - Removes access to organization projects if the user is not an organization member and is not a collaborator on any other organization repositories.
/// - Unstars the repository
/// - Updates access permissions to packages
///
/// Removing a user as a collaborator has the following effects on forks:
/// - If the user had access to a fork through their membership to this repository, the user will also be removed from the fork.
/// - If the user had their own fork of the repository, the fork will be deleted.
/// - If the user still has read access to the repository, open pull requests by this user from a fork will be denied.
///
/// > [!NOTE]
/// > A user can still have access to the repository through organization permissions like base repository permissions.
///
/// Although the API responds immediately, the additional permission updates might take some extra time to complete in the background.
///
/// For more information on fork permissions, see "[About permissions and visibility of forks](https://docs.github.com/pull-requests/collaborating-with-pull-requests/working-with-forks/about-permissions-and-visibility-of-forks)".
///
/// [GitHub API docs for remove_collaborator](https://docs.github.com/rest/collaborators/collaborators#remove-a-repository-collaborator)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn remove_collaborator(&self, owner: &str, repo: &str, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/collaborators/{}", super::GITHUB_BASE_API_URL, owner, repo, 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(ReposRemoveCollaboratorError::Status422(github_response.to_json()?).into()),
403 => Err(ReposRemoveCollaboratorError::Status403(github_response.to_json()?).into()),
code => Err(ReposRemoveCollaboratorError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Remove status check contexts
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// [GitHub API docs for remove_status_check_contexts](https://docs.github.com/rest/branches/branch-protection#remove-status-check-contexts)
///
/// ---
pub async fn remove_status_check_contexts_async(&self, owner: &str, repo: &str, branch: &str, body: DeleteReposRemoveStatusCheckContexts) -> Result<Vec<String>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_status_checks/contexts", super::GITHUB_BASE_API_URL, owner, repo, branch);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<DeleteReposRemoveStatusCheckContexts>(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(ReposRemoveStatusCheckContextsError::Status404(github_response.to_json_async().await?).into()),
422 => Err(ReposRemoveStatusCheckContextsError::Status422(github_response.to_json_async().await?).into()),
code => Err(ReposRemoveStatusCheckContextsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Remove status check contexts
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// [GitHub API docs for remove_status_check_contexts](https://docs.github.com/rest/branches/branch-protection#remove-status-check-contexts)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn remove_status_check_contexts(&self, owner: &str, repo: &str, branch: &str, body: DeleteReposRemoveStatusCheckContexts) -> Result<Vec<String>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_status_checks/contexts", super::GITHUB_BASE_API_URL, owner, repo, branch);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<DeleteReposRemoveStatusCheckContexts>(body)?),
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(ReposRemoveStatusCheckContextsError::Status404(github_response.to_json()?).into()),
422 => Err(ReposRemoveStatusCheckContextsError::Status422(github_response.to_json()?).into()),
code => Err(ReposRemoveStatusCheckContextsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Remove status check protection
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// [GitHub API docs for remove_status_check_protection](https://docs.github.com/rest/branches/branch-protection#remove-status-check-protection)
///
/// ---
pub async fn remove_status_check_protection_async(&self, owner: &str, repo: &str, branch: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_status_checks", super::GITHUB_BASE_API_URL, owner, repo, branch);
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(ReposRemoveStatusCheckProtectionError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Remove status check protection
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// [GitHub API docs for remove_status_check_protection](https://docs.github.com/rest/branches/branch-protection#remove-status-check-protection)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn remove_status_check_protection(&self, owner: &str, repo: &str, branch: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_status_checks", super::GITHUB_BASE_API_URL, owner, repo, branch);
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(ReposRemoveStatusCheckProtectionError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Remove team access restrictions
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// Removes the ability of a team to push to this branch. You can also remove push access for child teams.
///
/// [GitHub API docs for remove_team_access_restrictions](https://docs.github.com/rest/branches/branch-protection#remove-team-access-restrictions)
///
/// ---
pub async fn remove_team_access_restrictions_async(&self, owner: &str, repo: &str, branch: &str, body: DeleteReposRemoveTeamAccessRestrictions) -> Result<Vec<Team>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions/teams", super::GITHUB_BASE_API_URL, owner, repo, branch);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<DeleteReposRemoveTeamAccessRestrictions>(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() {
422 => Err(ReposRemoveTeamAccessRestrictionsError::Status422(github_response.to_json_async().await?).into()),
code => Err(ReposRemoveTeamAccessRestrictionsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Remove team access restrictions
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// Removes the ability of a team to push to this branch. You can also remove push access for child teams.
///
/// [GitHub API docs for remove_team_access_restrictions](https://docs.github.com/rest/branches/branch-protection#remove-team-access-restrictions)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn remove_team_access_restrictions(&self, owner: &str, repo: &str, branch: &str, body: DeleteReposRemoveTeamAccessRestrictions) -> Result<Vec<Team>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions/teams", super::GITHUB_BASE_API_URL, owner, repo, branch);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<DeleteReposRemoveTeamAccessRestrictions>(body)?),
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() {
422 => Err(ReposRemoveTeamAccessRestrictionsError::Status422(github_response.to_json()?).into()),
code => Err(ReposRemoveTeamAccessRestrictionsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Remove user access restrictions
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// Removes the ability of a user to push to this branch.
///
/// | Type | Description |
/// | ------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
/// | `array` | Usernames of the people who should no longer have push access. **Note**: The list of users, apps, and teams in total is limited to 100 items. |
///
/// [GitHub API docs for remove_user_access_restrictions](https://docs.github.com/rest/branches/branch-protection#remove-user-access-restrictions)
///
/// ---
pub async fn remove_user_access_restrictions_async(&self, owner: &str, repo: &str, branch: &str, body: DeleteReposRemoveUserAccessRestrictions) -> Result<Vec<SimpleUser>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions/users", super::GITHUB_BASE_API_URL, owner, repo, branch);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<DeleteReposRemoveUserAccessRestrictions>(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() {
422 => Err(ReposRemoveUserAccessRestrictionsError::Status422(github_response.to_json_async().await?).into()),
code => Err(ReposRemoveUserAccessRestrictionsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Remove user access restrictions
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// Removes the ability of a user to push to this branch.
///
/// | Type | Description |
/// | ------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
/// | `array` | Usernames of the people who should no longer have push access. **Note**: The list of users, apps, and teams in total is limited to 100 items. |
///
/// [GitHub API docs for remove_user_access_restrictions](https://docs.github.com/rest/branches/branch-protection#remove-user-access-restrictions)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn remove_user_access_restrictions(&self, owner: &str, repo: &str, branch: &str, body: DeleteReposRemoveUserAccessRestrictions) -> Result<Vec<SimpleUser>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions/users", super::GITHUB_BASE_API_URL, owner, repo, branch);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<DeleteReposRemoveUserAccessRestrictions>(body)?),
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() {
422 => Err(ReposRemoveUserAccessRestrictionsError::Status422(github_response.to_json()?).into()),
code => Err(ReposRemoveUserAccessRestrictionsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Rename a branch
///
/// Renames a branch in a repository.
///
/// > [!NOTE]
/// > Although the API responds immediately, the branch rename process might take some extra time to complete in the background. You won't be able to push to the old branch name while the rename process is in progress. For more information, see "[Renaming a branch](https://docs.github.com/github/administering-a-repository/renaming-a-branch)".
///
/// The authenticated user must have push access to the branch. If the branch is the default branch, the authenticated user must also have admin or owner permissions.
///
/// In order to rename the default branch, fine-grained access tokens also need the `administration:write` repository permission.
///
/// [GitHub API docs for rename_branch](https://docs.github.com/rest/branches/branches#rename-a-branch)
///
/// ---
pub async fn rename_branch_async(&self, owner: &str, repo: &str, branch: &str, body: PostReposRenameBranch) -> Result<BranchWithProtection, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/rename", super::GITHUB_BASE_API_URL, owner, repo, branch);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposRenameBranch>(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() {
403 => Err(ReposRenameBranchError::Status403(github_response.to_json_async().await?).into()),
404 => Err(ReposRenameBranchError::Status404(github_response.to_json_async().await?).into()),
422 => Err(ReposRenameBranchError::Status422(github_response.to_json_async().await?).into()),
code => Err(ReposRenameBranchError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Rename a branch
///
/// Renames a branch in a repository.
///
/// > [!NOTE]
/// > Although the API responds immediately, the branch rename process might take some extra time to complete in the background. You won't be able to push to the old branch name while the rename process is in progress. For more information, see "[Renaming a branch](https://docs.github.com/github/administering-a-repository/renaming-a-branch)".
///
/// The authenticated user must have push access to the branch. If the branch is the default branch, the authenticated user must also have admin or owner permissions.
///
/// In order to rename the default branch, fine-grained access tokens also need the `administration:write` repository permission.
///
/// [GitHub API docs for rename_branch](https://docs.github.com/rest/branches/branches#rename-a-branch)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn rename_branch(&self, owner: &str, repo: &str, branch: &str, body: PostReposRenameBranch) -> Result<BranchWithProtection, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/rename", super::GITHUB_BASE_API_URL, owner, repo, branch);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposRenameBranch>(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() {
403 => Err(ReposRenameBranchError::Status403(github_response.to_json()?).into()),
404 => Err(ReposRenameBranchError::Status404(github_response.to_json()?).into()),
422 => Err(ReposRenameBranchError::Status422(github_response.to_json()?).into()),
code => Err(ReposRenameBranchError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Replace all repository topics
///
/// [GitHub API docs for replace_all_topics](https://docs.github.com/rest/repos/repos#replace-all-repository-topics)
///
/// ---
pub async fn replace_all_topics_async(&self, owner: &str, repo: &str, body: PutReposReplaceAllTopics) -> Result<Topic, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/topics", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutReposReplaceAllTopics>(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(ReposReplaceAllTopicsError::Status404(github_response.to_json_async().await?).into()),
422 => Err(ReposReplaceAllTopicsError::Status422(github_response.to_json_async().await?).into()),
code => Err(ReposReplaceAllTopicsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Replace all repository topics
///
/// [GitHub API docs for replace_all_topics](https://docs.github.com/rest/repos/repos#replace-all-repository-topics)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn replace_all_topics(&self, owner: &str, repo: &str, body: PutReposReplaceAllTopics) -> Result<Topic, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/topics", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutReposReplaceAllTopics>(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(ReposReplaceAllTopicsError::Status404(github_response.to_json()?).into()),
422 => Err(ReposReplaceAllTopicsError::Status422(github_response.to_json()?).into()),
code => Err(ReposReplaceAllTopicsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Request a GitHub Pages build
///
/// You can request that your site be built from the latest revision on the default branch. This has the same effect as pushing a commit to your default branch, but does not require an additional commit. Manually triggering page builds can be helpful when diagnosing build warnings and failures.
///
/// Build requests are limited to one concurrent build per repository and one concurrent build per requester. If you request a build while another is still in progress, the second request will be queued until the first completes.
///
/// [GitHub API docs for request_pages_build](https://docs.github.com/rest/pages/pages#request-a-apiname-pages-build)
///
/// ---
pub async fn request_pages_build_async(&self, owner: &str, repo: &str) -> Result<PageBuildStatus, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pages/builds", super::GITHUB_BASE_API_URL, owner, repo);
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() {
code => Err(ReposRequestPagesBuildError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Request a GitHub Pages build
///
/// You can request that your site be built from the latest revision on the default branch. This has the same effect as pushing a commit to your default branch, but does not require an additional commit. Manually triggering page builds can be helpful when diagnosing build warnings and failures.
///
/// Build requests are limited to one concurrent build per repository and one concurrent build per requester. If you request a build while another is still in progress, the second request will be queued until the first completes.
///
/// [GitHub API docs for request_pages_build](https://docs.github.com/rest/pages/pages#request-a-apiname-pages-build)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn request_pages_build(&self, owner: &str, repo: &str) -> Result<PageBuildStatus, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pages/builds", super::GITHUB_BASE_API_URL, owner, repo);
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() {
code => Err(ReposRequestPagesBuildError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Set admin branch protection
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// Adding admin enforcement requires admin or owner permissions to the repository and branch protection to be enabled.
///
/// [GitHub API docs for set_admin_branch_protection](https://docs.github.com/rest/branches/branch-protection#set-admin-branch-protection)
///
/// ---
pub async fn set_admin_branch_protection_async(&self, owner: &str, repo: &str, branch: &str) -> Result<ProtectedBranchAdminEnforced, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/enforce_admins", super::GITHUB_BASE_API_URL, owner, repo, branch);
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() {
code => Err(ReposSetAdminBranchProtectionError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Set admin branch protection
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// Adding admin enforcement requires admin or owner permissions to the repository and branch protection to be enabled.
///
/// [GitHub API docs for set_admin_branch_protection](https://docs.github.com/rest/branches/branch-protection#set-admin-branch-protection)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn set_admin_branch_protection(&self, owner: &str, repo: &str, branch: &str) -> Result<ProtectedBranchAdminEnforced, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/enforce_admins", super::GITHUB_BASE_API_URL, owner, repo, branch);
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() {
code => Err(ReposSetAdminBranchProtectionError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Set app access restrictions
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// Replaces the list of apps that have push access to this branch. This removes all apps that previously had push access and grants push access to the new list of apps. Only GitHub Apps that are installed on the repository and that have been granted write access to the repository contents can be added as authorized actors on a protected branch.
///
/// [GitHub API docs for set_app_access_restrictions](https://docs.github.com/rest/branches/branch-protection#set-app-access-restrictions)
///
/// ---
pub async fn set_app_access_restrictions_async(&self, owner: &str, repo: &str, branch: &str, body: PutReposSetAppAccessRestrictions) -> Result<Vec<Integration>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions/apps", super::GITHUB_BASE_API_URL, owner, repo, branch);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutReposSetAppAccessRestrictions>(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(ReposSetAppAccessRestrictionsError::Status422(github_response.to_json_async().await?).into()),
code => Err(ReposSetAppAccessRestrictionsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Set app access restrictions
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// Replaces the list of apps that have push access to this branch. This removes all apps that previously had push access and grants push access to the new list of apps. Only GitHub Apps that are installed on the repository and that have been granted write access to the repository contents can be added as authorized actors on a protected branch.
///
/// [GitHub API docs for set_app_access_restrictions](https://docs.github.com/rest/branches/branch-protection#set-app-access-restrictions)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn set_app_access_restrictions(&self, owner: &str, repo: &str, branch: &str, body: PutReposSetAppAccessRestrictions) -> Result<Vec<Integration>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions/apps", super::GITHUB_BASE_API_URL, owner, repo, branch);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutReposSetAppAccessRestrictions>(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(ReposSetAppAccessRestrictionsError::Status422(github_response.to_json()?).into()),
code => Err(ReposSetAppAccessRestrictionsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Set status check contexts
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// [GitHub API docs for set_status_check_contexts](https://docs.github.com/rest/branches/branch-protection#set-status-check-contexts)
///
/// ---
pub async fn set_status_check_contexts_async(&self, owner: &str, repo: &str, branch: &str, body: PutReposSetStatusCheckContexts) -> Result<Vec<String>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_status_checks/contexts", super::GITHUB_BASE_API_URL, owner, repo, branch);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutReposSetStatusCheckContexts>(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(ReposSetStatusCheckContextsError::Status422(github_response.to_json_async().await?).into()),
404 => Err(ReposSetStatusCheckContextsError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposSetStatusCheckContextsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Set status check contexts
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// [GitHub API docs for set_status_check_contexts](https://docs.github.com/rest/branches/branch-protection#set-status-check-contexts)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn set_status_check_contexts(&self, owner: &str, repo: &str, branch: &str, body: PutReposSetStatusCheckContexts) -> Result<Vec<String>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_status_checks/contexts", super::GITHUB_BASE_API_URL, owner, repo, branch);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutReposSetStatusCheckContexts>(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(ReposSetStatusCheckContextsError::Status422(github_response.to_json()?).into()),
404 => Err(ReposSetStatusCheckContextsError::Status404(github_response.to_json()?).into()),
code => Err(ReposSetStatusCheckContextsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Set team access restrictions
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// Replaces the list of teams that have push access to this branch. This removes all teams that previously had push access and grants push access to the new list of teams. Team restrictions include child teams.
///
/// [GitHub API docs for set_team_access_restrictions](https://docs.github.com/rest/branches/branch-protection#set-team-access-restrictions)
///
/// ---
pub async fn set_team_access_restrictions_async(&self, owner: &str, repo: &str, branch: &str, body: PutReposSetTeamAccessRestrictions) -> Result<Vec<Team>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions/teams", super::GITHUB_BASE_API_URL, owner, repo, branch);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutReposSetTeamAccessRestrictions>(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(ReposSetTeamAccessRestrictionsError::Status422(github_response.to_json_async().await?).into()),
code => Err(ReposSetTeamAccessRestrictionsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Set team access restrictions
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// Replaces the list of teams that have push access to this branch. This removes all teams that previously had push access and grants push access to the new list of teams. Team restrictions include child teams.
///
/// [GitHub API docs for set_team_access_restrictions](https://docs.github.com/rest/branches/branch-protection#set-team-access-restrictions)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn set_team_access_restrictions(&self, owner: &str, repo: &str, branch: &str, body: PutReposSetTeamAccessRestrictions) -> Result<Vec<Team>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions/teams", super::GITHUB_BASE_API_URL, owner, repo, branch);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutReposSetTeamAccessRestrictions>(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(ReposSetTeamAccessRestrictionsError::Status422(github_response.to_json()?).into()),
code => Err(ReposSetTeamAccessRestrictionsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Set user access restrictions
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// Replaces the list of people that have push access to this branch. This removes all people that previously had push access and grants push access to the new list of people.
///
/// | Type | Description |
/// | ------- | ----------------------------------------------------------------------------------------------------------------------------- |
/// | `array` | Usernames for people who can have push access. **Note**: The list of users, apps, and teams in total is limited to 100 items. |
///
/// [GitHub API docs for set_user_access_restrictions](https://docs.github.com/rest/branches/branch-protection#set-user-access-restrictions)
///
/// ---
pub async fn set_user_access_restrictions_async(&self, owner: &str, repo: &str, branch: &str, body: PutReposSetUserAccessRestrictions) -> Result<Vec<SimpleUser>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions/users", super::GITHUB_BASE_API_URL, owner, repo, branch);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutReposSetUserAccessRestrictions>(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(ReposSetUserAccessRestrictionsError::Status422(github_response.to_json_async().await?).into()),
code => Err(ReposSetUserAccessRestrictionsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Set user access restrictions
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// Replaces the list of people that have push access to this branch. This removes all people that previously had push access and grants push access to the new list of people.
///
/// | Type | Description |
/// | ------- | ----------------------------------------------------------------------------------------------------------------------------- |
/// | `array` | Usernames for people who can have push access. **Note**: The list of users, apps, and teams in total is limited to 100 items. |
///
/// [GitHub API docs for set_user_access_restrictions](https://docs.github.com/rest/branches/branch-protection#set-user-access-restrictions)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn set_user_access_restrictions(&self, owner: &str, repo: &str, branch: &str, body: PutReposSetUserAccessRestrictions) -> Result<Vec<SimpleUser>, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions/users", super::GITHUB_BASE_API_URL, owner, repo, branch);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutReposSetUserAccessRestrictions>(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(ReposSetUserAccessRestrictionsError::Status422(github_response.to_json()?).into()),
code => Err(ReposSetUserAccessRestrictionsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Test the push repository webhook
///
/// This will trigger the hook with the latest push to the current repository if the hook is subscribed to `push` events. If the hook is not subscribed to `push` events, the server will respond with 204 but no test POST will be generated.
///
/// > [!NOTE]
/// > Previously `/repos/:owner/:repo/hooks/:hook_id/test`
///
/// [GitHub API docs for test_push_webhook](https://docs.github.com/rest/repos/webhooks#test-the-push-repository-webhook)
///
/// ---
pub async fn test_push_webhook_async(&self, owner: &str, repo: &str, hook_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/hooks/{}/tests", super::GITHUB_BASE_API_URL, owner, repo, 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(ReposTestPushWebhookError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposTestPushWebhookError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Test the push repository webhook
///
/// This will trigger the hook with the latest push to the current repository if the hook is subscribed to `push` events. If the hook is not subscribed to `push` events, the server will respond with 204 but no test POST will be generated.
///
/// > [!NOTE]
/// > Previously `/repos/:owner/:repo/hooks/:hook_id/test`
///
/// [GitHub API docs for test_push_webhook](https://docs.github.com/rest/repos/webhooks#test-the-push-repository-webhook)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn test_push_webhook(&self, owner: &str, repo: &str, hook_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/hooks/{}/tests", super::GITHUB_BASE_API_URL, owner, repo, 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(ReposTestPushWebhookError::Status404(github_response.to_json()?).into()),
code => Err(ReposTestPushWebhookError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Transfer a repository
///
/// A transfer request will need to be accepted by the new owner when transferring a personal repository to another user. The response will contain the original `owner`, and the transfer will continue asynchronously. For more details on the requirements to transfer personal and organization-owned repositories, see [about repository transfers](https://docs.github.com/articles/about-repository-transfers/).
///
/// [GitHub API docs for transfer](https://docs.github.com/rest/repos/repos#transfer-a-repository)
///
/// ---
pub async fn transfer_async(&self, owner: &str, repo: &str, body: PostReposTransfer) -> Result<MinimalRepository, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/transfer", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposTransfer>(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(ReposTransferError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Transfer a repository
///
/// A transfer request will need to be accepted by the new owner when transferring a personal repository to another user. The response will contain the original `owner`, and the transfer will continue asynchronously. For more details on the requirements to transfer personal and organization-owned repositories, see [about repository transfers](https://docs.github.com/articles/about-repository-transfers/).
///
/// [GitHub API docs for transfer](https://docs.github.com/rest/repos/repos#transfer-a-repository)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn transfer(&self, owner: &str, repo: &str, body: PostReposTransfer) -> Result<MinimalRepository, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/transfer", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostReposTransfer>(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(ReposTransferError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update a repository
///
/// **Note**: To edit a repository's topics, use the [Replace all repository topics](https://docs.github.com/rest/repos/repos#replace-all-repository-topics) endpoint.
///
/// [GitHub API docs for update](https://docs.github.com/rest/repos/repos#update-a-repository)
///
/// ---
pub async fn update_async(&self, owner: &str, repo: &str, body: PatchReposUpdate) -> Result<FullRepository, AdapterError> {
let request_uri = format!("{}/repos/{}/{}", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchReposUpdate>(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() {
307 => Err(ReposUpdateError::Status307(github_response.to_json_async().await?).into()),
403 => Err(ReposUpdateError::Status403(github_response.to_json_async().await?).into()),
422 => Err(ReposUpdateError::Status422(github_response.to_json_async().await?).into()),
404 => Err(ReposUpdateError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposUpdateError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update a repository
///
/// **Note**: To edit a repository's topics, use the [Replace all repository topics](https://docs.github.com/rest/repos/repos#replace-all-repository-topics) endpoint.
///
/// [GitHub API docs for update](https://docs.github.com/rest/repos/repos#update-a-repository)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn update(&self, owner: &str, repo: &str, body: PatchReposUpdate) -> Result<FullRepository, AdapterError> {
let request_uri = format!("{}/repos/{}/{}", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchReposUpdate>(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() {
307 => Err(ReposUpdateError::Status307(github_response.to_json()?).into()),
403 => Err(ReposUpdateError::Status403(github_response.to_json()?).into()),
422 => Err(ReposUpdateError::Status422(github_response.to_json()?).into()),
404 => Err(ReposUpdateError::Status404(github_response.to_json()?).into()),
code => Err(ReposUpdateError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update branch protection
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// Protecting a branch requires admin or owner permissions to the repository.
///
/// > [!NOTE]
/// > Passing new arrays of `users` and `teams` replaces their previous values.
///
/// > [!NOTE]
/// > The list of users, apps, and teams in total is limited to 100 items.
///
/// [GitHub API docs for update_branch_protection](https://docs.github.com/rest/branches/branch-protection#update-branch-protection)
///
/// ---
pub async fn update_branch_protection_async(&self, owner: &str, repo: &str, branch: &str, body: PutReposUpdateBranchProtection) -> Result<ProtectedBranch, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection", super::GITHUB_BASE_API_URL, owner, repo, branch);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutReposUpdateBranchProtection>(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(ReposUpdateBranchProtectionError::Status403(github_response.to_json_async().await?).into()),
422 => Err(ReposUpdateBranchProtectionError::Status422(github_response.to_json_async().await?).into()),
404 => Err(ReposUpdateBranchProtectionError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposUpdateBranchProtectionError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update branch protection
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// Protecting a branch requires admin or owner permissions to the repository.
///
/// > [!NOTE]
/// > Passing new arrays of `users` and `teams` replaces their previous values.
///
/// > [!NOTE]
/// > The list of users, apps, and teams in total is limited to 100 items.
///
/// [GitHub API docs for update_branch_protection](https://docs.github.com/rest/branches/branch-protection#update-branch-protection)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn update_branch_protection(&self, owner: &str, repo: &str, branch: &str, body: PutReposUpdateBranchProtection) -> Result<ProtectedBranch, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection", super::GITHUB_BASE_API_URL, owner, repo, branch);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutReposUpdateBranchProtection>(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(ReposUpdateBranchProtectionError::Status403(github_response.to_json()?).into()),
422 => Err(ReposUpdateBranchProtectionError::Status422(github_response.to_json()?).into()),
404 => Err(ReposUpdateBranchProtectionError::Status404(github_response.to_json()?).into()),
code => Err(ReposUpdateBranchProtectionError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update a commit comment
///
/// Updates the contents of a specified commit comment.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
///
/// [GitHub API docs for update_commit_comment](https://docs.github.com/rest/commits/comments#update-a-commit-comment)
///
/// ---
pub async fn update_commit_comment_async(&self, owner: &str, repo: &str, comment_id: i64, body: PatchReposUpdateCommitComment) -> Result<CommitComment, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/comments/{}", super::GITHUB_BASE_API_URL, owner, repo, comment_id);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchReposUpdateCommitComment>(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() {
404 => Err(ReposUpdateCommitCommentError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposUpdateCommitCommentError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update a commit comment
///
/// Updates the contents of a specified commit comment.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
///
/// [GitHub API docs for update_commit_comment](https://docs.github.com/rest/commits/comments#update-a-commit-comment)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn update_commit_comment(&self, owner: &str, repo: &str, comment_id: i64, body: PatchReposUpdateCommitComment) -> Result<CommitComment, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/comments/{}", super::GITHUB_BASE_API_URL, owner, repo, comment_id);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchReposUpdateCommitComment>(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() {
404 => Err(ReposUpdateCommitCommentError::Status404(github_response.to_json()?).into()),
code => Err(ReposUpdateCommitCommentError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update a deployment branch policy
///
/// Updates a deployment branch or tag policy for an environment.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.
///
/// [GitHub API docs for update_deployment_branch_policy](https://docs.github.com/rest/deployments/branch-policies#update-a-deployment-branch-policy)
///
/// ---
pub async fn update_deployment_branch_policy_async(&self, owner: &str, repo: &str, environment_name: &str, branch_policy_id: i32, body: PutReposUpdateDeploymentBranchPolicy) -> Result<DeploymentBranchPolicy, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/environments/{}/deployment-branch-policies/{}", super::GITHUB_BASE_API_URL, owner, repo, environment_name, branch_policy_id);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutReposUpdateDeploymentBranchPolicy>(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() {
code => Err(ReposUpdateDeploymentBranchPolicyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update a deployment branch policy
///
/// Updates a deployment branch or tag policy for an environment.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.
///
/// [GitHub API docs for update_deployment_branch_policy](https://docs.github.com/rest/deployments/branch-policies#update-a-deployment-branch-policy)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn update_deployment_branch_policy(&self, owner: &str, repo: &str, environment_name: &str, branch_policy_id: i32, body: PutReposUpdateDeploymentBranchPolicy) -> Result<DeploymentBranchPolicy, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/environments/{}/deployment-branch-policies/{}", super::GITHUB_BASE_API_URL, owner, repo, environment_name, branch_policy_id);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutReposUpdateDeploymentBranchPolicy>(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() {
code => Err(ReposUpdateDeploymentBranchPolicyError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update information about a GitHub Pages site
///
/// Updates information for a GitHub Pages site. For more information, see "[About GitHub Pages](/github/working-with-github-pages/about-github-pages).
///
/// The authenticated user must be a repository administrator, maintainer, or have the 'manage GitHub Pages settings' permission.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.
///
/// [GitHub API docs for update_information_about_pages_site](https://docs.github.com/rest/pages/pages#update-information-about-a-apiname-pages-site)
///
/// ---
pub async fn update_information_about_pages_site_async(&self, owner: &str, repo: &str, body: PutReposUpdateInformationAboutPagesSite) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pages", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutReposUpdateInformationAboutPagesSite>(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(ReposUpdateInformationAboutPagesSiteError::Status422(github_response.to_json_async().await?).into()),
400 => Err(ReposUpdateInformationAboutPagesSiteError::Status400(github_response.to_json_async().await?).into()),
409 => Err(ReposUpdateInformationAboutPagesSiteError::Status409(github_response.to_json_async().await?).into()),
code => Err(ReposUpdateInformationAboutPagesSiteError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update information about a GitHub Pages site
///
/// Updates information for a GitHub Pages site. For more information, see "[About GitHub Pages](/github/working-with-github-pages/about-github-pages).
///
/// The authenticated user must be a repository administrator, maintainer, or have the 'manage GitHub Pages settings' permission.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.
///
/// [GitHub API docs for update_information_about_pages_site](https://docs.github.com/rest/pages/pages#update-information-about-a-apiname-pages-site)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn update_information_about_pages_site(&self, owner: &str, repo: &str, body: PutReposUpdateInformationAboutPagesSite) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pages", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutReposUpdateInformationAboutPagesSite>(body)?),
method: "PUT",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
422 => Err(ReposUpdateInformationAboutPagesSiteError::Status422(github_response.to_json()?).into()),
400 => Err(ReposUpdateInformationAboutPagesSiteError::Status400(github_response.to_json()?).into()),
409 => Err(ReposUpdateInformationAboutPagesSiteError::Status409(github_response.to_json()?).into()),
code => Err(ReposUpdateInformationAboutPagesSiteError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update a repository invitation
///
/// [GitHub API docs for update_invitation](https://docs.github.com/rest/collaborators/invitations#update-a-repository-invitation)
///
/// ---
pub async fn update_invitation_async(&self, owner: &str, repo: &str, invitation_id: i32, body: PatchReposUpdateInvitation) -> Result<RepositoryInvitation, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/invitations/{}", super::GITHUB_BASE_API_URL, owner, repo, invitation_id);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchReposUpdateInvitation>(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(ReposUpdateInvitationError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update a repository invitation
///
/// [GitHub API docs for update_invitation](https://docs.github.com/rest/collaborators/invitations#update-a-repository-invitation)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn update_invitation(&self, owner: &str, repo: &str, invitation_id: i32, body: PatchReposUpdateInvitation) -> Result<RepositoryInvitation, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/invitations/{}", super::GITHUB_BASE_API_URL, owner, repo, invitation_id);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchReposUpdateInvitation>(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(ReposUpdateInvitationError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update an organization repository ruleset
///
/// Update a ruleset for an organization.
///
/// [GitHub API docs for update_org_ruleset](https://docs.github.com/rest/orgs/rules#update-an-organization-repository-ruleset)
///
/// ---
pub async fn update_org_ruleset_async(&self, org: &str, ruleset_id: i32, body: PutReposUpdateOrgRuleset) -> Result<RepositoryRuleset, AdapterError> {
let request_uri = format!("{}/orgs/{}/rulesets/{}", super::GITHUB_BASE_API_URL, org, ruleset_id);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutReposUpdateOrgRuleset>(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(ReposUpdateOrgRulesetError::Status404(github_response.to_json_async().await?).into()),
500 => Err(ReposUpdateOrgRulesetError::Status500(github_response.to_json_async().await?).into()),
code => Err(ReposUpdateOrgRulesetError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update an organization repository ruleset
///
/// Update a ruleset for an organization.
///
/// [GitHub API docs for update_org_ruleset](https://docs.github.com/rest/orgs/rules#update-an-organization-repository-ruleset)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn update_org_ruleset(&self, org: &str, ruleset_id: i32, body: PutReposUpdateOrgRuleset) -> Result<RepositoryRuleset, AdapterError> {
let request_uri = format!("{}/orgs/{}/rulesets/{}", super::GITHUB_BASE_API_URL, org, ruleset_id);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutReposUpdateOrgRuleset>(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(ReposUpdateOrgRulesetError::Status404(github_response.to_json()?).into()),
500 => Err(ReposUpdateOrgRulesetError::Status500(github_response.to_json()?).into()),
code => Err(ReposUpdateOrgRulesetError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update pull request review protection
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// Updating pull request review enforcement requires admin or owner permissions to the repository and branch protection to be enabled.
///
/// > [!NOTE]
/// > Passing new arrays of `users` and `teams` replaces their previous values.
///
/// [GitHub API docs for update_pull_request_review_protection](https://docs.github.com/rest/branches/branch-protection#update-pull-request-review-protection)
///
/// ---
pub async fn update_pull_request_review_protection_async(&self, owner: &str, repo: &str, branch: &str, body: PatchReposUpdatePullRequestReviewProtection) -> Result<ProtectedBranchPullRequestReview, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_pull_request_reviews", super::GITHUB_BASE_API_URL, owner, repo, branch);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchReposUpdatePullRequestReviewProtection>(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(ReposUpdatePullRequestReviewProtectionError::Status422(github_response.to_json_async().await?).into()),
code => Err(ReposUpdatePullRequestReviewProtectionError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update pull request review protection
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// Updating pull request review enforcement requires admin or owner permissions to the repository and branch protection to be enabled.
///
/// > [!NOTE]
/// > Passing new arrays of `users` and `teams` replaces their previous values.
///
/// [GitHub API docs for update_pull_request_review_protection](https://docs.github.com/rest/branches/branch-protection#update-pull-request-review-protection)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn update_pull_request_review_protection(&self, owner: &str, repo: &str, branch: &str, body: PatchReposUpdatePullRequestReviewProtection) -> Result<ProtectedBranchPullRequestReview, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_pull_request_reviews", super::GITHUB_BASE_API_URL, owner, repo, branch);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchReposUpdatePullRequestReviewProtection>(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(ReposUpdatePullRequestReviewProtectionError::Status422(github_response.to_json()?).into()),
code => Err(ReposUpdatePullRequestReviewProtectionError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update a release
///
/// Users with push access to the repository can edit a release.
///
/// [GitHub API docs for update_release](https://docs.github.com/rest/releases/releases#update-a-release)
///
/// ---
pub async fn update_release_async(&self, owner: &str, repo: &str, release_id: i32, body: PatchReposUpdateRelease) -> Result<Release, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/releases/{}", super::GITHUB_BASE_API_URL, owner, repo, release_id);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchReposUpdateRelease>(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() {
404 => Err(ReposUpdateReleaseError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposUpdateReleaseError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update a release
///
/// Users with push access to the repository can edit a release.
///
/// [GitHub API docs for update_release](https://docs.github.com/rest/releases/releases#update-a-release)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn update_release(&self, owner: &str, repo: &str, release_id: i32, body: PatchReposUpdateRelease) -> Result<Release, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/releases/{}", super::GITHUB_BASE_API_URL, owner, repo, release_id);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchReposUpdateRelease>(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() {
404 => Err(ReposUpdateReleaseError::Status404(github_response.to_json()?).into()),
code => Err(ReposUpdateReleaseError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update a release asset
///
/// Users with push access to the repository can edit a release asset.
///
/// [GitHub API docs for update_release_asset](https://docs.github.com/rest/releases/assets#update-a-release-asset)
///
/// ---
pub async fn update_release_asset_async(&self, owner: &str, repo: &str, asset_id: i32, body: PatchReposUpdateReleaseAsset) -> Result<ReleaseAsset, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/releases/assets/{}", super::GITHUB_BASE_API_URL, owner, repo, asset_id);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchReposUpdateReleaseAsset>(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(ReposUpdateReleaseAssetError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update a release asset
///
/// Users with push access to the repository can edit a release asset.
///
/// [GitHub API docs for update_release_asset](https://docs.github.com/rest/releases/assets#update-a-release-asset)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn update_release_asset(&self, owner: &str, repo: &str, asset_id: i32, body: PatchReposUpdateReleaseAsset) -> Result<ReleaseAsset, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/releases/assets/{}", super::GITHUB_BASE_API_URL, owner, repo, asset_id);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchReposUpdateReleaseAsset>(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(ReposUpdateReleaseAssetError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update a repository ruleset
///
/// Update a ruleset for a repository.
///
/// [GitHub API docs for update_repo_ruleset](https://docs.github.com/rest/repos/rules#update-a-repository-ruleset)
///
/// ---
pub async fn update_repo_ruleset_async(&self, owner: &str, repo: &str, ruleset_id: i32, body: PutReposUpdateRepoRuleset) -> Result<RepositoryRuleset, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/rulesets/{}", super::GITHUB_BASE_API_URL, owner, repo, ruleset_id);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutReposUpdateRepoRuleset>(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(ReposUpdateRepoRulesetError::Status404(github_response.to_json_async().await?).into()),
500 => Err(ReposUpdateRepoRulesetError::Status500(github_response.to_json_async().await?).into()),
code => Err(ReposUpdateRepoRulesetError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update a repository ruleset
///
/// Update a ruleset for a repository.
///
/// [GitHub API docs for update_repo_ruleset](https://docs.github.com/rest/repos/rules#update-a-repository-ruleset)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn update_repo_ruleset(&self, owner: &str, repo: &str, ruleset_id: i32, body: PutReposUpdateRepoRuleset) -> Result<RepositoryRuleset, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/rulesets/{}", super::GITHUB_BASE_API_URL, owner, repo, ruleset_id);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutReposUpdateRepoRuleset>(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(ReposUpdateRepoRulesetError::Status404(github_response.to_json()?).into()),
500 => Err(ReposUpdateRepoRulesetError::Status500(github_response.to_json()?).into()),
code => Err(ReposUpdateRepoRulesetError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update status check protection
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// Updating required status checks requires admin or owner permissions to the repository and branch protection to be enabled.
///
/// [GitHub API docs for update_status_check_protection](https://docs.github.com/rest/branches/branch-protection#update-status-check-protection)
///
/// ---
pub async fn update_status_check_protection_async(&self, owner: &str, repo: &str, branch: &str, body: PatchReposUpdateStatusCheckProtection) -> Result<StatusCheckPolicy, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_status_checks", super::GITHUB_BASE_API_URL, owner, repo, branch);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchReposUpdateStatusCheckProtection>(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() {
404 => Err(ReposUpdateStatusCheckProtectionError::Status404(github_response.to_json_async().await?).into()),
422 => Err(ReposUpdateStatusCheckProtectionError::Status422(github_response.to_json_async().await?).into()),
code => Err(ReposUpdateStatusCheckProtectionError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update status check protection
///
/// Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// Updating required status checks requires admin or owner permissions to the repository and branch protection to be enabled.
///
/// [GitHub API docs for update_status_check_protection](https://docs.github.com/rest/branches/branch-protection#update-status-check-protection)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn update_status_check_protection(&self, owner: &str, repo: &str, branch: &str, body: PatchReposUpdateStatusCheckProtection) -> Result<StatusCheckPolicy, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_status_checks", super::GITHUB_BASE_API_URL, owner, repo, branch);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchReposUpdateStatusCheckProtection>(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() {
404 => Err(ReposUpdateStatusCheckProtectionError::Status404(github_response.to_json()?).into()),
422 => Err(ReposUpdateStatusCheckProtectionError::Status422(github_response.to_json()?).into()),
code => Err(ReposUpdateStatusCheckProtectionError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update a repository webhook
///
/// Updates a webhook configured in a repository. 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 a repository](/rest/webhooks/repo-config#update-a-webhook-configuration-for-a-repository)."
///
/// [GitHub API docs for update_webhook](https://docs.github.com/rest/repos/webhooks#update-a-repository-webhook)
///
/// ---
pub async fn update_webhook_async(&self, owner: &str, repo: &str, hook_id: i32, body: PatchReposUpdateWebhook) -> Result<Hook, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/hooks/{}", super::GITHUB_BASE_API_URL, owner, repo, hook_id);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchReposUpdateWebhook>(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(ReposUpdateWebhookError::Status422(github_response.to_json_async().await?).into()),
404 => Err(ReposUpdateWebhookError::Status404(github_response.to_json_async().await?).into()),
code => Err(ReposUpdateWebhookError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update a repository webhook
///
/// Updates a webhook configured in a repository. 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 a repository](/rest/webhooks/repo-config#update-a-webhook-configuration-for-a-repository)."
///
/// [GitHub API docs for update_webhook](https://docs.github.com/rest/repos/webhooks#update-a-repository-webhook)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn update_webhook(&self, owner: &str, repo: &str, hook_id: i32, body: PatchReposUpdateWebhook) -> Result<Hook, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/hooks/{}", super::GITHUB_BASE_API_URL, owner, repo, hook_id);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchReposUpdateWebhook>(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(ReposUpdateWebhookError::Status422(github_response.to_json()?).into()),
404 => Err(ReposUpdateWebhookError::Status404(github_response.to_json()?).into()),
code => Err(ReposUpdateWebhookError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update a webhook configuration for a repository
///
/// Updates the webhook configuration for a repository. To update more information about the webhook, including the `active` state and `events`, use "[Update a repository webhook](/rest/webhooks/repos#update-a-repository-webhook)."
///
/// OAuth app tokens and personal access tokens (classic) need the `write:repo_hook` or `repo` scope to use this endpoint.
///
/// [GitHub API docs for update_webhook_config_for_repo](https://docs.github.com/rest/repos/webhooks#update-a-webhook-configuration-for-a-repository)
///
/// ---
pub async fn update_webhook_config_for_repo_async(&self, owner: &str, repo: &str, hook_id: i32, body: PatchReposUpdateWebhookConfigForRepo) -> Result<WebhookConfig, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/hooks/{}/config", super::GITHUB_BASE_API_URL, owner, repo, hook_id);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchReposUpdateWebhookConfigForRepo>(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(ReposUpdateWebhookConfigForRepoError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update a webhook configuration for a repository
///
/// Updates the webhook configuration for a repository. To update more information about the webhook, including the `active` state and `events`, use "[Update a repository webhook](/rest/webhooks/repos#update-a-repository-webhook)."
///
/// OAuth app tokens and personal access tokens (classic) need the `write:repo_hook` or `repo` scope to use this endpoint.
///
/// [GitHub API docs for update_webhook_config_for_repo](https://docs.github.com/rest/repos/webhooks#update-a-webhook-configuration-for-a-repository)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn update_webhook_config_for_repo(&self, owner: &str, repo: &str, hook_id: i32, body: PatchReposUpdateWebhookConfigForRepo) -> Result<WebhookConfig, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/hooks/{}/config", super::GITHUB_BASE_API_URL, owner, repo, hook_id);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchReposUpdateWebhookConfigForRepo>(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(ReposUpdateWebhookConfigForRepoError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Upload a release asset
///
/// This endpoint makes use of a [Hypermedia relation](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#hypermedia) to determine which URL to access. The endpoint you call to upload release assets is specific to your release. Use the `upload_url` returned in
/// the response of the [Create a release endpoint](https://docs.github.com/rest/releases/releases#create-a-release) to upload a release asset.
///
/// You need to use an HTTP client which supports [SNI](http://en.wikipedia.org/wiki/Server_Name_Indication) to make calls to this endpoint.
///
/// Most libraries will set the required `Content-Length` header automatically. Use the required `Content-Type` header to provide the media type of the asset. For a list of media types, see [Media Types](https://www.iana.org/assignments/media-types/media-types.xhtml). For example:
///
/// `application/zip`
///
/// GitHub expects the asset data in its raw binary form, rather than JSON. You will send the raw binary content of the asset as the request body. Everything else about the endpoint is the same as the rest of the API. For example,
/// you'll still need to pass your authentication to be able to upload an asset.
///
/// When an upstream failure occurs, you will receive a `502 Bad Gateway` status. This may leave an empty asset with a state of `starter`. It can be safely deleted.
///
/// **Notes:**
/// * GitHub renames asset filenames that have special characters, non-alphanumeric characters, and leading or trailing periods. The "[List release assets](https://docs.github.com/rest/releases/assets#list-release-assets)"
/// endpoint lists the renamed filenames. For more information and help, contact [GitHub Support](https://support.github.com/contact?tags=dotcom-rest-api).
/// * To find the `release_id` query the [`GET /repos/{owner}/{repo}/releases/latest` endpoint](https://docs.github.com/rest/releases/releases#get-the-latest-release).
/// * If you upload an asset with the same filename as another uploaded asset, you'll receive an error and must delete the old file before you can re-upload the new asset.
///
/// [GitHub API docs for upload_release_asset](https://docs.github.com/rest/releases/assets#upload-a-release-asset)
///
/// ---
pub async fn upload_release_asset_async(&self, owner: &str, repo: &str, release_id: i32, query_params: impl Into<ReposUploadReleaseAssetParams<'api>>, body: std::vec::Vec<u8>) -> Result<ReleaseAsset, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/releases/{}/assets", super::GITHUB_BASE_API_URL, owner, repo, release_id);
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(query_params.into())?);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<Vec<u8>>(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(ReposUploadReleaseAssetError::Status422.into()),
code => Err(ReposUploadReleaseAssetError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Upload a release asset
///
/// This endpoint makes use of a [Hypermedia relation](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#hypermedia) to determine which URL to access. The endpoint you call to upload release assets is specific to your release. Use the `upload_url` returned in
/// the response of the [Create a release endpoint](https://docs.github.com/rest/releases/releases#create-a-release) to upload a release asset.
///
/// You need to use an HTTP client which supports [SNI](http://en.wikipedia.org/wiki/Server_Name_Indication) to make calls to this endpoint.
///
/// Most libraries will set the required `Content-Length` header automatically. Use the required `Content-Type` header to provide the media type of the asset. For a list of media types, see [Media Types](https://www.iana.org/assignments/media-types/media-types.xhtml). For example:
///
/// `application/zip`
///
/// GitHub expects the asset data in its raw binary form, rather than JSON. You will send the raw binary content of the asset as the request body. Everything else about the endpoint is the same as the rest of the API. For example,
/// you'll still need to pass your authentication to be able to upload an asset.
///
/// When an upstream failure occurs, you will receive a `502 Bad Gateway` status. This may leave an empty asset with a state of `starter`. It can be safely deleted.
///
/// **Notes:**
/// * GitHub renames asset filenames that have special characters, non-alphanumeric characters, and leading or trailing periods. The "[List release assets](https://docs.github.com/rest/releases/assets#list-release-assets)"
/// endpoint lists the renamed filenames. For more information and help, contact [GitHub Support](https://support.github.com/contact?tags=dotcom-rest-api).
/// * To find the `release_id` query the [`GET /repos/{owner}/{repo}/releases/latest` endpoint](https://docs.github.com/rest/releases/releases#get-the-latest-release).
/// * If you upload an asset with the same filename as another uploaded asset, you'll receive an error and must delete the old file before you can re-upload the new asset.
///
/// [GitHub API docs for upload_release_asset](https://docs.github.com/rest/releases/assets#upload-a-release-asset)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn upload_release_asset(&self, owner: &str, repo: &str, release_id: i32, query_params: impl Into<ReposUploadReleaseAssetParams<'api>>, body: std::vec::Vec<u8>) -> Result<ReleaseAsset, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/releases/{}/assets", super::GITHUB_BASE_API_URL, owner, repo, release_id);
request_uri.push_str("?");
let qp: ReposUploadReleaseAssetParams = query_params.into();
request_uri.push_str(&serde_urlencoded::to_string(qp)?);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<Vec<u8>>(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(ReposUploadReleaseAssetError::Status422.into()),
code => Err(ReposUploadReleaseAssetError::Generic { code }.into()),
}
}
}
}