jira_api_v2/apis/
audit_records_api.rs

1/*
2 * The Jira Cloud platform REST API
3 *
4 * Jira Cloud platform REST API documentation
5 *
6 * The version of the OpenAPI document: 1001.0.0-SNAPSHOT
7 * Contact: ecosystem@atlassian.com
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17
18/// struct for typed errors of method [`get_audit_records`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum GetAuditRecordsError {
22    Status401(),
23    Status403(),
24    UnknownValue(serde_json::Value),
25}
26
27
28/// Returns a list of audit records. The list can be filtered to include items:   *  containing a string in at least one field. For example, providing *up* will return all audit records where one or more fields contains words such as *update*.  *  created on or after a date and time.  *  created or or before a date and time.  *  created during a time period.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
29pub async fn get_audit_records(configuration: &configuration::Configuration, offset: Option<i32>, limit: Option<i32>, filter: Option<&str>, from: Option<String>, to: Option<String>) -> Result<models::AuditRecords, Error<GetAuditRecordsError>> {
30    // add a prefix to parameters to efficiently prevent name collisions
31    let p_offset = offset;
32    let p_limit = limit;
33    let p_filter = filter;
34    let p_from = from;
35    let p_to = to;
36
37    let uri_str = format!("{}/rest/api/2/auditing/record", configuration.base_path);
38    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
39
40    if let Some(ref param_value) = p_offset {
41        req_builder = req_builder.query(&[("offset", &param_value.to_string())]);
42    }
43    if let Some(ref param_value) = p_limit {
44        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
45    }
46    if let Some(ref param_value) = p_filter {
47        req_builder = req_builder.query(&[("filter", &param_value.to_string())]);
48    }
49    if let Some(ref param_value) = p_from {
50        req_builder = req_builder.query(&[("from", &param_value.to_string())]);
51    }
52    if let Some(ref param_value) = p_to {
53        req_builder = req_builder.query(&[("to", &param_value.to_string())]);
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    if let Some(ref auth_conf) = configuration.basic_auth {
62        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.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
70    if !status.is_client_error() && !status.is_server_error() {
71        let content = resp.text().await?;
72        serde_json::from_str(&content).map_err(Error::from)
73    } else {
74        let content = resp.text().await?;
75        let entity: Option<GetAuditRecordsError> = serde_json::from_str(&content).ok();
76        Err(Error::ResponseError(ResponseContent { status, content, entity }))
77    }
78}
79