ory_client/apis/
project_api.rs

1/*
2 * Ory APIs
3 *
4 * # Introduction Documentation for all public and administrative Ory APIs. Administrative APIs can only be accessed with a valid Personal Access Token. Public APIs are mostly used in browsers.  ## SDKs This document describes the APIs available in the Ory Network. The APIs are available as SDKs for the following languages:  | Language       | Download SDK                                                     | Documentation                                                                        | | -------------- | ---------------------------------------------------------------- | ------------------------------------------------------------------------------------ | | Dart           | [pub.dev](https://pub.dev/packages/ory_client)                   | [README](https://github.com/ory/sdk/blob/master/clients/client/dart/README.md)       | | .NET           | [nuget.org](https://www.nuget.org/packages/Ory.Client/)          | [README](https://github.com/ory/sdk/blob/master/clients/client/dotnet/README.md)     | | Elixir         | [hex.pm](https://hex.pm/packages/ory_client)                     | [README](https://github.com/ory/sdk/blob/master/clients/client/elixir/README.md)     | | Go             | [github.com](https://github.com/ory/client-go)                   | [README](https://github.com/ory/sdk/blob/master/clients/client/go/README.md)         | | Java           | [maven.org](https://search.maven.org/artifact/sh.ory/ory-client) | [README](https://github.com/ory/sdk/blob/master/clients/client/java/README.md)       | | JavaScript     | [npmjs.com](https://www.npmjs.com/package/@ory/client)           | [README](https://github.com/ory/sdk/blob/master/clients/client/typescript/README.md) | | JavaScript (With fetch) | [npmjs.com](https://www.npmjs.com/package/@ory/client-fetch)           | [README](https://github.com/ory/sdk/blob/master/clients/client/typescript-fetch/README.md) |  | PHP            | [packagist.org](https://packagist.org/packages/ory/client)       | [README](https://github.com/ory/sdk/blob/master/clients/client/php/README.md)        | | Python         | [pypi.org](https://pypi.org/project/ory-client/)                 | [README](https://github.com/ory/sdk/blob/master/clients/client/python/README.md)     | | Ruby           | [rubygems.org](https://rubygems.org/gems/ory-client)             | [README](https://github.com/ory/sdk/blob/master/clients/client/ruby/README.md)       | | Rust           | [crates.io](https://crates.io/crates/ory-client)                 | [README](https://github.com/ory/sdk/blob/master/clients/client/rust/README.md)       | 
5 *
6 * The version of the OpenAPI document: v1.22.4
7 * Contact: support@ory.sh
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18/// struct for typed errors of method [`create_organization`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum CreateOrganizationError {
22    Status400(models::ErrorGeneric),
23    Status403(models::ErrorGeneric),
24    Status409(models::ErrorGeneric),
25    DefaultResponse(models::ErrorGeneric),
26    UnknownValue(serde_json::Value),
27}
28
29/// struct for typed errors of method [`create_organization_onboarding_portal_link`]
30#[derive(Debug, Clone, Serialize, Deserialize)]
31#[serde(untagged)]
32pub enum CreateOrganizationOnboardingPortalLinkError {
33    DefaultResponse(models::ErrorGeneric),
34    UnknownValue(serde_json::Value),
35}
36
37/// struct for typed errors of method [`create_project`]
38#[derive(Debug, Clone, Serialize, Deserialize)]
39#[serde(untagged)]
40pub enum CreateProjectError {
41    Status401(models::ErrorGeneric),
42    Status403(models::ErrorGeneric),
43    Status404(models::ErrorGeneric),
44    DefaultResponse(models::ErrorGeneric),
45    UnknownValue(serde_json::Value),
46}
47
48/// struct for typed errors of method [`create_project_api_key`]
49#[derive(Debug, Clone, Serialize, Deserialize)]
50#[serde(untagged)]
51pub enum CreateProjectApiKeyError {
52    DefaultResponse(models::ErrorGeneric),
53    UnknownValue(serde_json::Value),
54}
55
56/// struct for typed errors of method [`delete_organization`]
57#[derive(Debug, Clone, Serialize, Deserialize)]
58#[serde(untagged)]
59pub enum DeleteOrganizationError {
60    Status400(models::ErrorGeneric),
61    Status403(models::ErrorGeneric),
62    Status404(models::ErrorGeneric),
63    Status409(models::ErrorGeneric),
64    DefaultResponse(models::ErrorGeneric),
65    UnknownValue(serde_json::Value),
66}
67
68/// struct for typed errors of method [`delete_organization_onboarding_portal_link`]
69#[derive(Debug, Clone, Serialize, Deserialize)]
70#[serde(untagged)]
71pub enum DeleteOrganizationOnboardingPortalLinkError {
72    Status400(models::ErrorGeneric),
73    Status403(models::ErrorGeneric),
74    DefaultResponse(models::ErrorGeneric),
75    UnknownValue(serde_json::Value),
76}
77
78/// struct for typed errors of method [`delete_project_api_key`]
79#[derive(Debug, Clone, Serialize, Deserialize)]
80#[serde(untagged)]
81pub enum DeleteProjectApiKeyError {
82    DefaultResponse(models::ErrorGeneric),
83    UnknownValue(serde_json::Value),
84}
85
86/// struct for typed errors of method [`get_organization`]
87#[derive(Debug, Clone, Serialize, Deserialize)]
88#[serde(untagged)]
89pub enum GetOrganizationError {
90    Status400(models::ErrorGeneric),
91    Status403(models::ErrorGeneric),
92    DefaultResponse(models::ErrorGeneric),
93    UnknownValue(serde_json::Value),
94}
95
96/// struct for typed errors of method [`get_organization_onboarding_portal_links`]
97#[derive(Debug, Clone, Serialize, Deserialize)]
98#[serde(untagged)]
99pub enum GetOrganizationOnboardingPortalLinksError {
100    Status400(models::ErrorGeneric),
101    Status403(models::ErrorGeneric),
102    DefaultResponse(models::ErrorGeneric),
103    UnknownValue(serde_json::Value),
104}
105
106/// struct for typed errors of method [`get_project`]
107#[derive(Debug, Clone, Serialize, Deserialize)]
108#[serde(untagged)]
109pub enum GetProjectError {
110    Status401(models::ErrorGeneric),
111    Status403(models::ErrorGeneric),
112    Status404(models::ErrorGeneric),
113    DefaultResponse(models::ErrorGeneric),
114    UnknownValue(serde_json::Value),
115}
116
117/// struct for typed errors of method [`get_project_members`]
118#[derive(Debug, Clone, Serialize, Deserialize)]
119#[serde(untagged)]
120pub enum GetProjectMembersError {
121    Status401(models::GenericError),
122    Status406(models::GenericError),
123    DefaultResponse(models::GenericError),
124    UnknownValue(serde_json::Value),
125}
126
127/// struct for typed errors of method [`list_organizations`]
128#[derive(Debug, Clone, Serialize, Deserialize)]
129#[serde(untagged)]
130pub enum ListOrganizationsError {
131    Status400(models::ErrorGeneric),
132    Status403(models::ErrorGeneric),
133    DefaultResponse(models::ErrorGeneric),
134    UnknownValue(serde_json::Value),
135}
136
137/// struct for typed errors of method [`list_project_api_keys`]
138#[derive(Debug, Clone, Serialize, Deserialize)]
139#[serde(untagged)]
140pub enum ListProjectApiKeysError {
141    DefaultResponse(models::ErrorGeneric),
142    UnknownValue(serde_json::Value),
143}
144
145/// struct for typed errors of method [`list_projects`]
146#[derive(Debug, Clone, Serialize, Deserialize)]
147#[serde(untagged)]
148pub enum ListProjectsError {
149    Status401(models::ErrorGeneric),
150    Status403(models::ErrorGeneric),
151    Status404(models::ErrorGeneric),
152    DefaultResponse(models::ErrorGeneric),
153    UnknownValue(serde_json::Value),
154}
155
156/// struct for typed errors of method [`patch_project`]
157#[derive(Debug, Clone, Serialize, Deserialize)]
158#[serde(untagged)]
159pub enum PatchProjectError {
160    Status400(models::ErrorGeneric),
161    Status401(models::ErrorGeneric),
162    Status403(models::ErrorGeneric),
163    Status404(models::ErrorGeneric),
164    DefaultResponse(models::ErrorGeneric),
165    UnknownValue(serde_json::Value),
166}
167
168/// struct for typed errors of method [`patch_project_with_revision`]
169#[derive(Debug, Clone, Serialize, Deserialize)]
170#[serde(untagged)]
171pub enum PatchProjectWithRevisionError {
172    Status400(models::ErrorGeneric),
173    Status401(models::ErrorGeneric),
174    Status403(models::ErrorGeneric),
175    Status404(models::ErrorGeneric),
176    DefaultResponse(models::ErrorGeneric),
177    UnknownValue(serde_json::Value),
178}
179
180/// struct for typed errors of method [`purge_project`]
181#[derive(Debug, Clone, Serialize, Deserialize)]
182#[serde(untagged)]
183pub enum PurgeProjectError {
184    Status401(models::GenericError),
185    Status403(models::GenericError),
186    Status404(models::GenericError),
187    DefaultResponse(models::GenericError),
188    UnknownValue(serde_json::Value),
189}
190
191/// struct for typed errors of method [`remove_project_member`]
192#[derive(Debug, Clone, Serialize, Deserialize)]
193#[serde(untagged)]
194pub enum RemoveProjectMemberError {
195    Status401(models::GenericError),
196    Status406(models::GenericError),
197    DefaultResponse(models::GenericError),
198    UnknownValue(serde_json::Value),
199}
200
201/// struct for typed errors of method [`set_project`]
202#[derive(Debug, Clone, Serialize, Deserialize)]
203#[serde(untagged)]
204pub enum SetProjectError {
205    Status400(models::ErrorGeneric),
206    Status401(models::ErrorGeneric),
207    Status403(models::ErrorGeneric),
208    Status404(models::ErrorGeneric),
209    DefaultResponse(models::ErrorGeneric),
210    UnknownValue(serde_json::Value),
211}
212
213/// struct for typed errors of method [`update_organization`]
214#[derive(Debug, Clone, Serialize, Deserialize)]
215#[serde(untagged)]
216pub enum UpdateOrganizationError {
217    Status400(models::ErrorGeneric),
218    Status403(models::ErrorGeneric),
219    Status404(models::ErrorGeneric),
220    Status409(models::ErrorGeneric),
221    DefaultResponse(models::ErrorGeneric),
222    UnknownValue(serde_json::Value),
223}
224
225/// struct for typed errors of method [`update_organization_onboarding_portal_link`]
226#[derive(Debug, Clone, Serialize, Deserialize)]
227#[serde(untagged)]
228pub enum UpdateOrganizationOnboardingPortalLinkError {
229    DefaultResponse(models::ErrorGeneric),
230    UnknownValue(serde_json::Value),
231}
232
233
234/// Creates an Enterprise SSO Organization in a project.
235pub async fn create_organization(configuration: &configuration::Configuration, project_id: &str, organization_body: Option<models::OrganizationBody>) -> Result<models::Organization, Error<CreateOrganizationError>> {
236    // add a prefix to parameters to efficiently prevent name collisions
237    let p_project_id = project_id;
238    let p_organization_body = organization_body;
239
240    let uri_str = format!("{}/projects/{project_id}/organizations", configuration.base_path, project_id=crate::apis::urlencode(p_project_id));
241    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
242
243    if let Some(ref user_agent) = configuration.user_agent {
244        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
245    }
246    if let Some(ref token) = configuration.bearer_access_token {
247        req_builder = req_builder.bearer_auth(token.to_owned());
248    };
249    req_builder = req_builder.json(&p_organization_body);
250
251    let req = req_builder.build()?;
252    let resp = configuration.client.execute(req).await?;
253
254    let status = resp.status();
255    let content_type = resp
256        .headers()
257        .get("content-type")
258        .and_then(|v| v.to_str().ok())
259        .unwrap_or("application/octet-stream");
260    let content_type = super::ContentType::from(content_type);
261
262    if !status.is_client_error() && !status.is_server_error() {
263        let content = resp.text().await?;
264        match content_type {
265            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
266            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Organization`"))),
267            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Organization`")))),
268        }
269    } else {
270        let content = resp.text().await?;
271        let entity: Option<CreateOrganizationError> = serde_json::from_str(&content).ok();
272        Err(Error::ResponseError(ResponseContent { status, content, entity }))
273    }
274}
275
276/// Create a onboarding portal link for an organization.
277pub async fn create_organization_onboarding_portal_link(configuration: &configuration::Configuration, project_id: &str, organization_id: &str, create_organization_onboarding_portal_link_body: Option<models::CreateOrganizationOnboardingPortalLinkBody>) -> Result<models::OnboardingPortalLink, Error<CreateOrganizationOnboardingPortalLinkError>> {
278    // add a prefix to parameters to efficiently prevent name collisions
279    let p_project_id = project_id;
280    let p_organization_id = organization_id;
281    let p_create_organization_onboarding_portal_link_body = create_organization_onboarding_portal_link_body;
282
283    let uri_str = format!("{}/projects/{project_id}/organizations/{organization_id}/onboarding-portal-links", configuration.base_path, project_id=crate::apis::urlencode(p_project_id), organization_id=crate::apis::urlencode(p_organization_id));
284    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
285
286    if let Some(ref user_agent) = configuration.user_agent {
287        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
288    }
289    if let Some(ref token) = configuration.bearer_access_token {
290        req_builder = req_builder.bearer_auth(token.to_owned());
291    };
292    req_builder = req_builder.json(&p_create_organization_onboarding_portal_link_body);
293
294    let req = req_builder.build()?;
295    let resp = configuration.client.execute(req).await?;
296
297    let status = resp.status();
298    let content_type = resp
299        .headers()
300        .get("content-type")
301        .and_then(|v| v.to_str().ok())
302        .unwrap_or("application/octet-stream");
303    let content_type = super::ContentType::from(content_type);
304
305    if !status.is_client_error() && !status.is_server_error() {
306        let content = resp.text().await?;
307        match content_type {
308            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
309            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OnboardingPortalLink`"))),
310            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OnboardingPortalLink`")))),
311        }
312    } else {
313        let content = resp.text().await?;
314        let entity: Option<CreateOrganizationOnboardingPortalLinkError> = serde_json::from_str(&content).ok();
315        Err(Error::ResponseError(ResponseContent { status, content, entity }))
316    }
317}
318
319/// Creates a new project.
320pub async fn create_project(configuration: &configuration::Configuration, create_project_body: Option<models::CreateProjectBody>) -> Result<models::Project, Error<CreateProjectError>> {
321    // add a prefix to parameters to efficiently prevent name collisions
322    let p_create_project_body = create_project_body;
323
324    let uri_str = format!("{}/projects", configuration.base_path);
325    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
326
327    if let Some(ref user_agent) = configuration.user_agent {
328        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
329    }
330    if let Some(ref token) = configuration.bearer_access_token {
331        req_builder = req_builder.bearer_auth(token.to_owned());
332    };
333    req_builder = req_builder.json(&p_create_project_body);
334
335    let req = req_builder.build()?;
336    let resp = configuration.client.execute(req).await?;
337
338    let status = resp.status();
339    let content_type = resp
340        .headers()
341        .get("content-type")
342        .and_then(|v| v.to_str().ok())
343        .unwrap_or("application/octet-stream");
344    let content_type = super::ContentType::from(content_type);
345
346    if !status.is_client_error() && !status.is_server_error() {
347        let content = resp.text().await?;
348        match content_type {
349            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
350            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Project`"))),
351            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Project`")))),
352        }
353    } else {
354        let content = resp.text().await?;
355        let entity: Option<CreateProjectError> = serde_json::from_str(&content).ok();
356        Err(Error::ResponseError(ResponseContent { status, content, entity }))
357    }
358}
359
360/// Create an API key for a project.
361pub async fn create_project_api_key(configuration: &configuration::Configuration, project: &str, create_project_api_key_request: Option<models::CreateProjectApiKeyRequest>) -> Result<models::ProjectApiKey, Error<CreateProjectApiKeyError>> {
362    // add a prefix to parameters to efficiently prevent name collisions
363    let p_project = project;
364    let p_create_project_api_key_request = create_project_api_key_request;
365
366    let uri_str = format!("{}/projects/{project}/tokens", configuration.base_path, project=crate::apis::urlencode(p_project));
367    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
368
369    if let Some(ref user_agent) = configuration.user_agent {
370        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
371    }
372    if let Some(ref token) = configuration.bearer_access_token {
373        req_builder = req_builder.bearer_auth(token.to_owned());
374    };
375    req_builder = req_builder.json(&p_create_project_api_key_request);
376
377    let req = req_builder.build()?;
378    let resp = configuration.client.execute(req).await?;
379
380    let status = resp.status();
381    let content_type = resp
382        .headers()
383        .get("content-type")
384        .and_then(|v| v.to_str().ok())
385        .unwrap_or("application/octet-stream");
386    let content_type = super::ContentType::from(content_type);
387
388    if !status.is_client_error() && !status.is_server_error() {
389        let content = resp.text().await?;
390        match content_type {
391            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
392            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProjectApiKey`"))),
393            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ProjectApiKey`")))),
394        }
395    } else {
396        let content = resp.text().await?;
397        let entity: Option<CreateProjectApiKeyError> = serde_json::from_str(&content).ok();
398        Err(Error::ResponseError(ResponseContent { status, content, entity }))
399    }
400}
401
402/// Irrecoverably deletes an Enterprise SSO Organization in a project by its ID.
403pub async fn delete_organization(configuration: &configuration::Configuration, project_id: &str, organization_id: &str) -> Result<(), Error<DeleteOrganizationError>> {
404    // add a prefix to parameters to efficiently prevent name collisions
405    let p_project_id = project_id;
406    let p_organization_id = organization_id;
407
408    let uri_str = format!("{}/projects/{project_id}/organizations/{organization_id}", configuration.base_path, project_id=crate::apis::urlencode(p_project_id), organization_id=crate::apis::urlencode(p_organization_id));
409    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
410
411    if let Some(ref user_agent) = configuration.user_agent {
412        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
413    }
414    if let Some(ref token) = configuration.bearer_access_token {
415        req_builder = req_builder.bearer_auth(token.to_owned());
416    };
417
418    let req = req_builder.build()?;
419    let resp = configuration.client.execute(req).await?;
420
421    let status = resp.status();
422
423    if !status.is_client_error() && !status.is_server_error() {
424        Ok(())
425    } else {
426        let content = resp.text().await?;
427        let entity: Option<DeleteOrganizationError> = serde_json::from_str(&content).ok();
428        Err(Error::ResponseError(ResponseContent { status, content, entity }))
429    }
430}
431
432/// Deletes a onboarding portal link for an organization.
433pub async fn delete_organization_onboarding_portal_link(configuration: &configuration::Configuration, project_id: &str, organization_id: &str, onboarding_portal_link_id: &str) -> Result<(), Error<DeleteOrganizationOnboardingPortalLinkError>> {
434    // add a prefix to parameters to efficiently prevent name collisions
435    let p_project_id = project_id;
436    let p_organization_id = organization_id;
437    let p_onboarding_portal_link_id = onboarding_portal_link_id;
438
439    let uri_str = format!("{}/projects/{project_id}/organizations/{organization_id}/onboarding-portal-links/{onboarding_portal_link_id}", configuration.base_path, project_id=crate::apis::urlencode(p_project_id), organization_id=crate::apis::urlencode(p_organization_id), onboarding_portal_link_id=crate::apis::urlencode(p_onboarding_portal_link_id));
440    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
441
442    if let Some(ref user_agent) = configuration.user_agent {
443        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
444    }
445    if let Some(ref token) = configuration.bearer_access_token {
446        req_builder = req_builder.bearer_auth(token.to_owned());
447    };
448
449    let req = req_builder.build()?;
450    let resp = configuration.client.execute(req).await?;
451
452    let status = resp.status();
453
454    if !status.is_client_error() && !status.is_server_error() {
455        Ok(())
456    } else {
457        let content = resp.text().await?;
458        let entity: Option<DeleteOrganizationOnboardingPortalLinkError> = serde_json::from_str(&content).ok();
459        Err(Error::ResponseError(ResponseContent { status, content, entity }))
460    }
461}
462
463/// Deletes an API key and immediately removes it.
464pub async fn delete_project_api_key(configuration: &configuration::Configuration, project: &str, token_id: &str) -> Result<(), Error<DeleteProjectApiKeyError>> {
465    // add a prefix to parameters to efficiently prevent name collisions
466    let p_project = project;
467    let p_token_id = token_id;
468
469    let uri_str = format!("{}/projects/{project}/tokens/{token_id}", configuration.base_path, project=crate::apis::urlencode(p_project), token_id=crate::apis::urlencode(p_token_id));
470    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
471
472    if let Some(ref user_agent) = configuration.user_agent {
473        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
474    }
475    if let Some(ref token) = configuration.bearer_access_token {
476        req_builder = req_builder.bearer_auth(token.to_owned());
477    };
478
479    let req = req_builder.build()?;
480    let resp = configuration.client.execute(req).await?;
481
482    let status = resp.status();
483
484    if !status.is_client_error() && !status.is_server_error() {
485        Ok(())
486    } else {
487        let content = resp.text().await?;
488        let entity: Option<DeleteProjectApiKeyError> = serde_json::from_str(&content).ok();
489        Err(Error::ResponseError(ResponseContent { status, content, entity }))
490    }
491}
492
493/// Retrieves an Enterprise SSO Organization for a project by its ID
494pub async fn get_organization(configuration: &configuration::Configuration, project_id: &str, organization_id: &str) -> Result<models::GetOrganizationResponse, Error<GetOrganizationError>> {
495    // add a prefix to parameters to efficiently prevent name collisions
496    let p_project_id = project_id;
497    let p_organization_id = organization_id;
498
499    let uri_str = format!("{}/projects/{project_id}/organizations/{organization_id}", configuration.base_path, project_id=crate::apis::urlencode(p_project_id), organization_id=crate::apis::urlencode(p_organization_id));
500    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
501
502    if let Some(ref user_agent) = configuration.user_agent {
503        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
504    }
505    if let Some(ref token) = configuration.bearer_access_token {
506        req_builder = req_builder.bearer_auth(token.to_owned());
507    };
508
509    let req = req_builder.build()?;
510    let resp = configuration.client.execute(req).await?;
511
512    let status = resp.status();
513    let content_type = resp
514        .headers()
515        .get("content-type")
516        .and_then(|v| v.to_str().ok())
517        .unwrap_or("application/octet-stream");
518    let content_type = super::ContentType::from(content_type);
519
520    if !status.is_client_error() && !status.is_server_error() {
521        let content = resp.text().await?;
522        match content_type {
523            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
524            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetOrganizationResponse`"))),
525            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetOrganizationResponse`")))),
526        }
527    } else {
528        let content = resp.text().await?;
529        let entity: Option<GetOrganizationError> = serde_json::from_str(&content).ok();
530        Err(Error::ResponseError(ResponseContent { status, content, entity }))
531    }
532}
533
534/// Retrieves the organization onboarding portal links.
535pub async fn get_organization_onboarding_portal_links(configuration: &configuration::Configuration, project_id: &str, organization_id: &str) -> Result<models::OrganizationOnboardingPortalLinksResponse, Error<GetOrganizationOnboardingPortalLinksError>> {
536    // add a prefix to parameters to efficiently prevent name collisions
537    let p_project_id = project_id;
538    let p_organization_id = organization_id;
539
540    let uri_str = format!("{}/projects/{project_id}/organizations/{organization_id}/onboarding-portal-links", configuration.base_path, project_id=crate::apis::urlencode(p_project_id), organization_id=crate::apis::urlencode(p_organization_id));
541    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
542
543    if let Some(ref user_agent) = configuration.user_agent {
544        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
545    }
546    if let Some(ref token) = configuration.bearer_access_token {
547        req_builder = req_builder.bearer_auth(token.to_owned());
548    };
549
550    let req = req_builder.build()?;
551    let resp = configuration.client.execute(req).await?;
552
553    let status = resp.status();
554    let content_type = resp
555        .headers()
556        .get("content-type")
557        .and_then(|v| v.to_str().ok())
558        .unwrap_or("application/octet-stream");
559    let content_type = super::ContentType::from(content_type);
560
561    if !status.is_client_error() && !status.is_server_error() {
562        let content = resp.text().await?;
563        match content_type {
564            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
565            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationOnboardingPortalLinksResponse`"))),
566            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationOnboardingPortalLinksResponse`")))),
567        }
568    } else {
569        let content = resp.text().await?;
570        let entity: Option<GetOrganizationOnboardingPortalLinksError> = serde_json::from_str(&content).ok();
571        Err(Error::ResponseError(ResponseContent { status, content, entity }))
572    }
573}
574
575/// Get a projects you have access to by its ID.
576pub async fn get_project(configuration: &configuration::Configuration, project_id: &str) -> Result<models::Project, Error<GetProjectError>> {
577    // add a prefix to parameters to efficiently prevent name collisions
578    let p_project_id = project_id;
579
580    let uri_str = format!("{}/projects/{project_id}", configuration.base_path, project_id=crate::apis::urlencode(p_project_id));
581    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
582
583    if let Some(ref user_agent) = configuration.user_agent {
584        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
585    }
586    if let Some(ref token) = configuration.bearer_access_token {
587        req_builder = req_builder.bearer_auth(token.to_owned());
588    };
589
590    let req = req_builder.build()?;
591    let resp = configuration.client.execute(req).await?;
592
593    let status = resp.status();
594    let content_type = resp
595        .headers()
596        .get("content-type")
597        .and_then(|v| v.to_str().ok())
598        .unwrap_or("application/octet-stream");
599    let content_type = super::ContentType::from(content_type);
600
601    if !status.is_client_error() && !status.is_server_error() {
602        let content = resp.text().await?;
603        match content_type {
604            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
605            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Project`"))),
606            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Project`")))),
607        }
608    } else {
609        let content = resp.text().await?;
610        let entity: Option<GetProjectError> = serde_json::from_str(&content).ok();
611        Err(Error::ResponseError(ResponseContent { status, content, entity }))
612    }
613}
614
615/// This endpoint requires the user to be a member of the project with the role `OWNER` or `DEVELOPER`.
616pub async fn get_project_members(configuration: &configuration::Configuration, project: &str) -> Result<Vec<models::ProjectMember>, Error<GetProjectMembersError>> {
617    // add a prefix to parameters to efficiently prevent name collisions
618    let p_project = project;
619
620    let uri_str = format!("{}/projects/{project}/members", configuration.base_path, project=crate::apis::urlencode(p_project));
621    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
622
623    if let Some(ref user_agent) = configuration.user_agent {
624        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
625    }
626    if let Some(ref token) = configuration.bearer_access_token {
627        req_builder = req_builder.bearer_auth(token.to_owned());
628    };
629
630    let req = req_builder.build()?;
631    let resp = configuration.client.execute(req).await?;
632
633    let status = resp.status();
634    let content_type = resp
635        .headers()
636        .get("content-type")
637        .and_then(|v| v.to_str().ok())
638        .unwrap_or("application/octet-stream");
639    let content_type = super::ContentType::from(content_type);
640
641    if !status.is_client_error() && !status.is_server_error() {
642        let content = resp.text().await?;
643        match content_type {
644            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
645            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::ProjectMember&gt;`"))),
646            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::ProjectMember&gt;`")))),
647        }
648    } else {
649        let content = resp.text().await?;
650        let entity: Option<GetProjectMembersError> = serde_json::from_str(&content).ok();
651        Err(Error::ResponseError(ResponseContent { status, content, entity }))
652    }
653}
654
655/// Lists all Enterprise SSO organizations in a project.
656pub async fn list_organizations(configuration: &configuration::Configuration, project_id: &str, page_size: Option<i64>, page_token: Option<&str>, domain: Option<&str>) -> Result<models::ListOrganizationsResponse, Error<ListOrganizationsError>> {
657    // add a prefix to parameters to efficiently prevent name collisions
658    let p_project_id = project_id;
659    let p_page_size = page_size;
660    let p_page_token = page_token;
661    let p_domain = domain;
662
663    let uri_str = format!("{}/projects/{project_id}/organizations", configuration.base_path, project_id=crate::apis::urlencode(p_project_id));
664    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
665
666    if let Some(ref param_value) = p_page_size {
667        req_builder = req_builder.query(&[("page_size", &param_value.to_string())]);
668    }
669    if let Some(ref param_value) = p_page_token {
670        req_builder = req_builder.query(&[("page_token", &param_value.to_string())]);
671    }
672    if let Some(ref param_value) = p_domain {
673        req_builder = req_builder.query(&[("domain", &param_value.to_string())]);
674    }
675    if let Some(ref user_agent) = configuration.user_agent {
676        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
677    }
678    if let Some(ref token) = configuration.bearer_access_token {
679        req_builder = req_builder.bearer_auth(token.to_owned());
680    };
681
682    let req = req_builder.build()?;
683    let resp = configuration.client.execute(req).await?;
684
685    let status = resp.status();
686    let content_type = resp
687        .headers()
688        .get("content-type")
689        .and_then(|v| v.to_str().ok())
690        .unwrap_or("application/octet-stream");
691    let content_type = super::ContentType::from(content_type);
692
693    if !status.is_client_error() && !status.is_server_error() {
694        let content = resp.text().await?;
695        match content_type {
696            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
697            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListOrganizationsResponse`"))),
698            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ListOrganizationsResponse`")))),
699        }
700    } else {
701        let content = resp.text().await?;
702        let entity: Option<ListOrganizationsError> = serde_json::from_str(&content).ok();
703        Err(Error::ResponseError(ResponseContent { status, content, entity }))
704    }
705}
706
707/// A list of all the project's API keys.
708pub async fn list_project_api_keys(configuration: &configuration::Configuration, project: &str) -> Result<Vec<models::ProjectApiKey>, Error<ListProjectApiKeysError>> {
709    // add a prefix to parameters to efficiently prevent name collisions
710    let p_project = project;
711
712    let uri_str = format!("{}/projects/{project}/tokens", configuration.base_path, project=crate::apis::urlencode(p_project));
713    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
714
715    if let Some(ref user_agent) = configuration.user_agent {
716        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
717    }
718    if let Some(ref token) = configuration.bearer_access_token {
719        req_builder = req_builder.bearer_auth(token.to_owned());
720    };
721
722    let req = req_builder.build()?;
723    let resp = configuration.client.execute(req).await?;
724
725    let status = resp.status();
726    let content_type = resp
727        .headers()
728        .get("content-type")
729        .and_then(|v| v.to_str().ok())
730        .unwrap_or("application/octet-stream");
731    let content_type = super::ContentType::from(content_type);
732
733    if !status.is_client_error() && !status.is_server_error() {
734        let content = resp.text().await?;
735        match content_type {
736            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
737            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::ProjectApiKey&gt;`"))),
738            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::ProjectApiKey&gt;`")))),
739        }
740    } else {
741        let content = resp.text().await?;
742        let entity: Option<ListProjectApiKeysError> = serde_json::from_str(&content).ok();
743        Err(Error::ResponseError(ResponseContent { status, content, entity }))
744    }
745}
746
747/// Lists all projects you have access to.
748pub async fn list_projects(configuration: &configuration::Configuration, ) -> Result<Vec<models::ProjectMetadata>, Error<ListProjectsError>> {
749
750    let uri_str = format!("{}/projects", configuration.base_path);
751    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
752
753    if let Some(ref user_agent) = configuration.user_agent {
754        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
755    }
756    if let Some(ref token) = configuration.bearer_access_token {
757        req_builder = req_builder.bearer_auth(token.to_owned());
758    };
759
760    let req = req_builder.build()?;
761    let resp = configuration.client.execute(req).await?;
762
763    let status = resp.status();
764    let content_type = resp
765        .headers()
766        .get("content-type")
767        .and_then(|v| v.to_str().ok())
768        .unwrap_or("application/octet-stream");
769    let content_type = super::ContentType::from(content_type);
770
771    if !status.is_client_error() && !status.is_server_error() {
772        let content = resp.text().await?;
773        match content_type {
774            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
775            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::ProjectMetadata&gt;`"))),
776            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::ProjectMetadata&gt;`")))),
777        }
778    } else {
779        let content = resp.text().await?;
780        let entity: Option<ListProjectsError> = serde_json::from_str(&content).ok();
781        Err(Error::ResponseError(ResponseContent { status, content, entity }))
782    }
783}
784
785/// Deprecated: Use the `patchProjectWithRevision` endpoint instead to specify the exact revision the patch was generated for.  This endpoints allows you to patch individual Ory Network project configuration keys for Ory's services (identity, permission, ...). The configuration format is fully compatible with the open source projects for the respective services (e.g. Ory Kratos for Identity, Ory Keto for Permissions).  This endpoint expects the `version` key to be set in the payload. If it is unset, it will try to import the config as if it is from the most recent version.  If you have an older version of a configuration, you should set the version key in the payload!  While this endpoint is able to process all configuration items related to features (e.g. password reset), it does not support operational configuration items (e.g. port, tracing, logging) otherwise available in the open source.  For configuration items that can not be translated to the Ory Network, this endpoint will return a list of warnings to help you understand which parts of your config could not be processed.
786pub async fn patch_project(configuration: &configuration::Configuration, project_id: &str, json_patch: Option<Vec<models::JsonPatch>>) -> Result<models::SuccessfulProjectUpdate, Error<PatchProjectError>> {
787    // add a prefix to parameters to efficiently prevent name collisions
788    let p_project_id = project_id;
789    let p_json_patch = json_patch;
790
791    let uri_str = format!("{}/projects/{project_id}", configuration.base_path, project_id=crate::apis::urlencode(p_project_id));
792    let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
793
794    if let Some(ref user_agent) = configuration.user_agent {
795        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
796    }
797    if let Some(ref token) = configuration.bearer_access_token {
798        req_builder = req_builder.bearer_auth(token.to_owned());
799    };
800    req_builder = req_builder.json(&p_json_patch);
801
802    let req = req_builder.build()?;
803    let resp = configuration.client.execute(req).await?;
804
805    let status = resp.status();
806    let content_type = resp
807        .headers()
808        .get("content-type")
809        .and_then(|v| v.to_str().ok())
810        .unwrap_or("application/octet-stream");
811    let content_type = super::ContentType::from(content_type);
812
813    if !status.is_client_error() && !status.is_server_error() {
814        let content = resp.text().await?;
815        match content_type {
816            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
817            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SuccessfulProjectUpdate`"))),
818            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SuccessfulProjectUpdate`")))),
819        }
820    } else {
821        let content = resp.text().await?;
822        let entity: Option<PatchProjectError> = serde_json::from_str(&content).ok();
823        Err(Error::ResponseError(ResponseContent { status, content, entity }))
824    }
825}
826
827/// This endpoints allows you to patch individual Ory Network Project configuration keys for Ory's services (identity, permission, ...). The configuration format is fully compatible with the open source projects for the respective services (e.g. Ory Kratos for Identity, Ory Keto for Permissions).  This endpoint expects the `version` key to be set in the payload. If it is unset, it will try to import the config as if it is from the most recent version.  If you have an older version of a configuration, you should set the version key in the payload!  While this endpoint is able to process all configuration items related to features (e.g. password reset), it does not support operational configuration items (e.g. port, tracing, logging) otherwise available in the open source.  For configuration items that can not be translated to the Ory Network, this endpoint will return a list of warnings to help you understand which parts of your config could not be processed.
828pub async fn patch_project_with_revision(configuration: &configuration::Configuration, project_id: &str, revision_id: &str, json_patch: Option<Vec<models::JsonPatch>>) -> Result<models::SuccessfulProjectUpdate, Error<PatchProjectWithRevisionError>> {
829    // add a prefix to parameters to efficiently prevent name collisions
830    let p_project_id = project_id;
831    let p_revision_id = revision_id;
832    let p_json_patch = json_patch;
833
834    let uri_str = format!("{}/projects/{project_id}/revision/{revision_id}", configuration.base_path, project_id=crate::apis::urlencode(p_project_id), revision_id=crate::apis::urlencode(p_revision_id));
835    let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
836
837    if let Some(ref user_agent) = configuration.user_agent {
838        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
839    }
840    if let Some(ref token) = configuration.bearer_access_token {
841        req_builder = req_builder.bearer_auth(token.to_owned());
842    };
843    req_builder = req_builder.json(&p_json_patch);
844
845    let req = req_builder.build()?;
846    let resp = configuration.client.execute(req).await?;
847
848    let status = resp.status();
849    let content_type = resp
850        .headers()
851        .get("content-type")
852        .and_then(|v| v.to_str().ok())
853        .unwrap_or("application/octet-stream");
854    let content_type = super::ContentType::from(content_type);
855
856    if !status.is_client_error() && !status.is_server_error() {
857        let content = resp.text().await?;
858        match content_type {
859            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
860            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SuccessfulProjectUpdate`"))),
861            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SuccessfulProjectUpdate`")))),
862        }
863    } else {
864        let content = resp.text().await?;
865        let entity: Option<PatchProjectWithRevisionError> = serde_json::from_str(&content).ok();
866        Err(Error::ResponseError(ResponseContent { status, content, entity }))
867    }
868}
869
870/// !! Use with extreme caution !!  Using this API endpoint you can purge (completely delete) a project and its data. This action can not be undone and will delete ALL your data.  Calling this endpoint will additionally delete custom domains and other related data.  If the project is linked to a subscription, the subscription needs to be unlinked first.
871pub async fn purge_project(configuration: &configuration::Configuration, project_id: &str) -> Result<(), Error<PurgeProjectError>> {
872    // add a prefix to parameters to efficiently prevent name collisions
873    let p_project_id = project_id;
874
875    let uri_str = format!("{}/projects/{project_id}", configuration.base_path, project_id=crate::apis::urlencode(p_project_id));
876    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
877
878    if let Some(ref user_agent) = configuration.user_agent {
879        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
880    }
881    if let Some(ref token) = configuration.bearer_access_token {
882        req_builder = req_builder.bearer_auth(token.to_owned());
883    };
884
885    let req = req_builder.build()?;
886    let resp = configuration.client.execute(req).await?;
887
888    let status = resp.status();
889
890    if !status.is_client_error() && !status.is_server_error() {
891        Ok(())
892    } else {
893        let content = resp.text().await?;
894        let entity: Option<PurgeProjectError> = serde_json::from_str(&content).ok();
895        Err(Error::ResponseError(ResponseContent { status, content, entity }))
896    }
897}
898
899/// This also sets their invite status to `REMOVED`. This endpoint requires the user to be a member of the project with the role `OWNER`.
900pub async fn remove_project_member(configuration: &configuration::Configuration, project: &str, member: &str) -> Result<(), Error<RemoveProjectMemberError>> {
901    // add a prefix to parameters to efficiently prevent name collisions
902    let p_project = project;
903    let p_member = member;
904
905    let uri_str = format!("{}/projects/{project}/members/{member}", configuration.base_path, project=crate::apis::urlencode(p_project), member=crate::apis::urlencode(p_member));
906    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
907
908    if let Some(ref user_agent) = configuration.user_agent {
909        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
910    }
911    if let Some(ref token) = configuration.bearer_access_token {
912        req_builder = req_builder.bearer_auth(token.to_owned());
913    };
914
915    let req = req_builder.build()?;
916    let resp = configuration.client.execute(req).await?;
917
918    let status = resp.status();
919
920    if !status.is_client_error() && !status.is_server_error() {
921        Ok(())
922    } else {
923        let content = resp.text().await?;
924        let entity: Option<RemoveProjectMemberError> = serde_json::from_str(&content).ok();
925        Err(Error::ResponseError(ResponseContent { status, content, entity }))
926    }
927}
928
929/// This endpoints allows you to update the Ory Network project configuration for individual services (identity, permission, ...). The configuration is fully compatible with the open source projects for the respective services (e.g. Ory Kratos for Identity, Ory Keto for Permissions).  This endpoint expects the `version` key to be set in the payload. If it is unset, it will try to import the config as if it is from the most recent version.  If you have an older version of a configuration, you should set the version key in the payload!  While this endpoint is able to process all configuration items related to features (e.g. password reset), it does not support operational configuration items (e.g. port, tracing, logging) otherwise available in the open source.  For configuration items that can not be translated to the Ory Network, this endpoint will return a list of warnings to help you understand which parts of your config could not be processed.  Be aware that updating any service's configuration will completely override your current configuration for that service!
930pub async fn set_project(configuration: &configuration::Configuration, project_id: &str, set_project: Option<models::SetProject>) -> Result<models::SuccessfulProjectUpdate, Error<SetProjectError>> {
931    // add a prefix to parameters to efficiently prevent name collisions
932    let p_project_id = project_id;
933    let p_set_project = set_project;
934
935    let uri_str = format!("{}/projects/{project_id}", configuration.base_path, project_id=crate::apis::urlencode(p_project_id));
936    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
937
938    if let Some(ref user_agent) = configuration.user_agent {
939        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
940    }
941    if let Some(ref token) = configuration.bearer_access_token {
942        req_builder = req_builder.bearer_auth(token.to_owned());
943    };
944    req_builder = req_builder.json(&p_set_project);
945
946    let req = req_builder.build()?;
947    let resp = configuration.client.execute(req).await?;
948
949    let status = resp.status();
950    let content_type = resp
951        .headers()
952        .get("content-type")
953        .and_then(|v| v.to_str().ok())
954        .unwrap_or("application/octet-stream");
955    let content_type = super::ContentType::from(content_type);
956
957    if !status.is_client_error() && !status.is_server_error() {
958        let content = resp.text().await?;
959        match content_type {
960            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
961            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SuccessfulProjectUpdate`"))),
962            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SuccessfulProjectUpdate`")))),
963        }
964    } else {
965        let content = resp.text().await?;
966        let entity: Option<SetProjectError> = serde_json::from_str(&content).ok();
967        Err(Error::ResponseError(ResponseContent { status, content, entity }))
968    }
969}
970
971/// Updates an Enterprise SSO Organization in a project by its ID.
972pub async fn update_organization(configuration: &configuration::Configuration, project_id: &str, organization_id: &str, organization_body: Option<models::OrganizationBody>) -> Result<models::Organization, Error<UpdateOrganizationError>> {
973    // add a prefix to parameters to efficiently prevent name collisions
974    let p_project_id = project_id;
975    let p_organization_id = organization_id;
976    let p_organization_body = organization_body;
977
978    let uri_str = format!("{}/projects/{project_id}/organizations/{organization_id}", configuration.base_path, project_id=crate::apis::urlencode(p_project_id), organization_id=crate::apis::urlencode(p_organization_id));
979    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
980
981    if let Some(ref user_agent) = configuration.user_agent {
982        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
983    }
984    if let Some(ref token) = configuration.bearer_access_token {
985        req_builder = req_builder.bearer_auth(token.to_owned());
986    };
987    req_builder = req_builder.json(&p_organization_body);
988
989    let req = req_builder.build()?;
990    let resp = configuration.client.execute(req).await?;
991
992    let status = resp.status();
993    let content_type = resp
994        .headers()
995        .get("content-type")
996        .and_then(|v| v.to_str().ok())
997        .unwrap_or("application/octet-stream");
998    let content_type = super::ContentType::from(content_type);
999
1000    if !status.is_client_error() && !status.is_server_error() {
1001        let content = resp.text().await?;
1002        match content_type {
1003            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1004            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Organization`"))),
1005            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Organization`")))),
1006        }
1007    } else {
1008        let content = resp.text().await?;
1009        let entity: Option<UpdateOrganizationError> = serde_json::from_str(&content).ok();
1010        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1011    }
1012}
1013
1014/// Update a onboarding portal link for an organization.
1015pub async fn update_organization_onboarding_portal_link(configuration: &configuration::Configuration, project_id: &str, organization_id: &str, onboarding_portal_link_id: &str, update_organization_onboarding_portal_link_body: Option<models::UpdateOrganizationOnboardingPortalLinkBody>) -> Result<models::OnboardingPortalLink, Error<UpdateOrganizationOnboardingPortalLinkError>> {
1016    // add a prefix to parameters to efficiently prevent name collisions
1017    let p_project_id = project_id;
1018    let p_organization_id = organization_id;
1019    let p_onboarding_portal_link_id = onboarding_portal_link_id;
1020    let p_update_organization_onboarding_portal_link_body = update_organization_onboarding_portal_link_body;
1021
1022    let uri_str = format!("{}/projects/{project_id}/organizations/{organization_id}/onboarding-portal-links/{onboarding_portal_link_id}", configuration.base_path, project_id=crate::apis::urlencode(p_project_id), organization_id=crate::apis::urlencode(p_organization_id), onboarding_portal_link_id=crate::apis::urlencode(p_onboarding_portal_link_id));
1023    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1024
1025    if let Some(ref user_agent) = configuration.user_agent {
1026        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1027    }
1028    if let Some(ref token) = configuration.bearer_access_token {
1029        req_builder = req_builder.bearer_auth(token.to_owned());
1030    };
1031    req_builder = req_builder.json(&p_update_organization_onboarding_portal_link_body);
1032
1033    let req = req_builder.build()?;
1034    let resp = configuration.client.execute(req).await?;
1035
1036    let status = resp.status();
1037    let content_type = resp
1038        .headers()
1039        .get("content-type")
1040        .and_then(|v| v.to_str().ok())
1041        .unwrap_or("application/octet-stream");
1042    let content_type = super::ContentType::from(content_type);
1043
1044    if !status.is_client_error() && !status.is_server_error() {
1045        let content = resp.text().await?;
1046        match content_type {
1047            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1048            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OnboardingPortalLink`"))),
1049            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OnboardingPortalLink`")))),
1050        }
1051    } else {
1052        let content = resp.text().await?;
1053        let entity: Option<UpdateOrganizationOnboardingPortalLinkError> = serde_json::from_str(&content).ok();
1054        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1055    }
1056}
1057