use reqwest;
use serde::{Deserialize, Serialize, de::Error as _};
use crate::{apis::ResponseContent, models};
use super::{Error, configuration, ContentType};
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ClusterHaArmHaError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ClusterHaCreateGroupsError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ClusterHaCreateResourcesError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ClusterHaCreateRuleError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ClusterHaDeleteGroupsError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ClusterHaDeleteResourcesError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ClusterHaDeleteRuleError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ClusterHaDisarmHaError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ClusterHaGetGroupsError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ClusterHaGetHaError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ClusterHaGetResourcesError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ClusterHaGetRulesError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ClusterHaGetStatusError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ClusterHaManagerStatusError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ClusterHaMigrateError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ClusterHaReadGetGroupsError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ClusterHaReadGetResourcesError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ClusterHaReadRuleError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ClusterHaRelocateError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ClusterHaStatusError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ClusterHaUpdateGroupsError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ClusterHaUpdateResourcesError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ClusterHaUpdateRuleError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
pub async fn cluster_ha_arm_ha(configuration: &configuration::Configuration, ) -> Result<models::ClusterHaArmHaResponse, Error<ClusterHaArmHaError>> {
let uri_str = format!("{}/cluster/ha/status/arm-ha", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterHaArmHaResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ClusterHaArmHaResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ClusterHaArmHaError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn cluster_ha_create_groups(configuration: &configuration::Configuration, cluster_ha_create_groups_request: models::ClusterHaCreateGroupsRequest) -> Result<models::ClusterHaCreateGroupsResponse, Error<ClusterHaCreateGroupsError>> {
let p_body_cluster_ha_create_groups_request = cluster_ha_create_groups_request;
let uri_str = format!("{}/cluster/ha/groups", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
req_builder = req_builder.json(&p_body_cluster_ha_create_groups_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterHaCreateGroupsResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ClusterHaCreateGroupsResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ClusterHaCreateGroupsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn cluster_ha_create_resources(configuration: &configuration::Configuration, cluster_ha_create_resources_request: models::ClusterHaCreateResourcesRequest) -> Result<models::ClusterHaCreateResourcesResponse, Error<ClusterHaCreateResourcesError>> {
let p_body_cluster_ha_create_resources_request = cluster_ha_create_resources_request;
let uri_str = format!("{}/cluster/ha/resources", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
req_builder = req_builder.json(&p_body_cluster_ha_create_resources_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterHaCreateResourcesResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ClusterHaCreateResourcesResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ClusterHaCreateResourcesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn cluster_ha_create_rule(configuration: &configuration::Configuration, cluster_ha_create_rule_request: models::ClusterHaCreateRuleRequest) -> Result<models::ClusterHaCreateRuleResponse, Error<ClusterHaCreateRuleError>> {
let p_body_cluster_ha_create_rule_request = cluster_ha_create_rule_request;
let uri_str = format!("{}/cluster/ha/rules", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
req_builder = req_builder.json(&p_body_cluster_ha_create_rule_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterHaCreateRuleResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ClusterHaCreateRuleResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ClusterHaCreateRuleError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn cluster_ha_delete_groups(configuration: &configuration::Configuration, group: &str) -> Result<models::ClusterHaDeleteGroupsResponse, Error<ClusterHaDeleteGroupsError>> {
let p_path_group = group;
let uri_str = format!("{}/cluster/ha/groups/{group}", configuration.base_path, group=crate::apis::urlencode(p_path_group));
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterHaDeleteGroupsResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ClusterHaDeleteGroupsResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ClusterHaDeleteGroupsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn cluster_ha_delete_resources(configuration: &configuration::Configuration, sid: &str, purge: Option<&str>) -> Result<models::ClusterHaDeleteResourcesResponse, Error<ClusterHaDeleteResourcesError>> {
let p_path_sid = sid;
let p_query_purge = purge;
let uri_str = format!("{}/cluster/ha/resources/{sid}", configuration.base_path, sid=crate::apis::urlencode(p_path_sid));
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref param_value) = p_query_purge {
req_builder = req_builder.query(&[("purge", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterHaDeleteResourcesResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ClusterHaDeleteResourcesResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ClusterHaDeleteResourcesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn cluster_ha_delete_rule(configuration: &configuration::Configuration, rule: &str) -> Result<models::ClusterHaDeleteRuleResponse, Error<ClusterHaDeleteRuleError>> {
let p_path_rule = rule;
let uri_str = format!("{}/cluster/ha/rules/{rule}", configuration.base_path, rule=crate::apis::urlencode(p_path_rule));
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterHaDeleteRuleResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ClusterHaDeleteRuleResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ClusterHaDeleteRuleError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn cluster_ha_disarm_ha(configuration: &configuration::Configuration, cluster_ha_disarm_ha_request: models::ClusterHaDisarmHaRequest) -> Result<models::ClusterHaDisarmHaResponse, Error<ClusterHaDisarmHaError>> {
let p_body_cluster_ha_disarm_ha_request = cluster_ha_disarm_ha_request;
let uri_str = format!("{}/cluster/ha/status/disarm-ha", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
req_builder = req_builder.json(&p_body_cluster_ha_disarm_ha_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterHaDisarmHaResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ClusterHaDisarmHaResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ClusterHaDisarmHaError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn cluster_ha_get_groups(configuration: &configuration::Configuration, ) -> Result<models::ClusterHaGetGroupsResponse, Error<ClusterHaGetGroupsError>> {
let uri_str = format!("{}/cluster/ha/groups", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterHaGetGroupsResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ClusterHaGetGroupsResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ClusterHaGetGroupsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn cluster_ha_get_ha(configuration: &configuration::Configuration, ) -> Result<models::ClusterHaGetHaResponse, Error<ClusterHaGetHaError>> {
let uri_str = format!("{}/cluster/ha", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterHaGetHaResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ClusterHaGetHaResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ClusterHaGetHaError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn cluster_ha_get_resources(configuration: &configuration::Configuration, r#type: Option<models::PveClusterHaTypeTypeEnum>) -> Result<models::ClusterHaGetResourcesResponse, Error<ClusterHaGetResourcesError>> {
let p_query_type = r#type;
let uri_str = format!("{}/cluster/ha/resources", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_type {
req_builder = req_builder.query(&[("type", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterHaGetResourcesResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ClusterHaGetResourcesResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ClusterHaGetResourcesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn cluster_ha_get_rules(configuration: &configuration::Configuration, resource: Option<&str>, r#type: Option<models::PveCauseEnum>) -> Result<models::ClusterHaGetRulesResponse, Error<ClusterHaGetRulesError>> {
let p_query_resource = resource;
let p_query_type = r#type;
let uri_str = format!("{}/cluster/ha/rules", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_resource {
req_builder = req_builder.query(&[("resource", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_type {
req_builder = req_builder.query(&[("type", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterHaGetRulesResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ClusterHaGetRulesResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ClusterHaGetRulesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn cluster_ha_get_status(configuration: &configuration::Configuration, ) -> Result<models::ClusterHaGetStatusResponse, Error<ClusterHaGetStatusError>> {
let uri_str = format!("{}/cluster/ha/status", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterHaGetStatusResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ClusterHaGetStatusResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ClusterHaGetStatusError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn cluster_ha_manager_status(configuration: &configuration::Configuration, ) -> Result<models::ClusterHaManagerStatusResponse, Error<ClusterHaManagerStatusError>> {
let uri_str = format!("{}/cluster/ha/status/manager_status", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterHaManagerStatusResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ClusterHaManagerStatusResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ClusterHaManagerStatusError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn cluster_ha_migrate(configuration: &configuration::Configuration, sid: &str, cluster_ha_migrate_request: models::ClusterHaMigrateRequest) -> Result<models::ClusterHaMigrateResponse, Error<ClusterHaMigrateError>> {
let p_path_sid = sid;
let p_body_cluster_ha_migrate_request = cluster_ha_migrate_request;
let uri_str = format!("{}/cluster/ha/resources/{sid}/migrate", configuration.base_path, sid=crate::apis::urlencode(p_path_sid));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
req_builder = req_builder.json(&p_body_cluster_ha_migrate_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterHaMigrateResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ClusterHaMigrateResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ClusterHaMigrateError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn cluster_ha_read_get_groups(configuration: &configuration::Configuration, group: &str) -> Result<models::ClusterHaReadGetGroupsResponse, Error<ClusterHaReadGetGroupsError>> {
let p_path_group = group;
let uri_str = format!("{}/cluster/ha/groups/{group}", configuration.base_path, group=crate::apis::urlencode(p_path_group));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterHaReadGetGroupsResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ClusterHaReadGetGroupsResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ClusterHaReadGetGroupsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn cluster_ha_read_get_resources(configuration: &configuration::Configuration, sid: &str) -> Result<models::ClusterHaReadGetResourcesResponse, Error<ClusterHaReadGetResourcesError>> {
let p_path_sid = sid;
let uri_str = format!("{}/cluster/ha/resources/{sid}", configuration.base_path, sid=crate::apis::urlencode(p_path_sid));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterHaReadGetResourcesResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ClusterHaReadGetResourcesResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ClusterHaReadGetResourcesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn cluster_ha_read_rule(configuration: &configuration::Configuration, rule: &str) -> Result<models::ClusterHaReadRuleResponse, Error<ClusterHaReadRuleError>> {
let p_path_rule = rule;
let uri_str = format!("{}/cluster/ha/rules/{rule}", configuration.base_path, rule=crate::apis::urlencode(p_path_rule));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterHaReadRuleResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ClusterHaReadRuleResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ClusterHaReadRuleError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn cluster_ha_relocate(configuration: &configuration::Configuration, sid: &str, cluster_ha_migrate_request: models::ClusterHaMigrateRequest) -> Result<models::ClusterHaRelocateResponse, Error<ClusterHaRelocateError>> {
let p_path_sid = sid;
let p_body_cluster_ha_migrate_request = cluster_ha_migrate_request;
let uri_str = format!("{}/cluster/ha/resources/{sid}/relocate", configuration.base_path, sid=crate::apis::urlencode(p_path_sid));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
req_builder = req_builder.json(&p_body_cluster_ha_migrate_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterHaRelocateResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ClusterHaRelocateResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ClusterHaRelocateError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn cluster_ha_status(configuration: &configuration::Configuration, ) -> Result<models::ClusterHaStatusResponse, Error<ClusterHaStatusError>> {
let uri_str = format!("{}/cluster/ha/status/current", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterHaStatusResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ClusterHaStatusResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ClusterHaStatusError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn cluster_ha_update_groups(configuration: &configuration::Configuration, group: &str, cluster_ha_update_groups_request: Option<models::ClusterHaUpdateGroupsRequest>) -> Result<models::ClusterHaUpdateGroupsResponse, Error<ClusterHaUpdateGroupsError>> {
let p_path_group = group;
let p_body_cluster_ha_update_groups_request = cluster_ha_update_groups_request;
let uri_str = format!("{}/cluster/ha/groups/{group}", configuration.base_path, group=crate::apis::urlencode(p_path_group));
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
req_builder = req_builder.json(&p_body_cluster_ha_update_groups_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterHaUpdateGroupsResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ClusterHaUpdateGroupsResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ClusterHaUpdateGroupsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn cluster_ha_update_resources(configuration: &configuration::Configuration, sid: &str, cluster_ha_update_resources_request: Option<models::ClusterHaUpdateResourcesRequest>) -> Result<models::ClusterHaUpdateResourcesResponse, Error<ClusterHaUpdateResourcesError>> {
let p_path_sid = sid;
let p_body_cluster_ha_update_resources_request = cluster_ha_update_resources_request;
let uri_str = format!("{}/cluster/ha/resources/{sid}", configuration.base_path, sid=crate::apis::urlencode(p_path_sid));
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
req_builder = req_builder.json(&p_body_cluster_ha_update_resources_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterHaUpdateResourcesResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ClusterHaUpdateResourcesResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ClusterHaUpdateResourcesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn cluster_ha_update_rule(configuration: &configuration::Configuration, rule: &str, cluster_ha_update_rule_request: models::ClusterHaUpdateRuleRequest) -> Result<models::ClusterHaUpdateRuleResponse, Error<ClusterHaUpdateRuleError>> {
let p_path_rule = rule;
let p_body_cluster_ha_update_rule_request = cluster_ha_update_rule_request;
let uri_str = format!("{}/cluster/ha/rules/{rule}", configuration.base_path, rule=crate::apis::urlencode(p_path_rule));
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
req_builder = req_builder.json(&p_body_cluster_ha_update_rule_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterHaUpdateRuleResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ClusterHaUpdateRuleResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ClusterHaUpdateRuleError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}