gitea_sdk/api/issues/
list.rs

1use build_it::Builder;
2use serde::Serialize;
3
4use crate::error::Result;
5use crate::model::issues::{Issue, IssueType, State};
6
7#[derive(Debug, Clone, Serialize, Builder)]
8#[build_it(into)]
9pub struct ListIssuesBuilder {
10    #[skip]
11    #[serde(skip)]
12    owner: String,
13    #[skip]
14    #[serde(skip)]
15    repo: String,
16
17    /// Whether issue is open or closed
18    pub state: Option<State>,
19    /// Comma separated list of labels. Fetch only issues that have any of this labels. Non existent labels are discarded
20    pub labels: Option<Vec<String>>,
21    /// Search string
22    #[serde(rename = "q")]
23    pub query: Option<String>,
24    /// Filter by type (Issues or Pulls) if set
25    #[serde(rename = "type")]
26    pub issue_type: Option<IssueType>,
27    /// Comma-separated list of milestone names or ids. It uses names and fall back to ids.
28    /// Fetch only issues that have any of this milestones. Non existent milestones are discarded
29    pub milestone: Option<String>,
30    /// Only show items updated after the given time. This is a timestamp in RFC 3339 format
31    pub since: Option<String>,
32    /// Only show items updated before the given time. This is a timestamp in RFC 3339 format
33    pub before: Option<String>,
34    /// Only show items which were created by the given user
35    pub created_by: Option<String>,
36    /// Only show items for which the given user is assigned
37    pub assigned_by: Option<String>,
38    /// Only show items in which the given user was mentioned
39    pub mentioned_by: Option<String>,
40    /// Page number of results to return (1-based)
41    pub page: Option<i64>,
42    /// Page size of results
43    pub limit: Option<i64>,
44}
45
46impl ListIssuesBuilder {
47    pub fn new(owner: impl ToString, repo: impl ToString) -> Self {
48        Self {
49            owner: owner.to_string(),
50            repo: repo.to_string(),
51            state: None,
52            labels: None,
53            query: None,
54            issue_type: None,
55            milestone: None,
56            since: None,
57            before: None,
58            created_by: None,
59            assigned_by: None,
60            mentioned_by: None,
61            page: None,
62            limit: None,
63        }
64    }
65    /// Send the request to get the issues.
66    pub async fn send(&self, client: &crate::Client) -> Result<Vec<Issue>> {
67        let owner = &self.owner;
68        let repo = &self.repo;
69        let req = client
70            .get(format!("repos/{owner}/{repo}/issues"))
71            .query(self)
72            .build()?;
73        let res = client.make_request(req).await?;
74        client.parse_response(res).await
75    }
76}