ephemeris_forge_github/api/http/
autolinks.rs1use ephemeris_forge::{RepoRef, encode};
2use reqwest::Method;
3
4use crate::api::HttpApi;
5use crate::api::error::ForgeError;
6use crate::api::model::Autolink;
7use crate::api::operations::AutolinksApi;
8use crate::api::request::AutolinkBody;
9
10impl AutolinksApi for HttpApi {
11 async fn autolinks(&self, repository: &RepoRef) -> Result<Vec<Autolink>, ForgeError> {
12 let route = path(repository);
13 self.paged(&route).await
14 }
15
16 async fn create_autolink(
17 &self,
18 repository: &RepoRef,
19 autolink: &AutolinkBody,
20 ) -> Result<(), ForgeError> {
21 self.empty(Method::POST, &path(repository), Some(encode(autolink)))
22 .await
23 }
24
25 async fn delete_autolink(&self, repository: &RepoRef, id: u64) -> Result<(), ForgeError> {
26 self.empty(Method::DELETE, &format!("{}/{id}", path(repository)), None)
27 .await
28 }
29}
30
31fn path(repository: &RepoRef) -> String {
32 repository.path("autolinks")
33}