clientapi_pbs/apis/
access_openid_api.rs1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum AccessOpenidCreateAuthUrlError {
22 Status400(models::PbsError),
23 Status401(models::PbsError),
24 Status403(models::PbsError),
25 Status404(models::PbsError),
26 Status500(models::PbsError),
27 Status501(models::PbsError),
28 Status503(models::PbsError),
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum AccessOpenidCreateLoginError {
36 Status400(models::PbsError),
37 Status401(models::PbsError),
38 Status403(models::PbsError),
39 Status404(models::PbsError),
40 Status500(models::PbsError),
41 Status501(models::PbsError),
42 Status503(models::PbsError),
43 UnknownValue(serde_json::Value),
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum AccessOpenidGetOpenidError {
50 Status400(models::PbsError),
51 Status401(models::PbsError),
52 Status403(models::PbsError),
53 Status404(models::PbsError),
54 Status500(models::PbsError),
55 Status501(models::PbsError),
56 Status503(models::PbsError),
57 UnknownValue(serde_json::Value),
58}
59
60
61pub async fn access_openid_create_auth_url(configuration: &configuration::Configuration, access_openid_create_auth_url_request: models::AccessOpenidCreateAuthUrlRequest) -> Result<models::AccessOpenidCreateAuthUrlResponse, Error<AccessOpenidCreateAuthUrlError>> {
63 let p_body_access_openid_create_auth_url_request = access_openid_create_auth_url_request;
65
66 let uri_str = format!("{}/access/openid/auth-url", configuration.base_path);
67 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
68
69 if let Some(ref user_agent) = configuration.user_agent {
70 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
71 }
72 req_builder = req_builder.json(&p_body_access_openid_create_auth_url_request);
73
74 let req = req_builder.build()?;
75 let resp = configuration.client.execute(req).await?;
76
77 let status = resp.status();
78 let content_type = resp
79 .headers()
80 .get("content-type")
81 .and_then(|v| v.to_str().ok())
82 .unwrap_or("application/octet-stream");
83 let content_type = super::ContentType::from(content_type);
84
85 if !status.is_client_error() && !status.is_server_error() {
86 let content = resp.text().await?;
87 match content_type {
88 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
89 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AccessOpenidCreateAuthUrlResponse`"))),
90 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::AccessOpenidCreateAuthUrlResponse`")))),
91 }
92 } else {
93 let content = resp.text().await?;
94 let entity: Option<AccessOpenidCreateAuthUrlError> = serde_json::from_str(&content).ok();
95 Err(Error::ResponseError(ResponseContent { status, content, entity }))
96 }
97}
98
99pub async fn access_openid_create_login(configuration: &configuration::Configuration, access_openid_create_login_request: models::AccessOpenidCreateLoginRequest) -> Result<models::AccessOpenidCreateLoginResponse, Error<AccessOpenidCreateLoginError>> {
101 let p_body_access_openid_create_login_request = access_openid_create_login_request;
103
104 let uri_str = format!("{}/access/openid/login", configuration.base_path);
105 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
106
107 if let Some(ref user_agent) = configuration.user_agent {
108 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
109 }
110 req_builder = req_builder.json(&p_body_access_openid_create_login_request);
111
112 let req = req_builder.build()?;
113 let resp = configuration.client.execute(req).await?;
114
115 let status = resp.status();
116 let content_type = resp
117 .headers()
118 .get("content-type")
119 .and_then(|v| v.to_str().ok())
120 .unwrap_or("application/octet-stream");
121 let content_type = super::ContentType::from(content_type);
122
123 if !status.is_client_error() && !status.is_server_error() {
124 let content = resp.text().await?;
125 match content_type {
126 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
127 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AccessOpenidCreateLoginResponse`"))),
128 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::AccessOpenidCreateLoginResponse`")))),
129 }
130 } else {
131 let content = resp.text().await?;
132 let entity: Option<AccessOpenidCreateLoginError> = serde_json::from_str(&content).ok();
133 Err(Error::ResponseError(ResponseContent { status, content, entity }))
134 }
135}
136
137pub async fn access_openid_get_openid(configuration: &configuration::Configuration, ) -> Result<models::AccessOpenidGetOpenidResponse, Error<AccessOpenidGetOpenidError>> {
139
140 let uri_str = format!("{}/access/openid", configuration.base_path);
141 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
142
143 if let Some(ref user_agent) = configuration.user_agent {
144 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
145 }
146 if let Some(ref apikey) = configuration.api_key {
147 let key = apikey.key.clone();
148 let value = match apikey.prefix {
149 Some(ref prefix) => format!("{} {}", prefix, key),
150 None => key,
151 };
152 req_builder = req_builder.header("Authorization", value);
153 };
154 if let Some(ref apikey) = configuration.api_key {
155 let key = apikey.key.clone();
156 let value = match apikey.prefix {
157 Some(ref prefix) => format!("{} {}", prefix, key),
158 None => key,
159 };
160 req_builder = req_builder.header("CSRFPreventionToken", value);
161 };
162
163 let req = req_builder.build()?;
164 let resp = configuration.client.execute(req).await?;
165
166 let status = resp.status();
167 let content_type = resp
168 .headers()
169 .get("content-type")
170 .and_then(|v| v.to_str().ok())
171 .unwrap_or("application/octet-stream");
172 let content_type = super::ContentType::from(content_type);
173
174 if !status.is_client_error() && !status.is_server_error() {
175 let content = resp.text().await?;
176 match content_type {
177 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
178 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AccessOpenidGetOpenidResponse`"))),
179 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::AccessOpenidGetOpenidResponse`")))),
180 }
181 } else {
182 let content = resp.text().await?;
183 let entity: Option<AccessOpenidGetOpenidError> = serde_json::from_str(&content).ok();
184 Err(Error::ResponseError(ResponseContent { status, content, entity }))
185 }
186}
187