sendgrid_api/
single_sign_on_settings.rs

1use crate::Client;
2use crate::ClientResult;
3
4pub struct SingleSignOnSettings {
5    pub client: Client,
6}
7
8impl SingleSignOnSettings {
9    #[doc(hidden)]
10    pub fn new(client: Client) -> Self {
11        SingleSignOnSettings { client }
12    }
13
14    /**
15     * Get All SSO Integrations.
16     *
17     * This function performs a `GET` to the `/sso/integrations` endpoint.
18     *
19     * **This endpoint allows you to retrieve all SSO integrations tied to your Twilio SendGrid account.**
20     *
21     * The IDs returned by this endpoint can be used by the APIs additional endpoints to modify your SSO integrations.
22     *
23     * **Parameters:**
24     *
25     * * `si: bool` -- If this parameter is set to `true`, the response will include the `completed_integration` field.
26     */
27    pub async fn get_sso_integrations(
28        &self,
29        si: bool,
30    ) -> ClientResult<crate::Response<Vec<crate::types::SsoIntegrationAllOf>>> {
31        let mut query_args: Vec<(String, String)> = Default::default();
32        if si {
33            query_args.push(("si".to_string(), si.to_string()));
34        }
35        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
36        let url = self
37            .client
38            .url(&format!("/sso/integrations?{}", query_), None);
39        self.client
40            .get(
41                &url,
42                crate::Message {
43                    body: None,
44                    content_type: None,
45                },
46            )
47            .await
48    }
49    /**
50     * Get All SSO Integrations.
51     *
52     * This function performs a `GET` to the `/sso/integrations` endpoint.
53     *
54     * As opposed to `get_sso_integrations`, this function returns all the pages of the request at once.
55     *
56     * **This endpoint allows you to retrieve all SSO integrations tied to your Twilio SendGrid account.**
57     *
58     * The IDs returned by this endpoint can be used by the APIs additional endpoints to modify your SSO integrations.
59     */
60    pub async fn get_all_sso_integrations(
61        &self,
62        si: bool,
63    ) -> ClientResult<crate::Response<Vec<crate::types::SsoIntegrationAllOf>>> {
64        let mut query_args: Vec<(String, String)> = Default::default();
65        if si {
66            query_args.push(("si".to_string(), si.to_string()));
67        }
68        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
69        let url = self
70            .client
71            .url(&format!("/sso/integrations?{}", query_), None);
72        self.client
73            .get_all_pages(
74                &url,
75                crate::Message {
76                    body: None,
77                    content_type: None,
78                },
79            )
80            .await
81    }
82    /**
83     * Create an SSO Integration.
84     *
85     * This function performs a `POST` to the `/sso/integrations` endpoint.
86     *
87     * **This endpoint allows you to create an SSO integration.**
88     */
89    pub async fn post_sso_integration(
90        &self,
91        body: &crate::types::CreateIntegrationRequest,
92    ) -> ClientResult<crate::Response<crate::types::SsoIntegrationAllOf>> {
93        let url = self.client.url("/sso/integrations", None);
94        self.client
95            .post(
96                &url,
97                crate::Message {
98                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
99                    content_type: None,
100                },
101            )
102            .await
103    }
104    /**
105     * Get an SSO Integration.
106     *
107     * This function performs a `GET` to the `/sso/integrations/{id}` endpoint.
108     *
109     * **This endpoint allows you to retrieve an SSO integration by ID.**
110     *
111     * You can retrieve the IDs for your configurations from the response provided by the "Get All SSO Integrations" endpoint.
112     *
113     * **Parameters:**
114     *
115     * * `si: bool` -- If this parameter is set to `true`, the response will include the `completed_integration` field.
116     */
117    pub async fn get_sso_integration(
118        &self,
119        id: &str,
120        si: bool,
121    ) -> ClientResult<crate::Response<crate::types::SsoIntegrationAllOf>> {
122        let mut query_args: Vec<(String, String)> = Default::default();
123        if si {
124            query_args.push(("si".to_string(), si.to_string()));
125        }
126        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
127        let url = self.client.url(
128            &format!(
129                "/sso/integrations/{}?{}",
130                crate::progenitor_support::encode_path(id),
131                query_
132            ),
133            None,
134        );
135        self.client
136            .get(
137                &url,
138                crate::Message {
139                    body: None,
140                    content_type: None,
141                },
142            )
143            .await
144    }
145    /**
146     * Delete an SSO Integration.
147     *
148     * This function performs a `DELETE` to the `/sso/integrations/{id}` endpoint.
149     *
150     * **This endpoint allows you to delete an IdP configuration by ID.**
151     *
152     * You can retrieve the IDs for your configurations from the response provided by the "Get All SSO Integrations" endpoint.
153     */
154    pub async fn delete_sso_integrations(&self, id: &str) -> ClientResult<crate::Response<()>> {
155        let url = self.client.url(
156            &format!(
157                "/sso/integrations/{}",
158                crate::progenitor_support::encode_path(id),
159            ),
160            None,
161        );
162        self.client
163            .delete(
164                &url,
165                crate::Message {
166                    body: None,
167                    content_type: None,
168                },
169            )
170            .await
171    }
172    /**
173     * Update an SSO Integration.
174     *
175     * This function performs a `PATCH` to the `/sso/integrations/{id}` endpoint.
176     *
177     * **This endpoint allows you to modify an exisiting SSO integration.**
178     *
179     * You can retrieve the IDs for your configurations from the response provided by the "Get All SSO Integrations" endpoint.
180     *
181     * **Parameters:**
182     *
183     * * `si: bool` -- If this parameter is set to `true`, the response will include the `completed_integration` field.
184     */
185    pub async fn patch_sso_integrations(
186        &self,
187        id: &str,
188        si: bool,
189        body: &crate::types::CreateIntegrationRequest,
190    ) -> ClientResult<crate::Response<crate::types::SsoIntegrationAllOf>> {
191        let mut query_args: Vec<(String, String)> = Default::default();
192        if si {
193            query_args.push(("si".to_string(), si.to_string()));
194        }
195        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
196        let url = self.client.url(
197            &format!(
198                "/sso/integrations/{}?{}",
199                crate::progenitor_support::encode_path(id),
200                query_
201            ),
202            None,
203        );
204        self.client
205            .patch(
206                &url,
207                crate::Message {
208                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
209                    content_type: None,
210                },
211            )
212            .await
213    }
214}