use super::{configuration, Error};
use crate::gen::apis::ResponseContent;
use crate::gen::models;
#[derive(Clone, Debug)]
pub struct AddActorUsersParams {
pub project_id_or_key: String,
pub id: i64,
pub actors_map: models::ActorsMap,
}
#[derive(Clone, Debug)]
pub struct AddProjectRoleActorsToRoleParams {
pub id: i64,
pub actor_input_bean: models::ActorInputBean,
}
#[derive(Clone, Debug)]
pub struct DeleteActorParams {
pub project_id_or_key: String,
pub id: i64,
pub user: Option<String>,
pub group: Option<String>,
}
#[derive(Clone, Debug)]
pub struct DeleteProjectRoleActorsFromRoleParams {
pub id: i64,
pub user: Option<String>,
pub group: Option<String>,
}
#[derive(Clone, Debug)]
pub struct GetProjectRoleActorsForRoleParams {
pub id: i64,
}
#[derive(Clone, Debug)]
pub struct SetActorsParams {
pub project_id_or_key: String,
pub id: i64,
pub project_role_actors_update_bean: models::ProjectRoleActorsUpdateBean,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AddActorUsersError {
Status400(),
Status401(),
Status404(),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AddProjectRoleActorsToRoleError {
Status400(),
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteActorError {
Status400(),
Status404(),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteProjectRoleActorsFromRoleError {
Status400(),
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetProjectRoleActorsForRoleError {
Status400(),
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SetActorsError {
Status400(),
Status401(),
Status404(),
UnknownValue(serde_json::Value),
}
pub async fn add_actor_users(
configuration: &configuration::Configuration,
params: AddActorUsersParams,
) -> Result<models::ProjectRole, Error<AddActorUsersError>> {
let project_id_or_key = params.project_id_or_key;
let id = params.id;
let actors_map = params.actors_map;
let local_var_client = &configuration.client;
let local_var_uri_str = format!(
"{}/rest/api/3/project/{projectIdOrKey}/role/{id}",
configuration.base_path,
projectIdOrKey = crate::gen::apis::urlencode(project_id_or_key),
id = id
);
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(&actors_map);
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<AddActorUsersError> =
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 add_project_role_actors_to_role(
configuration: &configuration::Configuration,
params: AddProjectRoleActorsToRoleParams,
) -> Result<models::ProjectRole, Error<AddProjectRoleActorsToRoleError>> {
let id = params.id;
let actor_input_bean = params.actor_input_bean;
let local_var_client = &configuration.client;
let local_var_uri_str = format!(
"{}/rest/api/3/role/{id}/actors",
configuration.base_path,
id = id
);
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(&actor_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<AddProjectRoleActorsToRoleError> =
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 delete_actor(
configuration: &configuration::Configuration,
params: DeleteActorParams,
) -> Result<(), Error<DeleteActorError>> {
let project_id_or_key = params.project_id_or_key;
let id = params.id;
let user = params.user;
let group = params.group;
let local_var_client = &configuration.client;
let local_var_uri_str = format!(
"{}/rest/api/3/project/{projectIdOrKey}/role/{id}",
configuration.base_path,
projectIdOrKey = crate::gen::apis::urlencode(project_id_or_key),
id = id
);
let mut local_var_req_builder = local_var_client.delete(local_var_uri_str.as_str());
if let Some(ref local_var_str) = user {
local_var_req_builder =
local_var_req_builder.query(&[("user", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = group {
local_var_req_builder =
local_var_req_builder.query(&[("group", &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<DeleteActorError> =
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 delete_project_role_actors_from_role(
configuration: &configuration::Configuration,
params: DeleteProjectRoleActorsFromRoleParams,
) -> Result<models::ProjectRole, Error<DeleteProjectRoleActorsFromRoleError>> {
let id = params.id;
let user = params.user;
let group = params.group;
let local_var_client = &configuration.client;
let local_var_uri_str = format!(
"{}/rest/api/3/role/{id}/actors",
configuration.base_path,
id = id
);
let mut local_var_req_builder = local_var_client.delete(local_var_uri_str.as_str());
if let Some(ref local_var_str) = user {
local_var_req_builder =
local_var_req_builder.query(&[("user", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = group {
local_var_req_builder =
local_var_req_builder.query(&[("group", &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<DeleteProjectRoleActorsFromRoleError> =
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_project_role_actors_for_role(
configuration: &configuration::Configuration,
params: GetProjectRoleActorsForRoleParams,
) -> Result<models::ProjectRole, Error<GetProjectRoleActorsForRoleError>> {
let id = params.id;
let local_var_client = &configuration.client;
let local_var_uri_str = format!(
"{}/rest/api/3/role/{id}/actors",
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_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<GetProjectRoleActorsForRoleError> =
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 set_actors(
configuration: &configuration::Configuration,
params: SetActorsParams,
) -> Result<models::ProjectRole, Error<SetActorsError>> {
let project_id_or_key = params.project_id_or_key;
let id = params.id;
let project_role_actors_update_bean = params.project_role_actors_update_bean;
let local_var_client = &configuration.client;
let local_var_uri_str = format!(
"{}/rest/api/3/project/{projectIdOrKey}/role/{id}",
configuration.base_path,
projectIdOrKey = crate::gen::apis::urlencode(project_id_or_key),
id = id
);
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(&project_role_actors_update_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<SetActorsError> =
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))
}
}