/*
* 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 super::{configuration, Error};
use crate::gen::apis::ResponseContent;
use crate::gen::models;
/// struct for passing parameters to the method `delete_worklog_property`
#[derive(Clone, Debug)]
pub struct DeleteWorklogPropertyParams {
/// The ID or key of the issue.
pub issue_id_or_key: String,
/// The ID of the worklog.
pub worklog_id: String,
/// The key of the property.
pub property_key: String,
}
/// struct for passing parameters to the method `get_worklog_property`
#[derive(Clone, Debug)]
pub struct GetWorklogPropertyParams {
/// The ID or key of the issue.
pub issue_id_or_key: String,
/// The ID of the worklog.
pub worklog_id: String,
/// The key of the property.
pub property_key: String,
}
/// struct for passing parameters to the method `get_worklog_property_keys`
#[derive(Clone, Debug)]
pub struct GetWorklogPropertyKeysParams {
/// The ID or key of the issue.
pub issue_id_or_key: String,
/// The ID of the worklog.
pub worklog_id: String,
}
/// struct for passing parameters to the method `set_worklog_property`
#[derive(Clone, Debug)]
pub struct SetWorklogPropertyParams {
/// The ID or key of the issue.
pub issue_id_or_key: String,
/// The ID of the worklog.
pub worklog_id: String,
/// The key of the issue property. The maximum length is 255 characters.
pub property_key: String,
pub body: Option<serde_json::Value>,
}
/// struct for typed errors of method `delete_worklog_property`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteWorklogPropertyError {
Status400(),
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `get_worklog_property`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetWorklogPropertyError {
Status400(),
Status401(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `get_worklog_property_keys`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetWorklogPropertyKeysError {
Status400(),
Status401(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `set_worklog_property`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SetWorklogPropertyError {
Status400(),
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
/// Deletes a worklog property. This operation can be accessed anonymously. **[Permissions](#permissions) required:** * *Browse projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project that the issue is in. * If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, issue-level security permission to view the issue. * If the worklog has visibility restrictions, belongs to the group or has the role visibility is restricted to.
pub async fn delete_worklog_property(
configuration: &configuration::Configuration,
params: DeleteWorklogPropertyParams,
) -> Result<(), Error<DeleteWorklogPropertyError>> {
// unbox the parameters
let issue_id_or_key = params.issue_id_or_key;
let worklog_id = params.worklog_id;
let property_key = params.property_key;
let local_var_client = &configuration.client;
let local_var_uri_str = format!(
"{}/rest/api/3/issue/{issueIdOrKey}/worklog/{worklogId}/properties/{propertyKey}",
configuration.base_path,
issueIdOrKey = crate::gen::apis::urlencode(issue_id_or_key),
worklogId = crate::gen::apis::urlencode(worklog_id),
propertyKey = crate::gen::apis::urlencode(property_key)
);
let mut local_var_req_builder = local_var_client.delete(local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = 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) = 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) = 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() {
Ok(())
} else {
let local_var_entity: Option<DeleteWorklogPropertyError> =
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))
}
}
/// Returns the value of a worklog property. This operation can be accessed anonymously. **[Permissions](#permissions) required:** * *Browse projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project that the issue is in. * If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, issue-level security permission to view the issue. * If the worklog has visibility restrictions, belongs to the group or has the role visibility is restricted to.
pub async fn get_worklog_property(
configuration: &configuration::Configuration,
params: GetWorklogPropertyParams,
) -> Result<models::EntityProperty, Error<GetWorklogPropertyError>> {
// unbox the parameters
let issue_id_or_key = params.issue_id_or_key;
let worklog_id = params.worklog_id;
let property_key = params.property_key;
let local_var_client = &configuration.client;
let local_var_uri_str = format!(
"{}/rest/api/3/issue/{issueIdOrKey}/worklog/{worklogId}/properties/{propertyKey}",
configuration.base_path,
issueIdOrKey = crate::gen::apis::urlencode(issue_id_or_key),
worklogId = crate::gen::apis::urlencode(worklog_id),
propertyKey = crate::gen::apis::urlencode(property_key)
);
let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = 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) = 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) = 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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<GetWorklogPropertyError> =
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))
}
}
/// Returns the keys of all properties for a worklog. This operation can be accessed anonymously. **[Permissions](#permissions) required:** * *Browse projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project that the issue is in. * If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, issue-level security permission to view the issue. * If the worklog has visibility restrictions, belongs to the group or has the role visibility is restricted to.
pub async fn get_worklog_property_keys(
configuration: &configuration::Configuration,
params: GetWorklogPropertyKeysParams,
) -> Result<models::PropertyKeys, Error<GetWorklogPropertyKeysError>> {
// unbox the parameters
let issue_id_or_key = params.issue_id_or_key;
let worklog_id = params.worklog_id;
let local_var_client = &configuration.client;
let local_var_uri_str = format!(
"{}/rest/api/3/issue/{issueIdOrKey}/worklog/{worklogId}/properties",
configuration.base_path,
issueIdOrKey = crate::gen::apis::urlencode(issue_id_or_key),
worklogId = crate::gen::apis::urlencode(worklog_id)
);
let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = 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) = 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) = 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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<GetWorklogPropertyKeysError> =
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))
}
}
/// Sets the value of a worklog property. Use this operation to store custom data against the worklog. The value of the request body must be a [valid](http://tools.ietf.org/html/rfc4627), non-empty JSON blob. The maximum length is 32768 characters. This operation can be accessed anonymously. **[Permissions](#permissions) required:** * *Browse projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project that the issue is in. * If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, issue-level security permission to view the issue. * *Edit all worklogs*[ project permission](https://confluence.atlassian.com/x/yodKLg) to update any worklog or *Edit own worklogs* to update worklogs created by the user. * If the worklog has visibility restrictions, belongs to the group or has the role visibility is restricted to.
pub async fn set_worklog_property(
configuration: &configuration::Configuration,
params: SetWorklogPropertyParams,
) -> Result<serde_json::Value, Error<SetWorklogPropertyError>> {
// unbox the parameters
let issue_id_or_key = params.issue_id_or_key;
let worklog_id = params.worklog_id;
let property_key = params.property_key;
let body = params.body;
let local_var_client = &configuration.client;
let local_var_uri_str = format!(
"{}/rest/api/3/issue/{issueIdOrKey}/worklog/{worklogId}/properties/{propertyKey}",
configuration.base_path,
issueIdOrKey = crate::gen::apis::urlencode(issue_id_or_key),
worklogId = crate::gen::apis::urlencode(worklog_id),
propertyKey = crate::gen::apis::urlencode(property_key)
);
let mut local_var_req_builder = local_var_client.put(local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = 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) = 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) = 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(),
);
};
local_var_req_builder = local_var_req_builder.json(&body);
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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<SetWorklogPropertyError> =
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))
}
}