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 CheckUserPersistenceExistsError {
Status401(models::Error),
Status404(),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateWorldError {
Status400(models::Error),
Status401(models::Error),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteAllUserPersistenceDataError {
Status401(models::Error),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteUserPersistenceError {
Status401(models::Error),
Status404(),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteWorldError {
Status401(models::Error),
Status404(models::Error),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetActiveWorldsError {
Status401(models::Error),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetFavoritedWorldsError {
Status401(models::Error),
Status403(models::Error),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetRecentWorldsError {
Status401(models::Error),
Status403(models::Error),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetWorldError {
Status404(models::Error),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetWorldInstanceError {
Status401(models::Error),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetWorldMetadataError {
Status404(models::Error),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetWorldPublishStatusError {
Status401(models::Error),
Status404(models::Error),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PublishWorldError {
Status401(models::Error),
Status404(models::Error),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SearchWorldsError {
Status401(models::Error),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UnpublishWorldError {
Status401(models::Error),
Status404(models::Error),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateWorldError {
Status401(models::Error),
Status404(models::Error),
UnknownValue(serde_json::Value),
}
pub async fn check_user_persistence_exists(
configuration: &configuration::Configuration,
user_id: &str,
world_id: &str,
) -> Result<(), Error<CheckUserPersistenceExistsError>> {
let p_path_user_id = user_id;
let p_path_world_id = world_id;
let uri_str = format!(
"{}/users/{userId}/{worldId}/persist/exists",
configuration.base_path,
userId = crate::apis::urlencode(p_path_user_id),
worldId = crate::apis::urlencode(p_path_world_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();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<CheckUserPersistenceExistsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn create_world(
configuration: &configuration::Configuration,
create_world_request: Option<models::CreateWorldRequest>,
) -> Result<models::World, Error<CreateWorldError>> {
let p_body_create_world_request = create_world_request;
let uri_str = format!("{}/worlds", 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_world_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::World`"))),
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::World`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateWorldError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn delete_all_user_persistence_data(
configuration: &configuration::Configuration,
user_id: &str,
) -> Result<(), Error<DeleteAllUserPersistenceDataError>> {
let p_path_user_id = user_id;
let uri_str = format!(
"{}/users/{userId}/persist",
configuration.base_path,
userId = crate::apis::urlencode(p_path_user_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
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<DeleteAllUserPersistenceDataError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn delete_user_persistence(
configuration: &configuration::Configuration,
user_id: &str,
world_id: &str,
) -> Result<(), Error<DeleteUserPersistenceError>> {
let p_path_user_id = user_id;
let p_path_world_id = world_id;
let uri_str = format!(
"{}/users/{userId}/{worldId}/persist",
configuration.base_path,
userId = crate::apis::urlencode(p_path_user_id),
worldId = crate::apis::urlencode(p_path_world_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
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<DeleteUserPersistenceError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn delete_world(
configuration: &configuration::Configuration,
world_id: &str,
) -> Result<(), Error<DeleteWorldError>> {
let p_path_world_id = world_id;
let uri_str = format!(
"{}/worlds/{worldId}",
configuration.base_path,
worldId = crate::apis::urlencode(p_path_world_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
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<DeleteWorldError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_active_worlds(
configuration: &configuration::Configuration,
featured: Option<bool>,
sort: Option<models::SortOption>,
n: Option<i32>,
order: Option<models::OrderOption>,
offset: Option<i32>,
search: Option<&str>,
tag: Option<&str>,
notag: Option<&str>,
release_status: Option<models::ReleaseStatus>,
max_unity_version: Option<&str>,
min_unity_version: Option<&str>,
platform: Option<&str>,
noplatform: Option<&str>,
) -> Result<Vec<models::LimitedWorld>, Error<GetActiveWorldsError>> {
let p_query_featured = featured;
let p_query_sort = sort;
let p_query_n = n;
let p_query_order = order;
let p_query_offset = offset;
let p_query_search = search;
let p_query_tag = tag;
let p_query_notag = notag;
let p_query_release_status = release_status;
let p_query_max_unity_version = max_unity_version;
let p_query_min_unity_version = min_unity_version;
let p_query_platform = platform;
let p_query_noplatform = noplatform;
let uri_str = format!("{}/worlds/active", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_featured {
req_builder = req_builder.query(&[("featured", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_sort {
req_builder = req_builder.query(&[("sort", ¶m_value.to_string())]);
}
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_order {
req_builder = req_builder.query(&[("order", ¶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 param_value) = p_query_search {
req_builder = req_builder.query(&[("search", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_tag {
req_builder = req_builder.query(&[("tag", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_notag {
req_builder = req_builder.query(&[("notag", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_release_status {
req_builder = req_builder.query(&[("releaseStatus", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_max_unity_version {
req_builder = req_builder.query(&[("maxUnityVersion", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_min_unity_version {
req_builder = req_builder.query(&[("minUnityVersion", ¶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_noplatform {
req_builder = req_builder.query(&[("noplatform", ¶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 `Vec<models::LimitedWorld>`"))),
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::LimitedWorld>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetActiveWorldsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_favorited_worlds(
configuration: &configuration::Configuration,
featured: Option<bool>,
sort: Option<models::SortOption>,
n: Option<i32>,
order: Option<models::OrderOption>,
offset: Option<i32>,
search: Option<&str>,
tag: Option<&str>,
notag: Option<&str>,
release_status: Option<models::ReleaseStatus>,
max_unity_version: Option<&str>,
min_unity_version: Option<&str>,
platform: Option<&str>,
user_id: Option<&str>,
) -> Result<Vec<models::FavoritedWorld>, Error<GetFavoritedWorldsError>> {
let p_query_featured = featured;
let p_query_sort = sort;
let p_query_n = n;
let p_query_order = order;
let p_query_offset = offset;
let p_query_search = search;
let p_query_tag = tag;
let p_query_notag = notag;
let p_query_release_status = release_status;
let p_query_max_unity_version = max_unity_version;
let p_query_min_unity_version = min_unity_version;
let p_query_platform = platform;
let p_query_user_id = user_id;
let uri_str = format!("{}/worlds/favorites", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_featured {
req_builder = req_builder.query(&[("featured", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_sort {
req_builder = req_builder.query(&[("sort", ¶m_value.to_string())]);
}
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_order {
req_builder = req_builder.query(&[("order", ¶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 param_value) = p_query_search {
req_builder = req_builder.query(&[("search", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_tag {
req_builder = req_builder.query(&[("tag", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_notag {
req_builder = req_builder.query(&[("notag", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_release_status {
req_builder = req_builder.query(&[("releaseStatus", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_max_unity_version {
req_builder = req_builder.query(&[("maxUnityVersion", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_min_unity_version {
req_builder = req_builder.query(&[("minUnityVersion", ¶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_user_id {
req_builder = req_builder.query(&[("userId", ¶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 `Vec<models::FavoritedWorld>`"))),
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::FavoritedWorld>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetFavoritedWorldsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_recent_worlds(
configuration: &configuration::Configuration,
featured: Option<bool>,
sort: Option<models::SortOption>,
n: Option<i32>,
order: Option<models::OrderOption>,
offset: Option<i32>,
search: Option<&str>,
tag: Option<&str>,
notag: Option<&str>,
release_status: Option<models::ReleaseStatus>,
max_unity_version: Option<&str>,
min_unity_version: Option<&str>,
platform: Option<&str>,
user_id: Option<&str>,
) -> Result<Vec<models::LimitedWorld>, Error<GetRecentWorldsError>> {
let p_query_featured = featured;
let p_query_sort = sort;
let p_query_n = n;
let p_query_order = order;
let p_query_offset = offset;
let p_query_search = search;
let p_query_tag = tag;
let p_query_notag = notag;
let p_query_release_status = release_status;
let p_query_max_unity_version = max_unity_version;
let p_query_min_unity_version = min_unity_version;
let p_query_platform = platform;
let p_query_user_id = user_id;
let uri_str = format!("{}/worlds/recent", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_featured {
req_builder = req_builder.query(&[("featured", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_sort {
req_builder = req_builder.query(&[("sort", ¶m_value.to_string())]);
}
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_order {
req_builder = req_builder.query(&[("order", ¶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 param_value) = p_query_search {
req_builder = req_builder.query(&[("search", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_tag {
req_builder = req_builder.query(&[("tag", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_notag {
req_builder = req_builder.query(&[("notag", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_release_status {
req_builder = req_builder.query(&[("releaseStatus", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_max_unity_version {
req_builder = req_builder.query(&[("maxUnityVersion", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_min_unity_version {
req_builder = req_builder.query(&[("minUnityVersion", ¶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_user_id {
req_builder = req_builder.query(&[("userId", ¶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 `Vec<models::LimitedWorld>`"))),
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::LimitedWorld>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetRecentWorldsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_world(
configuration: &configuration::Configuration,
world_id: &str,
) -> Result<models::World, Error<GetWorldError>> {
let p_path_world_id = world_id;
let uri_str = format!(
"{}/worlds/{worldId}",
configuration.base_path,
worldId = crate::apis::urlencode(p_path_world_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?;
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::World`"))),
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::World`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetWorldError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_world_instance(
configuration: &configuration::Configuration,
world_id: &str,
instance_id: &str,
) -> Result<models::Instance, Error<GetWorldInstanceError>> {
let p_path_world_id = world_id;
let p_path_instance_id = instance_id;
let uri_str = format!(
"{}/worlds/{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?;
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?;
let entity: Option<GetWorldInstanceError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
#[deprecated]
pub async fn get_world_metadata(
configuration: &configuration::Configuration,
world_id: &str,
) -> Result<models::WorldMetadata, Error<GetWorldMetadataError>> {
let p_path_world_id = world_id;
let uri_str = format!(
"{}/worlds/{worldId}/metadata",
configuration.base_path,
worldId = crate::apis::urlencode(p_path_world_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?;
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::WorldMetadata`"))),
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::WorldMetadata`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetWorldMetadataError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_world_publish_status(
configuration: &configuration::Configuration,
world_id: &str,
) -> Result<models::WorldPublishStatus, Error<GetWorldPublishStatusError>> {
let p_path_world_id = world_id;
let uri_str = format!(
"{}/worlds/{worldId}/publish",
configuration.base_path,
worldId = crate::apis::urlencode(p_path_world_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?;
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::WorldPublishStatus`"))),
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::WorldPublishStatus`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetWorldPublishStatusError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn publish_world(
configuration: &configuration::Configuration,
world_id: &str,
) -> Result<(), Error<PublishWorldError>> {
let p_path_world_id = world_id;
let uri_str = format!(
"{}/worlds/{worldId}/publish",
configuration.base_path,
worldId = crate::apis::urlencode(p_path_world_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());
}
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<PublishWorldError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn search_worlds(
configuration: &configuration::Configuration,
featured: Option<bool>,
sort: Option<models::SortOption>,
user: Option<&str>,
user_id: Option<&str>,
n: Option<i32>,
order: Option<models::OrderOption>,
offset: Option<i32>,
search: Option<&str>,
tag: Option<&str>,
notag: Option<&str>,
release_status: Option<models::ReleaseStatus>,
max_unity_version: Option<&str>,
min_unity_version: Option<&str>,
platform: Option<&str>,
noplatform: Option<&str>,
fuzzy: Option<bool>,
avatar_specific: Option<bool>,
) -> Result<Vec<models::LimitedWorld>, Error<SearchWorldsError>> {
let p_query_featured = featured;
let p_query_sort = sort;
let p_query_user = user;
let p_query_user_id = user_id;
let p_query_n = n;
let p_query_order = order;
let p_query_offset = offset;
let p_query_search = search;
let p_query_tag = tag;
let p_query_notag = notag;
let p_query_release_status = release_status;
let p_query_max_unity_version = max_unity_version;
let p_query_min_unity_version = min_unity_version;
let p_query_platform = platform;
let p_query_noplatform = noplatform;
let p_query_fuzzy = fuzzy;
let p_query_avatar_specific = avatar_specific;
let uri_str = format!("{}/worlds", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_featured {
req_builder = req_builder.query(&[("featured", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_sort {
req_builder = req_builder.query(&[("sort", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_user {
req_builder = req_builder.query(&[("user", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_user_id {
req_builder = req_builder.query(&[("userId", ¶m_value.to_string())]);
}
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_order {
req_builder = req_builder.query(&[("order", ¶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 param_value) = p_query_search {
req_builder = req_builder.query(&[("search", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_tag {
req_builder = req_builder.query(&[("tag", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_notag {
req_builder = req_builder.query(&[("notag", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_release_status {
req_builder = req_builder.query(&[("releaseStatus", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_max_unity_version {
req_builder = req_builder.query(&[("maxUnityVersion", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_min_unity_version {
req_builder = req_builder.query(&[("minUnityVersion", ¶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_noplatform {
req_builder = req_builder.query(&[("noplatform", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_fuzzy {
req_builder = req_builder.query(&[("fuzzy", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_avatar_specific {
req_builder = req_builder.query(&[("avatarSpecific", ¶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 `Vec<models::LimitedWorld>`"))),
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::LimitedWorld>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SearchWorldsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn unpublish_world(
configuration: &configuration::Configuration,
world_id: &str,
) -> Result<(), Error<UnpublishWorldError>> {
let p_path_world_id = world_id;
let uri_str = format!(
"{}/worlds/{worldId}/publish",
configuration.base_path,
worldId = crate::apis::urlencode(p_path_world_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
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<UnpublishWorldError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn update_world(
configuration: &configuration::Configuration,
world_id: &str,
update_world_request: Option<models::UpdateWorldRequest>,
) -> Result<models::World, Error<UpdateWorldError>> {
let p_path_world_id = world_id;
let p_body_update_world_request = update_world_request;
let uri_str = format!(
"{}/worlds/{worldId}",
configuration.base_path,
worldId = crate::apis::urlencode(p_path_world_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_world_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::World`"))),
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::World`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateWorldError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}