gitea_sdk/api/search/
issues.rs

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
use build_it::Builder;
use serde::Serialize;

use crate::error::Result;
use crate::model::issues::{Issue, IssueType, State};

/// Options for searching issues.
/// All fields are optional.
#[derive(Default, Debug, Clone, Serialize, Builder)]
#[build_it(into)]
pub struct SearchIssuesBuilder {
    /// Filter by open or closed issues
    state: Option<State>,
    /// Filter issues by labels. Non-existent labels are ignored.
    #[serde(skip)]
    labels: Option<Vec<String>>,
    /// Filter issues by milestone names. Non-existent milestones are ignored.
    #[serde(skip)]
    milestones: Option<Vec<String>>,
    /// Search string
    #[serde(rename = "q")]
    query: Option<String>,
    /// Repository to prioritize in the results
    priority_repo_id: Option<i64>,
    /// Filter by type (issue or pull request) if set
    #[serde(rename = "type")]
    issue_type: Option<IssueType>,
    /// Only show issues updated after the given time. This is a timestamp in RFC 3339 format.
    // TODO: Make this a DateTime<Utc>
    since: Option<String>,
    /// Only show issues updated before the given time. This is a timestamp in RFC 3339 format.
    // TODO: Make this a DateTime<Utc>
    before: Option<String>,
    /// Filter issues/PRs assigned to the authenticated user, default is false
    assigned: Option<bool>,
    /// Filter issues/PRs created by the authenticated user, default is false
    created: Option<bool>,
    /// Filter issues/PRs in which the authenticated user is mentioned, default is false
    mentioned: Option<bool>,
    /// Filter pull requests awaiting review by the authenticated user, default is false
    review_requested: Option<bool>,
    /// Filter pull requests reviewed by the authenticated user, default is false
    reviewed: Option<bool>,
    /// Filter by owner
    owner: Option<String>,
    /// Filter by team
    team: Option<String>,
    /// Page number of results to return (1-based)
    page: Option<i32>,
    /// Page size of results
    limit: Option<i32>,
}

impl SearchIssuesBuilder {
    pub fn new() -> Self {
        Self::default()
    }
    /// Send the request to search for issues.
    /// This will return a [Vec<Issue>] of all issues matching the search criteria.
    /// Only shows issues the currently authenticated user can see.
    pub async fn send(&self, client: &crate::Client) -> Result<Vec<Issue>> {
        let req = client
            .get("repos/issues/search".to_string())
            .query(self)
            .build()?;
        let res = client.make_request(req).await?;
        client.parse_response(res).await
    }
}