clerk_rs/apis/
beta_features_api.rs

1/*
2 * Clerk Backend API
3 *
4 * The Clerk REST Backend API, meant to be accessed by backend servers. Please see https://clerk.com/docs for more information.
5 *
6 * The version of the OpenAPI document: v1
7 * Contact: support@clerk.com
8 * Generated by: https://openapi-generator.tech
9 */
10
11use reqwest;
12
13use super::Error;
14use crate::{apis::ResponseContent, clerk::Clerk};
15
16/// struct for typed errors of method [`update_instance_auth_config`]
17#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum UpdateInstanceAuthConfigError {
20	Status402(crate::models::ClerkErrors),
21	Status422(crate::models::ClerkErrors),
22	UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`update_production_instance_domain`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum UpdateProductionInstanceDomainError {
29	Status400(crate::models::ClerkErrors),
30	Status422(crate::models::ClerkErrors),
31	UnknownValue(serde_json::Value),
32}
33
34pub struct BetaFeatures;
35
36impl BetaFeatures {
37	/// Updates the settings of an instance
38	pub async fn update_instance_auth_config(
39		clerk_client: &Clerk,
40		update_instance_auth_config_request: Option<crate::models::UpdateInstanceAuthConfigRequest>,
41	) -> Result<crate::models::UpdateInstanceAuthConfig200Response, Error<UpdateInstanceAuthConfigError>> {
42		let local_var_configuration = &clerk_client.config;
43
44		let local_var_client = &local_var_configuration.client;
45
46		let local_var_uri_str = format!("{}/beta_features/instance_settings", local_var_configuration.base_path);
47		let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
48
49		if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
50			local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
51		}
52
53		local_var_req_builder = local_var_req_builder.json(&update_instance_auth_config_request);
54
55		let local_var_req = local_var_req_builder.build()?;
56		let local_var_resp = local_var_client.execute(local_var_req).await?;
57
58		let local_var_status = local_var_resp.status();
59		let local_var_content = local_var_resp.text().await?;
60
61		if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
62			serde_json::from_str(&local_var_content).map_err(Error::from)
63		} else {
64			let local_var_entity: Option<UpdateInstanceAuthConfigError> = serde_json::from_str(&local_var_content).ok();
65			let local_var_error = ResponseContent {
66				status: local_var_status,
67				content: local_var_content,
68				entity: local_var_entity,
69			};
70			Err(Error::ResponseError(local_var_error))
71		}
72	}
73
74	/// Change the domain of a production instance.  Changing the domain requires updating the [DNS records](https://clerk.com/docs/deployments/overview#dns-records) accordingly, deploying new [SSL certificates](https://clerk.com/docs/deployments/overview#deploy), updating your Social Connection's redirect URLs and setting the new keys in your code.  WARNING: Changing your domain will invalidate all current user sessions (i.e. users will be logged out). Also, while your application is being deployed, a small downtime is expected to occur.
75	pub async fn update_production_instance_domain(
76		clerk_client: &Clerk,
77		update_production_instance_domain_request: Option<crate::models::UpdateProductionInstanceDomainRequest>,
78	) -> Result<(), Error<UpdateProductionInstanceDomainError>> {
79		let local_var_configuration = &clerk_client.config;
80
81		let local_var_client = &local_var_configuration.client;
82
83		let local_var_uri_str = format!("{}/beta_features/domain", local_var_configuration.base_path);
84		let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
85
86		if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
87			local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
88		}
89
90		local_var_req_builder = local_var_req_builder.json(&update_production_instance_domain_request);
91
92		let local_var_req = local_var_req_builder.build()?;
93		let local_var_resp = local_var_client.execute(local_var_req).await?;
94
95		let local_var_status = local_var_resp.status();
96		let local_var_content = local_var_resp.text().await?;
97
98		if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
99			Ok(())
100		} else {
101			let local_var_entity: Option<UpdateProductionInstanceDomainError> = serde_json::from_str(&local_var_content).ok();
102			let local_var_error = ResponseContent {
103				status: local_var_status,
104				content: local_var_content,
105				entity: local_var_entity,
106			};
107			Err(Error::ResponseError(local_var_error))
108		}
109	}
110}