1use reqwest;
12use serde::{de::Error as _, Deserialize, Serialize};
13
14use super::{configuration, ContentType, Error};
15use crate::{apis::ResponseContent, models};
16
17#[derive(Debug, Clone, Serialize, Deserialize)]
19#[serde(untagged)]
20pub enum OrganizationsOrgIdPoliciesGetError {
21 UnknownValue(serde_json::Value),
22}
23
24#[derive(Debug, Clone, Serialize, Deserialize)]
26#[serde(untagged)]
27pub enum OrganizationsOrgIdPoliciesInvitedUserGetError {
28 UnknownValue(serde_json::Value),
29}
30
31#[derive(Debug, Clone, Serialize, Deserialize)]
33#[serde(untagged)]
34pub enum OrganizationsOrgIdPoliciesMasterPasswordGetError {
35 UnknownValue(serde_json::Value),
36}
37
38#[derive(Debug, Clone, Serialize, Deserialize)]
40#[serde(untagged)]
41pub enum OrganizationsOrgIdPoliciesTokenGetError {
42 UnknownValue(serde_json::Value),
43}
44
45#[derive(Debug, Clone, Serialize, Deserialize)]
47#[serde(untagged)]
48pub enum OrganizationsOrgIdPoliciesTypeGetError {
49 UnknownValue(serde_json::Value),
50}
51
52#[derive(Debug, Clone, Serialize, Deserialize)]
54#[serde(untagged)]
55pub enum OrganizationsOrgIdPoliciesTypePutError {
56 UnknownValue(serde_json::Value),
57}
58
59pub async fn organizations_org_id_policies_get(
60 configuration: &configuration::Configuration,
61 org_id: &str,
62) -> Result<models::PolicyResponseModelListResponseModel, Error<OrganizationsOrgIdPoliciesGetError>>
63{
64 let p_org_id = org_id;
66
67 let uri_str = format!(
68 "{}/organizations/{orgId}/policies",
69 configuration.base_path,
70 orgId = crate::apis::urlencode(p_org_id)
71 );
72 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
73
74 if let Some(ref user_agent) = configuration.user_agent {
75 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
76 }
77 if let Some(ref token) = configuration.oauth_access_token {
78 req_builder = req_builder.bearer_auth(token.to_owned());
79 };
80
81 let req = req_builder.build()?;
82 let resp = configuration.client.execute(req).await?;
83
84 let status = resp.status();
85 let content_type = resp
86 .headers()
87 .get("content-type")
88 .and_then(|v| v.to_str().ok())
89 .unwrap_or("application/octet-stream");
90 let content_type = super::ContentType::from(content_type);
91
92 if !status.is_client_error() && !status.is_server_error() {
93 let content = resp.text().await?;
94 match content_type {
95 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
96 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PolicyResponseModelListResponseModel`"))),
97 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::PolicyResponseModelListResponseModel`")))),
98 }
99 } else {
100 let content = resp.text().await?;
101 let entity: Option<OrganizationsOrgIdPoliciesGetError> =
102 serde_json::from_str(&content).ok();
103 Err(Error::ResponseError(ResponseContent {
104 status,
105 content,
106 entity,
107 }))
108 }
109}
110
111pub async fn organizations_org_id_policies_invited_user_get(
112 configuration: &configuration::Configuration,
113 org_id: uuid::Uuid,
114 user_id: Option<uuid::Uuid>,
115) -> Result<
116 models::PolicyResponseModelListResponseModel,
117 Error<OrganizationsOrgIdPoliciesInvitedUserGetError>,
118> {
119 let p_org_id = org_id;
121 let p_user_id = user_id;
122
123 let uri_str = format!(
124 "{}/organizations/{orgId}/policies/invited-user",
125 configuration.base_path,
126 orgId = crate::apis::urlencode(p_org_id.to_string())
127 );
128 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
129
130 if let Some(ref param_value) = p_user_id {
131 req_builder = req_builder.query(&[("userId", ¶m_value.to_string())]);
132 }
133 if let Some(ref user_agent) = configuration.user_agent {
134 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
135 }
136 if let Some(ref token) = configuration.oauth_access_token {
137 req_builder = req_builder.bearer_auth(token.to_owned());
138 };
139
140 let req = req_builder.build()?;
141 let resp = configuration.client.execute(req).await?;
142
143 let status = resp.status();
144 let content_type = resp
145 .headers()
146 .get("content-type")
147 .and_then(|v| v.to_str().ok())
148 .unwrap_or("application/octet-stream");
149 let content_type = super::ContentType::from(content_type);
150
151 if !status.is_client_error() && !status.is_server_error() {
152 let content = resp.text().await?;
153 match content_type {
154 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
155 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PolicyResponseModelListResponseModel`"))),
156 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::PolicyResponseModelListResponseModel`")))),
157 }
158 } else {
159 let content = resp.text().await?;
160 let entity: Option<OrganizationsOrgIdPoliciesInvitedUserGetError> =
161 serde_json::from_str(&content).ok();
162 Err(Error::ResponseError(ResponseContent {
163 status,
164 content,
165 entity,
166 }))
167 }
168}
169
170pub async fn organizations_org_id_policies_master_password_get(
171 configuration: &configuration::Configuration,
172 org_id: uuid::Uuid,
173) -> Result<models::PolicyResponseModel, Error<OrganizationsOrgIdPoliciesMasterPasswordGetError>> {
174 let p_org_id = org_id;
176
177 let uri_str = format!(
178 "{}/organizations/{orgId}/policies/master-password",
179 configuration.base_path,
180 orgId = crate::apis::urlencode(p_org_id.to_string())
181 );
182 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
183
184 if let Some(ref user_agent) = configuration.user_agent {
185 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
186 }
187 if let Some(ref token) = configuration.oauth_access_token {
188 req_builder = req_builder.bearer_auth(token.to_owned());
189 };
190
191 let req = req_builder.build()?;
192 let resp = configuration.client.execute(req).await?;
193
194 let status = resp.status();
195 let content_type = resp
196 .headers()
197 .get("content-type")
198 .and_then(|v| v.to_str().ok())
199 .unwrap_or("application/octet-stream");
200 let content_type = super::ContentType::from(content_type);
201
202 if !status.is_client_error() && !status.is_server_error() {
203 let content = resp.text().await?;
204 match content_type {
205 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
206 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PolicyResponseModel`"))),
207 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::PolicyResponseModel`")))),
208 }
209 } else {
210 let content = resp.text().await?;
211 let entity: Option<OrganizationsOrgIdPoliciesMasterPasswordGetError> =
212 serde_json::from_str(&content).ok();
213 Err(Error::ResponseError(ResponseContent {
214 status,
215 content,
216 entity,
217 }))
218 }
219}
220
221pub async fn organizations_org_id_policies_token_get(
222 configuration: &configuration::Configuration,
223 org_id: uuid::Uuid,
224 email: Option<&str>,
225 token: Option<&str>,
226 organization_user_id: Option<uuid::Uuid>,
227) -> Result<
228 models::PolicyResponseModelListResponseModel,
229 Error<OrganizationsOrgIdPoliciesTokenGetError>,
230> {
231 let p_org_id = org_id;
233 let p_email = email;
234 let p_token = token;
235 let p_organization_user_id = organization_user_id;
236
237 let uri_str = format!(
238 "{}/organizations/{orgId}/policies/token",
239 configuration.base_path,
240 orgId = crate::apis::urlencode(p_org_id.to_string())
241 );
242 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
243
244 if let Some(ref param_value) = p_email {
245 req_builder = req_builder.query(&[("email", ¶m_value.to_string())]);
246 }
247 if let Some(ref param_value) = p_token {
248 req_builder = req_builder.query(&[("token", ¶m_value.to_string())]);
249 }
250 if let Some(ref param_value) = p_organization_user_id {
251 req_builder = req_builder.query(&[("organizationUserId", ¶m_value.to_string())]);
252 }
253 if let Some(ref user_agent) = configuration.user_agent {
254 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
255 }
256 if let Some(ref token) = configuration.oauth_access_token {
257 req_builder = req_builder.bearer_auth(token.to_owned());
258 };
259
260 let req = req_builder.build()?;
261 let resp = configuration.client.execute(req).await?;
262
263 let status = resp.status();
264 let content_type = resp
265 .headers()
266 .get("content-type")
267 .and_then(|v| v.to_str().ok())
268 .unwrap_or("application/octet-stream");
269 let content_type = super::ContentType::from(content_type);
270
271 if !status.is_client_error() && !status.is_server_error() {
272 let content = resp.text().await?;
273 match content_type {
274 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
275 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PolicyResponseModelListResponseModel`"))),
276 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::PolicyResponseModelListResponseModel`")))),
277 }
278 } else {
279 let content = resp.text().await?;
280 let entity: Option<OrganizationsOrgIdPoliciesTokenGetError> =
281 serde_json::from_str(&content).ok();
282 Err(Error::ResponseError(ResponseContent {
283 status,
284 content,
285 entity,
286 }))
287 }
288}
289
290pub async fn organizations_org_id_policies_type_get(
291 configuration: &configuration::Configuration,
292 org_id: uuid::Uuid,
293 r#type: i32,
294) -> Result<models::PolicyDetailResponseModel, Error<OrganizationsOrgIdPoliciesTypeGetError>> {
295 let p_org_id = org_id;
297 let p_type = r#type;
298
299 let uri_str = format!("{}/organizations/{orgId}/policies/{type}", configuration.base_path, orgId=crate::apis::urlencode(p_org_id.to_string()), type=p_type);
300 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
301
302 if let Some(ref user_agent) = configuration.user_agent {
303 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
304 }
305 if let Some(ref token) = configuration.oauth_access_token {
306 req_builder = req_builder.bearer_auth(token.to_owned());
307 };
308
309 let req = req_builder.build()?;
310 let resp = configuration.client.execute(req).await?;
311
312 let status = resp.status();
313 let content_type = resp
314 .headers()
315 .get("content-type")
316 .and_then(|v| v.to_str().ok())
317 .unwrap_or("application/octet-stream");
318 let content_type = super::ContentType::from(content_type);
319
320 if !status.is_client_error() && !status.is_server_error() {
321 let content = resp.text().await?;
322 match content_type {
323 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
324 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PolicyDetailResponseModel`"))),
325 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::PolicyDetailResponseModel`")))),
326 }
327 } else {
328 let content = resp.text().await?;
329 let entity: Option<OrganizationsOrgIdPoliciesTypeGetError> =
330 serde_json::from_str(&content).ok();
331 Err(Error::ResponseError(ResponseContent {
332 status,
333 content,
334 entity,
335 }))
336 }
337}
338
339pub async fn organizations_org_id_policies_type_put(
340 configuration: &configuration::Configuration,
341 org_id: uuid::Uuid,
342 r#type: models::PolicyType,
343 policy_request_model: Option<models::PolicyRequestModel>,
344) -> Result<models::PolicyResponseModel, Error<OrganizationsOrgIdPoliciesTypePutError>> {
345 let p_org_id = org_id;
347 let p_type = r#type;
348 let p_policy_request_model = policy_request_model;
349
350 let uri_str = format!("{}/organizations/{orgId}/policies/{type}", configuration.base_path, orgId=crate::apis::urlencode(p_org_id.to_string()), type=p_type.to_string());
351 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
352
353 if let Some(ref user_agent) = configuration.user_agent {
354 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
355 }
356 if let Some(ref token) = configuration.oauth_access_token {
357 req_builder = req_builder.bearer_auth(token.to_owned());
358 };
359 req_builder = req_builder.json(&p_policy_request_model);
360
361 let req = req_builder.build()?;
362 let resp = configuration.client.execute(req).await?;
363
364 let status = resp.status();
365 let content_type = resp
366 .headers()
367 .get("content-type")
368 .and_then(|v| v.to_str().ok())
369 .unwrap_or("application/octet-stream");
370 let content_type = super::ContentType::from(content_type);
371
372 if !status.is_client_error() && !status.is_server_error() {
373 let content = resp.text().await?;
374 match content_type {
375 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
376 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PolicyResponseModel`"))),
377 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::PolicyResponseModel`")))),
378 }
379 } else {
380 let content = resp.text().await?;
381 let entity: Option<OrganizationsOrgIdPoliciesTypePutError> =
382 serde_json::from_str(&content).ok();
383 Err(Error::ResponseError(ResponseContent {
384 status,
385 content,
386 entity,
387 }))
388 }
389}