/*
* 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 serde::{Deserialize, Serialize};
use crate::{apis::ResponseContent, models};
use super::{Error, configuration};
/// struct for typed errors of method [`get_available_time_tracking_implementations`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetAvailableTimeTrackingImplementationsError {
Status401(),
Status403(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_selected_time_tracking_implementation`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetSelectedTimeTrackingImplementationError {
Status401(),
Status403(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_shared_time_tracking_configuration`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetSharedTimeTrackingConfigurationError {
Status401(),
Status403(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`select_time_tracking_implementation`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SelectTimeTrackingImplementationError {
Status400(),
Status401(),
Status403(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`set_shared_time_tracking_configuration`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SetSharedTimeTrackingConfigurationError {
Status400(),
Status401(),
Status403(),
UnknownValue(serde_json::Value),
}
/// Returns all time tracking providers. By default, Jira only has one time tracking provider: *JIRA provided time tracking*. However, you can install other time tracking providers via apps from the Atlassian Marketplace. For more information on time tracking providers, see the documentation for the [ Time Tracking Provider](https://developer.atlassian.com/cloud/jira/platform/modules/time-tracking-provider/) module. **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
pub async fn get_available_time_tracking_implementations(configuration: &configuration::Configuration, ) -> Result<Vec<models::TimeTrackingProvider>, Error<GetAvailableTimeTrackingImplementationsError>> {
let uri_str = format!("{}/rest/api/2/configuration/timetracking/list", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
serde_json::from_str(&content).map_err(Error::from)
} else {
let content = resp.text().await?;
let entity: Option<GetAvailableTimeTrackingImplementationsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Returns the time tracking provider that is currently selected. Note that if time tracking is disabled, then a successful but empty response is returned. **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
pub async fn get_selected_time_tracking_implementation(configuration: &configuration::Configuration, ) -> Result<models::TimeTrackingProvider, Error<GetSelectedTimeTrackingImplementationError>> {
let uri_str = format!("{}/rest/api/2/configuration/timetracking", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
serde_json::from_str(&content).map_err(Error::from)
} else {
let content = resp.text().await?;
let entity: Option<GetSelectedTimeTrackingImplementationError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Returns the time tracking settings. This includes settings such as the time format, default time unit, and others. For more information, see [Configuring time tracking](https://confluence.atlassian.com/x/qoXKM). **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
pub async fn get_shared_time_tracking_configuration(configuration: &configuration::Configuration, ) -> Result<models::TimeTrackingConfiguration, Error<GetSharedTimeTrackingConfigurationError>> {
let uri_str = format!("{}/rest/api/2/configuration/timetracking/options", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
serde_json::from_str(&content).map_err(Error::from)
} else {
let content = resp.text().await?;
let entity: Option<GetSharedTimeTrackingConfigurationError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Selects a time tracking provider. **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
pub async fn select_time_tracking_implementation(configuration: &configuration::Configuration, time_tracking_provider: models::TimeTrackingProvider) -> Result<serde_json::Value, Error<SelectTimeTrackingImplementationError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_time_tracking_provider = time_tracking_provider;
let uri_str = format!("{}/rest/api/2/configuration/timetracking", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
};
req_builder = req_builder.json(&p_time_tracking_provider);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
serde_json::from_str(&content).map_err(Error::from)
} else {
let content = resp.text().await?;
let entity: Option<SelectTimeTrackingImplementationError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Sets the time tracking settings. **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
pub async fn set_shared_time_tracking_configuration(configuration: &configuration::Configuration, time_tracking_configuration: models::TimeTrackingConfiguration) -> Result<models::TimeTrackingConfiguration, Error<SetSharedTimeTrackingConfigurationError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_time_tracking_configuration = time_tracking_configuration;
let uri_str = format!("{}/rest/api/2/configuration/timetracking/options", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
};
req_builder = req_builder.json(&p_time_tracking_configuration);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
serde_json::from_str(&content).map_err(Error::from)
} else {
let content = resp.text().await?;
let entity: Option<SetSharedTimeTrackingConfigurationError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}