/*
* Immich
*
* Immich API
*
* The version of the OpenAPI document: 1.137.3
*
* Generated by: https://openapi-generator.tech
*/
use reqwest;
use serde::{Deserialize, Serialize, de::Error as _};
use crate::{apis::ResponseContent, models};
use super::{Error, configuration, ContentType};
/// struct for typed errors of method [`get_assets_by_city`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetAssetsByCityError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_explore_data`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetExploreDataError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_search_suggestions`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetSearchSuggestionsError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`search_asset_statistics`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SearchAssetStatisticsError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`search_assets`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SearchAssetsError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`search_large_assets`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SearchLargeAssetsError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`search_person`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SearchPersonError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`search_places`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SearchPlacesError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`search_random`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SearchRandomError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`search_smart`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SearchSmartError {
UnknownValue(serde_json::Value),
}
/// This endpoint requires the `asset.read` permission.
pub async fn get_assets_by_city(configuration: &configuration::Configuration, ) -> Result<Vec<models::AssetResponseDto>, Error<GetAssetsByCityError>> {
let uri_str = format!("{}/search/cities", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("x-api-key", value);
};
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
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::AssetResponseDto>`"))),
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::AssetResponseDto>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetAssetsByCityError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// This endpoint requires the `asset.read` permission.
pub async fn get_explore_data(configuration: &configuration::Configuration, ) -> Result<Vec<models::SearchExploreResponseDto>, Error<GetExploreDataError>> {
let uri_str = format!("{}/search/explore", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("x-api-key", value);
};
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
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::SearchExploreResponseDto>`"))),
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::SearchExploreResponseDto>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetExploreDataError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// This endpoint requires the `asset.read` permission.
pub async fn get_search_suggestions(configuration: &configuration::Configuration, r#type: models::SearchSuggestionType, country: Option<&str>, include_null: Option<bool>, make: Option<&str>, model: Option<&str>, state: Option<&str>) -> Result<Vec<String>, Error<GetSearchSuggestionsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_type = r#type;
let p_country = country;
let p_include_null = include_null;
let p_make = make;
let p_model = model;
let p_state = state;
let uri_str = format!("{}/search/suggestions", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_country {
req_builder = req_builder.query(&[("country", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_include_null {
req_builder = req_builder.query(&[("includeNull", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_make {
req_builder = req_builder.query(&[("make", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_model {
req_builder = req_builder.query(&[("model", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_state {
req_builder = req_builder.query(&[("state", ¶m_value.to_string())]);
}
req_builder = req_builder.query(&[("type", &p_type.to_string())]);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("x-api-key", value);
};
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
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<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?;
let entity: Option<GetSearchSuggestionsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// This endpoint requires the `asset.statistics` permission.
pub async fn search_asset_statistics(configuration: &configuration::Configuration, statistics_search_dto: models::StatisticsSearchDto) -> Result<models::SearchStatisticsResponseDto, Error<SearchAssetStatisticsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_statistics_search_dto = statistics_search_dto;
let uri_str = format!("{}/search/statistics", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("x-api-key", value);
};
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_statistics_search_dto);
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::SearchStatisticsResponseDto`"))),
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::SearchStatisticsResponseDto`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SearchAssetStatisticsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// This endpoint requires the `asset.read` permission.
pub async fn search_assets(configuration: &configuration::Configuration, metadata_search_dto: models::MetadataSearchDto) -> Result<models::SearchResponseDto, Error<SearchAssetsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_metadata_search_dto = metadata_search_dto;
let uri_str = format!("{}/search/metadata", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("x-api-key", value);
};
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_metadata_search_dto);
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::SearchResponseDto`"))),
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::SearchResponseDto`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SearchAssetsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// This endpoint requires the `asset.read` permission.
pub async fn search_large_assets(configuration: &configuration::Configuration, album_ids: Option<Vec<uuid::Uuid>>, city: Option<&str>, country: Option<&str>, created_after: Option<String>, created_before: Option<String>, device_id: Option<&str>, is_encoded: Option<bool>, is_favorite: Option<bool>, is_motion: Option<bool>, is_not_in_album: Option<bool>, is_offline: Option<bool>, lens_model: Option<&str>, library_id: Option<&str>, make: Option<&str>, min_file_size: Option<u32>, model: Option<&str>, person_ids: Option<Vec<uuid::Uuid>>, rating: Option<f64>, size: Option<f64>, state: Option<&str>, tag_ids: Option<Vec<uuid::Uuid>>, taken_after: Option<String>, taken_before: Option<String>, trashed_after: Option<String>, trashed_before: Option<String>, r#type: Option<models::AssetTypeEnum>, updated_after: Option<String>, updated_before: Option<String>, visibility: Option<models::AssetVisibility>, with_deleted: Option<bool>, with_exif: Option<bool>) -> Result<Vec<models::AssetResponseDto>, Error<SearchLargeAssetsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_album_ids = album_ids;
let p_city = city;
let p_country = country;
let p_created_after = created_after;
let p_created_before = created_before;
let p_device_id = device_id;
let p_is_encoded = is_encoded;
let p_is_favorite = is_favorite;
let p_is_motion = is_motion;
let p_is_not_in_album = is_not_in_album;
let p_is_offline = is_offline;
let p_lens_model = lens_model;
let p_library_id = library_id;
let p_make = make;
let p_min_file_size = min_file_size;
let p_model = model;
let p_person_ids = person_ids;
let p_rating = rating;
let p_size = size;
let p_state = state;
let p_tag_ids = tag_ids;
let p_taken_after = taken_after;
let p_taken_before = taken_before;
let p_trashed_after = trashed_after;
let p_trashed_before = trashed_before;
let p_type = r#type;
let p_updated_after = updated_after;
let p_updated_before = updated_before;
let p_visibility = visibility;
let p_with_deleted = with_deleted;
let p_with_exif = with_exif;
let uri_str = format!("{}/search/large-assets", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref param_value) = p_album_ids {
req_builder = match "multi" {
"multi" => req_builder.query(¶m_value.into_iter().map(|p| ("albumIds".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
_ => req_builder.query(&[("albumIds", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
};
}
if let Some(ref param_value) = p_city {
req_builder = req_builder.query(&[("city", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_country {
req_builder = req_builder.query(&[("country", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_created_after {
req_builder = req_builder.query(&[("createdAfter", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_created_before {
req_builder = req_builder.query(&[("createdBefore", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_device_id {
req_builder = req_builder.query(&[("deviceId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_is_encoded {
req_builder = req_builder.query(&[("isEncoded", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_is_favorite {
req_builder = req_builder.query(&[("isFavorite", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_is_motion {
req_builder = req_builder.query(&[("isMotion", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_is_not_in_album {
req_builder = req_builder.query(&[("isNotInAlbum", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_is_offline {
req_builder = req_builder.query(&[("isOffline", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_lens_model {
req_builder = req_builder.query(&[("lensModel", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_library_id {
req_builder = req_builder.query(&[("libraryId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_make {
req_builder = req_builder.query(&[("make", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_min_file_size {
req_builder = req_builder.query(&[("minFileSize", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_model {
req_builder = req_builder.query(&[("model", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_person_ids {
req_builder = match "multi" {
"multi" => req_builder.query(¶m_value.into_iter().map(|p| ("personIds".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
_ => req_builder.query(&[("personIds", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
};
}
if let Some(ref param_value) = p_rating {
req_builder = req_builder.query(&[("rating", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_size {
req_builder = req_builder.query(&[("size", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_state {
req_builder = req_builder.query(&[("state", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_tag_ids {
req_builder = match "multi" {
"multi" => req_builder.query(¶m_value.into_iter().map(|p| ("tagIds".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
_ => req_builder.query(&[("tagIds", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
};
}
if let Some(ref param_value) = p_taken_after {
req_builder = req_builder.query(&[("takenAfter", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_taken_before {
req_builder = req_builder.query(&[("takenBefore", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_trashed_after {
req_builder = req_builder.query(&[("trashedAfter", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_trashed_before {
req_builder = req_builder.query(&[("trashedBefore", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_type {
req_builder = req_builder.query(&[("type", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_updated_after {
req_builder = req_builder.query(&[("updatedAfter", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_updated_before {
req_builder = req_builder.query(&[("updatedBefore", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_visibility {
req_builder = req_builder.query(&[("visibility", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_with_deleted {
req_builder = req_builder.query(&[("withDeleted", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_with_exif {
req_builder = req_builder.query(&[("withExif", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("x-api-key", value);
};
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
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::AssetResponseDto>`"))),
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::AssetResponseDto>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SearchLargeAssetsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// This endpoint requires the `person.read` permission.
pub async fn search_person(configuration: &configuration::Configuration, name: &str, with_hidden: Option<bool>) -> Result<Vec<models::PersonResponseDto>, Error<SearchPersonError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_name = name;
let p_with_hidden = with_hidden;
let uri_str = format!("{}/search/person", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("name", &p_name.to_string())]);
if let Some(ref param_value) = p_with_hidden {
req_builder = req_builder.query(&[("withHidden", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("x-api-key", value);
};
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
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::PersonResponseDto>`"))),
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::PersonResponseDto>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SearchPersonError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// This endpoint requires the `asset.read` permission.
pub async fn search_places(configuration: &configuration::Configuration, name: &str) -> Result<Vec<models::PlacesResponseDto>, Error<SearchPlacesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_name = name;
let uri_str = format!("{}/search/places", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("name", &p_name.to_string())]);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("x-api-key", value);
};
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
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::PlacesResponseDto>`"))),
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::PlacesResponseDto>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SearchPlacesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// This endpoint requires the `asset.read` permission.
pub async fn search_random(configuration: &configuration::Configuration, random_search_dto: models::RandomSearchDto) -> Result<Vec<models::AssetResponseDto>, Error<SearchRandomError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_random_search_dto = random_search_dto;
let uri_str = format!("{}/search/random", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("x-api-key", value);
};
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_random_search_dto);
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::AssetResponseDto>`"))),
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::AssetResponseDto>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SearchRandomError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// This endpoint requires the `asset.read` permission.
pub async fn search_smart(configuration: &configuration::Configuration, smart_search_dto: models::SmartSearchDto) -> Result<models::SearchResponseDto, Error<SearchSmartError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_smart_search_dto = smart_search_dto;
let uri_str = format!("{}/search/smart", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("x-api-key", value);
};
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_smart_search_dto);
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::SearchResponseDto`"))),
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::SearchResponseDto`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SearchSmartError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}