authentik_rust/apis/
enterprise_api.rs

1/*
2 * authentik
3 *
4 * Making authentication simple.
5 *
6 * The version of the OpenAPI document: 2024.2.1
7 * Contact: hello@goauthentik.io
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17
18/// struct for typed errors of method [`enterprise_license_create`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum EnterpriseLicenseCreateError {
22    Status400(models::ValidationError),
23    Status403(models::GenericError),
24    UnknownValue(serde_json::Value),
25}
26
27/// struct for typed errors of method [`enterprise_license_destroy`]
28#[derive(Debug, Clone, Serialize, Deserialize)]
29#[serde(untagged)]
30pub enum EnterpriseLicenseDestroyError {
31    Status400(models::ValidationError),
32    Status403(models::GenericError),
33    UnknownValue(serde_json::Value),
34}
35
36/// struct for typed errors of method [`enterprise_license_forecast_retrieve`]
37#[derive(Debug, Clone, Serialize, Deserialize)]
38#[serde(untagged)]
39pub enum EnterpriseLicenseForecastRetrieveError {
40    Status400(models::ValidationError),
41    Status403(models::GenericError),
42    UnknownValue(serde_json::Value),
43}
44
45/// struct for typed errors of method [`enterprise_license_get_install_id_retrieve`]
46#[derive(Debug, Clone, Serialize, Deserialize)]
47#[serde(untagged)]
48pub enum EnterpriseLicenseGetInstallIdRetrieveError {
49    Status400(models::ValidationError),
50    Status403(models::GenericError),
51    UnknownValue(serde_json::Value),
52}
53
54/// struct for typed errors of method [`enterprise_license_list`]
55#[derive(Debug, Clone, Serialize, Deserialize)]
56#[serde(untagged)]
57pub enum EnterpriseLicenseListError {
58    Status400(models::ValidationError),
59    Status403(models::GenericError),
60    UnknownValue(serde_json::Value),
61}
62
63/// struct for typed errors of method [`enterprise_license_partial_update`]
64#[derive(Debug, Clone, Serialize, Deserialize)]
65#[serde(untagged)]
66pub enum EnterpriseLicensePartialUpdateError {
67    Status400(models::ValidationError),
68    Status403(models::GenericError),
69    UnknownValue(serde_json::Value),
70}
71
72/// struct for typed errors of method [`enterprise_license_retrieve`]
73#[derive(Debug, Clone, Serialize, Deserialize)]
74#[serde(untagged)]
75pub enum EnterpriseLicenseRetrieveError {
76    Status400(models::ValidationError),
77    Status403(models::GenericError),
78    UnknownValue(serde_json::Value),
79}
80
81/// struct for typed errors of method [`enterprise_license_summary_retrieve`]
82#[derive(Debug, Clone, Serialize, Deserialize)]
83#[serde(untagged)]
84pub enum EnterpriseLicenseSummaryRetrieveError {
85    Status400(models::ValidationError),
86    Status403(models::GenericError),
87    UnknownValue(serde_json::Value),
88}
89
90/// struct for typed errors of method [`enterprise_license_update`]
91#[derive(Debug, Clone, Serialize, Deserialize)]
92#[serde(untagged)]
93pub enum EnterpriseLicenseUpdateError {
94    Status400(models::ValidationError),
95    Status403(models::GenericError),
96    UnknownValue(serde_json::Value),
97}
98
99/// struct for typed errors of method [`enterprise_license_used_by_list`]
100#[derive(Debug, Clone, Serialize, Deserialize)]
101#[serde(untagged)]
102pub enum EnterpriseLicenseUsedByListError {
103    Status400(models::ValidationError),
104    Status403(models::GenericError),
105    UnknownValue(serde_json::Value),
106}
107
108
109/// License Viewset
110pub async fn enterprise_license_create(configuration: &configuration::Configuration, license_request: models::LicenseRequest) -> Result<models::License, Error<EnterpriseLicenseCreateError>> {
111    let local_var_configuration = configuration;
112
113    let local_var_client = &local_var_configuration.client;
114
115    let local_var_uri_str = format!("{}/enterprise/license/", local_var_configuration.base_path);
116    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
117
118    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
119        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
120    }
121    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
122        let local_var_key = local_var_apikey.key.clone();
123        let local_var_value = match local_var_apikey.prefix {
124            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
125            None => local_var_key,
126        };
127        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
128    };
129    local_var_req_builder = local_var_req_builder.json(&license_request);
130
131    let local_var_req = local_var_req_builder.build()?;
132    let local_var_resp = local_var_client.execute(local_var_req).await?;
133
134    let local_var_status = local_var_resp.status();
135    let local_var_content = local_var_resp.text().await?;
136
137    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
138        serde_json::from_str(&local_var_content).map_err(Error::from)
139    } else {
140        let local_var_entity: Option<EnterpriseLicenseCreateError> = serde_json::from_str(&local_var_content).ok();
141        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
142        Err(Error::ResponseError(local_var_error))
143    }
144}
145
146/// License Viewset
147pub async fn enterprise_license_destroy(configuration: &configuration::Configuration, license_uuid: &str) -> Result<(), Error<EnterpriseLicenseDestroyError>> {
148    let local_var_configuration = configuration;
149
150    let local_var_client = &local_var_configuration.client;
151
152    let local_var_uri_str = format!("{}/enterprise/license/{license_uuid}/", local_var_configuration.base_path, license_uuid=crate::apis::urlencode(license_uuid));
153    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
154
155    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
156        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
157    }
158    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
159        let local_var_key = local_var_apikey.key.clone();
160        let local_var_value = match local_var_apikey.prefix {
161            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
162            None => local_var_key,
163        };
164        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
165    };
166
167    let local_var_req = local_var_req_builder.build()?;
168    let local_var_resp = local_var_client.execute(local_var_req).await?;
169
170    let local_var_status = local_var_resp.status();
171    let local_var_content = local_var_resp.text().await?;
172
173    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
174        Ok(())
175    } else {
176        let local_var_entity: Option<EnterpriseLicenseDestroyError> = serde_json::from_str(&local_var_content).ok();
177        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
178        Err(Error::ResponseError(local_var_error))
179    }
180}
181
182/// Forecast how many users will be required in a year
183pub async fn enterprise_license_forecast_retrieve(configuration: &configuration::Configuration, ) -> Result<models::LicenseForecast, Error<EnterpriseLicenseForecastRetrieveError>> {
184    let local_var_configuration = configuration;
185
186    let local_var_client = &local_var_configuration.client;
187
188    let local_var_uri_str = format!("{}/enterprise/license/forecast/", local_var_configuration.base_path);
189    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
190
191    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
192        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
193    }
194    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
195        let local_var_key = local_var_apikey.key.clone();
196        let local_var_value = match local_var_apikey.prefix {
197            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
198            None => local_var_key,
199        };
200        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
201    };
202
203    let local_var_req = local_var_req_builder.build()?;
204    let local_var_resp = local_var_client.execute(local_var_req).await?;
205
206    let local_var_status = local_var_resp.status();
207    let local_var_content = local_var_resp.text().await?;
208
209    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
210        serde_json::from_str(&local_var_content).map_err(Error::from)
211    } else {
212        let local_var_entity: Option<EnterpriseLicenseForecastRetrieveError> = serde_json::from_str(&local_var_content).ok();
213        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
214        Err(Error::ResponseError(local_var_error))
215    }
216}
217
218/// Get install_id
219pub async fn enterprise_license_get_install_id_retrieve(configuration: &configuration::Configuration, ) -> Result<models::InstallId, Error<EnterpriseLicenseGetInstallIdRetrieveError>> {
220    let local_var_configuration = configuration;
221
222    let local_var_client = &local_var_configuration.client;
223
224    let local_var_uri_str = format!("{}/enterprise/license/get_install_id/", local_var_configuration.base_path);
225    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
226
227    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
228        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
229    }
230    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
231        let local_var_key = local_var_apikey.key.clone();
232        let local_var_value = match local_var_apikey.prefix {
233            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
234            None => local_var_key,
235        };
236        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
237    };
238
239    let local_var_req = local_var_req_builder.build()?;
240    let local_var_resp = local_var_client.execute(local_var_req).await?;
241
242    let local_var_status = local_var_resp.status();
243    let local_var_content = local_var_resp.text().await?;
244
245    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
246        serde_json::from_str(&local_var_content).map_err(Error::from)
247    } else {
248        let local_var_entity: Option<EnterpriseLicenseGetInstallIdRetrieveError> = serde_json::from_str(&local_var_content).ok();
249        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
250        Err(Error::ResponseError(local_var_error))
251    }
252}
253
254/// License Viewset
255pub async fn enterprise_license_list(configuration: &configuration::Configuration, name: Option<&str>, ordering: Option<&str>, page: Option<i32>, page_size: Option<i32>, search: Option<&str>) -> Result<models::PaginatedLicenseList, Error<EnterpriseLicenseListError>> {
256    let local_var_configuration = configuration;
257
258    let local_var_client = &local_var_configuration.client;
259
260    let local_var_uri_str = format!("{}/enterprise/license/", local_var_configuration.base_path);
261    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
262
263    if let Some(ref local_var_str) = name {
264        local_var_req_builder = local_var_req_builder.query(&[("name", &local_var_str.to_string())]);
265    }
266    if let Some(ref local_var_str) = ordering {
267        local_var_req_builder = local_var_req_builder.query(&[("ordering", &local_var_str.to_string())]);
268    }
269    if let Some(ref local_var_str) = page {
270        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
271    }
272    if let Some(ref local_var_str) = page_size {
273        local_var_req_builder = local_var_req_builder.query(&[("page_size", &local_var_str.to_string())]);
274    }
275    if let Some(ref local_var_str) = search {
276        local_var_req_builder = local_var_req_builder.query(&[("search", &local_var_str.to_string())]);
277    }
278    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
279        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
280    }
281    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
282        let local_var_key = local_var_apikey.key.clone();
283        let local_var_value = match local_var_apikey.prefix {
284            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
285            None => local_var_key,
286        };
287        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
288    };
289
290    let local_var_req = local_var_req_builder.build()?;
291    let local_var_resp = local_var_client.execute(local_var_req).await?;
292
293    let local_var_status = local_var_resp.status();
294    let local_var_content = local_var_resp.text().await?;
295
296    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
297        serde_json::from_str(&local_var_content).map_err(Error::from)
298    } else {
299        let local_var_entity: Option<EnterpriseLicenseListError> = serde_json::from_str(&local_var_content).ok();
300        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
301        Err(Error::ResponseError(local_var_error))
302    }
303}
304
305/// License Viewset
306pub async fn enterprise_license_partial_update(configuration: &configuration::Configuration, license_uuid: &str, patched_license_request: Option<models::PatchedLicenseRequest>) -> Result<models::License, Error<EnterpriseLicensePartialUpdateError>> {
307    let local_var_configuration = configuration;
308
309    let local_var_client = &local_var_configuration.client;
310
311    let local_var_uri_str = format!("{}/enterprise/license/{license_uuid}/", local_var_configuration.base_path, license_uuid=crate::apis::urlencode(license_uuid));
312    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
313
314    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
315        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
316    }
317    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
318        let local_var_key = local_var_apikey.key.clone();
319        let local_var_value = match local_var_apikey.prefix {
320            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
321            None => local_var_key,
322        };
323        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
324    };
325    local_var_req_builder = local_var_req_builder.json(&patched_license_request);
326
327    let local_var_req = local_var_req_builder.build()?;
328    let local_var_resp = local_var_client.execute(local_var_req).await?;
329
330    let local_var_status = local_var_resp.status();
331    let local_var_content = local_var_resp.text().await?;
332
333    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
334        serde_json::from_str(&local_var_content).map_err(Error::from)
335    } else {
336        let local_var_entity: Option<EnterpriseLicensePartialUpdateError> = serde_json::from_str(&local_var_content).ok();
337        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
338        Err(Error::ResponseError(local_var_error))
339    }
340}
341
342/// License Viewset
343pub async fn enterprise_license_retrieve(configuration: &configuration::Configuration, license_uuid: &str) -> Result<models::License, Error<EnterpriseLicenseRetrieveError>> {
344    let local_var_configuration = configuration;
345
346    let local_var_client = &local_var_configuration.client;
347
348    let local_var_uri_str = format!("{}/enterprise/license/{license_uuid}/", local_var_configuration.base_path, license_uuid=crate::apis::urlencode(license_uuid));
349    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
350
351    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
352        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
353    }
354    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
355        let local_var_key = local_var_apikey.key.clone();
356        let local_var_value = match local_var_apikey.prefix {
357            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
358            None => local_var_key,
359        };
360        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
361    };
362
363    let local_var_req = local_var_req_builder.build()?;
364    let local_var_resp = local_var_client.execute(local_var_req).await?;
365
366    let local_var_status = local_var_resp.status();
367    let local_var_content = local_var_resp.text().await?;
368
369    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
370        serde_json::from_str(&local_var_content).map_err(Error::from)
371    } else {
372        let local_var_entity: Option<EnterpriseLicenseRetrieveError> = serde_json::from_str(&local_var_content).ok();
373        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
374        Err(Error::ResponseError(local_var_error))
375    }
376}
377
378/// Get the total license status
379pub async fn enterprise_license_summary_retrieve(configuration: &configuration::Configuration, ) -> Result<models::LicenseSummary, Error<EnterpriseLicenseSummaryRetrieveError>> {
380    let local_var_configuration = configuration;
381
382    let local_var_client = &local_var_configuration.client;
383
384    let local_var_uri_str = format!("{}/enterprise/license/summary/", local_var_configuration.base_path);
385    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
386
387    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
388        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
389    }
390    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
391        let local_var_key = local_var_apikey.key.clone();
392        let local_var_value = match local_var_apikey.prefix {
393            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
394            None => local_var_key,
395        };
396        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
397    };
398
399    let local_var_req = local_var_req_builder.build()?;
400    let local_var_resp = local_var_client.execute(local_var_req).await?;
401
402    let local_var_status = local_var_resp.status();
403    let local_var_content = local_var_resp.text().await?;
404
405    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
406        serde_json::from_str(&local_var_content).map_err(Error::from)
407    } else {
408        let local_var_entity: Option<EnterpriseLicenseSummaryRetrieveError> = serde_json::from_str(&local_var_content).ok();
409        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
410        Err(Error::ResponseError(local_var_error))
411    }
412}
413
414/// License Viewset
415pub async fn enterprise_license_update(configuration: &configuration::Configuration, license_uuid: &str, license_request: models::LicenseRequest) -> Result<models::License, Error<EnterpriseLicenseUpdateError>> {
416    let local_var_configuration = configuration;
417
418    let local_var_client = &local_var_configuration.client;
419
420    let local_var_uri_str = format!("{}/enterprise/license/{license_uuid}/", local_var_configuration.base_path, license_uuid=crate::apis::urlencode(license_uuid));
421    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
422
423    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
424        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
425    }
426    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
427        let local_var_key = local_var_apikey.key.clone();
428        let local_var_value = match local_var_apikey.prefix {
429            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
430            None => local_var_key,
431        };
432        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
433    };
434    local_var_req_builder = local_var_req_builder.json(&license_request);
435
436    let local_var_req = local_var_req_builder.build()?;
437    let local_var_resp = local_var_client.execute(local_var_req).await?;
438
439    let local_var_status = local_var_resp.status();
440    let local_var_content = local_var_resp.text().await?;
441
442    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
443        serde_json::from_str(&local_var_content).map_err(Error::from)
444    } else {
445        let local_var_entity: Option<EnterpriseLicenseUpdateError> = serde_json::from_str(&local_var_content).ok();
446        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
447        Err(Error::ResponseError(local_var_error))
448    }
449}
450
451/// Get a list of all objects that use this object
452pub async fn enterprise_license_used_by_list(configuration: &configuration::Configuration, license_uuid: &str) -> Result<Vec<models::UsedBy>, Error<EnterpriseLicenseUsedByListError>> {
453    let local_var_configuration = configuration;
454
455    let local_var_client = &local_var_configuration.client;
456
457    let local_var_uri_str = format!("{}/enterprise/license/{license_uuid}/used_by/", local_var_configuration.base_path, license_uuid=crate::apis::urlencode(license_uuid));
458    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
459
460    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
461        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
462    }
463    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
464        let local_var_key = local_var_apikey.key.clone();
465        let local_var_value = match local_var_apikey.prefix {
466            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
467            None => local_var_key,
468        };
469        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
470    };
471
472    let local_var_req = local_var_req_builder.build()?;
473    let local_var_resp = local_var_client.execute(local_var_req).await?;
474
475    let local_var_status = local_var_resp.status();
476    let local_var_content = local_var_resp.text().await?;
477
478    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
479        serde_json::from_str(&local_var_content).map_err(Error::from)
480    } else {
481        let local_var_entity: Option<EnterpriseLicenseUsedByListError> = serde_json::from_str(&local_var_content).ok();
482        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
483        Err(Error::ResponseError(local_var_error))
484    }
485}
486