1use reqwest;
13use serde::{Deserialize, Serialize};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum CopyDashboardError {
22 Status400(models::ErrorCollection),
23 Status401(models::ErrorCollection),
24 Status404(models::ErrorCollection),
25 UnknownValue(serde_json::Value),
26}
27
28#[derive(Debug, Clone, Serialize, Deserialize)]
30#[serde(untagged)]
31pub enum CreateDashboardError {
32 Status400(models::ErrorCollection),
33 Status401(models::ErrorCollection),
34 UnknownValue(serde_json::Value),
35}
36
37#[derive(Debug, Clone, Serialize, Deserialize)]
39#[serde(untagged)]
40pub enum DeleteDashboardError {
41 Status400(models::ErrorCollection),
42 Status401(models::ErrorCollection),
43 UnknownValue(serde_json::Value),
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum DeleteDashboardItemPropertyError {
50 Status400(),
51 Status401(),
52 Status403(),
53 Status404(),
54 UnknownValue(serde_json::Value),
55}
56
57#[derive(Debug, Clone, Serialize, Deserialize)]
59#[serde(untagged)]
60pub enum GetAllDashboardsError {
61 Status400(models::ErrorCollection),
62 Status401(models::ErrorCollection),
63 UnknownValue(serde_json::Value),
64}
65
66#[derive(Debug, Clone, Serialize, Deserialize)]
68#[serde(untagged)]
69pub enum GetDashboardError {
70 Status400(models::ErrorCollection),
71 Status401(models::ErrorCollection),
72 Status404(),
73 UnknownValue(serde_json::Value),
74}
75
76#[derive(Debug, Clone, Serialize, Deserialize)]
78#[serde(untagged)]
79pub enum GetDashboardItemPropertyError {
80 Status401(),
81 Status404(),
82 UnknownValue(serde_json::Value),
83}
84
85#[derive(Debug, Clone, Serialize, Deserialize)]
87#[serde(untagged)]
88pub enum GetDashboardItemPropertyKeysError {
89 Status401(),
90 Status404(),
91 UnknownValue(serde_json::Value),
92}
93
94#[derive(Debug, Clone, Serialize, Deserialize)]
96#[serde(untagged)]
97pub enum GetDashboardsPaginatedError {
98 Status400(models::ErrorCollection),
99 Status401(models::ErrorCollection),
100 UnknownValue(serde_json::Value),
101}
102
103#[derive(Debug, Clone, Serialize, Deserialize)]
105#[serde(untagged)]
106pub enum SetDashboardItemPropertyError {
107 Status400(),
108 Status401(),
109 Status403(),
110 Status404(),
111 UnknownValue(serde_json::Value),
112}
113
114#[derive(Debug, Clone, Serialize, Deserialize)]
116#[serde(untagged)]
117pub enum UpdateDashboardError {
118 Status400(models::ErrorCollection),
119 Status401(models::ErrorCollection),
120 Status404(models::ErrorCollection),
121 UnknownValue(serde_json::Value),
122}
123
124
125pub async fn copy_dashboard(configuration: &configuration::Configuration, id: &str, dashboard_details: models::DashboardDetails) -> Result<models::Dashboard, Error<CopyDashboardError>> {
127 let p_id = id;
129 let p_dashboard_details = dashboard_details;
130
131 let uri_str = format!("{}/rest/api/2/dashboard/{id}/copy", configuration.base_path, id=crate::apis::urlencode(p_id));
132 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
133
134 if let Some(ref user_agent) = configuration.user_agent {
135 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
136 }
137 if let Some(ref token) = configuration.oauth_access_token {
138 req_builder = req_builder.bearer_auth(token.to_owned());
139 };
140 if let Some(ref auth_conf) = configuration.basic_auth {
141 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
142 };
143 req_builder = req_builder.json(&p_dashboard_details);
144
145 let req = req_builder.build()?;
146 let resp = configuration.client.execute(req).await?;
147
148 let status = resp.status();
149
150 if !status.is_client_error() && !status.is_server_error() {
151 let content = resp.text().await?;
152 serde_json::from_str(&content).map_err(Error::from)
153 } else {
154 let content = resp.text().await?;
155 let entity: Option<CopyDashboardError> = serde_json::from_str(&content).ok();
156 Err(Error::ResponseError(ResponseContent { status, content, entity }))
157 }
158}
159
160pub async fn create_dashboard(configuration: &configuration::Configuration, dashboard_details: models::DashboardDetails) -> Result<models::Dashboard, Error<CreateDashboardError>> {
162 let p_dashboard_details = dashboard_details;
164
165 let uri_str = format!("{}/rest/api/2/dashboard", configuration.base_path);
166 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
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 if let Some(ref auth_conf) = configuration.basic_auth {
175 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
176 };
177 req_builder = req_builder.json(&p_dashboard_details);
178
179 let req = req_builder.build()?;
180 let resp = configuration.client.execute(req).await?;
181
182 let status = resp.status();
183
184 if !status.is_client_error() && !status.is_server_error() {
185 let content = resp.text().await?;
186 serde_json::from_str(&content).map_err(Error::from)
187 } else {
188 let content = resp.text().await?;
189 let entity: Option<CreateDashboardError> = serde_json::from_str(&content).ok();
190 Err(Error::ResponseError(ResponseContent { status, content, entity }))
191 }
192}
193
194pub async fn delete_dashboard(configuration: &configuration::Configuration, id: &str) -> Result<(), Error<DeleteDashboardError>> {
196 let p_id = id;
198
199 let uri_str = format!("{}/rest/api/2/dashboard/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
200 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
201
202 if let Some(ref user_agent) = configuration.user_agent {
203 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
204 }
205 if let Some(ref token) = configuration.oauth_access_token {
206 req_builder = req_builder.bearer_auth(token.to_owned());
207 };
208 if let Some(ref auth_conf) = configuration.basic_auth {
209 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
210 };
211
212 let req = req_builder.build()?;
213 let resp = configuration.client.execute(req).await?;
214
215 let status = resp.status();
216
217 if !status.is_client_error() && !status.is_server_error() {
218 Ok(())
219 } else {
220 let content = resp.text().await?;
221 let entity: Option<DeleteDashboardError> = serde_json::from_str(&content).ok();
222 Err(Error::ResponseError(ResponseContent { status, content, entity }))
223 }
224}
225
226pub async fn delete_dashboard_item_property(configuration: &configuration::Configuration, dashboard_id: &str, item_id: &str, property_key: &str) -> Result<(), Error<DeleteDashboardItemPropertyError>> {
228 let p_dashboard_id = dashboard_id;
230 let p_item_id = item_id;
231 let p_property_key = property_key;
232
233 let uri_str = format!("{}/rest/api/2/dashboard/{dashboardId}/items/{itemId}/properties/{propertyKey}", configuration.base_path, dashboardId=crate::apis::urlencode(p_dashboard_id), itemId=crate::apis::urlencode(p_item_id), propertyKey=crate::apis::urlencode(p_property_key));
234 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
235
236 if let Some(ref user_agent) = configuration.user_agent {
237 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
238 }
239 if let Some(ref token) = configuration.oauth_access_token {
240 req_builder = req_builder.bearer_auth(token.to_owned());
241 };
242 if let Some(ref auth_conf) = configuration.basic_auth {
243 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
244 };
245
246 let req = req_builder.build()?;
247 let resp = configuration.client.execute(req).await?;
248
249 let status = resp.status();
250
251 if !status.is_client_error() && !status.is_server_error() {
252 Ok(())
253 } else {
254 let content = resp.text().await?;
255 let entity: Option<DeleteDashboardItemPropertyError> = serde_json::from_str(&content).ok();
256 Err(Error::ResponseError(ResponseContent { status, content, entity }))
257 }
258}
259
260pub async fn get_all_dashboards(configuration: &configuration::Configuration, filter: Option<&str>, start_at: Option<i32>, max_results: Option<i32>) -> Result<models::PageOfDashboards, Error<GetAllDashboardsError>> {
262 let p_filter = filter;
264 let p_start_at = start_at;
265 let p_max_results = max_results;
266
267 let uri_str = format!("{}/rest/api/2/dashboard", configuration.base_path);
268 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
269
270 if let Some(ref param_value) = p_filter {
271 req_builder = req_builder.query(&[("filter", ¶m_value.to_string())]);
272 }
273 if let Some(ref param_value) = p_start_at {
274 req_builder = req_builder.query(&[("startAt", ¶m_value.to_string())]);
275 }
276 if let Some(ref param_value) = p_max_results {
277 req_builder = req_builder.query(&[("maxResults", ¶m_value.to_string())]);
278 }
279 if let Some(ref user_agent) = configuration.user_agent {
280 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
281 }
282 if let Some(ref token) = configuration.oauth_access_token {
283 req_builder = req_builder.bearer_auth(token.to_owned());
284 };
285 if let Some(ref auth_conf) = configuration.basic_auth {
286 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
287 };
288
289 let req = req_builder.build()?;
290 let resp = configuration.client.execute(req).await?;
291
292 let status = resp.status();
293
294 if !status.is_client_error() && !status.is_server_error() {
295 let content = resp.text().await?;
296 serde_json::from_str(&content).map_err(Error::from)
297 } else {
298 let content = resp.text().await?;
299 let entity: Option<GetAllDashboardsError> = serde_json::from_str(&content).ok();
300 Err(Error::ResponseError(ResponseContent { status, content, entity }))
301 }
302}
303
304pub async fn get_dashboard(configuration: &configuration::Configuration, id: &str) -> Result<models::Dashboard, Error<GetDashboardError>> {
306 let p_id = id;
308
309 let uri_str = format!("{}/rest/api/2/dashboard/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
310 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
311
312 if let Some(ref user_agent) = configuration.user_agent {
313 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
314 }
315 if let Some(ref token) = configuration.oauth_access_token {
316 req_builder = req_builder.bearer_auth(token.to_owned());
317 };
318 if let Some(ref auth_conf) = configuration.basic_auth {
319 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
320 };
321
322 let req = req_builder.build()?;
323 let resp = configuration.client.execute(req).await?;
324
325 let status = resp.status();
326
327 if !status.is_client_error() && !status.is_server_error() {
328 let content = resp.text().await?;
329 serde_json::from_str(&content).map_err(Error::from)
330 } else {
331 let content = resp.text().await?;
332 let entity: Option<GetDashboardError> = serde_json::from_str(&content).ok();
333 Err(Error::ResponseError(ResponseContent { status, content, entity }))
334 }
335}
336
337pub async fn get_dashboard_item_property(configuration: &configuration::Configuration, dashboard_id: &str, item_id: &str, property_key: &str) -> Result<models::EntityProperty, Error<GetDashboardItemPropertyError>> {
339 let p_dashboard_id = dashboard_id;
341 let p_item_id = item_id;
342 let p_property_key = property_key;
343
344 let uri_str = format!("{}/rest/api/2/dashboard/{dashboardId}/items/{itemId}/properties/{propertyKey}", configuration.base_path, dashboardId=crate::apis::urlencode(p_dashboard_id), itemId=crate::apis::urlencode(p_item_id), propertyKey=crate::apis::urlencode(p_property_key));
345 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
346
347 if let Some(ref user_agent) = configuration.user_agent {
348 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
349 }
350 if let Some(ref token) = configuration.oauth_access_token {
351 req_builder = req_builder.bearer_auth(token.to_owned());
352 };
353 if let Some(ref auth_conf) = configuration.basic_auth {
354 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
355 };
356
357 let req = req_builder.build()?;
358 let resp = configuration.client.execute(req).await?;
359
360 let status = resp.status();
361
362 if !status.is_client_error() && !status.is_server_error() {
363 let content = resp.text().await?;
364 serde_json::from_str(&content).map_err(Error::from)
365 } else {
366 let content = resp.text().await?;
367 let entity: Option<GetDashboardItemPropertyError> = serde_json::from_str(&content).ok();
368 Err(Error::ResponseError(ResponseContent { status, content, entity }))
369 }
370}
371
372pub async fn get_dashboard_item_property_keys(configuration: &configuration::Configuration, dashboard_id: &str, item_id: &str) -> Result<models::PropertyKeys, Error<GetDashboardItemPropertyKeysError>> {
374 let p_dashboard_id = dashboard_id;
376 let p_item_id = item_id;
377
378 let uri_str = format!("{}/rest/api/2/dashboard/{dashboardId}/items/{itemId}/properties", configuration.base_path, dashboardId=crate::apis::urlencode(p_dashboard_id), itemId=crate::apis::urlencode(p_item_id));
379 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
380
381 if let Some(ref user_agent) = configuration.user_agent {
382 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
383 }
384 if let Some(ref token) = configuration.oauth_access_token {
385 req_builder = req_builder.bearer_auth(token.to_owned());
386 };
387 if let Some(ref auth_conf) = configuration.basic_auth {
388 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
389 };
390
391 let req = req_builder.build()?;
392 let resp = configuration.client.execute(req).await?;
393
394 let status = resp.status();
395
396 if !status.is_client_error() && !status.is_server_error() {
397 let content = resp.text().await?;
398 serde_json::from_str(&content).map_err(Error::from)
399 } else {
400 let content = resp.text().await?;
401 let entity: Option<GetDashboardItemPropertyKeysError> = serde_json::from_str(&content).ok();
402 Err(Error::ResponseError(ResponseContent { status, content, entity }))
403 }
404}
405
406pub async fn get_dashboards_paginated(configuration: &configuration::Configuration, dashboard_name: Option<&str>, account_id: Option<&str>, owner: Option<&str>, groupname: Option<&str>, project_id: Option<i64>, order_by: Option<&str>, start_at: Option<i64>, max_results: Option<i32>, expand: Option<&str>) -> Result<models::PageBeanDashboard, Error<GetDashboardsPaginatedError>> {
408 let p_dashboard_name = dashboard_name;
410 let p_account_id = account_id;
411 let p_owner = owner;
412 let p_groupname = groupname;
413 let p_project_id = project_id;
414 let p_order_by = order_by;
415 let p_start_at = start_at;
416 let p_max_results = max_results;
417 let p_expand = expand;
418
419 let uri_str = format!("{}/rest/api/2/dashboard/search", configuration.base_path);
420 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
421
422 if let Some(ref param_value) = p_dashboard_name {
423 req_builder = req_builder.query(&[("dashboardName", ¶m_value.to_string())]);
424 }
425 if let Some(ref param_value) = p_account_id {
426 req_builder = req_builder.query(&[("accountId", ¶m_value.to_string())]);
427 }
428 if let Some(ref param_value) = p_owner {
429 req_builder = req_builder.query(&[("owner", ¶m_value.to_string())]);
430 }
431 if let Some(ref param_value) = p_groupname {
432 req_builder = req_builder.query(&[("groupname", ¶m_value.to_string())]);
433 }
434 if let Some(ref param_value) = p_project_id {
435 req_builder = req_builder.query(&[("projectId", ¶m_value.to_string())]);
436 }
437 if let Some(ref param_value) = p_order_by {
438 req_builder = req_builder.query(&[("orderBy", ¶m_value.to_string())]);
439 }
440 if let Some(ref param_value) = p_start_at {
441 req_builder = req_builder.query(&[("startAt", ¶m_value.to_string())]);
442 }
443 if let Some(ref param_value) = p_max_results {
444 req_builder = req_builder.query(&[("maxResults", ¶m_value.to_string())]);
445 }
446 if let Some(ref param_value) = p_expand {
447 req_builder = req_builder.query(&[("expand", ¶m_value.to_string())]);
448 }
449 if let Some(ref user_agent) = configuration.user_agent {
450 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
451 }
452 if let Some(ref token) = configuration.oauth_access_token {
453 req_builder = req_builder.bearer_auth(token.to_owned());
454 };
455 if let Some(ref auth_conf) = configuration.basic_auth {
456 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
457 };
458
459 let req = req_builder.build()?;
460 let resp = configuration.client.execute(req).await?;
461
462 let status = resp.status();
463
464 if !status.is_client_error() && !status.is_server_error() {
465 let content = resp.text().await?;
466 serde_json::from_str(&content).map_err(Error::from)
467 } else {
468 let content = resp.text().await?;
469 let entity: Option<GetDashboardsPaginatedError> = serde_json::from_str(&content).ok();
470 Err(Error::ResponseError(ResponseContent { status, content, entity }))
471 }
472}
473
474pub async fn set_dashboard_item_property(configuration: &configuration::Configuration, dashboard_id: &str, item_id: &str, property_key: &str, body: Option<serde_json::Value>) -> Result<serde_json::Value, Error<SetDashboardItemPropertyError>> {
476 let p_dashboard_id = dashboard_id;
478 let p_item_id = item_id;
479 let p_property_key = property_key;
480 let p_body = body;
481
482 let uri_str = format!("{}/rest/api/2/dashboard/{dashboardId}/items/{itemId}/properties/{propertyKey}", configuration.base_path, dashboardId=crate::apis::urlencode(p_dashboard_id), itemId=crate::apis::urlencode(p_item_id), propertyKey=crate::apis::urlencode(p_property_key));
483 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
484
485 if let Some(ref user_agent) = configuration.user_agent {
486 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
487 }
488 if let Some(ref token) = configuration.oauth_access_token {
489 req_builder = req_builder.bearer_auth(token.to_owned());
490 };
491 if let Some(ref auth_conf) = configuration.basic_auth {
492 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
493 };
494 req_builder = req_builder.json(&p_body);
495
496 let req = req_builder.build()?;
497 let resp = configuration.client.execute(req).await?;
498
499 let status = resp.status();
500
501 if !status.is_client_error() && !status.is_server_error() {
502 let content = resp.text().await?;
503 serde_json::from_str(&content).map_err(Error::from)
504 } else {
505 let content = resp.text().await?;
506 let entity: Option<SetDashboardItemPropertyError> = serde_json::from_str(&content).ok();
507 Err(Error::ResponseError(ResponseContent { status, content, entity }))
508 }
509}
510
511pub async fn update_dashboard(configuration: &configuration::Configuration, id: &str, dashboard_details: models::DashboardDetails) -> Result<models::Dashboard, Error<UpdateDashboardError>> {
513 let p_id = id;
515 let p_dashboard_details = dashboard_details;
516
517 let uri_str = format!("{}/rest/api/2/dashboard/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
518 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
519
520 if let Some(ref user_agent) = configuration.user_agent {
521 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
522 }
523 if let Some(ref token) = configuration.oauth_access_token {
524 req_builder = req_builder.bearer_auth(token.to_owned());
525 };
526 if let Some(ref auth_conf) = configuration.basic_auth {
527 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
528 };
529 req_builder = req_builder.json(&p_dashboard_details);
530
531 let req = req_builder.build()?;
532 let resp = configuration.client.execute(req).await?;
533
534 let status = resp.status();
535
536 if !status.is_client_error() && !status.is_server_error() {
537 let content = resp.text().await?;
538 serde_json::from_str(&content).map_err(Error::from)
539 } else {
540 let content = resp.text().await?;
541 let entity: Option<UpdateDashboardError> = serde_json::from_str(&content).ok();
542 Err(Error::ResponseError(ResponseContent { status, content, entity }))
543 }
544}
545