bitwarden_api_api/apis/
security_task_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 TasksGetError {
21 UnknownValue(serde_json::Value),
22}
23
24#[derive(Debug, Clone, Serialize, Deserialize)]
26#[serde(untagged)]
27pub enum TasksOrgIdBulkCreatePostError {
28 UnknownValue(serde_json::Value),
29}
30
31#[derive(Debug, Clone, Serialize, Deserialize)]
33#[serde(untagged)]
34pub enum TasksOrganizationGetError {
35 UnknownValue(serde_json::Value),
36}
37
38#[derive(Debug, Clone, Serialize, Deserialize)]
40#[serde(untagged)]
41pub enum TasksTaskIdCompletePatchError {
42 UnknownValue(serde_json::Value),
43}
44
45pub async fn tasks_get(
46 configuration: &configuration::Configuration,
47 status: Option<models::SecurityTaskStatus>,
48) -> Result<models::SecurityTasksResponseModelListResponseModel, Error<TasksGetError>> {
49 let p_status = status;
51
52 let uri_str = format!("{}/tasks", configuration.base_path);
53 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
54
55 if let Some(ref param_value) = p_status {
56 req_builder = req_builder.query(&[("status", ¶m_value.to_string())]);
57 }
58 if let Some(ref user_agent) = configuration.user_agent {
59 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
60 }
61 if let Some(ref token) = configuration.oauth_access_token {
62 req_builder = req_builder.bearer_auth(token.to_owned());
63 };
64
65 let req = req_builder.build()?;
66 let resp = configuration.client.execute(req).await?;
67
68 let status = resp.status();
69 let content_type = resp
70 .headers()
71 .get("content-type")
72 .and_then(|v| v.to_str().ok())
73 .unwrap_or("application/octet-stream");
74 let content_type = super::ContentType::from(content_type);
75
76 if !status.is_client_error() && !status.is_server_error() {
77 let content = resp.text().await?;
78 match content_type {
79 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
80 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SecurityTasksResponseModelListResponseModel`"))),
81 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::SecurityTasksResponseModelListResponseModel`")))),
82 }
83 } else {
84 let content = resp.text().await?;
85 let entity: Option<TasksGetError> = serde_json::from_str(&content).ok();
86 Err(Error::ResponseError(ResponseContent {
87 status,
88 content,
89 entity,
90 }))
91 }
92}
93
94pub async fn tasks_org_id_bulk_create_post(
95 configuration: &configuration::Configuration,
96 org_id: uuid::Uuid,
97 bulk_create_security_tasks_request_model: Option<models::BulkCreateSecurityTasksRequestModel>,
98) -> Result<models::SecurityTasksResponseModelListResponseModel, Error<TasksOrgIdBulkCreatePostError>>
99{
100 let p_org_id = org_id;
102 let p_bulk_create_security_tasks_request_model = bulk_create_security_tasks_request_model;
103
104 let uri_str = format!(
105 "{}/tasks/{orgId}/bulk-create",
106 configuration.base_path,
107 orgId = crate::apis::urlencode(p_org_id.to_string())
108 );
109 let mut req_builder = configuration
110 .client
111 .request(reqwest::Method::POST, &uri_str);
112
113 if let Some(ref user_agent) = configuration.user_agent {
114 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
115 }
116 if let Some(ref token) = configuration.oauth_access_token {
117 req_builder = req_builder.bearer_auth(token.to_owned());
118 };
119 req_builder = req_builder.json(&p_bulk_create_security_tasks_request_model);
120
121 let req = req_builder.build()?;
122 let resp = configuration.client.execute(req).await?;
123
124 let status = resp.status();
125 let content_type = resp
126 .headers()
127 .get("content-type")
128 .and_then(|v| v.to_str().ok())
129 .unwrap_or("application/octet-stream");
130 let content_type = super::ContentType::from(content_type);
131
132 if !status.is_client_error() && !status.is_server_error() {
133 let content = resp.text().await?;
134 match content_type {
135 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
136 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SecurityTasksResponseModelListResponseModel`"))),
137 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::SecurityTasksResponseModelListResponseModel`")))),
138 }
139 } else {
140 let content = resp.text().await?;
141 let entity: Option<TasksOrgIdBulkCreatePostError> = serde_json::from_str(&content).ok();
142 Err(Error::ResponseError(ResponseContent {
143 status,
144 content,
145 entity,
146 }))
147 }
148}
149
150pub async fn tasks_organization_get(
151 configuration: &configuration::Configuration,
152 organization_id: Option<uuid::Uuid>,
153 status: Option<models::SecurityTaskStatus>,
154) -> Result<models::SecurityTasksResponseModelListResponseModel, Error<TasksOrganizationGetError>> {
155 let p_organization_id = organization_id;
157 let p_status = status;
158
159 let uri_str = format!("{}/tasks/organization", configuration.base_path);
160 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
161
162 if let Some(ref param_value) = p_organization_id {
163 req_builder = req_builder.query(&[("organizationId", ¶m_value.to_string())]);
164 }
165 if let Some(ref param_value) = p_status {
166 req_builder = req_builder.query(&[("status", ¶m_value.to_string())]);
167 }
168 if let Some(ref user_agent) = configuration.user_agent {
169 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
170 }
171 if let Some(ref token) = configuration.oauth_access_token {
172 req_builder = req_builder.bearer_auth(token.to_owned());
173 };
174
175 let req = req_builder.build()?;
176 let resp = configuration.client.execute(req).await?;
177
178 let status = resp.status();
179 let content_type = resp
180 .headers()
181 .get("content-type")
182 .and_then(|v| v.to_str().ok())
183 .unwrap_or("application/octet-stream");
184 let content_type = super::ContentType::from(content_type);
185
186 if !status.is_client_error() && !status.is_server_error() {
187 let content = resp.text().await?;
188 match content_type {
189 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
190 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SecurityTasksResponseModelListResponseModel`"))),
191 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::SecurityTasksResponseModelListResponseModel`")))),
192 }
193 } else {
194 let content = resp.text().await?;
195 let entity: Option<TasksOrganizationGetError> = serde_json::from_str(&content).ok();
196 Err(Error::ResponseError(ResponseContent {
197 status,
198 content,
199 entity,
200 }))
201 }
202}
203
204pub async fn tasks_task_id_complete_patch(
205 configuration: &configuration::Configuration,
206 task_id: uuid::Uuid,
207) -> Result<(), Error<TasksTaskIdCompletePatchError>> {
208 let p_task_id = task_id;
210
211 let uri_str = format!(
212 "{}/tasks/{taskId}/complete",
213 configuration.base_path,
214 taskId = crate::apis::urlencode(p_task_id.to_string())
215 );
216 let mut req_builder = configuration
217 .client
218 .request(reqwest::Method::PATCH, &uri_str);
219
220 if let Some(ref user_agent) = configuration.user_agent {
221 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
222 }
223 if let Some(ref token) = configuration.oauth_access_token {
224 req_builder = req_builder.bearer_auth(token.to_owned());
225 };
226
227 let req = req_builder.build()?;
228 let resp = configuration.client.execute(req).await?;
229
230 let status = resp.status();
231
232 if !status.is_client_error() && !status.is_server_error() {
233 Ok(())
234 } else {
235 let content = resp.text().await?;
236 let entity: Option<TasksTaskIdCompletePatchError> = serde_json::from_str(&content).ok();
237 Err(Error::ResponseError(ResponseContent {
238 status,
239 content,
240 entity,
241 }))
242 }
243}