1use std::collections::HashMap;
7
8use crate::{
9 CheckRun, CreateComment, CreatePullRequest, IssueComment, MergePullRequest, MergeResult,
10 PullRequest, Result, UpdateComment, UpdatePullRequest,
11};
12
13pub trait GitHubApi: Send + Sync {
23 fn get_pr(
27 &self,
28 owner: &str,
29 repo: &str,
30 number: u64,
31 ) -> impl std::future::Future<Output = Result<PullRequest>> + Send;
32
33 fn get_prs_batch(
37 &self,
38 owner: &str,
39 repo: &str,
40 numbers: &[u64],
41 ) -> impl std::future::Future<Output = Result<HashMap<u64, PullRequest>>> + Send;
42
43 fn find_pr_for_branch(
47 &self,
48 owner: &str,
49 repo: &str,
50 branch: &str,
51 ) -> impl std::future::Future<Output = Result<Option<PullRequest>>> + Send;
52
53 fn create_pr(
55 &self,
56 owner: &str,
57 repo: &str,
58 pr: CreatePullRequest,
59 ) -> impl std::future::Future<Output = Result<PullRequest>> + Send;
60
61 fn update_pr(
63 &self,
64 owner: &str,
65 repo: &str,
66 number: u64,
67 update: UpdatePullRequest,
68 ) -> impl std::future::Future<Output = Result<PullRequest>> + Send;
69
70 fn get_check_runs(
74 &self,
75 owner: &str,
76 repo: &str,
77 commit_sha: &str,
78 ) -> impl std::future::Future<Output = Result<Vec<CheckRun>>> + Send;
79
80 fn merge_pr(
84 &self,
85 owner: &str,
86 repo: &str,
87 number: u64,
88 merge: MergePullRequest,
89 ) -> impl std::future::Future<Output = Result<MergeResult>> + Send;
90
91 fn delete_ref(
95 &self,
96 owner: &str,
97 repo: &str,
98 ref_name: &str,
99 ) -> impl std::future::Future<Output = Result<()>> + Send;
100
101 fn get_default_branch(
105 &self,
106 owner: &str,
107 repo: &str,
108 ) -> impl std::future::Future<Output = Result<String>> + Send;
109
110 fn list_pr_comments(
114 &self,
115 owner: &str,
116 repo: &str,
117 pr_number: u64,
118 ) -> impl std::future::Future<Output = Result<Vec<IssueComment>>> + Send;
119
120 fn create_pr_comment(
122 &self,
123 owner: &str,
124 repo: &str,
125 pr_number: u64,
126 comment: CreateComment,
127 ) -> impl std::future::Future<Output = Result<IssueComment>> + Send;
128
129 fn update_pr_comment(
131 &self,
132 owner: &str,
133 repo: &str,
134 comment_id: u64,
135 comment: UpdateComment,
136 ) -> impl std::future::Future<Output = Result<IssueComment>> + Send;
137}