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>
impl<'octo> IssueHandler<'octo>
Sourcepub async fn get(&self, number: u64) -> Result<Issue>
pub async fn get(&self, number: u64) -> Result<Issue>
Gets an issue from the repository.
let issue = octocrab.issues("owner", "repo").get(3).await?;
Sourcepub fn create(&self, title: impl Into<String>) -> CreateIssueBuilder<'_, '_>
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?;
Sourcepub fn list(&self) -> ListIssuesBuilder<'_, '_, '_, '_>
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?;
Sourcepub fn update(&self, number: u64) -> UpdateIssueBuilder<'_, '_, '_, '_, '_, '_>
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?;
Sourcepub async fn lock(
&self,
number: u64,
reason: impl Into<Option<LockReason>>,
) -> Result<bool>
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§impl<'octo> IssueHandler<'octo>
§Assignees
impl<'octo> IssueHandler<'octo>
§Assignees
Sourcepub async fn add_assignees(
&self,
number: u64,
assignees: &[&str],
) -> Result<Issue>
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?;
Sourcepub async fn remove_assignees(
&self,
number: u64,
assignees: &[&str],
) -> Result<Issue>
pub async fn remove_assignees( &self, number: u64, assignees: &[&str], ) -> Result<Issue>
Removes one or more assignees from an issue.
let issue = octocrab.issues("owner", "repo").remove_assignees(101, &["username1", "username2"]).await?;
Sourcepub async fn check_assignee(&self, assignee: impl AsRef<str>) -> Result<bool>
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?);
Sourcepub fn list_assignees(&self) -> ListAssigneesBuilder<'_, '_>
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
impl<'octo> IssueHandler<'octo>
§Labels
Sourcepub async fn add_labels(
&self,
number: u64,
labels: &[String],
) -> Result<Vec<Label>>
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?;
Sourcepub async fn remove_label(
&self,
number: u64,
label: impl AsRef<str>,
) -> Result<Vec<Label>>
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?;
Sourcepub async fn replace_all_labels(
&self,
number: u64,
labels: &[String],
) -> Result<Vec<Label>>
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?;
Sourcepub async fn create_label(
&self,
name: impl AsRef<str>,
color: impl AsRef<str>,
description: impl AsRef<str>,
) -> Result<Label>
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?;
Sourcepub async fn get_label(&self, name: impl AsRef<str>) -> Result<Label>
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?;
Sourcepub async fn delete_label(&self, name: impl AsRef<str>) -> Result<()>
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?;
Sourcepub fn list_labels_for_issue(
&self,
number: u64,
) -> ListLabelsForIssueBuilder<'_, '_>
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?;
Sourcepub fn list_labels_for_repo(&self) -> ListLabelsForRepoBuilder<'_, '_>
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
impl<'octo> IssueHandler<'octo>
§Comments
Sourcepub async fn create_comment(
&self,
number: u64,
body: impl AsRef<str>,
) -> Result<Comment>
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?;
Sourcepub async fn get_comment(&self, comment_id: CommentId) -> Result<Comment>
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?;
Sourcepub async fn update_comment(
&self,
comment_id: CommentId,
body: impl AsRef<str>,
) -> Result<Comment>
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?;
Sourcepub async fn delete_comment(&self, comment_id: CommentId) -> Result<()>
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?;
Sourcepub fn list_comments(&self, issue_number: u64) -> ListCommentsBuilder<'_, '_>
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?;
Sourcepub fn list_issue_comments(&self) -> ListIssueCommentsBuilder<'_, '_>
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 IssueHandler<'_>
impl IssueHandler<'_>
Sourcepub fn list_timeline_events(
&self,
issue_number: u64,
) -> ListTimelineEventsBuilder<'_, '_>
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 IssueHandler<'_>
impl IssueHandler<'_>
Sourcepub fn list_reactions(&self, issue_number: u64) -> ListReactionsBuilder<'_, '_>
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?;
Sourcepub fn list_comment_reactions(
&self,
comment_id: impl Into<CommentId>,
) -> ListCommentReactionsBuilder<'_, '_>
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>
impl<'octo> IssueHandler<'octo>
Sourcepub async fn create_reaction(
&self,
issue_number: u64,
content: ReactionContent,
) -> Result<Reaction>
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?;
Sourcepub async fn create_comment_reaction(
&self,
comment_id: impl Into<CommentId>,
content: ReactionContent,
) -> Result<Reaction>
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>
impl<'octo> IssueHandler<'octo>
Sourcepub async fn delete_reaction(
&self,
issue_number: u64,
reaction_id: impl Into<ReactionId>,
) -> Result<()>
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?;
Sourcepub async fn delete_comment_reaction(
&self,
comment_id: impl Into<CommentId>,
reaction_id: impl Into<ReactionId>,
) -> Result<()>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more