gitea_sdk/api/search/issues.rs
1use build_it::Builder;
2use serde::Serialize;
3
4use crate::error::Result;
5use crate::model::issues::{Issue, IssueType, State};
6
7/// Options for searching issues.
8/// All fields are optional.
9#[derive(Default, Debug, Clone, Serialize, Builder)]
10#[build_it(into)]
11pub struct SearchIssuesBuilder {
12 /// Filter by open or closed issues
13 state: Option<State>,
14 /// Filter issues by labels. Non-existent labels are ignored.
15 #[serde(skip)]
16 labels: Option<Vec<String>>,
17 /// Filter issues by milestone names. Non-existent milestones are ignored.
18 #[serde(skip)]
19 milestones: Option<Vec<String>>,
20 /// Search string
21 #[serde(rename = "q")]
22 query: Option<String>,
23 /// Repository to prioritize in the results
24 priority_repo_id: Option<i64>,
25 /// Filter by type (issue or pull request) if set
26 #[serde(rename = "type")]
27 issue_type: Option<IssueType>,
28 /// Only show issues updated after the given time. This is a timestamp in RFC 3339 format.
29 // TODO: Make this a DateTime<Utc>
30 since: Option<String>,
31 /// Only show issues updated before the given time. This is a timestamp in RFC 3339 format.
32 // TODO: Make this a DateTime<Utc>
33 before: Option<String>,
34 /// Filter issues/PRs assigned to the authenticated user, default is false
35 assigned: Option<bool>,
36 /// Filter issues/PRs created by the authenticated user, default is false
37 created: Option<bool>,
38 /// Filter issues/PRs in which the authenticated user is mentioned, default is false
39 mentioned: Option<bool>,
40 /// Filter pull requests awaiting review by the authenticated user, default is false
41 review_requested: Option<bool>,
42 /// Filter pull requests reviewed by the authenticated user, default is false
43 reviewed: Option<bool>,
44 /// Filter by owner
45 owner: Option<String>,
46 /// Filter by team
47 team: Option<String>,
48 /// Page number of results to return (1-based)
49 page: Option<i32>,
50 /// Page size of results
51 limit: Option<i32>,
52}
53
54impl SearchIssuesBuilder {
55 pub fn new() -> Self {
56 Self::default()
57 }
58 /// Send the request to search for issues.
59 /// This will return a [Vec<Issue>] of all issues matching the search criteria.
60 /// Only shows issues the currently authenticated user can see.
61 pub async fn send(&self, client: &crate::Client) -> Result<Vec<Issue>> {
62 let req = client
63 .get("repos/issues/search".to_string())
64 .query(self)
65 .build()?;
66 let res = client.make_request(req).await?;
67 client.parse_response(res).await
68 }
69}