/*
* 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_project_property`
#[derive(Clone, Debug)]
pub struct DeleteProjectPropertyParams {
/// The project ID or project key (case sensitive).
pub project_id_or_key: String,
/// The project property key. Use [Get project property keys](#api-rest-api-3-project-projectIdOrKey-properties-get) to get a list of all project property keys.
pub property_key: String,
}
/// struct for passing parameters to the method `get_project_property`
#[derive(Clone, Debug)]
pub struct GetProjectPropertyParams {
/// The project ID or project key (case sensitive).
pub project_id_or_key: String,
/// The project property key. Use [Get project property keys](#api-rest-api-3-project-projectIdOrKey-properties-get) to get a list of all project property keys.
pub property_key: String,
}
/// struct for passing parameters to the method `get_project_property_keys`
#[derive(Clone, Debug)]
pub struct GetProjectPropertyKeysParams {
/// The project ID or project key (case sensitive).
pub project_id_or_key: String,
}
/// struct for passing parameters to the method `set_project_property`
#[derive(Clone, Debug)]
pub struct SetProjectPropertyParams {
/// The project ID or project key (case sensitive).
pub project_id_or_key: String,
/// The key of the project property. The maximum length is 255 characters.
pub property_key: String,
pub body: Option<serde_json::Value>,
}
/// struct for typed errors of method `delete_project_property`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteProjectPropertyError {
Status400(),
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `get_project_property`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetProjectPropertyError {
Status400(),
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `get_project_property_keys`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetProjectPropertyKeysError {
Status400(),
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `set_project_property`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SetProjectPropertyError {
Status400(),
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
/// Deletes the [property](https://developer.atlassian.com/cloud/jira/platform/storing-data-without-a-database/#a-id-jira-entity-properties-a-jira-entity-properties) from a project. This operation can be accessed anonymously. **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg) or *Administer Projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project containing the property.
pub async fn delete_project_property(
configuration: &configuration::Configuration,
params: DeleteProjectPropertyParams,
) -> Result<(), Error<DeleteProjectPropertyError>> {
// unbox the parameters
let project_id_or_key = params.project_id_or_key;
let property_key = params.property_key;
let local_var_client = &configuration.client;
let local_var_uri_str = format!(
"{}/rest/api/3/project/{projectIdOrKey}/properties/{propertyKey}",
configuration.base_path,
projectIdOrKey = crate::gen::apis::urlencode(project_id_or_key),
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<DeleteProjectPropertyError> =
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 [project property](https://developer.atlassian.com/cloud/jira/platform/storing-data-without-a-database/#a-id-jira-entity-properties-a-jira-entity-properties). This operation can be accessed anonymously. **[Permissions](#permissions) required:** *Browse Projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project containing the property.
pub async fn get_project_property(
configuration: &configuration::Configuration,
params: GetProjectPropertyParams,
) -> Result<models::EntityProperty, Error<GetProjectPropertyError>> {
// unbox the parameters
let project_id_or_key = params.project_id_or_key;
let property_key = params.property_key;
let local_var_client = &configuration.client;
let local_var_uri_str = format!(
"{}/rest/api/3/project/{projectIdOrKey}/properties/{propertyKey}",
configuration.base_path,
projectIdOrKey = crate::gen::apis::urlencode(project_id_or_key),
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<GetProjectPropertyError> =
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 all [project property](https://developer.atlassian.com/cloud/jira/platform/storing-data-without-a-database/#a-id-jira-entity-properties-a-jira-entity-properties) keys for the project. This operation can be accessed anonymously. **[Permissions](#permissions) required:** *Browse Projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project.
pub async fn get_project_property_keys(
configuration: &configuration::Configuration,
params: GetProjectPropertyKeysParams,
) -> Result<models::PropertyKeys, Error<GetProjectPropertyKeysError>> {
// unbox the parameters
let project_id_or_key = params.project_id_or_key;
let local_var_client = &configuration.client;
let local_var_uri_str = format!(
"{}/rest/api/3/project/{projectIdOrKey}/properties",
configuration.base_path,
projectIdOrKey = crate::gen::apis::urlencode(project_id_or_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<GetProjectPropertyKeysError> =
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 the [project property](https://developer.atlassian.com/cloud/jira/platform/storing-data-without-a-database/#a-id-jira-entity-properties-a-jira-entity-properties). You can use project properties to store custom data against the project. 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:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg) or *Administer Projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project in which the property is created.
pub async fn set_project_property(
configuration: &configuration::Configuration,
params: SetProjectPropertyParams,
) -> Result<serde_json::Value, Error<SetProjectPropertyError>> {
// unbox the parameters
let project_id_or_key = params.project_id_or_key;
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/project/{projectIdOrKey}/properties/{propertyKey}",
configuration.base_path,
projectIdOrKey = crate::gen::apis::urlencode(project_id_or_key),
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<SetProjectPropertyError> =
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))
}
}