bitwarden_api_api/apis/
counts_api.rs1use 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 OrganizationsOrganizationIdSmCountsGetError {
21 UnknownValue(serde_json::Value),
22}
23
24#[derive(Debug, Clone, Serialize, Deserialize)]
26#[serde(untagged)]
27pub enum ProjectsProjectIdSmCountsGetError {
28 UnknownValue(serde_json::Value),
29}
30
31#[derive(Debug, Clone, Serialize, Deserialize)]
33#[serde(untagged)]
34pub enum ServiceAccountsServiceAccountIdSmCountsGetError {
35 UnknownValue(serde_json::Value),
36}
37
38pub async fn organizations_organization_id_sm_counts_get(
39 configuration: &configuration::Configuration,
40 organization_id: uuid::Uuid,
41) -> Result<
42 models::OrganizationCountsResponseModel,
43 Error<OrganizationsOrganizationIdSmCountsGetError>,
44> {
45 let p_organization_id = organization_id;
47
48 let uri_str = format!(
49 "{}/organizations/{organizationId}/sm-counts",
50 configuration.base_path,
51 organizationId = crate::apis::urlencode(p_organization_id.to_string())
52 );
53 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
54
55 if let Some(ref user_agent) = configuration.user_agent {
56 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
57 }
58 if let Some(ref token) = configuration.oauth_access_token {
59 req_builder = req_builder.bearer_auth(token.to_owned());
60 };
61
62 let req = req_builder.build()?;
63 let resp = configuration.client.execute(req).await?;
64
65 let status = resp.status();
66 let content_type = resp
67 .headers()
68 .get("content-type")
69 .and_then(|v| v.to_str().ok())
70 .unwrap_or("application/octet-stream");
71 let content_type = super::ContentType::from(content_type);
72
73 if !status.is_client_error() && !status.is_server_error() {
74 let content = resp.text().await?;
75 match content_type {
76 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
77 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationCountsResponseModel`"))),
78 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::OrganizationCountsResponseModel`")))),
79 }
80 } else {
81 let content = resp.text().await?;
82 let entity: Option<OrganizationsOrganizationIdSmCountsGetError> =
83 serde_json::from_str(&content).ok();
84 Err(Error::ResponseError(ResponseContent {
85 status,
86 content,
87 entity,
88 }))
89 }
90}
91
92pub async fn projects_project_id_sm_counts_get(
93 configuration: &configuration::Configuration,
94 project_id: uuid::Uuid,
95) -> Result<models::ProjectCountsResponseModel, Error<ProjectsProjectIdSmCountsGetError>> {
96 let p_project_id = project_id;
98
99 let uri_str = format!(
100 "{}/projects/{projectId}/sm-counts",
101 configuration.base_path,
102 projectId = crate::apis::urlencode(p_project_id.to_string())
103 );
104 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
105
106 if let Some(ref user_agent) = configuration.user_agent {
107 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
108 }
109 if let Some(ref token) = configuration.oauth_access_token {
110 req_builder = req_builder.bearer_auth(token.to_owned());
111 };
112
113 let req = req_builder.build()?;
114 let resp = configuration.client.execute(req).await?;
115
116 let status = resp.status();
117 let content_type = resp
118 .headers()
119 .get("content-type")
120 .and_then(|v| v.to_str().ok())
121 .unwrap_or("application/octet-stream");
122 let content_type = super::ContentType::from(content_type);
123
124 if !status.is_client_error() && !status.is_server_error() {
125 let content = resp.text().await?;
126 match content_type {
127 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
128 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProjectCountsResponseModel`"))),
129 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::ProjectCountsResponseModel`")))),
130 }
131 } else {
132 let content = resp.text().await?;
133 let entity: Option<ProjectsProjectIdSmCountsGetError> = serde_json::from_str(&content).ok();
134 Err(Error::ResponseError(ResponseContent {
135 status,
136 content,
137 entity,
138 }))
139 }
140}
141
142pub async fn service_accounts_service_account_id_sm_counts_get(
143 configuration: &configuration::Configuration,
144 service_account_id: uuid::Uuid,
145) -> Result<
146 models::ServiceAccountCountsResponseModel,
147 Error<ServiceAccountsServiceAccountIdSmCountsGetError>,
148> {
149 let p_service_account_id = service_account_id;
151
152 let uri_str = format!(
153 "{}/service-accounts/{serviceAccountId}/sm-counts",
154 configuration.base_path,
155 serviceAccountId = crate::apis::urlencode(p_service_account_id.to_string())
156 );
157 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
158
159 if let Some(ref user_agent) = configuration.user_agent {
160 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
161 }
162 if let Some(ref token) = configuration.oauth_access_token {
163 req_builder = req_builder.bearer_auth(token.to_owned());
164 };
165
166 let req = req_builder.build()?;
167 let resp = configuration.client.execute(req).await?;
168
169 let status = resp.status();
170 let content_type = resp
171 .headers()
172 .get("content-type")
173 .and_then(|v| v.to_str().ok())
174 .unwrap_or("application/octet-stream");
175 let content_type = super::ContentType::from(content_type);
176
177 if !status.is_client_error() && !status.is_server_error() {
178 let content = resp.text().await?;
179 match content_type {
180 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
181 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ServiceAccountCountsResponseModel`"))),
182 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::ServiceAccountCountsResponseModel`")))),
183 }
184 } else {
185 let content = resp.text().await?;
186 let entity: Option<ServiceAccountsServiceAccountIdSmCountsGetError> =
187 serde_json::from_str(&content).ok();
188 Err(Error::ResponseError(ResponseContent {
189 status,
190 content,
191 entity,
192 }))
193 }
194}