/*
* 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 `archive_project`
#[derive(Clone, Debug)]
pub struct ArchiveProjectParams {
/// The project ID or project key (case sensitive).
pub project_id_or_key: String,
}
/// struct for passing parameters to the method `create_project`
#[derive(Clone, Debug)]
pub struct CreateProjectParams {
/// The JSON representation of the project being created.
pub project_input_bean: models::ProjectInputBean,
}
/// struct for passing parameters to the method `delete_project`
#[derive(Clone, Debug)]
pub struct DeleteProjectParams {
/// The project ID or project key (case sensitive).
pub project_id_or_key: String,
/// Whether this project is placed in the Jira recycle bin where it will be available for restoration.
pub enable_undo: Option<bool>,
}
/// struct for passing parameters to the method `delete_project_asynchronously`
#[derive(Clone, Debug)]
pub struct DeleteProjectAsynchronouslyParams {
/// The project ID or project key (case sensitive).
pub project_id_or_key: String,
}
/// struct for passing parameters to the method `get_all_projects`
#[derive(Clone, Debug)]
pub struct GetAllProjectsParams {
/// Use [expand](#expansion) to include additional information in the response. This parameter accepts a comma-separated list. Expanded options include: * `description` Returns the project description. * `issueTypes` Returns all issue types associated with the project. * `lead` Returns information about the project lead. * `projectKeys` Returns all project keys associated with the project.
pub expand: Option<String>,
/// Returns the user's most recently accessed projects. You may specify the number of results to return up to a maximum of 20. If access is anonymous, then the recently accessed projects are based on the current HTTP session.
pub recent: Option<i32>,
/// A list of project properties to return for the project. This parameter accepts a comma-separated list.
pub properties: Option<Vec<String>>,
}
/// struct for passing parameters to the method `get_all_statuses`
#[derive(Clone, Debug)]
pub struct GetAllStatusesParams {
/// The project ID or project key (case sensitive).
pub project_id_or_key: String,
}
/// struct for passing parameters to the method `get_hierarchy`
#[derive(Clone, Debug)]
pub struct GetHierarchyParams {
/// The ID of the project.
pub project_id: i64,
}
/// struct for passing parameters to the method `get_notification_scheme_for_project`
#[derive(Clone, Debug)]
pub struct GetNotificationSchemeForProjectParams {
/// The project ID or project key (case sensitive).
pub project_key_or_id: String,
/// Use [expand](#expansion) to include additional information in the response. This parameter accepts a comma-separated list. Expand options include: * `all` Returns all expandable information. * `field` Returns information about any custom fields assigned to receive an event. * `group` Returns information about any groups assigned to receive an event. * `notificationSchemeEvents` Returns a list of event associations. This list is returned for all expandable information. * `projectRole` Returns information about any project roles assigned to receive an event. * `user` Returns information about any users assigned to receive an event.
pub expand: Option<String>,
}
/// struct for passing parameters to the method `get_project`
#[derive(Clone, Debug)]
pub struct GetProjectParams {
/// The project ID or project key (case sensitive).
pub project_id_or_key: String,
/// Use [expand](#expansion) to include additional information in the response. This parameter accepts a comma-separated list. Note that the project description, issue types, and project lead are included in all responses by default. Expand options include: * `description` The project description. * `issueTypes` The issue types associated with the project. * `lead` The project lead. * `projectKeys` All project keys associated with the project. * `issueTypeHierarchy` The project issue type hierarchy.
pub expand: Option<String>,
/// A list of project properties to return for the project. This parameter accepts a comma-separated list.
pub properties: Option<Vec<String>>,
}
/// struct for passing parameters to the method `restore`
#[derive(Clone, Debug)]
pub struct RestoreParams {
/// The project ID or project key (case sensitive).
pub project_id_or_key: String,
}
/// struct for passing parameters to the method `search_projects`
#[derive(Clone, Debug)]
pub struct SearchProjectsParams {
/// The index of the first item to return in a page of results (page offset).
pub start_at: Option<i64>,
/// The maximum number of items to return per page.
pub max_results: Option<i32>,
/// [Order](#ordering) the results by a field. * `category` Sorts by project category. A complete list of category IDs is found using [Get all project categories](#api-rest-api-3-projectCategory-get). * `issueCount` Sorts by the total number of issues in each project. * `key` Sorts by project key. * `lastIssueUpdatedTime` Sorts by the last issue update time. * `name` Sorts by project name. * `owner` Sorts by project lead. * `archivedDate` EXPERIMENTAL. Sorts by project archived date. * `deletedDate` EXPERIMENTAL. Sorts by project deleted date.
pub order_by: Option<String>,
/// Filter the results using a literal string. Projects with a matching `key` or `name` are returned (case insensitive).
pub query: Option<String>,
/// Orders results by the [project type](https://confluence.atlassian.com/x/GwiiLQ#Jiraapplicationsoverview-Productfeaturesandprojecttypes). This parameter accepts a comma-separated list. Valid values are `business`, `service_desk`, and `software`.
pub type_key: Option<String>,
/// The ID of the project's category. A complete list of category IDs is found using the [Get all project categories](#api-rest-api-3-projectCategory-get) operation.
pub category_id: Option<i64>,
/// Filter results by projects for which the user can: * `view` the project, meaning that they have one of the following permissions: * *Browse projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project. * *Administer projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project. * *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg). * `browse` the project, meaning that they have the *Browse projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project. * `edit` the project, meaning that they have one of the following permissions: * *Administer projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project. * *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
pub action: Option<String>,
/// Use [expand](#expansion) to include additional information in the response. This parameter accepts a comma-separated list. Expanded options include: * `description` Returns the project description. * `projectKeys` Returns all project keys associated with a project. * `lead` Returns information about the project lead. * `issueTypes` Returns all issue types associated with the project. * `url` Returns the URL associated with the project. * `insight` EXPERIMENTAL. Returns the insight details of total issue count and last issue update time for the project.
pub expand: Option<String>,
/// EXPERIMENTAL. Filter results by project status: * `live` Search live projects. * `archived` Search archived projects. * `deleted` Search deleted projects, those in the recycle bin.
pub status: Option<Vec<String>>,
}
/// struct for passing parameters to the method `update_project`
#[derive(Clone, Debug)]
pub struct UpdateProjectParams {
/// The project ID or project key (case sensitive).
pub project_id_or_key: String,
/// The project details to be updated.
pub project_input_bean: models::ProjectInputBean,
/// Use [expand](#expansion) to include additional information in the response. This parameter accepts a comma-separated list. Note that the project description, issue types, and project lead are included in all responses by default. Expand options include: * `description` The project description. * `issueTypes` The issue types associated with the project. * `lead` The project lead. * `projectKeys` All project keys associated with the project.
pub expand: Option<String>,
}
/// struct for passing parameters to the method `update_project_type`
#[derive(Clone, Debug)]
pub struct UpdateProjectTypeParams {
/// The project ID or project key (case sensitive).
pub project_id_or_key: String,
/// The key of the new project type.
pub new_project_type_key: String,
}
/// struct for typed errors of method `archive_project`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ArchiveProjectError {
Status400(),
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `create_project`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateProjectError {
Status400(),
Status401(),
Status403(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `delete_project`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteProjectError {
Status401(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `delete_project_asynchronously`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteProjectAsynchronouslyError {
Status400(),
Status401(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `get_all_projects`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetAllProjectsError {
Status401(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `get_all_statuses`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetAllStatusesError {
Status401(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `get_hierarchy`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetHierarchyError {
Status400(),
Status401(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `get_notification_scheme_for_project`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetNotificationSchemeForProjectError {
Status400(),
Status401(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `get_project`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetProjectError {
Status401(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `restore`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RestoreError {
Status400(),
Status401(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `search_projects`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SearchProjectsError {
Status400(),
Status401(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `update_project`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateProjectError {
Status400(),
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `update_project_type`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateProjectTypeError {
Status400(),
Status401(),
Status404(),
UnknownValue(serde_json::Value),
}
/// Archives a project. Archived projects cannot be deleted. To delete an archived project, restore the project and then delete it. To restore a project, use the Jira UI. **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
pub async fn archive_project(
configuration: &configuration::Configuration,
params: ArchiveProjectParams,
) -> Result<serde_json::Value, Error<ArchiveProjectError>> {
// 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}/archive",
configuration.base_path,
projectIdOrKey = crate::gen::apis::urlencode(project_id_or_key)
);
let mut local_var_req_builder = local_var_client.post(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<ArchiveProjectError> =
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))
}
}
/// Creates a project based on a project type template, as shown in the following table: | Project Type Key | Project Template Key | |--|--| | `business` | `com.atlassian.jira-core-project-templates:jira-core-simplified-content-management`, `com.atlassian.jira-core-project-templates:jira-core-simplified-document-approval`, `com.atlassian.jira-core-project-templates:jira-core-simplified-lead-tracking`, `com.atlassian.jira-core-project-templates:jira-core-simplified-process-control`, `com.atlassian.jira-core-project-templates:jira-core-simplified-procurement`, `com.atlassian.jira-core-project-templates:jira-core-simplified-project-management`, `com.atlassian.jira-core-project-templates:jira-core-simplified-recruitment`, `com.atlassian.jira-core-project-templates:jira-core-simplified-task-tracking` | | `service_desk` | `com.atlassian.servicedesk:simplified-it-service-desk`, `com.atlassian.servicedesk:simplified-internal-service-desk`, `com.atlassian.servicedesk:simplified-external-service-desk` | | `software` | `com.pyxis.greenhopper.jira:gh-simplified-agility-kanban`, `com.pyxis.greenhopper.jira:gh-simplified-agility-scrum`, `com.pyxis.greenhopper.jira:gh-simplified-basic`, `com.pyxis.greenhopper.jira:gh-simplified-kanban-classic`, `com.pyxis.greenhopper.jira:gh-simplified-scrum-classic` | The project types are available according to the installed Jira features as follows: * Jira Core, the default, enables `business` projects. * Jira Service Management enables `service_desk` projects. * Jira Software enables `software` projects. To determine which features are installed, go to **Jira settings** > **Apps** > **Manage apps** and review the System Apps list. To add Jira Software or Jira Service Management into a JIRA instance, use **Jira settings** > **Apps** > **Finding new apps**. For more information, see [ Managing add-ons](https://confluence.atlassian.com/x/S31NLg). **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
pub async fn create_project(
configuration: &configuration::Configuration,
params: CreateProjectParams,
) -> Result<models::ProjectIdentifiers, Error<CreateProjectError>> {
// unbox the parameters
let project_input_bean = params.project_input_bean;
let local_var_client = &configuration.client;
let local_var_uri_str = format!("{}/rest/api/3/project", configuration.base_path);
let mut local_var_req_builder = local_var_client.post(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(&project_input_bean);
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<CreateProjectError> =
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))
}
}
/// Deletes a project. **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
pub async fn delete_project(
configuration: &configuration::Configuration,
params: DeleteProjectParams,
) -> Result<(), Error<DeleteProjectError>> {
// unbox the parameters
let project_id_or_key = params.project_id_or_key;
let enable_undo = params.enable_undo;
let local_var_client = &configuration.client;
let local_var_uri_str = format!(
"{}/rest/api/3/project/{projectIdOrKey}",
configuration.base_path,
projectIdOrKey = crate::gen::apis::urlencode(project_id_or_key)
);
let mut local_var_req_builder = local_var_client.delete(local_var_uri_str.as_str());
if let Some(ref local_var_str) = enable_undo {
local_var_req_builder =
local_var_req_builder.query(&[("enableUndo", &local_var_str.to_string())]);
}
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<DeleteProjectError> =
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))
}
}
/// Deletes a project asynchronously. This operation is: * transactional, that is, if part of the delete fails the project is not deleted. * [asynchronous](#async). Follow the `location` link in the response to determine the status of the task and use [Get task](#api-rest-api-3-task-taskId-get) to obtain subsequent updates. **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
pub async fn delete_project_asynchronously(
configuration: &configuration::Configuration,
params: DeleteProjectAsynchronouslyParams,
) -> Result<(), Error<DeleteProjectAsynchronouslyError>> {
// 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}/delete",
configuration.base_path,
projectIdOrKey = crate::gen::apis::urlencode(project_id_or_key)
);
let mut local_var_req_builder = local_var_client.post(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<DeleteProjectAsynchronouslyError> =
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 projects visible to the user. Deprecated, use [ Get projects paginated](#api-rest-api-3-project-search-get) that supports search and pagination. This operation can be accessed anonymously. **[Permissions](#permissions) required:** Projects are returned only where the user has *Browse Projects* or *Administer projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project.
pub async fn get_all_projects(
configuration: &configuration::Configuration,
params: GetAllProjectsParams,
) -> Result<Vec<models::Project>, Error<GetAllProjectsError>> {
// unbox the parameters
let expand = params.expand;
let recent = params.recent;
let properties = params.properties;
let local_var_client = &configuration.client;
let local_var_uri_str = format!("{}/rest/api/3/project", configuration.base_path);
let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
if let Some(ref local_var_str) = expand {
local_var_req_builder =
local_var_req_builder.query(&[("expand", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = recent {
local_var_req_builder =
local_var_req_builder.query(&[("recent", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = properties {
local_var_req_builder = local_var_req_builder.query(&[(
"properties",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]);
}
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<GetAllProjectsError> =
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 valid statuses for a project. The statuses are grouped by issue type, as each project has a set of valid issue types and each issue type has a set of valid statuses. 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_all_statuses(
configuration: &configuration::Configuration,
params: GetAllStatusesParams,
) -> Result<Vec<models::IssueTypeWithStatus>, Error<GetAllStatusesError>> {
// 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}/statuses",
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<GetAllStatusesError> =
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))
}
}
/// Get the issue type hierarchy for a next-gen project. The issue type hierarchy for a project consists of: * *Epic* at level 1 (optional). * One or more issue types at level 0 such as *Story*, *Task*, or *Bug*. Where the issue type *Epic* is defined, these issue types are used to break down the content of an epic. * *Subtask* at level -1 (optional). This issue type enables level 0 issue types to be broken down into components. Issues based on a level -1 issue type must have a parent issue. **[Permissions](#permissions) required:** *Browse projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project.
pub async fn get_hierarchy(
configuration: &configuration::Configuration,
params: GetHierarchyParams,
) -> Result<models::ProjectIssueTypeHierarchy, Error<GetHierarchyError>> {
// unbox the parameters
let project_id = params.project_id;
let local_var_client = &configuration.client;
let local_var_uri_str = format!(
"{}/rest/api/3/project/{projectId}/hierarchy",
configuration.base_path,
projectId = project_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<GetHierarchyError> =
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))
}
}
/// Gets a [notification scheme](https://confluence.atlassian.com/x/8YdKLg) associated with the project. See the [Get notification scheme](#api-rest-api-3-notificationscheme-id-get) resource for more information about notification schemes. **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg) or *Administer Projects* [project permission](https://confluence.atlassian.com/x/yodKLg).
pub async fn get_notification_scheme_for_project(
configuration: &configuration::Configuration,
params: GetNotificationSchemeForProjectParams,
) -> Result<models::NotificationScheme, Error<GetNotificationSchemeForProjectError>> {
// unbox the parameters
let project_key_or_id = params.project_key_or_id;
let expand = params.expand;
let local_var_client = &configuration.client;
let local_var_uri_str = format!(
"{}/rest/api/3/project/{projectKeyOrId}/notificationscheme",
configuration.base_path,
projectKeyOrId = crate::gen::apis::urlencode(project_key_or_id)
);
let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
if let Some(ref local_var_str) = expand {
local_var_req_builder =
local_var_req_builder.query(&[("expand", &local_var_str.to_string())]);
}
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<GetNotificationSchemeForProjectError> =
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 [project details](https://confluence.atlassian.com/x/ahLpNw) for a 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(
configuration: &configuration::Configuration,
params: GetProjectParams,
) -> Result<models::Project, Error<GetProjectError>> {
// unbox the parameters
let project_id_or_key = params.project_id_or_key;
let expand = params.expand;
let properties = params.properties;
let local_var_client = &configuration.client;
let local_var_uri_str = format!(
"{}/rest/api/3/project/{projectIdOrKey}",
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_str) = expand {
local_var_req_builder =
local_var_req_builder.query(&[("expand", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = properties {
local_var_req_builder = local_var_req_builder.query(&[(
"properties",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]);
}
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<GetProjectError> =
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))
}
}
/// Restores a project from the Jira recycle bin. **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
pub async fn restore(
configuration: &configuration::Configuration,
params: RestoreParams,
) -> Result<models::Project, Error<RestoreError>> {
// 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}/restore",
configuration.base_path,
projectIdOrKey = crate::gen::apis::urlencode(project_id_or_key)
);
let mut local_var_req_builder = local_var_client.post(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<RestoreError> = 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 a [paginated](#pagination) list of projects visible to the user. This operation can be accessed anonymously. **[Permissions](#permissions) required:** Projects are returned only where the user has one of: * *Browse Projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project. * *Administer Projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project. * *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
pub async fn search_projects(
configuration: &configuration::Configuration,
params: SearchProjectsParams,
) -> Result<models::PageBeanProject, Error<SearchProjectsError>> {
// unbox the parameters
let start_at = params.start_at;
let max_results = params.max_results;
let order_by = params.order_by;
let query = params.query;
let type_key = params.type_key;
let category_id = params.category_id;
let action = params.action;
let expand = params.expand;
let status = params.status;
let local_var_client = &configuration.client;
let local_var_uri_str = format!("{}/rest/api/3/project/search", configuration.base_path);
let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
if let Some(ref local_var_str) = start_at {
local_var_req_builder =
local_var_req_builder.query(&[("startAt", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = max_results {
local_var_req_builder =
local_var_req_builder.query(&[("maxResults", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = order_by {
local_var_req_builder =
local_var_req_builder.query(&[("orderBy", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = query {
local_var_req_builder =
local_var_req_builder.query(&[("query", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = type_key {
local_var_req_builder =
local_var_req_builder.query(&[("typeKey", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = category_id {
local_var_req_builder =
local_var_req_builder.query(&[("categoryId", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = action {
local_var_req_builder =
local_var_req_builder.query(&[("action", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = expand {
local_var_req_builder =
local_var_req_builder.query(&[("expand", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = status {
local_var_req_builder = local_var_req_builder.query(&[(
"status",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]);
}
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<SearchProjectsError> =
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))
}
}
/// Updates the [project details](https://confluence.atlassian.com/x/ahLpNw) of a project. All parameters are optional in the body of the request. **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
pub async fn update_project(
configuration: &configuration::Configuration,
params: UpdateProjectParams,
) -> Result<models::Project, Error<UpdateProjectError>> {
// unbox the parameters
let project_id_or_key = params.project_id_or_key;
let project_input_bean = params.project_input_bean;
let expand = params.expand;
let local_var_client = &configuration.client;
let local_var_uri_str = format!(
"{}/rest/api/3/project/{projectIdOrKey}",
configuration.base_path,
projectIdOrKey = crate::gen::apis::urlencode(project_id_or_key)
);
let mut local_var_req_builder = local_var_client.put(local_var_uri_str.as_str());
if let Some(ref local_var_str) = expand {
local_var_req_builder =
local_var_req_builder.query(&[("expand", &local_var_str.to_string())]);
}
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(&project_input_bean);
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<UpdateProjectError> =
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))
}
}
/// Deprecated, this feature is no longer supported and no alternatives are available, see [Convert project to a different template or type](https://confluence.atlassian.com/x/yEKeOQ). Updates a [project type](https://confluence.atlassian.com/x/GwiiLQ). The project type can be updated for classic projects only, project type cannot be updated for next-gen projects. **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
pub async fn update_project_type(
configuration: &configuration::Configuration,
params: UpdateProjectTypeParams,
) -> Result<models::Project, Error<UpdateProjectTypeError>> {
// unbox the parameters
let project_id_or_key = params.project_id_or_key;
let new_project_type_key = params.new_project_type_key;
let local_var_client = &configuration.client;
let local_var_uri_str = format!(
"{}/rest/api/3/project/{projectIdOrKey}/type/{newProjectTypeKey}",
configuration.base_path,
projectIdOrKey = crate::gen::apis::urlencode(project_id_or_key),
newProjectTypeKey = crate::gen::apis::urlencode(new_project_type_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(),
);
};
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<UpdateProjectTypeError> =
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))
}
}