use reqwest;
use crate::apis::ResponseContent;
use super::{Error, configuration};
#[derive(Clone, Debug, Default)]
pub struct AddActorUsersParams {
pub project_id_or_key: String,
pub id: i64,
pub actors_map: crate::models::ActorsMap
}
#[derive(Clone, Debug, Default)]
pub struct AddProjectRoleActorsToRoleParams {
pub id: i64,
pub actor_input_bean: crate::models::ActorInputBean
}
#[derive(Clone, Debug, Default)]
pub struct DeleteActorParams {
pub project_id_or_key: String,
pub id: i64,
pub user: Option<String>,
pub group: Option<String>
}
#[derive(Clone, Debug, Default)]
pub struct DeleteProjectRoleActorsFromRoleParams {
pub id: i64,
pub user: Option<String>,
pub group: Option<String>
}
#[derive(Clone, Debug, Default)]
pub struct GetProjectRoleActorsForRoleParams {
pub id: i64
}
#[derive(Clone, Debug, Default)]
pub struct SetActorsParams {
pub project_id_or_key: String,
pub id: i64,
pub project_role_actors_update_bean: crate::models::ProjectRoleActorsUpdateBean
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AddActorUsersSuccess {
Status200(crate::models::ProjectRole),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AddProjectRoleActorsToRoleSuccess {
Status200(crate::models::ProjectRole),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteActorSuccess {
Status204(),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteProjectRoleActorsFromRoleSuccess {
Status200(crate::models::ProjectRole),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetProjectRoleActorsForRoleSuccess {
Status200(crate::models::ProjectRole),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SetActorsSuccess {
Status200(crate::models::ProjectRole),
UnknownValue(serde_json::Value),
}
#[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<ResponseContent<AddActorUsersSuccess>, Error<AddActorUsersError>> {
let local_var_configuration = configuration;
let project_id_or_key = params.project_id_or_key;
let id = params.id;
let actors_map = params.actors_map;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/rest/api/2/project/{projectIdOrKey}/role/{id}", local_var_configuration.base_path, projectIdOrKey=crate::apis::urlencode(project_id_or_key), id=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(&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() {
let local_var_entity: Option<AddActorUsersSuccess> = 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<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<ResponseContent<AddProjectRoleActorsToRoleSuccess>, Error<AddProjectRoleActorsToRoleError>> {
let local_var_configuration = configuration;
let id = params.id;
let actor_input_bean = params.actor_input_bean;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/rest/api/2/role/{id}/actors", local_var_configuration.base_path, id=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(&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() {
let local_var_entity: Option<AddProjectRoleActorsToRoleSuccess> = 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<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<ResponseContent<DeleteActorSuccess>, Error<DeleteActorError>> {
let local_var_configuration = configuration;
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 = &local_var_configuration.client;
let local_var_uri_str = format!("{}/rest/api/2/project/{projectIdOrKey}/role/{id}", local_var_configuration.base_path, projectIdOrKey=crate::apis::urlencode(project_id_or_key), id=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_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) = 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<DeleteActorSuccess> = 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<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<ResponseContent<DeleteProjectRoleActorsFromRoleSuccess>, Error<DeleteProjectRoleActorsFromRoleError>> {
let local_var_configuration = configuration;
let id = params.id;
let user = params.user;
let group = params.group;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/rest/api/2/role/{id}/actors", local_var_configuration.base_path, id=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_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) = 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<DeleteProjectRoleActorsFromRoleSuccess> = 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<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<ResponseContent<GetProjectRoleActorsForRoleSuccess>, Error<GetProjectRoleActorsForRoleError>> {
let local_var_configuration = configuration;
let id = params.id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/rest/api/2/role/{id}/actors", local_var_configuration.base_path, id=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<GetProjectRoleActorsForRoleSuccess> = 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<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<ResponseContent<SetActorsSuccess>, Error<SetActorsError>> {
let local_var_configuration = configuration;
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 = &local_var_configuration.client;
let local_var_uri_str = format!("{}/rest/api/2/project/{projectIdOrKey}/role/{id}", local_var_configuration.base_path, projectIdOrKey=crate::apis::urlencode(project_id_or_key), id=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(&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() {
let local_var_entity: Option<SetActorsSuccess> = 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<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))
}
}