Skip to main content

PullRequestsClient

Struct PullRequestsClient 

Source
pub struct PullRequestsClient { /* private fields */ }
Expand description

Domain client for pull request operations.

Obtained via InstallationClient::pull_requests(). Cheap to clone (Arc-backed).

See docs/specs/interfaces/pull-request-operations.md

Implementations§

Source§

impl PullRequestsClient

Source

pub async fn list( &self, owner: &str, repo: &str, state: Option<&str>, page: Option<u32>, ) -> Result<PagedResponse<PullRequest>, ApiError>

List pull requests in a repository.

Returns a paginated response with pull requests and pagination metadata. Use the pagination information to fetch subsequent pages if needed.

§Arguments
  • owner - Repository owner
  • repo - Repository name
  • state - Filter by state ("open", "closed", or "all")
  • page - Page number (1-indexed, omit for first page)
§Examples
// Get first page
let response = client.list("owner", "repo", None, None).await?;
println!("Got {} pull requests", response.items.len());

// Check if more pages exist
if response.has_next() {
    if let Some(next_page) = response.next_page_number() {
        let next_response = client.list("owner", "repo", None, Some(next_page)).await?;
        println!("Got {} more PRs", next_response.items.len());
    }
}

See docs/spec/interfaces/pull-request-operations.md

Source

pub async fn get( &self, owner: &str, repo: &str, pull_number: u64, ) -> Result<PullRequest, ApiError>

Get a specific pull request by number.

See docs/spec/interfaces/pull-request-operations.md

Source

pub async fn create( &self, owner: &str, repo: &str, request: CreatePullRequestRequest, ) -> Result<PullRequest, ApiError>

Create a new pull request.

See docs/spec/interfaces/pull-request-operations.md

Source

pub async fn update( &self, owner: &str, repo: &str, pull_number: u64, request: UpdatePullRequestRequest, ) -> Result<PullRequest, ApiError>

Update an existing pull request.

See docs/spec/interfaces/pull-request-operations.md

Source

pub async fn merge( &self, owner: &str, repo: &str, pull_number: u64, request: MergePullRequestRequest, ) -> Result<MergeResult, ApiError>

Merge a pull request.

See docs/spec/interfaces/pull-request-operations.md

Source

pub async fn set_milestone( &self, owner: &str, repo: &str, pull_number: u64, milestone_number: Option<u64>, ) -> Result<PullRequest, ApiError>

Set the milestone on a pull request.

The GitHub Pulls API silently ignores the milestone field, so this method delegates to the Issues API (PATCH /repos/{owner}/{repo}/issues/{number}) which correctly applies the milestone, then re-fetches the PR to return the updated state.

§Partial-failure note

If the Issues API call succeeds but the subsequent get() call fails (e.g. due to a transient network error), this method returns an error even though the milestone was actually set on the PR. Callers should treat an error response as “milestone state unknown” rather than “milestone not set” and may wish to re-fetch the PR to confirm the current state.

See docs/specs/interfaces/pull-request-operations.md

Source

pub async fn list_reviews( &self, owner: &str, repo: &str, pull_number: u64, ) -> Result<Vec<Review>, ApiError>

List reviews on a pull request.

See docs/spec/interfaces/pull-request-operations.md

Source

pub async fn get_review( &self, owner: &str, repo: &str, pull_number: u64, review_id: u64, ) -> Result<Review, ApiError>

Get a specific review by ID.

See docs/spec/interfaces/pull-request-operations.md

Source

pub async fn create_review( &self, owner: &str, repo: &str, pull_number: u64, request: CreateReviewRequest, ) -> Result<Review, ApiError>

Create a review on a pull request.

See docs/spec/interfaces/pull-request-operations.md

Source

pub async fn update_review( &self, owner: &str, repo: &str, pull_number: u64, review_id: u64, request: UpdateReviewRequest, ) -> Result<Review, ApiError>

Update a pending review.

See docs/spec/interfaces/pull-request-operations.md

Source

pub async fn dismiss_review( &self, owner: &str, repo: &str, pull_number: u64, review_id: u64, request: DismissReviewRequest, ) -> Result<Review, ApiError>

Dismiss a review.

See docs/spec/interfaces/pull-request-operations.md

Source

pub async fn list_comments( &self, owner: &str, repo: &str, pull_number: u64, ) -> Result<Vec<Comment>, ApiError>

List all conversation-thread comments on a pull request (auto-paginated).

Uses the Issues comments endpoint per GitHub API design.

See docs/specs/interfaces/pull-request-operations.md

Source

pub async fn create_comment( &self, owner: &str, repo: &str, pull_number: u64, request: CreatePullRequestCommentRequest, ) -> Result<Comment, ApiError>

Add a conversation-thread comment to a pull request.

Uses the Issues comments endpoint per GitHub API design.

See docs/specs/interfaces/pull-request-operations.md

Source

pub async fn update_comment( &self, owner: &str, repo: &str, comment_id: u64, request: UpdatePullRequestCommentRequest, ) -> Result<Comment, ApiError>

Update an existing pull request conversation-thread comment.

See docs/specs/interfaces/pull-request-operations.md

Source

pub async fn delete_comment( &self, owner: &str, repo: &str, comment_id: u64, ) -> Result<(), ApiError>

Delete a pull request conversation-thread comment.

See docs/specs/interfaces/pull-request-operations.md

Source

pub async fn add_labels( &self, owner: &str, repo: &str, pull_number: u64, labels: Vec<String>, ) -> Result<Vec<Label>, ApiError>

Add labels to a pull request.

See docs/specs/interfaces/pull-request-operations.md

Source

pub async fn replace_labels( &self, owner: &str, repo: &str, pull_number: u64, labels: Vec<String>, ) -> Result<Vec<Label>, ApiError>

Replace all labels on a pull request.

Replaces the entire set of labels. Pass an empty vec to clear all labels.

See docs/specs/interfaces/pull-request-operations.md

Source

pub async fn remove_label( &self, owner: &str, repo: &str, pull_number: u64, name: &str, ) -> Result<Vec<Label>, ApiError>

Remove a label from a pull request.

See docs/spec/interfaces/pull-request-operations.md

§Error mapping

GitHub returns HTTP 422 when the label name is unprocessable (e.g. does not exist on the repository). This method maps that to ApiError::InvalidRequest, which is the correct semantic mapping and is consistent with how other label methods in this file behave. Callers that previously matched on ApiError::HttpError { status: 422, .. } must be updated to match ApiError::InvalidRequest { .. } instead.

Trait Implementations§

Source§

impl Clone for PullRequestsClient

Source§

fn clone(&self) -> PullRequestsClient

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PullRequestsClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more