async_openai/types/admin/
certificates.rs

1use crate::error::OpenAIError;
2use derive_builder::Builder;
3use serde::{Deserialize, Serialize};
4
5/// Sort order for listing organization certificates.
6#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
7#[serde(rename_all = "lowercase")]
8pub enum ListOrganizationCertificatesOrder {
9    /// Ascending order
10    Asc,
11    /// Descending order
12    Desc,
13}
14
15/// Query parameters for listing organization certificates.
16#[derive(Debug, Serialize, Default, Clone, Builder, PartialEq)]
17#[builder(name = "ListOrganizationCertificatesQueryArgs")]
18#[builder(pattern = "mutable")]
19#[builder(setter(into, strip_option), default)]
20#[builder(derive(Debug))]
21#[builder(build_fn(error = "OpenAIError"))]
22pub struct ListOrganizationCertificatesQuery {
23    /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
24    #[serde(skip_serializing_if = "Option::is_none")]
25    pub limit: Option<u32>,
26    /// A cursor for use in pagination. `after` is an object ID that defines your place in the list.
27    #[serde(skip_serializing_if = "Option::is_none")]
28    pub after: Option<String>,
29    /// Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order.
30    #[serde(skip_serializing_if = "Option::is_none")]
31    pub order: Option<ListOrganizationCertificatesOrder>,
32}
33
34/// Sort order for listing project certificates.
35#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
36#[serde(rename_all = "lowercase")]
37pub enum ListProjectCertificatesOrder {
38    /// Ascending order
39    Asc,
40    /// Descending order
41    Desc,
42}
43
44/// Query parameters for listing project certificates.
45#[derive(Debug, Serialize, Default, Clone, Builder, PartialEq)]
46#[builder(name = "ListProjectCertificatesQueryArgs")]
47#[builder(pattern = "mutable")]
48#[builder(setter(into, strip_option), default)]
49#[builder(derive(Debug))]
50#[builder(build_fn(error = "OpenAIError"))]
51pub struct ListProjectCertificatesQuery {
52    /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
53    #[serde(skip_serializing_if = "Option::is_none")]
54    pub limit: Option<u32>,
55    /// A cursor for use in pagination. `after` is an object ID that defines your place in the list.
56    #[serde(skip_serializing_if = "Option::is_none")]
57    pub after: Option<String>,
58    /// Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order.
59    #[serde(skip_serializing_if = "Option::is_none")]
60    pub order: Option<ListProjectCertificatesOrder>,
61}
62
63/// Query parameters for getting a certificate.
64#[derive(Debug, Serialize, Default, Clone, Builder, PartialEq)]
65#[builder(name = "GetCertificateQueryArgs")]
66#[builder(pattern = "mutable")]
67#[builder(setter(into, strip_option), default)]
68#[builder(derive(Debug))]
69#[builder(build_fn(error = "OpenAIError"))]
70pub struct GetCertificateQuery {
71    /// A list of additional fields to include in the response. Currently the only supported value is `content` to fetch the PEM content of the certificate.
72    #[serde(skip_serializing_if = "Option::is_none")]
73    pub include: Option<Vec<String>>,
74}
75
76/// Represents an individual certificate uploaded to the organization.
77#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
78pub struct Certificate {
79    /// The object type. Can be `certificate`, `organization.certificate`, or `organization.project.certificate`.
80    pub object: String,
81    /// The identifier, which can be referenced in API endpoints.
82    pub id: String,
83    /// The name of the certificate.
84    pub name: String,
85    /// The Unix timestamp (in seconds) of when the certificate was uploaded.
86    pub created_at: u64,
87    /// Details about the certificate.
88    pub certificate_details: CertificateDetails,
89    /// Whether the certificate is currently active at the specified scope.
90    /// Not returned when getting details for a specific certificate.
91    #[serde(skip_serializing_if = "Option::is_none")]
92    pub active: Option<bool>,
93}
94
95/// Details about a certificate.
96#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
97pub struct CertificateDetails {
98    /// The Unix timestamp (in seconds) of when the certificate becomes valid.
99    pub valid_at: u64,
100    /// The Unix timestamp (in seconds) of when the certificate expires.
101    pub expires_at: u64,
102    /// The content of the certificate in PEM format.
103    /// Only included when requested via the `include[]=content` query parameter.
104    #[serde(skip_serializing_if = "Option::is_none")]
105    pub content: Option<String>,
106}
107
108/// Response for listing certificates.
109#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
110pub struct ListCertificatesResponse {
111    /// The object type, which is always `list`.
112    pub object: String,
113    /// The list of certificates.
114    pub data: Vec<Certificate>,
115    /// The ID of the first certificate in the list.
116    #[serde(skip_serializing_if = "Option::is_none")]
117    pub first_id: Option<String>,
118    /// The ID of the last certificate in the list.
119    #[serde(skip_serializing_if = "Option::is_none")]
120    pub last_id: Option<String>,
121    /// Indicates if there are more certificates available.
122    pub has_more: bool,
123}
124
125/// Request for uploading a certificate.
126#[derive(Debug, Serialize, Deserialize, Builder, Clone, PartialEq)]
127#[builder(name = "UploadCertificateRequestArgs")]
128#[builder(pattern = "mutable")]
129#[builder(setter(into, strip_option))]
130#[builder(derive(Debug))]
131#[builder(build_fn(error = "OpenAIError"))]
132pub struct UploadCertificateRequest {
133    /// An optional name for the certificate.
134    #[serde(skip_serializing_if = "Option::is_none")]
135    pub name: Option<String>,
136    /// The certificate content in PEM format.
137    pub content: String,
138}
139
140/// Request for modifying a certificate.
141#[derive(Debug, Serialize, Deserialize, Builder, Clone, PartialEq)]
142#[builder(name = "ModifyCertificateRequestArgs")]
143#[builder(pattern = "mutable")]
144#[builder(setter(into, strip_option))]
145#[builder(derive(Debug))]
146#[builder(build_fn(error = "OpenAIError"))]
147pub struct ModifyCertificateRequest {
148    /// The updated name for the certificate.
149    pub name: String,
150}
151
152/// Request for toggling (activating/deactivating) certificates.
153#[derive(Debug, Serialize, Deserialize, Builder, Clone, PartialEq)]
154#[builder(name = "ToggleCertificatesRequestArgs")]
155#[builder(pattern = "mutable")]
156#[builder(setter(into, strip_option))]
157#[builder(derive(Debug))]
158#[builder(build_fn(error = "OpenAIError"))]
159pub struct ToggleCertificatesRequest {
160    /// Array of certificate IDs to toggle (1-10 certificates).
161    pub certificate_ids: Vec<String>,
162}
163
164/// Response for deleting a certificate.
165#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
166pub struct DeleteCertificateResponse {
167    /// The object type, which is always `certificate.deleted`.
168    pub object: String,
169    /// The ID of the certificate that was deleted.
170    pub id: String,
171}