pub struct IssueHandler<'octo> { /* private fields */ }
Expand description

Handler for GitHub’s issue API.

Note: GitHub’s REST API v3 considers every pull request an issue, but not every issue is a pull request. For this reason, “Issues” endpoints may return both issues and pull requests in the response. You can identify pull requests by the pull_request key.

Created with Octocrab::issues.

Implementations§

source§

impl<'octo> IssueHandler<'octo>

source

pub async fn get(&self, number: u64) -> Result<Issue>

Gets an issue from the repository.

let issue = octocrab.issues("owner", "repo").get(3).await?;
source

pub fn create(&self, title: impl Into<String>) -> CreateIssueBuilder<'_, '_>

Create an issue in the repository.

let issue = octocrab.issues("owner", "repo").create("My first issue")
    // Optional Parameters
    .body("This is an autogenerated issue..")
    .milestone(1001)
    .labels(vec![String::from("help-wanted")])
    .assignees(vec![String::from("ferris")])
    // Send the request
    .send()
    .await?;
source

pub fn list(&self) -> ListIssuesBuilder<'_, '_, '_, '_>

List issues in the repository.

use octocrab::params;

let issue = octocrab.issues("owner", "repo")
    .list()
    // Optional Parameters
    .state(params::State::All)
    .milestone(1234)
    .assignee("ferris")
    .creator("octocrab")
    .mentioned("octocat")
    .labels(&[String::from("help wanted"), String::from("good first issue")])
    .sort(params::issues::Sort::Comments)
    .direction(params::Direction::Ascending)
    .per_page(100)
    .page(1u8)
    // Send the request
    .send()
    .await?;
source

pub fn update(&self, number: u64) -> UpdateIssueBuilder<'_, '_, '_, '_, '_, '_>

Update an issue in the repository.

use octocrab::models;

let issue = octocrab.issues("owner", "repo")
    .update(1234u64)
    // Optional Parameters
    .title("Updated title")
    .body("New body")
    .state(models::IssueState::Closed)
    .milestone(1234u64)
    .assignees(&[String::from("ferris")])
    .labels(&[String::from("help wanted"), String::from("good first issue")])
    // Send the request
    .send()
    .await?;
source

pub async fn lock( &self, number: u64, reason: impl Into<Option<LockReason>> ) -> Result<bool>

Users with push access can lock an issue or pull request’s conversation.

See also: https://docs.github.com/en/rest/issues/issues#lock-an-issue

use octocrab::params;

assert!(octocrab::instance().issues("owner", "repo").lock(404, params::LockReason::OffTopic).await?);
source

pub async fn unlock(&self, number: u64) -> Result<bool>

Users with push access can unlock an issue or pull request’s conversation.

See also: https://docs.github.com/en/rest/issues/issues#unlock-an-issue

assert!(octocrab::instance().issues("owner", "repo").unlock(404).await?);
source§

impl<'octo> IssueHandler<'octo>

§Assignees

source

pub async fn add_assignees( &self, number: u64, assignees: &[&str] ) -> Result<Issue>

Adds up to 10 assignees to an issue. Users already assigned to an issue are not replaced.

let issue = octocrab.issues("owner", "repo").add_assignees(101, &["username1", "username2"]).await?;
source

pub async fn check_assignee(&self, assignee: impl AsRef<str>) -> Result<bool>

Checks if a user has permission to be assigned to an issue in the repository.

assert!(octocrab.issues("owner", "repo").check_assignee("ferris").await?);
source

pub fn list_assignees(&self) -> ListAssigneesBuilder<'_, '_>

Lists the available assignees for issues in a repository.

let assignees = octocrab
    .issues("owner", "repo")
    .list_assignees()
    .per_page(15)
    .page(2u32)
    .send()
    .await?;
source§

impl<'octo> IssueHandler<'octo>

§Labels

source

pub async fn add_labels( &self, number: u64, labels: &[String] ) -> Result<Vec<Label>>

Adds labels to an issue.

let labels = octocrab::instance()
    .issues("owner", "repo")
    .add_labels(101, &[String::from("help wanted")])
    .await?;
source

pub async fn remove_label( &self, number: u64, label: impl AsRef<str> ) -> Result<Vec<Label>>

Removes label from an issue.

let removed_labels = octocrab::instance()
    .issues("owner", "repo")
    .remove_label(101, "my_label")
    .await?;
source

pub async fn replace_all_labels( &self, number: u64, labels: &[String] ) -> Result<Vec<Label>>

Replaces all labels for an issue.

let labels = octocrab::instance()
    .issues("owner", "repo")
    .replace_all_labels(101, &[String::from("help wanted")])
    .await?;
source

pub async fn create_label( &self, name: impl AsRef<str>, color: impl AsRef<str>, description: impl AsRef<str> ) -> Result<Label>

Creates a label in the repository.

let label = octocrab::instance()
    .issues("owner", "repo")
    .create_label("help wanted", "59dd5a", "")
    .await?;
source

pub async fn get_label(&self, name: impl AsRef<str>) -> Result<Label>

Gets a label from the repository.

let label = octocrab::instance()
    .issues("owner", "repo")
    .get_label("help wanted")
    .await?;
source

pub async fn delete_label(&self, name: impl AsRef<str>) -> Result<()>

Deletes a label in the repository.

let label = octocrab::instance()
    .issues("owner", "repo")
    .delete_label("help wanted")
    .await?;
