Skip to main content

ephemeris_forge_forgejo/api/http/
actions_variables.rs

1use ephemeris_forge::{RepoRef, encode};
2use reqwest::Method;
3
4use crate::api::HttpApi;
5use crate::api::error::ForgeError;
6use crate::api::model::ActionVariable;
7use crate::api::operations::ActionsVariablesApi;
8use crate::api::request::{CreateVariableOption, UpdateVariableOption};
9
10impl ActionsVariablesApi for HttpApi {
11    async fn actions_variables(&self, repo: &RepoRef) -> Result<Vec<ActionVariable>, ForgeError> {
12        self.paged(&repo.path("actions/variables")).await
13    }
14
15    async fn create_actions_variable(
16        &self,
17        repo: &RepoRef,
18        name: &str,
19        body: &CreateVariableOption,
20    ) -> Result<(), ForgeError> {
21        let path = repo.path(&format!("actions/variables/{name}"));
22        let body = encode(body);
23        self.send_write(Method::POST, &path, Some(&body)).await
24    }
25
26    async fn update_actions_variable(
27        &self,
28        repo: &RepoRef,
29        name: &str,
30        body: &UpdateVariableOption,
31    ) -> Result<(), ForgeError> {
32        let path = repo.path(&format!("actions/variables/{name}"));
33        let body = encode(body);
34        self.send_write(Method::PUT, &path, Some(&body)).await
35    }
36
37    async fn delete_actions_variable(&self, repo: &RepoRef, name: &str) -> Result<(), ForgeError> {
38        let path = repo.path(&format!("actions/variables/{name}"));
39        self.send_write(Method::DELETE, &path, None).await
40    }
41}