1use std::sync::Arc;
12
13use async_trait::async_trait;
14#[cfg(feature = "mockall")]
15use mockall::automock;
16use reqwest;
17use serde::{Deserialize, Serialize, de::Error as _};
18
19use super::{Error, configuration};
20use crate::{
21 apis::{AuthRequired, ContentType, ResponseContent},
22 models,
23};
24
25#[cfg_attr(feature = "mockall", automock)]
26#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
27#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
28pub trait OrganizationDomainApi: Send + Sync {
29 async fn get<'a>(
31 &self,
32 org_id: uuid::Uuid,
33 id: uuid::Uuid,
34 ) -> Result<models::OrganizationDomainResponseModel, Error<GetError>>;
35
36 async fn get_all<'a>(
38 &self,
39 org_id: uuid::Uuid,
40 ) -> Result<models::OrganizationDomainResponseModelListResponseModel, Error<GetAllError>>;
41
42 async fn get_org_domain_sso_details<'a>(
44 &self,
45 organization_domain_sso_details_request_model: Option<
46 models::OrganizationDomainSsoDetailsRequestModel,
47 >,
48 ) -> Result<models::OrganizationDomainSsoDetailsResponseModel, Error<GetOrgDomainSsoDetailsError>>;
49
50 async fn get_verified_org_domain_sso_details<'a>(
52 &self,
53 organization_domain_sso_details_request_model: Option<
54 models::OrganizationDomainSsoDetailsRequestModel,
55 >,
56 ) -> Result<
57 models::VerifiedOrganizationDomainSsoDetailsResponseModel,
58 Error<GetVerifiedOrgDomainSsoDetailsError>,
59 >;
60
61 async fn post<'a>(
63 &self,
64 org_id: uuid::Uuid,
65 organization_domain_request_model: Option<models::OrganizationDomainRequestModel>,
66 ) -> Result<models::OrganizationDomainResponseModel, Error<PostError>>;
67
68 async fn remove_domain<'a>(
70 &self,
71 org_id: uuid::Uuid,
72 id: uuid::Uuid,
73 ) -> Result<(), Error<RemoveDomainError>>;
74
75 async fn verify<'a>(
77 &self,
78 org_id: uuid::Uuid,
79 id: uuid::Uuid,
80 ) -> Result<models::OrganizationDomainResponseModel, Error<VerifyError>>;
81}
82
83pub struct OrganizationDomainApiClient {
84 configuration: Arc<configuration::Configuration>,
85}
86
87impl OrganizationDomainApiClient {
88 pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
89 Self { configuration }
90 }
91}
92
93#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
94#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
95impl OrganizationDomainApi for OrganizationDomainApiClient {
96 async fn get<'a>(
97 &self,
98 org_id: uuid::Uuid,
99 id: uuid::Uuid,
100 ) -> Result<models::OrganizationDomainResponseModel, Error<GetError>> {
101 let local_var_configuration = &self.configuration;
102
103 let local_var_client = &local_var_configuration.client;
104
105 let local_var_uri_str = format!(
106 "{}/organizations/{orgId}/domain/{id}",
107 local_var_configuration.base_path,
108 orgId = org_id,
109 id = id
110 );
111 let mut local_var_req_builder =
112 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
113
114 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
115
116 let local_var_resp = local_var_req_builder.send().await?;
117
118 let local_var_status = local_var_resp.status();
119 let local_var_content_type = local_var_resp
120 .headers()
121 .get("content-type")
122 .and_then(|v| v.to_str().ok())
123 .unwrap_or("application/octet-stream");
124 let local_var_content_type = super::ContentType::from(local_var_content_type);
125 let local_var_content = local_var_resp.text().await?;
126
127 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
128 match local_var_content_type {
129 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
130 ContentType::Text => {
131 return Err(Error::from(serde_json::Error::custom(
132 "Received `text/plain` content type response that cannot be converted to `models::OrganizationDomainResponseModel`",
133 )));
134 }
135 ContentType::Unsupported(local_var_unknown_type) => {
136 return Err(Error::from(serde_json::Error::custom(format!(
137 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationDomainResponseModel`"
138 ))));
139 }
140 }
141 } else {
142 let local_var_entity: Option<GetError> = serde_json::from_str(&local_var_content).ok();
143 let local_var_error = ResponseContent {
144 status: local_var_status,
145 content: local_var_content,
146 entity: local_var_entity,
147 };
148 Err(Error::ResponseError(local_var_error))
149 }
150 }
151
152 async fn get_all<'a>(
153 &self,
154 org_id: uuid::Uuid,
155 ) -> Result<models::OrganizationDomainResponseModelListResponseModel, Error<GetAllError>> {
156 let local_var_configuration = &self.configuration;
157
158 let local_var_client = &local_var_configuration.client;
159
160 let local_var_uri_str = format!(
161 "{}/organizations/{orgId}/domain",
162 local_var_configuration.base_path,
163 orgId = org_id
164 );
165 let mut local_var_req_builder =
166 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
167
168 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
169
170 let local_var_resp = local_var_req_builder.send().await?;
171
172 let local_var_status = local_var_resp.status();
173 let local_var_content_type = local_var_resp
174 .headers()
175 .get("content-type")
176 .and_then(|v| v.to_str().ok())
177 .unwrap_or("application/octet-stream");
178 let local_var_content_type = super::ContentType::from(local_var_content_type);
179 let local_var_content = local_var_resp.text().await?;
180
181 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
182 match local_var_content_type {
183 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
184 ContentType::Text => {
185 return Err(Error::from(serde_json::Error::custom(
186 "Received `text/plain` content type response that cannot be converted to `models::OrganizationDomainResponseModelListResponseModel`",
187 )));
188 }
189 ContentType::Unsupported(local_var_unknown_type) => {
190 return Err(Error::from(serde_json::Error::custom(format!(
191 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationDomainResponseModelListResponseModel`"
192 ))));
193 }
194 }
195 } else {
196 let local_var_entity: Option<GetAllError> =
197 serde_json::from_str(&local_var_content).ok();
198 let local_var_error = ResponseContent {
199 status: local_var_status,
200 content: local_var_content,
201 entity: local_var_entity,
202 };
203 Err(Error::ResponseError(local_var_error))
204 }
205 }
206
207 async fn get_org_domain_sso_details<'a>(
208 &self,
209 organization_domain_sso_details_request_model: Option<
210 models::OrganizationDomainSsoDetailsRequestModel,
211 >,
212 ) -> Result<models::OrganizationDomainSsoDetailsResponseModel, Error<GetOrgDomainSsoDetailsError>>
213 {
214 let local_var_configuration = &self.configuration;
215
216 let local_var_client = &local_var_configuration.client;
217
218 let local_var_uri_str = format!(
219 "{}/organizations/domain/sso/details",
220 local_var_configuration.base_path
221 );
222 let mut local_var_req_builder =
223 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
224
225 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
226 local_var_req_builder =
227 local_var_req_builder.json(&organization_domain_sso_details_request_model);
228
229 let local_var_resp = local_var_req_builder.send().await?;
230
231 let local_var_status = local_var_resp.status();
232 let local_var_content_type = local_var_resp
233 .headers()
234 .get("content-type")
235 .and_then(|v| v.to_str().ok())
236 .unwrap_or("application/octet-stream");
237 let local_var_content_type = super::ContentType::from(local_var_content_type);
238 let local_var_content = local_var_resp.text().await?;
239
240 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
241 match local_var_content_type {
242 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
243 ContentType::Text => {
244 return Err(Error::from(serde_json::Error::custom(
245 "Received `text/plain` content type response that cannot be converted to `models::OrganizationDomainSsoDetailsResponseModel`",
246 )));
247 }
248 ContentType::Unsupported(local_var_unknown_type) => {
249 return Err(Error::from(serde_json::Error::custom(format!(
250 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationDomainSsoDetailsResponseModel`"
251 ))));
252 }
253 }
254 } else {
255 let local_var_entity: Option<GetOrgDomainSsoDetailsError> =
256 serde_json::from_str(&local_var_content).ok();
257 let local_var_error = ResponseContent {
258 status: local_var_status,
259 content: local_var_content,
260 entity: local_var_entity,
261 };
262 Err(Error::ResponseError(local_var_error))
263 }
264 }
265
266 async fn get_verified_org_domain_sso_details<'a>(
267 &self,
268 organization_domain_sso_details_request_model: Option<
269 models::OrganizationDomainSsoDetailsRequestModel,
270 >,
271 ) -> Result<
272 models::VerifiedOrganizationDomainSsoDetailsResponseModel,
273 Error<GetVerifiedOrgDomainSsoDetailsError>,
274 > {
275 let local_var_configuration = &self.configuration;
276
277 let local_var_client = &local_var_configuration.client;
278
279 let local_var_uri_str = format!(
280 "{}/organizations/domain/sso/verified",
281 local_var_configuration.base_path
282 );
283 let mut local_var_req_builder =
284 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
285
286 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
287 local_var_req_builder =
288 local_var_req_builder.json(&organization_domain_sso_details_request_model);
289
290 let local_var_resp = local_var_req_builder.send().await?;
291
292 let local_var_status = local_var_resp.status();
293 let local_var_content_type = local_var_resp
294 .headers()
295 .get("content-type")
296 .and_then(|v| v.to_str().ok())
297 .unwrap_or("application/octet-stream");
298 let local_var_content_type = super::ContentType::from(local_var_content_type);
299 let local_var_content = local_var_resp.text().await?;
300
301 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
302 match local_var_content_type {
303 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
304 ContentType::Text => {
305 return Err(Error::from(serde_json::Error::custom(
306 "Received `text/plain` content type response that cannot be converted to `models::VerifiedOrganizationDomainSsoDetailsResponseModel`",
307 )));
308 }
309 ContentType::Unsupported(local_var_unknown_type) => {
310 return Err(Error::from(serde_json::Error::custom(format!(
311 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::VerifiedOrganizationDomainSsoDetailsResponseModel`"
312 ))));
313 }
314 }
315 } else {
316 let local_var_entity: Option<GetVerifiedOrgDomainSsoDetailsError> =
317 serde_json::from_str(&local_var_content).ok();
318 let local_var_error = ResponseContent {
319 status: local_var_status,
320 content: local_var_content,
321 entity: local_var_entity,
322 };
323 Err(Error::ResponseError(local_var_error))
324 }
325 }
326
327 async fn post<'a>(
328 &self,
329 org_id: uuid::Uuid,
330 organization_domain_request_model: Option<models::OrganizationDomainRequestModel>,
331 ) -> Result<models::OrganizationDomainResponseModel, Error<PostError>> {
332 let local_var_configuration = &self.configuration;
333
334 let local_var_client = &local_var_configuration.client;
335
336 let local_var_uri_str = format!(
337 "{}/organizations/{orgId}/domain",
338 local_var_configuration.base_path,
339 orgId = org_id
340 );
341 let mut local_var_req_builder =
342 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
343
344 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
345 local_var_req_builder = local_var_req_builder.json(&organization_domain_request_model);
346
347 let local_var_resp = local_var_req_builder.send().await?;
348
349 let local_var_status = local_var_resp.status();
350 let local_var_content_type = local_var_resp
351 .headers()
352 .get("content-type")
353 .and_then(|v| v.to_str().ok())
354 .unwrap_or("application/octet-stream");
355 let local_var_content_type = super::ContentType::from(local_var_content_type);
356 let local_var_content = local_var_resp.text().await?;
357
358 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
359 match local_var_content_type {
360 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
361 ContentType::Text => {
362 return Err(Error::from(serde_json::Error::custom(
363 "Received `text/plain` content type response that cannot be converted to `models::OrganizationDomainResponseModel`",
364 )));
365 }
366 ContentType::Unsupported(local_var_unknown_type) => {
367 return Err(Error::from(serde_json::Error::custom(format!(
368 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationDomainResponseModel`"
369 ))));
370 }
371 }
372 } else {
373 let local_var_entity: Option<PostError> = serde_json::from_str(&local_var_content).ok();
374 let local_var_error = ResponseContent {
375 status: local_var_status,
376 content: local_var_content,
377 entity: local_var_entity,
378 };
379 Err(Error::ResponseError(local_var_error))
380 }
381 }
382
383 async fn remove_domain<'a>(
384 &self,
385 org_id: uuid::Uuid,
386 id: uuid::Uuid,
387 ) -> Result<(), Error<RemoveDomainError>> {
388 let local_var_configuration = &self.configuration;
389
390 let local_var_client = &local_var_configuration.client;
391
392 let local_var_uri_str = format!(
393 "{}/organizations/{orgId}/domain/{id}",
394 local_var_configuration.base_path,
395 orgId = org_id,
396 id = id
397 );
398 let mut local_var_req_builder =
399 local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
400
401 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
402
403 let local_var_resp = local_var_req_builder.send().await?;
404
405 let local_var_status = local_var_resp.status();
406 let local_var_content = local_var_resp.text().await?;
407
408 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
409 Ok(())
410 } else {
411 let local_var_entity: Option<RemoveDomainError> =
412 serde_json::from_str(&local_var_content).ok();
413 let local_var_error = ResponseContent {
414 status: local_var_status,
415 content: local_var_content,
416 entity: local_var_entity,
417 };
418 Err(Error::ResponseError(local_var_error))
419 }
420 }
421
422 async fn verify<'a>(
423 &self,
424 org_id: uuid::Uuid,
425 id: uuid::Uuid,
426 ) -> Result<models::OrganizationDomainResponseModel, Error<VerifyError>> {
427 let local_var_configuration = &self.configuration;
428
429 let local_var_client = &local_var_configuration.client;
430
431 let local_var_uri_str = format!(
432 "{}/organizations/{orgId}/domain/{id}/verify",
433 local_var_configuration.base_path,
434 orgId = org_id,
435 id = id
436 );
437 let mut local_var_req_builder =
438 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
439
440 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
441
442 let local_var_resp = local_var_req_builder.send().await?;
443
444 let local_var_status = local_var_resp.status();
445 let local_var_content_type = local_var_resp
446 .headers()
447 .get("content-type")
448 .and_then(|v| v.to_str().ok())
449 .unwrap_or("application/octet-stream");
450 let local_var_content_type = super::ContentType::from(local_var_content_type);
451 let local_var_content = local_var_resp.text().await?;
452
453 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
454 match local_var_content_type {
455 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
456 ContentType::Text => {
457 return Err(Error::from(serde_json::Error::custom(
458 "Received `text/plain` content type response that cannot be converted to `models::OrganizationDomainResponseModel`",
459 )));
460 }
461 ContentType::Unsupported(local_var_unknown_type) => {
462 return Err(Error::from(serde_json::Error::custom(format!(
463 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::OrganizationDomainResponseModel`"
464 ))));
465 }
466 }
467 } else {
468 let local_var_entity: Option<VerifyError> =
469 serde_json::from_str(&local_var_content).ok();
470 let local_var_error = ResponseContent {
471 status: local_var_status,
472 content: local_var_content,
473 entity: local_var_entity,
474 };
475 Err(Error::ResponseError(local_var_error))
476 }
477 }
478}
479
480#[derive(Debug, Clone, Serialize, Deserialize)]
482#[serde(untagged)]
483pub enum GetError {
484 UnknownValue(serde_json::Value),
485}
486#[derive(Debug, Clone, Serialize, Deserialize)]
488#[serde(untagged)]
489pub enum GetAllError {
490 UnknownValue(serde_json::Value),
491}
492#[derive(Debug, Clone, Serialize, Deserialize)]
494#[serde(untagged)]
495pub enum GetOrgDomainSsoDetailsError {
496 UnknownValue(serde_json::Value),
497}
498#[derive(Debug, Clone, Serialize, Deserialize)]
500#[serde(untagged)]
501pub enum GetVerifiedOrgDomainSsoDetailsError {
502 UnknownValue(serde_json::Value),
503}
504#[derive(Debug, Clone, Serialize, Deserialize)]
506#[serde(untagged)]
507pub enum PostError {
508 UnknownValue(serde_json::Value),
509}
510#[derive(Debug, Clone, Serialize, Deserialize)]
512#[serde(untagged)]
513pub enum RemoveDomainError {
514 UnknownValue(serde_json::Value),
515}
516#[derive(Debug, Clone, Serialize, Deserialize)]
518#[serde(untagged)]
519pub enum VerifyError {
520 UnknownValue(serde_json::Value),
521}