//! Method, error and parameter types for the Users 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 Users<'api, C: Client> where AdapterError: From<<C as Client>::Err> {
client: &'api C
}
pub fn new<C: Client>(client: &C) -> Users<C> where AdapterError: From<<C as Client>::Err> {
Users { client }
}
/// Errors for the [Add an email address for the authenticated user](Users::add_email_for_authenticated_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum UsersAddEmailForAuthenticatedUserError {
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Not modified")]
Status304,
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<UsersAddEmailForAuthenticatedUserError> for AdapterError {
fn from(err: UsersAddEmailForAuthenticatedUserError) -> Self {
let (description, status_code) = match err {
UsersAddEmailForAuthenticatedUserError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
UsersAddEmailForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304),
UsersAddEmailForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404),
UsersAddEmailForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403),
UsersAddEmailForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401),
UsersAddEmailForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Add social accounts for the authenticated user](Users::add_social_account_for_authenticated_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum UsersAddSocialAccountForAuthenticatedUserError {
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Not modified")]
Status304,
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<UsersAddSocialAccountForAuthenticatedUserError> for AdapterError {
fn from(err: UsersAddSocialAccountForAuthenticatedUserError) -> Self {
let (description, status_code) = match err {
UsersAddSocialAccountForAuthenticatedUserError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
UsersAddSocialAccountForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304),
UsersAddSocialAccountForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404),
UsersAddSocialAccountForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403),
UsersAddSocialAccountForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401),
UsersAddSocialAccountForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Block a user](Users::block_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum UsersBlockError {
#[error("Not modified")]
Status304,
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<UsersBlockError> for AdapterError {
fn from(err: UsersBlockError) -> Self {
let (description, status_code) = match err {
UsersBlockError::Status304 => (String::from("Not modified"), 304),
UsersBlockError::Status404(_) => (String::from("Resource not found"), 404),
UsersBlockError::Status403(_) => (String::from("Forbidden"), 403),
UsersBlockError::Status401(_) => (String::from("Requires authentication"), 401),
UsersBlockError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
UsersBlockError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Check if a user is blocked by the authenticated user](Users::check_blocked_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum UsersCheckBlockedError {
#[error("If the user is not blocked")]
Status404(BasicError),
#[error("Not modified")]
Status304,
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<UsersCheckBlockedError> for AdapterError {
fn from(err: UsersCheckBlockedError) -> Self {
let (description, status_code) = match err {
UsersCheckBlockedError::Status404(_) => (String::from("If the user is not blocked"), 404),
UsersCheckBlockedError::Status304 => (String::from("Not modified"), 304),
UsersCheckBlockedError::Status403(_) => (String::from("Forbidden"), 403),
UsersCheckBlockedError::Status401(_) => (String::from("Requires authentication"), 401),
UsersCheckBlockedError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Check if a user follows another user](Users::check_following_for_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum UsersCheckFollowingForUserError {
#[error("if the user does not follow the target user")]
Status404,
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<UsersCheckFollowingForUserError> for AdapterError {
fn from(err: UsersCheckFollowingForUserError) -> Self {
let (description, status_code) = match err {
UsersCheckFollowingForUserError::Status404 => (String::from("if the user does not follow the target user"), 404),
UsersCheckFollowingForUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Check if a person is followed by the authenticated user](Users::check_person_is_followed_by_authenticated_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum UsersCheckPersonIsFollowedByAuthenticatedError {
#[error("if the person is not followed by the authenticated user")]
Status404(BasicError),
#[error("Not modified")]
Status304,
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<UsersCheckPersonIsFollowedByAuthenticatedError> for AdapterError {
fn from(err: UsersCheckPersonIsFollowedByAuthenticatedError) -> Self {
let (description, status_code) = match err {
UsersCheckPersonIsFollowedByAuthenticatedError::Status404(_) => (String::from("if the person is not followed by the authenticated user"), 404),
UsersCheckPersonIsFollowedByAuthenticatedError::Status304 => (String::from("Not modified"), 304),
UsersCheckPersonIsFollowedByAuthenticatedError::Status403(_) => (String::from("Forbidden"), 403),
UsersCheckPersonIsFollowedByAuthenticatedError::Status401(_) => (String::from("Requires authentication"), 401),
UsersCheckPersonIsFollowedByAuthenticatedError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Create a GPG key for the authenticated user](Users::create_gpg_key_for_authenticated_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum UsersCreateGpgKeyForAuthenticatedUserError {
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Not modified")]
Status304,
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<UsersCreateGpgKeyForAuthenticatedUserError> for AdapterError {
fn from(err: UsersCreateGpgKeyForAuthenticatedUserError) -> Self {
let (description, status_code) = match err {
UsersCreateGpgKeyForAuthenticatedUserError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
UsersCreateGpgKeyForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304),
UsersCreateGpgKeyForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404),
UsersCreateGpgKeyForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403),
UsersCreateGpgKeyForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401),
UsersCreateGpgKeyForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Create a public SSH key for the authenticated user](Users::create_public_ssh_key_for_authenticated_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum UsersCreatePublicSshKeyForAuthenticatedUserError {
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Not modified")]
Status304,
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<UsersCreatePublicSshKeyForAuthenticatedUserError> for AdapterError {
fn from(err: UsersCreatePublicSshKeyForAuthenticatedUserError) -> Self {
let (description, status_code) = match err {
UsersCreatePublicSshKeyForAuthenticatedUserError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
UsersCreatePublicSshKeyForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304),
UsersCreatePublicSshKeyForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404),
UsersCreatePublicSshKeyForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403),
UsersCreatePublicSshKeyForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401),
UsersCreatePublicSshKeyForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Create a SSH signing key for the authenticated user](Users::create_ssh_signing_key_for_authenticated_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum UsersCreateSshSigningKeyForAuthenticatedUserError {
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Not modified")]
Status304,
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<UsersCreateSshSigningKeyForAuthenticatedUserError> for AdapterError {
fn from(err: UsersCreateSshSigningKeyForAuthenticatedUserError) -> Self {
let (description, status_code) = match err {
UsersCreateSshSigningKeyForAuthenticatedUserError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
UsersCreateSshSigningKeyForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304),
UsersCreateSshSigningKeyForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404),
UsersCreateSshSigningKeyForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403),
UsersCreateSshSigningKeyForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401),
UsersCreateSshSigningKeyForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Delete attestations in bulk](Users::delete_attestations_bulk_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum UsersDeleteAttestationsBulkError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<UsersDeleteAttestationsBulkError> for AdapterError {
fn from(err: UsersDeleteAttestationsBulkError) -> Self {
let (description, status_code) = match err {
UsersDeleteAttestationsBulkError::Status404(_) => (String::from("Resource not found"), 404),
UsersDeleteAttestationsBulkError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Delete attestations by ID](Users::delete_attestations_by_id_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum UsersDeleteAttestationsByIdError {
#[error("Response")]
Status204,
#[error("Forbidden")]
Status403(BasicError),
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<UsersDeleteAttestationsByIdError> for AdapterError {
fn from(err: UsersDeleteAttestationsByIdError) -> Self {
let (description, status_code) = match err {
UsersDeleteAttestationsByIdError::Status204 => (String::from("Response"), 204),
UsersDeleteAttestationsByIdError::Status403(_) => (String::from("Forbidden"), 403),
UsersDeleteAttestationsByIdError::Status404(_) => (String::from("Resource not found"), 404),
UsersDeleteAttestationsByIdError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Delete attestations by subject digest](Users::delete_attestations_by_subject_digest_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum UsersDeleteAttestationsBySubjectDigestError {
#[error("Response")]
Status204,
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<UsersDeleteAttestationsBySubjectDigestError> for AdapterError {
fn from(err: UsersDeleteAttestationsBySubjectDigestError) -> Self {
let (description, status_code) = match err {
UsersDeleteAttestationsBySubjectDigestError::Status204 => (String::from("Response"), 204),
UsersDeleteAttestationsBySubjectDigestError::Status404(_) => (String::from("Resource not found"), 404),
UsersDeleteAttestationsBySubjectDigestError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Delete an email address for the authenticated user](Users::delete_email_for_authenticated_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum UsersDeleteEmailForAuthenticatedUserError {
#[error("Not modified")]
Status304,
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<UsersDeleteEmailForAuthenticatedUserError> for AdapterError {
fn from(err: UsersDeleteEmailForAuthenticatedUserError) -> Self {
let (description, status_code) = match err {
UsersDeleteEmailForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304),
UsersDeleteEmailForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404),
UsersDeleteEmailForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403),
UsersDeleteEmailForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401),
UsersDeleteEmailForAuthenticatedUserError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
UsersDeleteEmailForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Delete a GPG key for the authenticated user](Users::delete_gpg_key_for_authenticated_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum UsersDeleteGpgKeyForAuthenticatedUserError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Not modified")]
Status304,
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<UsersDeleteGpgKeyForAuthenticatedUserError> for AdapterError {
fn from(err: UsersDeleteGpgKeyForAuthenticatedUserError) -> Self {
let (description, status_code) = match err {
UsersDeleteGpgKeyForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404),
UsersDeleteGpgKeyForAuthenticatedUserError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
UsersDeleteGpgKeyForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304),
UsersDeleteGpgKeyForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403),
UsersDeleteGpgKeyForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401),
UsersDeleteGpgKeyForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Delete a public SSH key for the authenticated user](Users::delete_public_ssh_key_for_authenticated_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum UsersDeletePublicSshKeyForAuthenticatedUserError {
#[error("Not modified")]
Status304,
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<UsersDeletePublicSshKeyForAuthenticatedUserError> for AdapterError {
fn from(err: UsersDeletePublicSshKeyForAuthenticatedUserError) -> Self {
let (description, status_code) = match err {
UsersDeletePublicSshKeyForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304),
UsersDeletePublicSshKeyForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404),
UsersDeletePublicSshKeyForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403),
UsersDeletePublicSshKeyForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401),
UsersDeletePublicSshKeyForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Delete social accounts for the authenticated user](Users::delete_social_account_for_authenticated_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum UsersDeleteSocialAccountForAuthenticatedUserError {
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Not modified")]
Status304,
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<UsersDeleteSocialAccountForAuthenticatedUserError> for AdapterError {
fn from(err: UsersDeleteSocialAccountForAuthenticatedUserError) -> Self {
let (description, status_code) = match err {
UsersDeleteSocialAccountForAuthenticatedUserError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
UsersDeleteSocialAccountForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304),
UsersDeleteSocialAccountForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404),
UsersDeleteSocialAccountForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403),
UsersDeleteSocialAccountForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401),
UsersDeleteSocialAccountForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Delete an SSH signing key for the authenticated user](Users::delete_ssh_signing_key_for_authenticated_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum UsersDeleteSshSigningKeyForAuthenticatedUserError {
#[error("Not modified")]
Status304,
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<UsersDeleteSshSigningKeyForAuthenticatedUserError> for AdapterError {
fn from(err: UsersDeleteSshSigningKeyForAuthenticatedUserError) -> Self {
let (description, status_code) = match err {
UsersDeleteSshSigningKeyForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304),
UsersDeleteSshSigningKeyForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404),
UsersDeleteSshSigningKeyForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403),
UsersDeleteSshSigningKeyForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401),
UsersDeleteSshSigningKeyForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Follow a user](Users::follow_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum UsersFollowError {
#[error("Not modified")]
Status304,
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<UsersFollowError> for AdapterError {
fn from(err: UsersFollowError) -> Self {
let (description, status_code) = match err {
UsersFollowError::Status304 => (String::from("Not modified"), 304),
UsersFollowError::Status404(_) => (String::from("Resource not found"), 404),
UsersFollowError::Status403(_) => (String::from("Forbidden"), 403),
UsersFollowError::Status401(_) => (String::from("Requires authentication"), 401),
UsersFollowError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
UsersFollowError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get the authenticated user](Users::get_authenticated_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum UsersGetAuthenticatedError {
#[error("Not modified")]
Status304,
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<UsersGetAuthenticatedError> for AdapterError {
fn from(err: UsersGetAuthenticatedError) -> Self {
let (description, status_code) = match err {
UsersGetAuthenticatedError::Status304 => (String::from("Not modified"), 304),
UsersGetAuthenticatedError::Status403(_) => (String::from("Forbidden"), 403),
UsersGetAuthenticatedError::Status401(_) => (String::from("Requires authentication"), 401),
UsersGetAuthenticatedError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get a user using their ID](Users::get_by_id_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum UsersGetByIdError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<UsersGetByIdError> for AdapterError {
fn from(err: UsersGetByIdError) -> Self {
let (description, status_code) = match err {
UsersGetByIdError::Status404(_) => (String::from("Resource not found"), 404),
UsersGetByIdError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get a user](Users::get_by_username_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum UsersGetByUsernameError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<UsersGetByUsernameError> for AdapterError {
fn from(err: UsersGetByUsernameError) -> Self {
let (description, status_code) = match err {
UsersGetByUsernameError::Status404(_) => (String::from("Resource not found"), 404),
UsersGetByUsernameError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get contextual information for a user](Users::get_context_for_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum UsersGetContextForUserError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<UsersGetContextForUserError> for AdapterError {
fn from(err: UsersGetContextForUserError) -> Self {
let (description, status_code) = match err {
UsersGetContextForUserError::Status404(_) => (String::from("Resource not found"), 404),
UsersGetContextForUserError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
UsersGetContextForUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get a GPG key for the authenticated user](Users::get_gpg_key_for_authenticated_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum UsersGetGpgKeyForAuthenticatedUserError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Not modified")]
Status304,
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<UsersGetGpgKeyForAuthenticatedUserError> for AdapterError {
fn from(err: UsersGetGpgKeyForAuthenticatedUserError) -> Self {
let (description, status_code) = match err {
UsersGetGpgKeyForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404),
UsersGetGpgKeyForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304),
UsersGetGpgKeyForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403),
UsersGetGpgKeyForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401),
UsersGetGpgKeyForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get a public SSH key for the authenticated user](Users::get_public_ssh_key_for_authenticated_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum UsersGetPublicSshKeyForAuthenticatedUserError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Not modified")]
Status304,
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<UsersGetPublicSshKeyForAuthenticatedUserError> for AdapterError {
fn from(err: UsersGetPublicSshKeyForAuthenticatedUserError) -> Self {
let (description, status_code) = match err {
UsersGetPublicSshKeyForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404),
UsersGetPublicSshKeyForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304),
UsersGetPublicSshKeyForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403),
UsersGetPublicSshKeyForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401),
UsersGetPublicSshKeyForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get an SSH signing key for the authenticated user](Users::get_ssh_signing_key_for_authenticated_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum UsersGetSshSigningKeyForAuthenticatedUserError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Not modified")]
Status304,
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<UsersGetSshSigningKeyForAuthenticatedUserError> for AdapterError {
fn from(err: UsersGetSshSigningKeyForAuthenticatedUserError) -> Self {
let (description, status_code) = match err {
UsersGetSshSigningKeyForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404),
UsersGetSshSigningKeyForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304),
UsersGetSshSigningKeyForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403),
UsersGetSshSigningKeyForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401),
UsersGetSshSigningKeyForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List users](Users::list_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum UsersListError {
#[error("Not modified")]
Status304,
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<UsersListError> for AdapterError {
fn from(err: UsersListError) -> Self {
let (description, status_code) = match err {
UsersListError::Status304 => (String::from("Not modified"), 304),
UsersListError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List attestations](Users::list_attestations_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum UsersListAttestationsError {
#[error("Response")]
Status201(EmptyObject),
#[error("Response")]
Status204,
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<UsersListAttestationsError> for AdapterError {
fn from(err: UsersListAttestationsError) -> Self {
let (description, status_code) = match err {
UsersListAttestationsError::Status201(_) => (String::from("Response"), 201),
UsersListAttestationsError::Status204 => (String::from("Response"), 204),
UsersListAttestationsError::Status404(_) => (String::from("Resource not found"), 404),
UsersListAttestationsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List attestations by bulk subject digests](Users::list_attestations_bulk_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum UsersListAttestationsBulkError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<UsersListAttestationsBulkError> for AdapterError {
fn from(err: UsersListAttestationsBulkError) -> Self {
let (description, status_code) = match err {
UsersListAttestationsBulkError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List users blocked by the authenticated user](Users::list_blocked_by_authenticated_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum UsersListBlockedByAuthenticatedUserError {
#[error("Not modified")]
Status304,
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<UsersListBlockedByAuthenticatedUserError> for AdapterError {
fn from(err: UsersListBlockedByAuthenticatedUserError) -> Self {
let (description, status_code) = match err {
UsersListBlockedByAuthenticatedUserError::Status304 => (String::from("Not modified"), 304),
UsersListBlockedByAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404),
UsersListBlockedByAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403),
UsersListBlockedByAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401),
UsersListBlockedByAuthenticatedUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List email addresses for the authenticated user](Users::list_emails_for_authenticated_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum UsersListEmailsForAuthenticatedUserError {
#[error("Not modified")]
Status304,
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<UsersListEmailsForAuthenticatedUserError> for AdapterError {
fn from(err: UsersListEmailsForAuthenticatedUserError) -> Self {
let (description, status_code) = match err {
UsersListEmailsForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304),
UsersListEmailsForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404),
UsersListEmailsForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403),
UsersListEmailsForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401),
UsersListEmailsForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List the people the authenticated user follows](Users::list_followed_by_authenticated_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum UsersListFollowedByAuthenticatedUserError {
#[error("Not modified")]
Status304,
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<UsersListFollowedByAuthenticatedUserError> for AdapterError {
fn from(err: UsersListFollowedByAuthenticatedUserError) -> Self {
let (description, status_code) = match err {
UsersListFollowedByAuthenticatedUserError::Status304 => (String::from("Not modified"), 304),
UsersListFollowedByAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403),
UsersListFollowedByAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401),
UsersListFollowedByAuthenticatedUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List followers of the authenticated user](Users::list_followers_for_authenticated_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum UsersListFollowersForAuthenticatedUserError {
#[error("Not modified")]
Status304,
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<UsersListFollowersForAuthenticatedUserError> for AdapterError {
fn from(err: UsersListFollowersForAuthenticatedUserError) -> Self {
let (description, status_code) = match err {
UsersListFollowersForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304),
UsersListFollowersForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403),
UsersListFollowersForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401),
UsersListFollowersForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List followers of a user](Users::list_followers_for_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum UsersListFollowersForUserError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<UsersListFollowersForUserError> for AdapterError {
fn from(err: UsersListFollowersForUserError) -> Self {
let (description, status_code) = match err {
UsersListFollowersForUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List the people a user follows](Users::list_following_for_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum UsersListFollowingForUserError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<UsersListFollowingForUserError> for AdapterError {
fn from(err: UsersListFollowingForUserError) -> Self {
let (description, status_code) = match err {
UsersListFollowingForUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List GPG keys for the authenticated user](Users::list_gpg_keys_for_authenticated_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum UsersListGpgKeysForAuthenticatedUserError {
#[error("Not modified")]
Status304,
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<UsersListGpgKeysForAuthenticatedUserError> for AdapterError {
fn from(err: UsersListGpgKeysForAuthenticatedUserError) -> Self {
let (description, status_code) = match err {
UsersListGpgKeysForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304),
UsersListGpgKeysForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404),
UsersListGpgKeysForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403),
UsersListGpgKeysForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401),
UsersListGpgKeysForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List GPG keys for a user](Users::list_gpg_keys_for_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum UsersListGpgKeysForUserError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<UsersListGpgKeysForUserError> for AdapterError {
fn from(err: UsersListGpgKeysForUserError) -> Self {
let (description, status_code) = match err {
UsersListGpgKeysForUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List public email addresses for the authenticated user](Users::list_public_emails_for_authenticated_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum UsersListPublicEmailsForAuthenticatedUserError {
#[error("Not modified")]
Status304,
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<UsersListPublicEmailsForAuthenticatedUserError> for AdapterError {
fn from(err: UsersListPublicEmailsForAuthenticatedUserError) -> Self {
let (description, status_code) = match err {
UsersListPublicEmailsForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304),
UsersListPublicEmailsForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404),
UsersListPublicEmailsForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403),
UsersListPublicEmailsForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401),
UsersListPublicEmailsForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List public keys for a user](Users::list_public_keys_for_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum UsersListPublicKeysForUserError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<UsersListPublicKeysForUserError> for AdapterError {
fn from(err: UsersListPublicKeysForUserError) -> Self {
let (description, status_code) = match err {
UsersListPublicKeysForUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List public SSH keys for the authenticated user](Users::list_public_ssh_keys_for_authenticated_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum UsersListPublicSshKeysForAuthenticatedUserError {
#[error("Not modified")]
Status304,
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<UsersListPublicSshKeysForAuthenticatedUserError> for AdapterError {
fn from(err: UsersListPublicSshKeysForAuthenticatedUserError) -> Self {
let (description, status_code) = match err {
UsersListPublicSshKeysForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304),
UsersListPublicSshKeysForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404),
UsersListPublicSshKeysForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403),
UsersListPublicSshKeysForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401),
UsersListPublicSshKeysForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List social accounts for the authenticated user](Users::list_social_accounts_for_authenticated_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum UsersListSocialAccountsForAuthenticatedUserError {
#[error("Not modified")]
Status304,
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<UsersListSocialAccountsForAuthenticatedUserError> for AdapterError {
fn from(err: UsersListSocialAccountsForAuthenticatedUserError) -> Self {
let (description, status_code) = match err {
UsersListSocialAccountsForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304),
UsersListSocialAccountsForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404),
UsersListSocialAccountsForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403),
UsersListSocialAccountsForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401),
UsersListSocialAccountsForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List social accounts for a user](Users::list_social_accounts_for_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum UsersListSocialAccountsForUserError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<UsersListSocialAccountsForUserError> for AdapterError {
fn from(err: UsersListSocialAccountsForUserError) -> Self {
let (description, status_code) = match err {
UsersListSocialAccountsForUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List SSH signing keys for the authenticated user](Users::list_ssh_signing_keys_for_authenticated_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum UsersListSshSigningKeysForAuthenticatedUserError {
#[error("Not modified")]
Status304,
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<UsersListSshSigningKeysForAuthenticatedUserError> for AdapterError {
fn from(err: UsersListSshSigningKeysForAuthenticatedUserError) -> Self {
let (description, status_code) = match err {
UsersListSshSigningKeysForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304),
UsersListSshSigningKeysForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404),
UsersListSshSigningKeysForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403),
UsersListSshSigningKeysForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401),
UsersListSshSigningKeysForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List SSH signing keys for a user](Users::list_ssh_signing_keys_for_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum UsersListSshSigningKeysForUserError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<UsersListSshSigningKeysForUserError> for AdapterError {
fn from(err: UsersListSshSigningKeysForUserError) -> Self {
let (description, status_code) = match err {
UsersListSshSigningKeysForUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Set primary email visibility for the authenticated user](Users::set_primary_email_visibility_for_authenticated_user_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum UsersSetPrimaryEmailVisibilityForAuthenticatedUserError {
#[error("Not modified")]
Status304,
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<UsersSetPrimaryEmailVisibilityForAuthenticatedUserError> for AdapterError {
fn from(err: UsersSetPrimaryEmailVisibilityForAuthenticatedUserError) -> Self {
let (description, status_code) = match err {
UsersSetPrimaryEmailVisibilityForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304),
UsersSetPrimaryEmailVisibilityForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404),
UsersSetPrimaryEmailVisibilityForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403),
UsersSetPrimaryEmailVisibilityForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401),
UsersSetPrimaryEmailVisibilityForAuthenticatedUserError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
UsersSetPrimaryEmailVisibilityForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Unblock a user](Users::unblock_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum UsersUnblockError {
#[error("Not modified")]
Status304,
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<UsersUnblockError> for AdapterError {
fn from(err: UsersUnblockError) -> Self {
let (description, status_code) = match err {
UsersUnblockError::Status304 => (String::from("Not modified"), 304),
UsersUnblockError::Status403(_) => (String::from("Forbidden"), 403),
UsersUnblockError::Status401(_) => (String::from("Requires authentication"), 401),
UsersUnblockError::Status404(_) => (String::from("Resource not found"), 404),
UsersUnblockError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Unfollow a user](Users::unfollow_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum UsersUnfollowError {
#[error("Not modified")]
Status304,
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<UsersUnfollowError> for AdapterError {
fn from(err: UsersUnfollowError) -> Self {
let (description, status_code) = match err {
UsersUnfollowError::Status304 => (String::from("Not modified"), 304),
UsersUnfollowError::Status404(_) => (String::from("Resource not found"), 404),
UsersUnfollowError::Status403(_) => (String::from("Forbidden"), 403),
UsersUnfollowError::Status401(_) => (String::from("Requires authentication"), 401),
UsersUnfollowError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Update the authenticated user](Users::update_authenticated_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum UsersUpdateAuthenticatedError {
#[error("Not modified")]
Status304,
#[error("Resource not found")]
Status404(BasicError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Requires authentication")]
Status401(BasicError),
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<UsersUpdateAuthenticatedError> for AdapterError {
fn from(err: UsersUpdateAuthenticatedError) -> Self {
let (description, status_code) = match err {
UsersUpdateAuthenticatedError::Status304 => (String::from("Not modified"), 304),
UsersUpdateAuthenticatedError::Status404(_) => (String::from("Resource not found"), 404),
UsersUpdateAuthenticatedError::Status403(_) => (String::from("Forbidden"), 403),
UsersUpdateAuthenticatedError::Status401(_) => (String::from("Requires authentication"), 401),
UsersUpdateAuthenticatedError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
UsersUpdateAuthenticatedError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Query parameters for the [Get contextual information for a user](Users::get_context_for_user_async()) endpoint.
#[derive(Default, Serialize)]
pub struct UsersGetContextForUserParams<'req> {
/// Identifies which additional information you'd like to receive about the person's hovercard. Can be `organization`, `repository`, `issue`, `pull_request`. **Required** when using `subject_id`.
subject_type: Option<&'req str>,
/// Uses the ID for the `subject_type` you specified. **Required** when using `subject_type`.
subject_id: Option<&'req str>
}
impl<'req> UsersGetContextForUserParams<'req> {
pub fn new() -> Self {
Self::default()
}
/// Identifies which additional information you'd like to receive about the person's hovercard. Can be `organization`, `repository`, `issue`, `pull_request`. **Required** when using `subject_id`.
pub fn subject_type(self, subject_type: &'req str) -> Self {
Self {
subject_type: Some(subject_type),
subject_id: self.subject_id,
}
}
/// Uses the ID for the `subject_type` you specified. **Required** when using `subject_type`.
pub fn subject_id(self, subject_id: &'req str) -> Self {
Self {
subject_type: self.subject_type,
subject_id: Some(subject_id),
}
}
}
/// Query parameters for the [List users](Users::list_async()) endpoint.
#[derive(Default, Serialize)]
pub struct UsersListParams {
/// A user ID. Only return users with an ID greater than this ID.
since: Option<i32>,
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
per_page: Option<u16>
}
impl UsersListParams {
pub fn new() -> Self {
Self::default()
}
/// A user ID. Only return users with an ID greater than this ID.
pub fn since(self, since: i32) -> Self {
Self {
since: Some(since),
per_page: self.per_page,
}
}
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn per_page(self, per_page: u16) -> Self {
Self {
since: self.since,
per_page: Some(per_page),
}
}
}
/// Query parameters for the [List attestations](Users::list_attestations_async()) endpoint.
#[derive(Default, Serialize)]
pub struct UsersListAttestationsParams<'req> {
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
per_page: Option<u16>,
/// A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results before this cursor. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
before: Option<&'req str>,
/// A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results after this cursor. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
after: Option<&'req str>,
/// Optional filter for fetching attestations with a given predicate type. This option accepts `provenance`, `sbom`, or freeform text for custom predicate types.
predicate_type: Option<&'req str>
}
impl<'req> UsersListAttestationsParams<'req> {
pub fn new() -> Self {
Self::default()
}
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn per_page(self, per_page: u16) -> Self {
Self {
per_page: Some(per_page),
before: self.before,
after: self.after,
predicate_type: self.predicate_type,
}
}
/// A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results before this cursor. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn before(self, before: &'req str) -> Self {
Self {
per_page: self.per_page,
before: Some(before),
after: self.after,
predicate_type: self.predicate_type,
}
}
/// A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results after this cursor. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn after(self, after: &'req str) -> Self {
Self {
per_page: self.per_page,
before: self.before,
after: Some(after),
predicate_type: self.predicate_type,
}
}
/// Optional filter for fetching attestations with a given predicate type. This option accepts `provenance`, `sbom`, or freeform text for custom predicate types.
pub fn predicate_type(self, predicate_type: &'req str) -> Self {
Self {
per_page: self.per_page,
before: self.before,
after: self.after,
predicate_type: Some(predicate_type),
}
}
}
/// Query parameters for the [List attestations by bulk subject digests](Users::list_attestations_bulk_async()) endpoint.
#[derive(Default, Serialize)]
pub struct UsersListAttestationsBulkParams<'req> {
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
per_page: Option<u16>,
/// A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results before this cursor. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
before: Option<&'req str>,
/// A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results after this cursor. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
after: Option<&'req str>
}
impl<'req> UsersListAttestationsBulkParams<'req> {
pub fn new() -> Self {
Self::default()
}
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn per_page(self, per_page: u16) -> Self {
Self {
per_page: Some(per_page),
before: self.before,
after: self.after,
}
}
/// A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results before this cursor. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn before(self, before: &'req str) -> Self {
Self {
per_page: self.per_page,
before: Some(before),
after: self.after,
}
}
/// A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results after this cursor. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn after(self, after: &'req str) -> Self {
Self {
per_page: self.per_page,
before: self.before,
after: Some(after),
}
}
}
/// Query parameters for the [List users blocked by the authenticated user](Users::list_blocked_by_authenticated_user_async()) endpoint.
#[derive(Default, Serialize)]
pub struct UsersListBlockedByAuthenticatedUserParams {
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
per_page: Option<u16>,
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
page: Option<u16>
}
impl UsersListBlockedByAuthenticatedUserParams {
pub fn new() -> Self {
Self::default()
}
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn per_page(self, per_page: u16) -> Self {
Self {
per_page: Some(per_page),
page: self.page,
}
}
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn page(self, page: u16) -> Self {
Self {
per_page: self.per_page,
page: Some(page),
}
}
}
impl<'enc> From<&'enc PerPage> for UsersListBlockedByAuthenticatedUserParams {
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 email addresses for the authenticated user](Users::list_emails_for_authenticated_user_async()) endpoint.
#[derive(Default, Serialize)]
pub struct UsersListEmailsForAuthenticatedUserParams {
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
per_page: Option<u16>,
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
page: Option<u16>
}
impl UsersListEmailsForAuthenticatedUserParams {
pub fn new() -> Self {
Self::default()
}
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn per_page(self, per_page: u16) -> Self {
Self {
per_page: Some(per_page),
page: self.page,
}
}
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn page(self, page: u16) -> Self {
Self {
per_page: self.per_page,
page: Some(page),
}
}
}
impl<'enc> From<&'enc PerPage> for UsersListEmailsForAuthenticatedUserParams {
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 the people the authenticated user follows](Users::list_followed_by_authenticated_user_async()) endpoint.
#[derive(Default, Serialize)]
pub struct UsersListFollowedByAuthenticatedUserParams {
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
per_page: Option<u16>,
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
page: Option<u16>
}
impl UsersListFollowedByAuthenticatedUserParams {
pub fn new() -> Self {
Self::default()
}
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn per_page(self, per_page: u16) -> Self {
Self {
per_page: Some(per_page),
page: self.page,
}
}
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn page(self, page: u16) -> Self {
Self {
per_page: self.per_page,
page: Some(page),
}
}
}
impl<'enc> From<&'enc PerPage> for UsersListFollowedByAuthenticatedUserParams {
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 followers of the authenticated user](Users::list_followers_for_authenticated_user_async()) endpoint.
#[derive(Default, Serialize)]
pub struct UsersListFollowersForAuthenticatedUserParams {
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
per_page: Option<u16>,
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
page: Option<u16>
}
impl UsersListFollowersForAuthenticatedUserParams {
pub fn new() -> Self {
Self::default()
}
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn per_page(self, per_page: u16) -> Self {
Self {
per_page: Some(per_page),
page: self.page,
}
}
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn page(self, page: u16) -> Self {
Self {
per_page: self.per_page,
page: Some(page),
}
}
}
impl<'enc> From<&'enc PerPage> for UsersListFollowersForAuthenticatedUserParams {
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 followers of a user](Users::list_followers_for_user_async()) endpoint.
#[derive(Default, Serialize)]
pub struct UsersListFollowersForUserParams {
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
per_page: Option<u16>,
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
page: Option<u16>
}
impl UsersListFollowersForUserParams {
pub fn new() -> Self {
Self::default()
}
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn per_page(self, per_page: u16) -> Self {
Self {
per_page: Some(per_page),
page: self.page,
}
}
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn page(self, page: u16) -> Self {
Self {
per_page: self.per_page,
page: Some(page),
}
}
}
impl<'enc> From<&'enc PerPage> for UsersListFollowersForUserParams {
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 the people a user follows](Users::list_following_for_user_async()) endpoint.
#[derive(Default, Serialize)]
pub struct UsersListFollowingForUserParams {
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
per_page: Option<u16>,
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
page: Option<u16>
}
impl UsersListFollowingForUserParams {
pub fn new() -> Self {
Self::default()
}
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn per_page(self, per_page: u16) -> Self {
Self {
per_page: Some(per_page),
page: self.page,
}
}
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn page(self, page: u16) -> Self {
Self {
per_page: self.per_page,
page: Some(page),
}
}
}
impl<'enc> From<&'enc PerPage> for UsersListFollowingForUserParams {
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 GPG keys for the authenticated user](Users::list_gpg_keys_for_authenticated_user_async()) endpoint.
#[derive(Default, Serialize)]
pub struct UsersListGpgKeysForAuthenticatedUserParams {
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
per_page: Option<u16>,
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
page: Option<u16>
}
impl UsersListGpgKeysForAuthenticatedUserParams {
pub fn new() -> Self {
Self::default()
}
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn per_page(self, per_page: u16) -> Self {
Self {
per_page: Some(per_page),
page: self.page,
}
}
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn page(self, page: u16) -> Self {
Self {
per_page: self.per_page,
page: Some(page),
}
}
}
impl<'enc> From<&'enc PerPage> for UsersListGpgKeysForAuthenticatedUserParams {
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 GPG keys for a user](Users::list_gpg_keys_for_user_async()) endpoint.
#[derive(Default, Serialize)]
pub struct UsersListGpgKeysForUserParams {
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
per_page: Option<u16>,
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
page: Option<u16>
}
impl UsersListGpgKeysForUserParams {
pub fn new() -> Self {
Self::default()
}
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn per_page(self, per_page: u16) -> Self {
Self {
per_page: Some(per_page),
page: self.page,
}
}
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn page(self, page: u16) -> Self {
Self {
per_page: self.per_page,
page: Some(page),
}
}
}
impl<'enc> From<&'enc PerPage> for UsersListGpgKeysForUserParams {
fn from(per_page: &'enc PerPage) -> Self {
Self {
per_page: Some(per_page.per_page),
page: Some(per_page.page),
..Default::default()
}
}
}
/// Query parameters for the [List public email addresses for the authenticated user](Users::list_public_emails_for_authenticated_user_async()) endpoint.
#[derive(Default, Serialize)]
pub struct UsersListPublicEmailsForAuthenticatedUserParams {
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
per_page: Option<u16>,
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
page: Option<u16>
}
impl UsersListPublicEmailsForAuthenticatedUserParams {
pub fn new() -> Self {
Self::default()
}
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn per_page(self, per_page: u16) -> Self {
Self {
per_page: Some(per_page),
page: self.page,
}
}
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn page(self, page: u16) -> Self {
Self {
per_page: self.per_page,
page: Some(page),
}
}
}
impl<'enc> From<&'enc PerPage> for UsersListPublicEmailsForAuthenticatedUserParams {
fn from(per_page: &'enc PerPage) -> Self {
Self {
per_page: Some(per_page.per_page),
page: Some(per_page.page),
..Default::default()
}
}
}
/// Query parameters for the [List public keys for a user](Users::list_public_keys_for_user_async()) endpoint.
#[derive(Default, Serialize)]
pub struct UsersListPublicKeysForUserParams {
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
per_page: Option<u16>,
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
page: Option<u16>
}
impl UsersListPublicKeysForUserParams {
pub fn new() -> Self {
Self::default()
}
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn per_page(self, per_page: u16) -> Self {
Self {
per_page: Some(per_page),
page: self.page,
}
}
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn page(self, page: u16) -> Self {
Self {
per_page: self.per_page,
page: Some(page),
}
}
}
impl<'enc> From<&'enc PerPage> for UsersListPublicKeysForUserParams {
fn from(per_page: &'enc PerPage) -> Self {
Self {
per_page: Some(per_page.per_page),
page: Some(per_page.page),
..Default::default()
}
}
}
/// Query parameters for the [List public SSH keys for the authenticated user](Users::list_public_ssh_keys_for_authenticated_user_async()) endpoint.
#[derive(Default, Serialize)]
pub struct UsersListPublicSshKeysForAuthenticatedUserParams {
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
per_page: Option<u16>,
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
page: Option<u16>
}
impl UsersListPublicSshKeysForAuthenticatedUserParams {
pub fn new() -> Self {
Self::default()
}
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn per_page(self, per_page: u16) -> Self {
Self {
per_page: Some(per_page),
page: self.page,
}
}
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn page(self, page: u16) -> Self {
Self {
per_page: self.per_page,
page: Some(page),
}
}
}
impl<'enc> From<&'enc PerPage> for UsersListPublicSshKeysForAuthenticatedUserParams {
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 social accounts for the authenticated user](Users::list_social_accounts_for_authenticated_user_async()) endpoint.
#[derive(Default, Serialize)]
pub struct UsersListSocialAccountsForAuthenticatedUserParams {
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
per_page: Option<u16>,
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
page: Option<u16>
}
impl UsersListSocialAccountsForAuthenticatedUserParams {
pub fn new() -> Self {
Self::default()
}
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn per_page(self, per_page: u16) -> Self {
Self {
per_page: Some(per_page),
page: self.page,
}
}
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn page(self, page: u16) -> Self {
Self {
per_page: self.per_page,
page: Some(page),
}
}
}
impl<'enc> From<&'enc PerPage> for UsersListSocialAccountsForAuthenticatedUserParams {
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 social accounts for a user](Users::list_social_accounts_for_user_async()) endpoint.
#[derive(Default, Serialize)]
pub struct UsersListSocialAccountsForUserParams {
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
per_page: Option<u16>,
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
page: Option<u16>
}
impl UsersListSocialAccountsForUserParams {
pub fn new() -> Self {
Self::default()
}
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn per_page(self, per_page: u16) -> Self {
Self {
per_page: Some(per_page),
page: self.page,
}
}
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn page(self, page: u16) -> Self {
Self {
per_page: self.per_page,
page: Some(page),
}
}
}
impl<'enc> From<&'enc PerPage> for UsersListSocialAccountsForUserParams {
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 SSH signing keys for the authenticated user](Users::list_ssh_signing_keys_for_authenticated_user_async()) endpoint.
#[derive(Default, Serialize)]
pub struct UsersListSshSigningKeysForAuthenticatedUserParams {
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
per_page: Option<u16>,
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
page: Option<u16>
}
impl UsersListSshSigningKeysForAuthenticatedUserParams {
pub fn new() -> Self {
Self::default()
}
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn per_page(self, per_page: u16) -> Self {
Self {
per_page: Some(per_page),
page: self.page,
}
}
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn page(self, page: u16) -> Self {
Self {
per_page: self.per_page,
page: Some(page),
}
}
}
impl<'enc> From<&'enc PerPage> for UsersListSshSigningKeysForAuthenticatedUserParams {
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 SSH signing keys for a user](Users::list_ssh_signing_keys_for_user_async()) endpoint.
#[derive(Default, Serialize)]
pub struct UsersListSshSigningKeysForUserParams {
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
per_page: Option<u16>,
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
page: Option<u16>
}
impl UsersListSshSigningKeysForUserParams {
pub fn new() -> Self {
Self::default()
}
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn per_page(self, per_page: u16) -> Self {
Self {
per_page: Some(per_page),
page: self.page,
}
}
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn page(self, page: u16) -> Self {
Self {
per_page: self.per_page,
page: Some(page),
}
}
}
impl<'enc> From<&'enc PerPage> for UsersListSshSigningKeysForUserParams {
fn from(per_page: &'enc PerPage) -> Self {
Self {
per_page: Some(per_page.per_page),
page: Some(per_page.page),
..Default::default()
}
}
}
impl<'api, C: Client> Users<'api, C> where AdapterError: From<<C as Client>::Err> {
/// ---
///
/// # Add an email address for the authenticated user
///
/// OAuth app tokens and personal access tokens (classic) need the `user` scope to use this endpoint.
///
/// [GitHub API docs for add_email_for_authenticated_user](https://docs.github.com/rest/users/emails#add-an-email-address-for-the-authenticated-user)
///
/// ---
pub async fn add_email_for_authenticated_user_async(&self, body: PostUsersAddEmailForAuthenticatedUser) -> Result<Vec<Email>, AdapterError> {
let request_uri = format!("{}/user/emails", super::GITHUB_BASE_API_URL);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostUsersAddEmailForAuthenticatedUser>(body)?),
method: "POST",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
422 => Err(UsersAddEmailForAuthenticatedUserError::Status422(github_response.to_json_async().await?).into()),
304 => Err(UsersAddEmailForAuthenticatedUserError::Status304.into()),
404 => Err(UsersAddEmailForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()),
403 => Err(UsersAddEmailForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()),
401 => Err(UsersAddEmailForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()),
code => Err(UsersAddEmailForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Add an email address for the authenticated user
///
/// OAuth app tokens and personal access tokens (classic) need the `user` scope to use this endpoint.
///
/// [GitHub API docs for add_email_for_authenticated_user](https://docs.github.com/rest/users/emails#add-an-email-address-for-the-authenticated-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn add_email_for_authenticated_user(&self, body: PostUsersAddEmailForAuthenticatedUser) -> Result<Vec<Email>, AdapterError> {
let request_uri = format!("{}/user/emails", super::GITHUB_BASE_API_URL);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostUsersAddEmailForAuthenticatedUser>(body)?),
method: "POST",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
422 => Err(UsersAddEmailForAuthenticatedUserError::Status422(github_response.to_json()?).into()),
304 => Err(UsersAddEmailForAuthenticatedUserError::Status304.into()),
404 => Err(UsersAddEmailForAuthenticatedUserError::Status404(github_response.to_json()?).into()),
403 => Err(UsersAddEmailForAuthenticatedUserError::Status403(github_response.to_json()?).into()),
401 => Err(UsersAddEmailForAuthenticatedUserError::Status401(github_response.to_json()?).into()),
code => Err(UsersAddEmailForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Add social accounts for the authenticated user
///
/// Add one or more social accounts to the authenticated user's profile.
///
/// OAuth app tokens and personal access tokens (classic) need the `user` scope to use this endpoint.
///
/// [GitHub API docs for add_social_account_for_authenticated_user](https://docs.github.com/rest/users/social-accounts#add-social-accounts-for-the-authenticated-user)
///
/// ---
pub async fn add_social_account_for_authenticated_user_async(&self, body: PostUsersAddSocialAccountForAuthenticatedUser) -> Result<Vec<SocialAccount>, AdapterError> {
let request_uri = format!("{}/user/social_accounts", super::GITHUB_BASE_API_URL);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostUsersAddSocialAccountForAuthenticatedUser>(body)?),
method: "POST",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
422 => Err(UsersAddSocialAccountForAuthenticatedUserError::Status422(github_response.to_json_async().await?).into()),
304 => Err(UsersAddSocialAccountForAuthenticatedUserError::Status304.into()),
404 => Err(UsersAddSocialAccountForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()),
403 => Err(UsersAddSocialAccountForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()),
401 => Err(UsersAddSocialAccountForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()),
code => Err(UsersAddSocialAccountForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Add social accounts for the authenticated user
///
/// Add one or more social accounts to the authenticated user's profile.
///
/// OAuth app tokens and personal access tokens (classic) need the `user` scope to use this endpoint.
///
/// [GitHub API docs for add_social_account_for_authenticated_user](https://docs.github.com/rest/users/social-accounts#add-social-accounts-for-the-authenticated-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn add_social_account_for_authenticated_user(&self, body: PostUsersAddSocialAccountForAuthenticatedUser) -> Result<Vec<SocialAccount>, AdapterError> {
let request_uri = format!("{}/user/social_accounts", super::GITHUB_BASE_API_URL);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostUsersAddSocialAccountForAuthenticatedUser>(body)?),
method: "POST",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
422 => Err(UsersAddSocialAccountForAuthenticatedUserError::Status422(github_response.to_json()?).into()),
304 => Err(UsersAddSocialAccountForAuthenticatedUserError::Status304.into()),
404 => Err(UsersAddSocialAccountForAuthenticatedUserError::Status404(github_response.to_json()?).into()),
403 => Err(UsersAddSocialAccountForAuthenticatedUserError::Status403(github_response.to_json()?).into()),
401 => Err(UsersAddSocialAccountForAuthenticatedUserError::Status401(github_response.to_json()?).into()),
code => Err(UsersAddSocialAccountForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Block a user
///
/// Blocks the given user and returns a 204. If the authenticated user cannot block the given user a 422 is returned.
///
/// [GitHub API docs for block](https://docs.github.com/rest/users/blocking#block-a-user)
///
/// ---
pub async fn block_async(&self, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/user/blocks/{}", super::GITHUB_BASE_API_URL, username);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "PUT",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
304 => Err(UsersBlockError::Status304.into()),
404 => Err(UsersBlockError::Status404(github_response.to_json_async().await?).into()),
403 => Err(UsersBlockError::Status403(github_response.to_json_async().await?).into()),
401 => Err(UsersBlockError::Status401(github_response.to_json_async().await?).into()),
422 => Err(UsersBlockError::Status422(github_response.to_json_async().await?).into()),
code => Err(UsersBlockError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Block a user
///
/// Blocks the given user and returns a 204. If the authenticated user cannot block the given user a 422 is returned.
///
/// [GitHub API docs for block](https://docs.github.com/rest/users/blocking#block-a-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn block(&self, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/user/blocks/{}", super::GITHUB_BASE_API_URL, username);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "PUT",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
304 => Err(UsersBlockError::Status304.into()),
404 => Err(UsersBlockError::Status404(github_response.to_json()?).into()),
403 => Err(UsersBlockError::Status403(github_response.to_json()?).into()),
401 => Err(UsersBlockError::Status401(github_response.to_json()?).into()),
422 => Err(UsersBlockError::Status422(github_response.to_json()?).into()),
code => Err(UsersBlockError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Check if a user is blocked by the authenticated user
///
/// Returns a 204 if the given user is blocked by the authenticated user. Returns a 404 if the given user is not blocked by the authenticated user, or if the given user account has been identified as spam by GitHub.
///
/// [GitHub API docs for check_blocked](https://docs.github.com/rest/users/blocking#check-if-a-user-is-blocked-by-the-authenticated-user)
///
/// ---
pub async fn check_blocked_async(&self, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/user/blocks/{}", 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(())
} else {
match github_response.status_code() {
404 => Err(UsersCheckBlockedError::Status404(github_response.to_json_async().await?).into()),
304 => Err(UsersCheckBlockedError::Status304.into()),
403 => Err(UsersCheckBlockedError::Status403(github_response.to_json_async().await?).into()),
401 => Err(UsersCheckBlockedError::Status401(github_response.to_json_async().await?).into()),
code => Err(UsersCheckBlockedError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Check if a user is blocked by the authenticated user
///
/// Returns a 204 if the given user is blocked by the authenticated user. Returns a 404 if the given user is not blocked by the authenticated user, or if the given user account has been identified as spam by GitHub.
///
/// [GitHub API docs for check_blocked](https://docs.github.com/rest/users/blocking#check-if-a-user-is-blocked-by-the-authenticated-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn check_blocked(&self, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/user/blocks/{}", 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(())
} else {
match github_response.status_code() {
404 => Err(UsersCheckBlockedError::Status404(github_response.to_json()?).into()),
304 => Err(UsersCheckBlockedError::Status304.into()),
403 => Err(UsersCheckBlockedError::Status403(github_response.to_json()?).into()),
401 => Err(UsersCheckBlockedError::Status401(github_response.to_json()?).into()),
code => Err(UsersCheckBlockedError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Check if a user follows another user
///
/// [GitHub API docs for check_following_for_user](https://docs.github.com/rest/users/followers#check-if-a-user-follows-another-user)
///
/// ---
pub async fn check_following_for_user_async(&self, username: &str, target_user: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/users/{}/following/{}", super::GITHUB_BASE_API_URL, username, target_user);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
404 => Err(UsersCheckFollowingForUserError::Status404.into()),
code => Err(UsersCheckFollowingForUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Check if a user follows another user
///
/// [GitHub API docs for check_following_for_user](https://docs.github.com/rest/users/followers#check-if-a-user-follows-another-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn check_following_for_user(&self, username: &str, target_user: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/users/{}/following/{}", super::GITHUB_BASE_API_URL, username, target_user);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
404 => Err(UsersCheckFollowingForUserError::Status404.into()),
code => Err(UsersCheckFollowingForUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Check if a person is followed by the authenticated user
///
/// [GitHub API docs for check_person_is_followed_by_authenticated](https://docs.github.com/rest/users/followers#check-if-a-person-is-followed-by-the-authenticated-user)
///
/// ---
pub async fn check_person_is_followed_by_authenticated_async(&self, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/user/following/{}", 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(())
} else {
match github_response.status_code() {
404 => Err(UsersCheckPersonIsFollowedByAuthenticatedError::Status404(github_response.to_json_async().await?).into()),
304 => Err(UsersCheckPersonIsFollowedByAuthenticatedError::Status304.into()),
403 => Err(UsersCheckPersonIsFollowedByAuthenticatedError::Status403(github_response.to_json_async().await?).into()),
401 => Err(UsersCheckPersonIsFollowedByAuthenticatedError::Status401(github_response.to_json_async().await?).into()),
code => Err(UsersCheckPersonIsFollowedByAuthenticatedError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Check if a person is followed by the authenticated user
///
/// [GitHub API docs for check_person_is_followed_by_authenticated](https://docs.github.com/rest/users/followers#check-if-a-person-is-followed-by-the-authenticated-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn check_person_is_followed_by_authenticated(&self, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/user/following/{}", 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(())
} else {
match github_response.status_code() {
404 => Err(UsersCheckPersonIsFollowedByAuthenticatedError::Status404(github_response.to_json()?).into()),
304 => Err(UsersCheckPersonIsFollowedByAuthenticatedError::Status304.into()),
403 => Err(UsersCheckPersonIsFollowedByAuthenticatedError::Status403(github_response.to_json()?).into()),
401 => Err(UsersCheckPersonIsFollowedByAuthenticatedError::Status401(github_response.to_json()?).into()),
code => Err(UsersCheckPersonIsFollowedByAuthenticatedError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a GPG key for the authenticated user
///
/// Adds a GPG key to the authenticated user's GitHub account.
///
/// OAuth app tokens and personal access tokens (classic) need the `write:gpg_key` scope to use this endpoint.
///
/// [GitHub API docs for create_gpg_key_for_authenticated_user](https://docs.github.com/rest/users/gpg-keys#create-a-gpg-key-for-the-authenticated-user)
///
/// ---
pub async fn create_gpg_key_for_authenticated_user_async(&self, body: PostUsersCreateGpgKeyForAuthenticatedUser) -> Result<GpgKey, AdapterError> {
let request_uri = format!("{}/user/gpg_keys", super::GITHUB_BASE_API_URL);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostUsersCreateGpgKeyForAuthenticatedUser>(body)?),
method: "POST",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
422 => Err(UsersCreateGpgKeyForAuthenticatedUserError::Status422(github_response.to_json_async().await?).into()),
304 => Err(UsersCreateGpgKeyForAuthenticatedUserError::Status304.into()),
404 => Err(UsersCreateGpgKeyForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()),
403 => Err(UsersCreateGpgKeyForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()),
401 => Err(UsersCreateGpgKeyForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()),
code => Err(UsersCreateGpgKeyForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a GPG key for the authenticated user
///
/// Adds a GPG key to the authenticated user's GitHub account.
///
/// OAuth app tokens and personal access tokens (classic) need the `write:gpg_key` scope to use this endpoint.
///
/// [GitHub API docs for create_gpg_key_for_authenticated_user](https://docs.github.com/rest/users/gpg-keys#create-a-gpg-key-for-the-authenticated-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn create_gpg_key_for_authenticated_user(&self, body: PostUsersCreateGpgKeyForAuthenticatedUser) -> Result<GpgKey, AdapterError> {
let request_uri = format!("{}/user/gpg_keys", super::GITHUB_BASE_API_URL);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostUsersCreateGpgKeyForAuthenticatedUser>(body)?),
method: "POST",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
422 => Err(UsersCreateGpgKeyForAuthenticatedUserError::Status422(github_response.to_json()?).into()),
304 => Err(UsersCreateGpgKeyForAuthenticatedUserError::Status304.into()),
404 => Err(UsersCreateGpgKeyForAuthenticatedUserError::Status404(github_response.to_json()?).into()),
403 => Err(UsersCreateGpgKeyForAuthenticatedUserError::Status403(github_response.to_json()?).into()),
401 => Err(UsersCreateGpgKeyForAuthenticatedUserError::Status401(github_response.to_json()?).into()),
code => Err(UsersCreateGpgKeyForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a public SSH key for the authenticated user
///
/// Adds a public SSH key to the authenticated user's GitHub account.
///
/// OAuth app tokens and personal access tokens (classic) need the `write:gpg_key` scope to use this endpoint.
///
/// [GitHub API docs for create_public_ssh_key_for_authenticated_user](https://docs.github.com/rest/users/keys#create-a-public-ssh-key-for-the-authenticated-user)
///
/// ---
pub async fn create_public_ssh_key_for_authenticated_user_async(&self, body: PostUsersCreatePublicSshKeyForAuthenticatedUser) -> Result<Key, AdapterError> {
let request_uri = format!("{}/user/keys", super::GITHUB_BASE_API_URL);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostUsersCreatePublicSshKeyForAuthenticatedUser>(body)?),
method: "POST",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
422 => Err(UsersCreatePublicSshKeyForAuthenticatedUserError::Status422(github_response.to_json_async().await?).into()),
304 => Err(UsersCreatePublicSshKeyForAuthenticatedUserError::Status304.into()),
404 => Err(UsersCreatePublicSshKeyForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()),
403 => Err(UsersCreatePublicSshKeyForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()),
401 => Err(UsersCreatePublicSshKeyForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()),
code => Err(UsersCreatePublicSshKeyForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a public SSH key for the authenticated user
///
/// Adds a public SSH key to the authenticated user's GitHub account.
///
/// OAuth app tokens and personal access tokens (classic) need the `write:gpg_key` scope to use this endpoint.
///
/// [GitHub API docs for create_public_ssh_key_for_authenticated_user](https://docs.github.com/rest/users/keys#create-a-public-ssh-key-for-the-authenticated-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn create_public_ssh_key_for_authenticated_user(&self, body: PostUsersCreatePublicSshKeyForAuthenticatedUser) -> Result<Key, AdapterError> {
let request_uri = format!("{}/user/keys", super::GITHUB_BASE_API_URL);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostUsersCreatePublicSshKeyForAuthenticatedUser>(body)?),
method: "POST",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
422 => Err(UsersCreatePublicSshKeyForAuthenticatedUserError::Status422(github_response.to_json()?).into()),
304 => Err(UsersCreatePublicSshKeyForAuthenticatedUserError::Status304.into()),
404 => Err(UsersCreatePublicSshKeyForAuthenticatedUserError::Status404(github_response.to_json()?).into()),
403 => Err(UsersCreatePublicSshKeyForAuthenticatedUserError::Status403(github_response.to_json()?).into()),
401 => Err(UsersCreatePublicSshKeyForAuthenticatedUserError::Status401(github_response.to_json()?).into()),
code => Err(UsersCreatePublicSshKeyForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a SSH signing key for the authenticated user
///
/// Creates an SSH signing key for the authenticated user's GitHub account.
///
/// OAuth app tokens and personal access tokens (classic) need the `write:ssh_signing_key` scope to use this endpoint.
///
/// [GitHub API docs for create_ssh_signing_key_for_authenticated_user](https://docs.github.com/rest/users/ssh-signing-keys#create-a-ssh-signing-key-for-the-authenticated-user)
///
/// ---
pub async fn create_ssh_signing_key_for_authenticated_user_async(&self, body: PostUsersCreateSshSigningKeyForAuthenticatedUser) -> Result<SshSigningKey, AdapterError> {
let request_uri = format!("{}/user/ssh_signing_keys", super::GITHUB_BASE_API_URL);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostUsersCreateSshSigningKeyForAuthenticatedUser>(body)?),
method: "POST",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
422 => Err(UsersCreateSshSigningKeyForAuthenticatedUserError::Status422(github_response.to_json_async().await?).into()),
304 => Err(UsersCreateSshSigningKeyForAuthenticatedUserError::Status304.into()),
404 => Err(UsersCreateSshSigningKeyForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()),
403 => Err(UsersCreateSshSigningKeyForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()),
401 => Err(UsersCreateSshSigningKeyForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()),
code => Err(UsersCreateSshSigningKeyForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a SSH signing key for the authenticated user
///
/// Creates an SSH signing key for the authenticated user's GitHub account.
///
/// OAuth app tokens and personal access tokens (classic) need the `write:ssh_signing_key` scope to use this endpoint.
///
/// [GitHub API docs for create_ssh_signing_key_for_authenticated_user](https://docs.github.com/rest/users/ssh-signing-keys#create-a-ssh-signing-key-for-the-authenticated-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn create_ssh_signing_key_for_authenticated_user(&self, body: PostUsersCreateSshSigningKeyForAuthenticatedUser) -> Result<SshSigningKey, AdapterError> {
let request_uri = format!("{}/user/ssh_signing_keys", super::GITHUB_BASE_API_URL);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostUsersCreateSshSigningKeyForAuthenticatedUser>(body)?),
method: "POST",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
422 => Err(UsersCreateSshSigningKeyForAuthenticatedUserError::Status422(github_response.to_json()?).into()),
304 => Err(UsersCreateSshSigningKeyForAuthenticatedUserError::Status304.into()),
404 => Err(UsersCreateSshSigningKeyForAuthenticatedUserError::Status404(github_response.to_json()?).into()),
403 => Err(UsersCreateSshSigningKeyForAuthenticatedUserError::Status403(github_response.to_json()?).into()),
401 => Err(UsersCreateSshSigningKeyForAuthenticatedUserError::Status401(github_response.to_json()?).into()),
code => Err(UsersCreateSshSigningKeyForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete attestations in bulk
///
/// Delete artifact attestations in bulk by either subject digests or unique ID.
///
/// [GitHub API docs for delete_attestations_bulk](https://docs.github.com/rest/users/attestations#delete-attestations-in-bulk)
///
/// ---
pub async fn delete_attestations_bulk_async(&self, username: &str, body: PostUsersDeleteAttestationsBulk) -> Result<(), AdapterError> {
let request_uri = format!("{}/users/{}/attestations/delete-request", super::GITHUB_BASE_API_URL, username);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostUsersDeleteAttestationsBulk>(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(UsersDeleteAttestationsBulkError::Status404(github_response.to_json_async().await?).into()),
code => Err(UsersDeleteAttestationsBulkError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete attestations in bulk
///
/// Delete artifact attestations in bulk by either subject digests or unique ID.
///
/// [GitHub API docs for delete_attestations_bulk](https://docs.github.com/rest/users/attestations#delete-attestations-in-bulk)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete_attestations_bulk(&self, username: &str, body: PostUsersDeleteAttestationsBulk) -> Result<(), AdapterError> {
let request_uri = format!("{}/users/{}/attestations/delete-request", super::GITHUB_BASE_API_URL, username);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostUsersDeleteAttestationsBulk>(body)?),
method: "POST",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
404 => Err(UsersDeleteAttestationsBulkError::Status404(github_response.to_json()?).into()),
code => Err(UsersDeleteAttestationsBulkError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete attestations by ID
///
/// Delete an artifact attestation by unique ID that is associated with a repository owned by a user.
///
/// [GitHub API docs for delete_attestations_by_id](https://docs.github.com/rest/users/attestations#delete-attestations-by-id)
///
/// ---
pub async fn delete_attestations_by_id_async(&self, username: &str, attestation_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/users/{}/attestations/{}", super::GITHUB_BASE_API_URL, username, attestation_id);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
204 => Err(UsersDeleteAttestationsByIdError::Status204.into()),
403 => Err(UsersDeleteAttestationsByIdError::Status403(github_response.to_json_async().await?).into()),
404 => Err(UsersDeleteAttestationsByIdError::Status404(github_response.to_json_async().await?).into()),
code => Err(UsersDeleteAttestationsByIdError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete attestations by ID
///
/// Delete an artifact attestation by unique ID that is associated with a repository owned by a user.
///
/// [GitHub API docs for delete_attestations_by_id](https://docs.github.com/rest/users/attestations#delete-attestations-by-id)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete_attestations_by_id(&self, username: &str, attestation_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/users/{}/attestations/{}", super::GITHUB_BASE_API_URL, username, attestation_id);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
204 => Err(UsersDeleteAttestationsByIdError::Status204.into()),
403 => Err(UsersDeleteAttestationsByIdError::Status403(github_response.to_json()?).into()),
404 => Err(UsersDeleteAttestationsByIdError::Status404(github_response.to_json()?).into()),
code => Err(UsersDeleteAttestationsByIdError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete attestations by subject digest
///
/// Delete an artifact attestation by subject digest.
///
/// [GitHub API docs for delete_attestations_by_subject_digest](https://docs.github.com/rest/users/attestations#delete-attestations-by-subject-digest)
///
/// ---
pub async fn delete_attestations_by_subject_digest_async(&self, username: &str, subject_digest: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/users/{}/attestations/digest/{}", super::GITHUB_BASE_API_URL, username, subject_digest);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
204 => Err(UsersDeleteAttestationsBySubjectDigestError::Status204.into()),
404 => Err(UsersDeleteAttestationsBySubjectDigestError::Status404(github_response.to_json_async().await?).into()),
code => Err(UsersDeleteAttestationsBySubjectDigestError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete attestations by subject digest
///
/// Delete an artifact attestation by subject digest.
///
/// [GitHub API docs for delete_attestations_by_subject_digest](https://docs.github.com/rest/users/attestations#delete-attestations-by-subject-digest)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete_attestations_by_subject_digest(&self, username: &str, subject_digest: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/users/{}/attestations/digest/{}", super::GITHUB_BASE_API_URL, username, subject_digest);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
204 => Err(UsersDeleteAttestationsBySubjectDigestError::Status204.into()),
404 => Err(UsersDeleteAttestationsBySubjectDigestError::Status404(github_response.to_json()?).into()),
code => Err(UsersDeleteAttestationsBySubjectDigestError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete an email address for the authenticated user
///
/// OAuth app tokens and personal access tokens (classic) need the `user` scope to use this endpoint.
///
/// [GitHub API docs for delete_email_for_authenticated_user](https://docs.github.com/rest/users/emails#delete-an-email-address-for-the-authenticated-user)
///
/// ---
pub async fn delete_email_for_authenticated_user_async(&self, body: DeleteUsersDeleteEmailForAuthenticatedUser) -> Result<(), AdapterError> {
let request_uri = format!("{}/user/emails", super::GITHUB_BASE_API_URL);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<DeleteUsersDeleteEmailForAuthenticatedUser>(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() {
304 => Err(UsersDeleteEmailForAuthenticatedUserError::Status304.into()),
404 => Err(UsersDeleteEmailForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()),
403 => Err(UsersDeleteEmailForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()),
401 => Err(UsersDeleteEmailForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()),
422 => Err(UsersDeleteEmailForAuthenticatedUserError::Status422(github_response.to_json_async().await?).into()),
code => Err(UsersDeleteEmailForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete an email address for the authenticated user
///
/// OAuth app tokens and personal access tokens (classic) need the `user` scope to use this endpoint.
///
/// [GitHub API docs for delete_email_for_authenticated_user](https://docs.github.com/rest/users/emails#delete-an-email-address-for-the-authenticated-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete_email_for_authenticated_user(&self, body: DeleteUsersDeleteEmailForAuthenticatedUser) -> Result<(), AdapterError> {
let request_uri = format!("{}/user/emails", super::GITHUB_BASE_API_URL);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<DeleteUsersDeleteEmailForAuthenticatedUser>(body)?),
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() {
304 => Err(UsersDeleteEmailForAuthenticatedUserError::Status304.into()),
404 => Err(UsersDeleteEmailForAuthenticatedUserError::Status404(github_response.to_json()?).into()),
403 => Err(UsersDeleteEmailForAuthenticatedUserError::Status403(github_response.to_json()?).into()),
401 => Err(UsersDeleteEmailForAuthenticatedUserError::Status401(github_response.to_json()?).into()),
422 => Err(UsersDeleteEmailForAuthenticatedUserError::Status422(github_response.to_json()?).into()),
code => Err(UsersDeleteEmailForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a GPG key for the authenticated user
///
/// Removes a GPG key from the authenticated user's GitHub account.
///
/// OAuth app tokens and personal access tokens (classic) need the `admin:gpg_key` scope to use this endpoint.
///
/// [GitHub API docs for delete_gpg_key_for_authenticated_user](https://docs.github.com/rest/users/gpg-keys#delete-a-gpg-key-for-the-authenticated-user)
///
/// ---
pub async fn delete_gpg_key_for_authenticated_user_async(&self, gpg_key_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/user/gpg_keys/{}", super::GITHUB_BASE_API_URL, gpg_key_id);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
404 => Err(UsersDeleteGpgKeyForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()),
422 => Err(UsersDeleteGpgKeyForAuthenticatedUserError::Status422(github_response.to_json_async().await?).into()),
304 => Err(UsersDeleteGpgKeyForAuthenticatedUserError::Status304.into()),
403 => Err(UsersDeleteGpgKeyForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()),
401 => Err(UsersDeleteGpgKeyForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()),
code => Err(UsersDeleteGpgKeyForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a GPG key for the authenticated user
///
/// Removes a GPG key from the authenticated user's GitHub account.
///
/// OAuth app tokens and personal access tokens (classic) need the `admin:gpg_key` scope to use this endpoint.
///
/// [GitHub API docs for delete_gpg_key_for_authenticated_user](https://docs.github.com/rest/users/gpg-keys#delete-a-gpg-key-for-the-authenticated-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete_gpg_key_for_authenticated_user(&self, gpg_key_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/user/gpg_keys/{}", super::GITHUB_BASE_API_URL, gpg_key_id);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
404 => Err(UsersDeleteGpgKeyForAuthenticatedUserError::Status404(github_response.to_json()?).into()),
422 => Err(UsersDeleteGpgKeyForAuthenticatedUserError::Status422(github_response.to_json()?).into()),
304 => Err(UsersDeleteGpgKeyForAuthenticatedUserError::Status304.into()),
403 => Err(UsersDeleteGpgKeyForAuthenticatedUserError::Status403(github_response.to_json()?).into()),
401 => Err(UsersDeleteGpgKeyForAuthenticatedUserError::Status401(github_response.to_json()?).into()),
code => Err(UsersDeleteGpgKeyForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a public SSH key for the authenticated user
///
/// Removes a public SSH key from the authenticated user's GitHub account.
///
/// OAuth app tokens and personal access tokens (classic) need the `admin:public_key` scope to use this endpoint.
///
/// [GitHub API docs for delete_public_ssh_key_for_authenticated_user](https://docs.github.com/rest/users/keys#delete-a-public-ssh-key-for-the-authenticated-user)
///
/// ---
pub async fn delete_public_ssh_key_for_authenticated_user_async(&self, key_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/user/keys/{}", super::GITHUB_BASE_API_URL, key_id);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
304 => Err(UsersDeletePublicSshKeyForAuthenticatedUserError::Status304.into()),
404 => Err(UsersDeletePublicSshKeyForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()),
403 => Err(UsersDeletePublicSshKeyForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()),
401 => Err(UsersDeletePublicSshKeyForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()),
code => Err(UsersDeletePublicSshKeyForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a public SSH key for the authenticated user
///
/// Removes a public SSH key from the authenticated user's GitHub account.
///
/// OAuth app tokens and personal access tokens (classic) need the `admin:public_key` scope to use this endpoint.
///
/// [GitHub API docs for delete_public_ssh_key_for_authenticated_user](https://docs.github.com/rest/users/keys#delete-a-public-ssh-key-for-the-authenticated-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete_public_ssh_key_for_authenticated_user(&self, key_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/user/keys/{}", super::GITHUB_BASE_API_URL, key_id);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
304 => Err(UsersDeletePublicSshKeyForAuthenticatedUserError::Status304.into()),
404 => Err(UsersDeletePublicSshKeyForAuthenticatedUserError::Status404(github_response.to_json()?).into()),
403 => Err(UsersDeletePublicSshKeyForAuthenticatedUserError::Status403(github_response.to_json()?).into()),
401 => Err(UsersDeletePublicSshKeyForAuthenticatedUserError::Status401(github_response.to_json()?).into()),
code => Err(UsersDeletePublicSshKeyForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete social accounts for the authenticated user
///
/// Deletes one or more social accounts from the authenticated user's profile.
///
/// OAuth app tokens and personal access tokens (classic) need the `user` scope to use this endpoint.
///
/// [GitHub API docs for delete_social_account_for_authenticated_user](https://docs.github.com/rest/users/social-accounts#delete-social-accounts-for-the-authenticated-user)
///
/// ---
pub async fn delete_social_account_for_authenticated_user_async(&self, body: DeleteUsersDeleteSocialAccountForAuthenticatedUser) -> Result<(), AdapterError> {
let request_uri = format!("{}/user/social_accounts", super::GITHUB_BASE_API_URL);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<DeleteUsersDeleteSocialAccountForAuthenticatedUser>(body)?),
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
422 => Err(UsersDeleteSocialAccountForAuthenticatedUserError::Status422(github_response.to_json_async().await?).into()),
304 => Err(UsersDeleteSocialAccountForAuthenticatedUserError::Status304.into()),
404 => Err(UsersDeleteSocialAccountForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()),
403 => Err(UsersDeleteSocialAccountForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()),
401 => Err(UsersDeleteSocialAccountForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()),
code => Err(UsersDeleteSocialAccountForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete social accounts for the authenticated user
///
/// Deletes one or more social accounts from the authenticated user's profile.
///
/// OAuth app tokens and personal access tokens (classic) need the `user` scope to use this endpoint.
///
/// [GitHub API docs for delete_social_account_for_authenticated_user](https://docs.github.com/rest/users/social-accounts#delete-social-accounts-for-the-authenticated-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete_social_account_for_authenticated_user(&self, body: DeleteUsersDeleteSocialAccountForAuthenticatedUser) -> Result<(), AdapterError> {
let request_uri = format!("{}/user/social_accounts", super::GITHUB_BASE_API_URL);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<DeleteUsersDeleteSocialAccountForAuthenticatedUser>(body)?),
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
422 => Err(UsersDeleteSocialAccountForAuthenticatedUserError::Status422(github_response.to_json()?).into()),
304 => Err(UsersDeleteSocialAccountForAuthenticatedUserError::Status304.into()),
404 => Err(UsersDeleteSocialAccountForAuthenticatedUserError::Status404(github_response.to_json()?).into()),
403 => Err(UsersDeleteSocialAccountForAuthenticatedUserError::Status403(github_response.to_json()?).into()),
401 => Err(UsersDeleteSocialAccountForAuthenticatedUserError::Status401(github_response.to_json()?).into()),
code => Err(UsersDeleteSocialAccountForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete an SSH signing key for the authenticated user
///
/// Deletes an SSH signing key from the authenticated user's GitHub account.
///
/// OAuth app tokens and personal access tokens (classic) need the `admin:ssh_signing_key` scope to use this endpoint.
///
/// [GitHub API docs for delete_ssh_signing_key_for_authenticated_user](https://docs.github.com/rest/users/ssh-signing-keys#delete-an-ssh-signing-key-for-the-authenticated-user)
///
/// ---
pub async fn delete_ssh_signing_key_for_authenticated_user_async(&self, ssh_signing_key_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/user/ssh_signing_keys/{}", super::GITHUB_BASE_API_URL, ssh_signing_key_id);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
304 => Err(UsersDeleteSshSigningKeyForAuthenticatedUserError::Status304.into()),
404 => Err(UsersDeleteSshSigningKeyForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()),
403 => Err(UsersDeleteSshSigningKeyForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()),
401 => Err(UsersDeleteSshSigningKeyForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()),
code => Err(UsersDeleteSshSigningKeyForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete an SSH signing key for the authenticated user
///
/// Deletes an SSH signing key from the authenticated user's GitHub account.
///
/// OAuth app tokens and personal access tokens (classic) need the `admin:ssh_signing_key` scope to use this endpoint.
///
/// [GitHub API docs for delete_ssh_signing_key_for_authenticated_user](https://docs.github.com/rest/users/ssh-signing-keys#delete-an-ssh-signing-key-for-the-authenticated-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete_ssh_signing_key_for_authenticated_user(&self, ssh_signing_key_id: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/user/ssh_signing_keys/{}", super::GITHUB_BASE_API_URL, ssh_signing_key_id);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
304 => Err(UsersDeleteSshSigningKeyForAuthenticatedUserError::Status304.into()),
404 => Err(UsersDeleteSshSigningKeyForAuthenticatedUserError::Status404(github_response.to_json()?).into()),
403 => Err(UsersDeleteSshSigningKeyForAuthenticatedUserError::Status403(github_response.to_json()?).into()),
401 => Err(UsersDeleteSshSigningKeyForAuthenticatedUserError::Status401(github_response.to_json()?).into()),
code => Err(UsersDeleteSshSigningKeyForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Follow a user
///
/// Note that you'll need to set `Content-Length` to zero when calling out to this endpoint. For more information, see "[HTTP verbs](https://docs.github.com/rest/guides/getting-started-with-the-rest-api#http-method)."
///
/// OAuth app tokens and personal access tokens (classic) need the `user:follow` scope to use this endpoint.
///
/// [GitHub API docs for follow](https://docs.github.com/rest/users/followers#follow-a-user)
///
/// ---
pub async fn follow_async(&self, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/user/following/{}", super::GITHUB_BASE_API_URL, username);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "PUT",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
304 => Err(UsersFollowError::Status304.into()),
404 => Err(UsersFollowError::Status404(github_response.to_json_async().await?).into()),
403 => Err(UsersFollowError::Status403(github_response.to_json_async().await?).into()),
401 => Err(UsersFollowError::Status401(github_response.to_json_async().await?).into()),
422 => Err(UsersFollowError::Status422(github_response.to_json_async().await?).into()),
code => Err(UsersFollowError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Follow a user
///
/// Note that you'll need to set `Content-Length` to zero when calling out to this endpoint. For more information, see "[HTTP verbs](https://docs.github.com/rest/guides/getting-started-with-the-rest-api#http-method)."
///
/// OAuth app tokens and personal access tokens (classic) need the `user:follow` scope to use this endpoint.
///
/// [GitHub API docs for follow](https://docs.github.com/rest/users/followers#follow-a-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn follow(&self, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/user/following/{}", super::GITHUB_BASE_API_URL, username);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "PUT",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
304 => Err(UsersFollowError::Status304.into()),
404 => Err(UsersFollowError::Status404(github_response.to_json()?).into()),
403 => Err(UsersFollowError::Status403(github_response.to_json()?).into()),
401 => Err(UsersFollowError::Status401(github_response.to_json()?).into()),
422 => Err(UsersFollowError::Status422(github_response.to_json()?).into()),
code => Err(UsersFollowError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get the authenticated user
///
/// OAuth app tokens and personal access tokens (classic) need the `user` scope in order for the response to include private profile information.
///
/// [GitHub API docs for get_authenticated](https://docs.github.com/rest/users/users#get-the-authenticated-user)
///
/// ---
pub async fn get_authenticated_async(&self) -> Result<GetUsersGetByUsernameResponse200, AdapterError> {
let request_uri = format!("{}/user", 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() {
304 => Err(UsersGetAuthenticatedError::Status304.into()),
403 => Err(UsersGetAuthenticatedError::Status403(github_response.to_json_async().await?).into()),
401 => Err(UsersGetAuthenticatedError::Status401(github_response.to_json_async().await?).into()),
code => Err(UsersGetAuthenticatedError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get the authenticated user
///
/// OAuth app tokens and personal access tokens (classic) need the `user` scope in order for the response to include private profile information.
///
/// [GitHub API docs for get_authenticated](https://docs.github.com/rest/users/users#get-the-authenticated-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_authenticated(&self) -> Result<GetUsersGetByUsernameResponse200, AdapterError> {
let request_uri = format!("{}/user", 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() {
304 => Err(UsersGetAuthenticatedError::Status304.into()),
403 => Err(UsersGetAuthenticatedError::Status403(github_response.to_json()?).into()),
401 => Err(UsersGetAuthenticatedError::Status401(github_response.to_json()?).into()),
code => Err(UsersGetAuthenticatedError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a user using their ID
///
/// Provides publicly available information about someone with a GitHub account. This method takes their durable user `ID` instead of their `login`, which can change over time.
///
/// If you are requesting information about an [Enterprise Managed User](https://docs.github.com/enterprise-cloud@latest/admin/managing-iam/understanding-iam-for-enterprises/about-enterprise-managed-users), or a GitHub App bot that is installed in an organization that uses Enterprise Managed Users, your requests must be authenticated as a user or GitHub App that has access to the organization to view that account's information. If you are not authorized, the request will return a `404 Not Found` status.
///
/// The `email` key in the following response is the publicly visible email address from your GitHub [profile page](https://github.com/settings/profile). When setting up your profile, you can select a primary email address to be public which provides an email entry for this endpoint. If you do not set a public email address for `email`, then it will have a value of `null`. You only see publicly visible email addresses when authenticated with GitHub. For more information, see [Authentication](https://docs.github.com/rest/guides/getting-started-with-the-rest-api#authentication).
///
/// The Emails API enables you to list all of your email addresses, and toggle a primary email to be visible publicly. For more information, see [Emails API](https://docs.github.com/rest/users/emails).
///
/// [GitHub API docs for get_by_id](https://docs.github.com/rest/users/users#get-a-user-using-their-id)
///
/// ---
pub async fn get_by_id_async(&self, account_id: i32) -> Result<GetUsersGetByUsernameResponse200, AdapterError> {
let request_uri = format!("{}/user/{}", super::GITHUB_BASE_API_URL, account_id);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
404 => Err(UsersGetByIdError::Status404(github_response.to_json_async().await?).into()),
code => Err(UsersGetByIdError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a user using their ID
///
/// Provides publicly available information about someone with a GitHub account. This method takes their durable user `ID` instead of their `login`, which can change over time.
///
/// If you are requesting information about an [Enterprise Managed User](https://docs.github.com/enterprise-cloud@latest/admin/managing-iam/understanding-iam-for-enterprises/about-enterprise-managed-users), or a GitHub App bot that is installed in an organization that uses Enterprise Managed Users, your requests must be authenticated as a user or GitHub App that has access to the organization to view that account's information. If you are not authorized, the request will return a `404 Not Found` status.
///
/// The `email` key in the following response is the publicly visible email address from your GitHub [profile page](https://github.com/settings/profile). When setting up your profile, you can select a primary email address to be public which provides an email entry for this endpoint. If you do not set a public email address for `email`, then it will have a value of `null`. You only see publicly visible email addresses when authenticated with GitHub. For more information, see [Authentication](https://docs.github.com/rest/guides/getting-started-with-the-rest-api#authentication).
///
/// The Emails API enables you to list all of your email addresses, and toggle a primary email to be visible publicly. For more information, see [Emails API](https://docs.github.com/rest/users/emails).
///
/// [GitHub API docs for get_by_id](https://docs.github.com/rest/users/users#get-a-user-using-their-id)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_by_id(&self, account_id: i32) -> Result<GetUsersGetByUsernameResponse200, AdapterError> {
let request_uri = format!("{}/user/{}", super::GITHUB_BASE_API_URL, account_id);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
404 => Err(UsersGetByIdError::Status404(github_response.to_json()?).into()),
code => Err(UsersGetByIdError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a user
///
/// Provides publicly available information about someone with a GitHub account.
///
/// If you are requesting information about an [Enterprise Managed User](https://docs.github.com/enterprise-cloud@latest/admin/managing-iam/understanding-iam-for-enterprises/about-enterprise-managed-users), or a GitHub App bot that is installed in an organization that uses Enterprise Managed Users, your requests must be authenticated as a user or GitHub App that has access to the organization to view that account's information. If you are not authorized, the request will return a `404 Not Found` status.
///
/// The `email` key in the following response is the publicly visible email address from your GitHub [profile page](https://github.com/settings/profile). When setting up your profile, you can select a primary email address to be public which provides an email entry for this endpoint. If you do not set a public email address for `email`, then it will have a value of `null`. You only see publicly visible email addresses when authenticated with GitHub. For more information, see [Authentication](https://docs.github.com/rest/guides/getting-started-with-the-rest-api#authentication).
///
/// The Emails API enables you to list all of your email addresses, and toggle a primary email to be visible publicly. For more information, see [Emails API](https://docs.github.com/rest/users/emails).
///
/// [GitHub API docs for get_by_username](https://docs.github.com/rest/users/users#get-a-user)
///
/// ---
pub async fn get_by_username_async(&self, username: &str) -> Result<GetUsersGetByUsernameResponse200, AdapterError> {
let request_uri = format!("{}/users/{}", 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() {
404 => Err(UsersGetByUsernameError::Status404(github_response.to_json_async().await?).into()),
code => Err(UsersGetByUsernameError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a user
///
/// Provides publicly available information about someone with a GitHub account.
///
/// If you are requesting information about an [Enterprise Managed User](https://docs.github.com/enterprise-cloud@latest/admin/managing-iam/understanding-iam-for-enterprises/about-enterprise-managed-users), or a GitHub App bot that is installed in an organization that uses Enterprise Managed Users, your requests must be authenticated as a user or GitHub App that has access to the organization to view that account's information. If you are not authorized, the request will return a `404 Not Found` status.
///
/// The `email` key in the following response is the publicly visible email address from your GitHub [profile page](https://github.com/settings/profile). When setting up your profile, you can select a primary email address to be public which provides an email entry for this endpoint. If you do not set a public email address for `email`, then it will have a value of `null`. You only see publicly visible email addresses when authenticated with GitHub. For more information, see [Authentication](https://docs.github.com/rest/guides/getting-started-with-the-rest-api#authentication).
///
/// The Emails API enables you to list all of your email addresses, and toggle a primary email to be visible publicly. For more information, see [Emails API](https://docs.github.com/rest/users/emails).
///
/// [GitHub API docs for get_by_username](https://docs.github.com/rest/users/users#get-a-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_by_username(&self, username: &str) -> Result<GetUsersGetByUsernameResponse200, AdapterError> {
let request_uri = format!("{}/users/{}", 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() {
404 => Err(UsersGetByUsernameError::Status404(github_response.to_json()?).into()),
code => Err(UsersGetByUsernameError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get contextual information for a user
///
/// Provides hovercard information. You can find out more about someone in relation to their pull requests, issues, repositories, and organizations.
///
/// The `subject_type` and `subject_id` parameters provide context for the person's hovercard, which returns more information than without the parameters. For example, if you wanted to find out more about `octocat` who owns the `Spoon-Knife` repository, you would use a `subject_type` value of `repository` and a `subject_id` value of `1300192` (the ID of the `Spoon-Knife` repository).
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.
///
/// [GitHub API docs for get_context_for_user](https://docs.github.com/rest/users/users#get-contextual-information-for-a-user)
///
/// ---
pub async fn get_context_for_user_async(&self, username: &str, query_params: Option<impl Into<UsersGetContextForUserParams<'api>>>) -> Result<Hovercard, AdapterError> {
let mut request_uri = format!("{}/users/{}/hovercard", super::GITHUB_BASE_API_URL, username);
if let Some(params) = query_params {
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(params.into())?);
}
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
404 => Err(UsersGetContextForUserError::Status404(github_response.to_json_async().await?).into()),
422 => Err(UsersGetContextForUserError::Status422(github_response.to_json_async().await?).into()),
code => Err(UsersGetContextForUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get contextual information for a user
///
/// Provides hovercard information. You can find out more about someone in relation to their pull requests, issues, repositories, and organizations.
///
/// The `subject_type` and `subject_id` parameters provide context for the person's hovercard, which returns more information than without the parameters. For example, if you wanted to find out more about `octocat` who owns the `Spoon-Knife` repository, you would use a `subject_type` value of `repository` and a `subject_id` value of `1300192` (the ID of the `Spoon-Knife` repository).
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.
///
/// [GitHub API docs for get_context_for_user](https://docs.github.com/rest/users/users#get-contextual-information-for-a-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_context_for_user(&self, username: &str, query_params: Option<impl Into<UsersGetContextForUserParams<'api>>>) -> Result<Hovercard, AdapterError> {
let mut request_uri = format!("{}/users/{}/hovercard", super::GITHUB_BASE_API_URL, username);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: UsersGetContextForUserParams = 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(UsersGetContextForUserError::Status404(github_response.to_json()?).into()),
422 => Err(UsersGetContextForUserError::Status422(github_response.to_json()?).into()),
code => Err(UsersGetContextForUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a GPG key for the authenticated user
///
/// View extended details for a single GPG key.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:gpg_key` scope to use this endpoint.
///
/// [GitHub API docs for get_gpg_key_for_authenticated_user](https://docs.github.com/rest/users/gpg-keys#get-a-gpg-key-for-the-authenticated-user)
///
/// ---
pub async fn get_gpg_key_for_authenticated_user_async(&self, gpg_key_id: i32) -> Result<GpgKey, AdapterError> {
let request_uri = format!("{}/user/gpg_keys/{}", super::GITHUB_BASE_API_URL, gpg_key_id);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
404 => Err(UsersGetGpgKeyForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()),
304 => Err(UsersGetGpgKeyForAuthenticatedUserError::Status304.into()),
403 => Err(UsersGetGpgKeyForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()),
401 => Err(UsersGetGpgKeyForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()),
code => Err(UsersGetGpgKeyForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a GPG key for the authenticated user
///
/// View extended details for a single GPG key.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:gpg_key` scope to use this endpoint.
///
/// [GitHub API docs for get_gpg_key_for_authenticated_user](https://docs.github.com/rest/users/gpg-keys#get-a-gpg-key-for-the-authenticated-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_gpg_key_for_authenticated_user(&self, gpg_key_id: i32) -> Result<GpgKey, AdapterError> {
let request_uri = format!("{}/user/gpg_keys/{}", super::GITHUB_BASE_API_URL, gpg_key_id);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
404 => Err(UsersGetGpgKeyForAuthenticatedUserError::Status404(github_response.to_json()?).into()),
304 => Err(UsersGetGpgKeyForAuthenticatedUserError::Status304.into()),
403 => Err(UsersGetGpgKeyForAuthenticatedUserError::Status403(github_response.to_json()?).into()),
401 => Err(UsersGetGpgKeyForAuthenticatedUserError::Status401(github_response.to_json()?).into()),
code => Err(UsersGetGpgKeyForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a public SSH key for the authenticated user
///
/// View extended details for a single public SSH key.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:public_key` scope to use this endpoint.
///
/// [GitHub API docs for get_public_ssh_key_for_authenticated_user](https://docs.github.com/rest/users/keys#get-a-public-ssh-key-for-the-authenticated-user)
///
/// ---
pub async fn get_public_ssh_key_for_authenticated_user_async(&self, key_id: i32) -> Result<Key, AdapterError> {
let request_uri = format!("{}/user/keys/{}", super::GITHUB_BASE_API_URL, key_id);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
404 => Err(UsersGetPublicSshKeyForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()),
304 => Err(UsersGetPublicSshKeyForAuthenticatedUserError::Status304.into()),
403 => Err(UsersGetPublicSshKeyForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()),
401 => Err(UsersGetPublicSshKeyForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()),
code => Err(UsersGetPublicSshKeyForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a public SSH key for the authenticated user
///
/// View extended details for a single public SSH key.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:public_key` scope to use this endpoint.
///
/// [GitHub API docs for get_public_ssh_key_for_authenticated_user](https://docs.github.com/rest/users/keys#get-a-public-ssh-key-for-the-authenticated-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_public_ssh_key_for_authenticated_user(&self, key_id: i32) -> Result<Key, AdapterError> {
let request_uri = format!("{}/user/keys/{}", super::GITHUB_BASE_API_URL, key_id);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
404 => Err(UsersGetPublicSshKeyForAuthenticatedUserError::Status404(github_response.to_json()?).into()),
304 => Err(UsersGetPublicSshKeyForAuthenticatedUserError::Status304.into()),
403 => Err(UsersGetPublicSshKeyForAuthenticatedUserError::Status403(github_response.to_json()?).into()),
401 => Err(UsersGetPublicSshKeyForAuthenticatedUserError::Status401(github_response.to_json()?).into()),
code => Err(UsersGetPublicSshKeyForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get an SSH signing key for the authenticated user
///
/// Gets extended details for an SSH signing key.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:ssh_signing_key` scope to use this endpoint.
///
/// [GitHub API docs for get_ssh_signing_key_for_authenticated_user](https://docs.github.com/rest/users/ssh-signing-keys#get-an-ssh-signing-key-for-the-authenticated-user)
///
/// ---
pub async fn get_ssh_signing_key_for_authenticated_user_async(&self, ssh_signing_key_id: i32) -> Result<SshSigningKey, AdapterError> {
let request_uri = format!("{}/user/ssh_signing_keys/{}", super::GITHUB_BASE_API_URL, ssh_signing_key_id);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
404 => Err(UsersGetSshSigningKeyForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()),
304 => Err(UsersGetSshSigningKeyForAuthenticatedUserError::Status304.into()),
403 => Err(UsersGetSshSigningKeyForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()),
401 => Err(UsersGetSshSigningKeyForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()),
code => Err(UsersGetSshSigningKeyForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get an SSH signing key for the authenticated user
///
/// Gets extended details for an SSH signing key.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:ssh_signing_key` scope to use this endpoint.
///
/// [GitHub API docs for get_ssh_signing_key_for_authenticated_user](https://docs.github.com/rest/users/ssh-signing-keys#get-an-ssh-signing-key-for-the-authenticated-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_ssh_signing_key_for_authenticated_user(&self, ssh_signing_key_id: i32) -> Result<SshSigningKey, AdapterError> {
let request_uri = format!("{}/user/ssh_signing_keys/{}", super::GITHUB_BASE_API_URL, ssh_signing_key_id);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
404 => Err(UsersGetSshSigningKeyForAuthenticatedUserError::Status404(github_response.to_json()?).into()),
304 => Err(UsersGetSshSigningKeyForAuthenticatedUserError::Status304.into()),
403 => Err(UsersGetSshSigningKeyForAuthenticatedUserError::Status403(github_response.to_json()?).into()),
401 => Err(UsersGetSshSigningKeyForAuthenticatedUserError::Status401(github_response.to_json()?).into()),
code => Err(UsersGetSshSigningKeyForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List users
///
/// Lists all users, in the order that they signed up on GitHub. This list includes personal user accounts and organization accounts.
///
/// Note: Pagination is powered exclusively by the `since` parameter. Use the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers) to get the URL for the next page of users.
///
/// [GitHub API docs for list](https://docs.github.com/rest/users/users#list-users)
///
/// ---
pub async fn list_async(&self, query_params: Option<impl Into<UsersListParams>>) -> Result<Vec<SimpleUser>, AdapterError> {
let mut request_uri = format!("{}/users", super::GITHUB_BASE_API_URL);
if let Some(params) = query_params {
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(params.into())?);
}
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
304 => Err(UsersListError::Status304.into()),
code => Err(UsersListError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List users
///
/// Lists all users, in the order that they signed up on GitHub. This list includes personal user accounts and organization accounts.
///
/// Note: Pagination is powered exclusively by the `since` parameter. Use the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers) to get the URL for the next page of users.
///
/// [GitHub API docs for list](https://docs.github.com/rest/users/users#list-users)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list(&self, query_params: Option<impl Into<UsersListParams>>) -> Result<Vec<SimpleUser>, AdapterError> {
let mut request_uri = format!("{}/users", super::GITHUB_BASE_API_URL);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: UsersListParams = params.into();
request_uri.push_str(&serde_urlencoded::to_string(qp)?);
}
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
304 => Err(UsersListError::Status304.into()),
code => Err(UsersListError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List attestations
///
/// List a collection of artifact attestations with a given subject digest that are associated with repositories owned by a user.
///
/// The collection of attestations returned by this endpoint is filtered according to the authenticated user's permissions; if the authenticated user cannot read a repository, the attestations associated with that repository will not be included in the response. In addition, when using a fine-grained access token the `attestations:read` permission is required.
///
/// **Please note:** in order to offer meaningful security benefits, an attestation's signature and timestamps **must** be cryptographically verified, and the identity of the attestation signer **must** be validated. Attestations can be verified using the [GitHub CLI `attestation verify` command](https://cli.github.com/manual/gh_attestation_verify). For more information, see [our guide on how to use artifact attestations to establish a build's provenance](https://docs.github.com/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds).
///
/// [GitHub API docs for list_attestations](https://docs.github.com/rest/users/attestations#list-attestations)
///
/// ---
pub async fn list_attestations_async(&self, username: &str, subject_digest: &str, query_params: Option<impl Into<UsersListAttestationsParams<'api>>>) -> Result<GetUsersListAttestationsResponse200, AdapterError> {
let mut request_uri = format!("{}/users/{}/attestations/{}", super::GITHUB_BASE_API_URL, username, subject_digest);
if let Some(params) = query_params {
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(params.into())?);
}
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
201 => Err(UsersListAttestationsError::Status201(github_response.to_json_async().await?).into()),
204 => Err(UsersListAttestationsError::Status204.into()),
404 => Err(UsersListAttestationsError::Status404(github_response.to_json_async().await?).into()),
code => Err(UsersListAttestationsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List attestations
///
/// List a collection of artifact attestations with a given subject digest that are associated with repositories owned by a user.
///
/// The collection of attestations returned by this endpoint is filtered according to the authenticated user's permissions; if the authenticated user cannot read a repository, the attestations associated with that repository will not be included in the response. In addition, when using a fine-grained access token the `attestations:read` permission is required.
///
/// **Please note:** in order to offer meaningful security benefits, an attestation's signature and timestamps **must** be cryptographically verified, and the identity of the attestation signer **must** be validated. Attestations can be verified using the [GitHub CLI `attestation verify` command](https://cli.github.com/manual/gh_attestation_verify). For more information, see [our guide on how to use artifact attestations to establish a build's provenance](https://docs.github.com/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds).
///
/// [GitHub API docs for list_attestations](https://docs.github.com/rest/users/attestations#list-attestations)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_attestations(&self, username: &str, subject_digest: &str, query_params: Option<impl Into<UsersListAttestationsParams<'api>>>) -> Result<GetUsersListAttestationsResponse200, AdapterError> {
let mut request_uri = format!("{}/users/{}/attestations/{}", super::GITHUB_BASE_API_URL, username, subject_digest);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: UsersListAttestationsParams = 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() {
201 => Err(UsersListAttestationsError::Status201(github_response.to_json()?).into()),
204 => Err(UsersListAttestationsError::Status204.into()),
404 => Err(UsersListAttestationsError::Status404(github_response.to_json()?).into()),
code => Err(UsersListAttestationsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List attestations by bulk subject digests
///
/// List a collection of artifact attestations associated with any entry in a list of subject digests owned by a user.
///
/// The collection of attestations returned by this endpoint is filtered according to the authenticated user's permissions; if the authenticated user cannot read a repository, the attestations associated with that repository will not be included in the response. In addition, when using a fine-grained access token the `attestations:read` permission is required.
///
/// **Please note:** in order to offer meaningful security benefits, an attestation's signature and timestamps **must** be cryptographically verified, and the identity of the attestation signer **must** be validated. Attestations can be verified using the [GitHub CLI `attestation verify` command](https://cli.github.com/manual/gh_attestation_verify). For more information, see [our guide on how to use artifact attestations to establish a build's provenance](https://docs.github.com/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds).
///
/// [GitHub API docs for list_attestations_bulk](https://docs.github.com/rest/users/attestations#list-attestations-by-bulk-subject-digests)
///
/// ---
pub async fn list_attestations_bulk_async(&self, username: &str, query_params: Option<impl Into<UsersListAttestationsBulkParams<'api>>>, body: PostUsersListAttestationsBulk) -> Result<PostUsersListAttestationsBulkResponse200, AdapterError> {
let mut request_uri = format!("{}/users/{}/attestations/bulk-list", super::GITHUB_BASE_API_URL, username);
if let Some(params) = query_params {
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(params.into())?);
}
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostUsersListAttestationsBulk>(body)?),
method: "POST",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
code => Err(UsersListAttestationsBulkError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List attestations by bulk subject digests
///
/// List a collection of artifact attestations associated with any entry in a list of subject digests owned by a user.
///
/// The collection of attestations returned by this endpoint is filtered according to the authenticated user's permissions; if the authenticated user cannot read a repository, the attestations associated with that repository will not be included in the response. In addition, when using a fine-grained access token the `attestations:read` permission is required.
///
/// **Please note:** in order to offer meaningful security benefits, an attestation's signature and timestamps **must** be cryptographically verified, and the identity of the attestation signer **must** be validated. Attestations can be verified using the [GitHub CLI `attestation verify` command](https://cli.github.com/manual/gh_attestation_verify). For more information, see [our guide on how to use artifact attestations to establish a build's provenance](https://docs.github.com/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds).
///
/// [GitHub API docs for list_attestations_bulk](https://docs.github.com/rest/users/attestations#list-attestations-by-bulk-subject-digests)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_attestations_bulk(&self, username: &str, query_params: Option<impl Into<UsersListAttestationsBulkParams<'api>>>, body: PostUsersListAttestationsBulk) -> Result<PostUsersListAttestationsBulkResponse200, AdapterError> {
let mut request_uri = format!("{}/users/{}/attestations/bulk-list", super::GITHUB_BASE_API_URL, username);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: UsersListAttestationsBulkParams = params.into();
request_uri.push_str(&serde_urlencoded::to_string(qp)?);
}
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostUsersListAttestationsBulk>(body)?),
method: "POST",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
code => Err(UsersListAttestationsBulkError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List users blocked by the authenticated user
///
/// List the users you've blocked on your personal account.
///
/// [GitHub API docs for list_blocked_by_authenticated_user](https://docs.github.com/rest/users/blocking#list-users-blocked-by-the-authenticated-user)
///
/// ---
pub async fn list_blocked_by_authenticated_user_async(&self, query_params: Option<impl Into<UsersListBlockedByAuthenticatedUserParams>>) -> Result<Vec<SimpleUser>, AdapterError> {
let mut request_uri = format!("{}/user/blocks", super::GITHUB_BASE_API_URL);
if let Some(params) = query_params {
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(params.into())?);
}
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
304 => Err(UsersListBlockedByAuthenticatedUserError::Status304.into()),
404 => Err(UsersListBlockedByAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()),
403 => Err(UsersListBlockedByAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()),
401 => Err(UsersListBlockedByAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()),
code => Err(UsersListBlockedByAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List users blocked by the authenticated user
///
/// List the users you've blocked on your personal account.
///
/// [GitHub API docs for list_blocked_by_authenticated_user](https://docs.github.com/rest/users/blocking#list-users-blocked-by-the-authenticated-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_blocked_by_authenticated_user(&self, query_params: Option<impl Into<UsersListBlockedByAuthenticatedUserParams>>) -> Result<Vec<SimpleUser>, AdapterError> {
let mut request_uri = format!("{}/user/blocks", super::GITHUB_BASE_API_URL);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: UsersListBlockedByAuthenticatedUserParams = params.into();
request_uri.push_str(&serde_urlencoded::to_string(qp)?);
}
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
304 => Err(UsersListBlockedByAuthenticatedUserError::Status304.into()),
404 => Err(UsersListBlockedByAuthenticatedUserError::Status404(github_response.to_json()?).into()),
403 => Err(UsersListBlockedByAuthenticatedUserError::Status403(github_response.to_json()?).into()),
401 => Err(UsersListBlockedByAuthenticatedUserError::Status401(github_response.to_json()?).into()),
code => Err(UsersListBlockedByAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List email addresses for the authenticated user
///
/// Lists all of your email addresses, and specifies which one is visible
/// to the public.
///
/// OAuth app tokens and personal access tokens (classic) need the `user:email` scope to use this endpoint.
///
/// [GitHub API docs for list_emails_for_authenticated_user](https://docs.github.com/rest/users/emails#list-email-addresses-for-the-authenticated-user)
///
/// ---
pub async fn list_emails_for_authenticated_user_async(&self, query_params: Option<impl Into<UsersListEmailsForAuthenticatedUserParams>>) -> Result<Vec<Email>, AdapterError> {
let mut request_uri = format!("{}/user/emails", super::GITHUB_BASE_API_URL);
if let Some(params) = query_params {
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(params.into())?);
}
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
304 => Err(UsersListEmailsForAuthenticatedUserError::Status304.into()),
404 => Err(UsersListEmailsForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()),
403 => Err(UsersListEmailsForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()),
401 => Err(UsersListEmailsForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()),
code => Err(UsersListEmailsForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List email addresses for the authenticated user
///
/// Lists all of your email addresses, and specifies which one is visible
/// to the public.
///
/// OAuth app tokens and personal access tokens (classic) need the `user:email` scope to use this endpoint.
///
/// [GitHub API docs for list_emails_for_authenticated_user](https://docs.github.com/rest/users/emails#list-email-addresses-for-the-authenticated-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_emails_for_authenticated_user(&self, query_params: Option<impl Into<UsersListEmailsForAuthenticatedUserParams>>) -> Result<Vec<Email>, AdapterError> {
let mut request_uri = format!("{}/user/emails", super::GITHUB_BASE_API_URL);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: UsersListEmailsForAuthenticatedUserParams = params.into();
request_uri.push_str(&serde_urlencoded::to_string(qp)?);
}
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
304 => Err(UsersListEmailsForAuthenticatedUserError::Status304.into()),
404 => Err(UsersListEmailsForAuthenticatedUserError::Status404(github_response.to_json()?).into()),
403 => Err(UsersListEmailsForAuthenticatedUserError::Status403(github_response.to_json()?).into()),
401 => Err(UsersListEmailsForAuthenticatedUserError::Status401(github_response.to_json()?).into()),
code => Err(UsersListEmailsForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List the people the authenticated user follows
///
/// Lists the people who the authenticated user follows.
///
/// [GitHub API docs for list_followed_by_authenticated_user](https://docs.github.com/rest/users/followers#list-the-people-the-authenticated-user-follows)
///
/// ---
pub async fn list_followed_by_authenticated_user_async(&self, query_params: Option<impl Into<UsersListFollowedByAuthenticatedUserParams>>) -> Result<Vec<SimpleUser>, AdapterError> {
let mut request_uri = format!("{}/user/following", super::GITHUB_BASE_API_URL);
if let Some(params) = query_params {
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(params.into())?);
}
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
304 => Err(UsersListFollowedByAuthenticatedUserError::Status304.into()),
403 => Err(UsersListFollowedByAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()),
401 => Err(UsersListFollowedByAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()),
code => Err(UsersListFollowedByAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List the people the authenticated user follows
///
/// Lists the people who the authenticated user follows.
///
/// [GitHub API docs for list_followed_by_authenticated_user](https://docs.github.com/rest/users/followers#list-the-people-the-authenticated-user-follows)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_followed_by_authenticated_user(&self, query_params: Option<impl Into<UsersListFollowedByAuthenticatedUserParams>>) -> Result<Vec<SimpleUser>, AdapterError> {
let mut request_uri = format!("{}/user/following", super::GITHUB_BASE_API_URL);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: UsersListFollowedByAuthenticatedUserParams = params.into();
request_uri.push_str(&serde_urlencoded::to_string(qp)?);
}
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
304 => Err(UsersListFollowedByAuthenticatedUserError::Status304.into()),
403 => Err(UsersListFollowedByAuthenticatedUserError::Status403(github_response.to_json()?).into()),
401 => Err(UsersListFollowedByAuthenticatedUserError::Status401(github_response.to_json()?).into()),
code => Err(UsersListFollowedByAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List followers of the authenticated user
///
/// Lists the people following the authenticated user.
///
/// [GitHub API docs for list_followers_for_authenticated_user](https://docs.github.com/rest/users/followers#list-followers-of-the-authenticated-user)
///
/// ---
pub async fn list_followers_for_authenticated_user_async(&self, query_params: Option<impl Into<UsersListFollowersForAuthenticatedUserParams>>) -> Result<Vec<SimpleUser>, AdapterError> {
let mut request_uri = format!("{}/user/followers", super::GITHUB_BASE_API_URL);
if let Some(params) = query_params {
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(params.into())?);
}
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
304 => Err(UsersListFollowersForAuthenticatedUserError::Status304.into()),
403 => Err(UsersListFollowersForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()),
401 => Err(UsersListFollowersForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()),
code => Err(UsersListFollowersForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List followers of the authenticated user
///
/// Lists the people following the authenticated user.
///
/// [GitHub API docs for list_followers_for_authenticated_user](https://docs.github.com/rest/users/followers#list-followers-of-the-authenticated-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_followers_for_authenticated_user(&self, query_params: Option<impl Into<UsersListFollowersForAuthenticatedUserParams>>) -> Result<Vec<SimpleUser>, AdapterError> {
let mut request_uri = format!("{}/user/followers", super::GITHUB_BASE_API_URL);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: UsersListFollowersForAuthenticatedUserParams = params.into();
request_uri.push_str(&serde_urlencoded::to_string(qp)?);
}
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
304 => Err(UsersListFollowersForAuthenticatedUserError::Status304.into()),
403 => Err(UsersListFollowersForAuthenticatedUserError::Status403(github_response.to_json()?).into()),
401 => Err(UsersListFollowersForAuthenticatedUserError::Status401(github_response.to_json()?).into()),
code => Err(UsersListFollowersForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List followers of a user
///
/// Lists the people following the specified user.
///
/// [GitHub API docs for list_followers_for_user](https://docs.github.com/rest/users/followers#list-followers-of-a-user)
///
/// ---
pub async fn list_followers_for_user_async(&self, username: &str, query_params: Option<impl Into<UsersListFollowersForUserParams>>) -> Result<Vec<SimpleUser>, AdapterError> {
let mut request_uri = format!("{}/users/{}/followers", super::GITHUB_BASE_API_URL, username);
if let Some(params) = query_params {
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(params.into())?);
}
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
code => Err(UsersListFollowersForUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List followers of a user
///
/// Lists the people following the specified user.
///
/// [GitHub API docs for list_followers_for_user](https://docs.github.com/rest/users/followers#list-followers-of-a-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_followers_for_user(&self, username: &str, query_params: Option<impl Into<UsersListFollowersForUserParams>>) -> Result<Vec<SimpleUser>, AdapterError> {
let mut request_uri = format!("{}/users/{}/followers", super::GITHUB_BASE_API_URL, username);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: UsersListFollowersForUserParams = params.into();
request_uri.push_str(&serde_urlencoded::to_string(qp)?);
}
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
code => Err(UsersListFollowersForUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List the people a user follows
///
/// Lists the people who the specified user follows.
///
/// [GitHub API docs for list_following_for_user](https://docs.github.com/rest/users/followers#list-the-people-a-user-follows)
///
/// ---
pub async fn list_following_for_user_async(&self, username: &str, query_params: Option<impl Into<UsersListFollowingForUserParams>>) -> Result<Vec<SimpleUser>, AdapterError> {
let mut request_uri = format!("{}/users/{}/following", super::GITHUB_BASE_API_URL, username);
if let Some(params) = query_params {
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(params.into())?);
}
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
code => Err(UsersListFollowingForUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List the people a user follows
///
/// Lists the people who the specified user follows.
///
/// [GitHub API docs for list_following_for_user](https://docs.github.com/rest/users/followers#list-the-people-a-user-follows)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_following_for_user(&self, username: &str, query_params: Option<impl Into<UsersListFollowingForUserParams>>) -> Result<Vec<SimpleUser>, AdapterError> {
let mut request_uri = format!("{}/users/{}/following", super::GITHUB_BASE_API_URL, username);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: UsersListFollowingForUserParams = params.into();
request_uri.push_str(&serde_urlencoded::to_string(qp)?);
}
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
code => Err(UsersListFollowingForUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List GPG keys for the authenticated user
///
/// Lists the current user's GPG keys.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:gpg_key` scope to use this endpoint.
///
/// [GitHub API docs for list_gpg_keys_for_authenticated_user](https://docs.github.com/rest/users/gpg-keys#list-gpg-keys-for-the-authenticated-user)
///
/// ---
pub async fn list_gpg_keys_for_authenticated_user_async(&self, query_params: Option<impl Into<UsersListGpgKeysForAuthenticatedUserParams>>) -> Result<Vec<GpgKey>, AdapterError> {
let mut request_uri = format!("{}/user/gpg_keys", super::GITHUB_BASE_API_URL);
if let Some(params) = query_params {
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(params.into())?);
}
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
304 => Err(UsersListGpgKeysForAuthenticatedUserError::Status304.into()),
404 => Err(UsersListGpgKeysForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()),
403 => Err(UsersListGpgKeysForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()),
401 => Err(UsersListGpgKeysForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()),
code => Err(UsersListGpgKeysForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List GPG keys for the authenticated user
///
/// Lists the current user's GPG keys.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:gpg_key` scope to use this endpoint.
///
/// [GitHub API docs for list_gpg_keys_for_authenticated_user](https://docs.github.com/rest/users/gpg-keys#list-gpg-keys-for-the-authenticated-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_gpg_keys_for_authenticated_user(&self, query_params: Option<impl Into<UsersListGpgKeysForAuthenticatedUserParams>>) -> Result<Vec<GpgKey>, AdapterError> {
let mut request_uri = format!("{}/user/gpg_keys", super::GITHUB_BASE_API_URL);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: UsersListGpgKeysForAuthenticatedUserParams = params.into();
request_uri.push_str(&serde_urlencoded::to_string(qp)?);
}
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
304 => Err(UsersListGpgKeysForAuthenticatedUserError::Status304.into()),
404 => Err(UsersListGpgKeysForAuthenticatedUserError::Status404(github_response.to_json()?).into()),
403 => Err(UsersListGpgKeysForAuthenticatedUserError::Status403(github_response.to_json()?).into()),
401 => Err(UsersListGpgKeysForAuthenticatedUserError::Status401(github_response.to_json()?).into()),
code => Err(UsersListGpgKeysForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List GPG keys for a user
///
/// Lists the GPG keys for a user. This information is accessible by anyone.
///
/// [GitHub API docs for list_gpg_keys_for_user](https://docs.github.com/rest/users/gpg-keys#list-gpg-keys-for-a-user)
///
/// ---
pub async fn list_gpg_keys_for_user_async(&self, username: &str, query_params: Option<impl Into<UsersListGpgKeysForUserParams>>) -> Result<Vec<GpgKey>, AdapterError> {
let mut request_uri = format!("{}/users/{}/gpg_keys", super::GITHUB_BASE_API_URL, username);
if let Some(params) = query_params {
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(params.into())?);
}
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
code => Err(UsersListGpgKeysForUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List GPG keys for a user
///
/// Lists the GPG keys for a user. This information is accessible by anyone.
///
/// [GitHub API docs for list_gpg_keys_for_user](https://docs.github.com/rest/users/gpg-keys#list-gpg-keys-for-a-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_gpg_keys_for_user(&self, username: &str, query_params: Option<impl Into<UsersListGpgKeysForUserParams>>) -> Result<Vec<GpgKey>, AdapterError> {
let mut request_uri = format!("{}/users/{}/gpg_keys", super::GITHUB_BASE_API_URL, username);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: UsersListGpgKeysForUserParams = params.into();
request_uri.push_str(&serde_urlencoded::to_string(qp)?);
}
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
code => Err(UsersListGpgKeysForUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List public email addresses for the authenticated user
///
/// Lists your publicly visible email address, which you can set with the
/// [Set primary email visibility for the authenticated user](https://docs.github.com/rest/users/emails#set-primary-email-visibility-for-the-authenticated-user)
/// endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need the `user:email` scope to use this endpoint.
///
/// [GitHub API docs for list_public_emails_for_authenticated_user](https://docs.github.com/rest/users/emails#list-public-email-addresses-for-the-authenticated-user)
///
/// ---
pub async fn list_public_emails_for_authenticated_user_async(&self, query_params: Option<impl Into<UsersListPublicEmailsForAuthenticatedUserParams>>) -> Result<Vec<Email>, AdapterError> {
let mut request_uri = format!("{}/user/public_emails", super::GITHUB_BASE_API_URL);
if let Some(params) = query_params {
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(params.into())?);
}
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
304 => Err(UsersListPublicEmailsForAuthenticatedUserError::Status304.into()),
404 => Err(UsersListPublicEmailsForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()),
403 => Err(UsersListPublicEmailsForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()),
401 => Err(UsersListPublicEmailsForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()),
code => Err(UsersListPublicEmailsForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List public email addresses for the authenticated user
///
/// Lists your publicly visible email address, which you can set with the
/// [Set primary email visibility for the authenticated user](https://docs.github.com/rest/users/emails#set-primary-email-visibility-for-the-authenticated-user)
/// endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need the `user:email` scope to use this endpoint.
///
/// [GitHub API docs for list_public_emails_for_authenticated_user](https://docs.github.com/rest/users/emails#list-public-email-addresses-for-the-authenticated-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_public_emails_for_authenticated_user(&self, query_params: Option<impl Into<UsersListPublicEmailsForAuthenticatedUserParams>>) -> Result<Vec<Email>, AdapterError> {
let mut request_uri = format!("{}/user/public_emails", super::GITHUB_BASE_API_URL);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: UsersListPublicEmailsForAuthenticatedUserParams = params.into();
request_uri.push_str(&serde_urlencoded::to_string(qp)?);
}
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
304 => Err(UsersListPublicEmailsForAuthenticatedUserError::Status304.into()),
404 => Err(UsersListPublicEmailsForAuthenticatedUserError::Status404(github_response.to_json()?).into()),
403 => Err(UsersListPublicEmailsForAuthenticatedUserError::Status403(github_response.to_json()?).into()),
401 => Err(UsersListPublicEmailsForAuthenticatedUserError::Status401(github_response.to_json()?).into()),
code => Err(UsersListPublicEmailsForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List public keys for a user
///
/// Lists the _verified_ public SSH keys for a user. This is accessible by anyone.
///
/// [GitHub API docs for list_public_keys_for_user](https://docs.github.com/rest/users/keys#list-public-keys-for-a-user)
///
/// ---
pub async fn list_public_keys_for_user_async(&self, username: &str, query_params: Option<impl Into<UsersListPublicKeysForUserParams>>) -> Result<Vec<KeySimple>, AdapterError> {
let mut request_uri = format!("{}/users/{}/keys", super::GITHUB_BASE_API_URL, username);
if let Some(params) = query_params {
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(params.into())?);
}
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
code => Err(UsersListPublicKeysForUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List public keys for a user
///
/// Lists the _verified_ public SSH keys for a user. This is accessible by anyone.
///
/// [GitHub API docs for list_public_keys_for_user](https://docs.github.com/rest/users/keys#list-public-keys-for-a-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_public_keys_for_user(&self, username: &str, query_params: Option<impl Into<UsersListPublicKeysForUserParams>>) -> Result<Vec<KeySimple>, AdapterError> {
let mut request_uri = format!("{}/users/{}/keys", super::GITHUB_BASE_API_URL, username);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: UsersListPublicKeysForUserParams = params.into();
request_uri.push_str(&serde_urlencoded::to_string(qp)?);
}
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
code => Err(UsersListPublicKeysForUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List public SSH keys for the authenticated user
///
/// Lists the public SSH keys for the authenticated user's GitHub account.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:public_key` scope to use this endpoint.
///
/// [GitHub API docs for list_public_ssh_keys_for_authenticated_user](https://docs.github.com/rest/users/keys#list-public-ssh-keys-for-the-authenticated-user)
///
/// ---
pub async fn list_public_ssh_keys_for_authenticated_user_async(&self, query_params: Option<impl Into<UsersListPublicSshKeysForAuthenticatedUserParams>>) -> Result<Vec<Key>, AdapterError> {
let mut request_uri = format!("{}/user/keys", super::GITHUB_BASE_API_URL);
if let Some(params) = query_params {
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(params.into())?);
}
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
304 => Err(UsersListPublicSshKeysForAuthenticatedUserError::Status304.into()),
404 => Err(UsersListPublicSshKeysForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()),
403 => Err(UsersListPublicSshKeysForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()),
401 => Err(UsersListPublicSshKeysForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()),
code => Err(UsersListPublicSshKeysForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List public SSH keys for the authenticated user
///
/// Lists the public SSH keys for the authenticated user's GitHub account.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:public_key` scope to use this endpoint.
///
/// [GitHub API docs for list_public_ssh_keys_for_authenticated_user](https://docs.github.com/rest/users/keys#list-public-ssh-keys-for-the-authenticated-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_public_ssh_keys_for_authenticated_user(&self, query_params: Option<impl Into<UsersListPublicSshKeysForAuthenticatedUserParams>>) -> Result<Vec<Key>, AdapterError> {
let mut request_uri = format!("{}/user/keys", super::GITHUB_BASE_API_URL);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: UsersListPublicSshKeysForAuthenticatedUserParams = params.into();
request_uri.push_str(&serde_urlencoded::to_string(qp)?);
}
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
304 => Err(UsersListPublicSshKeysForAuthenticatedUserError::Status304.into()),
404 => Err(UsersListPublicSshKeysForAuthenticatedUserError::Status404(github_response.to_json()?).into()),
403 => Err(UsersListPublicSshKeysForAuthenticatedUserError::Status403(github_response.to_json()?).into()),
401 => Err(UsersListPublicSshKeysForAuthenticatedUserError::Status401(github_response.to_json()?).into()),
code => Err(UsersListPublicSshKeysForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List social accounts for the authenticated user
///
/// Lists all of your social accounts.
///
/// [GitHub API docs for list_social_accounts_for_authenticated_user](https://docs.github.com/rest/users/social-accounts#list-social-accounts-for-the-authenticated-user)
///
/// ---
pub async fn list_social_accounts_for_authenticated_user_async(&self, query_params: Option<impl Into<UsersListSocialAccountsForAuthenticatedUserParams>>) -> Result<Vec<SocialAccount>, AdapterError> {
let mut request_uri = format!("{}/user/social_accounts", super::GITHUB_BASE_API_URL);
if let Some(params) = query_params {
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(params.into())?);
}
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
304 => Err(UsersListSocialAccountsForAuthenticatedUserError::Status304.into()),
404 => Err(UsersListSocialAccountsForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()),
403 => Err(UsersListSocialAccountsForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()),
401 => Err(UsersListSocialAccountsForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()),
code => Err(UsersListSocialAccountsForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List social accounts for the authenticated user
///
/// Lists all of your social accounts.
///
/// [GitHub API docs for list_social_accounts_for_authenticated_user](https://docs.github.com/rest/users/social-accounts#list-social-accounts-for-the-authenticated-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_social_accounts_for_authenticated_user(&self, query_params: Option<impl Into<UsersListSocialAccountsForAuthenticatedUserParams>>) -> Result<Vec<SocialAccount>, AdapterError> {
let mut request_uri = format!("{}/user/social_accounts", super::GITHUB_BASE_API_URL);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: UsersListSocialAccountsForAuthenticatedUserParams = params.into();
request_uri.push_str(&serde_urlencoded::to_string(qp)?);
}
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
304 => Err(UsersListSocialAccountsForAuthenticatedUserError::Status304.into()),
404 => Err(UsersListSocialAccountsForAuthenticatedUserError::Status404(github_response.to_json()?).into()),
403 => Err(UsersListSocialAccountsForAuthenticatedUserError::Status403(github_response.to_json()?).into()),
401 => Err(UsersListSocialAccountsForAuthenticatedUserError::Status401(github_response.to_json()?).into()),
code => Err(UsersListSocialAccountsForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List social accounts for a user
///
/// Lists social media accounts for a user. This endpoint is accessible by anyone.
///
/// [GitHub API docs for list_social_accounts_for_user](https://docs.github.com/rest/users/social-accounts#list-social-accounts-for-a-user)
///
/// ---
pub async fn list_social_accounts_for_user_async(&self, username: &str, query_params: Option<impl Into<UsersListSocialAccountsForUserParams>>) -> Result<Vec<SocialAccount>, AdapterError> {
let mut request_uri = format!("{}/users/{}/social_accounts", super::GITHUB_BASE_API_URL, username);
if let Some(params) = query_params {
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(params.into())?);
}
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
code => Err(UsersListSocialAccountsForUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List social accounts for a user
///
/// Lists social media accounts for a user. This endpoint is accessible by anyone.
///
/// [GitHub API docs for list_social_accounts_for_user](https://docs.github.com/rest/users/social-accounts#list-social-accounts-for-a-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_social_accounts_for_user(&self, username: &str, query_params: Option<impl Into<UsersListSocialAccountsForUserParams>>) -> Result<Vec<SocialAccount>, AdapterError> {
let mut request_uri = format!("{}/users/{}/social_accounts", super::GITHUB_BASE_API_URL, username);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: UsersListSocialAccountsForUserParams = params.into();
request_uri.push_str(&serde_urlencoded::to_string(qp)?);
}
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
code => Err(UsersListSocialAccountsForUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List SSH signing keys for the authenticated user
///
/// Lists the SSH signing keys for the authenticated user's GitHub account.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:ssh_signing_key` scope to use this endpoint.
///
/// [GitHub API docs for list_ssh_signing_keys_for_authenticated_user](https://docs.github.com/rest/users/ssh-signing-keys#list-ssh-signing-keys-for-the-authenticated-user)
///
/// ---
pub async fn list_ssh_signing_keys_for_authenticated_user_async(&self, query_params: Option<impl Into<UsersListSshSigningKeysForAuthenticatedUserParams>>) -> Result<Vec<SshSigningKey>, AdapterError> {
let mut request_uri = format!("{}/user/ssh_signing_keys", super::GITHUB_BASE_API_URL);
if let Some(params) = query_params {
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(params.into())?);
}
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
304 => Err(UsersListSshSigningKeysForAuthenticatedUserError::Status304.into()),
404 => Err(UsersListSshSigningKeysForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()),
403 => Err(UsersListSshSigningKeysForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()),
401 => Err(UsersListSshSigningKeysForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()),
code => Err(UsersListSshSigningKeysForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List SSH signing keys for the authenticated user
///
/// Lists the SSH signing keys for the authenticated user's GitHub account.
///
/// OAuth app tokens and personal access tokens (classic) need the `read:ssh_signing_key` scope to use this endpoint.
///
/// [GitHub API docs for list_ssh_signing_keys_for_authenticated_user](https://docs.github.com/rest/users/ssh-signing-keys#list-ssh-signing-keys-for-the-authenticated-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_ssh_signing_keys_for_authenticated_user(&self, query_params: Option<impl Into<UsersListSshSigningKeysForAuthenticatedUserParams>>) -> Result<Vec<SshSigningKey>, AdapterError> {
let mut request_uri = format!("{}/user/ssh_signing_keys", super::GITHUB_BASE_API_URL);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: UsersListSshSigningKeysForAuthenticatedUserParams = params.into();
request_uri.push_str(&serde_urlencoded::to_string(qp)?);
}
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
304 => Err(UsersListSshSigningKeysForAuthenticatedUserError::Status304.into()),
404 => Err(UsersListSshSigningKeysForAuthenticatedUserError::Status404(github_response.to_json()?).into()),
403 => Err(UsersListSshSigningKeysForAuthenticatedUserError::Status403(github_response.to_json()?).into()),
401 => Err(UsersListSshSigningKeysForAuthenticatedUserError::Status401(github_response.to_json()?).into()),
code => Err(UsersListSshSigningKeysForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List SSH signing keys for a user
///
/// Lists the SSH signing keys for a user. This operation is accessible by anyone.
///
/// [GitHub API docs for list_ssh_signing_keys_for_user](https://docs.github.com/rest/users/ssh-signing-keys#list-ssh-signing-keys-for-a-user)
///
/// ---
pub async fn list_ssh_signing_keys_for_user_async(&self, username: &str, query_params: Option<impl Into<UsersListSshSigningKeysForUserParams>>) -> Result<Vec<SshSigningKey>, AdapterError> {
let mut request_uri = format!("{}/users/{}/ssh_signing_keys", super::GITHUB_BASE_API_URL, username);
if let Some(params) = query_params {
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(params.into())?);
}
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
code => Err(UsersListSshSigningKeysForUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List SSH signing keys for a user
///
/// Lists the SSH signing keys for a user. This operation is accessible by anyone.
///
/// [GitHub API docs for list_ssh_signing_keys_for_user](https://docs.github.com/rest/users/ssh-signing-keys#list-ssh-signing-keys-for-a-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_ssh_signing_keys_for_user(&self, username: &str, query_params: Option<impl Into<UsersListSshSigningKeysForUserParams>>) -> Result<Vec<SshSigningKey>, AdapterError> {
let mut request_uri = format!("{}/users/{}/ssh_signing_keys", super::GITHUB_BASE_API_URL, username);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: UsersListSshSigningKeysForUserParams = params.into();
request_uri.push_str(&serde_urlencoded::to_string(qp)?);
}
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
code => Err(UsersListSshSigningKeysForUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Set primary email visibility for the authenticated user
///
/// Sets the visibility for your primary email addresses.
///
/// [GitHub API docs for set_primary_email_visibility_for_authenticated_user](https://docs.github.com/rest/users/emails#set-primary-email-visibility-for-the-authenticated-user)
///
/// ---
pub async fn set_primary_email_visibility_for_authenticated_user_async(&self, body: PatchUsersSetPrimaryEmailVisibilityForAuthenticatedUser) -> Result<Vec<Email>, AdapterError> {
let request_uri = format!("{}/user/email/visibility", super::GITHUB_BASE_API_URL);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchUsersSetPrimaryEmailVisibilityForAuthenticatedUser>(body)?),
method: "PATCH",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
304 => Err(UsersSetPrimaryEmailVisibilityForAuthenticatedUserError::Status304.into()),
404 => Err(UsersSetPrimaryEmailVisibilityForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()),
403 => Err(UsersSetPrimaryEmailVisibilityForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()),
401 => Err(UsersSetPrimaryEmailVisibilityForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()),
422 => Err(UsersSetPrimaryEmailVisibilityForAuthenticatedUserError::Status422(github_response.to_json_async().await?).into()),
code => Err(UsersSetPrimaryEmailVisibilityForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Set primary email visibility for the authenticated user
///
/// Sets the visibility for your primary email addresses.
///
/// [GitHub API docs for set_primary_email_visibility_for_authenticated_user](https://docs.github.com/rest/users/emails#set-primary-email-visibility-for-the-authenticated-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn set_primary_email_visibility_for_authenticated_user(&self, body: PatchUsersSetPrimaryEmailVisibilityForAuthenticatedUser) -> Result<Vec<Email>, AdapterError> {
let request_uri = format!("{}/user/email/visibility", super::GITHUB_BASE_API_URL);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchUsersSetPrimaryEmailVisibilityForAuthenticatedUser>(body)?),
method: "PATCH",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
304 => Err(UsersSetPrimaryEmailVisibilityForAuthenticatedUserError::Status304.into()),
404 => Err(UsersSetPrimaryEmailVisibilityForAuthenticatedUserError::Status404(github_response.to_json()?).into()),
403 => Err(UsersSetPrimaryEmailVisibilityForAuthenticatedUserError::Status403(github_response.to_json()?).into()),
401 => Err(UsersSetPrimaryEmailVisibilityForAuthenticatedUserError::Status401(github_response.to_json()?).into()),
422 => Err(UsersSetPrimaryEmailVisibilityForAuthenticatedUserError::Status422(github_response.to_json()?).into()),
code => Err(UsersSetPrimaryEmailVisibilityForAuthenticatedUserError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Unblock a user
///
/// Unblocks the given user and returns a 204.
///
/// [GitHub API docs for unblock](https://docs.github.com/rest/users/blocking#unblock-a-user)
///
/// ---
pub async fn unblock_async(&self, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/user/blocks/{}", super::GITHUB_BASE_API_URL, 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() {
304 => Err(UsersUnblockError::Status304.into()),
403 => Err(UsersUnblockError::Status403(github_response.to_json_async().await?).into()),
401 => Err(UsersUnblockError::Status401(github_response.to_json_async().await?).into()),
404 => Err(UsersUnblockError::Status404(github_response.to_json_async().await?).into()),
code => Err(UsersUnblockError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Unblock a user
///
/// Unblocks the given user and returns a 204.
///
/// [GitHub API docs for unblock](https://docs.github.com/rest/users/blocking#unblock-a-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn unblock(&self, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/user/blocks/{}", super::GITHUB_BASE_API_URL, 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() {
304 => Err(UsersUnblockError::Status304.into()),
403 => Err(UsersUnblockError::Status403(github_response.to_json()?).into()),
401 => Err(UsersUnblockError::Status401(github_response.to_json()?).into()),
404 => Err(UsersUnblockError::Status404(github_response.to_json()?).into()),
code => Err(UsersUnblockError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Unfollow a user
///
/// OAuth app tokens and personal access tokens (classic) need the `user:follow` scope to use this endpoint.
///
/// [GitHub API docs for unfollow](https://docs.github.com/rest/users/followers#unfollow-a-user)
///
/// ---
pub async fn unfollow_async(&self, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/user/following/{}", super::GITHUB_BASE_API_URL, 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() {
304 => Err(UsersUnfollowError::Status304.into()),
404 => Err(UsersUnfollowError::Status404(github_response.to_json_async().await?).into()),
403 => Err(UsersUnfollowError::Status403(github_response.to_json_async().await?).into()),
401 => Err(UsersUnfollowError::Status401(github_response.to_json_async().await?).into()),
code => Err(UsersUnfollowError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Unfollow a user
///
/// OAuth app tokens and personal access tokens (classic) need the `user:follow` scope to use this endpoint.
///
/// [GitHub API docs for unfollow](https://docs.github.com/rest/users/followers#unfollow-a-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn unfollow(&self, username: &str) -> Result<(), AdapterError> {
let request_uri = format!("{}/user/following/{}", super::GITHUB_BASE_API_URL, 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() {
304 => Err(UsersUnfollowError::Status304.into()),
404 => Err(UsersUnfollowError::Status404(github_response.to_json()?).into()),
403 => Err(UsersUnfollowError::Status403(github_response.to_json()?).into()),
401 => Err(UsersUnfollowError::Status401(github_response.to_json()?).into()),
code => Err(UsersUnfollowError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update the authenticated user
///
/// **Note:** If your email is set to private and you send an `email` parameter as part of this request to update your profile, your privacy settings are still enforced: the email address will not be displayed on your public profile or via the API.
///
/// [GitHub API docs for update_authenticated](https://docs.github.com/rest/users/users#update-the-authenticated-user)
///
/// ---
pub async fn update_authenticated_async(&self, body: PatchUsersUpdateAuthenticated) -> Result<PrivateUser, AdapterError> {
let request_uri = format!("{}/user", super::GITHUB_BASE_API_URL);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchUsersUpdateAuthenticated>(body)?),
method: "PATCH",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
304 => Err(UsersUpdateAuthenticatedError::Status304.into()),
404 => Err(UsersUpdateAuthenticatedError::Status404(github_response.to_json_async().await?).into()),
403 => Err(UsersUpdateAuthenticatedError::Status403(github_response.to_json_async().await?).into()),
401 => Err(UsersUpdateAuthenticatedError::Status401(github_response.to_json_async().await?).into()),
422 => Err(UsersUpdateAuthenticatedError::Status422(github_response.to_json_async().await?).into()),
code => Err(UsersUpdateAuthenticatedError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update the authenticated user
///
/// **Note:** If your email is set to private and you send an `email` parameter as part of this request to update your profile, your privacy settings are still enforced: the email address will not be displayed on your public profile or via the API.
///
/// [GitHub API docs for update_authenticated](https://docs.github.com/rest/users/users#update-the-authenticated-user)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn update_authenticated(&self, body: PatchUsersUpdateAuthenticated) -> Result<PrivateUser, AdapterError> {
let request_uri = format!("{}/user", super::GITHUB_BASE_API_URL);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchUsersUpdateAuthenticated>(body)?),
method: "PATCH",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
304 => Err(UsersUpdateAuthenticatedError::Status304.into()),
404 => Err(UsersUpdateAuthenticatedError::Status404(github_response.to_json()?).into()),
403 => Err(UsersUpdateAuthenticatedError::Status403(github_response.to_json()?).into()),
401 => Err(UsersUpdateAuthenticatedError::Status401(github_response.to_json()?).into()),
422 => Err(UsersUpdateAuthenticatedError::Status422(github_response.to_json()?).into()),
code => Err(UsersUpdateAuthenticatedError::Generic { code }.into()),
}
}
}
}