async_openai/admin/
external_storage.rs1use crate::{
2 config::Config, error::OpenAIError, types::admin::external_storage::*, Client, RequestOptions,
3};
4
5pub struct ExternalStorage<'c, C: Config> {
7 client: &'c Client<C>,
8 pub(crate) request_options: RequestOptions,
9}
10
11impl<'c, C: Config> ExternalStorage<'c, C> {
12 pub fn new(client: &'c Client<C>) -> Self {
13 Self {
14 client,
15 request_options: RequestOptions::new(),
16 }
17 }
18
19 #[crate::byot(T0 = serde::Serialize, R = serde::de::DeserializeOwned)]
21 pub async fn create(
22 &self,
23 request: CreateExternalStorageBody,
24 ) -> Result<ExternalStorageResponse, OpenAIError> {
25 self.client
26 .post(
27 "/organization/external_storage",
28 request,
29 &self.request_options,
30 )
31 .await
32 }
33
34 #[crate::byot(R = serde::de::DeserializeOwned)]
36 pub async fn list(&self) -> Result<ExternalStorageListResource, OpenAIError> {
37 self.client
38 .get("/organization/external_storage", &self.request_options)
39 .await
40 }
41
42 #[crate::byot(T0 = std::fmt::Display, R = serde::de::DeserializeOwned)]
44 pub async fn retrieve(&self, id: &str) -> Result<ExternalStorageResponse, OpenAIError> {
45 self.client
46 .get(
47 &format!("/organization/external_storage/{id}"),
48 &self.request_options,
49 )
50 .await
51 }
52
53 #[crate::byot(T0 = std::fmt::Display, R = serde::de::DeserializeOwned)]
55 pub async fn delete(&self, id: &str) -> Result<ExternalStorageDeletedResource, OpenAIError> {
56 self.client
57 .delete(
58 &format!("/organization/external_storage/{id}"),
59 &self.request_options,
60 )
61 .await
62 }
63
64 #[crate::byot(T0 = std::fmt::Display, R = serde::de::DeserializeOwned)]
66 pub async fn validate(&self, id: &str) -> Result<ExternalStorageResponse, OpenAIError> {
67 self.client
68 .post(
69 &format!("/organization/external_storage/{id}/validate"),
70 serde_json::json!({}),
71 &self.request_options,
72 )
73 .await
74 }
75}