/*
* The Jira Cloud platform REST API
*
* Jira Cloud platform REST API documentation
*
* The version of the OpenAPI document: 1001.0.0-SNAPSHOT
* Contact: ecosystem@atlassian.com
* Generated by: https://openapi-generator.tech
*/
use reqwest;
use crate::apis::ResponseContent;
use super::{Error, configuration};
/// struct for passing parameters to the method [`get_audit_records`]
#[derive(Clone, Debug, Default)]
pub struct GetAuditRecordsParams {
/// The number of records to skip before returning the first result.
pub offset: Option<i32>,
/// The maximum number of results to return.
pub limit: Option<i32>,
/// The strings to match with audit field content, space separated.
pub filter: Option<String>,
/// The date and time on or after which returned audit records must have been created. If `to` is provided `from` must be before `to` or no audit records are returned.
pub from: Option<String>,
/// The date and time on or before which returned audit results must have been created. If `from` is provided `to` must be after `from` or no audit records are returned.
pub to: Option<String>
}
/// struct for typed successes of method [`get_audit_records`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetAuditRecordsSuccess {
Status200(crate::models::AuditRecords),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_audit_records`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetAuditRecordsError {
Status401(),
Status403(),
UnknownValue(serde_json::Value),
}
/// Returns a list of audit records. The list can be filtered to include items: * where each item in `filter` has at least one match in any of these fields: * `summary` * `category` * `eventSource` * `objectItem.name` If the object is a user, account ID is available to filter. * `objectItem.parentName` * `objectItem.typeName` * `changedValues.changedFrom` * `changedValues.changedTo` * `remoteAddress` For example, if `filter` contains *man ed*, an audit record containing `summary\": \"User added to group\"` and `\"category\": \"group management\"` is returned. * created on or after a date and time. * created or or before a date and time. **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
pub async fn get_audit_records(configuration: &configuration::Configuration, params: GetAuditRecordsParams) -> Result<ResponseContent<GetAuditRecordsSuccess>, Error<GetAuditRecordsError>> {
let local_var_configuration = configuration;
// unbox the parameters
let offset = params.offset;
let limit = params.limit;
let filter = params.filter;
let from = params.from;
let to = params.to;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/rest/api/2/auditing/record", local_var_configuration.base_path);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_str) = offset {
local_var_req_builder = local_var_req_builder.query(&[("offset", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = limit {
local_var_req_builder = local_var_req_builder.query(&[("limit", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter {
local_var_req_builder = local_var_req_builder.query(&[("filter", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = from {
local_var_req_builder = local_var_req_builder.query(&[("from", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = to {
local_var_req_builder = local_var_req_builder.query(&[("to", &local_var_str.to_string())]);
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
let local_var_entity: Option<GetAuditRecordsSuccess> = serde_json::from_str(&local_var_content).ok();
let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Ok(local_var_result)
} else {
let local_var_entity: Option<GetAuditRecordsError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}