Skip to main content

ephemeris_forge_github/api/operations/
environments.rs

1use ephemeris_forge::RepoRef;
2
3use crate::BranchPolicy as Policy;
4use crate::api::error::ForgeError;
5use crate::api::model::{BranchPolicy, Environment};
6use crate::api::request::EnvironmentBody;
7
8/// The environments operations of the GitHub API.
9pub trait EnvironmentsApi {
10    /// Read the branch policies of `environment`.
11    fn branch_policies(
12        &self,
13        repository: &RepoRef,
14        environment: &str,
15    ) -> impl Future<Output = Result<Vec<BranchPolicy>, ForgeError>> + Send;
16
17    /// Add a branch policy to `environment`.
18    fn create_branch_policy(
19        &self,
20        repository: &RepoRef,
21        environment: &str,
22        policy: &Policy,
23    ) -> impl Future<Output = Result<(), ForgeError>> + Send;
24
25    /// Remove the branch policy `id` from `environment`.
26    fn delete_branch_policy(
27        &self,
28        repository: &RepoRef,
29        environment: &str,
30        id: u64,
31    ) -> impl Future<Output = Result<(), ForgeError>> + Send;
32
33    /// Delete `environment`.
34    fn delete_environment(
35        &self,
36        repository: &RepoRef,
37        environment: &str,
38    ) -> impl Future<Output = Result<(), ForgeError>> + Send;
39
40    /// Read the repository's environments, without their branch policies.
41    fn environments(
42        &self,
43        repository: &RepoRef,
44    ) -> impl Future<Output = Result<Vec<Environment>, ForgeError>> + Send;
45
46    /// Create `environment` or replace its settings.
47    fn put_environment(
48        &self,
49        repository: &RepoRef,
50        environment: &str,
51        settings: &EnvironmentBody,
52    ) -> impl Future<Output = Result<(), ForgeError>> + Send;
53}