jellyfin_sdk_rust/api/endpoints/
api_keys.rs1use crate::{
2 api::URLBuilder,
3 models::{keys::JellyfinKey, JellyfinBaseResponse},
4 JellyfinAPI, JellyfinResponse, JellyfinSDKResult,
5};
6
7impl JellyfinAPI {
8 #[cfg(feature = "sync")]
9 pub fn get_all_keys(&self) {
10 unimplemented!()
11 }
12
13 pub async fn async_get_keys(
15 &self,
16 ) -> JellyfinSDKResult<JellyfinResponse<JellyfinBaseResponse<JellyfinKey>>> {
17 let url = URLBuilder::from(self.base_addr(), "/Auth/Keys")?;
18
19 let res = self.async_client().get(url.build()).send().await?;
20
21 JellyfinResponse::async_from(res).await
22 }
23
24 #[cfg(feature = "sync")]
25 pub fn create_key(&self, app: &str) {}
26
27 pub async fn async_create_key(&self, app: &str) -> JellyfinSDKResult<JellyfinResponse<()>> {
29 let mut url = URLBuilder::from(self.base_addr(), "/Auth/Keys")?;
30 url.add_param("App", app);
31
32 let res = self.async_client().post(url.build()).send().await?;
33
34 JellyfinResponse::async_from(res).await
35 }
36
37 #[cfg(feature = "sync")]
38 pub fn revoke_key(&self, key: &str) {}
39
40 pub async fn async_revoke_key(&self, key: &str) -> JellyfinSDKResult<JellyfinResponse<()>> {
42 let mut url = URLBuilder::from(self.base_addr(), "/Auth/Keys/")?;
43 url.join_path(key)?;
44
45 let res = self.async_client().delete(url.build()).send().await?;
46
47 JellyfinResponse::async_from(res).await
48 }
49}