use super::{configuration, ContentType, Error};
use crate::{apis::ResponseContent, models};
use reqwest;
use serde::{de::Error as _, Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CloseInstanceError {
Status401(models::Error),
Status403(models::Error),
Status404(models::Error),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateInstanceError {
Status400(models::Error),
Status401(models::Error),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DiscoverInstancesError {
Status400(models::Error),
Status401(models::Error),
Status403(models::Error),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetActiveInstancesError {
Status400(models::Error),
Status401(models::Error),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetInstanceError {
Status401(models::Error),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetInstanceByShortNameError {
Status401(models::Error),
Status404(models::Error),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetInstanceCategoriesError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetInstanceCountError {
Status401(models::Error),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetInstanceVibesError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetRecentLocationsError {
Status401(models::Error),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetShortNameError {
Status401(models::Error),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateInstanceError {
Status400(models::Error),
Status401(models::Error),
Status403(models::Error),
Status404(models::Error),
UnknownValue(serde_json::Value),
}
pub async fn close_instance(
configuration: &configuration::Configuration,
world_id: &str,
instance_id: &str,
hard_close: Option<bool>,
closed_at: Option<chrono::DateTime<chrono::FixedOffset>>,
) -> Result<models::Instance, Error<CloseInstanceError>> {
let p_path_world_id = world_id;
let p_path_instance_id = instance_id;
let p_query_hard_close = hard_close;
let p_query_closed_at = closed_at;
let uri_str = format!(
"{}/instances/{worldId}:{instanceId}",
configuration.base_path,
worldId = crate::apis::urlencode(p_path_world_id),
instanceId = crate::apis::urlencode(p_path_instance_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref param_value) = p_query_hard_close {
req_builder = req_builder.query(&[("hardClose", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_closed_at {
req_builder = req_builder.query(&[("closedAt", ¶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?;
if configuration.debug {
log::debug!("close_instance returned: {content}");
}
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::Instance`"))),
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::Instance`")))),
}
} else {
let content = resp.text().await?;
if configuration.debug {
log::debug!("close_instance returned: {content}");
}
let entity: Option<CloseInstanceError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn create_instance(
configuration: &configuration::Configuration,
create_instance_request: models::CreateInstanceRequest,
) -> Result<models::Instance, Error<CreateInstanceError>> {
let p_body_create_instance_request = create_instance_request;
let uri_str = format!("{}/instances", configuration.base_path);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_body_create_instance_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
if configuration.debug {
log::debug!("create_instance returned: {content}");
}
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::Instance`"))),
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::Instance`")))),
}
} else {
let content = resp.text().await?;
if configuration.debug {
log::debug!("create_instance returned: {content}");
}
let entity: Option<CreateInstanceError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn discover_instances(
configuration: &configuration::Configuration,
n: Option<i32>,
region: Option<models::CreateInstanceRequestRegion>,
platform: Option<models::InstanceDiscoveryPlatform>,
world_id: Option<Vec<String>>,
group_id: Option<Vec<String>>,
vibe: Option<Vec<String>>,
category: Option<&str>,
any_world_tag: Option<Vec<String>>,
boost: Option<Vec<models::InstanceDiscoveryBoost>>,
group_hosted: Option<bool>,
max_occupants: Option<i32>,
min_occupants: Option<i32>,
min_spots_left: Option<i32>,
mode: Option<models::InstanceDiscoveryMode>,
not_world_tag: Option<Vec<String>>,
world_pool: Option<models::InstanceDiscoveryWorldPool>,
) -> Result<models::InstanceDiscovery, Error<DiscoverInstancesError>> {
let p_query_n = n;
let p_query_region = region;
let p_query_platform = platform;
let p_query_world_id = world_id;
let p_query_group_id = group_id;
let p_query_vibe = vibe;
let p_query_category = category;
let p_query_any_world_tag = any_world_tag;
let p_query_boost = boost;
let p_query_group_hosted = group_hosted;
let p_query_max_occupants = max_occupants;
let p_query_min_occupants = min_occupants;
let p_query_min_spots_left = min_spots_left;
let p_query_mode = mode;
let p_query_not_world_tag = not_world_tag;
let p_query_world_pool = world_pool;
let uri_str = format!("{}/instances/discover", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_n {
req_builder = req_builder.query(&[("n", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_region {
req_builder = req_builder.query(&[("region", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_platform {
req_builder = req_builder.query(&[("platform", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_world_id {
req_builder = match "multi" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("worldId".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"worldId",
¶m_value
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref param_value) = p_query_group_id {
req_builder = match "multi" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("groupId".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"groupId",
¶m_value
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref param_value) = p_query_vibe {
req_builder = match "multi" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("vibe".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"vibe",
¶m_value
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref param_value) = p_query_category {
req_builder = req_builder.query(&[("category", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_any_world_tag {
req_builder = match "multi" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("anyWorldTag".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"anyWorldTag",
¶m_value
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref param_value) = p_query_boost {
req_builder = match "multi" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("boost".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"boost",
¶m_value
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref param_value) = p_query_group_hosted {
req_builder = req_builder.query(&[("groupHosted", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_max_occupants {
req_builder = req_builder.query(&[("maxOccupants", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_min_occupants {
req_builder = req_builder.query(&[("minOccupants", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_min_spots_left {
req_builder = req_builder.query(&[("minSpotsLeft", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_mode {
req_builder = req_builder.query(&[("mode", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_not_world_tag {
req_builder = match "multi" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("notWorldTag".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"notWorldTag",
¶m_value
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref param_value) = p_query_world_pool {
req_builder = req_builder.query(&[("worldPool", ¶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?;
if configuration.debug {
log::debug!("discover_instances returned: {content}");
}
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::InstanceDiscovery`"))),
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::InstanceDiscovery`")))),
}
} else {
let content = resp.text().await?;
if configuration.debug {
log::debug!("discover_instances returned: {content}");
}
let entity: Option<DiscoverInstancesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_active_instances(
configuration: &configuration::Configuration,
n: Option<i32>,
offset: Option<i32>,
) -> Result<Vec<models::Instance>, Error<GetActiveInstancesError>> {
let p_query_n = n;
let p_query_offset = offset;
let uri_str = format!("{}/instances/active", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_n {
req_builder = req_builder.query(&[("n", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_offset {
req_builder = req_builder.query(&[("offset", ¶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?;
if configuration.debug {
log::debug!("get_active_instances returned: {content}");
}
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 `Vec<models::Instance>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::Instance>`")))),
}
} else {
let content = resp.text().await?;
if configuration.debug {
log::debug!("get_active_instances returned: {content}");
}
let entity: Option<GetActiveInstancesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_instance(
configuration: &configuration::Configuration,
world_id: &str,
instance_id: &str,
) -> Result<models::Instance, Error<GetInstanceError>> {
let p_path_world_id = world_id;
let p_path_instance_id = instance_id;
let uri_str = format!(
"{}/instances/{worldId}:{instanceId}",
configuration.base_path,
worldId = crate::apis::urlencode(p_path_world_id),
instanceId = crate::apis::urlencode(p_path_instance_id)
);
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();
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?;
if configuration.debug {
log::debug!("get_instance returned: {content}");
}
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::Instance`"))),
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::Instance`")))),
}
} else {
let content = resp.text().await?;
if configuration.debug {
log::debug!("get_instance returned: {content}");
}
let entity: Option<GetInstanceError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_instance_by_short_name(
configuration: &configuration::Configuration,
short_name: &str,
) -> Result<models::Instance, Error<GetInstanceByShortNameError>> {
let p_path_short_name = short_name;
let uri_str = format!(
"{}/instances/s/{shortName}",
configuration.base_path,
shortName = crate::apis::urlencode(p_path_short_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();
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?;
if configuration.debug {
log::debug!("get_instance_by_short_name returned: {content}");
}
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::Instance`"))),
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::Instance`")))),
}
} else {
let content = resp.text().await?;
if configuration.debug {
log::debug!("get_instance_by_short_name returned: {content}");
}
let entity: Option<GetInstanceByShortNameError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_instance_categories(
configuration: &configuration::Configuration,
) -> Result<Vec<models::InstanceCategory>, Error<GetInstanceCategoriesError>> {
let uri_str = format!("{}/instanceCategories", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
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?;
if configuration.debug {
log::debug!("get_instance_categories returned: {content}");
}
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 `Vec<models::InstanceCategory>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::InstanceCategory>`")))),
}
} else {
let content = resp.text().await?;
if configuration.debug {
log::debug!("get_instance_categories returned: {content}");
}
let entity: Option<GetInstanceCategoriesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_instance_count(
configuration: &configuration::Configuration,
) -> Result<models::InstanceCount, Error<GetInstanceCountError>> {
let uri_str = format!("{}/instances/count", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
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?;
if configuration.debug {
log::debug!("get_instance_count returned: {content}");
}
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::InstanceCount`"))),
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::InstanceCount`")))),
}
} else {
let content = resp.text().await?;
if configuration.debug {
log::debug!("get_instance_count returned: {content}");
}
let entity: Option<GetInstanceCountError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_instance_vibes(
configuration: &configuration::Configuration,
) -> Result<Vec<models::InstanceVibe>, Error<GetInstanceVibesError>> {
let uri_str = format!("{}/instanceVibes", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
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?;
if configuration.debug {
log::debug!("get_instance_vibes returned: {content}");
}
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 `Vec<models::InstanceVibe>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::InstanceVibe>`")))),
}
} else {
let content = resp.text().await?;
if configuration.debug {
log::debug!("get_instance_vibes returned: {content}");
}
let entity: Option<GetInstanceVibesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_recent_locations(
configuration: &configuration::Configuration,
n: Option<i32>,
offset: Option<i32>,
) -> Result<Vec<String>, Error<GetRecentLocationsError>> {
let p_query_n = n;
let p_query_offset = offset;
let uri_str = format!("{}/instances/recent", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_n {
req_builder = req_builder.query(&[("n", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_offset {
req_builder = req_builder.query(&[("offset", ¶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?;
if configuration.debug {
log::debug!("get_recent_locations returned: {content}");
}
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 `Vec<String>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<String>`")))),
}
} else {
let content = resp.text().await?;
if configuration.debug {
log::debug!("get_recent_locations returned: {content}");
}
let entity: Option<GetRecentLocationsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_short_name(
configuration: &configuration::Configuration,
world_id: &str,
instance_id: &str,
) -> Result<models::InstanceShortNameResponse, Error<GetShortNameError>> {
let p_path_world_id = world_id;
let p_path_instance_id = instance_id;
let uri_str = format!(
"{}/instances/{worldId}:{instanceId}/shortName",
configuration.base_path,
worldId = crate::apis::urlencode(p_path_world_id),
instanceId = crate::apis::urlencode(p_path_instance_id)
);
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();
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?;
if configuration.debug {
log::debug!("get_short_name returned: {content}");
}
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::InstanceShortNameResponse`"))),
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::InstanceShortNameResponse`")))),
}
} else {
let content = resp.text().await?;
if configuration.debug {
log::debug!("get_short_name returned: {content}");
}
let entity: Option<GetShortNameError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn update_instance(
configuration: &configuration::Configuration,
world_id: &str,
instance_id: &str,
update_instance_request: models::UpdateInstanceRequest,
) -> Result<models::Instance, Error<UpdateInstanceError>> {
let p_path_world_id = world_id;
let p_path_instance_id = instance_id;
let p_body_update_instance_request = update_instance_request;
let uri_str = format!(
"{}/instances/{worldId}:{instanceId}",
configuration.base_path,
worldId = crate::apis::urlencode(p_path_world_id),
instanceId = crate::apis::urlencode(p_path_instance_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_body_update_instance_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
if configuration.debug {
log::debug!("update_instance returned: {content}");
}
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::Instance`"))),
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::Instance`")))),
}
} else {
let content = resp.text().await?;
if configuration.debug {
log::debug!("update_instance returned: {content}");
}
let entity: Option<UpdateInstanceError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}