sendgrid_api/certificates.rs
1use crate::Client;
2use crate::ClientResult;
3
4pub struct Certificates {
5 pub client: Client,
6}
7
8impl Certificates {
9 #[doc(hidden)]
10 pub fn new(client: Client) -> Self {
11 Certificates { client }
12 }
13
14 /**
15 * Create an SSO Certificate.
16 *
17 * This function performs a `POST` to the `/sso/certificates` endpoint.
18 *
19 * **This endpoint allows you to create an SSO certificate.**
20 */
21 pub async fn post_sso(
22 &self,
23 body: &crate::types::PostSsoCertificatesRequest,
24 ) -> ClientResult<crate::Response<crate::types::SsoCertificateBody>> {
25 let url = self.client.url("/sso/certificates", None);
26 self.client
27 .post(
28 &url,
29 crate::Message {
30 body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
31 content_type: Some("application/json".to_string()),
32 },
33 )
34 .await
35 }
36 /**
37 * Get All SSO Certificates by Integration.
38 *
39 * This function performs a `GET` to the `/sso/integrations/{integration_id}/certificates` endpoint.
40 *
41 * **This endpoint allows you to retrieve all your IdP configurations by configuration ID.**
42 *
43 * The `integration_id` expected by this endpoint is the `id` returned in the response by the "Get All SSO Integrations" endpoint.
44 */
45 pub async fn get_sso_integrations_integration(
46 &self,
47 integration_id: &str,
48 ) -> ClientResult<crate::Response<Vec<crate::types::SsoCertificateBody>>> {
49 let url = self.client.url(
50 &format!(
51 "/sso/integrations/{}/certificates",
52 crate::progenitor_support::encode_path(integration_id),
53 ),
54 None,
55 );
56 self.client
57 .get(
58 &url,
59 crate::Message {
60 body: None,
61 content_type: None,
62 },
63 )
64 .await
65 }
66 /**
67 * Get All SSO Certificates by Integration.
68 *
69 * This function performs a `GET` to the `/sso/integrations/{integration_id}/certificates` endpoint.
70 *
71 * As opposed to `get_sso_integrations_integration`, this function returns all the pages of the request at once.
72 *
73 * **This endpoint allows you to retrieve all your IdP configurations by configuration ID.**
74 *
75 * The `integration_id` expected by this endpoint is the `id` returned in the response by the "Get All SSO Integrations" endpoint.
76 */
77 pub async fn get_all_sso_integrations_integration(
78 &self,
79 integration_id: &str,
80 ) -> ClientResult<crate::Response<Vec<crate::types::SsoCertificateBody>>> {
81 let url = self.client.url(
82 &format!(
83 "/sso/integrations/{}/certificates",
84 crate::progenitor_support::encode_path(integration_id),
85 ),
86 None,
87 );
88 self.client
89 .get_all_pages(
90 &url,
91 crate::Message {
92 body: None,
93 content_type: None,
94 },
95 )
96 .await
97 }
98 /**
99 * Get an SSO Certificate.
100 *
101 * This function performs a `GET` to the `/sso/certificates/{cert_id}` endpoint.
102 *
103 * **This endpoint allows you to retrieve an individual SSO certificate.**
104 */
105 pub async fn get_sso_cert(
106 &self,
107 cert_id: &str,
108 ) -> ClientResult<crate::Response<crate::types::SsoCertificateBody>> {
109 let url = self.client.url(
110 &format!(
111 "/sso/certificates/{}",
112 crate::progenitor_support::encode_path(cert_id),
113 ),
114 None,
115 );
116 self.client
117 .get(
118 &url,
119 crate::Message {
120 body: None,
121 content_type: None,
122 },
123 )
124 .await
125 }
126 /**
127 * Delete an SSO Certificate.
128 *
129 * This function performs a `DELETE` to the `/sso/certificates/{cert_id}` endpoint.
130 *
131 * **This endpoint allows you to delete an SSO certificate.**
132 *
133 * You can retrieve a certificate's ID from the response provided by the "Get All SSO Integrations" endpoint.
134 */
135 pub async fn delete_sso_cert(
136 &self,
137 cert_id: &str,
138 ) -> ClientResult<crate::Response<crate::types::SsoCertificateBody>> {
139 let url = self.client.url(
140 &format!(
141 "/sso/certificates/{}",
142 crate::progenitor_support::encode_path(cert_id),
143 ),
144 None,
145 );
146 self.client
147 .delete(
148 &url,
149 crate::Message {
150 body: None,
151 content_type: None,
152 },
153 )
154 .await
155 }
156 /**
157 * Update SSO Certificate.
158 *
159 * This function performs a `PATCH` to the `/sso/certificates/{cert_id}` endpoint.
160 *
161 * **This endpoint allows you to update an existing certificate by ID.**
162 *
163 * You can retrieve a certificate's ID from the response provided by the "Get All SSO Integrations" endpoint.
164 */
165 pub async fn patch_sso_cert(
166 &self,
167 cert_id: &str,
168 body: &crate::types::PatchSsoCertificatesCertRequest,
169 ) -> ClientResult<crate::Response<Vec<crate::types::SsoErrorResponse>>> {
170 let url = self.client.url(
171 &format!(
172 "/sso/certificates/{}",
173 crate::progenitor_support::encode_path(cert_id),
174 ),
175 None,
176 );
177 self.client
178 .patch(
179 &url,
180 crate::Message {
181 body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
182 content_type: Some("application/json".to_string()),
183 },
184 )
185 .await
186 }
187}