authentik_client/apis/
ssf_api.rs

1/*
2 * authentik
3 *
4 * Making authentication simple.
5 *
6 * The version of the OpenAPI document: 2025.8.4
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 [`ssf_streams_list`]
17#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum SsfStreamsListError {
20    Status400(models::ValidationError),
21    Status403(models::GenericError),
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`ssf_streams_retrieve`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum SsfStreamsRetrieveError {
29    Status400(models::ValidationError),
30    Status403(models::GenericError),
31    UnknownValue(serde_json::Value),
32}
33
34/// SSFStream Viewset
35pub async fn ssf_streams_list(
36    configuration: &configuration::Configuration,
37    delivery_method: Option<&str>,
38    endpoint_url: Option<&str>,
39    ordering: Option<&str>,
40    page: Option<i32>,
41    page_size: Option<i32>,
42    provider: Option<i32>,
43    search: Option<&str>,
44) -> Result<models::PaginatedSsfStreamList, Error<SsfStreamsListError>> {
45    // add a prefix to parameters to efficiently prevent name collisions
46    let p_query_delivery_method = delivery_method;
47    let p_query_endpoint_url = endpoint_url;
48    let p_query_ordering = ordering;
49    let p_query_page = page;
50    let p_query_page_size = page_size;
51    let p_query_provider = provider;
52    let p_query_search = search;
53
54    let uri_str = format!("{}/ssf/streams/", configuration.base_path);
55    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
56
57    if let Some(ref param_value) = p_query_delivery_method {
58        req_builder = req_builder.query(&[("delivery_method", &param_value.to_string())]);
59    }
60    if let Some(ref param_value) = p_query_endpoint_url {
61        req_builder = req_builder.query(&[("endpoint_url", &param_value.to_string())]);
62    }
63    if let Some(ref param_value) = p_query_ordering {
64        req_builder = req_builder.query(&[("ordering", &param_value.to_string())]);
65    }
66    if let Some(ref param_value) = p_query_page {
67        req_builder = req_builder.query(&[("page", &param_value.to_string())]);
68    }
69    if let Some(ref param_value) = p_query_page_size {
70        req_builder = req_builder.query(&[("page_size", &param_value.to_string())]);
71    }
72    if let Some(ref param_value) = p_query_provider {
73        req_builder = req_builder.query(&[("provider", &param_value.to_string())]);
74    }
75    if let Some(ref param_value) = p_query_search {
76        req_builder = req_builder.query(&[("search", &param_value.to_string())]);
77    }
78    if let Some(ref user_agent) = configuration.user_agent {
79        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
80    }
81    if let Some(ref token) = configuration.bearer_access_token {
82        req_builder = req_builder.bearer_auth(token.to_owned());
83    };
84
85    let req = req_builder.build()?;
86    let resp = configuration.client.execute(req).await?;
87
88    let status = resp.status();
89    let content_type = resp
90        .headers()
91        .get("content-type")
92        .and_then(|v| v.to_str().ok())
93        .unwrap_or("application/octet-stream");
94    let content_type = super::ContentType::from(content_type);
95
96    if !status.is_client_error() && !status.is_server_error() {
97        let content = resp.text().await?;
98        match content_type {
99            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
100            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedSsfStreamList`"))),
101            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::PaginatedSsfStreamList`")))),
102        }
103    } else {
104        let content = resp.text().await?;
105        let entity: Option<SsfStreamsListError> = serde_json::from_str(&content).ok();
106        Err(Error::ResponseError(ResponseContent {
107            status,
108            content,
109            entity,
110        }))
111    }
112}
113
114/// SSFStream Viewset
115pub async fn ssf_streams_retrieve(
116    configuration: &configuration::Configuration,
117    uuid: &str,
118) -> Result<models::SsfStream, Error<SsfStreamsRetrieveError>> {
119    // add a prefix to parameters to efficiently prevent name collisions
120    let p_path_uuid = uuid;
121
122    let uri_str = format!(
123        "{}/ssf/streams/{uuid}/",
124        configuration.base_path,
125        uuid = crate::apis::urlencode(p_path_uuid)
126    );
127    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
128
129    if let Some(ref user_agent) = configuration.user_agent {
130        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
131    }
132    if let Some(ref token) = configuration.bearer_access_token {
133        req_builder = req_builder.bearer_auth(token.to_owned());
134    };
135
136    let req = req_builder.build()?;
137    let resp = configuration.client.execute(req).await?;
138
139    let status = resp.status();
140    let content_type = resp
141        .headers()
142        .get("content-type")
143        .and_then(|v| v.to_str().ok())
144        .unwrap_or("application/octet-stream");
145    let content_type = super::ContentType::from(content_type);
146
147    if !status.is_client_error() && !status.is_server_error() {
148        let content = resp.text().await?;
149        match content_type {
150            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
151            ContentType::Text => {
152                return Err(Error::from(serde_json::Error::custom(
153                    "Received `text/plain` content type response that cannot be converted to `models::SsfStream`",
154                )))
155            }
156            ContentType::Unsupported(unknown_type) => {
157                return Err(Error::from(serde_json::Error::custom(format!(
158                    "Received `{unknown_type}` content type response that cannot be converted to `models::SsfStream`"
159                ))))
160            }
161        }
162    } else {
163        let content = resp.text().await?;
164        let entity: Option<SsfStreamsRetrieveError> = serde_json::from_str(&content).ok();
165        Err(Error::ResponseError(ResponseContent {
166            status,
167            content,
168            entity,
169        }))
170    }
171}