//! Method, error and parameter types for the Pulls 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 Pulls<'api, C: Client> where AdapterError: From<<C as Client>::Err> {
client: &'api C
}
pub fn new<C: Client>(client: &C) -> Pulls<C> where AdapterError: From<<C as Client>::Err> {
Pulls { client }
}
/// Errors for the [Check if a pull request has been merged](Pulls::check_if_merged_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PullsCheckIfMergedError {
#[error("Not Found if pull request has not been merged")]
Status404,
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PullsCheckIfMergedError> for AdapterError {
fn from(err: PullsCheckIfMergedError) -> Self {
let (description, status_code) = match err {
PullsCheckIfMergedError::Status404 => (String::from("Not Found if pull request has not been merged"), 404),
PullsCheckIfMergedError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Create a pull request](Pulls::create_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PullsCreateError {
#[error("Forbidden")]
Status403(BasicError),
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PullsCreateError> for AdapterError {
fn from(err: PullsCreateError) -> Self {
let (description, status_code) = match err {
PullsCreateError::Status403(_) => (String::from("Forbidden"), 403),
PullsCreateError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
PullsCreateError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Create a reply for a review comment](Pulls::create_reply_for_review_comment_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PullsCreateReplyForReviewCommentError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PullsCreateReplyForReviewCommentError> for AdapterError {
fn from(err: PullsCreateReplyForReviewCommentError) -> Self {
let (description, status_code) = match err {
PullsCreateReplyForReviewCommentError::Status404(_) => (String::from("Resource not found"), 404),
PullsCreateReplyForReviewCommentError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Create a review for a pull request](Pulls::create_review_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PullsCreateReviewError {
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationErrorSimple),
#[error("Forbidden")]
Status403(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PullsCreateReviewError> for AdapterError {
fn from(err: PullsCreateReviewError) -> Self {
let (description, status_code) = match err {
PullsCreateReviewError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
PullsCreateReviewError::Status403(_) => (String::from("Forbidden"), 403),
PullsCreateReviewError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Create a review comment for a pull request](Pulls::create_review_comment_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PullsCreateReviewCommentError {
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PullsCreateReviewCommentError> for AdapterError {
fn from(err: PullsCreateReviewCommentError) -> Self {
let (description, status_code) = match err {
PullsCreateReviewCommentError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
PullsCreateReviewCommentError::Status403(_) => (String::from("Forbidden"), 403),
PullsCreateReviewCommentError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Delete a pending review for a pull request](Pulls::delete_pending_review_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PullsDeletePendingReviewError {
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationErrorSimple),
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PullsDeletePendingReviewError> for AdapterError {
fn from(err: PullsDeletePendingReviewError) -> Self {
let (description, status_code) = match err {
PullsDeletePendingReviewError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
PullsDeletePendingReviewError::Status404(_) => (String::from("Resource not found"), 404),
PullsDeletePendingReviewError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Delete a review comment for a pull request](Pulls::delete_review_comment_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PullsDeleteReviewCommentError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PullsDeleteReviewCommentError> for AdapterError {
fn from(err: PullsDeleteReviewCommentError) -> Self {
let (description, status_code) = match err {
PullsDeleteReviewCommentError::Status404(_) => (String::from("Resource not found"), 404),
PullsDeleteReviewCommentError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Dismiss a review for a pull request](Pulls::dismiss_review_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PullsDismissReviewError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationErrorSimple),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PullsDismissReviewError> for AdapterError {
fn from(err: PullsDismissReviewError) -> Self {
let (description, status_code) = match err {
PullsDismissReviewError::Status404(_) => (String::from("Resource not found"), 404),
PullsDismissReviewError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
PullsDismissReviewError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get a pull request](Pulls::get_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PullsGetError {
#[error("Not modified")]
Status304,
#[error("Resource not found")]
Status404(BasicError),
#[error("Unacceptable")]
Status406(BasicError),
#[error("Internal Error")]
Status500(BasicError),
#[error("Service unavailable")]
Status503(GetBillingGetGithubBillingUsageReportUserResponse503),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PullsGetError> for AdapterError {
fn from(err: PullsGetError) -> Self {
let (description, status_code) = match err {
PullsGetError::Status304 => (String::from("Not modified"), 304),
PullsGetError::Status404(_) => (String::from("Resource not found"), 404),
PullsGetError::Status406(_) => (String::from("Unacceptable"), 406),
PullsGetError::Status500(_) => (String::from("Internal Error"), 500),
PullsGetError::Status503(_) => (String::from("Service unavailable"), 503),
PullsGetError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get a review for a pull request](Pulls::get_review_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PullsGetReviewError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PullsGetReviewError> for AdapterError {
fn from(err: PullsGetReviewError) -> Self {
let (description, status_code) = match err {
PullsGetReviewError::Status404(_) => (String::from("Resource not found"), 404),
PullsGetReviewError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get a review comment for a pull request](Pulls::get_review_comment_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PullsGetReviewCommentError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PullsGetReviewCommentError> for AdapterError {
fn from(err: PullsGetReviewCommentError) -> Self {
let (description, status_code) = match err {
PullsGetReviewCommentError::Status404(_) => (String::from("Resource not found"), 404),
PullsGetReviewCommentError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List pull requests](Pulls::list_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PullsListError {
#[error("Not modified")]
Status304,
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PullsListError> for AdapterError {
fn from(err: PullsListError) -> Self {
let (description, status_code) = match err {
PullsListError::Status304 => (String::from("Not modified"), 304),
PullsListError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
PullsListError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List comments for a pull request review](Pulls::list_comments_for_review_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PullsListCommentsForReviewError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PullsListCommentsForReviewError> for AdapterError {
fn from(err: PullsListCommentsForReviewError) -> Self {
let (description, status_code) = match err {
PullsListCommentsForReviewError::Status404(_) => (String::from("Resource not found"), 404),
PullsListCommentsForReviewError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List commits on a pull request](Pulls::list_commits_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PullsListCommitsError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PullsListCommitsError> for AdapterError {
fn from(err: PullsListCommitsError) -> Self {
let (description, status_code) = match err {
PullsListCommitsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List pull requests files](Pulls::list_files_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PullsListFilesError {
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Internal Error")]
Status500(BasicError),
#[error("Service unavailable")]
Status503(GetBillingGetGithubBillingUsageReportUserResponse503),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PullsListFilesError> for AdapterError {
fn from(err: PullsListFilesError) -> Self {
let (description, status_code) = match err {
PullsListFilesError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
PullsListFilesError::Status500(_) => (String::from("Internal Error"), 500),
PullsListFilesError::Status503(_) => (String::from("Service unavailable"), 503),
PullsListFilesError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Get all requested reviewers for a pull request](Pulls::list_requested_reviewers_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PullsListRequestedReviewersError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PullsListRequestedReviewersError> for AdapterError {
fn from(err: PullsListRequestedReviewersError) -> Self {
let (description, status_code) = match err {
PullsListRequestedReviewersError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List review comments on a pull request](Pulls::list_review_comments_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PullsListReviewCommentsError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PullsListReviewCommentsError> for AdapterError {
fn from(err: PullsListReviewCommentsError) -> Self {
let (description, status_code) = match err {
PullsListReviewCommentsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List review comments in a repository](Pulls::list_review_comments_for_repo_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PullsListReviewCommentsForRepoError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PullsListReviewCommentsForRepoError> for AdapterError {
fn from(err: PullsListReviewCommentsForRepoError) -> Self {
let (description, status_code) = match err {
PullsListReviewCommentsForRepoError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [List reviews for a pull request](Pulls::list_reviews_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PullsListReviewsError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PullsListReviewsError> for AdapterError {
fn from(err: PullsListReviewsError) -> Self {
let (description, status_code) = match err {
PullsListReviewsError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Merge a pull request](Pulls::merge_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PullsMergeError {
#[error("Method Not Allowed if merge cannot be performed")]
Status405(PutTeamsAddOrUpdateProjectPermissionsLegacyResponse403),
#[error("Conflict if sha was provided and pull request head did not match")]
Status409(PutTeamsAddOrUpdateProjectPermissionsLegacyResponse403),
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Resource not found")]
Status404(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PullsMergeError> for AdapterError {
fn from(err: PullsMergeError) -> Self {
let (description, status_code) = match err {
PullsMergeError::Status405(_) => (String::from("Method Not Allowed if merge cannot be performed"), 405),
PullsMergeError::Status409(_) => (String::from("Conflict if sha was provided and pull request head did not match"), 409),
PullsMergeError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
PullsMergeError::Status403(_) => (String::from("Forbidden"), 403),
PullsMergeError::Status404(_) => (String::from("Resource not found"), 404),
PullsMergeError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Remove requested reviewers from a pull request](Pulls::remove_requested_reviewers_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PullsRemoveRequestedReviewersError {
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PullsRemoveRequestedReviewersError> for AdapterError {
fn from(err: PullsRemoveRequestedReviewersError) -> Self {
let (description, status_code) = match err {
PullsRemoveRequestedReviewersError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
PullsRemoveRequestedReviewersError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Request reviewers for a pull request](Pulls::request_reviewers_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PullsRequestReviewersError {
#[error("Unprocessable Entity if user is not a collaborator")]
Status422,
#[error("Forbidden")]
Status403(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PullsRequestReviewersError> for AdapterError {
fn from(err: PullsRequestReviewersError) -> Self {
let (description, status_code) = match err {
PullsRequestReviewersError::Status422 => (String::from("Unprocessable Entity if user is not a collaborator"), 422),
PullsRequestReviewersError::Status403(_) => (String::from("Forbidden"), 403),
PullsRequestReviewersError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Submit a review for a pull request](Pulls::submit_review_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PullsSubmitReviewError {
#[error("Resource not found")]
Status404(BasicError),
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationErrorSimple),
#[error("Forbidden")]
Status403(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PullsSubmitReviewError> for AdapterError {
fn from(err: PullsSubmitReviewError) -> Self {
let (description, status_code) = match err {
PullsSubmitReviewError::Status404(_) => (String::from("Resource not found"), 404),
PullsSubmitReviewError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
PullsSubmitReviewError::Status403(_) => (String::from("Forbidden"), 403),
PullsSubmitReviewError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Update a pull request](Pulls::update_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PullsUpdateError {
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PullsUpdateError> for AdapterError {
fn from(err: PullsUpdateError) -> Self {
let (description, status_code) = match err {
PullsUpdateError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
PullsUpdateError::Status403(_) => (String::from("Forbidden"), 403),
PullsUpdateError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Update a pull request branch](Pulls::update_branch_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PullsUpdateBranchError {
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationError),
#[error("Forbidden")]
Status403(BasicError),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PullsUpdateBranchError> for AdapterError {
fn from(err: PullsUpdateBranchError) -> Self {
let (description, status_code) = match err {
PullsUpdateBranchError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
PullsUpdateBranchError::Status403(_) => (String::from("Forbidden"), 403),
PullsUpdateBranchError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Update a review for a pull request](Pulls::update_review_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PullsUpdateReviewError {
#[error("Validation failed, or the endpoint has been spammed.")]
Status422(ValidationErrorSimple),
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PullsUpdateReviewError> for AdapterError {
fn from(err: PullsUpdateReviewError) -> Self {
let (description, status_code) = match err {
PullsUpdateReviewError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422),
PullsUpdateReviewError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Errors for the [Update a review comment for a pull request](Pulls::update_review_comment_async()) endpoint.
#[derive(Debug, thiserror::Error)]
pub enum PullsUpdateReviewCommentError {
#[error("Status code: {}", code)]
Generic { code: u16 },
}
impl From<PullsUpdateReviewCommentError> for AdapterError {
fn from(err: PullsUpdateReviewCommentError) -> Self {
let (description, status_code) = match err {
PullsUpdateReviewCommentError::Generic { code } => (String::from("Generic"), code)
};
Self::Endpoint {
description,
status_code,
source: Some(Box::new(err))
}
}
}
/// Query parameters for the [List pull requests](Pulls::list_async()) endpoint.
#[derive(Default, Serialize)]
pub struct PullsListParams<'req> {
/// Either `open`, `closed`, or `all` to filter by state.
state: Option<&'req str>,
/// Filter pulls by head user or head organization and branch name in the format of `user:ref-name` or `organization:ref-name`. For example: `github:new-script-format` or `octocat:test-branch`.
head: Option<&'req str>,
/// Filter pulls by base branch name. Example: `gh-pages`.
base: Option<&'req str>,
/// What to sort results by. `popularity` will sort by the number of comments. `long-running` will sort by date created and will limit the results to pull requests that have been open for more than a month and have had activity within the past month.
sort: Option<&'req str>,
/// The direction of the sort. Default: `desc` when sort is `created` or sort is not specified, otherwise `asc`.
direction: Option<&'req str>,
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
per_page: Option<u16>,
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
page: Option<u16>
}
impl<'req> PullsListParams<'req> {
pub fn new() -> Self {
Self::default()
}
/// Either `open`, `closed`, or `all` to filter by state.
pub fn state(self, state: &'req str) -> Self {
Self {
state: Some(state),
head: self.head,
base: self.base,
sort: self.sort,
direction: self.direction,
per_page: self.per_page,
page: self.page,
}
}
/// Filter pulls by head user or head organization and branch name in the format of `user:ref-name` or `organization:ref-name`. For example: `github:new-script-format` or `octocat:test-branch`.
pub fn head(self, head: &'req str) -> Self {
Self {
state: self.state,
head: Some(head),
base: self.base,
sort: self.sort,
direction: self.direction,
per_page: self.per_page,
page: self.page,
}
}
/// Filter pulls by base branch name. Example: `gh-pages`.
pub fn base(self, base: &'req str) -> Self {
Self {
state: self.state,
head: self.head,
base: Some(base),
sort: self.sort,
direction: self.direction,
per_page: self.per_page,
page: self.page,
}
}
/// What to sort results by. `popularity` will sort by the number of comments. `long-running` will sort by date created and will limit the results to pull requests that have been open for more than a month and have had activity within the past month.
pub fn sort(self, sort: &'req str) -> Self {
Self {
state: self.state,
head: self.head,
base: self.base,
sort: Some(sort),
direction: self.direction,
per_page: self.per_page,
page: self.page,
}
}
/// The direction of the sort. Default: `desc` when sort is `created` or sort is not specified, otherwise `asc`.
pub fn direction(self, direction: &'req str) -> Self {
Self {
state: self.state,
head: self.head,
base: self.base,
sort: self.sort,
direction: Some(direction),
per_page: self.per_page,
page: self.page,
}
}
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn per_page(self, per_page: u16) -> Self {
Self {
state: self.state,
head: self.head,
base: self.base,
sort: self.sort,
direction: self.direction,
per_page: Some(per_page),
page: self.page,
}
}
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn page(self, page: u16) -> Self {
Self {
state: self.state,
head: self.head,
base: self.base,
sort: self.sort,
direction: self.direction,
per_page: self.per_page,
page: Some(page),
}
}
}
impl<'enc> From<&'enc PerPage> for PullsListParams<'enc> {
fn from(per_page: &'enc PerPage) -> Self {
Self {
per_page: Some(per_page.per_page),
page: Some(per_page.page),
..Default::default()
}
}
}
/// Query parameters for the [List comments for a pull request review](Pulls::list_comments_for_review_async()) endpoint.
#[derive(Default, Serialize)]
pub struct PullsListCommentsForReviewParams {
/// 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 PullsListCommentsForReviewParams {
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 PullsListCommentsForReviewParams {
fn from(per_page: &'enc PerPage) -> Self {
Self {
per_page: Some(per_page.per_page),
page: Some(per_page.page),
..Default::default()
}
}
}
/// Query parameters for the [List commits on a pull request](Pulls::list_commits_async()) endpoint.
#[derive(Default, Serialize)]
pub struct PullsListCommitsParams {
/// 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 PullsListCommitsParams {
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 PullsListCommitsParams {
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 pull requests files](Pulls::list_files_async()) endpoint.
#[derive(Default, Serialize)]
pub struct PullsListFilesParams {
/// 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 PullsListFilesParams {
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 PullsListFilesParams {
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 review comments on a pull request](Pulls::list_review_comments_async()) endpoint.
#[derive(Default, Serialize)]
pub struct PullsListReviewCommentsParams<'req> {
/// The property to sort the results by.
sort: Option<&'req str>,
/// The direction to sort results. Ignored without `sort` parameter.
direction: Option<&'req str>,
/// Only show results that were last updated after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
since: Option<chrono::DateTime<chrono::Utc>>,
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
per_page: Option<u16>,
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
page: Option<u16>
}
impl<'req> PullsListReviewCommentsParams<'req> {
pub fn new() -> Self {
Self::default()
}
/// The property to sort the results by.
pub fn sort(self, sort: &'req str) -> Self {
Self {
sort: Some(sort),
direction: self.direction,
since: self.since,
per_page: self.per_page,
page: self.page,
}
}
/// The direction to sort results. Ignored without `sort` parameter.
pub fn direction(self, direction: &'req str) -> Self {
Self {
sort: self.sort,
direction: Some(direction),
since: self.since,
per_page: self.per_page,
page: self.page,
}
}
/// Only show results that were last updated after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
pub fn since(self, since: chrono::DateTime<chrono::Utc>) -> Self {
Self {
sort: self.sort,
direction: self.direction,
since: Some(since),
per_page: self.per_page,
page: self.page,
}
}
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn per_page(self, per_page: u16) -> Self {
Self {
sort: self.sort,
direction: self.direction,
since: self.since,
per_page: Some(per_page),
page: self.page,
}
}
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn page(self, page: u16) -> Self {
Self {
sort: self.sort,
direction: self.direction,
since: self.since,
per_page: self.per_page,
page: Some(page),
}
}
}
impl<'enc> From<&'enc PerPage> for PullsListReviewCommentsParams<'enc> {
fn from(per_page: &'enc PerPage) -> Self {
Self {
per_page: Some(per_page.per_page),
page: Some(per_page.page),
..Default::default()
}
}
}
/// Query parameters for the [List review comments in a repository](Pulls::list_review_comments_for_repo_async()) endpoint.
#[derive(Default, Serialize)]
pub struct PullsListReviewCommentsForRepoParams<'req> {
sort: Option<&'req str>,
/// The direction to sort results. Ignored without `sort` parameter.
direction: Option<&'req str>,
/// Only show results that were last updated after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
since: Option<chrono::DateTime<chrono::Utc>>,
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
per_page: Option<u16>,
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
page: Option<u16>
}
impl<'req> PullsListReviewCommentsForRepoParams<'req> {
pub fn new() -> Self {
Self::default()
}
pub fn sort(self, sort: &'req str) -> Self {
Self {
sort: Some(sort),
direction: self.direction,
since: self.since,
per_page: self.per_page,
page: self.page,
}
}
/// The direction to sort results. Ignored without `sort` parameter.
pub fn direction(self, direction: &'req str) -> Self {
Self {
sort: self.sort,
direction: Some(direction),
since: self.since,
per_page: self.per_page,
page: self.page,
}
}
/// Only show results that were last updated after the given time. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
pub fn since(self, since: chrono::DateTime<chrono::Utc>) -> Self {
Self {
sort: self.sort,
direction: self.direction,
since: Some(since),
per_page: self.per_page,
page: self.page,
}
}
/// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn per_page(self, per_page: u16) -> Self {
Self {
sort: self.sort,
direction: self.direction,
since: self.since,
per_page: Some(per_page),
page: self.page,
}
}
/// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"
pub fn page(self, page: u16) -> Self {
Self {
sort: self.sort,
direction: self.direction,
since: self.since,
per_page: self.per_page,
page: Some(page),
}
}
}
impl<'enc> From<&'enc PerPage> for PullsListReviewCommentsForRepoParams<'enc> {
fn from(per_page: &'enc PerPage) -> Self {
Self {
per_page: Some(per_page.per_page),
page: Some(per_page.page),
..Default::default()
}
}
}
/// Query parameters for the [List reviews for a pull request](Pulls::list_reviews_async()) endpoint.
#[derive(Default, Serialize)]
pub struct PullsListReviewsParams {
/// 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 PullsListReviewsParams {
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 PullsListReviewsParams {
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> Pulls<'api, C> where AdapterError: From<<C as Client>::Err> {
/// ---
///
/// # Check if a pull request has been merged
///
/// Checks if a pull request has been merged into the base branch. The HTTP status of the response indicates whether or not the pull request has been merged; the response body is empty.
///
/// [GitHub API docs for check_if_merged](https://docs.github.com/rest/pulls/pulls#check-if-a-pull-request-has-been-merged)
///
/// ---
pub async fn check_if_merged_async(&self, owner: &str, repo: &str, pull_number: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pulls/{}/merge", super::GITHUB_BASE_API_URL, owner, repo, pull_number);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
404 => Err(PullsCheckIfMergedError::Status404.into()),
code => Err(PullsCheckIfMergedError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Check if a pull request has been merged
///
/// Checks if a pull request has been merged into the base branch. The HTTP status of the response indicates whether or not the pull request has been merged; the response body is empty.
///
/// [GitHub API docs for check_if_merged](https://docs.github.com/rest/pulls/pulls#check-if-a-pull-request-has-been-merged)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn check_if_merged(&self, owner: &str, repo: &str, pull_number: i32) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pulls/{}/merge", super::GITHUB_BASE_API_URL, owner, repo, pull_number);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
404 => Err(PullsCheckIfMergedError::Status404.into()),
code => Err(PullsCheckIfMergedError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a pull request
///
/// Draft pull requests are available in public repositories with GitHub Free and GitHub Free for organizations, GitHub Pro, and legacy per-repository billing plans, and in public and private repositories with GitHub Team and GitHub Enterprise Cloud. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// To open or update a pull request in a public repository, you must have write access to the head or the source branch. For organization-owned repositories, you must be a member of the organization that owns the repository to open or update a pull request.
///
/// This endpoint triggers [notifications](https://docs.github.com/github/managing-subscriptions-and-notifications-on-github/about-notifications). Creating content too quickly using this endpoint may result in secondary rate limiting. For more information, see "[Rate limits for the API](https://docs.github.com/rest/using-the-rest-api/rate-limits-for-the-rest-api#about-secondary-rate-limits)" and "[Best practices for using the REST API](https://docs.github.com/rest/guides/best-practices-for-using-the-rest-api)."
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
///
/// [GitHub API docs for create](https://docs.github.com/rest/pulls/pulls#create-a-pull-request)
///
/// ---
pub async fn create_async(&self, owner: &str, repo: &str, body: PostPullsCreate) -> Result<PullRequest, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pulls", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostPullsCreate>(body)?),
method: "POST",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
403 => Err(PullsCreateError::Status403(github_response.to_json_async().await?).into()),
422 => Err(PullsCreateError::Status422(github_response.to_json_async().await?).into()),
code => Err(PullsCreateError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a pull request
///
/// Draft pull requests are available in public repositories with GitHub Free and GitHub Free for organizations, GitHub Pro, and legacy per-repository billing plans, and in public and private repositories with GitHub Team and GitHub Enterprise Cloud. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// To open or update a pull request in a public repository, you must have write access to the head or the source branch. For organization-owned repositories, you must be a member of the organization that owns the repository to open or update a pull request.
///
/// This endpoint triggers [notifications](https://docs.github.com/github/managing-subscriptions-and-notifications-on-github/about-notifications). Creating content too quickly using this endpoint may result in secondary rate limiting. For more information, see "[Rate limits for the API](https://docs.github.com/rest/using-the-rest-api/rate-limits-for-the-rest-api#about-secondary-rate-limits)" and "[Best practices for using the REST API](https://docs.github.com/rest/guides/best-practices-for-using-the-rest-api)."
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
///
/// [GitHub API docs for create](https://docs.github.com/rest/pulls/pulls#create-a-pull-request)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn create(&self, owner: &str, repo: &str, body: PostPullsCreate) -> Result<PullRequest, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pulls", super::GITHUB_BASE_API_URL, owner, repo);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostPullsCreate>(body)?),
method: "POST",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
403 => Err(PullsCreateError::Status403(github_response.to_json()?).into()),
422 => Err(PullsCreateError::Status422(github_response.to_json()?).into()),
code => Err(PullsCreateError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a reply for a review comment
///
/// Creates a reply to a review comment for a pull request. For the `comment_id`, provide the ID of the review comment you are replying to. This must be the ID of a _top-level review comment_, not a reply to that comment. Replies to replies are not supported.
///
/// This endpoint triggers [notifications](https://docs.github.com/github/managing-subscriptions-and-notifications-on-github/about-notifications). Creating content too quickly using this endpoint may result in secondary rate limiting. For more information, see "[Rate limits for the API](https://docs.github.com/rest/using-the-rest-api/rate-limits-for-the-rest-api#about-secondary-rate-limits)"
/// and "[Best practices for using the REST API](https://docs.github.com/rest/guides/best-practices-for-using-the-rest-api)."
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
///
/// [GitHub API docs for create_reply_for_review_comment](https://docs.github.com/rest/pulls/comments#create-a-reply-for-a-review-comment)
///
/// ---
pub async fn create_reply_for_review_comment_async(&self, owner: &str, repo: &str, pull_number: i32, comment_id: i64, body: PostPullsCreateReplyForReviewComment) -> Result<PullRequestReviewComment, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pulls/{}/comments/{}/replies", super::GITHUB_BASE_API_URL, owner, repo, pull_number, comment_id);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostPullsCreateReplyForReviewComment>(body)?),
method: "POST",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
404 => Err(PullsCreateReplyForReviewCommentError::Status404(github_response.to_json_async().await?).into()),
code => Err(PullsCreateReplyForReviewCommentError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a reply for a review comment
///
/// Creates a reply to a review comment for a pull request. For the `comment_id`, provide the ID of the review comment you are replying to. This must be the ID of a _top-level review comment_, not a reply to that comment. Replies to replies are not supported.
///
/// This endpoint triggers [notifications](https://docs.github.com/github/managing-subscriptions-and-notifications-on-github/about-notifications). Creating content too quickly using this endpoint may result in secondary rate limiting. For more information, see "[Rate limits for the API](https://docs.github.com/rest/using-the-rest-api/rate-limits-for-the-rest-api#about-secondary-rate-limits)"
/// and "[Best practices for using the REST API](https://docs.github.com/rest/guides/best-practices-for-using-the-rest-api)."
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
///
/// [GitHub API docs for create_reply_for_review_comment](https://docs.github.com/rest/pulls/comments#create-a-reply-for-a-review-comment)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn create_reply_for_review_comment(&self, owner: &str, repo: &str, pull_number: i32, comment_id: i64, body: PostPullsCreateReplyForReviewComment) -> Result<PullRequestReviewComment, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pulls/{}/comments/{}/replies", super::GITHUB_BASE_API_URL, owner, repo, pull_number, comment_id);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostPullsCreateReplyForReviewComment>(body)?),
method: "POST",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
404 => Err(PullsCreateReplyForReviewCommentError::Status404(github_response.to_json()?).into()),
code => Err(PullsCreateReplyForReviewCommentError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a review for a pull request
///
/// Creates a review on a specified pull request.
///
/// This endpoint triggers [notifications](https://docs.github.com/github/managing-subscriptions-and-notifications-on-github/about-notifications). Creating content too quickly using this endpoint may result in secondary rate limiting. For more information, see "[Rate limits for the API](https://docs.github.com/rest/using-the-rest-api/rate-limits-for-the-rest-api#about-secondary-rate-limits)" and "[Best practices for using the REST API](https://docs.github.com/rest/guides/best-practices-for-using-the-rest-api)."
///
/// Pull request reviews created in the `PENDING` state are not submitted and therefore do not include the `submitted_at` property in the response. To create a pending review for a pull request, leave the `event` parameter blank. For more information about submitting a `PENDING` review, see "[Submit a review for a pull request](https://docs.github.com/rest/pulls/reviews#submit-a-review-for-a-pull-request)."
///
/// > [!NOTE]
/// > To comment on a specific line in a file, you need to first determine the position of that line in the diff. To see a pull request diff, add the `application/vnd.github.v3.diff` media type to the `Accept` header of a call to the [Get a pull request](https://docs.github.com/rest/pulls/pulls#get-a-pull-request) endpoint.
///
/// The `position` value equals the number of lines down from the first "@@" hunk header in the file you want to add a comment. The line just below the "@@" line is position 1, the next line is position 2, and so on. The position in the diff continues to increase through lines of whitespace and additional hunks until the beginning of a new file.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
///
/// [GitHub API docs for create_review](https://docs.github.com/rest/pulls/reviews#create-a-review-for-a-pull-request)
///
/// ---
pub async fn create_review_async(&self, owner: &str, repo: &str, pull_number: i32, body: PostPullsCreateReview) -> Result<PullRequestReview, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pulls/{}/reviews", super::GITHUB_BASE_API_URL, owner, repo, pull_number);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostPullsCreateReview>(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(PullsCreateReviewError::Status422(github_response.to_json_async().await?).into()),
403 => Err(PullsCreateReviewError::Status403(github_response.to_json_async().await?).into()),
code => Err(PullsCreateReviewError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a review for a pull request
///
/// Creates a review on a specified pull request.
///
/// This endpoint triggers [notifications](https://docs.github.com/github/managing-subscriptions-and-notifications-on-github/about-notifications). Creating content too quickly using this endpoint may result in secondary rate limiting. For more information, see "[Rate limits for the API](https://docs.github.com/rest/using-the-rest-api/rate-limits-for-the-rest-api#about-secondary-rate-limits)" and "[Best practices for using the REST API](https://docs.github.com/rest/guides/best-practices-for-using-the-rest-api)."
///
/// Pull request reviews created in the `PENDING` state are not submitted and therefore do not include the `submitted_at` property in the response. To create a pending review for a pull request, leave the `event` parameter blank. For more information about submitting a `PENDING` review, see "[Submit a review for a pull request](https://docs.github.com/rest/pulls/reviews#submit-a-review-for-a-pull-request)."
///
/// > [!NOTE]
/// > To comment on a specific line in a file, you need to first determine the position of that line in the diff. To see a pull request diff, add the `application/vnd.github.v3.diff` media type to the `Accept` header of a call to the [Get a pull request](https://docs.github.com/rest/pulls/pulls#get-a-pull-request) endpoint.
///
/// The `position` value equals the number of lines down from the first "@@" hunk header in the file you want to add a comment. The line just below the "@@" line is position 1, the next line is position 2, and so on. The position in the diff continues to increase through lines of whitespace and additional hunks until the beginning of a new file.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
///
/// [GitHub API docs for create_review](https://docs.github.com/rest/pulls/reviews#create-a-review-for-a-pull-request)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn create_review(&self, owner: &str, repo: &str, pull_number: i32, body: PostPullsCreateReview) -> Result<PullRequestReview, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pulls/{}/reviews", super::GITHUB_BASE_API_URL, owner, repo, pull_number);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostPullsCreateReview>(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(PullsCreateReviewError::Status422(github_response.to_json()?).into()),
403 => Err(PullsCreateReviewError::Status403(github_response.to_json()?).into()),
code => Err(PullsCreateReviewError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a review comment for a pull request
///
/// Creates a review comment on the diff of a specified pull request. To add a regular comment to a pull request timeline, see "[Create an issue comment](https://docs.github.com/rest/issues/comments#create-an-issue-comment)."
///
/// If your comment applies to more than one line in the pull request diff, you should use the parameters `line`, `side`, and optionally `start_line` and `start_side` in your request.
///
/// The `position` parameter is closing down. If you use `position`, the `line`, `side`, `start_line`, and `start_side` parameters are not required.
///
/// This endpoint triggers [notifications](https://docs.github.com/github/managing-subscriptions-and-notifications-on-github/about-notifications). Creating content too quickly using this endpoint may result in secondary rate limiting. For more information, see "[Rate limits for the API](https://docs.github.com/rest/using-the-rest-api/rate-limits-for-the-rest-api#about-secondary-rate-limits)"
/// and "[Best practices for using the REST API](https://docs.github.com/rest/guides/best-practices-for-using-the-rest-api)."
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
///
/// [GitHub API docs for create_review_comment](https://docs.github.com/rest/pulls/comments#create-a-review-comment-for-a-pull-request)
///
/// ---
pub async fn create_review_comment_async(&self, owner: &str, repo: &str, pull_number: i32, body: PostPullsCreateReviewComment) -> Result<PullRequestReviewComment, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pulls/{}/comments", super::GITHUB_BASE_API_URL, owner, repo, pull_number);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostPullsCreateReviewComment>(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(PullsCreateReviewCommentError::Status422(github_response.to_json_async().await?).into()),
403 => Err(PullsCreateReviewCommentError::Status403(github_response.to_json_async().await?).into()),
code => Err(PullsCreateReviewCommentError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Create a review comment for a pull request
///
/// Creates a review comment on the diff of a specified pull request. To add a regular comment to a pull request timeline, see "[Create an issue comment](https://docs.github.com/rest/issues/comments#create-an-issue-comment)."
///
/// If your comment applies to more than one line in the pull request diff, you should use the parameters `line`, `side`, and optionally `start_line` and `start_side` in your request.
///
/// The `position` parameter is closing down. If you use `position`, the `line`, `side`, `start_line`, and `start_side` parameters are not required.
///
/// This endpoint triggers [notifications](https://docs.github.com/github/managing-subscriptions-and-notifications-on-github/about-notifications). Creating content too quickly using this endpoint may result in secondary rate limiting. For more information, see "[Rate limits for the API](https://docs.github.com/rest/using-the-rest-api/rate-limits-for-the-rest-api#about-secondary-rate-limits)"
/// and "[Best practices for using the REST API](https://docs.github.com/rest/guides/best-practices-for-using-the-rest-api)."
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
///
/// [GitHub API docs for create_review_comment](https://docs.github.com/rest/pulls/comments#create-a-review-comment-for-a-pull-request)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn create_review_comment(&self, owner: &str, repo: &str, pull_number: i32, body: PostPullsCreateReviewComment) -> Result<PullRequestReviewComment, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pulls/{}/comments", super::GITHUB_BASE_API_URL, owner, repo, pull_number);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostPullsCreateReviewComment>(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(PullsCreateReviewCommentError::Status422(github_response.to_json()?).into()),
403 => Err(PullsCreateReviewCommentError::Status403(github_response.to_json()?).into()),
code => Err(PullsCreateReviewCommentError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a pending review for a pull request
///
/// Deletes a pull request review that has not been submitted. Submitted reviews cannot be deleted.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
///
/// [GitHub API docs for delete_pending_review](https://docs.github.com/rest/pulls/reviews#delete-a-pending-review-for-a-pull-request)
///
/// ---
pub async fn delete_pending_review_async(&self, owner: &str, repo: &str, pull_number: i32, review_id: i32) -> Result<PullRequestReview, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pulls/{}/reviews/{}", super::GITHUB_BASE_API_URL, owner, repo, pull_number, review_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(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
422 => Err(PullsDeletePendingReviewError::Status422(github_response.to_json_async().await?).into()),
404 => Err(PullsDeletePendingReviewError::Status404(github_response.to_json_async().await?).into()),
code => Err(PullsDeletePendingReviewError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a pending review for a pull request
///
/// Deletes a pull request review that has not been submitted. Submitted reviews cannot be deleted.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
///
/// [GitHub API docs for delete_pending_review](https://docs.github.com/rest/pulls/reviews#delete-a-pending-review-for-a-pull-request)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete_pending_review(&self, owner: &str, repo: &str, pull_number: i32, review_id: i32) -> Result<PullRequestReview, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pulls/{}/reviews/{}", super::GITHUB_BASE_API_URL, owner, repo, pull_number, review_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(github_response.to_json()?)
} else {
match github_response.status_code() {
422 => Err(PullsDeletePendingReviewError::Status422(github_response.to_json()?).into()),
404 => Err(PullsDeletePendingReviewError::Status404(github_response.to_json()?).into()),
code => Err(PullsDeletePendingReviewError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a review comment for a pull request
///
/// Deletes a review comment.
///
/// [GitHub API docs for delete_review_comment](https://docs.github.com/rest/pulls/comments#delete-a-review-comment-for-a-pull-request)
///
/// ---
pub async fn delete_review_comment_async(&self, owner: &str, repo: &str, comment_id: i64) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pulls/comments/{}", super::GITHUB_BASE_API_URL, owner, repo, comment_id);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
404 => Err(PullsDeleteReviewCommentError::Status404(github_response.to_json_async().await?).into()),
code => Err(PullsDeleteReviewCommentError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Delete a review comment for a pull request
///
/// Deletes a review comment.
///
/// [GitHub API docs for delete_review_comment](https://docs.github.com/rest/pulls/comments#delete-a-review-comment-for-a-pull-request)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn delete_review_comment(&self, owner: &str, repo: &str, comment_id: i64) -> Result<(), AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pulls/comments/{}", super::GITHUB_BASE_API_URL, owner, repo, comment_id);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(())
} else {
match github_response.status_code() {
404 => Err(PullsDeleteReviewCommentError::Status404(github_response.to_json()?).into()),
code => Err(PullsDeleteReviewCommentError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Dismiss a review for a pull request
///
/// Dismisses a specified review on a pull request.
///
/// > [!NOTE]
/// > To dismiss a pull request review on a [protected branch](https://docs.github.com/rest/branches/branch-protection), you must be a repository administrator or be included in the list of people or teams who can dismiss pull request reviews.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
///
/// [GitHub API docs for dismiss_review](https://docs.github.com/rest/pulls/reviews#dismiss-a-review-for-a-pull-request)
///
/// ---
pub async fn dismiss_review_async(&self, owner: &str, repo: &str, pull_number: i32, review_id: i32, body: PutPullsDismissReview) -> Result<PullRequestReview, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pulls/{}/reviews/{}/dismissals", super::GITHUB_BASE_API_URL, owner, repo, pull_number, review_id);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutPullsDismissReview>(body)?),
method: "PUT",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
404 => Err(PullsDismissReviewError::Status404(github_response.to_json_async().await?).into()),
422 => Err(PullsDismissReviewError::Status422(github_response.to_json_async().await?).into()),
code => Err(PullsDismissReviewError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Dismiss a review for a pull request
///
/// Dismisses a specified review on a pull request.
///
/// > [!NOTE]
/// > To dismiss a pull request review on a [protected branch](https://docs.github.com/rest/branches/branch-protection), you must be a repository administrator or be included in the list of people or teams who can dismiss pull request reviews.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
///
/// [GitHub API docs for dismiss_review](https://docs.github.com/rest/pulls/reviews#dismiss-a-review-for-a-pull-request)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn dismiss_review(&self, owner: &str, repo: &str, pull_number: i32, review_id: i32, body: PutPullsDismissReview) -> Result<PullRequestReview, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pulls/{}/reviews/{}/dismissals", super::GITHUB_BASE_API_URL, owner, repo, pull_number, review_id);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutPullsDismissReview>(body)?),
method: "PUT",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
404 => Err(PullsDismissReviewError::Status404(github_response.to_json()?).into()),
422 => Err(PullsDismissReviewError::Status422(github_response.to_json()?).into()),
code => Err(PullsDismissReviewError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a pull request
///
/// Draft pull requests are available in public repositories with GitHub Free and GitHub Free for organizations, GitHub Pro, and legacy per-repository billing plans, and in public and private repositories with GitHub Team and GitHub Enterprise Cloud. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// Lists details of a pull request by providing its number.
///
/// When you get, [create](https://docs.github.com/rest/pulls/pulls/#create-a-pull-request), or [edit](https://docs.github.com/rest/pulls/pulls#update-a-pull-request) a pull request, GitHub creates a merge commit to test whether the pull request can be automatically merged into the base branch. This test commit is not added to the base branch or the head branch. You can review the status of the test commit using the `mergeable` key. For more information, see "[Checking mergeability of pull requests](https://docs.github.com/rest/guides/getting-started-with-the-git-database-api#checking-mergeability-of-pull-requests)".
///
/// The value of the `mergeable` attribute can be `true`, `false`, or `null`. If the value is `null`, then GitHub has started a background job to compute the mergeability. After giving the job time to complete, resubmit the request. When the job finishes, you will see a non-`null` value for the `mergeable` attribute in the response. If `mergeable` is `true`, then `merge_commit_sha` will be the SHA of the _test_ merge commit.
///
/// The value of the `merge_commit_sha` attribute changes depending on the state of the pull request. Before merging a pull request, the `merge_commit_sha` attribute holds the SHA of the _test_ merge commit. After merging a pull request, the `merge_commit_sha` attribute changes depending on how you merged the pull request:
///
/// * If merged as a [merge commit](https://docs.github.com/articles/about-merge-methods-on-github/), `merge_commit_sha` represents the SHA of the merge commit.
/// * If merged via a [squash](https://docs.github.com/articles/about-merge-methods-on-github/#squashing-your-merge-commits), `merge_commit_sha` represents the SHA of the squashed commit on the base branch.
/// * If [rebased](https://docs.github.com/articles/about-merge-methods-on-github/#rebasing-and-merging-your-commits), `merge_commit_sha` represents the commit that the base branch was updated to.
///
/// Pass the appropriate [media type](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types) to fetch diff and patch formats.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
/// - **`application/vnd.github.diff`**: For more information, see "[git-diff](https://git-scm.com/docs/git-diff)" in the Git documentation. If a diff is corrupt, contact us through the [GitHub Support portal](https://support.github.com/). Include the repository name and pull request ID in your message.
///
/// [GitHub API docs for get](https://docs.github.com/rest/pulls/pulls#get-a-pull-request)
///
/// ---
pub async fn get_async(&self, owner: &str, repo: &str, pull_number: i32) -> Result<PullRequest, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pulls/{}", super::GITHUB_BASE_API_URL, owner, repo, pull_number);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
304 => Err(PullsGetError::Status304.into()),
404 => Err(PullsGetError::Status404(github_response.to_json_async().await?).into()),
406 => Err(PullsGetError::Status406(github_response.to_json_async().await?).into()),
500 => Err(PullsGetError::Status500(github_response.to_json_async().await?).into()),
503 => Err(PullsGetError::Status503(github_response.to_json_async().await?).into()),
code => Err(PullsGetError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a pull request
///
/// Draft pull requests are available in public repositories with GitHub Free and GitHub Free for organizations, GitHub Pro, and legacy per-repository billing plans, and in public and private repositories with GitHub Team and GitHub Enterprise Cloud. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// Lists details of a pull request by providing its number.
///
/// When you get, [create](https://docs.github.com/rest/pulls/pulls/#create-a-pull-request), or [edit](https://docs.github.com/rest/pulls/pulls#update-a-pull-request) a pull request, GitHub creates a merge commit to test whether the pull request can be automatically merged into the base branch. This test commit is not added to the base branch or the head branch. You can review the status of the test commit using the `mergeable` key. For more information, see "[Checking mergeability of pull requests](https://docs.github.com/rest/guides/getting-started-with-the-git-database-api#checking-mergeability-of-pull-requests)".
///
/// The value of the `mergeable` attribute can be `true`, `false`, or `null`. If the value is `null`, then GitHub has started a background job to compute the mergeability. After giving the job time to complete, resubmit the request. When the job finishes, you will see a non-`null` value for the `mergeable` attribute in the response. If `mergeable` is `true`, then `merge_commit_sha` will be the SHA of the _test_ merge commit.
///
/// The value of the `merge_commit_sha` attribute changes depending on the state of the pull request. Before merging a pull request, the `merge_commit_sha` attribute holds the SHA of the _test_ merge commit. After merging a pull request, the `merge_commit_sha` attribute changes depending on how you merged the pull request:
///
/// * If merged as a [merge commit](https://docs.github.com/articles/about-merge-methods-on-github/), `merge_commit_sha` represents the SHA of the merge commit.
/// * If merged via a [squash](https://docs.github.com/articles/about-merge-methods-on-github/#squashing-your-merge-commits), `merge_commit_sha` represents the SHA of the squashed commit on the base branch.
/// * If [rebased](https://docs.github.com/articles/about-merge-methods-on-github/#rebasing-and-merging-your-commits), `merge_commit_sha` represents the commit that the base branch was updated to.
///
/// Pass the appropriate [media type](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types) to fetch diff and patch formats.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
/// - **`application/vnd.github.diff`**: For more information, see "[git-diff](https://git-scm.com/docs/git-diff)" in the Git documentation. If a diff is corrupt, contact us through the [GitHub Support portal](https://support.github.com/). Include the repository name and pull request ID in your message.
///
/// [GitHub API docs for get](https://docs.github.com/rest/pulls/pulls#get-a-pull-request)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get(&self, owner: &str, repo: &str, pull_number: i32) -> Result<PullRequest, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pulls/{}", super::GITHUB_BASE_API_URL, owner, repo, pull_number);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
304 => Err(PullsGetError::Status304.into()),
404 => Err(PullsGetError::Status404(github_response.to_json()?).into()),
406 => Err(PullsGetError::Status406(github_response.to_json()?).into()),
500 => Err(PullsGetError::Status500(github_response.to_json()?).into()),
503 => Err(PullsGetError::Status503(github_response.to_json()?).into()),
code => Err(PullsGetError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a review for a pull request
///
/// Retrieves a pull request review by its ID.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
///
/// [GitHub API docs for get_review](https://docs.github.com/rest/pulls/reviews#get-a-review-for-a-pull-request)
///
/// ---
pub async fn get_review_async(&self, owner: &str, repo: &str, pull_number: i32, review_id: i32) -> Result<PullRequestReview, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pulls/{}/reviews/{}", super::GITHUB_BASE_API_URL, owner, repo, pull_number, review_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(PullsGetReviewError::Status404(github_response.to_json_async().await?).into()),
code => Err(PullsGetReviewError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a review for a pull request
///
/// Retrieves a pull request review by its ID.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
///
/// [GitHub API docs for get_review](https://docs.github.com/rest/pulls/reviews#get-a-review-for-a-pull-request)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_review(&self, owner: &str, repo: &str, pull_number: i32, review_id: i32) -> Result<PullRequestReview, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pulls/{}/reviews/{}", super::GITHUB_BASE_API_URL, owner, repo, pull_number, review_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(PullsGetReviewError::Status404(github_response.to_json()?).into()),
code => Err(PullsGetReviewError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a review comment for a pull request
///
/// Provides details for a specified review comment.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
///
/// [GitHub API docs for get_review_comment](https://docs.github.com/rest/pulls/comments#get-a-review-comment-for-a-pull-request)
///
/// ---
pub async fn get_review_comment_async(&self, owner: &str, repo: &str, comment_id: i64) -> Result<PullRequestReviewComment, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pulls/comments/{}", super::GITHUB_BASE_API_URL, owner, repo, comment_id);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
404 => Err(PullsGetReviewCommentError::Status404(github_response.to_json_async().await?).into()),
code => Err(PullsGetReviewCommentError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get a review comment for a pull request
///
/// Provides details for a specified review comment.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
///
/// [GitHub API docs for get_review_comment](https://docs.github.com/rest/pulls/comments#get-a-review-comment-for-a-pull-request)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn get_review_comment(&self, owner: &str, repo: &str, comment_id: i64) -> Result<PullRequestReviewComment, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pulls/comments/{}", super::GITHUB_BASE_API_URL, owner, repo, comment_id);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
404 => Err(PullsGetReviewCommentError::Status404(github_response.to_json()?).into()),
code => Err(PullsGetReviewCommentError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List pull requests
///
/// Lists pull requests in a specified repository.
///
/// Draft pull requests are available in public repositories with GitHub
/// Free and GitHub Free for organizations, GitHub Pro, and legacy per-repository billing
/// plans, and in public and private repositories with GitHub Team and GitHub Enterprise
/// Cloud. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products)
/// in the GitHub Help documentation.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
///
/// [GitHub API docs for list](https://docs.github.com/rest/pulls/pulls#list-pull-requests)
///
/// ---
pub async fn list_async(&self, owner: &str, repo: &str, query_params: Option<impl Into<PullsListParams<'api>>>) -> Result<Vec<PullRequestSimple>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/pulls", super::GITHUB_BASE_API_URL, owner, repo);
if let Some(params) = query_params {
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(params.into())?);
}
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
304 => Err(PullsListError::Status304.into()),
422 => Err(PullsListError::Status422(github_response.to_json_async().await?).into()),
code => Err(PullsListError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List pull requests
///
/// Lists pull requests in a specified repository.
///
/// Draft pull requests are available in public repositories with GitHub
/// Free and GitHub Free for organizations, GitHub Pro, and legacy per-repository billing
/// plans, and in public and private repositories with GitHub Team and GitHub Enterprise
/// Cloud. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products)
/// in the GitHub Help documentation.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
///
/// [GitHub API docs for list](https://docs.github.com/rest/pulls/pulls#list-pull-requests)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list(&self, owner: &str, repo: &str, query_params: Option<impl Into<PullsListParams<'api>>>) -> Result<Vec<PullRequestSimple>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/pulls", super::GITHUB_BASE_API_URL, owner, repo);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: PullsListParams = 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(PullsListError::Status304.into()),
422 => Err(PullsListError::Status422(github_response.to_json()?).into()),
code => Err(PullsListError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List comments for a pull request review
///
/// Lists comments for a specific pull request review.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
///
/// [GitHub API docs for list_comments_for_review](https://docs.github.com/rest/pulls/reviews#list-comments-for-a-pull-request-review)
///
/// ---
pub async fn list_comments_for_review_async(&self, owner: &str, repo: &str, pull_number: i32, review_id: i32, query_params: Option<impl Into<PullsListCommentsForReviewParams>>) -> Result<Vec<ReviewComment>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/pulls/{}/reviews/{}/comments", super::GITHUB_BASE_API_URL, owner, repo, pull_number, review_id);
if let Some(params) = query_params {
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(params.into())?);
}
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
404 => Err(PullsListCommentsForReviewError::Status404(github_response.to_json_async().await?).into()),
code => Err(PullsListCommentsForReviewError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List comments for a pull request review
///
/// Lists comments for a specific pull request review.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
///
/// [GitHub API docs for list_comments_for_review](https://docs.github.com/rest/pulls/reviews#list-comments-for-a-pull-request-review)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_comments_for_review(&self, owner: &str, repo: &str, pull_number: i32, review_id: i32, query_params: Option<impl Into<PullsListCommentsForReviewParams>>) -> Result<Vec<ReviewComment>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/pulls/{}/reviews/{}/comments", super::GITHUB_BASE_API_URL, owner, repo, pull_number, review_id);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: PullsListCommentsForReviewParams = 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(PullsListCommentsForReviewError::Status404(github_response.to_json()?).into()),
code => Err(PullsListCommentsForReviewError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List commits on a pull request
///
/// Lists a maximum of 250 commits for a pull request. To receive a complete
/// commit list for pull requests with more than 250 commits, use the [List commits](https://docs.github.com/rest/commits/commits#list-commits)
/// endpoint.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
///
/// [GitHub API docs for list_commits](https://docs.github.com/rest/pulls/pulls#list-commits-on-a-pull-request)
///
/// ---
pub async fn list_commits_async(&self, owner: &str, repo: &str, pull_number: i32, query_params: Option<impl Into<PullsListCommitsParams>>) -> Result<Vec<Commit>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/pulls/{}/commits", super::GITHUB_BASE_API_URL, owner, repo, pull_number);
if let Some(params) = query_params {
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(params.into())?);
}
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
code => Err(PullsListCommitsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List commits on a pull request
///
/// Lists a maximum of 250 commits for a pull request. To receive a complete
/// commit list for pull requests with more than 250 commits, use the [List commits](https://docs.github.com/rest/commits/commits#list-commits)
/// endpoint.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
///
/// [GitHub API docs for list_commits](https://docs.github.com/rest/pulls/pulls#list-commits-on-a-pull-request)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_commits(&self, owner: &str, repo: &str, pull_number: i32, query_params: Option<impl Into<PullsListCommitsParams>>) -> Result<Vec<Commit>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/pulls/{}/commits", super::GITHUB_BASE_API_URL, owner, repo, pull_number);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: PullsListCommitsParams = 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(PullsListCommitsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List pull requests files
///
/// Lists the files in a specified pull request.
///
/// > [!NOTE]
/// > Responses include a maximum of 3000 files. The paginated response returns 30 files per page by default.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
///
/// [GitHub API docs for list_files](https://docs.github.com/rest/pulls/pulls#list-pull-requests-files)
///
/// ---
pub async fn list_files_async(&self, owner: &str, repo: &str, pull_number: i32, query_params: Option<impl Into<PullsListFilesParams>>) -> Result<Vec<DiffEntry>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/pulls/{}/files", super::GITHUB_BASE_API_URL, owner, repo, pull_number);
if let Some(params) = query_params {
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(params.into())?);
}
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
422 => Err(PullsListFilesError::Status422(github_response.to_json_async().await?).into()),
500 => Err(PullsListFilesError::Status500(github_response.to_json_async().await?).into()),
503 => Err(PullsListFilesError::Status503(github_response.to_json_async().await?).into()),
code => Err(PullsListFilesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List pull requests files
///
/// Lists the files in a specified pull request.
///
/// > [!NOTE]
/// > Responses include a maximum of 3000 files. The paginated response returns 30 files per page by default.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
///
/// [GitHub API docs for list_files](https://docs.github.com/rest/pulls/pulls#list-pull-requests-files)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_files(&self, owner: &str, repo: &str, pull_number: i32, query_params: Option<impl Into<PullsListFilesParams>>) -> Result<Vec<DiffEntry>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/pulls/{}/files", super::GITHUB_BASE_API_URL, owner, repo, pull_number);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: PullsListFilesParams = params.into();
request_uri.push_str(&serde_urlencoded::to_string(qp)?);
}
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
422 => Err(PullsListFilesError::Status422(github_response.to_json()?).into()),
500 => Err(PullsListFilesError::Status500(github_response.to_json()?).into()),
503 => Err(PullsListFilesError::Status503(github_response.to_json()?).into()),
code => Err(PullsListFilesError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get all requested reviewers for a pull request
///
/// Gets the users or teams whose review is requested for a pull request. Once a requested reviewer submits a review, they are no longer considered a requested reviewer. Their review will instead be returned by the [List reviews for a pull request](https://docs.github.com/rest/pulls/reviews#list-reviews-for-a-pull-request) operation.
///
/// [GitHub API docs for list_requested_reviewers](https://docs.github.com/rest/pulls/review-requests#get-all-requested-reviewers-for-a-pull-request)
///
/// ---
pub async fn list_requested_reviewers_async(&self, owner: &str, repo: &str, pull_number: i32) -> Result<PullRequestReviewRequest, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pulls/{}/requested_reviewers", super::GITHUB_BASE_API_URL, owner, repo, pull_number);
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
code => Err(PullsListRequestedReviewersError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Get all requested reviewers for a pull request
///
/// Gets the users or teams whose review is requested for a pull request. Once a requested reviewer submits a review, they are no longer considered a requested reviewer. Their review will instead be returned by the [List reviews for a pull request](https://docs.github.com/rest/pulls/reviews#list-reviews-for-a-pull-request) operation.
///
/// [GitHub API docs for list_requested_reviewers](https://docs.github.com/rest/pulls/review-requests#get-all-requested-reviewers-for-a-pull-request)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_requested_reviewers(&self, owner: &str, repo: &str, pull_number: i32) -> Result<PullRequestReviewRequest, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pulls/{}/requested_reviewers", super::GITHUB_BASE_API_URL, owner, repo, pull_number);
let req = GitHubRequest {
uri: request_uri,
body: None,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
code => Err(PullsListRequestedReviewersError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List review comments on a pull request
///
/// Lists all review comments for a specified pull request. By default, review comments
/// are in ascending order by ID.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
///
/// [GitHub API docs for list_review_comments](https://docs.github.com/rest/pulls/comments#list-review-comments-on-a-pull-request)
///
/// ---
pub async fn list_review_comments_async(&self, owner: &str, repo: &str, pull_number: i32, query_params: Option<impl Into<PullsListReviewCommentsParams<'api>>>) -> Result<Vec<PullRequestReviewComment>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/pulls/{}/comments", super::GITHUB_BASE_API_URL, owner, repo, pull_number);
if let Some(params) = query_params {
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(params.into())?);
}
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
code => Err(PullsListReviewCommentsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List review comments on a pull request
///
/// Lists all review comments for a specified pull request. By default, review comments
/// are in ascending order by ID.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
///
/// [GitHub API docs for list_review_comments](https://docs.github.com/rest/pulls/comments#list-review-comments-on-a-pull-request)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_review_comments(&self, owner: &str, repo: &str, pull_number: i32, query_params: Option<impl Into<PullsListReviewCommentsParams<'api>>>) -> Result<Vec<PullRequestReviewComment>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/pulls/{}/comments", super::GITHUB_BASE_API_URL, owner, repo, pull_number);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: PullsListReviewCommentsParams = 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(PullsListReviewCommentsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List review comments in a repository
///
/// Lists review comments for all pull requests in a repository. By default,
/// review comments are in ascending order by ID.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
///
/// [GitHub API docs for list_review_comments_for_repo](https://docs.github.com/rest/pulls/comments#list-review-comments-in-a-repository)
///
/// ---
pub async fn list_review_comments_for_repo_async(&self, owner: &str, repo: &str, query_params: Option<impl Into<PullsListReviewCommentsForRepoParams<'api>>>) -> Result<Vec<PullRequestReviewComment>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/pulls/comments", super::GITHUB_BASE_API_URL, owner, repo);
if let Some(params) = query_params {
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(params.into())?);
}
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
code => Err(PullsListReviewCommentsForRepoError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List review comments in a repository
///
/// Lists review comments for all pull requests in a repository. By default,
/// review comments are in ascending order by ID.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
///
/// [GitHub API docs for list_review_comments_for_repo](https://docs.github.com/rest/pulls/comments#list-review-comments-in-a-repository)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_review_comments_for_repo(&self, owner: &str, repo: &str, query_params: Option<impl Into<PullsListReviewCommentsForRepoParams<'api>>>) -> Result<Vec<PullRequestReviewComment>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/pulls/comments", super::GITHUB_BASE_API_URL, owner, repo);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: PullsListReviewCommentsForRepoParams = 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(PullsListReviewCommentsForRepoError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List reviews for a pull request
///
/// Lists all reviews for a specified pull request. The list of reviews returns in chronological order.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
///
/// [GitHub API docs for list_reviews](https://docs.github.com/rest/pulls/reviews#list-reviews-for-a-pull-request)
///
/// ---
pub async fn list_reviews_async(&self, owner: &str, repo: &str, pull_number: i32, query_params: Option<impl Into<PullsListReviewsParams>>) -> Result<Vec<PullRequestReview>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/pulls/{}/reviews", super::GITHUB_BASE_API_URL, owner, repo, pull_number);
if let Some(params) = query_params {
request_uri.push_str("?");
request_uri.push_str(&serde_urlencoded::to_string(params.into())?);
}
let req = GitHubRequest {
uri: request_uri,
body: None::<C::Body>,
method: "GET",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
code => Err(PullsListReviewsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # List reviews for a pull request
///
/// Lists all reviews for a specified pull request. The list of reviews returns in chronological order.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
///
/// [GitHub API docs for list_reviews](https://docs.github.com/rest/pulls/reviews#list-reviews-for-a-pull-request)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn list_reviews(&self, owner: &str, repo: &str, pull_number: i32, query_params: Option<impl Into<PullsListReviewsParams>>) -> Result<Vec<PullRequestReview>, AdapterError> {
let mut request_uri = format!("{}/repos/{}/{}/pulls/{}/reviews", super::GITHUB_BASE_API_URL, owner, repo, pull_number);
if let Some(params) = query_params {
request_uri.push_str("?");
let qp: PullsListReviewsParams = 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(PullsListReviewsError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Merge a pull request
///
/// Merges a pull request into the base branch.
/// This endpoint triggers [notifications](https://docs.github.com/github/managing-subscriptions-and-notifications-on-github/about-notifications). Creating content too quickly using this endpoint may result in secondary rate limiting. For more information, see "[Rate limits for the API](https://docs.github.com/rest/using-the-rest-api/rate-limits-for-the-rest-api#about-secondary-rate-limits)" and "[Best practices for using the REST API](https://docs.github.com/rest/guides/best-practices-for-using-the-rest-api)."
///
/// [GitHub API docs for merge](https://docs.github.com/rest/pulls/pulls#merge-a-pull-request)
///
/// ---
pub async fn merge_async(&self, owner: &str, repo: &str, pull_number: i32, body: PutPullsMerge) -> Result<PullRequestMergeResult, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pulls/{}/merge", super::GITHUB_BASE_API_URL, owner, repo, pull_number);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutPullsMerge>(body)?),
method: "PUT",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
405 => Err(PullsMergeError::Status405(github_response.to_json_async().await?).into()),
409 => Err(PullsMergeError::Status409(github_response.to_json_async().await?).into()),
422 => Err(PullsMergeError::Status422(github_response.to_json_async().await?).into()),
403 => Err(PullsMergeError::Status403(github_response.to_json_async().await?).into()),
404 => Err(PullsMergeError::Status404(github_response.to_json_async().await?).into()),
code => Err(PullsMergeError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Merge a pull request
///
/// Merges a pull request into the base branch.
/// This endpoint triggers [notifications](https://docs.github.com/github/managing-subscriptions-and-notifications-on-github/about-notifications). Creating content too quickly using this endpoint may result in secondary rate limiting. For more information, see "[Rate limits for the API](https://docs.github.com/rest/using-the-rest-api/rate-limits-for-the-rest-api#about-secondary-rate-limits)" and "[Best practices for using the REST API](https://docs.github.com/rest/guides/best-practices-for-using-the-rest-api)."
///
/// [GitHub API docs for merge](https://docs.github.com/rest/pulls/pulls#merge-a-pull-request)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn merge(&self, owner: &str, repo: &str, pull_number: i32, body: PutPullsMerge) -> Result<PullRequestMergeResult, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pulls/{}/merge", super::GITHUB_BASE_API_URL, owner, repo, pull_number);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutPullsMerge>(body)?),
method: "PUT",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
405 => Err(PullsMergeError::Status405(github_response.to_json()?).into()),
409 => Err(PullsMergeError::Status409(github_response.to_json()?).into()),
422 => Err(PullsMergeError::Status422(github_response.to_json()?).into()),
403 => Err(PullsMergeError::Status403(github_response.to_json()?).into()),
404 => Err(PullsMergeError::Status404(github_response.to_json()?).into()),
code => Err(PullsMergeError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Remove requested reviewers from a pull request
///
/// Removes review requests from a pull request for a given set of users and/or teams.
///
/// [GitHub API docs for remove_requested_reviewers](https://docs.github.com/rest/pulls/review-requests#remove-requested-reviewers-from-a-pull-request)
///
/// ---
pub async fn remove_requested_reviewers_async(&self, owner: &str, repo: &str, pull_number: i32, body: DeletePullsRemoveRequestedReviewers) -> Result<PullRequestSimple, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pulls/{}/requested_reviewers", super::GITHUB_BASE_API_URL, owner, repo, pull_number);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<DeletePullsRemoveRequestedReviewers>(body)?),
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
422 => Err(PullsRemoveRequestedReviewersError::Status422(github_response.to_json_async().await?).into()),
code => Err(PullsRemoveRequestedReviewersError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Remove requested reviewers from a pull request
///
/// Removes review requests from a pull request for a given set of users and/or teams.
///
/// [GitHub API docs for remove_requested_reviewers](https://docs.github.com/rest/pulls/review-requests#remove-requested-reviewers-from-a-pull-request)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn remove_requested_reviewers(&self, owner: &str, repo: &str, pull_number: i32, body: DeletePullsRemoveRequestedReviewers) -> Result<PullRequestSimple, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pulls/{}/requested_reviewers", super::GITHUB_BASE_API_URL, owner, repo, pull_number);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<DeletePullsRemoveRequestedReviewers>(body)?),
method: "DELETE",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
422 => Err(PullsRemoveRequestedReviewersError::Status422(github_response.to_json()?).into()),
code => Err(PullsRemoveRequestedReviewersError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Request reviewers for a pull request
///
/// Requests reviews for a pull request from a given set of users and/or teams.
/// This endpoint triggers [notifications](https://docs.github.com/github/managing-subscriptions-and-notifications-on-github/about-notifications). Creating content too quickly using this endpoint may result in secondary rate limiting. For more information, see "[Rate limits for the API](https://docs.github.com/rest/using-the-rest-api/rate-limits-for-the-rest-api#about-secondary-rate-limits)" and "[Best practices for using the REST API](https://docs.github.com/rest/guides/best-practices-for-using-the-rest-api)."
///
/// [GitHub API docs for request_reviewers](https://docs.github.com/rest/pulls/review-requests#request-reviewers-for-a-pull-request)
///
/// ---
pub async fn request_reviewers_async(&self, owner: &str, repo: &str, pull_number: i32, body: PostPullsRequestReviewers) -> Result<PullRequestSimple, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pulls/{}/requested_reviewers", super::GITHUB_BASE_API_URL, owner, repo, pull_number);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostPullsRequestReviewers>(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(PullsRequestReviewersError::Status422.into()),
403 => Err(PullsRequestReviewersError::Status403(github_response.to_json_async().await?).into()),
code => Err(PullsRequestReviewersError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Request reviewers for a pull request
///
/// Requests reviews for a pull request from a given set of users and/or teams.
/// This endpoint triggers [notifications](https://docs.github.com/github/managing-subscriptions-and-notifications-on-github/about-notifications). Creating content too quickly using this endpoint may result in secondary rate limiting. For more information, see "[Rate limits for the API](https://docs.github.com/rest/using-the-rest-api/rate-limits-for-the-rest-api#about-secondary-rate-limits)" and "[Best practices for using the REST API](https://docs.github.com/rest/guides/best-practices-for-using-the-rest-api)."
///
/// [GitHub API docs for request_reviewers](https://docs.github.com/rest/pulls/review-requests#request-reviewers-for-a-pull-request)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn request_reviewers(&self, owner: &str, repo: &str, pull_number: i32, body: PostPullsRequestReviewers) -> Result<PullRequestSimple, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pulls/{}/requested_reviewers", super::GITHUB_BASE_API_URL, owner, repo, pull_number);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostPullsRequestReviewers>(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(PullsRequestReviewersError::Status422.into()),
403 => Err(PullsRequestReviewersError::Status403(github_response.to_json()?).into()),
code => Err(PullsRequestReviewersError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Submit a review for a pull request
///
/// Submits a pending review for a pull request. For more information about creating a pending review for a pull request, see "[Create a review for a pull request](https://docs.github.com/rest/pulls/reviews#create-a-review-for-a-pull-request)."
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
///
/// [GitHub API docs for submit_review](https://docs.github.com/rest/pulls/reviews#submit-a-review-for-a-pull-request)
///
/// ---
pub async fn submit_review_async(&self, owner: &str, repo: &str, pull_number: i32, review_id: i32, body: PostPullsSubmitReview) -> Result<PullRequestReview, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pulls/{}/reviews/{}/events", super::GITHUB_BASE_API_URL, owner, repo, pull_number, review_id);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostPullsSubmitReview>(body)?),
method: "POST",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
404 => Err(PullsSubmitReviewError::Status404(github_response.to_json_async().await?).into()),
422 => Err(PullsSubmitReviewError::Status422(github_response.to_json_async().await?).into()),
403 => Err(PullsSubmitReviewError::Status403(github_response.to_json_async().await?).into()),
code => Err(PullsSubmitReviewError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Submit a review for a pull request
///
/// Submits a pending review for a pull request. For more information about creating a pending review for a pull request, see "[Create a review for a pull request](https://docs.github.com/rest/pulls/reviews#create-a-review-for-a-pull-request)."
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
///
/// [GitHub API docs for submit_review](https://docs.github.com/rest/pulls/reviews#submit-a-review-for-a-pull-request)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn submit_review(&self, owner: &str, repo: &str, pull_number: i32, review_id: i32, body: PostPullsSubmitReview) -> Result<PullRequestReview, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pulls/{}/reviews/{}/events", super::GITHUB_BASE_API_URL, owner, repo, pull_number, review_id);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PostPullsSubmitReview>(body)?),
method: "POST",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
404 => Err(PullsSubmitReviewError::Status404(github_response.to_json()?).into()),
422 => Err(PullsSubmitReviewError::Status422(github_response.to_json()?).into()),
403 => Err(PullsSubmitReviewError::Status403(github_response.to_json()?).into()),
code => Err(PullsSubmitReviewError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update a pull request
///
/// Draft pull requests are available in public repositories with GitHub Free and GitHub Free for organizations, GitHub Pro, and legacy per-repository billing plans, and in public and private repositories with GitHub Team and GitHub Enterprise Cloud. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// To open or update a pull request in a public repository, you must have write access to the head or the source branch. For organization-owned repositories, you must be a member of the organization that owns the repository to open or update a pull request.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
///
/// [GitHub API docs for update](https://docs.github.com/rest/pulls/pulls#update-a-pull-request)
///
/// ---
pub async fn update_async(&self, owner: &str, repo: &str, pull_number: i32, body: PatchPullsUpdate) -> Result<PullRequest, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pulls/{}", super::GITHUB_BASE_API_URL, owner, repo, pull_number);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchPullsUpdate>(body)?),
method: "PATCH",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
422 => Err(PullsUpdateError::Status422(github_response.to_json_async().await?).into()),
403 => Err(PullsUpdateError::Status403(github_response.to_json_async().await?).into()),
code => Err(PullsUpdateError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update a pull request
///
/// Draft pull requests are available in public repositories with GitHub Free and GitHub Free for organizations, GitHub Pro, and legacy per-repository billing plans, and in public and private repositories with GitHub Team and GitHub Enterprise Cloud. For more information, see [GitHub's products](https://docs.github.com/github/getting-started-with-github/githubs-products) in the GitHub Help documentation.
///
/// To open or update a pull request in a public repository, you must have write access to the head or the source branch. For organization-owned repositories, you must be a member of the organization that owns the repository to open or update a pull request.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
///
/// [GitHub API docs for update](https://docs.github.com/rest/pulls/pulls#update-a-pull-request)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn update(&self, owner: &str, repo: &str, pull_number: i32, body: PatchPullsUpdate) -> Result<PullRequest, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pulls/{}", super::GITHUB_BASE_API_URL, owner, repo, pull_number);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchPullsUpdate>(body)?),
method: "PATCH",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
422 => Err(PullsUpdateError::Status422(github_response.to_json()?).into()),
403 => Err(PullsUpdateError::Status403(github_response.to_json()?).into()),
code => Err(PullsUpdateError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update a pull request branch
///
/// Updates the pull request branch with the latest upstream changes by merging HEAD from the base branch into the pull request branch.
/// Note: If making a request on behalf of a GitHub App you must also have permissions to write the contents of the head repository.
///
/// [GitHub API docs for update_branch](https://docs.github.com/rest/pulls/pulls#update-a-pull-request-branch)
///
/// ---
pub async fn update_branch_async(&self, owner: &str, repo: &str, pull_number: i32, body: PutPullsUpdateBranch) -> Result<PutPullsUpdateBranchResponse202, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pulls/{}/update-branch", super::GITHUB_BASE_API_URL, owner, repo, pull_number);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutPullsUpdateBranch>(body)?),
method: "PUT",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
422 => Err(PullsUpdateBranchError::Status422(github_response.to_json_async().await?).into()),
403 => Err(PullsUpdateBranchError::Status403(github_response.to_json_async().await?).into()),
code => Err(PullsUpdateBranchError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update a pull request branch
///
/// Updates the pull request branch with the latest upstream changes by merging HEAD from the base branch into the pull request branch.
/// Note: If making a request on behalf of a GitHub App you must also have permissions to write the contents of the head repository.
///
/// [GitHub API docs for update_branch](https://docs.github.com/rest/pulls/pulls#update-a-pull-request-branch)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn update_branch(&self, owner: &str, repo: &str, pull_number: i32, body: PutPullsUpdateBranch) -> Result<PutPullsUpdateBranchResponse202, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pulls/{}/update-branch", super::GITHUB_BASE_API_URL, owner, repo, pull_number);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutPullsUpdateBranch>(body)?),
method: "PUT",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
422 => Err(PullsUpdateBranchError::Status422(github_response.to_json()?).into()),
403 => Err(PullsUpdateBranchError::Status403(github_response.to_json()?).into()),
code => Err(PullsUpdateBranchError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update a review for a pull request
///
/// Updates the contents of a specified review summary comment.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
///
/// [GitHub API docs for update_review](https://docs.github.com/rest/pulls/reviews#update-a-review-for-a-pull-request)
///
/// ---
pub async fn update_review_async(&self, owner: &str, repo: &str, pull_number: i32, review_id: i32, body: PutPullsUpdateReview) -> Result<PullRequestReview, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pulls/{}/reviews/{}", super::GITHUB_BASE_API_URL, owner, repo, pull_number, review_id);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutPullsUpdateReview>(body)?),
method: "PUT",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
422 => Err(PullsUpdateReviewError::Status422(github_response.to_json_async().await?).into()),
code => Err(PullsUpdateReviewError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update a review for a pull request
///
/// Updates the contents of a specified review summary comment.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
///
/// [GitHub API docs for update_review](https://docs.github.com/rest/pulls/reviews#update-a-review-for-a-pull-request)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn update_review(&self, owner: &str, repo: &str, pull_number: i32, review_id: i32, body: PutPullsUpdateReview) -> Result<PullRequestReview, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pulls/{}/reviews/{}", super::GITHUB_BASE_API_URL, owner, repo, pull_number, review_id);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PutPullsUpdateReview>(body)?),
method: "PUT",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
422 => Err(PullsUpdateReviewError::Status422(github_response.to_json()?).into()),
code => Err(PullsUpdateReviewError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update a review comment for a pull request
///
/// Edits the content of a specified review comment.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
///
/// [GitHub API docs for update_review_comment](https://docs.github.com/rest/pulls/comments#update-a-review-comment-for-a-pull-request)
///
/// ---
pub async fn update_review_comment_async(&self, owner: &str, repo: &str, comment_id: i64, body: PatchPullsUpdateReviewComment) -> Result<PullRequestReviewComment, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pulls/comments/{}", super::GITHUB_BASE_API_URL, owner, repo, comment_id);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchPullsUpdateReviewComment>(body)?),
method: "PATCH",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch_async(request).await?;
// --
if github_response.is_success() {
Ok(github_response.to_json_async().await?)
} else {
match github_response.status_code() {
code => Err(PullsUpdateReviewCommentError::Generic { code }.into()),
}
}
}
/// ---
///
/// # Update a review comment for a pull request
///
/// Edits the content of a specified review comment.
///
/// This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."
///
/// - **`application/vnd.github-commitcomment.raw+json`**: Returns the raw markdown body. Response will include `body`. This is the default if you do not pass any specific media type.
/// - **`application/vnd.github-commitcomment.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
/// - **`application/vnd.github-commitcomment.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
/// - **`application/vnd.github-commitcomment.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
///
/// [GitHub API docs for update_review_comment](https://docs.github.com/rest/pulls/comments#update-a-review-comment-for-a-pull-request)
///
/// ---
#[cfg(not(target_arch = "wasm32"))]
pub fn update_review_comment(&self, owner: &str, repo: &str, comment_id: i64, body: PatchPullsUpdateReviewComment) -> Result<PullRequestReviewComment, AdapterError> {
let request_uri = format!("{}/repos/{}/{}/pulls/comments/{}", super::GITHUB_BASE_API_URL, owner, repo, comment_id);
let req = GitHubRequest {
uri: request_uri,
body: Some(C::from_json::<PatchPullsUpdateReviewComment>(body)?),
method: "PATCH",
headers: vec![]
};
let request = self.client.build(req)?;
// --
let github_response = self.client.fetch(request)?;
// --
if github_response.is_success() {
Ok(github_response.to_json()?)
} else {
match github_response.status_code() {
code => Err(PullsUpdateReviewCommentError::Generic { code }.into()),
}
}
}
}