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 InstanceAccessError {
Status400(models::InstancesPut400Response),
Status403(models::InstancesGet403Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstanceBackupDeleteError {
Status400(models::InstancesPut400Response),
Status403(models::InstancesGet403Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstanceBackupExportError {
Status403(models::InstancesGet403Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstanceBackupGetError {
Status403(models::InstancesGet403Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstanceBackupPostError {
Status400(models::InstancesPut400Response),
Status403(models::InstancesGet403Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstanceBackupsGetError {
Status403(models::InstancesGet403Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstanceBackupsGetRecursion1Error {
Status403(models::InstancesGet403Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstanceBackupsPostError {
Status400(models::InstancesPut400Response),
Status403(models::InstancesGet403Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstanceBitmapsPostError {
Status400(models::InstancesPut400Response),
Status403(models::InstancesGet403Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstanceConsoleDeleteError {
Status400(models::InstancesPut400Response),
Status403(models::InstancesGet403Response),
Status404(models::InstanceConsoleGet404Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstanceConsoleGetError {
Status400(models::InstancesPut400Response),
Status403(models::InstancesGet403Response),
Status404(models::InstanceConsoleGet404Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstanceConsolePostError {
Status400(models::InstancesPut400Response),
Status403(models::InstancesGet403Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstanceDebugMemoryGetError {
Status400(models::InstancesPut400Response),
Status403(models::InstancesGet403Response),
Status404(models::InstanceConsoleGet404Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstanceDebugRepairPostError {
Status400(models::InstancesPut400Response),
Status403(models::InstancesGet403Response),
Status404(models::InstanceConsoleGet404Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstanceDeleteError {
Status400(models::InstancesPut400Response),
Status403(models::InstancesGet403Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstanceExecOutputDeleteError {
Status400(models::InstancesPut400Response),
Status403(models::InstancesGet403Response),
Status404(models::InstanceConsoleGet404Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstanceExecOutputGetError {
Status400(models::InstancesPut400Response),
Status403(models::InstancesGet403Response),
Status404(models::InstanceConsoleGet404Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstanceExecOutputsGetError {
Status403(models::InstancesGet403Response),
Status404(models::InstanceConsoleGet404Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstanceExecPostError {
Status400(models::InstancesPut400Response),
Status403(models::InstancesGet403Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstanceFilesDeleteError {
Status400(models::InstancesPut400Response),
Status403(models::InstancesGet403Response),
Status404(models::InstanceConsoleGet404Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstanceFilesGetError {
Status400(models::InstancesPut400Response),
Status403(models::InstancesGet403Response),
Status404(models::InstanceConsoleGet404Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstanceFilesHeadError {
Status400(models::InstancesPut400Response),
Status403(models::InstancesGet403Response),
Status404(models::InstanceConsoleGet404Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstanceFilesPostError {
Status400(models::InstancesPut400Response),
Status403(models::InstancesGet403Response),
Status404(models::InstanceConsoleGet404Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstanceGetError {
Status403(models::InstancesGet403Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstanceGetRecursion1Error {
Status403(models::InstancesGet403Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstanceLogDeleteError {
Status400(models::InstancesPut400Response),
Status403(models::InstancesGet403Response),
Status404(models::InstanceConsoleGet404Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstanceLogGetError {
Status400(models::InstancesPut400Response),
Status403(models::InstancesGet403Response),
Status404(models::InstanceConsoleGet404Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstanceLogsGetError {
Status403(models::InstancesGet403Response),
Status404(models::InstanceConsoleGet404Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstanceMetadataGetError {
Status403(models::InstancesGet403Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstanceMetadataPatchError {
Status400(models::InstancesPut400Response),
Status403(models::InstancesGet403Response),
Status412(models::InstanceMetadataPut412Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstanceMetadataPutError {
Status400(models::InstancesPut400Response),
Status403(models::InstancesGet403Response),
Status412(models::InstanceMetadataPut412Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstanceMetadataTemplatesDeleteError {
Status400(models::InstancesPut400Response),
Status403(models::InstancesGet403Response),
Status404(models::InstanceConsoleGet404Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstanceMetadataTemplatesGetError {
Status400(models::InstancesPut400Response),
Status403(models::InstancesGet403Response),
Status404(models::InstanceConsoleGet404Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstanceMetadataTemplatesPostError {
Status400(models::InstancesPut400Response),
Status403(models::InstancesGet403Response),
Status404(models::InstanceConsoleGet404Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancePatchError {
Status400(models::InstancesPut400Response),
Status403(models::InstancesGet403Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancePostError {
Status400(models::InstancesPut400Response),
Status403(models::InstancesGet403Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancePutError {
Status400(models::InstancesPut400Response),
Status403(models::InstancesGet403Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstanceRebuildPostError {
Status400(models::InstancesPut400Response),
Status403(models::InstancesGet403Response),
Status404(models::InstanceConsoleGet404Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstanceSftpError {
Status400(models::InstancesPut400Response),
Status403(models::InstancesGet403Response),
Status404(models::InstanceConsoleGet404Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstanceSnapshotDeleteError {
Status400(models::InstancesPut400Response),
Status403(models::InstancesGet403Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstanceSnapshotGetError {
Status403(models::InstancesGet403Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstanceSnapshotPatchError {
Status400(models::InstancesPut400Response),
Status403(models::InstancesGet403Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstanceSnapshotPostError {
Status400(models::InstancesPut400Response),
Status403(models::InstancesGet403Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstanceSnapshotPutError {
Status400(models::InstancesPut400Response),
Status403(models::InstancesGet403Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstanceSnapshotsGetError {
Status403(models::InstancesGet403Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstanceSnapshotsGetRecursion1Error {
Status403(models::InstancesGet403Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstanceSnapshotsPostError {
Status400(models::InstancesPut400Response),
Status403(models::InstancesGet403Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstanceStateGetError {
Status400(models::InstancesPut400Response),
Status403(models::InstancesGet403Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstanceStatePutError {
Status400(models::InstancesPut400Response),
Status403(models::InstancesGet403Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesGetError {
Status403(models::InstancesGet403Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesPostError {
Status400(models::InstancesPut400Response),
Status403(models::InstancesGet403Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesPutError {
Status400(models::InstancesPut400Response),
Status403(models::InstancesGet403Response),
Status500(models::InstancesGet500Response),
UnknownValue(serde_json::Value),
}
pub async fn instance_access(configuration: &configuration::Configuration, name: &str, project: Option<&str>) -> Result<models::InstanceAccess200Response, Error<InstanceAccessError>> {
let p_path_name = name;
let p_query_project = project;
let uri_str = format!("{}/1.0/instances/{name}/access", configuration.base_path, name=crate::apis::urlencode(p_path_name));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶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());
}
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::InstanceAccess200Response`"))),
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::InstanceAccess200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstanceAccessError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instance_backup_delete(configuration: &configuration::Configuration, name: &str, backup: &str, project: Option<&str>) -> Result<models::InstancesPut202Response, Error<InstanceBackupDeleteError>> {
let p_path_name = name;
let p_path_backup = backup;
let p_query_project = project;
let uri_str = format!("{}/1.0/instances/{name}/backups/{backup}", configuration.base_path, name=crate::apis::urlencode(p_path_name), backup=crate::apis::urlencode(p_path_backup));
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶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());
}
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::InstancesPut202Response`"))),
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::InstancesPut202Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstanceBackupDeleteError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instance_backup_export(configuration: &configuration::Configuration, name: &str, backup: &str, project: Option<&str>) -> Result<(), Error<InstanceBackupExportError>> {
let p_path_name = name;
let p_path_backup = backup;
let p_query_project = project;
let uri_str = format!("{}/1.0/instances/{name}/backups/{backup}/export", configuration.base_path, name=crate::apis::urlencode(p_path_name), backup=crate::apis::urlencode(p_path_backup));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶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());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<InstanceBackupExportError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instance_backup_get(configuration: &configuration::Configuration, name: &str, backup: &str, project: Option<&str>) -> Result<models::InstanceBackupGet200Response, Error<InstanceBackupGetError>> {
let p_path_name = name;
let p_path_backup = backup;
let p_query_project = project;
let uri_str = format!("{}/1.0/instances/{name}/backups/{backup}", configuration.base_path, name=crate::apis::urlencode(p_path_name), backup=crate::apis::urlencode(p_path_backup));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶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());
}
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::InstanceBackupGet200Response`"))),
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::InstanceBackupGet200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstanceBackupGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instance_backup_post(configuration: &configuration::Configuration, name: &str, backup: &str, project: Option<&str>, backup2: Option<models::InstanceBackupPost>) -> Result<models::InstancesPut202Response, Error<InstanceBackupPostError>> {
let p_path_name = name;
let p_path_backup = backup;
let p_query_project = project;
let p_body_backup = backup2;
let uri_str = format!("{}/1.0/instances/{name}/backups/{backup}", configuration.base_path, name=crate::apis::urlencode(p_path_name), backup=crate::apis::urlencode(p_path_backup));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶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());
}
req_builder = req_builder.json(&p_body_backup);
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::InstancesPut202Response`"))),
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::InstancesPut202Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstanceBackupPostError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instance_backups_get(configuration: &configuration::Configuration, name: &str, project: Option<&str>) -> Result<models::InstanceBackupsGet200Response, Error<InstanceBackupsGetError>> {
let p_path_name = name;
let p_query_project = project;
let uri_str = format!("{}/1.0/instances/{name}/backups", configuration.base_path, name=crate::apis::urlencode(p_path_name));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶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());
}
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::InstanceBackupsGet200Response`"))),
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::InstanceBackupsGet200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstanceBackupsGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instance_backups_get_recursion1(configuration: &configuration::Configuration, name: &str, project: Option<&str>) -> Result<models::InstanceBackupsGetRecursion1200Response, Error<InstanceBackupsGetRecursion1Error>> {
let p_path_name = name;
let p_query_project = project;
let uri_str = format!("{}/1.0/instances/{name}/backups?recursion=1", configuration.base_path, name=crate::apis::urlencode(p_path_name));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶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());
}
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::InstanceBackupsGetRecursion1200Response`"))),
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::InstanceBackupsGetRecursion1200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstanceBackupsGetRecursion1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instance_backups_post(configuration: &configuration::Configuration, name: &str, project: Option<&str>, backup: Option<models::InstanceBackupsPost>) -> Result<models::InstancesPut202Response, Error<InstanceBackupsPostError>> {
let p_path_name = name;
let p_query_project = project;
let p_body_backup = backup;
let uri_str = format!("{}/1.0/instances/{name}/backups", configuration.base_path, name=crate::apis::urlencode(p_path_name));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶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());
}
req_builder = req_builder.json(&p_body_backup);
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::InstancesPut202Response`"))),
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::InstancesPut202Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstanceBackupsPostError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instance_bitmaps_post(configuration: &configuration::Configuration, name: &str, project: Option<&str>, bitmap: Option<models::StorageVolumeBitmapsPost>) -> Result<models::InstancesPut202Response, Error<InstanceBitmapsPostError>> {
let p_path_name = name;
let p_query_project = project;
let p_body_bitmap = bitmap;
let uri_str = format!("{}/1.0/instances/{name}/bitmaps", configuration.base_path, name=crate::apis::urlencode(p_path_name));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶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());
}
req_builder = req_builder.json(&p_body_bitmap);
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::InstancesPut202Response`"))),
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::InstancesPut202Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstanceBitmapsPostError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instance_console_delete(configuration: &configuration::Configuration, name: &str, project: Option<&str>) -> Result<models::InstancePatch200Response, Error<InstanceConsoleDeleteError>> {
let p_path_name = name;
let p_query_project = project;
let uri_str = format!("{}/1.0/instances/{name}/console", configuration.base_path, name=crate::apis::urlencode(p_path_name));
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶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());
}
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::InstancePatch200Response`"))),
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::InstancePatch200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstanceConsoleDeleteError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instance_console_get(configuration: &configuration::Configuration, name: &str, project: Option<&str>, r#type: Option<&str>) -> Result<(), Error<InstanceConsoleGetError>> {
let p_path_name = name;
let p_query_project = project;
let p_query_type = r#type;
let uri_str = format!("{}/1.0/instances/{name}/console", configuration.base_path, name=crate::apis::urlencode(p_path_name));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶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());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<InstanceConsoleGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instance_console_post(configuration: &configuration::Configuration, name: &str, project: Option<&str>, console: Option<models::InstanceConsolePost>) -> Result<models::InstancesPut202Response, Error<InstanceConsolePostError>> {
let p_path_name = name;
let p_query_project = project;
let p_body_console = console;
let uri_str = format!("{}/1.0/instances/{name}/console", configuration.base_path, name=crate::apis::urlencode(p_path_name));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶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());
}
req_builder = req_builder.json(&p_body_console);
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::InstancesPut202Response`"))),
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::InstancesPut202Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstanceConsolePostError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instance_debug_memory_get(configuration: &configuration::Configuration, name: &str, project: Option<&str>, format: Option<&str>) -> Result<(), Error<InstanceDebugMemoryGetError>> {
let p_path_name = name;
let p_query_project = project;
let p_query_format = format;
let uri_str = format!("{}/1.0/instances/{name}/debug/memory", configuration.base_path, name=crate::apis::urlencode(p_path_name));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_format {
req_builder = req_builder.query(&[("format", ¶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());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<InstanceDebugMemoryGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instance_debug_repair_post(configuration: &configuration::Configuration, name: &str, project: Option<&str>, state: Option<models::InstanceDebugRepairPost>) -> Result<models::InstancePatch200Response, Error<InstanceDebugRepairPostError>> {
let p_path_name = name;
let p_query_project = project;
let p_body_state = state;
let uri_str = format!("{}/1.0/instances/{name}/debug/repair", configuration.base_path, name=crate::apis::urlencode(p_path_name));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶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());
}
req_builder = req_builder.json(&p_body_state);
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::InstancePatch200Response`"))),
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::InstancePatch200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstanceDebugRepairPostError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instance_delete(configuration: &configuration::Configuration, name: &str, project: Option<&str>) -> Result<models::InstancesPut202Response, Error<InstanceDeleteError>> {
let p_path_name = name;
let p_query_project = project;
let uri_str = format!("{}/1.0/instances/{name}", configuration.base_path, name=crate::apis::urlencode(p_path_name));
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶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());
}
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::InstancesPut202Response`"))),
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::InstancesPut202Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstanceDeleteError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instance_exec_output_delete(configuration: &configuration::Configuration, name: &str, filename: &str, project: Option<&str>) -> Result<models::InstancePatch200Response, Error<InstanceExecOutputDeleteError>> {
let p_path_name = name;
let p_path_filename = filename;
let p_query_project = project;
let uri_str = format!("{}/1.0/instances/{name}/logs/exec-output/{filename}", configuration.base_path, name=crate::apis::urlencode(p_path_name), filename=crate::apis::urlencode(p_path_filename));
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶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());
}
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::InstancePatch200Response`"))),
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::InstancePatch200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstanceExecOutputDeleteError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instance_exec_output_get(configuration: &configuration::Configuration, name: &str, filename: &str, project: Option<&str>) -> Result<(), Error<InstanceExecOutputGetError>> {
let p_path_name = name;
let p_path_filename = filename;
let p_query_project = project;
let uri_str = format!("{}/1.0/instances/{name}/logs/exec-output/{filename}", configuration.base_path, name=crate::apis::urlencode(p_path_name), filename=crate::apis::urlencode(p_path_filename));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶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());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<InstanceExecOutputGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instance_exec_outputs_get(configuration: &configuration::Configuration, name: &str, project: Option<&str>) -> Result<models::InstanceExecOutputsGet200Response, Error<InstanceExecOutputsGetError>> {
let p_path_name = name;
let p_query_project = project;
let uri_str = format!("{}/1.0/instances/{name}/logs/exec-output", configuration.base_path, name=crate::apis::urlencode(p_path_name));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶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());
}
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::InstanceExecOutputsGet200Response`"))),
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::InstanceExecOutputsGet200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstanceExecOutputsGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instance_exec_post(configuration: &configuration::Configuration, name: &str, project: Option<&str>, exec: Option<models::InstanceExecPost>) -> Result<models::InstancesPut202Response, Error<InstanceExecPostError>> {
let p_path_name = name;
let p_query_project = project;
let p_body_exec = exec;
let uri_str = format!("{}/1.0/instances/{name}/exec", configuration.base_path, name=crate::apis::urlencode(p_path_name));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶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());
}
req_builder = req_builder.json(&p_body_exec);
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::InstancesPut202Response`"))),
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::InstancesPut202Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstanceExecPostError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instance_files_delete(configuration: &configuration::Configuration, name: &str, path: Option<&str>, project: Option<&str>, x_incus_force: Option<&str>) -> Result<models::InstancePatch200Response, Error<InstanceFilesDeleteError>> {
let p_path_name = name;
let p_query_path = path;
let p_query_project = project;
let p_header_x_incus_force = x_incus_force;
let uri_str = format!("{}/1.0/instances/{name}/files", configuration.base_path, name=crate::apis::urlencode(p_path_name));
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref param_value) = p_query_path {
req_builder = req_builder.query(&[("path", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶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(param_value) = p_header_x_incus_force {
req_builder = req_builder.header("X-Incus-force", param_value.to_string());
}
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::InstancePatch200Response`"))),
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::InstancePatch200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstanceFilesDeleteError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instance_files_get(configuration: &configuration::Configuration, name: &str, path: Option<&str>, project: Option<&str>) -> Result<(), Error<InstanceFilesGetError>> {
let p_path_name = name;
let p_query_path = path;
let p_query_project = project;
let uri_str = format!("{}/1.0/instances/{name}/files", configuration.base_path, name=crate::apis::urlencode(p_path_name));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_path {
req_builder = req_builder.query(&[("path", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶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());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<InstanceFilesGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instance_files_head(configuration: &configuration::Configuration, name: &str, path: Option<&str>, project: Option<&str>) -> Result<(), Error<InstanceFilesHeadError>> {
let p_path_name = name;
let p_query_path = path;
let p_query_project = project;
let uri_str = format!("{}/1.0/instances/{name}/files", configuration.base_path, name=crate::apis::urlencode(p_path_name));
let mut req_builder = configuration.client.request(reqwest::Method::HEAD, &uri_str);
if let Some(ref param_value) = p_query_path {
req_builder = req_builder.query(&[("path", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶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());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<InstanceFilesHeadError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instance_files_post(configuration: &configuration::Configuration, name: &str, path: Option<&str>, project: Option<&str>, x_incus_uid: Option<&str>, x_incus_gid: Option<&str>, x_incus_mode: Option<&str>, x_incus_type: Option<&str>, x_incus_write: Option<&str>) -> Result<models::InstancePatch200Response, Error<InstanceFilesPostError>> {
let p_path_name = name;
let p_query_path = path;
let p_query_project = project;
let p_header_x_incus_uid = x_incus_uid;
let p_header_x_incus_gid = x_incus_gid;
let p_header_x_incus_mode = x_incus_mode;
let p_header_x_incus_type = x_incus_type;
let p_header_x_incus_write = x_incus_write;
let uri_str = format!("{}/1.0/instances/{name}/files", configuration.base_path, name=crate::apis::urlencode(p_path_name));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref param_value) = p_query_path {
req_builder = req_builder.query(&[("path", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶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(param_value) = p_header_x_incus_uid {
req_builder = req_builder.header("X-Incus-uid", param_value.to_string());
}
if let Some(param_value) = p_header_x_incus_gid {
req_builder = req_builder.header("X-Incus-gid", param_value.to_string());
}
if let Some(param_value) = p_header_x_incus_mode {
req_builder = req_builder.header("X-Incus-mode", param_value.to_string());
}
if let Some(param_value) = p_header_x_incus_type {
req_builder = req_builder.header("X-Incus-type", param_value.to_string());
}
if let Some(param_value) = p_header_x_incus_write {
req_builder = req_builder.header("X-Incus-write", param_value.to_string());
}
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::InstancePatch200Response`"))),
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::InstancePatch200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstanceFilesPostError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instance_get(configuration: &configuration::Configuration, name: &str, project: Option<&str>) -> Result<models::InstanceGet200Response, Error<InstanceGetError>> {
let p_path_name = name;
let p_query_project = project;
let uri_str = format!("{}/1.0/instances/{name}", configuration.base_path, name=crate::apis::urlencode(p_path_name));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶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());
}
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::InstanceGet200Response`"))),
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::InstanceGet200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstanceGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instance_get_recursion1(configuration: &configuration::Configuration, name: &str, project: Option<&str>) -> Result<models::InstanceGetRecursion1200Response, Error<InstanceGetRecursion1Error>> {
let p_path_name = name;
let p_query_project = project;
let uri_str = format!("{}/1.0/instances/{name}?recursion=1", configuration.base_path, name=crate::apis::urlencode(p_path_name));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶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());
}
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::InstanceGetRecursion1200Response`"))),
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::InstanceGetRecursion1200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstanceGetRecursion1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instance_log_delete(configuration: &configuration::Configuration, name: &str, filename: &str, project: Option<&str>) -> Result<models::InstancePatch200Response, Error<InstanceLogDeleteError>> {
let p_path_name = name;
let p_path_filename = filename;
let p_query_project = project;
let uri_str = format!("{}/1.0/instances/{name}/logs/{filename}", configuration.base_path, name=crate::apis::urlencode(p_path_name), filename=crate::apis::urlencode(p_path_filename));
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶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());
}
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::InstancePatch200Response`"))),
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::InstancePatch200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstanceLogDeleteError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instance_log_get(configuration: &configuration::Configuration, name: &str, filename: &str, project: Option<&str>) -> Result<(), Error<InstanceLogGetError>> {
let p_path_name = name;
let p_path_filename = filename;
let p_query_project = project;
let uri_str = format!("{}/1.0/instances/{name}/logs/{filename}", configuration.base_path, name=crate::apis::urlencode(p_path_name), filename=crate::apis::urlencode(p_path_filename));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶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());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<InstanceLogGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instance_logs_get(configuration: &configuration::Configuration, name: &str, project: Option<&str>) -> Result<models::InstanceLogsGet200Response, Error<InstanceLogsGetError>> {
let p_path_name = name;
let p_query_project = project;
let uri_str = format!("{}/1.0/instances/{name}/logs", configuration.base_path, name=crate::apis::urlencode(p_path_name));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶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());
}
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::InstanceLogsGet200Response`"))),
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::InstanceLogsGet200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstanceLogsGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instance_metadata_get(configuration: &configuration::Configuration, name: &str, project: Option<&str>) -> Result<models::InstanceMetadataGet200Response, Error<InstanceMetadataGetError>> {
let p_path_name = name;
let p_query_project = project;
let uri_str = format!("{}/1.0/instances/{name}/metadata", configuration.base_path, name=crate::apis::urlencode(p_path_name));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶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());
}
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::InstanceMetadataGet200Response`"))),
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::InstanceMetadataGet200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstanceMetadataGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instance_metadata_patch(configuration: &configuration::Configuration, name: &str, metadata: models::ImageMetadata, project: Option<&str>) -> Result<models::InstancePatch200Response, Error<InstanceMetadataPatchError>> {
let p_path_name = name;
let p_body_metadata = metadata;
let p_query_project = project;
let uri_str = format!("{}/1.0/instances/{name}/metadata", configuration.base_path, name=crate::apis::urlencode(p_path_name));
let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶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());
}
req_builder = req_builder.json(&p_body_metadata);
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::InstancePatch200Response`"))),
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::InstancePatch200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstanceMetadataPatchError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instance_metadata_put(configuration: &configuration::Configuration, name: &str, metadata: models::ImageMetadata, project: Option<&str>) -> Result<models::InstancePatch200Response, Error<InstanceMetadataPutError>> {
let p_path_name = name;
let p_body_metadata = metadata;
let p_query_project = project;
let uri_str = format!("{}/1.0/instances/{name}/metadata", configuration.base_path, name=crate::apis::urlencode(p_path_name));
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶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());
}
req_builder = req_builder.json(&p_body_metadata);
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::InstancePatch200Response`"))),
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::InstancePatch200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstanceMetadataPutError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instance_metadata_templates_delete(configuration: &configuration::Configuration, name: &str, path: Option<&str>, project: Option<&str>) -> Result<models::InstancePatch200Response, Error<InstanceMetadataTemplatesDeleteError>> {
let p_path_name = name;
let p_query_path = path;
let p_query_project = project;
let uri_str = format!("{}/1.0/instances/{name}/metadata/templates", configuration.base_path, name=crate::apis::urlencode(p_path_name));
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref param_value) = p_query_path {
req_builder = req_builder.query(&[("path", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶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());
}
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::InstancePatch200Response`"))),
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::InstancePatch200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstanceMetadataTemplatesDeleteError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instance_metadata_templates_get(configuration: &configuration::Configuration, name: &str, project: Option<&str>, path: Option<&str>) -> Result<(), Error<InstanceMetadataTemplatesGetError>> {
let p_path_name = name;
let p_query_project = project;
let p_query_path = path;
let uri_str = format!("{}/1.0/instances/{name}/metadata/templates", configuration.base_path, name=crate::apis::urlencode(p_path_name));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_path {
req_builder = req_builder.query(&[("path", ¶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());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<InstanceMetadataTemplatesGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instance_metadata_templates_post(configuration: &configuration::Configuration, name: &str, path: Option<&str>, project: Option<&str>) -> Result<models::InstancePatch200Response, Error<InstanceMetadataTemplatesPostError>> {
let p_path_name = name;
let p_query_path = path;
let p_query_project = project;
let uri_str = format!("{}/1.0/instances/{name}/metadata/templates", configuration.base_path, name=crate::apis::urlencode(p_path_name));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref param_value) = p_query_path {
req_builder = req_builder.query(&[("path", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶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());
}
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::InstancePatch200Response`"))),
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::InstancePatch200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstanceMetadataTemplatesPostError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instance_patch(configuration: &configuration::Configuration, name: &str, project: Option<&str>, instance: Option<models::InstancePut>) -> Result<models::InstancePatch200Response, Error<InstancePatchError>> {
let p_path_name = name;
let p_query_project = project;
let p_body_instance = instance;
let uri_str = format!("{}/1.0/instances/{name}", configuration.base_path, name=crate::apis::urlencode(p_path_name));
let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶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());
}
req_builder = req_builder.json(&p_body_instance);
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::InstancePatch200Response`"))),
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::InstancePatch200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancePatchError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instance_post(configuration: &configuration::Configuration, name: &str, project: Option<&str>, migration: Option<models::InstancePost>) -> Result<models::InstancesPut202Response, Error<InstancePostError>> {
let p_path_name = name;
let p_query_project = project;
let p_body_migration = migration;
let uri_str = format!("{}/1.0/instances/{name}", configuration.base_path, name=crate::apis::urlencode(p_path_name));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶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());
}
req_builder = req_builder.json(&p_body_migration);
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::InstancesPut202Response`"))),
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::InstancesPut202Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancePostError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instance_put(configuration: &configuration::Configuration, name: &str, project: Option<&str>, instance: Option<models::InstancePut>) -> Result<models::InstancesPut202Response, Error<InstancePutError>> {
let p_path_name = name;
let p_query_project = project;
let p_body_instance = instance;
let uri_str = format!("{}/1.0/instances/{name}", configuration.base_path, name=crate::apis::urlencode(p_path_name));
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶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());
}
req_builder = req_builder.json(&p_body_instance);
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::InstancesPut202Response`"))),
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::InstancesPut202Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancePutError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instance_rebuild_post(configuration: &configuration::Configuration, name: &str, instance: models::InstanceRebuildPost, project: Option<&str>) -> Result<models::InstancePatch200Response, Error<InstanceRebuildPostError>> {
let p_path_name = name;
let p_body_instance = instance;
let p_query_project = project;
let uri_str = format!("{}/1.0/instances/{name}/rebuild", configuration.base_path, name=crate::apis::urlencode(p_path_name));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶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());
}
req_builder = req_builder.json(&p_body_instance);
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::InstancePatch200Response`"))),
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::InstancePatch200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstanceRebuildPostError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instance_sftp(configuration: &configuration::Configuration, name: &str) -> Result<(), Error<InstanceSftpError>> {
let p_path_name = name;
let uri_str = format!("{}/1.0/instances/{name}/sftp", configuration.base_path, name=crate::apis::urlencode(p_path_name));
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());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<InstanceSftpError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instance_snapshot_delete(configuration: &configuration::Configuration, name: &str, snapshot: &str, project: Option<&str>) -> Result<models::InstancesPut202Response, Error<InstanceSnapshotDeleteError>> {
let p_path_name = name;
let p_path_snapshot = snapshot;
let p_query_project = project;
let uri_str = format!("{}/1.0/instances/{name}/snapshots/{snapshot}", configuration.base_path, name=crate::apis::urlencode(p_path_name), snapshot=crate::apis::urlencode(p_path_snapshot));
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶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());
}
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::InstancesPut202Response`"))),
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::InstancesPut202Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstanceSnapshotDeleteError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instance_snapshot_get(configuration: &configuration::Configuration, name: &str, snapshot: &str, project: Option<&str>) -> Result<models::InstanceSnapshotGet200Response, Error<InstanceSnapshotGetError>> {
let p_path_name = name;
let p_path_snapshot = snapshot;
let p_query_project = project;
let uri_str = format!("{}/1.0/instances/{name}/snapshots/{snapshot}", configuration.base_path, name=crate::apis::urlencode(p_path_name), snapshot=crate::apis::urlencode(p_path_snapshot));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶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());
}
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::InstanceSnapshotGet200Response`"))),
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::InstanceSnapshotGet200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstanceSnapshotGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instance_snapshot_patch(configuration: &configuration::Configuration, name: &str, snapshot: &str, project: Option<&str>, snapshot2: Option<models::InstanceSnapshotPut>) -> Result<models::InstancesPut202Response, Error<InstanceSnapshotPatchError>> {
let p_path_name = name;
let p_path_snapshot = snapshot;
let p_query_project = project;
let p_body_snapshot = snapshot2;
let uri_str = format!("{}/1.0/instances/{name}/snapshots/{snapshot}", configuration.base_path, name=crate::apis::urlencode(p_path_name), snapshot=crate::apis::urlencode(p_path_snapshot));
let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶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());
}
req_builder = req_builder.json(&p_body_snapshot);
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::InstancesPut202Response`"))),
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::InstancesPut202Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstanceSnapshotPatchError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instance_snapshot_post(configuration: &configuration::Configuration, name: &str, snapshot: &str, project: Option<&str>, snapshot2: Option<models::InstanceSnapshotPost>) -> Result<models::InstancesPut202Response, Error<InstanceSnapshotPostError>> {
let p_path_name = name;
let p_path_snapshot = snapshot;
let p_query_project = project;
let p_body_snapshot = snapshot2;
let uri_str = format!("{}/1.0/instances/{name}/snapshots/{snapshot}", configuration.base_path, name=crate::apis::urlencode(p_path_name), snapshot=crate::apis::urlencode(p_path_snapshot));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶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());
}
req_builder = req_builder.json(&p_body_snapshot);
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::InstancesPut202Response`"))),
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::InstancesPut202Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstanceSnapshotPostError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instance_snapshot_put(configuration: &configuration::Configuration, name: &str, snapshot: &str, project: Option<&str>, snapshot2: Option<models::InstanceSnapshotPut>) -> Result<models::InstancesPut202Response, Error<InstanceSnapshotPutError>> {
let p_path_name = name;
let p_path_snapshot = snapshot;
let p_query_project = project;
let p_body_snapshot = snapshot2;
let uri_str = format!("{}/1.0/instances/{name}/snapshots/{snapshot}", configuration.base_path, name=crate::apis::urlencode(p_path_name), snapshot=crate::apis::urlencode(p_path_snapshot));
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶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());
}
req_builder = req_builder.json(&p_body_snapshot);
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::InstancesPut202Response`"))),
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::InstancesPut202Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstanceSnapshotPutError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instance_snapshots_get(configuration: &configuration::Configuration, name: &str, project: Option<&str>) -> Result<models::InstanceSnapshotsGet200Response, Error<InstanceSnapshotsGetError>> {
let p_path_name = name;
let p_query_project = project;
let uri_str = format!("{}/1.0/instances/{name}/snapshots", configuration.base_path, name=crate::apis::urlencode(p_path_name));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶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());
}
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::InstanceSnapshotsGet200Response`"))),
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::InstanceSnapshotsGet200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstanceSnapshotsGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instance_snapshots_get_recursion1(configuration: &configuration::Configuration, name: &str, project: Option<&str>) -> Result<models::InstanceSnapshotsGetRecursion1200Response, Error<InstanceSnapshotsGetRecursion1Error>> {
let p_path_name = name;
let p_query_project = project;
let uri_str = format!("{}/1.0/instances/{name}/snapshots?recursion=1", configuration.base_path, name=crate::apis::urlencode(p_path_name));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶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());
}
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::InstanceSnapshotsGetRecursion1200Response`"))),
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::InstanceSnapshotsGetRecursion1200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstanceSnapshotsGetRecursion1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instance_snapshots_post(configuration: &configuration::Configuration, name: &str, project: Option<&str>, snapshot: Option<models::InstanceSnapshotsPost>) -> Result<models::InstancesPut202Response, Error<InstanceSnapshotsPostError>> {
let p_path_name = name;
let p_query_project = project;
let p_body_snapshot = snapshot;
let uri_str = format!("{}/1.0/instances/{name}/snapshots", configuration.base_path, name=crate::apis::urlencode(p_path_name));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶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());
}
req_builder = req_builder.json(&p_body_snapshot);
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::InstancesPut202Response`"))),
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::InstancesPut202Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstanceSnapshotsPostError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instance_state_get(configuration: &configuration::Configuration, name: &str, project: Option<&str>) -> Result<models::InstanceStateGet200Response, Error<InstanceStateGetError>> {
let p_path_name = name;
let p_query_project = project;
let uri_str = format!("{}/1.0/instances/{name}/state", configuration.base_path, name=crate::apis::urlencode(p_path_name));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶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());
}
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::InstanceStateGet200Response`"))),
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::InstanceStateGet200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstanceStateGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instance_state_put(configuration: &configuration::Configuration, name: &str, project: Option<&str>, state: Option<models::InstanceStatePut>) -> Result<models::InstancesPut202Response, Error<InstanceStatePutError>> {
let p_path_name = name;
let p_query_project = project;
let p_body_state = state;
let uri_str = format!("{}/1.0/instances/{name}/state", configuration.base_path, name=crate::apis::urlencode(p_path_name));
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶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());
}
req_builder = req_builder.json(&p_body_state);
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::InstancesPut202Response`"))),
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::InstancesPut202Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstanceStatePutError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instances_get(configuration: &configuration::Configuration, project: Option<&str>, filter: Option<&str>, all_projects: Option<bool>) -> Result<models::InstancesGet200Response, Error<InstancesGetError>> {
let p_query_project = project;
let p_query_filter = filter;
let p_query_all_projects = all_projects;
let uri_str = format!("{}/1.0/instances", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_filter {
req_builder = req_builder.query(&[("filter", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_all_projects {
req_builder = req_builder.query(&[("all-projects", ¶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());
}
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::InstancesGet200Response`"))),
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::InstancesGet200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instances_post(configuration: &configuration::Configuration, project: Option<&str>, target: Option<&str>) -> Result<models::InstancesPut202Response, Error<InstancesPostError>> {
let p_query_project = project;
let p_query_target = target;
let uri_str = format!("{}/1.0/instances", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_target {
req_builder = req_builder.query(&[("target", ¶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());
}
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::InstancesPut202Response`"))),
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::InstancesPut202Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesPostError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn instances_put(configuration: &configuration::Configuration, project: Option<&str>, state: Option<models::InstancesPut>) -> Result<models::InstancesPut202Response, Error<InstancesPutError>> {
let p_query_project = project;
let p_body_state = state;
let uri_str = format!("{}/1.0/instances", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref param_value) = p_query_project {
req_builder = req_builder.query(&[("project", ¶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());
}
req_builder = req_builder.json(&p_body_state);
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::InstancesPut202Response`"))),
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::InstancesPut202Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesPutError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}