//! Method, error and parameter types for the Packages 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 Packages<'api, C: Client> where AdapterError: From<<C as Client>::Err> {
client: &'api C
}
pub fn new<C: Client>(client: &C) -> Packages<C> where AdapterError: From<<C as Client>::Err> {
Packages { client }
}
/// Errors for the [Delete a package for the authenticated user](Packages::delete_package_for_authenticated_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PackagesDeletePackageForAuthenticatedUserError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PackagesDeletePackageForAuthenticatedUserError> for AdapterError {
fn from(err: PackagesDeletePackageForAuthenticatedUserError) -> Self {
let (description, status_code) = match err {
PackagesDeletePackageForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404),
PackagesDeletePackageForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403),
PackagesDeletePackageForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401),
PackagesDeletePackageForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Delete a package for an organization](Packages::delete_package_for_org_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PackagesDeletePackageForOrgError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PackagesDeletePackageForOrgError> for AdapterError {
fn from(err: PackagesDeletePackageForOrgError) -> Self {
let (description, status_code) = match err {
PackagesDeletePackageForOrgError::Status404(_) => (String::from("Resource not found"), 404),
PackagesDeletePackageForOrgError::Status403(_) => (String::from("Forbidden"), 403),
PackagesDeletePackageForOrgError::Status401(_) => (String::from("Requires authentication"), 401),
PackagesDeletePackageForOrgError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Delete a package for a user](Packages::delete_package_for_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PackagesDeletePackageForUserError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PackagesDeletePackageForUserError> for AdapterError {
fn from(err: PackagesDeletePackageForUserError) -> Self {
let (description, status_code) = match err {
PackagesDeletePackageForUserError::Status404(_) => (String::from("Resource not found"), 404),
PackagesDeletePackageForUserError::Status403(_) => (String::from("Forbidden"), 403),
PackagesDeletePackageForUserError::Status401(_) => (String::from("Requires authentication"), 401),
PackagesDeletePackageForUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Delete a package version for the authenticated user](Packages::delete_package_version_for_authenticated_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PackagesDeletePackageVersionForAuthenticatedUserError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PackagesDeletePackageVersionForAuthenticatedUserError> for AdapterError {
fn from(err: PackagesDeletePackageVersionForAuthenticatedUserError) -> Self {
let (description, status_code) = match err {
PackagesDeletePackageVersionForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404),
PackagesDeletePackageVersionForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403),
PackagesDeletePackageVersionForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401),
PackagesDeletePackageVersionForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Delete package version for an organization](Packages::delete_package_version_for_org_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PackagesDeletePackageVersionForOrgError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PackagesDeletePackageVersionForOrgError> for AdapterError {
fn from(err: PackagesDeletePackageVersionForOrgError) -> Self {
let (description, status_code) = match err {
PackagesDeletePackageVersionForOrgError::Status404(_) => (String::from("Resource not found"), 404),
PackagesDeletePackageVersionForOrgError::Status403(_) => (String::from("Forbidden"), 403),
PackagesDeletePackageVersionForOrgError::Status401(_) => (String::from("Requires authentication"), 401),
PackagesDeletePackageVersionForOrgError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Delete package version for a user](Packages::delete_package_version_for_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PackagesDeletePackageVersionForUserError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PackagesDeletePackageVersionForUserError> for AdapterError {
fn from(err: PackagesDeletePackageVersionForUserError) -> Self {
let (description, status_code) = match err {
PackagesDeletePackageVersionForUserError::Status404(_) => (String::from("Resource not found"), 404),
PackagesDeletePackageVersionForUserError::Status403(_) => (String::from("Forbidden"), 403),
PackagesDeletePackageVersionForUserError::Status401(_) => (String::from("Requires authentication"), 401),
PackagesDeletePackageVersionForUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List package versions for a package owned by the authenticated user](Packages::get_all_package_versions_for_package_owned_by_authenticated_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PackagesGetAllPackageVersionsForPackageOwnedByAuthenticatedUserError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PackagesGetAllPackageVersionsForPackageOwnedByAuthenticatedUserError> for AdapterError {
fn from(err: PackagesGetAllPackageVersionsForPackageOwnedByAuthenticatedUserError) -> Self {
let (description, status_code) = match err {
PackagesGetAllPackageVersionsForPackageOwnedByAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404),
PackagesGetAllPackageVersionsForPackageOwnedByAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403),
PackagesGetAllPackageVersionsForPackageOwnedByAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401),
PackagesGetAllPackageVersionsForPackageOwnedByAuthenticatedUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List package versions for a package owned by an organization](Packages::get_all_package_versions_for_package_owned_by_org_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PackagesGetAllPackageVersionsForPackageOwnedByOrgError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PackagesGetAllPackageVersionsForPackageOwnedByOrgError> for AdapterError {
fn from(err: PackagesGetAllPackageVersionsForPackageOwnedByOrgError) -> Self {
let (description, status_code) = match err {
PackagesGetAllPackageVersionsForPackageOwnedByOrgError::Status404(_) => (String::from("Resource not found"), 404),
PackagesGetAllPackageVersionsForPackageOwnedByOrgError::Status403(_) => (String::from("Forbidden"), 403),
PackagesGetAllPackageVersionsForPackageOwnedByOrgError::Status401(_) => (String::from("Requires authentication"), 401),
PackagesGetAllPackageVersionsForPackageOwnedByOrgError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List package versions for a package owned by a user](Packages::get_all_package_versions_for_package_owned_by_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PackagesGetAllPackageVersionsForPackageOwnedByUserError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PackagesGetAllPackageVersionsForPackageOwnedByUserError> for AdapterError {
fn from(err: PackagesGetAllPackageVersionsForPackageOwnedByUserError) -> Self {
let (description, status_code) = match err {
PackagesGetAllPackageVersionsForPackageOwnedByUserError::Status404(_) => (String::from("Resource not found"), 404),
PackagesGetAllPackageVersionsForPackageOwnedByUserError::Status403(_) => (String::from("Forbidden"), 403),
PackagesGetAllPackageVersionsForPackageOwnedByUserError::Status401(_) => (String::from("Requires authentication"), 401),
PackagesGetAllPackageVersionsForPackageOwnedByUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get a package for the authenticated user](Packages::get_package_for_authenticated_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PackagesGetPackageForAuthenticatedUserError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PackagesGetPackageForAuthenticatedUserError> for AdapterError {
fn from(err: PackagesGetPackageForAuthenticatedUserError) -> Self {
let (description, status_code) = match err {
PackagesGetPackageForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get a package for an organization](Packages::get_package_for_organization_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PackagesGetPackageForOrganizationError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PackagesGetPackageForOrganizationError> for AdapterError {
fn from(err: PackagesGetPackageForOrganizationError) -> Self {
let (description, status_code) = match err {
PackagesGetPackageForOrganizationError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get a package for a user](Packages::get_package_for_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PackagesGetPackageForUserError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PackagesGetPackageForUserError> for AdapterError {
fn from(err: PackagesGetPackageForUserError) -> Self {
let (description, status_code) = match err {
PackagesGetPackageForUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get a package version for the authenticated user](Packages::get_package_version_for_authenticated_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PackagesGetPackageVersionForAuthenticatedUserError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PackagesGetPackageVersionForAuthenticatedUserError> for AdapterError {
fn from(err: PackagesGetPackageVersionForAuthenticatedUserError) -> Self {
let (description, status_code) = match err {
PackagesGetPackageVersionForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get a package version for an organization](Packages::get_package_version_for_organization_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PackagesGetPackageVersionForOrganizationError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PackagesGetPackageVersionForOrganizationError> for AdapterError {
fn from(err: PackagesGetPackageVersionForOrganizationError) -> Self {
let (description, status_code) = match err {
PackagesGetPackageVersionForOrganizationError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get a package version for a user](Packages::get_package_version_for_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PackagesGetPackageVersionForUserError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PackagesGetPackageVersionForUserError> for AdapterError {
fn from(err: PackagesGetPackageVersionForUserError) -> Self {
let (description, status_code) = match err {
PackagesGetPackageVersionForUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get list of conflicting packages during Docker migration for authenticated-user](Packages::list_docker_migration_conflicting_packages_for_authenticated_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PackagesListDockerMigrationConflictingPackagesForAuthenticatedUserError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PackagesListDockerMigrationConflictingPackagesForAuthenticatedUserError> for AdapterError {
fn from(err: PackagesListDockerMigrationConflictingPackagesForAuthenticatedUserError) -> Self {
let (description, status_code) = match err {
PackagesListDockerMigrationConflictingPackagesForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get list of conflicting packages during Docker migration for organization](Packages::list_docker_migration_conflicting_packages_for_organization_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PackagesListDockerMigrationConflictingPackagesForOrganizationError {
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PackagesListDockerMigrationConflictingPackagesForOrganizationError> for AdapterError {
fn from(err: PackagesListDockerMigrationConflictingPackagesForOrganizationError) -> Self {
let (description, status_code) = match err {
PackagesListDockerMigrationConflictingPackagesForOrganizationError::Status403(_) => (String::from("Forbidden"), 403),
PackagesListDockerMigrationConflictingPackagesForOrganizationError::Status401(_) => (String::from("Requires authentication"), 401),
PackagesListDockerMigrationConflictingPackagesForOrganizationError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get list of conflicting packages during Docker migration for user](Packages::list_docker_migration_conflicting_packages_for_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PackagesListDockerMigrationConflictingPackagesForUserError {
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PackagesListDockerMigrationConflictingPackagesForUserError> for AdapterError {
fn from(err: PackagesListDockerMigrationConflictingPackagesForUserError) -> Self {
let (description, status_code) = match err {
PackagesListDockerMigrationConflictingPackagesForUserError::Status403(_) => (String::from("Forbidden"), 403),
PackagesListDockerMigrationConflictingPackagesForUserError::Status401(_) => (String::from("Requires authentication"), 401),
PackagesListDockerMigrationConflictingPackagesForUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List packages for the authenticated user's namespace](Packages::list_packages_for_authenticated_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PackagesListPackagesForAuthenticatedUserError {
#[error("The value of `per_page` multiplied by `page` cannot be greater than 10000.")]
Status400,
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PackagesListPackagesForAuthenticatedUserError> for AdapterError {
fn from(err: PackagesListPackagesForAuthenticatedUserError) -> Self {
let (description, status_code) = match err {
PackagesListPackagesForAuthenticatedUserError::Status400 => (String::from("The value of `per_page` multiplied by `page` cannot be greater than 10000."), 400),
PackagesListPackagesForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List packages for an organization](Packages::list_packages_for_organization_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PackagesListPackagesForOrganizationError {
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("The value of `per_page` multiplied by `page` cannot be greater than 10000.")]
Status400,
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PackagesListPackagesForOrganizationError> for AdapterError {
fn from(err: PackagesListPackagesForOrganizationError) -> Self {
let (description, status_code) = match err {
PackagesListPackagesForOrganizationError::Status403(_) => (String::from("Forbidden"), 403),
PackagesListPackagesForOrganizationError::Status401(_) => (String::from("Requires authentication"), 401),
PackagesListPackagesForOrganizationError::Status400 => (String::from("The value of `per_page` multiplied by `page` cannot be greater than 10000."), 400),
PackagesListPackagesForOrganizationError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List packages for a user](Packages::list_packages_for_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PackagesListPackagesForUserError {
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("The value of `per_page` multiplied by `page` cannot be greater than 10000.")]
Status400,
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PackagesListPackagesForUserError> for AdapterError {
fn from(err: PackagesListPackagesForUserError) -> Self {
let (description, status_code) = match err {
PackagesListPackagesForUserError::Status403(_) => (String::from("Forbidden"), 403),
PackagesListPackagesForUserError::Status401(_) => (String::from("Requires authentication"), 401),
PackagesListPackagesForUserError::Status400 => (String::from("The value of `per_page` multiplied by `page` cannot be greater than 10000."), 400),
PackagesListPackagesForUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Restore a package for the authenticated user](Packages::restore_package_for_authenticated_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PackagesRestorePackageForAuthenticatedUserError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PackagesRestorePackageForAuthenticatedUserError> for AdapterError {
fn from(err: PackagesRestorePackageForAuthenticatedUserError) -> Self {
let (description, status_code) = match err {
PackagesRestorePackageForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404),
PackagesRestorePackageForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403),
PackagesRestorePackageForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401),
PackagesRestorePackageForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Restore a package for an organization](Packages::restore_package_for_org_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PackagesRestorePackageForOrgError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PackagesRestorePackageForOrgError> for AdapterError {
fn from(err: PackagesRestorePackageForOrgError) -> Self {
let (description, status_code) = match err {
PackagesRestorePackageForOrgError::Status404(_) => (String::from("Resource not found"), 404),
PackagesRestorePackageForOrgError::Status403(_) => (String::from("Forbidden"), 403),
PackagesRestorePackageForOrgError::Status401(_) => (String::from("Requires authentication"), 401),
PackagesRestorePackageForOrgError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Restore a package for a user](Packages::restore_package_for_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PackagesRestorePackageForUserError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PackagesRestorePackageForUserError> for AdapterError {
fn from(err: PackagesRestorePackageForUserError) -> Self {
let (description, status_code) = match err {
PackagesRestorePackageForUserError::Status404(_) => (String::from("Resource not found"), 404),
PackagesRestorePackageForUserError::Status403(_) => (String::from("Forbidden"), 403),
PackagesRestorePackageForUserError::Status401(_) => (String::from("Requires authentication"), 401),
PackagesRestorePackageForUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Restore a package version for the authenticated user](Packages::restore_package_version_for_authenticated_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PackagesRestorePackageVersionForAuthenticatedUserError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PackagesRestorePackageVersionForAuthenticatedUserError> for AdapterError {
fn from(err: PackagesRestorePackageVersionForAuthenticatedUserError) -> Self {
let (description, status_code) = match err {
PackagesRestorePackageVersionForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404),
PackagesRestorePackageVersionForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403),
PackagesRestorePackageVersionForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401),
PackagesRestorePackageVersionForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Restore package version for an organization](Packages::restore_package_version_for_org_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PackagesRestorePackageVersionForOrgError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PackagesRestorePackageVersionForOrgError> for AdapterError {
fn from(err: PackagesRestorePackageVersionForOrgError) -> Self {
let (description, status_code) = match err {
PackagesRestorePackageVersionForOrgError::Status404(_) => (String::from("Resource not found"), 404),
PackagesRestorePackageVersionForOrgError::Status403(_) => (String::from("Forbidden"), 403),
PackagesRestorePackageVersionForOrgError::Status401(_) => (String::from("Requires authentication"), 401),
PackagesRestorePackageVersionForOrgError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Restore package version for a user](Packages::restore_package_version_for_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PackagesRestorePackageVersionForUserError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PackagesRestorePackageVersionForUserError> for AdapterError {
fn from(err: PackagesRestorePackageVersionForUserError) -> Self {
let (description, status_code) = match err {
PackagesRestorePackageVersionForUserError::Status404(_) => (String::from("Resource not found"), 404),
PackagesRestorePackageVersionForUserError::Status403(_) => (String::from("Forbidden"), 403),
PackagesRestorePackageVersionForUserError::Status401(_) => (String::from("Requires authentication"), 401),
PackagesRestorePackageVersionForUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Query parameters for the [List package versions for a package owned by the authenticated user](Packages::get_all_package_versions_for_package_owned_by_authenticated_user_async()) endpoint.
#[derive(Default, Serialize)]
pub struct PackagesGetAllPackageVersionsForPackageOwnedByAuthenticatedUserParams<'req> {
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
page: Option<u16>,
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
per_page: Option<u16>,
/// The state of the package, either active or deleted.
state: Option<&'req str>
}
impl<'req> PackagesGetAllPackageVersionsForPackageOwnedByAuthenticatedUserParams<'req> {
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,
state: self.state,
}
}
/// 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),
state: self.state,
}
}
/// The state of the package, either active or deleted.
pub fn state(self, state: &'req str) -> Self {
Self {
page: self.page,
per_page: self.per_page,
state: Some(state),
}
}
}
impl<'enc> From<&'enc PerPage> for PackagesGetAllPackageVersionsForPackageOwnedByAuthenticatedUserParams<'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 package versions for a package owned by an organization](Packages::get_all_package_versions_for_package_owned_by_org_async()) endpoint.
#[derive(Default, Serialize)]
pub struct PackagesGetAllPackageVersionsForPackageOwnedByOrgParams<'req> {
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
page: Option<u16>,
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
per_page: Option<u16>,
/// The state of the package, either active or deleted.
state: Option<&'req str>
}
impl<'req> PackagesGetAllPackageVersionsForPackageOwnedByOrgParams<'req> {
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,
state: self.state,
}
}
/// 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),
state: self.state,
}
}
/// The state of the package, either active or deleted.
pub fn state(self, state: &'req str) -> Self {
Self {
page: self.page,
per_page: self.per_page,
state: Some(state),
}
}
}
impl<'enc> From<&'enc PerPage> for PackagesGetAllPackageVersionsForPackageOwnedByOrgParams<'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 packages for the authenticated user's namespace](Packages::list_packages_for_authenticated_user_async()) endpoint.
#[derive(Default, Serialize)]
pub struct PackagesListPackagesForAuthenticatedUserParams<'req> {
/// The type of supported package. Packages in GitHub's Gradle registry have the type `maven`. Docker images pushed to GitHub's Container registry (`ghcr.io`) have the type `container`. You can use the type `docker` to find images that were pushed to GitHub's Docker registry (`docker.pkg.github.com`), even if these have now been migrated to the Container registry.
package_type: &'req str,
/// The selected visibility of the packages. This parameter is optional and only filters an existing result set. The `internal` visibility is only supported for GitHub Packages registries that allow for granular permissions. For other ecosystems `internal` is synonymous with `private`. For the list of GitHub Packages registries that support granular permissions, see \"[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#granular-permissions-for-userorganization-scoped-packages).\"
visibility: Option<&'req str>,
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
page: Option<u16>,
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
per_page: Option<u16>
}
impl<'req> PackagesListPackagesForAuthenticatedUserParams<'req> {
pub fn new() -> Self {
Self::default()
}
/// The type of supported package. Packages in GitHub's Gradle registry have the type `maven`. Docker images pushed to GitHub's Container registry (`ghcr.io`) have the type `container`. You can use the type `docker` to find images that were pushed to GitHub's Docker registry (`docker.pkg.github.com`), even if these have now been migrated to the Container registry.
pub fn package_type(self, package_type: &'req str) -> Self {
Self {
package_type: package_type,
visibility: self.visibility,
page: self.page,
per_page: self.per_page,
}
}
/// The selected visibility of the packages. This parameter is optional and only filters an existing result set. The `internal` visibility is only supported for GitHub Packages registries that allow for granular permissions. For other ecosystems `internal` is synonymous with `private`. For the list of GitHub Packages registries that support granular permissions, see \"[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#granular-permissions-for-userorganization-scoped-packages).\"
pub fn visibility(self, visibility: &'req str) -> Self {
Self {
package_type: self.package_type,
visibility: Some(visibility),
page: self.page,
per_page: self.per_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 {
package_type: self.package_type,
visibility: self.visibility,
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 {
package_type: self.package_type,
visibility: self.visibility,
page: self.page,
per_page: Some(per_page),
}
}
}
impl<'enc> From<&'enc PerPage> for PackagesListPackagesForAuthenticatedUserParams<'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 packages for an organization](Packages::list_packages_for_organization_async()) endpoint.
#[derive(Default, Serialize)]
pub struct PackagesListPackagesForOrganizationParams<'req> {
/// The type of supported package. Packages in GitHub's Gradle registry have the type `maven`. Docker images pushed to GitHub's Container registry (`ghcr.io`) have the type `container`. You can use the type `docker` to find images that were pushed to GitHub's Docker registry (`docker.pkg.github.com`), even if these have now been migrated to the Container registry.
package_type: &'req str,
/// The selected visibility of the packages. This parameter is optional and only filters an existing result set. The `internal` visibility is only supported for GitHub Packages registries that allow for granular permissions. For other ecosystems `internal` is synonymous with `private`. For the list of GitHub Packages registries that support granular permissions, see \"[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#granular-permissions-for-userorganization-scoped-packages).\"
visibility: Option<&'req str>,
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
page: Option<u16>,
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
per_page: Option<u16>
}
impl<'req> PackagesListPackagesForOrganizationParams<'req> {
pub fn new() -> Self {
Self::default()
}
/// The type of supported package. Packages in GitHub's Gradle registry have the type `maven`. Docker images pushed to GitHub's Container registry (`ghcr.io`) have the type `container`. You can use the type `docker` to find images that were pushed to GitHub's Docker registry (`docker.pkg.github.com`), even if these have now been migrated to the Container registry.
pub fn package_type(self, package_type: &'req str) -> Self {
Self {
package_type: package_type,
visibility: self.visibility,
page: self.page,
per_page: self.per_page,
}
}
/// The selected visibility of the packages. This parameter is optional and only filters an existing result set. The `internal` visibility is only supported for GitHub Packages registries that allow for granular permissions. For other ecosystems `internal` is synonymous with `private`. For the list of GitHub Packages registries that support granular permissions, see \"[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#granular-permissions-for-userorganization-scoped-packages).\"
pub fn visibility(self, visibility: &'req str) -> Self {
Self {
package_type: self.package_type,
visibility: Some(visibility),
page: self.page,
per_page: self.per_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 {
package_type: self.package_type,
visibility: self.visibility,
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 {
package_type: self.package_type,
visibility: self.visibility,
page: self.page,
per_page: Some(per_page),
}
}
}
impl<'enc> From<&'enc PerPage> for PackagesListPackagesForOrganizationParams<'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 packages for a user](Packages::list_packages_for_user_async()) endpoint.
#[derive(Default, Serialize)]
pub struct PackagesListPackagesForUserParams<'req> {
/// The type of supported package. Packages in GitHub's Gradle registry have the type `maven`. Docker images pushed to GitHub's Container registry (`ghcr.io`) have the type `container`. You can use the type `docker` to find images that were pushed to GitHub's Docker registry (`docker.pkg.github.com`), even if these have now been migrated to the Container registry.
package_type: &'req str,
/// The selected visibility of the packages. This parameter is optional and only filters an existing result set. The `internal` visibility is only supported for GitHub Packages registries that allow for granular permissions. For other ecosystems `internal` is synonymous with `private`. For the list of GitHub Packages registries that support granular permissions, see \"[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#granular-permissions-for-userorganization-scoped-packages).\"
visibility: Option<&'req str>,
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
page: Option<u16>,
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
per_page: Option<u16>
}
impl<'req> PackagesListPackagesForUserParams<'req> {
pub fn new() -> Self {
Self::default()
}
/// The type of supported package. Packages in GitHub's Gradle registry have the type `maven`. Docker images pushed to GitHub's Container registry (`ghcr.io`) have the type `container`. You can use the type `docker` to find images that were pushed to GitHub's Docker registry (`docker.pkg.github.com`), even if these have now been migrated to the Container registry.
pub fn package_type(self, package_type: &'req str) -> Self {
Self {
package_type: package_type,
visibility: self.visibility,
page: self.page,
per_page: self.per_page,
}
}
/// The selected visibility of the packages. This parameter is optional and only filters an existing result set. The `internal` visibility is only supported for GitHub Packages registries that allow for granular permissions. For other ecosystems `internal` is synonymous with `private`. For the list of GitHub Packages registries that support granular permissions, see \"[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#granular-permissions-for-userorganization-scoped-packages).\"
pub fn visibility(self, visibility: &'req str) -> Self {
Self {
package_type: self.package_type,
visibility: Some(visibility),
page: self.page,
per_page: self.per_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 {
package_type: self.package_type,
visibility: self.visibility,
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 {
package_type: self.package_type,
visibility: self.visibility,
page: self.page,
per_page: Some(per_page),
}
}
}
impl<'enc> From<&'enc PerPage> for PackagesListPackagesForUserParams<'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 [Restore a package for the authenticated user](Packages::restore_package_for_authenticated_user_async()) endpoint.
#[derive(Default, Serialize)]
pub struct PackagesRestorePackageForAuthenticatedUserParams<'req> {
/// package token
token: Option<&'req str>
}
impl<'req> PackagesRestorePackageForAuthenticatedUserParams<'req> {
pub fn new() -> Self {
Self::default()
}
/// package token
pub fn token(self, token: &'req str) -> Self {
Self {
token: Some(token),
}
}
}
/// Query parameters for the [Restore a package for an organization](Packages::restore_package_for_org_async()) endpoint.
#[derive(Default, Serialize)]
pub struct PackagesRestorePackageForOrgParams<'req> {
/// package token
token: Option<&'req str>
}
impl<'req> PackagesRestorePackageForOrgParams<'req> {
pub fn new() -> Self {
Self::default()
}
/// package token
pub fn token(self, token: &'req str) -> Self {
Self {
token: Some(token),
}
}
}
/// Query parameters for the [Restore a package for a user](Packages::restore_package_for_user_async()) endpoint.
#[derive(Default, Serialize)]
pub struct PackagesRestorePackageForUserParams<'req> {
/// package token
token: Option<&'req str>
}
impl<'req> PackagesRestorePackageForUserParams<'req> {
pub fn new() -> Self {
Self::default()
}
/// package token
pub fn token(self, token: &'req str) -> Self {
Self {
token: Some(token),
}
}
}
impl<'api, C: Client> Packages<'api, C> where AdapterError: From<<C as Client>::Err> {
/// ---
///
/// # Delete a package for the authenticated user
///
/// Deletes a package owned by the authenticated user. You cannot delete a public package if any version of the package has more than 5,000 downloads. In this scenario, contact GitHub support for further assistance.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` and `delete:packages` scopes to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)."
///
/// [GitHub API docs for delete_package_for_authenticated_user](https://docs.github.com/rest/packages/packages#delete-a-package-for-the-authenticated-user)
///
/// ---
pub async fn delete_package_for_authenticated_user_async(&self, package_type: &str, package_name: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/user/packages/{}/{}", super::GITHUB_BASE_API_URL, package_type, package_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() {
404 => Err(PackagesDeletePackageForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()),
403 => Err(PackagesDeletePackageForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()),
401 => Err(PackagesDeletePackageForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()),
code => Err(PackagesDeletePackageForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a package for the authenticated user
///
/// Deletes a package owned by the authenticated user. You cannot delete a public package if any version of the package has more than 5,000 downloads. In this scenario, contact GitHub support for further assistance.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` and `delete:packages` scopes to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)."
///
/// [GitHub API docs for delete_package_for_authenticated_user](https://docs.github.com/rest/packages/packages#delete-a-package-for-the-authenticated-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete_package_for_authenticated_user(&self, package_type: &str, package_name: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/user/packages/{}/{}", super::GITHUB_BASE_API_URL, package_type, package_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() {
404 => Err(PackagesDeletePackageForAuthenticatedUserError::Status404(github_response.to_json()?).into()),
403 => Err(PackagesDeletePackageForAuthenticatedUserError::Status403(github_response.to_json()?).into()),
401 => Err(PackagesDeletePackageForAuthenticatedUserError::Status401(github_response.to_json()?).into()),
code => Err(PackagesDeletePackageForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a package for an organization
///
/// Deletes an entire package in an organization. You cannot delete a public package if any version of the package has more than 5,000 downloads. In this scenario, contact GitHub support for further assistance.
///
/// The authenticated user must have admin permissions in the organization to use this endpoint. If the `package_type` belongs to a GitHub Packages registry that supports granular permissions, the authenticated user must also have admin permissions to the package. For the list of these registries, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#granular-permissions-for-userorganization-scoped-packages)."
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` and `delete:packages` scopes to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)."
///
/// [GitHub API docs for delete_package_for_org](https://docs.github.com/rest/packages/packages#delete-a-package-for-an-organization)
///
/// ---
pub async fn delete_package_for_org_async(&self, package_type: &str, package_name: &str, org: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/packages/{}/{}", super::GITHUB_BASE_API_URL, package_type, package_name, org);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
404 => Err(PackagesDeletePackageForOrgError::Status404(github_response.to_json_async().await?).into()),
403 => Err(PackagesDeletePackageForOrgError::Status403(github_response.to_json_async().await?).into()),
401 => Err(PackagesDeletePackageForOrgError::Status401(github_response.to_json_async().await?).into()),
code => Err(PackagesDeletePackageForOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a package for an organization
///
/// Deletes an entire package in an organization. You cannot delete a public package if any version of the package has more than 5,000 downloads. In this scenario, contact GitHub support for further assistance.
///
/// The authenticated user must have admin permissions in the organization to use this endpoint. If the `package_type` belongs to a GitHub Packages registry that supports granular permissions, the authenticated user must also have admin permissions to the package. For the list of these registries, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#granular-permissions-for-userorganization-scoped-packages)."
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` and `delete:packages` scopes to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)."
///
/// [GitHub API docs for delete_package_for_org](https://docs.github.com/rest/packages/packages#delete-a-package-for-an-organization)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete_package_for_org(&self, package_type: &str, package_name: &str, org: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/packages/{}/{}", super::GITHUB_BASE_API_URL, package_type, package_name, org);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
404 => Err(PackagesDeletePackageForOrgError::Status404(github_response.to_json()?).into()),
403 => Err(PackagesDeletePackageForOrgError::Status403(github_response.to_json()?).into()),
401 => Err(PackagesDeletePackageForOrgError::Status401(github_response.to_json()?).into()),
code => Err(PackagesDeletePackageForOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a package for a user
///
/// Deletes an entire package for a user. You cannot delete a public package if any version of the package has more than 5,000 downloads. In this scenario, contact GitHub support for further assistance.
///
/// If the `package_type` belongs to a GitHub Packages registry that supports granular permissions, the authenticated user must have admin permissions to the package. For the list of these registries, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#granular-permissions-for-userorganization-scoped-packages)."
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` and `delete:packages` scopes to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)."
///
/// [GitHub API docs for delete_package_for_user](https://docs.github.com/rest/packages/packages#delete-a-package-for-a-user)
///
/// ---
pub async fn delete_package_for_user_async(&self, package_type: &str, package_name: &str, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/users/{}/packages/{}/{}", super::GITHUB_BASE_API_URL, package_type, package_name, username);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
404 => Err(PackagesDeletePackageForUserError::Status404(github_response.to_json_async().await?).into()),
403 => Err(PackagesDeletePackageForUserError::Status403(github_response.to_json_async().await?).into()),
401 => Err(PackagesDeletePackageForUserError::Status401(github_response.to_json_async().await?).into()),
code => Err(PackagesDeletePackageForUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a package for a user
///
/// Deletes an entire package for a user. You cannot delete a public package if any version of the package has more than 5,000 downloads. In this scenario, contact GitHub support for further assistance.
///
/// If the `package_type` belongs to a GitHub Packages registry that supports granular permissions, the authenticated user must have admin permissions to the package. For the list of these registries, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#granular-permissions-for-userorganization-scoped-packages)."
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` and `delete:packages` scopes to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)."
///
/// [GitHub API docs for delete_package_for_user](https://docs.github.com/rest/packages/packages#delete-a-package-for-a-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete_package_for_user(&self, package_type: &str, package_name: &str, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/users/{}/packages/{}/{}", super::GITHUB_BASE_API_URL, package_type, package_name, username);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
404 => Err(PackagesDeletePackageForUserError::Status404(github_response.to_json()?).into()),
403 => Err(PackagesDeletePackageForUserError::Status403(github_response.to_json()?).into()),
401 => Err(PackagesDeletePackageForUserError::Status401(github_response.to_json()?).into()),
code => Err(PackagesDeletePackageForUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a package version for the authenticated user
///
/// Deletes a specific package version for a package owned by the authenticated user. If the package is public and the package version has more than 5,000 downloads, you cannot delete the package version. In this scenario, contact GitHub support for further assistance.
///
/// The authenticated user must have admin permissions in the organization to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` and `delete:packages` scopes to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)."
///
/// [GitHub API docs for delete_package_version_for_authenticated_user](https://docs.github.com/rest/packages/packages#delete-a-package-version-for-the-authenticated-user)
///
/// ---
pub async fn delete_package_version_for_authenticated_user_async(&self, package_type: &str, package_name: &str, package_version_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/user/packages/{}/{}/versions/{}", super::GITHUB_BASE_API_URL, package_type, package_name, package_version_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(PackagesDeletePackageVersionForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()),
403 => Err(PackagesDeletePackageVersionForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()),
401 => Err(PackagesDeletePackageVersionForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()),
code => Err(PackagesDeletePackageVersionForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a package version for the authenticated user
///
/// Deletes a specific package version for a package owned by the authenticated user. If the package is public and the package version has more than 5,000 downloads, you cannot delete the package version. In this scenario, contact GitHub support for further assistance.
///
/// The authenticated user must have admin permissions in the organization to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` and `delete:packages` scopes to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)."
///
/// [GitHub API docs for delete_package_version_for_authenticated_user](https://docs.github.com/rest/packages/packages#delete-a-package-version-for-the-authenticated-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete_package_version_for_authenticated_user(&self, package_type: &str, package_name: &str, package_version_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/user/packages/{}/{}/versions/{}", super::GITHUB_BASE_API_URL, package_type, package_name, package_version_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(PackagesDeletePackageVersionForAuthenticatedUserError::Status404(github_response.to_json()?).into()),
403 => Err(PackagesDeletePackageVersionForAuthenticatedUserError::Status403(github_response.to_json()?).into()),
401 => Err(PackagesDeletePackageVersionForAuthenticatedUserError::Status401(github_response.to_json()?).into()),
code => Err(PackagesDeletePackageVersionForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete package version for an organization
///
/// Deletes a specific package version in an organization. If the package is public and the package version has more than 5,000 downloads, you cannot delete the package version. In this scenario, contact GitHub support for further assistance.
///
/// The authenticated user must have admin permissions in the organization to use this endpoint. If the `package_type` belongs to a GitHub Packages registry that supports granular permissions, the authenticated user must also have admin permissions to the package. For the list of these registries, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#granular-permissions-for-userorganization-scoped-packages)."
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` and `delete:packages` scopes to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)."
///
/// [GitHub API docs for delete_package_version_for_org](https://docs.github.com/rest/packages/packages#delete-package-version-for-an-organization)
///
/// ---
pub async fn delete_package_version_for_org_async(&self, package_type: &str, package_name: &str, org: &str, package_version_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/packages/{}/{}/versions/{}", super::GITHUB_BASE_API_URL, package_type, package_name, org, package_version_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(PackagesDeletePackageVersionForOrgError::Status404(github_response.to_json_async().await?).into()),
403 => Err(PackagesDeletePackageVersionForOrgError::Status403(github_response.to_json_async().await?).into()),
401 => Err(PackagesDeletePackageVersionForOrgError::Status401(github_response.to_json_async().await?).into()),
code => Err(PackagesDeletePackageVersionForOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete package version for an organization
///
/// Deletes a specific package version in an organization. If the package is public and the package version has more than 5,000 downloads, you cannot delete the package version. In this scenario, contact GitHub support for further assistance.
///
/// The authenticated user must have admin permissions in the organization to use this endpoint. If the `package_type` belongs to a GitHub Packages registry that supports granular permissions, the authenticated user must also have admin permissions to the package. For the list of these registries, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#granular-permissions-for-userorganization-scoped-packages)."
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` and `delete:packages` scopes to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)."
///
/// [GitHub API docs for delete_package_version_for_org](https://docs.github.com/rest/packages/packages#delete-package-version-for-an-organization)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete_package_version_for_org(&self, package_type: &str, package_name: &str, org: &str, package_version_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/packages/{}/{}/versions/{}", super::GITHUB_BASE_API_URL, package_type, package_name, org, package_version_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(PackagesDeletePackageVersionForOrgError::Status404(github_response.to_json()?).into()),
403 => Err(PackagesDeletePackageVersionForOrgError::Status403(github_response.to_json()?).into()),
401 => Err(PackagesDeletePackageVersionForOrgError::Status401(github_response.to_json()?).into()),
code => Err(PackagesDeletePackageVersionForOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete package version for a user
///
/// Deletes a specific package version for a user. If the package is public and the package version has more than 5,000 downloads, you cannot delete the package version. In this scenario, contact GitHub support for further assistance.
///
/// If the `package_type` belongs to a GitHub Packages registry that supports granular permissions, the authenticated user must have admin permissions to the package. For the list of these registries, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#granular-permissions-for-userorganization-scoped-packages)."
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` and `delete:packages` scopes to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)."
///
/// [GitHub API docs for delete_package_version_for_user](https://docs.github.com/rest/packages/packages#delete-package-version-for-a-user)
///
/// ---
pub async fn delete_package_version_for_user_async(&self, package_type: &str, package_name: &str, username: &str, package_version_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/users/{}/packages/{}/{}/versions/{}", super::GITHUB_BASE_API_URL, package_type, package_name, username, package_version_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(PackagesDeletePackageVersionForUserError::Status404(github_response.to_json_async().await?).into()),
403 => Err(PackagesDeletePackageVersionForUserError::Status403(github_response.to_json_async().await?).into()),
401 => Err(PackagesDeletePackageVersionForUserError::Status401(github_response.to_json_async().await?).into()),
code => Err(PackagesDeletePackageVersionForUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete package version for a user
///
/// Deletes a specific package version for a user. If the package is public and the package version has more than 5,000 downloads, you cannot delete the package version. In this scenario, contact GitHub support for further assistance.
///
/// If the `package_type` belongs to a GitHub Packages registry that supports granular permissions, the authenticated user must have admin permissions to the package. For the list of these registries, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#granular-permissions-for-userorganization-scoped-packages)."
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` and `delete:packages` scopes to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)."
///
/// [GitHub API docs for delete_package_version_for_user](https://docs.github.com/rest/packages/packages#delete-package-version-for-a-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete_package_version_for_user(&self, package_type: &str, package_name: &str, username: &str, package_version_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/users/{}/packages/{}/{}/versions/{}", super::GITHUB_BASE_API_URL, package_type, package_name, username, package_version_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(PackagesDeletePackageVersionForUserError::Status404(github_response.to_json()?).into()),
403 => Err(PackagesDeletePackageVersionForUserError::Status403(github_response.to_json()?).into()),
401 => Err(PackagesDeletePackageVersionForUserError::Status401(github_response.to_json()?).into()),
code => Err(PackagesDeletePackageVersionForUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List package versions for a package owned by the authenticated user
///
/// Lists package versions for a package owned by the authenticated user.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)."
///
/// [GitHub API docs for get_all_package_versions_for_package_owned_by_authenticated_user](https://docs.github.com/rest/packages/packages#list-package-versions-for-a-package-owned-by-the-authenticated-user)
///
/// ---
pub async fn get_all_package_versions_for_package_owned_by_authenticated_user_async(&self, package_type: &str, package_name: &str, query_params: Option<impl Into<PackagesGetAllPackageVersionsForPackageOwnedByAuthenticatedUserParams<'api>>>) -> Result<Vec<PackageVersion>, AdapterError> {
let mut request_uri = format!("{}/user/packages/{}/{}/versions", super::GITHUB_BASE_API_URL, package_type, package_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() {
404 => Err(PackagesGetAllPackageVersionsForPackageOwnedByAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()),
403 => Err(PackagesGetAllPackageVersionsForPackageOwnedByAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()),
401 => Err(PackagesGetAllPackageVersionsForPackageOwnedByAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()),
code => Err(PackagesGetAllPackageVersionsForPackageOwnedByAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List package versions for a package owned by the authenticated user
///
/// Lists package versions for a package owned by the authenticated user.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)."
///
/// [GitHub API docs for get_all_package_versions_for_package_owned_by_authenticated_user](https://docs.github.com/rest/packages/packages#list-package-versions-for-a-package-owned-by-the-authenticated-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_all_package_versions_for_package_owned_by_authenticated_user(&self, package_type: &str, package_name: &str, query_params: Option<impl Into<PackagesGetAllPackageVersionsForPackageOwnedByAuthenticatedUserParams<'api>>>) -> Result<Vec<PackageVersion>, AdapterError> {
let mut request_uri = format!("{}/user/packages/{}/{}/versions", super::GITHUB_BASE_API_URL, package_type, package_name);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: PackagesGetAllPackageVersionsForPackageOwnedByAuthenticatedUserParams = 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(PackagesGetAllPackageVersionsForPackageOwnedByAuthenticatedUserError::Status404(github_response.to_json()?).into()),
403 => Err(PackagesGetAllPackageVersionsForPackageOwnedByAuthenticatedUserError::Status403(github_response.to_json()?).into()),
401 => Err(PackagesGetAllPackageVersionsForPackageOwnedByAuthenticatedUserError::Status401(github_response.to_json()?).into()),
code => Err(PackagesGetAllPackageVersionsForPackageOwnedByAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List package versions for a package owned by an organization
///
/// Lists package versions for a package owned by an organization.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)."
///
/// [GitHub API docs for get_all_package_versions_for_package_owned_by_org](https://docs.github.com/rest/packages/packages#list-package-versions-for-a-package-owned-by-an-organization)
///
/// ---
pub async fn get_all_package_versions_for_package_owned_by_org_async(&self, package_type: &str, package_name: &str, org: &str, query_params: Option<impl Into<PackagesGetAllPackageVersionsForPackageOwnedByOrgParams<'api>>>) -> Result<Vec<PackageVersion>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/packages/{}/{}/versions", super::GITHUB_BASE_API_URL, package_type, package_name, 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(PackagesGetAllPackageVersionsForPackageOwnedByOrgError::Status404(github_response.to_json_async().await?).into()),
403 => Err(PackagesGetAllPackageVersionsForPackageOwnedByOrgError::Status403(github_response.to_json_async().await?).into()),
401 => Err(PackagesGetAllPackageVersionsForPackageOwnedByOrgError::Status401(github_response.to_json_async().await?).into()),
code => Err(PackagesGetAllPackageVersionsForPackageOwnedByOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List package versions for a package owned by an organization
///
/// Lists package versions for a package owned by an organization.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)."
///
/// [GitHub API docs for get_all_package_versions_for_package_owned_by_org](https://docs.github.com/rest/packages/packages#list-package-versions-for-a-package-owned-by-an-organization)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_all_package_versions_for_package_owned_by_org(&self, package_type: &str, package_name: &str, org: &str, query_params: Option<impl Into<PackagesGetAllPackageVersionsForPackageOwnedByOrgParams<'api>>>) -> Result<Vec<PackageVersion>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/packages/{}/{}/versions", super::GITHUB_BASE_API_URL, package_type, package_name, org);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: PackagesGetAllPackageVersionsForPackageOwnedByOrgParams = 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(PackagesGetAllPackageVersionsForPackageOwnedByOrgError::Status404(github_response.to_json()?).into()),
403 => Err(PackagesGetAllPackageVersionsForPackageOwnedByOrgError::Status403(github_response.to_json()?).into()),
401 => Err(PackagesGetAllPackageVersionsForPackageOwnedByOrgError::Status401(github_response.to_json()?).into()),
code => Err(PackagesGetAllPackageVersionsForPackageOwnedByOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List package versions for a package owned by a user
///
/// Lists package versions for a public package owned by a specified user.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)."
///
/// [GitHub API docs for get_all_package_versions_for_package_owned_by_user](https://docs.github.com/rest/packages/packages#list-package-versions-for-a-package-owned-by-a-user)
///
/// ---
pub async fn get_all_package_versions_for_package_owned_by_user_async(&self, package_type: &str, package_name: &str, username: &str) -> Result<Vec<PackageVersion>, AdapterError> {
let request_uri = format!("{}/users/{}/packages/{}/{}/versions", super::GITHUB_BASE_API_URL, package_type, package_name, 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(PackagesGetAllPackageVersionsForPackageOwnedByUserError::Status404(github_response.to_json_async().await?).into()),
403 => Err(PackagesGetAllPackageVersionsForPackageOwnedByUserError::Status403(github_response.to_json_async().await?).into()),
401 => Err(PackagesGetAllPackageVersionsForPackageOwnedByUserError::Status401(github_response.to_json_async().await?).into()),
code => Err(PackagesGetAllPackageVersionsForPackageOwnedByUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List package versions for a package owned by a user
///
/// Lists package versions for a public package owned by a specified user.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)."
///
/// [GitHub API docs for get_all_package_versions_for_package_owned_by_user](https://docs.github.com/rest/packages/packages#list-package-versions-for-a-package-owned-by-a-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_all_package_versions_for_package_owned_by_user(&self, package_type: &str, package_name: &str, username: &str) -> Result<Vec<PackageVersion>, AdapterError> {
let request_uri = format!("{}/users/{}/packages/{}/{}/versions", super::GITHUB_BASE_API_URL, package_type, package_name, 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(PackagesGetAllPackageVersionsForPackageOwnedByUserError::Status404(github_response.to_json()?).into()),
403 => Err(PackagesGetAllPackageVersionsForPackageOwnedByUserError::Status403(github_response.to_json()?).into()),
401 => Err(PackagesGetAllPackageVersionsForPackageOwnedByUserError::Status401(github_response.to_json()?).into()),
code => Err(PackagesGetAllPackageVersionsForPackageOwnedByUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a package for the authenticated user
///
/// Gets a specific package for a package owned by the authenticated user.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)."
///
/// [GitHub API docs for get_package_for_authenticated_user](https://docs.github.com/rest/packages/packages#get-a-package-for-the-authenticated-user)
///
/// ---
pub async fn get_package_for_authenticated_user_async(&self, package_type: &str, package_name: &str) -> Result<Package, AdapterError> {
let request_uri = format!("{}/user/packages/{}/{}", super::GITHUB_BASE_API_URL, package_type, package_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(PackagesGetPackageForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a package for the authenticated user
///
/// Gets a specific package for a package owned by the authenticated user.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)."
///
/// [GitHub API docs for get_package_for_authenticated_user](https://docs.github.com/rest/packages/packages#get-a-package-for-the-authenticated-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_package_for_authenticated_user(&self, package_type: &str, package_name: &str) -> Result<Package, AdapterError> {
let request_uri = format!("{}/user/packages/{}/{}", super::GITHUB_BASE_API_URL, package_type, package_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(PackagesGetPackageForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a package for an organization
///
/// Gets a specific package in an organization.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)."
///
/// [GitHub API docs for get_package_for_organization](https://docs.github.com/rest/packages/packages#get-a-package-for-an-organization)
///
/// ---
pub async fn get_package_for_organization_async(&self, package_type: &str, package_name: &str, org: &str) -> Result<Package, AdapterError> {
let request_uri = format!("{}/orgs/{}/packages/{}/{}", super::GITHUB_BASE_API_URL, package_type, package_name, org);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
code => Err(PackagesGetPackageForOrganizationError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a package for an organization
///
/// Gets a specific package in an organization.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)."
///
/// [GitHub API docs for get_package_for_organization](https://docs.github.com/rest/packages/packages#get-a-package-for-an-organization)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_package_for_organization(&self, package_type: &str, package_name: &str, org: &str) -> Result<Package, AdapterError> {
let request_uri = format!("{}/orgs/{}/packages/{}/{}", super::GITHUB_BASE_API_URL, package_type, package_name, org);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
code => Err(PackagesGetPackageForOrganizationError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a package for a user
///
/// Gets a specific package metadata for a public package owned by a user.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)."
///
/// [GitHub API docs for get_package_for_user](https://docs.github.com/rest/packages/packages#get-a-package-for-a-user)
///
/// ---
pub async fn get_package_for_user_async(&self, package_type: &str, package_name: &str, username: &str) -> Result<Package, AdapterError> {
let request_uri = format!("{}/users/{}/packages/{}/{}", super::GITHUB_BASE_API_URL, package_type, package_name, 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() {
code => Err(PackagesGetPackageForUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a package for a user
///
/// Gets a specific package metadata for a public package owned by a user.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)."
///
/// [GitHub API docs for get_package_for_user](https://docs.github.com/rest/packages/packages#get-a-package-for-a-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_package_for_user(&self, package_type: &str, package_name: &str, username: &str) -> Result<Package, AdapterError> {
let request_uri = format!("{}/users/{}/packages/{}/{}", super::GITHUB_BASE_API_URL, package_type, package_name, 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() {
code => Err(PackagesGetPackageForUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a package version for the authenticated user
///
/// Gets a specific package version for a package owned by the authenticated user.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)."
///
/// [GitHub API docs for get_package_version_for_authenticated_user](https://docs.github.com/rest/packages/packages#get-a-package-version-for-the-authenticated-user)
///
/// ---
pub async fn get_package_version_for_authenticated_user_async(&self, package_type: &str, package_name: &str, package_version_id: i32) -> Result<PackageVersion, AdapterError> {
let request_uri = format!("{}/user/packages/{}/{}/versions/{}", super::GITHUB_BASE_API_URL, package_type, package_name, package_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() {
code => Err(PackagesGetPackageVersionForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a package version for the authenticated user
///
/// Gets a specific package version for a package owned by the authenticated user.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)."
///
/// [GitHub API docs for get_package_version_for_authenticated_user](https://docs.github.com/rest/packages/packages#get-a-package-version-for-the-authenticated-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_package_version_for_authenticated_user(&self, package_type: &str, package_name: &str, package_version_id: i32) -> Result<PackageVersion, AdapterError> {
let request_uri = format!("{}/user/packages/{}/{}/versions/{}", super::GITHUB_BASE_API_URL, package_type, package_name, package_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() {
code => Err(PackagesGetPackageVersionForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a package version for an organization
///
/// Gets a specific package version in an organization.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)."
///
/// [GitHub API docs for get_package_version_for_organization](https://docs.github.com/rest/packages/packages#get-a-package-version-for-an-organization)
///
/// ---
pub async fn get_package_version_for_organization_async(&self, package_type: &str, package_name: &str, org: &str, package_version_id: i32) -> Result<PackageVersion, AdapterError> {
let request_uri = format!("{}/orgs/{}/packages/{}/{}/versions/{}", super::GITHUB_BASE_API_URL, package_type, package_name, org, package_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() {
code => Err(PackagesGetPackageVersionForOrganizationError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a package version for an organization
///
/// Gets a specific package version in an organization.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)."
///
/// [GitHub API docs for get_package_version_for_organization](https://docs.github.com/rest/packages/packages#get-a-package-version-for-an-organization)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_package_version_for_organization(&self, package_type: &str, package_name: &str, org: &str, package_version_id: i32) -> Result<PackageVersion, AdapterError> {
let request_uri = format!("{}/orgs/{}/packages/{}/{}/versions/{}", super::GITHUB_BASE_API_URL, package_type, package_name, org, package_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() {
code => Err(PackagesGetPackageVersionForOrganizationError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a package version for a user
///
/// Gets a specific package version for a public package owned by a specified user.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)."
///
/// [GitHub API docs for get_package_version_for_user](https://docs.github.com/rest/packages/packages#get-a-package-version-for-a-user)
///
/// ---
pub async fn get_package_version_for_user_async(&self, package_type: &str, package_name: &str, package_version_id: i32, username: &str) -> Result<PackageVersion, AdapterError> {
let request_uri = format!("{}/users/{}/packages/{}/{}/versions/{}", super::GITHUB_BASE_API_URL, package_type, package_name, package_version_id, username);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
code => Err(PackagesGetPackageVersionForUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a package version for a user
///
/// Gets a specific package version for a public package owned by a specified user.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)."
///
/// [GitHub API docs for get_package_version_for_user](https://docs.github.com/rest/packages/packages#get-a-package-version-for-a-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_package_version_for_user(&self, package_type: &str, package_name: &str, package_version_id: i32, username: &str) -> Result<PackageVersion, AdapterError> {
let request_uri = format!("{}/users/{}/packages/{}/{}/versions/{}", super::GITHUB_BASE_API_URL, package_type, package_name, package_version_id, username);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
code => Err(PackagesGetPackageVersionForUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get list of conflicting packages during Docker migration for authenticated-user
///
/// Lists all packages that are owned by the authenticated user within the user's namespace, and that encountered a conflict during a Docker migration.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint.
///
/// [GitHub API docs for list_docker_migration_conflicting_packages_for_authenticated_user](https://docs.github.com/rest/packages/packages#get-list-of-conflicting-packages-during-docker-migration-for-authenticated-user)
///
/// ---
pub async fn list_docker_migration_conflicting_packages_for_authenticated_user_async(&self) -> Result<Vec<Package>, AdapterError> {
let request_uri = format!("{}/user/docker/conflicts", super::GITHUB_BASE_API_URL);
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(PackagesListDockerMigrationConflictingPackagesForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get list of conflicting packages during Docker migration for authenticated-user
///
/// Lists all packages that are owned by the authenticated user within the user's namespace, and that encountered a conflict during a Docker migration.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint.
///
/// [GitHub API docs for list_docker_migration_conflicting_packages_for_authenticated_user](https://docs.github.com/rest/packages/packages#get-list-of-conflicting-packages-during-docker-migration-for-authenticated-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_docker_migration_conflicting_packages_for_authenticated_user(&self) -> Result<Vec<Package>, AdapterError> {
let request_uri = format!("{}/user/docker/conflicts", super::GITHUB_BASE_API_URL);
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(PackagesListDockerMigrationConflictingPackagesForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get list of conflicting packages during Docker migration for organization
///
/// Lists all packages that are in a specific organization, are readable by the requesting user, and that encountered a conflict during a Docker migration.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint.
///
/// [GitHub API docs for list_docker_migration_conflicting_packages_for_organization](https://docs.github.com/rest/packages/packages#get-list-of-conflicting-packages-during-docker-migration-for-organization)
///
/// ---
pub async fn list_docker_migration_conflicting_packages_for_organization_async(&self, org: &str) -> Result<Vec<Package>, AdapterError> {
let request_uri = format!("{}/orgs/{}/docker/conflicts", super::GITHUB_BASE_API_URL, org);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
403 => Err(PackagesListDockerMigrationConflictingPackagesForOrganizationError::Status403(github_response.to_json_async().await?).into()),
401 => Err(PackagesListDockerMigrationConflictingPackagesForOrganizationError::Status401(github_response.to_json_async().await?).into()),
code => Err(PackagesListDockerMigrationConflictingPackagesForOrganizationError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get list of conflicting packages during Docker migration for organization
///
/// Lists all packages that are in a specific organization, are readable by the requesting user, and that encountered a conflict during a Docker migration.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint.
///
/// [GitHub API docs for list_docker_migration_conflicting_packages_for_organization](https://docs.github.com/rest/packages/packages#get-list-of-conflicting-packages-during-docker-migration-for-organization)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_docker_migration_conflicting_packages_for_organization(&self, org: &str) -> Result<Vec<Package>, AdapterError> {
let request_uri = format!("{}/orgs/{}/docker/conflicts", super::GITHUB_BASE_API_URL, org);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
403 => Err(PackagesListDockerMigrationConflictingPackagesForOrganizationError::Status403(github_response.to_json()?).into()),
401 => Err(PackagesListDockerMigrationConflictingPackagesForOrganizationError::Status401(github_response.to_json()?).into()),
code => Err(PackagesListDockerMigrationConflictingPackagesForOrganizationError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get list of conflicting packages during Docker migration for user
///
/// Lists all packages that are in a specific user's namespace, that the requesting user has access to, and that encountered a conflict during Docker migration.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint.
///
/// [GitHub API docs for list_docker_migration_conflicting_packages_for_user](https://docs.github.com/rest/packages/packages#get-list-of-conflicting-packages-during-docker-migration-for-user)
///
/// ---
pub async fn list_docker_migration_conflicting_packages_for_user_async(&self, username: &str) -> Result<Vec<Package>, AdapterError> {
let request_uri = format!("{}/users/{}/docker/conflicts", super::GITHUB_BASE_API_URL, 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() {
403 => Err(PackagesListDockerMigrationConflictingPackagesForUserError::Status403(github_response.to_json_async().await?).into()),
401 => Err(PackagesListDockerMigrationConflictingPackagesForUserError::Status401(github_response.to_json_async().await?).into()),
code => Err(PackagesListDockerMigrationConflictingPackagesForUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get list of conflicting packages during Docker migration for user
///
/// Lists all packages that are in a specific user's namespace, that the requesting user has access to, and that encountered a conflict during Docker migration.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint.
///
/// [GitHub API docs for list_docker_migration_conflicting_packages_for_user](https://docs.github.com/rest/packages/packages#get-list-of-conflicting-packages-during-docker-migration-for-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_docker_migration_conflicting_packages_for_user(&self, username: &str) -> Result<Vec<Package>, AdapterError> {
let request_uri = format!("{}/users/{}/docker/conflicts", super::GITHUB_BASE_API_URL, 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() {
403 => Err(PackagesListDockerMigrationConflictingPackagesForUserError::Status403(github_response.to_json()?).into()),
401 => Err(PackagesListDockerMigrationConflictingPackagesForUserError::Status401(github_response.to_json()?).into()),
code => Err(PackagesListDockerMigrationConflictingPackagesForUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List packages for the authenticated user's namespace
///
/// Lists packages owned by the authenticated user within the user's namespace.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)."
///
/// [GitHub API docs for list_packages_for_authenticated_user](https://docs.github.com/rest/packages/packages#list-packages-for-the-authenticated-users-namespace)
///
/// ---
pub async fn list_packages_for_authenticated_user_async(&self, query_params: impl Into<PackagesListPackagesForAuthenticatedUserParams<'api>>) -> Result<Vec<Package>, AdapterError> {
let mut request_uri = format!("{}/user/packages", super::GITHUB_BASE_API_URL);
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(query_params.into())?);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
400 => Err(PackagesListPackagesForAuthenticatedUserError::Status400.into()),
code => Err(PackagesListPackagesForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List packages for the authenticated user's namespace
///
/// Lists packages owned by the authenticated user within the user's namespace.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)."
///
/// [GitHub API docs for list_packages_for_authenticated_user](https://docs.github.com/rest/packages/packages#list-packages-for-the-authenticated-users-namespace)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_packages_for_authenticated_user(&self, query_params: impl Into<PackagesListPackagesForAuthenticatedUserParams<'api>>) -> Result<Vec<Package>, AdapterError> {
let mut request_uri = format!("{}/user/packages", super::GITHUB_BASE_API_URL);
request_uri.push_str("?");
let qp: PackagesListPackagesForAuthenticatedUserParams = query_params.into();
request_uri.push_str(&serde_urlencoded::to_string(qp)?);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
400 => Err(PackagesListPackagesForAuthenticatedUserError::Status400.into()),
code => Err(PackagesListPackagesForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List packages for an organization
///
/// Lists packages in an organization readable by the user.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)."
///
/// [GitHub API docs for list_packages_for_organization](https://docs.github.com/rest/packages/packages#list-packages-for-an-organization)
///
/// ---
pub async fn list_packages_for_organization_async(&self, org: &str, query_params: impl Into<PackagesListPackagesForOrganizationParams<'api>>) -> Result<Vec<Package>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/packages", super::GITHUB_BASE_API_URL, org);
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(query_params.into())?);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
403 => Err(PackagesListPackagesForOrganizationError::Status403(github_response.to_json_async().await?).into()),
401 => Err(PackagesListPackagesForOrganizationError::Status401(github_response.to_json_async().await?).into()),
400 => Err(PackagesListPackagesForOrganizationError::Status400.into()),
code => Err(PackagesListPackagesForOrganizationError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List packages for an organization
///
/// Lists packages in an organization readable by the user.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)."
///
/// [GitHub API docs for list_packages_for_organization](https://docs.github.com/rest/packages/packages#list-packages-for-an-organization)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_packages_for_organization(&self, org: &str, query_params: impl Into<PackagesListPackagesForOrganizationParams<'api>>) -> Result<Vec<Package>, AdapterError> {
let mut request_uri = format!("{}/orgs/{}/packages", super::GITHUB_BASE_API_URL, org);
request_uri.push_str("?");
let qp: PackagesListPackagesForOrganizationParams = query_params.into();
request_uri.push_str(&serde_urlencoded::to_string(qp)?);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
403 => Err(PackagesListPackagesForOrganizationError::Status403(github_response.to_json()?).into()),
401 => Err(PackagesListPackagesForOrganizationError::Status401(github_response.to_json()?).into()),
400 => Err(PackagesListPackagesForOrganizationError::Status400.into()),
code => Err(PackagesListPackagesForOrganizationError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List packages for a user
///
/// Lists all packages in a user's namespace for which the requesting user has access.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)."
///
/// [GitHub API docs for list_packages_for_user](https://docs.github.com/rest/packages/packages#list-packages-for-a-user)
///
/// ---
pub async fn list_packages_for_user_async(&self, username: &str, query_params: impl Into<PackagesListPackagesForUserParams<'api>>) -> Result<Vec<Package>, AdapterError> {
let mut request_uri = format!("{}/users/{}/packages", super::GITHUB_BASE_API_URL, username);
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(query_params.into())?);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
403 => Err(PackagesListPackagesForUserError::Status403(github_response.to_json_async().await?).into()),
401 => Err(PackagesListPackagesForUserError::Status401(github_response.to_json_async().await?).into()),
400 => Err(PackagesListPackagesForUserError::Status400.into()),
code => Err(PackagesListPackagesForUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List packages for a user
///
/// Lists all packages in a user's namespace for which the requesting user has access.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)."
///
/// [GitHub API docs for list_packages_for_user](https://docs.github.com/rest/packages/packages#list-packages-for-a-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_packages_for_user(&self, username: &str, query_params: impl Into<PackagesListPackagesForUserParams<'api>>) -> Result<Vec<Package>, AdapterError> {
let mut request_uri = format!("{}/users/{}/packages", super::GITHUB_BASE_API_URL, username);
request_uri.push_str("?");
let qp: PackagesListPackagesForUserParams = query_params.into();
request_uri.push_str(&serde_urlencoded::to_string(qp)?);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
403 => Err(PackagesListPackagesForUserError::Status403(github_response.to_json()?).into()),
401 => Err(PackagesListPackagesForUserError::Status401(github_response.to_json()?).into()),
400 => Err(PackagesListPackagesForUserError::Status400.into()),
code => Err(PackagesListPackagesForUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Restore a package for the authenticated user
///
/// Restores a package owned by the authenticated user.
///
/// You can restore a deleted package under the following conditions:
/// - The package was deleted within the last 30 days.
/// - The same package namespace and version is still available and not reused for a new package. If the same package namespace is not available, you will not be able to restore your package. In this scenario, to restore the deleted package, you must delete the new package that uses the deleted package's namespace first.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` and `write:packages` scopes to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)."
///
/// [GitHub API docs for restore_package_for_authenticated_user](https://docs.github.com/rest/packages/packages#restore-a-package-for-the-authenticated-user)
///
/// ---
pub async fn restore_package_for_authenticated_user_async(&self, package_type: &str, package_name: &str, query_params: Option<impl Into<PackagesRestorePackageForAuthenticatedUserParams<'api>>>) -> Result<(), AdapterError> {
let mut request_uri = format!("{}/user/packages/{}/{}/restore", super::GITHUB_BASE_API_URL, package_type, package_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: "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(PackagesRestorePackageForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()),
403 => Err(PackagesRestorePackageForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()),
401 => Err(PackagesRestorePackageForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()),
code => Err(PackagesRestorePackageForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Restore a package for the authenticated user
///
/// Restores a package owned by the authenticated user.
///
/// You can restore a deleted package under the following conditions:
/// - The package was deleted within the last 30 days.
/// - The same package namespace and version is still available and not reused for a new package. If the same package namespace is not available, you will not be able to restore your package. In this scenario, to restore the deleted package, you must delete the new package that uses the deleted package's namespace first.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` and `write:packages` scopes to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)."
///
/// [GitHub API docs for restore_package_for_authenticated_user](https://docs.github.com/rest/packages/packages#restore-a-package-for-the-authenticated-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn restore_package_for_authenticated_user(&self, package_type: &str, package_name: &str, query_params: Option<impl Into<PackagesRestorePackageForAuthenticatedUserParams<'api>>>) -> Result<(), AdapterError> {
let mut request_uri = format!("{}/user/packages/{}/{}/restore", super::GITHUB_BASE_API_URL, package_type, package_name);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: PackagesRestorePackageForAuthenticatedUserParams = params.into();
request_uri.push_str(&serde_urlencoded::to_string(qp)?);
}
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(PackagesRestorePackageForAuthenticatedUserError::Status404(github_response.to_json()?).into()),
403 => Err(PackagesRestorePackageForAuthenticatedUserError::Status403(github_response.to_json()?).into()),
401 => Err(PackagesRestorePackageForAuthenticatedUserError::Status401(github_response.to_json()?).into()),
code => Err(PackagesRestorePackageForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Restore a package for an organization
///
/// Restores an entire package in an organization.
///
/// You can restore a deleted package under the following conditions:
/// - The package was deleted within the last 30 days.
/// - The same package namespace and version is still available and not reused for a new package. If the same package namespace is not available, you will not be able to restore your package. In this scenario, to restore the deleted package, you must delete the new package that uses the deleted package's namespace first.
///
/// The authenticated user must have admin permissions in the organization to use this endpoint. If the `package_type` belongs to a GitHub Packages registry that supports granular permissions, the authenticated user must also have admin permissions to the package. For the list of these registries, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#granular-permissions-for-userorganization-scoped-packages)."
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` and `write:packages` scopes to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)."
///
/// [GitHub API docs for restore_package_for_org](https://docs.github.com/rest/packages/packages#restore-a-package-for-an-organization)
///
/// ---
pub async fn restore_package_for_org_async(&self, package_type: &str, package_name: &str, org: &str, query_params: Option<impl Into<PackagesRestorePackageForOrgParams<'api>>>) -> Result<(), AdapterError> {
let mut request_uri = format!("{}/orgs/{}/packages/{}/{}/restore", super::GITHUB_BASE_API_URL, package_type, package_name, 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: "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(PackagesRestorePackageForOrgError::Status404(github_response.to_json_async().await?).into()),
403 => Err(PackagesRestorePackageForOrgError::Status403(github_response.to_json_async().await?).into()),
401 => Err(PackagesRestorePackageForOrgError::Status401(github_response.to_json_async().await?).into()),
code => Err(PackagesRestorePackageForOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Restore a package for an organization
///
/// Restores an entire package in an organization.
///
/// You can restore a deleted package under the following conditions:
/// - The package was deleted within the last 30 days.
/// - The same package namespace and version is still available and not reused for a new package. If the same package namespace is not available, you will not be able to restore your package. In this scenario, to restore the deleted package, you must delete the new package that uses the deleted package's namespace first.
///
/// The authenticated user must have admin permissions in the organization to use this endpoint. If the `package_type` belongs to a GitHub Packages registry that supports granular permissions, the authenticated user must also have admin permissions to the package. For the list of these registries, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#granular-permissions-for-userorganization-scoped-packages)."
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` and `write:packages` scopes to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)."
///
/// [GitHub API docs for restore_package_for_org](https://docs.github.com/rest/packages/packages#restore-a-package-for-an-organization)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn restore_package_for_org(&self, package_type: &str, package_name: &str, org: &str, query_params: Option<impl Into<PackagesRestorePackageForOrgParams<'api>>>) -> Result<(), AdapterError> {
let mut request_uri = format!("{}/orgs/{}/packages/{}/{}/restore", super::GITHUB_BASE_API_URL, package_type, package_name, org);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: PackagesRestorePackageForOrgParams = params.into();
request_uri.push_str(&serde_urlencoded::to_string(qp)?);
}
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(PackagesRestorePackageForOrgError::Status404(github_response.to_json()?).into()),
403 => Err(PackagesRestorePackageForOrgError::Status403(github_response.to_json()?).into()),
401 => Err(PackagesRestorePackageForOrgError::Status401(github_response.to_json()?).into()),
code => Err(PackagesRestorePackageForOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Restore a package for a user
///
/// Restores an entire package for a user.
///
/// You can restore a deleted package under the following conditions:
/// - The package was deleted within the last 30 days.
/// - The same package namespace and version is still available and not reused for a new package. If the same package namespace is not available, you will not be able to restore your package. In this scenario, to restore the deleted package, you must delete the new package that uses the deleted package's namespace first.
///
/// If the `package_type` belongs to a GitHub Packages registry that supports granular permissions, the authenticated user must have admin permissions to the package. For the list of these registries, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#granular-permissions-for-userorganization-scoped-packages)."
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` and `write:packages` scopes to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)."
///
/// [GitHub API docs for restore_package_for_user](https://docs.github.com/rest/packages/packages#restore-a-package-for-a-user)
///
/// ---
pub async fn restore_package_for_user_async(&self, package_type: &str, package_name: &str, username: &str, query_params: Option<impl Into<PackagesRestorePackageForUserParams<'api>>>) -> Result<(), AdapterError> {
let mut request_uri = format!("{}/users/{}/packages/{}/{}/restore", super::GITHUB_BASE_API_URL, package_type, package_name, 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: "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(PackagesRestorePackageForUserError::Status404(github_response.to_json_async().await?).into()),
403 => Err(PackagesRestorePackageForUserError::Status403(github_response.to_json_async().await?).into()),
401 => Err(PackagesRestorePackageForUserError::Status401(github_response.to_json_async().await?).into()),
code => Err(PackagesRestorePackageForUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Restore a package for a user
///
/// Restores an entire package for a user.
///
/// You can restore a deleted package under the following conditions:
/// - The package was deleted within the last 30 days.
/// - The same package namespace and version is still available and not reused for a new package. If the same package namespace is not available, you will not be able to restore your package. In this scenario, to restore the deleted package, you must delete the new package that uses the deleted package's namespace first.
///
/// If the `package_type` belongs to a GitHub Packages registry that supports granular permissions, the authenticated user must have admin permissions to the package. For the list of these registries, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#granular-permissions-for-userorganization-scoped-packages)."
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` and `write:packages` scopes to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)."
///
/// [GitHub API docs for restore_package_for_user](https://docs.github.com/rest/packages/packages#restore-a-package-for-a-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn restore_package_for_user(&self, package_type: &str, package_name: &str, username: &str, query_params: Option<impl Into<PackagesRestorePackageForUserParams<'api>>>) -> Result<(), AdapterError> {
let mut request_uri = format!("{}/users/{}/packages/{}/{}/restore", super::GITHUB_BASE_API_URL, package_type, package_name, username);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: PackagesRestorePackageForUserParams = params.into();
request_uri.push_str(&serde_urlencoded::to_string(qp)?);
}
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(PackagesRestorePackageForUserError::Status404(github_response.to_json()?).into()),
403 => Err(PackagesRestorePackageForUserError::Status403(github_response.to_json()?).into()),
401 => Err(PackagesRestorePackageForUserError::Status401(github_response.to_json()?).into()),
code => Err(PackagesRestorePackageForUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Restore a package version for the authenticated user
///
/// Restores a package version owned by the authenticated user.
///
/// You can restore a deleted package version under the following conditions:
/// - The package was deleted within the last 30 days.
/// - The same package namespace and version is still available and not reused for a new package. If the same package namespace is not available, you will not be able to restore your package. In this scenario, to restore the deleted package, you must delete the new package that uses the deleted package's namespace first.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` and `write:packages` scopes to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)."
///
/// [GitHub API docs for restore_package_version_for_authenticated_user](https://docs.github.com/rest/packages/packages#restore-a-package-version-for-the-authenticated-user)
///
/// ---
pub async fn restore_package_version_for_authenticated_user_async(&self, package_type: &str, package_name: &str, package_version_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/user/packages/{}/{}/versions/{}/restore", super::GITHUB_BASE_API_URL, package_type, package_name, package_version_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(PackagesRestorePackageVersionForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()),
403 => Err(PackagesRestorePackageVersionForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()),
401 => Err(PackagesRestorePackageVersionForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()),
code => Err(PackagesRestorePackageVersionForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Restore a package version for the authenticated user
///
/// Restores a package version owned by the authenticated user.
///
/// You can restore a deleted package version under the following conditions:
/// - The package was deleted within the last 30 days.
/// - The same package namespace and version is still available and not reused for a new package. If the same package namespace is not available, you will not be able to restore your package. In this scenario, to restore the deleted package, you must delete the new package that uses the deleted package's namespace first.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` and `write:packages` scopes to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)."
///
/// [GitHub API docs for restore_package_version_for_authenticated_user](https://docs.github.com/rest/packages/packages#restore-a-package-version-for-the-authenticated-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn restore_package_version_for_authenticated_user(&self, package_type: &str, package_name: &str, package_version_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/user/packages/{}/{}/versions/{}/restore", super::GITHUB_BASE_API_URL, package_type, package_name, package_version_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(PackagesRestorePackageVersionForAuthenticatedUserError::Status404(github_response.to_json()?).into()),
403 => Err(PackagesRestorePackageVersionForAuthenticatedUserError::Status403(github_response.to_json()?).into()),
401 => Err(PackagesRestorePackageVersionForAuthenticatedUserError::Status401(github_response.to_json()?).into()),
code => Err(PackagesRestorePackageVersionForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Restore package version for an organization
///
/// Restores a specific package version in an organization.
///
/// You can restore a deleted package under the following conditions:
/// - The package was deleted within the last 30 days.
/// - The same package namespace and version is still available and not reused for a new package. If the same package namespace is not available, you will not be able to restore your package. In this scenario, to restore the deleted package, you must delete the new package that uses the deleted package's namespace first.
///
/// The authenticated user must have admin permissions in the organization to use this endpoint. If the `package_type` belongs to a GitHub Packages registry that supports granular permissions, the authenticated user must also have admin permissions to the package. For the list of these registries, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#granular-permissions-for-userorganization-scoped-packages)."
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` and `write:packages` scopes to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)."
///
/// [GitHub API docs for restore_package_version_for_org](https://docs.github.com/rest/packages/packages#restore-package-version-for-an-organization)
///
/// ---
pub async fn restore_package_version_for_org_async(&self, package_type: &str, package_name: &str, org: &str, package_version_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/packages/{}/{}/versions/{}/restore", super::GITHUB_BASE_API_URL, package_type, package_name, org, package_version_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(PackagesRestorePackageVersionForOrgError::Status404(github_response.to_json_async().await?).into()),
403 => Err(PackagesRestorePackageVersionForOrgError::Status403(github_response.to_json_async().await?).into()),
401 => Err(PackagesRestorePackageVersionForOrgError::Status401(github_response.to_json_async().await?).into()),
code => Err(PackagesRestorePackageVersionForOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Restore package version for an organization
///
/// Restores a specific package version in an organization.
///
/// You can restore a deleted package under the following conditions:
/// - The package was deleted within the last 30 days.
/// - The same package namespace and version is still available and not reused for a new package. If the same package namespace is not available, you will not be able to restore your package. In this scenario, to restore the deleted package, you must delete the new package that uses the deleted package's namespace first.
///
/// The authenticated user must have admin permissions in the organization to use this endpoint. If the `package_type` belongs to a GitHub Packages registry that supports granular permissions, the authenticated user must also have admin permissions to the package. For the list of these registries, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#granular-permissions-for-userorganization-scoped-packages)."
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` and `write:packages` scopes to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)."
///
/// [GitHub API docs for restore_package_version_for_org](https://docs.github.com/rest/packages/packages#restore-package-version-for-an-organization)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn restore_package_version_for_org(&self, package_type: &str, package_name: &str, org: &str, package_version_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/orgs/{}/packages/{}/{}/versions/{}/restore", super::GITHUB_BASE_API_URL, package_type, package_name, org, package_version_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(PackagesRestorePackageVersionForOrgError::Status404(github_response.to_json()?).into()),
403 => Err(PackagesRestorePackageVersionForOrgError::Status403(github_response.to_json()?).into()),
401 => Err(PackagesRestorePackageVersionForOrgError::Status401(github_response.to_json()?).into()),
code => Err(PackagesRestorePackageVersionForOrgError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Restore package version for a user
///
/// Restores a specific package version for a user.
///
/// You can restore a deleted package under the following conditions:
/// - The package was deleted within the last 30 days.
/// - The same package namespace and version is still available and not reused for a new package. If the same package namespace is not available, you will not be able to restore your package. In this scenario, to restore the deleted package, you must delete the new package that uses the deleted package's namespace first.
///
/// If the `package_type` belongs to a GitHub Packages registry that supports granular permissions, the authenticated user must have admin permissions to the package. For the list of these registries, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#granular-permissions-for-userorganization-scoped-packages)."
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` and `write:packages` scopes to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)."
///
/// [GitHub API docs for restore_package_version_for_user](https://docs.github.com/rest/packages/packages#restore-package-version-for-a-user)
///
/// ---
pub async fn restore_package_version_for_user_async(&self, package_type: &str, package_name: &str, username: &str, package_version_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/users/{}/packages/{}/{}/versions/{}/restore", super::GITHUB_BASE_API_URL, package_type, package_name, username, package_version_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(PackagesRestorePackageVersionForUserError::Status404(github_response.to_json_async().await?).into()),
403 => Err(PackagesRestorePackageVersionForUserError::Status403(github_response.to_json_async().await?).into()),
401 => Err(PackagesRestorePackageVersionForUserError::Status401(github_response.to_json_async().await?).into()),
code => Err(PackagesRestorePackageVersionForUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Restore package version for a user
///
/// Restores a specific package version for a user.
///
/// You can restore a deleted package under the following conditions:
/// - The package was deleted within the last 30 days.
/// - The same package namespace and version is still available and not reused for a new package. If the same package namespace is not available, you will not be able to restore your package. In this scenario, to restore the deleted package, you must delete the new package that uses the deleted package's namespace first.
///
/// If the `package_type` belongs to a GitHub Packages registry that supports granular permissions, the authenticated user must have admin permissions to the package. For the list of these registries, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#granular-permissions-for-userorganization-scoped-packages)."
///
/// OAuth app tokens and personal access tokens (classic) need the `read:packages` and `write:packages` scopes to use this endpoint. For more information, see "[About permissions for GitHub Packages](https://docs.github.com/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages)."
///
/// [GitHub API docs for restore_package_version_for_user](https://docs.github.com/rest/packages/packages#restore-package-version-for-a-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn restore_package_version_for_user(&self, package_type: &str, package_name: &str, username: &str, package_version_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/users/{}/packages/{}/{}/versions/{}/restore", super::GITHUB_BASE_API_URL, package_type, package_name, username, package_version_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(PackagesRestorePackageVersionForUserError::Status404(github_response.to_json()?).into()),
403 => Err(PackagesRestorePackageVersionForUserError::Status403(github_response.to_json()?).into()),
401 => Err(PackagesRestorePackageVersionForUserError::Status401(github_response.to_json()?).into()),
code => Err(PackagesRestorePackageVersionForUserError::Generic { code }.into()),
}
}
}
}