/*
* 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 [`add_gadget`]
#[derive(Clone, Debug, Default)]
pub struct AddGadgetParams {
/// The ID of the dashboard.
pub dashboard_id: i64,
pub dashboard_gadget_settings: crate::models::DashboardGadgetSettings
}
/// struct for passing parameters to the method [`copy_dashboard`]
#[derive(Clone, Debug, Default)]
pub struct CopyDashboardParams {
pub id: String,
/// Dashboard details.
pub dashboard_details: crate::models::DashboardDetails
}
/// struct for passing parameters to the method [`create_dashboard`]
#[derive(Clone, Debug, Default)]
pub struct CreateDashboardParams {
/// Dashboard details.
pub dashboard_details: crate::models::DashboardDetails
}
/// struct for passing parameters to the method [`delete_dashboard`]
#[derive(Clone, Debug, Default)]
pub struct DeleteDashboardParams {
/// The ID of the dashboard.
pub id: String
}
/// struct for passing parameters to the method [`delete_dashboard_item_property`]
#[derive(Clone, Debug, Default)]
pub struct DeleteDashboardItemPropertyParams {
/// The ID of the dashboard.
pub dashboard_id: String,
/// The ID of the dashboard item.
pub item_id: String,
/// The key of the dashboard item property.
pub property_key: String
}
/// struct for passing parameters to the method [`get_all_dashboards`]
#[derive(Clone, Debug, Default)]
pub struct GetAllDashboardsParams {
/// The filter applied to the list of dashboards. Valid values are: * `favourite` Returns dashboards the user has marked as favorite. * `my` Returns dashboards owned by the user.
pub filter: Option<String>,
/// The index of the first item to return in a page of results (page offset).
pub start_at: Option<i32>,
/// The maximum number of items to return per page.
pub max_results: Option<i32>
}
/// struct for passing parameters to the method [`get_all_gadgets`]
#[derive(Clone, Debug, Default)]
pub struct GetAllGadgetsParams {
/// The ID of the dashboard.
pub dashboard_id: i64,
/// The list of gadgets module keys. To include multiple module keys, separate module keys with ampersand: `moduleKey=key:one&moduleKey=key:two`.
pub module_key: Option<Vec<String>>,
/// The list of gadgets URIs. To include multiple URIs, separate URIs with ampersand: `uri=/rest/example/uri/1&uri=/rest/example/uri/2`.
pub uri: Option<Vec<String>>,
/// The list of gadgets IDs. To include multiple IDs, separate IDs with ampersand: `gadgetId=10000&gadgetId=10001`.
pub gadget_id: Option<Vec<i64>>
}
/// struct for passing parameters to the method [`get_dashboard`]
#[derive(Clone, Debug, Default)]
pub struct GetDashboardParams {
/// The ID of the dashboard.
pub id: String
}
/// struct for passing parameters to the method [`get_dashboard_item_property`]
#[derive(Clone, Debug, Default)]
pub struct GetDashboardItemPropertyParams {
/// The ID of the dashboard.
pub dashboard_id: String,
/// The ID of the dashboard item.
pub item_id: String,
/// The key of the dashboard item property.
pub property_key: String
}
/// struct for passing parameters to the method [`get_dashboard_item_property_keys`]
#[derive(Clone, Debug, Default)]
pub struct GetDashboardItemPropertyKeysParams {
/// The ID of the dashboard.
pub dashboard_id: String,
/// The ID of the dashboard item.
pub item_id: String
}
/// struct for passing parameters to the method [`get_dashboards_paginated`]
#[derive(Clone, Debug, Default)]
pub struct GetDashboardsPaginatedParams {
/// String used to perform a case-insensitive partial match with `name`.
pub dashboard_name: Option<String>,
/// User account ID used to return dashboards with the matching `owner.accountId`. This parameter cannot be used with the `owner` parameter.
pub account_id: Option<String>,
/// This parameter is deprecated because of privacy changes. Use `accountId` instead. See the [migration guide](https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-user-privacy-api-migration-guide/) for details. User name used to return dashboards with the matching `owner.name`. This parameter cannot be used with the `accountId` parameter.
pub owner: Option<String>,
/// Group name used to returns dashboards that are shared with a group that matches `sharePermissions.group.name`.
pub groupname: Option<String>,
/// Project ID used to returns dashboards that are shared with a project that matches `sharePermissions.project.id`.
pub project_id: Option<i64>,
/// [Order](#ordering) the results by a field: * `description` Sorts by dashboard description. Note that this sort works independently of whether the expand to display the description field is in use. * `favourite_count` Sorts by dashboard popularity. * `id` Sorts by dashboard ID. * `is_favourite` Sorts by whether the dashboard is marked as a favorite. * `name` Sorts by dashboard name. * `owner` Sorts by dashboard owner name.
pub order_by: Option<String>,
/// 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>,
/// The status to filter by. It may be active, archived or deleted.
pub status: Option<String>,
/// Use [expand](#expansion) to include additional information about dashboard in the response. This parameter accepts a comma-separated list. Expand options include: * `description` Returns the description of the dashboard. * `owner` Returns the owner of the dashboard. * `viewUrl` Returns the URL that is used to view the dashboard. * `favourite` Returns `isFavourite`, an indicator of whether the user has set the dashboard as a favorite. * `favouritedCount` Returns `popularity`, a count of how many users have set this dashboard as a favorite. * `sharePermissions` Returns details of the share permissions defined for the dashboard. * `editPermissions` Returns details of the edit permissions defined for the dashboard. * `isWritable` Returns whether the current user has permission to edit the dashboard.
pub expand: Option<String>
}
/// struct for passing parameters to the method [`remove_gadget`]
#[derive(Clone, Debug, Default)]
pub struct RemoveGadgetParams {
/// The ID of the dashboard.
pub dashboard_id: i64,
/// The ID of the gadget.
pub gadget_id: i64
}
/// struct for passing parameters to the method [`set_dashboard_item_property`]
#[derive(Clone, Debug, Default)]
pub struct SetDashboardItemPropertyParams {
/// The ID of the dashboard.
pub dashboard_id: String,
/// The ID of the dashboard item.
pub item_id: String,
/// The key of the dashboard item property. The maximum length is 255 characters.
pub property_key: String,
pub body: Option<serde_json::Value>
}
/// struct for passing parameters to the method [`update_dashboard`]
#[derive(Clone, Debug, Default)]
pub struct UpdateDashboardParams {
/// The ID of the dashboard to update.
pub id: String,
/// Replacement dashboard details.
pub dashboard_details: crate::models::DashboardDetails
}
/// struct for passing parameters to the method [`update_gadget`]
#[derive(Clone, Debug, Default)]
pub struct UpdateGadgetParams {
/// The ID of the dashboard.
pub dashboard_id: i64,
/// The ID of the gadget.
pub gadget_id: i64,
pub dashboard_gadget_update_request: crate::models::DashboardGadgetUpdateRequest
}
/// struct for typed successes of method [`add_gadget`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AddGadgetSuccess {
Status200(crate::models::DashboardGadget),
UnknownValue(serde_json::Value),
}
/// struct for typed successes of method [`copy_dashboard`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CopyDashboardSuccess {
Status200(crate::models::Dashboard),
UnknownValue(serde_json::Value),
}
/// struct for typed successes of method [`create_dashboard`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateDashboardSuccess {
Status200(crate::models::Dashboard),
UnknownValue(serde_json::Value),
}
/// struct for typed successes of method [`delete_dashboard`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteDashboardSuccess {
Status204(),
UnknownValue(serde_json::Value),
}
/// struct for typed successes of method [`delete_dashboard_item_property`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteDashboardItemPropertySuccess {
Status204(),
UnknownValue(serde_json::Value),
}
/// struct for typed successes of method [`get_all_available_dashboard_gadgets`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetAllAvailableDashboardGadgetsSuccess {
Status200(crate::models::AvailableDashboardGadgetsResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed successes of method [`get_all_dashboards`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetAllDashboardsSuccess {
Status200(crate::models::PageOfDashboards),
UnknownValue(serde_json::Value),
}
/// struct for typed successes of method [`get_all_gadgets`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetAllGadgetsSuccess {
Status200(crate::models::DashboardGadgetResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed successes of method [`get_dashboard`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetDashboardSuccess {
Status200(crate::models::Dashboard),
UnknownValue(serde_json::Value),
}
/// struct for typed successes of method [`get_dashboard_item_property`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetDashboardItemPropertySuccess {
Status200(crate::models::EntityProperty),
UnknownValue(serde_json::Value),
}
/// struct for typed successes of method [`get_dashboard_item_property_keys`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetDashboardItemPropertyKeysSuccess {
Status200(crate::models::PropertyKeys),
UnknownValue(serde_json::Value),
}
/// struct for typed successes of method [`get_dashboards_paginated`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetDashboardsPaginatedSuccess {
Status200(crate::models::PageBeanDashboard),
UnknownValue(serde_json::Value),
}
/// struct for typed successes of method [`remove_gadget`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RemoveGadgetSuccess {
Status204(serde_json::Value),
UnknownValue(serde_json::Value),
}
/// struct for typed successes of method [`set_dashboard_item_property`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SetDashboardItemPropertySuccess {
Status200(serde_json::Value),
Status201(serde_json::Value),
UnknownValue(serde_json::Value),
}
/// struct for typed successes of method [`update_dashboard`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateDashboardSuccess {
Status200(crate::models::Dashboard),
UnknownValue(serde_json::Value),
}
/// struct for typed successes of method [`update_gadget`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateGadgetSuccess {
Status204(serde_json::Value),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`add_gadget`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AddGadgetError {
Status400(crate::models::ErrorCollection),
Status401(),
Status404(crate::models::ErrorCollection),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`copy_dashboard`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CopyDashboardError {
Status400(crate::models::ErrorCollection),
Status401(crate::models::ErrorCollection),
Status404(crate::models::ErrorCollection),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_dashboard`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateDashboardError {
Status400(crate::models::ErrorCollection),
Status401(crate::models::ErrorCollection),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_dashboard`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteDashboardError {
Status400(crate::models::ErrorCollection),
Status401(crate::models::ErrorCollection),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_dashboard_item_property`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteDashboardItemPropertyError {
Status400(),
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_all_available_dashboard_gadgets`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetAllAvailableDashboardGadgetsError {
Status400(crate::models::ErrorCollection),
Status401(crate::models::ErrorCollection),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_all_dashboards`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetAllDashboardsError {
Status400(crate::models::ErrorCollection),
Status401(crate::models::ErrorCollection),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_all_gadgets`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetAllGadgetsError {
Status401(),
Status404(crate::models::ErrorCollection),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_dashboard`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetDashboardError {
Status400(crate::models::ErrorCollection),
Status401(crate::models::ErrorCollection),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_dashboard_item_property`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetDashboardItemPropertyError {
Status401(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_dashboard_item_property_keys`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetDashboardItemPropertyKeysError {
Status401(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_dashboards_paginated`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetDashboardsPaginatedError {
Status400(crate::models::ErrorCollection),
Status401(crate::models::ErrorCollection),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`remove_gadget`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RemoveGadgetError {
Status401(),
Status404(crate::models::ErrorCollection),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`set_dashboard_item_property`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SetDashboardItemPropertyError {
Status400(),
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_dashboard`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateDashboardError {
Status400(crate::models::ErrorCollection),
Status401(crate::models::ErrorCollection),
Status404(crate::models::ErrorCollection),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_gadget`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateGadgetError {
Status400(crate::models::ErrorCollection),
Status401(),
Status404(crate::models::ErrorCollection),
UnknownValue(serde_json::Value),
}
/// Adds a gadget to a dashboard. **[Permissions](#permissions) required:** None.
pub async fn add_gadget(configuration: &configuration::Configuration, params: AddGadgetParams) -> Result<ResponseContent<AddGadgetSuccess>, Error<AddGadgetError>> {
let local_var_configuration = configuration;
// unbox the parameters
let dashboard_id = params.dashboard_id;
let dashboard_gadget_settings = params.dashboard_gadget_settings;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/rest/api/2/dashboard/{dashboardId}/gadget", local_var_configuration.base_path, dashboardId=dashboard_id);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
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());
};
local_var_req_builder = local_var_req_builder.json(&dashboard_gadget_settings);
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<AddGadgetSuccess> = 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<AddGadgetError> = 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))
}
}
/// Copies a dashboard. Any values provided in the `dashboard` parameter replace those in the copied dashboard. **[Permissions](#permissions) required:** None The dashboard to be copied must be owned by or shared with the user.
pub async fn copy_dashboard(configuration: &configuration::Configuration, params: CopyDashboardParams) -> Result<ResponseContent<CopyDashboardSuccess>, Error<CopyDashboardError>> {
let local_var_configuration = configuration;
// unbox the parameters
let id = params.id;
let dashboard_details = params.dashboard_details;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/rest/api/2/dashboard/{id}/copy", local_var_configuration.base_path, id=crate::apis::urlencode(id));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
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());
};
local_var_req_builder = local_var_req_builder.json(&dashboard_details);
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<CopyDashboardSuccess> = 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<CopyDashboardError> = 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 dashboard. **[Permissions](#permissions) required:** None.
pub async fn create_dashboard(configuration: &configuration::Configuration, params: CreateDashboardParams) -> Result<ResponseContent<CreateDashboardSuccess>, Error<CreateDashboardError>> {
let local_var_configuration = configuration;
// unbox the parameters
let dashboard_details = params.dashboard_details;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/rest/api/2/dashboard", local_var_configuration.base_path);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
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());
};
local_var_req_builder = local_var_req_builder.json(&dashboard_details);
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<CreateDashboardSuccess> = 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<CreateDashboardError> = 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 dashboard. **[Permissions](#permissions) required:** None The dashboard to be deleted must be owned by the user.
pub async fn delete_dashboard(configuration: &configuration::Configuration, params: DeleteDashboardParams) -> Result<ResponseContent<DeleteDashboardSuccess>, Error<DeleteDashboardError>> {
let local_var_configuration = configuration;
// unbox the parameters
let id = params.id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/rest/api/2/dashboard/{id}", local_var_configuration.base_path, id=crate::apis::urlencode(id));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
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<DeleteDashboardSuccess> = 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<DeleteDashboardError> = 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 dashboard item property. This operation can be accessed anonymously. **[Permissions](#permissions) required:** The user must be the owner of the dashboard. Note, users with the *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg) are considered owners of the System dashboard.
pub async fn delete_dashboard_item_property(configuration: &configuration::Configuration, params: DeleteDashboardItemPropertyParams) -> Result<ResponseContent<DeleteDashboardItemPropertySuccess>, Error<DeleteDashboardItemPropertyError>> {
let local_var_configuration = configuration;
// unbox the parameters
let dashboard_id = params.dashboard_id;
let item_id = params.item_id;
let property_key = params.property_key;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/rest/api/2/dashboard/{dashboardId}/items/{itemId}/properties/{propertyKey}", local_var_configuration.base_path, dashboardId=crate::apis::urlencode(dashboard_id), itemId=crate::apis::urlencode(item_id), propertyKey=crate::apis::urlencode(property_key));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
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<DeleteDashboardItemPropertySuccess> = 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<DeleteDashboardItemPropertyError> = 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 list of all available gadgets that can be added to all dashboards. **[Permissions](#permissions) required:** None.
pub async fn get_all_available_dashboard_gadgets(configuration: &configuration::Configuration) -> Result<ResponseContent<GetAllAvailableDashboardGadgetsSuccess>, Error<GetAllAvailableDashboardGadgetsError>> {
let local_var_configuration = configuration;
// unbox the parameters
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/rest/api/2/dashboard/gadgets", 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_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<GetAllAvailableDashboardGadgetsSuccess> = 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<GetAllAvailableDashboardGadgetsError> = 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 list of dashboards owned by or shared with the user. The list may be filtered to include only favorite or owned dashboards. This operation can be accessed anonymously. **[Permissions](#permissions) required:** None.
pub async fn get_all_dashboards(configuration: &configuration::Configuration, params: GetAllDashboardsParams) -> Result<ResponseContent<GetAllDashboardsSuccess>, Error<GetAllDashboardsError>> {
let local_var_configuration = configuration;
// unbox the parameters
let filter = params.filter;
let start_at = params.start_at;
let max_results = params.max_results;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/rest/api/2/dashboard", 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) = filter {
local_var_req_builder = local_var_req_builder.query(&[("filter", &local_var_str.to_string())]);
}
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_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<GetAllDashboardsSuccess> = 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<GetAllDashboardsError> = 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 list of dashboard gadgets on a dashboard. This operation returns: * Gadgets from a list of IDs, when `id` is set. * Gadgets with a module key, when `moduleKey` is set. * Gadgets from a list of URIs, when `uri` is set. * All gadgets, when no other parameters are set. This operation can be accessed anonymously. **[Permissions](#permissions) required:** None.
pub async fn get_all_gadgets(configuration: &configuration::Configuration, params: GetAllGadgetsParams) -> Result<ResponseContent<GetAllGadgetsSuccess>, Error<GetAllGadgetsError>> {
let local_var_configuration = configuration;
// unbox the parameters
let dashboard_id = params.dashboard_id;
let module_key = params.module_key;
let uri = params.uri;
let gadget_id = params.gadget_id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/rest/api/2/dashboard/{dashboardId}/gadget", local_var_configuration.base_path, dashboardId=dashboard_id);
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) = module_key {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("moduleKey".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
_ => local_var_req_builder.query(&[("moduleKey", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
};
}
if let Some(ref local_var_str) = uri {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("uri".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
_ => local_var_req_builder.query(&[("uri", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
};
}
if let Some(ref local_var_str) = gadget_id {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("gadgetId".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
_ => local_var_req_builder.query(&[("gadgetId", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").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<GetAllGadgetsSuccess> = 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<GetAllGadgetsError> = 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 dashboard. This operation can be accessed anonymously. **[Permissions](#permissions) required:** None. However, to get a dashboard, the dashboard must be shared with the user or the user must own it. Note, users with the *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg) are considered owners of the System dashboard. The System dashboard is considered to be shared with all other users.
pub async fn get_dashboard(configuration: &configuration::Configuration, params: GetDashboardParams) -> Result<ResponseContent<GetDashboardSuccess>, Error<GetDashboardError>> {
let local_var_configuration = configuration;
// unbox the parameters
let id = params.id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/rest/api/2/dashboard/{id}", local_var_configuration.base_path, id=crate::apis::urlencode(id));
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_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<GetDashboardSuccess> = 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<GetDashboardError> = 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 key and value of a dashboard item property. A dashboard item enables an app to add user-specific information to a user dashboard. Dashboard items are exposed to users as gadgets that users can add to their dashboards. For more information on how users do this, see [Adding and customizing gadgets](https://confluence.atlassian.com/x/7AeiLQ). When an app creates a dashboard item it registers a callback to receive the dashboard item ID. The callback fires whenever the item is rendered or, where the item is configurable, the user edits the item. The app then uses this resource to store the item's content or configuration details. For more information on working with dashboard items, see [ Building a dashboard item for a JIRA Connect add-on](https://developer.atlassian.com/server/jira/platform/guide-building-a-dashboard-item-for-a-jira-connect-add-on-33746254/) and the [Dashboard Item](https://developer.atlassian.com/cloud/jira/platform/modules/dashboard-item/) documentation. There is no resource to set or get dashboard items. This operation can be accessed anonymously. **[Permissions](#permissions) required:** The user must be the owner of the dashboard or have the dashboard shared with them. Note, users with the *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg) are considered owners of the System dashboard. The System dashboard is considered to be shared with all other users, and is accessible to anonymous users when Jira’s anonymous access is permitted.
pub async fn get_dashboard_item_property(configuration: &configuration::Configuration, params: GetDashboardItemPropertyParams) -> Result<ResponseContent<GetDashboardItemPropertySuccess>, Error<GetDashboardItemPropertyError>> {
let local_var_configuration = configuration;
// unbox the parameters
let dashboard_id = params.dashboard_id;
let item_id = params.item_id;
let property_key = params.property_key;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/rest/api/2/dashboard/{dashboardId}/items/{itemId}/properties/{propertyKey}", local_var_configuration.base_path, dashboardId=crate::apis::urlencode(dashboard_id), itemId=crate::apis::urlencode(item_id), propertyKey=crate::apis::urlencode(property_key));
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_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<GetDashboardItemPropertySuccess> = 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<GetDashboardItemPropertyError> = 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 dashboard item. This operation can be accessed anonymously. **[Permissions](#permissions) required:** The user must be the owner of the dashboard or have the dashboard shared with them. Note, users with the *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg) are considered owners of the System dashboard. The System dashboard is considered to be shared with all other users, and is accessible to anonymous users when Jira’s anonymous access is permitted.
pub async fn get_dashboard_item_property_keys(configuration: &configuration::Configuration, params: GetDashboardItemPropertyKeysParams) -> Result<ResponseContent<GetDashboardItemPropertyKeysSuccess>, Error<GetDashboardItemPropertyKeysError>> {
let local_var_configuration = configuration;
// unbox the parameters
let dashboard_id = params.dashboard_id;
let item_id = params.item_id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/rest/api/2/dashboard/{dashboardId}/items/{itemId}/properties", local_var_configuration.base_path, dashboardId=crate::apis::urlencode(dashboard_id), itemId=crate::apis::urlencode(item_id));
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_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<GetDashboardItemPropertyKeysSuccess> = 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<GetDashboardItemPropertyKeysError> = 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 dashboards. This operation is similar to [Get dashboards](#api-rest-api-2-dashboard-get) except that the results can be refined to include dashboards that have specific attributes. For example, dashboards with a particular name. When multiple attributes are specified only filters matching all attributes are returned. This operation can be accessed anonymously. **[Permissions](#permissions) required:** The following dashboards that match the query parameters are returned: * Dashboards owned by the user. Not returned for anonymous users. * Dashboards shared with a group that the user is a member of. Not returned for anonymous users. * Dashboards shared with a private project that the user can browse. Not returned for anonymous users. * Dashboards shared with a public project. * Dashboards shared with the public.
pub async fn get_dashboards_paginated(configuration: &configuration::Configuration, params: GetDashboardsPaginatedParams) -> Result<ResponseContent<GetDashboardsPaginatedSuccess>, Error<GetDashboardsPaginatedError>> {
let local_var_configuration = configuration;
// unbox the parameters
let dashboard_name = params.dashboard_name;
let account_id = params.account_id;
let owner = params.owner;
let groupname = params.groupname;
let project_id = params.project_id;
let order_by = params.order_by;
let start_at = params.start_at;
let max_results = params.max_results;
let status = params.status;
let expand = params.expand;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/rest/api/2/dashboard/search", 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) = dashboard_name {
local_var_req_builder = local_var_req_builder.query(&[("dashboardName", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = account_id {
local_var_req_builder = local_var_req_builder.query(&[("accountId", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = owner {
local_var_req_builder = local_var_req_builder.query(&[("owner", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = groupname {
local_var_req_builder = local_var_req_builder.query(&[("groupname", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = project_id {
local_var_req_builder = local_var_req_builder.query(&[("projectId", &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) = 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) = status {
local_var_req_builder = local_var_req_builder.query(&[("status", &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_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<GetDashboardsPaginatedSuccess> = 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<GetDashboardsPaginatedError> = 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))
}
}
/// Removes a dashboard gadget from a dashboard. When a gadget is removed from a dashboard, other gadgets in the same column are moved up to fill the emptied position. **[Permissions](#permissions) required:** None.
pub async fn remove_gadget(configuration: &configuration::Configuration, params: RemoveGadgetParams) -> Result<ResponseContent<RemoveGadgetSuccess>, Error<RemoveGadgetError>> {
let local_var_configuration = configuration;
// unbox the parameters
let dashboard_id = params.dashboard_id;
let gadget_id = params.gadget_id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/rest/api/2/dashboard/{dashboardId}/gadget/{gadgetId}", local_var_configuration.base_path, dashboardId=dashboard_id, gadgetId=gadget_id);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
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<RemoveGadgetSuccess> = 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<RemoveGadgetError> = 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 dashboard item property. Use this resource in apps to store custom data against a dashboard item. A dashboard item enables an app to add user-specific information to a user dashboard. Dashboard items are exposed to users as gadgets that users can add to their dashboards. For more information on how users do this, see [Adding and customizing gadgets](https://confluence.atlassian.com/x/7AeiLQ). When an app creates a dashboard item it registers a callback to receive the dashboard item ID. The callback fires whenever the item is rendered or, where the item is configurable, the user edits the item. The app then uses this resource to store the item's content or configuration details. For more information on working with dashboard items, see [ Building a dashboard item for a JIRA Connect add-on](https://developer.atlassian.com/server/jira/platform/guide-building-a-dashboard-item-for-a-jira-connect-add-on-33746254/) and the [Dashboard Item](https://developer.atlassian.com/cloud/jira/platform/modules/dashboard-item/) documentation. There is no resource to set or get dashboard items. 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:** The user must be the owner of the dashboard. Note, users with the *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg) are considered owners of the System dashboard.
pub async fn set_dashboard_item_property(configuration: &configuration::Configuration, params: SetDashboardItemPropertyParams) -> Result<ResponseContent<SetDashboardItemPropertySuccess>, Error<SetDashboardItemPropertyError>> {
let local_var_configuration = configuration;
// unbox the parameters
let dashboard_id = params.dashboard_id;
let item_id = params.item_id;
let property_key = params.property_key;
let body = params.body;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/rest/api/2/dashboard/{dashboardId}/items/{itemId}/properties/{propertyKey}", local_var_configuration.base_path, dashboardId=crate::apis::urlencode(dashboard_id), itemId=crate::apis::urlencode(item_id), propertyKey=crate::apis::urlencode(property_key));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
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());
};
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() {
let local_var_entity: Option<SetDashboardItemPropertySuccess> = 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<SetDashboardItemPropertyError> = 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 a dashboard, replacing all the dashboard details with those provided. **[Permissions](#permissions) required:** None The dashboard to be updated must be owned by the user.
pub async fn update_dashboard(configuration: &configuration::Configuration, params: UpdateDashboardParams) -> Result<ResponseContent<UpdateDashboardSuccess>, Error<UpdateDashboardError>> {
let local_var_configuration = configuration;
// unbox the parameters
let id = params.id;
let dashboard_details = params.dashboard_details;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/rest/api/2/dashboard/{id}", local_var_configuration.base_path, id=crate::apis::urlencode(id));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
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());
};
local_var_req_builder = local_var_req_builder.json(&dashboard_details);
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<UpdateDashboardSuccess> = 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<UpdateDashboardError> = 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))
}
}
/// Changes the title, position, and color of the gadget on a dashboard. **[Permissions](#permissions) required:** None.
pub async fn update_gadget(configuration: &configuration::Configuration, params: UpdateGadgetParams) -> Result<ResponseContent<UpdateGadgetSuccess>, Error<UpdateGadgetError>> {
let local_var_configuration = configuration;
// unbox the parameters
let dashboard_id = params.dashboard_id;
let gadget_id = params.gadget_id;
let dashboard_gadget_update_request = params.dashboard_gadget_update_request;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/rest/api/2/dashboard/{dashboardId}/gadget/{gadgetId}", local_var_configuration.base_path, dashboardId=dashboard_id, gadgetId=gadget_id);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
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());
};
local_var_req_builder = local_var_req_builder.json(&dashboard_gadget_update_request);
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<UpdateGadgetSuccess> = 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<UpdateGadgetError> = 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))
}
}