async_openai/admin/
project_certificates.rs1use crate::{
2 config::Config,
3 error::OpenAIError,
4 types::admin::certificates::{ListCertificatesResponse, ToggleCertificatesRequest},
5 Client, RequestOptions,
6};
7
8pub struct ProjectCertificates<'c, C: Config> {
10 client: &'c Client<C>,
11 pub project_id: String,
12 pub(crate) request_options: RequestOptions,
13}
14
15impl<'c, C: Config> ProjectCertificates<'c, C> {
16 pub fn new(client: &'c Client<C>, project_id: &str) -> Self {
17 Self {
18 client,
19 project_id: project_id.into(),
20 request_options: RequestOptions::new(),
21 }
22 }
23
24 pub async fn list(&self) -> Result<ListCertificatesResponse, OpenAIError> {
26 self.client
27 .get(
28 format!("/organization/projects/{}/certificates", self.project_id).as_str(),
29 &self.request_options,
30 )
31 .await
32 }
33
34 pub async fn activate(
37 &self,
38 request: ToggleCertificatesRequest,
39 ) -> Result<ListCertificatesResponse, OpenAIError> {
40 self.client
41 .post(
42 format!(
43 "/organization/projects/{}/certificates/activate",
44 self.project_id
45 )
46 .as_str(),
47 request,
48 &self.request_options,
49 )
50 .await
51 }
52
53 pub async fn deactivate(
56 &self,
57 request: ToggleCertificatesRequest,
58 ) -> Result<ListCertificatesResponse, OpenAIError> {
59 self.client
60 .post(
61 format!(
62 "/organization/projects/{}/certificates/deactivate",
63 self.project_id
64 )
65 .as_str(),
66 request,
67 &self.request_options,
68 )
69 .await
70 }
71}