/*
* Ory APIs
*
* # 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) |
*
* The version of the OpenAPI document: v1.22.42
* Contact: support@ory.sh
* Generated by: https://openapi-generator.tech
*/
use reqwest;
use serde::{Deserialize, Serialize, de::Error as _};
use crate::{apis::ResponseContent, models};
use super::{Error, configuration, ContentType};
/// struct for typed errors of method [`create_organization`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateOrganizationError {
Status400(models::ErrorGeneric),
Status403(models::ErrorGeneric),
Status409(models::ErrorGeneric),
DefaultResponse(models::ErrorGeneric),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_organization_onboarding_portal_link`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateOrganizationOnboardingPortalLinkError {
DefaultResponse(models::ErrorGeneric),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_project`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateProjectError {
Status400(models::ErrorGeneric),
Status401(models::ErrorGeneric),
Status403(models::ErrorGeneric),
Status404(models::ErrorGeneric),
DefaultResponse(models::ErrorGeneric),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_project_api_key`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateProjectApiKeyError {
DefaultResponse(models::ErrorGeneric),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_organization`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteOrganizationError {
Status400(models::ErrorGeneric),
Status403(models::ErrorGeneric),
Status404(models::ErrorGeneric),
Status409(models::ErrorGeneric),
DefaultResponse(models::ErrorGeneric),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_organization_onboarding_portal_link`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteOrganizationOnboardingPortalLinkError {
Status400(models::ErrorGeneric),
Status403(models::ErrorGeneric),
DefaultResponse(models::ErrorGeneric),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_project_api_key`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteProjectApiKeyError {
DefaultResponse(models::ErrorGeneric),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_organization`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetOrganizationError {
Status400(models::ErrorGeneric),
Status403(models::ErrorGeneric),
Status404(models::ErrorGeneric),
DefaultResponse(models::ErrorGeneric),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_organization_onboarding_portal_links`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetOrganizationOnboardingPortalLinksError {
Status400(models::ErrorGeneric),
Status403(models::ErrorGeneric),
DefaultResponse(models::ErrorGeneric),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_project`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetProjectError {
Status401(models::ErrorGeneric),
Status403(models::ErrorGeneric),
Status404(models::ErrorGeneric),
DefaultResponse(models::ErrorGeneric),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_project_members`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetProjectMembersError {
Status401(models::GenericError),
Status406(models::GenericError),
DefaultResponse(models::GenericError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_organizations`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListOrganizationsError {
Status400(models::ErrorGeneric),
Status403(models::ErrorGeneric),
DefaultResponse(models::ErrorGeneric),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_project_api_keys`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListProjectApiKeysError {
DefaultResponse(models::ErrorGeneric),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_projects`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListProjectsError {
Status401(models::ErrorGeneric),
Status403(models::ErrorGeneric),
Status404(models::ErrorGeneric),
DefaultResponse(models::ErrorGeneric),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patch_project`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatchProjectError {
Status400(models::ErrorGeneric),
Status401(models::ErrorGeneric),
Status403(models::ErrorGeneric),
Status404(models::ErrorGeneric),
DefaultResponse(models::ErrorGeneric),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patch_project_with_revision`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatchProjectWithRevisionError {
Status400(models::ErrorGeneric),
Status401(models::ErrorGeneric),
Status403(models::ErrorGeneric),
Status404(models::ErrorGeneric),
Status409(models::ErrorGeneric),
DefaultResponse(models::ErrorGeneric),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`purge_project`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PurgeProjectError {
Status401(models::GenericError),
Status403(models::GenericError),
Status404(models::GenericError),
DefaultResponse(models::GenericError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`remove_project_member`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RemoveProjectMemberError {
Status401(models::GenericError),
Status406(models::GenericError),
DefaultResponse(models::GenericError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`set_project`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SetProjectError {
Status400(models::ErrorGeneric),
Status401(models::ErrorGeneric),
Status403(models::ErrorGeneric),
Status404(models::ErrorGeneric),
DefaultResponse(models::ErrorGeneric),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_organization`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateOrganizationError {
Status400(models::ErrorGeneric),
Status403(models::ErrorGeneric),
Status404(models::ErrorGeneric),
Status409(models::ErrorGeneric),
DefaultResponse(models::ErrorGeneric),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_organization_onboarding_portal_link`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateOrganizationOnboardingPortalLinkError {
DefaultResponse(models::ErrorGeneric),
UnknownValue(serde_json::Value),
}
/// Deprecated: use setProject or patchProjectWithRevision instead Creates an Enterprise SSO Organization in a project.
pub async fn create_organization(configuration: &configuration::Configuration, project_id: &str, organization_body: Option<models::OrganizationBody>) -> Result<models::Organization, Error<CreateOrganizationError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_project_id = project_id;
let p_body_organization_body = organization_body;
let uri_str = format!("{}/projects/{project_id}/organizations", configuration.base_path, project_id=crate::apis::urlencode(p_path_project_id));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_organization_body);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Organization`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateOrganizationError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Create a onboarding portal link for an organization.
pub 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>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_project_id = project_id;
let p_path_organization_id = organization_id;
let p_body_create_organization_onboarding_portal_link_body = create_organization_onboarding_portal_link_body;
let uri_str = format!("{}/projects/{project_id}/organizations/{organization_id}/onboarding-portal-links", configuration.base_path, project_id=crate::apis::urlencode(p_path_project_id), organization_id=crate::apis::urlencode(p_path_organization_id));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_create_organization_onboarding_portal_link_body);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OnboardingPortalLink`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateOrganizationOnboardingPortalLinkError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Creates a new project.
pub async fn create_project(configuration: &configuration::Configuration, create_project_body: Option<models::CreateProjectBody>) -> Result<models::Project, Error<CreateProjectError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_create_project_body = create_project_body;
let uri_str = format!("{}/projects", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_create_project_body);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Project`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateProjectError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Create an API key for a project.
pub async fn create_project_api_key(configuration: &configuration::Configuration, project: &str, create_project_api_key_request: Option<models::CreateProjectApiKeyRequest>) -> Result<models::ProjectApiKey, Error<CreateProjectApiKeyError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_project = project;
let p_body_create_project_api_key_request = create_project_api_key_request;
let uri_str = format!("{}/projects/{project}/tokens", configuration.base_path, project=crate::apis::urlencode(p_path_project));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_create_project_api_key_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProjectApiKey`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateProjectApiKeyError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Deprecated: use setProject or patchProjectWithRevision instead Irrecoverably deletes an Enterprise SSO Organization in a project by its ID.
pub async fn delete_organization(configuration: &configuration::Configuration, project_id: &str, organization_id: &str) -> Result<(), Error<DeleteOrganizationError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_project_id = project_id;
let p_path_organization_id = organization_id;
let uri_str = format!("{}/projects/{project_id}/organizations/{organization_id}", configuration.base_path, project_id=crate::apis::urlencode(p_path_project_id), organization_id=crate::apis::urlencode(p_path_organization_id));
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<DeleteOrganizationError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Deletes a onboarding portal link for an organization.
pub async fn delete_organization_onboarding_portal_link(configuration: &configuration::Configuration, project_id: &str, organization_id: &str, onboarding_portal_link_id: &str) -> Result<(), Error<DeleteOrganizationOnboardingPortalLinkError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_project_id = project_id;
let p_path_organization_id = organization_id;
let p_path_onboarding_portal_link_id = onboarding_portal_link_id;
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_path_project_id), organization_id=crate::apis::urlencode(p_path_organization_id), onboarding_portal_link_id=crate::apis::urlencode(p_path_onboarding_portal_link_id));
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<DeleteOrganizationOnboardingPortalLinkError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Deletes an API key and immediately removes it.
pub async fn delete_project_api_key(configuration: &configuration::Configuration, project: &str, token_id: &str) -> Result<(), Error<DeleteProjectApiKeyError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_project = project;
let p_path_token_id = token_id;
let uri_str = format!("{}/projects/{project}/tokens/{token_id}", configuration.base_path, project=crate::apis::urlencode(p_path_project), token_id=crate::apis::urlencode(p_path_token_id));
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<DeleteProjectApiKeyError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Deprecated: use getProject instead Retrieves an Enterprise SSO Organization for a project by its ID
pub async fn get_organization(configuration: &configuration::Configuration, project_id: &str, organization_id: &str) -> Result<models::GetOrganizationResponse, Error<GetOrganizationError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_project_id = project_id;
let p_path_organization_id = organization_id;
let uri_str = format!("{}/projects/{project_id}/organizations/{organization_id}", configuration.base_path, project_id=crate::apis::urlencode(p_path_project_id), organization_id=crate::apis::urlencode(p_path_organization_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetOrganizationResponse`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetOrganizationError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Retrieves the organization onboarding portal links.
pub async fn get_organization_onboarding_portal_links(configuration: &configuration::Configuration, project_id: &str, organization_id: &str) -> Result<models::OrganizationOnboardingPortalLinksResponse, Error<GetOrganizationOnboardingPortalLinksError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_project_id = project_id;
let p_path_organization_id = organization_id;
let uri_str = format!("{}/projects/{project_id}/organizations/{organization_id}/onboarding-portal-links", configuration.base_path, project_id=crate::apis::urlencode(p_path_project_id), organization_id=crate::apis::urlencode(p_path_organization_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationOnboardingPortalLinksResponse`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetOrganizationOnboardingPortalLinksError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get a project you have access to by its ID.
pub async fn get_project(configuration: &configuration::Configuration, project_id: &str) -> Result<models::Project, Error<GetProjectError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_project_id = project_id;
let uri_str = format!("{}/projects/{project_id}", configuration.base_path, project_id=crate::apis::urlencode(p_path_project_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Project`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetProjectError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// This endpoint requires the user to be a member of the project with the role `OWNER` or `DEVELOPER`.
pub async fn get_project_members(configuration: &configuration::Configuration, project: &str) -> Result<Vec<models::ProjectMember>, Error<GetProjectMembersError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_project = project;
let uri_str = format!("{}/projects/{project}/members", configuration.base_path, project=crate::apis::urlencode(p_path_project));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::ProjectMember>`"))),
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<models::ProjectMember>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetProjectMembersError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Deprecated: use getProject instead Lists all Enterprise SSO organizations in a project.
pub 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>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_project_id = project_id;
let p_query_page_size = page_size;
let p_query_page_token = page_token;
let p_query_domain = domain;
let uri_str = format!("{}/projects/{project_id}/organizations", configuration.base_path, project_id=crate::apis::urlencode(p_path_project_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_page_size {
req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_page_token {
req_builder = req_builder.query(&[("page_token", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_domain {
req_builder = req_builder.query(&[("domain", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListOrganizationsResponse`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListOrganizationsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// A list of all the project's API keys.
pub async fn list_project_api_keys(configuration: &configuration::Configuration, project: &str) -> Result<Vec<models::ProjectApiKey>, Error<ListProjectApiKeysError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_project = project;
let uri_str = format!("{}/projects/{project}/tokens", configuration.base_path, project=crate::apis::urlencode(p_path_project));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::ProjectApiKey>`"))),
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<models::ProjectApiKey>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListProjectApiKeysError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Lists all projects you have access to.
pub async fn list_projects(configuration: &configuration::Configuration, ) -> Result<Vec<models::ProjectMetadata>, Error<ListProjectsError>> {
let uri_str = format!("{}/projects", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::ProjectMetadata>`"))),
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<models::ProjectMetadata>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListProjectsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// 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.
pub async fn patch_project(configuration: &configuration::Configuration, project_id: &str, json_patch: Option<Vec<models::JsonPatch>>) -> Result<models::SuccessfulProjectUpdate, Error<PatchProjectError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_project_id = project_id;
let p_body_json_patch = json_patch;
let uri_str = format!("{}/projects/{project_id}", configuration.base_path, project_id=crate::apis::urlencode(p_path_project_id));
let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_json_patch);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SuccessfulProjectUpdate`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PatchProjectError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// 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.
pub 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>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_project_id = project_id;
let p_path_revision_id = revision_id;
let p_body_json_patch = json_patch;
let uri_str = format!("{}/projects/{project_id}/revision/{revision_id}", configuration.base_path, project_id=crate::apis::urlencode(p_path_project_id), revision_id=crate::apis::urlencode(p_path_revision_id));
let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_json_patch);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SuccessfulProjectUpdate`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PatchProjectWithRevisionError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// !! 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.
pub async fn purge_project(configuration: &configuration::Configuration, project_id: &str) -> Result<(), Error<PurgeProjectError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_project_id = project_id;
let uri_str = format!("{}/projects/{project_id}", configuration.base_path, project_id=crate::apis::urlencode(p_path_project_id));
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<PurgeProjectError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// This also sets their invite status to `REMOVED`. This endpoint requires the user to be a member of the project with the role `OWNER`.
pub async fn remove_project_member(configuration: &configuration::Configuration, project: &str, member: &str) -> Result<(), Error<RemoveProjectMemberError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_project = project;
let p_path_member = member;
let uri_str = format!("{}/projects/{project}/members/{member}", configuration.base_path, project=crate::apis::urlencode(p_path_project), member=crate::apis::urlencode(p_path_member));
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<RemoveProjectMemberError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// 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!
pub async fn set_project(configuration: &configuration::Configuration, project_id: &str, set_project: Option<models::SetProject>) -> Result<models::SuccessfulProjectUpdate, Error<SetProjectError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_project_id = project_id;
let p_body_set_project = set_project;
let uri_str = format!("{}/projects/{project_id}", configuration.base_path, project_id=crate::apis::urlencode(p_path_project_id));
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_set_project);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SuccessfulProjectUpdate`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SetProjectError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Deprecated: use setProject or patchProjectWithRevision instead Updates an Enterprise SSO Organization in a project by its ID.
pub async fn update_organization(configuration: &configuration::Configuration, project_id: &str, organization_id: &str, organization_body: Option<models::OrganizationBody>) -> Result<models::Organization, Error<UpdateOrganizationError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_project_id = project_id;
let p_path_organization_id = organization_id;
let p_body_organization_body = organization_body;
let uri_str = format!("{}/projects/{project_id}/organizations/{organization_id}", configuration.base_path, project_id=crate::apis::urlencode(p_path_project_id), organization_id=crate::apis::urlencode(p_path_organization_id));
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_organization_body);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Organization`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateOrganizationError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Update a onboarding portal link for an organization.
pub 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>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_project_id = project_id;
let p_path_organization_id = organization_id;
let p_path_onboarding_portal_link_id = onboarding_portal_link_id;
let p_body_update_organization_onboarding_portal_link_body = update_organization_onboarding_portal_link_body;
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_path_project_id), organization_id=crate::apis::urlencode(p_path_organization_id), onboarding_portal_link_id=crate::apis::urlencode(p_path_onboarding_portal_link_id));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_update_organization_onboarding_portal_link_body);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OnboardingPortalLink`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateOrganizationOnboardingPortalLinkError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}