use super::{configuration, Error};
use crate::gen::apis::ResponseContent;
use crate::gen::models;
#[derive(Clone, Debug)]
pub struct AssignFieldConfigurationSchemeToProjectParams {
pub field_configuration_scheme_project_association:
models::FieldConfigurationSchemeProjectAssociation,
}
#[derive(Clone, Debug)]
pub struct GetAllFieldConfigurationSchemesParams {
pub start_at: Option<i64>,
pub max_results: Option<i32>,
pub id: Option<Vec<i64>>,
}
#[derive(Clone, Debug)]
pub struct GetAllFieldConfigurationsParams {
pub start_at: Option<i64>,
pub max_results: Option<i32>,
pub id: Option<Vec<i64>>,
pub is_default: Option<bool>,
}
#[derive(Clone, Debug)]
pub struct GetFieldConfigurationItemsParams {
pub id: i64,
pub start_at: Option<i64>,
pub max_results: Option<i32>,
}
#[derive(Clone, Debug)]
pub struct GetFieldConfigurationSchemeMappingsParams {
pub start_at: Option<i64>,
pub max_results: Option<i32>,
pub field_configuration_scheme_id: Option<Vec<i64>>,
}
#[derive(Clone, Debug)]
pub struct GetFieldConfigurationSchemeProjectMappingParams {
pub project_id: Vec<i64>,
pub start_at: Option<i64>,
pub max_results: Option<i32>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AssignFieldConfigurationSchemeToProjectError {
Status400(),
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetAllFieldConfigurationSchemesError {
Status400(),
Status401(),
Status403(),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetAllFieldConfigurationsError {
Status401(),
Status403(),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetFieldConfigurationItemsError {
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetFieldConfigurationSchemeMappingsError {
Status400(),
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetFieldConfigurationSchemeProjectMappingError {
Status400(),
Status401(),
Status403(),
UnknownValue(serde_json::Value),
}
pub async fn assign_field_configuration_scheme_to_project(
configuration: &configuration::Configuration,
params: AssignFieldConfigurationSchemeToProjectParams,
) -> Result<serde_json::Value, Error<AssignFieldConfigurationSchemeToProjectError>> {
let field_configuration_scheme_project_association =
params.field_configuration_scheme_project_association;
let local_var_client = &configuration.client;
let local_var_uri_str = format!(
"{}/rest/api/3/fieldconfigurationscheme/project",
configuration.base_path
);
let mut local_var_req_builder = local_var_client.put(local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
if let Some(ref local_var_auth_conf) = configuration.basic_auth {
local_var_req_builder = local_var_req_builder.basic_auth(
local_var_auth_conf.0.to_owned(),
local_var_auth_conf.1.to_owned(),
);
};
local_var_req_builder =
local_var_req_builder.json(&field_configuration_scheme_project_association);
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<AssignFieldConfigurationSchemeToProjectError> =
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))
}
}
pub async fn get_all_field_configuration_schemes(
configuration: &configuration::Configuration,
params: GetAllFieldConfigurationSchemesParams,
) -> Result<models::PageBeanFieldConfigurationScheme, Error<GetAllFieldConfigurationSchemesError>> {
let start_at = params.start_at;
let max_results = params.max_results;
let id = params.id;
let local_var_client = &configuration.client;
let local_var_uri_str = format!(
"{}/rest/api/3/fieldconfigurationscheme",
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) = id {
local_var_req_builder = local_var_req_builder.query(&[(
"id",
&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<GetAllFieldConfigurationSchemesError> =
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))
}
}
pub async fn get_all_field_configurations(
configuration: &configuration::Configuration,
params: GetAllFieldConfigurationsParams,
) -> Result<models::PageBeanFieldConfiguration, Error<GetAllFieldConfigurationsError>> {
let start_at = params.start_at;
let max_results = params.max_results;
let id = params.id;
let is_default = params.is_default;
let local_var_client = &configuration.client;
let local_var_uri_str = format!("{}/rest/api/3/fieldconfiguration", 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) = id {
local_var_req_builder = local_var_req_builder.query(&[(
"id",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]);
}
if let Some(ref local_var_str) = is_default {
local_var_req_builder =
local_var_req_builder.query(&[("isDefault", &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<GetAllFieldConfigurationsError> =
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))
}
}
pub async fn get_field_configuration_items(
configuration: &configuration::Configuration,
params: GetFieldConfigurationItemsParams,
) -> Result<models::PageBeanFieldConfigurationItem, Error<GetFieldConfigurationItemsError>> {
let id = params.id;
let start_at = params.start_at;
let max_results = params.max_results;
let local_var_client = &configuration.client;
let local_var_uri_str = format!(
"{}/rest/api/3/fieldconfiguration/{id}/fields",
configuration.base_path,
id = id
);
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_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<GetFieldConfigurationItemsError> =
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))
}
}
pub async fn get_field_configuration_scheme_mappings(
configuration: &configuration::Configuration,
params: GetFieldConfigurationSchemeMappingsParams,
) -> Result<
models::PageBeanFieldConfigurationIssueTypeItem,
Error<GetFieldConfigurationSchemeMappingsError>,
> {
let start_at = params.start_at;
let max_results = params.max_results;
let field_configuration_scheme_id = params.field_configuration_scheme_id;
let local_var_client = &configuration.client;
let local_var_uri_str = format!(
"{}/rest/api/3/fieldconfigurationscheme/mapping",
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) = field_configuration_scheme_id {
local_var_req_builder = local_var_req_builder.query(&[(
"fieldConfigurationSchemeId",
&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<GetFieldConfigurationSchemeMappingsError> =
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))
}
}
pub async fn get_field_configuration_scheme_project_mapping(
configuration: &configuration::Configuration,
params: GetFieldConfigurationSchemeProjectMappingParams,
) -> Result<
models::PageBeanFieldConfigurationSchemeProjects,
Error<GetFieldConfigurationSchemeProjectMappingError>,
> {
let project_id = params.project_id;
let start_at = params.start_at;
let max_results = params.max_results;
let local_var_client = &configuration.client;
let local_var_uri_str = format!(
"{}/rest/api/3/fieldconfigurationscheme/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) = 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())]);
}
local_var_req_builder = local_var_req_builder.query(&[(
"projectId",
&project_id
.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<GetFieldConfigurationSchemeProjectMappingError> =
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))
}
}