Skip to main content

authentik_client/apis/
lifecycle_api.rs

1/*
2 * authentik
3 *
4 * Making authentication simple.
5 *
6 * The version of the OpenAPI document: 2026.2.0
7 * Contact: hello@goauthentik.io
8 * Generated by: https://openapi-generator.tech
9 */
10
11use super::{configuration, ContentType, Error};
12use crate::{apis::ResponseContent, models};
13use reqwest;
14use serde::{de::Error as _, Deserialize, Serialize};
15
16/// struct for typed errors of method [`lifecycle_iterations_create`]
17#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum LifecycleIterationsCreateError {
20    Status400(models::ValidationError),
21    Status403(models::GenericError),
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`lifecycle_iterations_latest_retrieve`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum LifecycleIterationsLatestRetrieveError {
29    Status400(models::ValidationError),
30    Status403(models::GenericError),
31    UnknownValue(serde_json::Value),
32}
33
34/// struct for typed errors of method [`lifecycle_iterations_list_open`]
35#[derive(Debug, Clone, Serialize, Deserialize)]
36#[serde(untagged)]
37pub enum LifecycleIterationsListOpenError {
38    Status400(models::ValidationError),
39    Status403(models::GenericError),
40    UnknownValue(serde_json::Value),
41}
42
43/// struct for typed errors of method [`lifecycle_reviews_create`]
44#[derive(Debug, Clone, Serialize, Deserialize)]
45#[serde(untagged)]
46pub enum LifecycleReviewsCreateError {
47    Status400(models::ValidationError),
48    Status403(models::GenericError),
49    UnknownValue(serde_json::Value),
50}
51
52/// struct for typed errors of method [`lifecycle_rules_create`]
53#[derive(Debug, Clone, Serialize, Deserialize)]
54#[serde(untagged)]
55pub enum LifecycleRulesCreateError {
56    Status400(models::ValidationError),
57    Status403(models::GenericError),
58    UnknownValue(serde_json::Value),
59}
60
61/// struct for typed errors of method [`lifecycle_rules_destroy`]
62#[derive(Debug, Clone, Serialize, Deserialize)]
63#[serde(untagged)]
64pub enum LifecycleRulesDestroyError {
65    Status400(models::ValidationError),
66    Status403(models::GenericError),
67    UnknownValue(serde_json::Value),
68}
69
70/// struct for typed errors of method [`lifecycle_rules_list`]
71#[derive(Debug, Clone, Serialize, Deserialize)]
72#[serde(untagged)]
73pub enum LifecycleRulesListError {
74    Status400(models::ValidationError),
75    Status403(models::GenericError),
76    UnknownValue(serde_json::Value),
77}
78
79/// struct for typed errors of method [`lifecycle_rules_partial_update`]
80#[derive(Debug, Clone, Serialize, Deserialize)]
81#[serde(untagged)]
82pub enum LifecycleRulesPartialUpdateError {
83    Status400(models::ValidationError),
84    Status403(models::GenericError),
85    UnknownValue(serde_json::Value),
86}
87
88/// struct for typed errors of method [`lifecycle_rules_retrieve`]
89#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum LifecycleRulesRetrieveError {
92    Status400(models::ValidationError),
93    Status403(models::GenericError),
94    UnknownValue(serde_json::Value),
95}
96
97/// struct for typed errors of method [`lifecycle_rules_update`]
98#[derive(Debug, Clone, Serialize, Deserialize)]
99#[serde(untagged)]
100pub enum LifecycleRulesUpdateError {
101    Status400(models::ValidationError),
102    Status403(models::GenericError),
103    UnknownValue(serde_json::Value),
104}
105
106/// Mixin to validate that a valid enterprise license exists before allowing to save the object
107pub async fn lifecycle_iterations_create(
108    configuration: &configuration::Configuration,
109    lifecycle_iteration_request: models::LifecycleIterationRequest,
110) -> Result<models::LifecycleIteration, Error<LifecycleIterationsCreateError>> {
111    // add a prefix to parameters to efficiently prevent name collisions
112    let p_body_lifecycle_iteration_request = lifecycle_iteration_request;
113
114    let uri_str = format!("{}/lifecycle/iterations/", configuration.base_path);
115    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
116
117    if let Some(ref user_agent) = configuration.user_agent {
118        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
119    }
120    if let Some(ref token) = configuration.bearer_access_token {
121        req_builder = req_builder.bearer_auth(token.to_owned());
122    };
123    req_builder = req_builder.json(&p_body_lifecycle_iteration_request);
124
125    let req = req_builder.build()?;
126    let resp = configuration.client.execute(req).await?;
127
128    let status = resp.status();
129    let content_type = resp
130        .headers()
131        .get("content-type")
132        .and_then(|v| v.to_str().ok())
133        .unwrap_or("application/octet-stream");
134    let content_type = super::ContentType::from(content_type);
135
136    if !status.is_client_error() && !status.is_server_error() {
137        let content = resp.text().await?;
138        match content_type {
139            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
140            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LifecycleIteration`"))),
141            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::LifecycleIteration`")))),
142        }
143    } else {
144        let content = resp.text().await?;
145        let entity: Option<LifecycleIterationsCreateError> = serde_json::from_str(&content).ok();
146        Err(Error::ResponseError(ResponseContent {
147            status,
148            content,
149            entity,
150        }))
151    }
152}
153
154/// Mixin to validate that a valid enterprise license exists before allowing to save the object
155pub async fn lifecycle_iterations_latest_retrieve(
156    configuration: &configuration::Configuration,
157    content_type: &str,
158    object_id: &str,
159) -> Result<models::LifecycleIteration, Error<LifecycleIterationsLatestRetrieveError>> {
160    // add a prefix to parameters to efficiently prevent name collisions
161    let p_path_content_type = content_type;
162    let p_path_object_id = object_id;
163
164    let uri_str = format!(
165        "{}/lifecycle/iterations/latest/{content_type}/{object_id}/",
166        configuration.base_path,
167        content_type = crate::apis::urlencode(p_path_content_type),
168        object_id = crate::apis::urlencode(p_path_object_id)
169    );
170    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
171
172    if let Some(ref user_agent) = configuration.user_agent {
173        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
174    }
175    if let Some(ref token) = configuration.bearer_access_token {
176        req_builder = req_builder.bearer_auth(token.to_owned());
177    };
178
179    let req = req_builder.build()?;
180    let resp = configuration.client.execute(req).await?;
181
182    let status = resp.status();
183    let content_type = resp
184        .headers()
185        .get("content-type")
186        .and_then(|v| v.to_str().ok())
187        .unwrap_or("application/octet-stream");
188    let content_type = super::ContentType::from(content_type);
189
190    if !status.is_client_error() && !status.is_server_error() {
191        let content = resp.text().await?;
192        match content_type {
193            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
194            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LifecycleIteration`"))),
195            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::LifecycleIteration`")))),
196        }
197    } else {
198        let content = resp.text().await?;
199        let entity: Option<LifecycleIterationsLatestRetrieveError> = serde_json::from_str(&content).ok();
200        Err(Error::ResponseError(ResponseContent {
201            status,
202            content,
203            entity,
204        }))
205    }
206}
207
208/// Mixin to validate that a valid enterprise license exists before allowing to save the object
209pub async fn lifecycle_iterations_list_open(
210    configuration: &configuration::Configuration,
211    ordering: Option<&str>,
212    page: Option<i32>,
213    page_size: Option<i32>,
214    search: Option<&str>,
215    user_is_reviewer: Option<bool>,
216) -> Result<models::PaginatedLifecycleIterationList, Error<LifecycleIterationsListOpenError>> {
217    // add a prefix to parameters to efficiently prevent name collisions
218    let p_query_ordering = ordering;
219    let p_query_page = page;
220    let p_query_page_size = page_size;
221    let p_query_search = search;
222    let p_query_user_is_reviewer = user_is_reviewer;
223
224    let uri_str = format!("{}/lifecycle/iterations/open/", configuration.base_path);
225    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
226
227    if let Some(ref param_value) = p_query_ordering {
228        req_builder = req_builder.query(&[("ordering", &param_value.to_string())]);
229    }
230    if let Some(ref param_value) = p_query_page {
231        req_builder = req_builder.query(&[("page", &param_value.to_string())]);
232    }
233    if let Some(ref param_value) = p_query_page_size {
234        req_builder = req_builder.query(&[("page_size", &param_value.to_string())]);
235    }
236    if let Some(ref param_value) = p_query_search {
237        req_builder = req_builder.query(&[("search", &param_value.to_string())]);
238    }
239    if let Some(ref param_value) = p_query_user_is_reviewer {
240        req_builder = req_builder.query(&[("user_is_reviewer", &param_value.to_string())]);
241    }
242    if let Some(ref user_agent) = configuration.user_agent {
243        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
244    }
245    if let Some(ref token) = configuration.bearer_access_token {
246        req_builder = req_builder.bearer_auth(token.to_owned());
247    };
248
249    let req = req_builder.build()?;
250    let resp = configuration.client.execute(req).await?;
251
252    let status = resp.status();
253    let content_type = resp
254        .headers()
255        .get("content-type")
256        .and_then(|v| v.to_str().ok())
257        .unwrap_or("application/octet-stream");
258    let content_type = super::ContentType::from(content_type);
259
260    if !status.is_client_error() && !status.is_server_error() {
261        let content = resp.text().await?;
262        match content_type {
263            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
264            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedLifecycleIterationList`"))),
265            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::PaginatedLifecycleIterationList`")))),
266        }
267    } else {
268        let content = resp.text().await?;
269        let entity: Option<LifecycleIterationsListOpenError> = serde_json::from_str(&content).ok();
270        Err(Error::ResponseError(ResponseContent {
271            status,
272            content,
273            entity,
274        }))
275    }
276}
277
278/// Mixin to validate that a valid enterprise license exists before allowing to save the object
279pub async fn lifecycle_reviews_create(
280    configuration: &configuration::Configuration,
281    review_request: models::ReviewRequest,
282) -> Result<models::Review, Error<LifecycleReviewsCreateError>> {
283    // add a prefix to parameters to efficiently prevent name collisions
284    let p_body_review_request = review_request;
285
286    let uri_str = format!("{}/lifecycle/reviews/", configuration.base_path);
287    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
288
289    if let Some(ref user_agent) = configuration.user_agent {
290        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
291    }
292    if let Some(ref token) = configuration.bearer_access_token {
293        req_builder = req_builder.bearer_auth(token.to_owned());
294    };
295    req_builder = req_builder.json(&p_body_review_request);
296
297    let req = req_builder.build()?;
298    let resp = configuration.client.execute(req).await?;
299
300    let status = resp.status();
301    let content_type = resp
302        .headers()
303        .get("content-type")
304        .and_then(|v| v.to_str().ok())
305        .unwrap_or("application/octet-stream");
306    let content_type = super::ContentType::from(content_type);
307
308    if !status.is_client_error() && !status.is_server_error() {
309        let content = resp.text().await?;
310        match content_type {
311            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
312            ContentType::Text => {
313                return Err(Error::from(serde_json::Error::custom(
314                    "Received `text/plain` content type response that cannot be converted to `models::Review`",
315                )))
316            }
317            ContentType::Unsupported(unknown_type) => {
318                return Err(Error::from(serde_json::Error::custom(format!(
319                    "Received `{unknown_type}` content type response that cannot be converted to `models::Review`"
320                ))))
321            }
322        }
323    } else {
324        let content = resp.text().await?;
325        let entity: Option<LifecycleReviewsCreateError> = serde_json::from_str(&content).ok();
326        Err(Error::ResponseError(ResponseContent {
327            status,
328            content,
329            entity,
330        }))
331    }
332}
333
334pub async fn lifecycle_rules_create(
335    configuration: &configuration::Configuration,
336    lifecycle_rule_request: models::LifecycleRuleRequest,
337) -> Result<models::LifecycleRule, Error<LifecycleRulesCreateError>> {
338    // add a prefix to parameters to efficiently prevent name collisions
339    let p_body_lifecycle_rule_request = lifecycle_rule_request;
340
341    let uri_str = format!("{}/lifecycle/rules/", configuration.base_path);
342    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
343
344    if let Some(ref user_agent) = configuration.user_agent {
345        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
346    }
347    if let Some(ref token) = configuration.bearer_access_token {
348        req_builder = req_builder.bearer_auth(token.to_owned());
349    };
350    req_builder = req_builder.json(&p_body_lifecycle_rule_request);
351
352    let req = req_builder.build()?;
353    let resp = configuration.client.execute(req).await?;
354
355    let status = resp.status();
356    let content_type = resp
357        .headers()
358        .get("content-type")
359        .and_then(|v| v.to_str().ok())
360        .unwrap_or("application/octet-stream");
361    let content_type = super::ContentType::from(content_type);
362
363    if !status.is_client_error() && !status.is_server_error() {
364        let content = resp.text().await?;
365        match content_type {
366            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
367            ContentType::Text => {
368                return Err(Error::from(serde_json::Error::custom(
369                    "Received `text/plain` content type response that cannot be converted to `models::LifecycleRule`",
370                )))
371            }
372            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!(
373                "Received `{unknown_type}` content type response that cannot be converted to `models::LifecycleRule`"
374            )))),
375        }
376    } else {
377        let content = resp.text().await?;
378        let entity: Option<LifecycleRulesCreateError> = serde_json::from_str(&content).ok();
379        Err(Error::ResponseError(ResponseContent {
380            status,
381            content,
382            entity,
383        }))
384    }
385}
386
387pub async fn lifecycle_rules_destroy(
388    configuration: &configuration::Configuration,
389    id: &str,
390) -> Result<(), Error<LifecycleRulesDestroyError>> {
391    // add a prefix to parameters to efficiently prevent name collisions
392    let p_path_id = id;
393
394    let uri_str = format!(
395        "{}/lifecycle/rules/{id}/",
396        configuration.base_path,
397        id = crate::apis::urlencode(p_path_id)
398    );
399    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
400
401    if let Some(ref user_agent) = configuration.user_agent {
402        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
403    }
404    if let Some(ref token) = configuration.bearer_access_token {
405        req_builder = req_builder.bearer_auth(token.to_owned());
406    };
407
408    let req = req_builder.build()?;
409    let resp = configuration.client.execute(req).await?;
410
411    let status = resp.status();
412
413    if !status.is_client_error() && !status.is_server_error() {
414        Ok(())
415    } else {
416        let content = resp.text().await?;
417        let entity: Option<LifecycleRulesDestroyError> = serde_json::from_str(&content).ok();
418        Err(Error::ResponseError(ResponseContent {
419            status,
420            content,
421            entity,
422        }))
423    }
424}
425
426pub async fn lifecycle_rules_list(
427    configuration: &configuration::Configuration,
428    content_type__model: Option<&str>,
429    ordering: Option<&str>,
430    page: Option<i32>,
431    page_size: Option<i32>,
432    search: Option<&str>,
433) -> Result<models::PaginatedLifecycleRuleList, Error<LifecycleRulesListError>> {
434    // add a prefix to parameters to efficiently prevent name collisions
435    let p_query_content_type__model = content_type__model;
436    let p_query_ordering = ordering;
437    let p_query_page = page;
438    let p_query_page_size = page_size;
439    let p_query_search = search;
440
441    let uri_str = format!("{}/lifecycle/rules/", configuration.base_path);
442    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
443
444    if let Some(ref param_value) = p_query_content_type__model {
445        req_builder = req_builder.query(&[("content_type__model", &param_value.to_string())]);
446    }
447    if let Some(ref param_value) = p_query_ordering {
448        req_builder = req_builder.query(&[("ordering", &param_value.to_string())]);
449    }
450    if let Some(ref param_value) = p_query_page {
451        req_builder = req_builder.query(&[("page", &param_value.to_string())]);
452    }
453    if let Some(ref param_value) = p_query_page_size {
454        req_builder = req_builder.query(&[("page_size", &param_value.to_string())]);
455    }
456    if let Some(ref param_value) = p_query_search {
457        req_builder = req_builder.query(&[("search", &param_value.to_string())]);
458    }
459    if let Some(ref user_agent) = configuration.user_agent {
460        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
461    }
462    if let Some(ref token) = configuration.bearer_access_token {
463        req_builder = req_builder.bearer_auth(token.to_owned());
464    };
465
466    let req = req_builder.build()?;
467    let resp = configuration.client.execute(req).await?;
468
469    let status = resp.status();
470    let content_type = resp
471        .headers()
472        .get("content-type")
473        .and_then(|v| v.to_str().ok())
474        .unwrap_or("application/octet-stream");
475    let content_type = super::ContentType::from(content_type);
476
477    if !status.is_client_error() && !status.is_server_error() {
478        let content = resp.text().await?;
479        match content_type {
480            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
481            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedLifecycleRuleList`"))),
482            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::PaginatedLifecycleRuleList`")))),
483        }
484    } else {
485        let content = resp.text().await?;
486        let entity: Option<LifecycleRulesListError> = serde_json::from_str(&content).ok();
487        Err(Error::ResponseError(ResponseContent {
488            status,
489            content,
490            entity,
491        }))
492    }
493}
494
495pub async fn lifecycle_rules_partial_update(
496    configuration: &configuration::Configuration,
497    id: &str,
498    patched_lifecycle_rule_request: Option<models::PatchedLifecycleRuleRequest>,
499) -> Result<models::LifecycleRule, Error<LifecycleRulesPartialUpdateError>> {
500    // add a prefix to parameters to efficiently prevent name collisions
501    let p_path_id = id;
502    let p_body_patched_lifecycle_rule_request = patched_lifecycle_rule_request;
503
504    let uri_str = format!(
505        "{}/lifecycle/rules/{id}/",
506        configuration.base_path,
507        id = crate::apis::urlencode(p_path_id)
508    );
509    let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
510
511    if let Some(ref user_agent) = configuration.user_agent {
512        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
513    }
514    if let Some(ref token) = configuration.bearer_access_token {
515        req_builder = req_builder.bearer_auth(token.to_owned());
516    };
517    req_builder = req_builder.json(&p_body_patched_lifecycle_rule_request);
518
519    let req = req_builder.build()?;
520    let resp = configuration.client.execute(req).await?;
521
522    let status = resp.status();
523    let content_type = resp
524        .headers()
525        .get("content-type")
526        .and_then(|v| v.to_str().ok())
527        .unwrap_or("application/octet-stream");
528    let content_type = super::ContentType::from(content_type);
529
530    if !status.is_client_error() && !status.is_server_error() {
531        let content = resp.text().await?;
532        match content_type {
533            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
534            ContentType::Text => {
535                return Err(Error::from(serde_json::Error::custom(
536                    "Received `text/plain` content type response that cannot be converted to `models::LifecycleRule`",
537                )))
538            }
539            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!(
540                "Received `{unknown_type}` content type response that cannot be converted to `models::LifecycleRule`"
541            )))),
542        }
543    } else {
544        let content = resp.text().await?;
545        let entity: Option<LifecycleRulesPartialUpdateError> = serde_json::from_str(&content).ok();
546        Err(Error::ResponseError(ResponseContent {
547            status,
548            content,
549            entity,
550        }))
551    }
552}
553
554pub async fn lifecycle_rules_retrieve(
555    configuration: &configuration::Configuration,
556    id: &str,
557) -> Result<models::LifecycleRule, Error<LifecycleRulesRetrieveError>> {
558    // add a prefix to parameters to efficiently prevent name collisions
559    let p_path_id = id;
560
561    let uri_str = format!(
562        "{}/lifecycle/rules/{id}/",
563        configuration.base_path,
564        id = crate::apis::urlencode(p_path_id)
565    );
566    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
567
568    if let Some(ref user_agent) = configuration.user_agent {
569        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
570    }
571    if let Some(ref token) = configuration.bearer_access_token {
572        req_builder = req_builder.bearer_auth(token.to_owned());
573    };
574
575    let req = req_builder.build()?;
576    let resp = configuration.client.execute(req).await?;
577
578    let status = resp.status();
579    let content_type = resp
580        .headers()
581        .get("content-type")
582        .and_then(|v| v.to_str().ok())
583        .unwrap_or("application/octet-stream");
584    let content_type = super::ContentType::from(content_type);
585
586    if !status.is_client_error() && !status.is_server_error() {
587        let content = resp.text().await?;
588        match content_type {
589            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
590            ContentType::Text => {
591                return Err(Error::from(serde_json::Error::custom(
592                    "Received `text/plain` content type response that cannot be converted to `models::LifecycleRule`",
593                )))
594            }
595            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!(
596                "Received `{unknown_type}` content type response that cannot be converted to `models::LifecycleRule`"
597            )))),
598        }
599    } else {
600        let content = resp.text().await?;
601        let entity: Option<LifecycleRulesRetrieveError> = serde_json::from_str(&content).ok();
602        Err(Error::ResponseError(ResponseContent {
603            status,
604            content,
605            entity,
606        }))
607    }
608}
609
610pub async fn lifecycle_rules_update(
611    configuration: &configuration::Configuration,
612    id: &str,
613    lifecycle_rule_request: models::LifecycleRuleRequest,
614) -> Result<models::LifecycleRule, Error<LifecycleRulesUpdateError>> {
615    // add a prefix to parameters to efficiently prevent name collisions
616    let p_path_id = id;
617    let p_body_lifecycle_rule_request = lifecycle_rule_request;
618
619    let uri_str = format!(
620        "{}/lifecycle/rules/{id}/",
621        configuration.base_path,
622        id = crate::apis::urlencode(p_path_id)
623    );
624    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
625
626    if let Some(ref user_agent) = configuration.user_agent {
627        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
628    }
629    if let Some(ref token) = configuration.bearer_access_token {
630        req_builder = req_builder.bearer_auth(token.to_owned());
631    };
632    req_builder = req_builder.json(&p_body_lifecycle_rule_request);
633
634    let req = req_builder.build()?;
635    let resp = configuration.client.execute(req).await?;
636
637    let status = resp.status();
638    let content_type = resp
639        .headers()
640        .get("content-type")
641        .and_then(|v| v.to_str().ok())
642        .unwrap_or("application/octet-stream");
643    let content_type = super::ContentType::from(content_type);
644
645    if !status.is_client_error() && !status.is_server_error() {
646        let content = resp.text().await?;
647        match content_type {
648            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
649            ContentType::Text => {
650                return Err(Error::from(serde_json::Error::custom(
651                    "Received `text/plain` content type response that cannot be converted to `models::LifecycleRule`",
652                )))
653            }
654            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!(
655                "Received `{unknown_type}` content type response that cannot be converted to `models::LifecycleRule`"
656            )))),
657        }
658    } else {
659        let content = resp.text().await?;
660        let entity: Option<LifecycleRulesUpdateError> = serde_json::from_str(&content).ok();
661        Err(Error::ResponseError(ResponseContent {
662            status,
663            content,
664            entity,
665        }))
666    }
667}