Skip to main content

ephemeris_forge_forgejo/api/operations/
branch_rules.rs

1use ephemeris_forge::RepoRef;
2
3use crate::api::error::ForgeError;
4use crate::api::model::BranchProtection;
5use crate::api::request::{CreateBranchProtectionOption, EditBranchProtectionOption};
6
7/// The branch rule operations of the Forgejo API.
8pub trait BranchRulesApi {
9    /// `GET /repos/{owner}/{repo}/branch_protections/{rule}`.
10    ///
11    /// `Ok(None)` when the forge answers 404, which means the rule is absent.
12    fn branch_protection(
13        &self,
14        repo: &RepoRef,
15        rule: &str,
16    ) -> impl Future<Output = Result<Option<BranchProtection>, ForgeError>> + Send;
17
18    /// `GET /repos/{owner}/{repo}/branch_protections`.
19    fn branch_protections(
20        &self,
21        repo: &RepoRef,
22    ) -> impl Future<Output = Result<Vec<BranchProtection>, ForgeError>> + Send;
23
24    /// `POST /repos/{owner}/{repo}/branch_protections`.
25    fn create_branch_protection(
26        &self,
27        repo: &RepoRef,
28        body: &CreateBranchProtectionOption,
29    ) -> impl Future<Output = Result<(), ForgeError>> + Send;
30
31    /// `DELETE /repos/{owner}/{repo}/branch_protections/{rule}`.
32    fn delete_branch_protection(
33        &self,
34        repo: &RepoRef,
35        rule: &str,
36    ) -> impl Future<Output = Result<(), ForgeError>> + Send;
37
38    /// `PATCH /repos/{owner}/{repo}/branch_protections/{rule}`.
39    fn patch_branch_protection(
40        &self,
41        repo: &RepoRef,
42        rule: &str,
43        body: &EditBranchProtectionOption,
44    ) -> impl Future<Output = Result<(), ForgeError>> + Send;
45}