1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
pub mod create;
pub mod delete;
pub mod edit;
pub mod get;
pub mod list;
pub struct Issues {
pub(crate) owner: String,
pub(crate) repo: String,
}
impl Issues {
/// Create an issue.
/// If using deadline only the date will be taken into account, and time of day ignored.
/// The only required field in the [CreateIssueOption] is `title`. All other fields are
/// optional.
/// This method will return the created issue.
///
/// # Example
/// ```
/// # use gitea_sdk::{Client, Auth};
/// # async fn create_issue() {
/// let client = Client::new(
/// "https://gitea.example.com",
/// Auth::Token("your-token")
/// );
/// let issue = client
/// .issues("owner", "repo")
/// .create("my-new-issue")
/// .send(&client)
/// .await
/// .unwrap();
/// # }
/// ```
/// This will create a new issue with the title "my-new-issue" in the repository "owner/repo".
pub fn create(&self, title: impl ToString) -> create::CreateIssueBuilder {
create::CreateIssueBuilder::new(&self.owner, &self.repo, title)
}
/// Delete an issue.
/// This will delete the issue with the given issue number.
/// WARNING: This is irreversible and will not ask for confirmation. Use with caution.
///
/// This method will return a 204 status code if the issue was successfully deleted.
/// If the issue does not exist, this method will return a 404 status code.
/// If the user is not authorized to delete the issue, this method will return a 403 status
/// code.
///
/// # Example
///
/// ```rust
/// # use gitea_sdk::{Client, Auth};
/// # async fn delete_issue() {
/// let client = Client::new(
/// "https://gitea.example.com",
/// Auth::Token("your-token")
/// );
/// client
/// .issues("owner", "repo")
/// .delete(1)
/// .send(&client)
/// .await
/// .unwrap();
/// # }
/// ```
/// This will delete the issue #1 in the repository "owner/repo".
pub fn delete(&self, issue_number: i64) -> delete::DeleteIssueBuilder {
delete::DeleteIssueBuilder::new(&self.owner, &self.repo, issue_number)
}
/// Get an issue.
/// This will return the issue with the given issue number.
///
/// # Example
/// ```rust
/// # use gitea_sdk::{Client, Auth};
/// # async fn get_issue() {
/// let client = Client::new(
/// "https://gitea.example.com",
/// Auth::Token("your-token")
/// );
/// let issue = client
/// .issues("owner", "repo")
/// .get(1)
/// .send(&client)
/// .await
/// .unwrap();
/// # }
/// ```
/// This will get the issue #1 in the repository "owner/repo".
pub fn get(&self, issue_number: i64) -> get::GetIssueBuilder {
get::GetIssueBuilder::new(&self.owner, &self.repo, issue_number)
}
/// Edit an issue.
///
/// # Example
/// ```rust
/// # use gitea_sdk::{Client, Auth};
/// # async fn edit_issue() {
/// let client = Client::new(
/// "https://gitea.example.com",
/// Auth::Token("your-token")
/// );
/// client
/// .issues("owner", "repo")
/// .edit(1)
/// .title("new-title".to_string())
/// .send(&client)
/// .await
/// .unwrap();
/// # }
/// ```
pub fn edit(&self, issue_number: i64) -> edit::EditIssueBuilder {
edit::EditIssueBuilder::new(&self.owner, &self.repo, issue_number)
}
/// List a repository's issues.
/// The [GetIssuesOption] struct provides a number of optional fields to filter the results,
/// but all fields are entirely optional.
/// If you don't set any fields, you will get the most recent issues for the repository.
///
///
/// # Example
///
/// ```rust
/// # use gitea_sdk::{Client, Auth, model::issues::State};
/// # async fn get_issues() {
/// let client = Client::new(
/// "https://gitea.example.com",
/// Auth::Token("your-token")
/// );
/// let issues = client
/// .issues("owner", "repo")
/// .list()
/// .state(State::Open)
/// .send(&client)
/// .await
/// .unwrap();
/// # }
/// ```
/// This will get all open issues in the repository "owner/repo".
pub fn list(&self) -> list::ListIssuesBuilder {
list::ListIssuesBuilder::new(&self.owner, &self.repo)
}
}