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