bitwarden_api_api/apis/
secrets_manager_events_api.rs

1/*
2 * Bitwarden Internal API
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: latest
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use reqwest;
12use serde::{Deserialize, Serialize};
13
14use super::{configuration, Error};
15use crate::{apis::ResponseContent, models};
16
17/// struct for typed errors of method [`sm_events_service_accounts_service_account_id_get`]
18#[derive(Debug, Clone, Serialize, Deserialize)]
19#[serde(untagged)]
20pub enum SmEventsServiceAccountsServiceAccountIdGetError {
21    UnknownValue(serde_json::Value),
22}
23
24pub async fn sm_events_service_accounts_service_account_id_get(
25    configuration: &configuration::Configuration,
26    service_account_id: uuid::Uuid,
27    start: Option<String>,
28    end: Option<String>,
29    continuation_token: Option<&str>,
30) -> Result<
31    models::EventResponseModelListResponseModel,
32    Error<SmEventsServiceAccountsServiceAccountIdGetError>,
33> {
34    let local_var_configuration = configuration;
35
36    let local_var_client = &local_var_configuration.client;
37
38    let local_var_uri_str = format!(
39        "{}/sm/events/service-accounts/{serviceAccountId}",
40        local_var_configuration.base_path,
41        serviceAccountId = crate::apis::urlencode(service_account_id.to_string())
42    );
43    let mut local_var_req_builder =
44        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
45
46    if let Some(ref local_var_str) = start {
47        local_var_req_builder =
48            local_var_req_builder.query(&[("start", &local_var_str.to_string())]);
49    }
50    if let Some(ref local_var_str) = end {
51        local_var_req_builder = local_var_req_builder.query(&[("end", &local_var_str.to_string())]);
52    }
53    if let Some(ref local_var_str) = continuation_token {
54        local_var_req_builder =
55            local_var_req_builder.query(&[("continuationToken", &local_var_str.to_string())]);
56    }
57    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
58        local_var_req_builder =
59            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
60    }
61    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
62        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
63    };
64
65    let local_var_req = local_var_req_builder.build()?;
66    let local_var_resp = local_var_client.execute(local_var_req).await?;
67
68    let local_var_status = local_var_resp.status();
69    let local_var_content = local_var_resp.text().await?;
70
71    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
72        serde_json::from_str(&local_var_content).map_err(Error::from)
73    } else {
74        let local_var_entity: Option<SmEventsServiceAccountsServiceAccountIdGetError> =
75            serde_json::from_str(&local_var_content).ok();
76        let local_var_error = ResponseContent {
77            status: local_var_status,
78            content: local_var_content,
79            entity: local_var_entity,
80        };
81        Err(Error::ResponseError(local_var_error))
82    }
83}