async_openai/types/admin/
certificates.rs

1use crate::error::OpenAIError;
2use derive_builder::Builder;
3use serde::{Deserialize, Serialize};
4
5/// Represents an individual certificate uploaded to the organization.
6#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
7pub struct Certificate {
8    /// The object type. Can be `certificate`, `organization.certificate`, or `organization.project.certificate`.
9    pub object: String,
10    /// The identifier, which can be referenced in API endpoints.
11    pub id: String,
12    /// The name of the certificate.
13    pub name: String,
14    /// The Unix timestamp (in seconds) of when the certificate was uploaded.
15    pub created_at: u64,
16    /// Details about the certificate.
17    pub certificate_details: CertificateDetails,
18    /// Whether the certificate is currently active at the specified scope.
19    /// Not returned when getting details for a specific certificate.
20    #[serde(skip_serializing_if = "Option::is_none")]
21    pub active: Option<bool>,
22}
23
24/// Details about a certificate.
25#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
26pub struct CertificateDetails {
27    /// The Unix timestamp (in seconds) of when the certificate becomes valid.
28    pub valid_at: u64,
29    /// The Unix timestamp (in seconds) of when the certificate expires.
30    pub expires_at: u64,
31    /// The content of the certificate in PEM format.
32    /// Only included when requested via the `include[]=content` query parameter.
33    #[serde(skip_serializing_if = "Option::is_none")]
34    pub content: Option<String>,
35}
36
37/// Response for listing certificates.
38#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
39pub struct ListCertificatesResponse {
40    /// The object type, which is always `list`.
41    pub object: String,
42    /// The list of certificates.
43    pub data: Vec<Certificate>,
44    /// The ID of the first certificate in the list.
45    #[serde(skip_serializing_if = "Option::is_none")]
46    pub first_id: Option<String>,
47    /// The ID of the last certificate in the list.
48    #[serde(skip_serializing_if = "Option::is_none")]
49    pub last_id: Option<String>,
50    /// Indicates if there are more certificates available.
51    pub has_more: bool,
52}
53
54/// Request for uploading a certificate.
55#[derive(Debug, Serialize, Deserialize, Builder, Clone, PartialEq)]
56#[builder(name = "UploadCertificateRequestArgs")]
57#[builder(pattern = "mutable")]
58#[builder(setter(into, strip_option))]
59#[builder(derive(Debug))]
60#[builder(build_fn(error = "OpenAIError"))]
61pub struct UploadCertificateRequest {
62    /// An optional name for the certificate.
63    #[serde(skip_serializing_if = "Option::is_none")]
64    pub name: Option<String>,
65    /// The certificate content in PEM format.
66    pub content: String,
67}
68
69/// Request for modifying a certificate.
70#[derive(Debug, Serialize, Deserialize, Builder, Clone, PartialEq)]
71#[builder(name = "ModifyCertificateRequestArgs")]
72#[builder(pattern = "mutable")]
73#[builder(setter(into, strip_option))]
74#[builder(derive(Debug))]
75#[builder(build_fn(error = "OpenAIError"))]
76pub struct ModifyCertificateRequest {
77    /// The updated name for the certificate.
78    pub name: String,
79}
80
81/// Request for toggling (activating/deactivating) certificates.
82#[derive(Debug, Serialize, Deserialize, Builder, Clone, PartialEq)]
83#[builder(name = "ToggleCertificatesRequestArgs")]
84#[builder(pattern = "mutable")]
85#[builder(setter(into, strip_option))]
86#[builder(derive(Debug))]
87#[builder(build_fn(error = "OpenAIError"))]
88pub struct ToggleCertificatesRequest {
89    /// Array of certificate IDs to toggle (1-10 certificates).
90    pub certificate_ids: Vec<String>,
91}
92
93/// Response for deleting a certificate.
94#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
95pub struct DeleteCertificateResponse {
96    /// The object type, which is always `certificate.deleted`.
97    pub object: String,
98    /// The ID of the certificate that was deleted.
99    pub id: String,
100}