source

pub fn list_labels_for_issue( &self, number: u64 ) -> ListLabelsForIssueBuilder<'_, '_>

List labels from an issue on a repository.

let page = octocrab::instance()
    .issues("owner", "repo")
    .list_labels_for_issue(404)
    // Optional Parameters
    .per_page(20)
    .page(2u32)
    .send()
    .await?;
source

pub fn list_labels_for_repo(&self) -> ListLabelsForRepoBuilder<'_, '_>

List all labels from a repository.

let page = octocrab::instance()
    .issues("owner", "repo")
    .list_labels_for_repo()
    // Optional Parameters
    .per_page(20)
    .page(2u32)
    .send()
    .await?;
source§

impl<'octo> IssueHandler<'octo>

§Comments

source

pub async fn create_comment( &self, number: u64, body: impl AsRef<str> ) -> Result<Comment>

Creates a comment in the issue.

let comment = octocrab::instance()
    .issues("owner", "repo")
    .create_comment(101, "Beep Boop")
    .await?;
source

pub async fn get_comment(&self, comment_id: CommentId) -> Result<Comment>

Gets a comment in the issue.

let comment = octocrab::instance()
    .issues("owner", "repo")
    .get_comment(101u64.into())
    .await?;
source

pub async fn update_comment( &self, comment_id: CommentId, body: impl AsRef<str> ) -> Result<Comment>

Updates a comment in the issue.

let comment = octocrab::instance()
    .issues("owner", "repo")
    .update_comment(101u64.into(), "Beep Boop")
    .await?;
source

pub async fn delete_comment(&self, comment_id: CommentId) -> Result<()>

Deletes a comment in an issue.

octocrab::instance().issues("owner", "repo").delete_comment(101u64.into()).await?;
source

pub fn list_comments(&self, issue_number: u64) -> ListCommentsBuilder<'_, '_>

Lists comments in the issue.

let comment = octocrab::instance()
    .issues("owner", "repo")
    .list_comments(101u64.into())
    .since(chrono::Utc::now())
    .per_page(100)
    .page(2u32)
    .send()
    .await?;
source

pub fn list_issue_comments(&self) -> ListIssueCommentsBuilder<'_, '_>

Lists comments for issues in the whole repo.

let comment = octocrab::instance()
    .issues("owner", "repo")
    .list_issue_comments()
    .per_page(100)
    .page(2u32)
    .send()
    .await?;
source§

impl<'octo> IssueHandler<'octo>

source

pub fn list_timeline_events( &self, issue_number: u64 ) -> ListTimelineEventsBuilder<'_, '_>

Lists events in the issue timeline.

let timeline = octocrab::instance()
    .issues("owner", "repo")
    .list_timeline_events(21u64.into())
    .per_page(100)
    .page(2u32)
    .send()
    .await?;
source§

impl<'octo> IssueHandler<'octo>

source

pub fn list_reactions(&self, issue_number: u64) -> ListReactionsBuilder<'_, '_>

Lists reactions for an issue.

let reactions = octocrab::instance()
    .issues("owner", "repo")
    .list_reactions(1)
    .per_page(100)
    .page(2u32)
    .send()
    .await?;
source

pub fn list_comment_reactions( &self, comment_id: impl Into<CommentId> ) -> ListCommentReactionsBuilder<'_, '_>

Lists reactions for an issue comment.

let reactions = octocrab::instance()
    .issues("owner", "repo")
    .list_comment_reactions(1)
    .per_page(100)
    .page(2u32)
    .send()
    .await?;
source§

impl<'octo> IssueHandler<'octo>

source

pub async fn create_reaction( &self, issue_number: u64, content: ReactionContent ) -> Result<Reaction>

Creates a reaction for an issue.

octocrab::instance()
    .issues("owner", "repo")
    .create_reaction(1, octocrab::models::reactions::ReactionContent::PlusOne)
    .await?;
source

pub async fn create_comment_reaction( &self, comment_id: impl Into<CommentId>, content: ReactionContent ) -> Result<Reaction>

Creates a reaction for an issue comment.

octocrab::instance()
    .issues("owner", "repo")
    .create_comment_reaction(1, octocrab::models::reactions::ReactionContent::PlusOne)
    .await?;
source§

impl<'octo> IssueHandler<'octo>

source

pub async fn delete_reaction( &self, issue_number: u64, reaction_id: impl Into<ReactionId> ) -> Result<()>

Deletes a reaction for an issue.

octocrab::instance()
    .issues("owner", "repo")
    .delete_reaction(1, 1)
    .await?;
source

pub async fn delete_comment_reaction( &self, comment_id: impl Into<CommentId>, reaction_id: impl Into<ReactionId> ) -> Result<()>

Deletes a reaction for an issue comment.

octocrab::instance()
    .issues("owner", "repo")
    .delete_comment_reaction(1, 1)
    .await?;

Auto Trait Implementations§

§

impl<'octo> Freeze for IssueHandler<'octo>

§

impl<'octo> !RefUnwindSafe for IssueHandler<'octo>

§

impl<'octo> Send for IssueHandler<'octo>

§

impl<'octo> Sync for IssueHandler<'octo>

§

impl<'octo> Unpin for IssueHandler<'octo>

§

impl<'octo> !UnwindSafe for IssueHandler<'octo>

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<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: 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: 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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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<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