use bon::bon;
use reqwest;
use std::sync::Arc;
use serde::{Deserialize, Serialize, de::Error as OtherError};
use crate::{apis::ResponseContent, models};
use super::{Error, configuration};
use crate::apis::ContentType;
use crate::*;
#[async_trait]
pub trait KnnApi: Send + Sync {
async fn stats(&self, params: StatsParams) -> Result<crate::knn::Stats, Error>;
async fn get_model(&self, params: GetModelParams) -> Result<crate::knn::GetModelResponse, Error>;
async fn train_model(&self, params: TrainModelParams) -> Result<crate::knn::TrainModelResponse, Error>;
async fn delete_model(&self, params: DeleteModelParams) -> Result<crate::knn::DeletedModel, Error>;
async fn warmup(&self, params: WarmupParams) -> Result<crate::common::ShardsOperationResponseBase, Error>;
async fn search_models(&self, params: SearchModelsParams) -> Result<crate::core::search::ResponseBody, Error>;
}
pub struct KnnApiClient {
configuration: Arc<crate::Configuration>
}
impl KnnApiClient {
pub fn new(configuration: Arc<crate::Configuration>) -> Self {
Self { configuration }
}
}
#[derive(Clone, Debug)]
#[cfg_attr(feature = "bon", derive(::bon::Builder))]
pub struct StatsParams {
pub timeout: Option<String>,
pub error_trace: Option<bool>,
pub filter_path: Option<common::FilterPath>,
pub human: Option<bool>,
pub node_id: String,
pub pretty: Option<bool>,
pub source: Option<String>,
pub stat: String,
}
#[derive(Clone, Debug)]
#[cfg_attr(feature = "bon", derive(::bon::Builder))]
pub struct GetModelParams {
pub error_trace: Option<bool>,
pub filter_path: Option<common::FilterPath>,
pub human: Option<bool>,
pub model_id: String,
pub pretty: Option<bool>,
pub source: Option<String>,
}
#[derive(Clone, Debug)]
#[cfg_attr(feature = "bon", derive(::bon::Builder))]
pub struct TrainModelParams {
pub train_model: knn::TrainModel,
pub error_trace: Option<bool>,
pub filter_path: Option<common::FilterPath>,
pub human: Option<bool>,
pub model_id: String,
pub pretty: Option<bool>,
pub source: Option<String>,
pub preference: Option<String>,
}
#[derive(Clone, Debug)]
#[cfg_attr(feature = "bon", derive(::bon::Builder))]
pub struct DeleteModelParams {
pub error_trace: Option<bool>,
pub filter_path: Option<common::FilterPath>,
pub human: Option<bool>,
pub model_id: String,
pub pretty: Option<bool>,
pub source: Option<String>,
}
#[derive(Clone, Debug)]
#[cfg_attr(feature = "bon", derive(::bon::Builder))]
pub struct WarmupParams {
pub error_trace: Option<bool>,
pub filter_path: Option<common::FilterPath>,
pub human: Option<bool>,
pub index: String,
pub pretty: Option<bool>,
pub source: Option<String>,
}
#[derive(Clone, Debug)]
#[cfg_attr(feature = "bon", derive(::bon::Builder))]
pub struct SearchModelsParams {
pub search_models: knn::SearchModels,
pub scroll: Option<String>,
pub timeout: Option<String>,
pub suggest_size: Option<i32>,
pub allow_partial_search_results: Option<bool>,
pub track_total_hits: Option<bool>,
pub rest_total_hits_as_int: Option<bool>,
pub ccs_minimize_roundtrips: Option<bool>,
pub source_excludes: Option<Vec<String>>,
pub source_includes: Option<Vec<String>>,
pub docvalue_fields: Option<Vec<String>>,
pub error_trace: Option<bool>,
pub filter_path: Option<common::FilterPath>,
pub human: Option<bool>,
pub pretty: Option<bool>,
pub routing: Option<common::Routing>,
pub sort: Option<Vec<String>>,
pub source: Option<String>,
pub stats: Option<Vec<String>>,
pub stored_fields: Option<Vec<String>>,
pub size: Option<i32>,
pub q: Option<String>,
pub search_type: Option<String>,
pub expand_wildcards: Option<common::ExpandWildcards>,
pub request_cache: Option<bool>,
pub suggest_mode: Option<String>,
pub preference: Option<String>,
pub typed_keys: Option<bool>,
pub lenient: Option<bool>,
pub explain: Option<bool>,
pub seq_no_primary_term: Option<bool>,
pub analyze_wildcard: Option<bool>,
pub suggest_field: Option<String>,
pub from: Option<i32>,
pub analyzer: Option<String>,
pub default_operator: Option<String>,
pub df: Option<String>,
pub terminate_after: Option<i32>,
pub max_concurrent_shard_requests: Option<i32>,
pub batched_reduce_size: Option<i32>,
pub suggest_text: Option<String>,
pub pre_filter_shard_size: Option<i32>,
pub ignore_unavailable: Option<bool>,
pub ignore_throttled: Option<bool>,
pub track_scores: Option<bool>,
pub allow_no_indices: Option<bool>,
pub version: Option<bool>,
}
#[async_trait]
impl KnnApi for KnnApiClient {
async fn stats(&self, params: StatsParams) -> Result<crate::knn::Stats, Error> {
let StatsParams {
timeout,
error_trace,
filter_path,
human,
node_id,
pretty,
source,
stat,
} = params;
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}_plugins/_knn/{node_id}/stats/{stat}", local_var_configuration.base_path, node_id=node_id, stat=stat);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_str) = timeout {
local_var_req_builder = local_var_req_builder.query(&[("timeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder = local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder = local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder = local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder = local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder = local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
} async fn get_model(&self, params: GetModelParams) -> Result<crate::knn::GetModelResponse, Error> {
let GetModelParams {
error_trace,
filter_path,
human,
model_id,
pretty,
source,
} = params;
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}_plugins/_knn/models/{model_id}", local_var_configuration.base_path, model_id=model_id);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_str) = pretty {
local_var_req_builder = local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder = local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder = local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder = local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder = local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
} async fn train_model(&self, params: TrainModelParams) -> Result<crate::knn::TrainModelResponse, Error> {
let TrainModelParams {
train_model,
error_trace,
filter_path,
human,
model_id,
pretty,
source,
preference,
} = params;
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}_plugins/_knn/models/{model_id}/_train", local_var_configuration.base_path, model_id=model_id);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_str) = preference {
local_var_req_builder = local_var_req_builder.query(&[("preference", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder = local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder = local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder = local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder = local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder = local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
local_var_req_builder = local_var_req_builder.json(&train_model);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
} async fn delete_model(&self, params: DeleteModelParams) -> Result<crate::knn::DeletedModel, Error> {
let DeleteModelParams {
error_trace,
filter_path,
human,
model_id,
pretty,
source,
} = params;
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}_plugins/_knn/models/{model_id}", local_var_configuration.base_path, model_id=model_id);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
if let Some(ref local_var_str) = pretty {
local_var_req_builder = local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder = local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder = local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder = local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder = local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
} async fn warmup(&self, params: WarmupParams) -> Result<crate::common::ShardsOperationResponseBase, Error> {
let WarmupParams {
error_trace,
filter_path,
human,
index,
pretty,
source,
} = params;
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}_plugins/_knn/warmup/{index}", local_var_configuration.base_path, index=index);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_str) = pretty {
local_var_req_builder = local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder = local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder = local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder = local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder = local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
} async fn search_models(&self, params: SearchModelsParams) -> Result<crate::core::search::ResponseBody, Error> {
let SearchModelsParams {
search_models,
scroll,
timeout,
suggest_size,
allow_partial_search_results,
track_total_hits,
rest_total_hits_as_int,
ccs_minimize_roundtrips,
source_excludes,
source_includes,
docvalue_fields,
error_trace,
filter_path,
human,
pretty,
routing,
sort,
source,
stats,
stored_fields,
size,
q,
search_type,
expand_wildcards,
request_cache,
suggest_mode,
preference,
typed_keys,
lenient,
explain,
seq_no_primary_term,
analyze_wildcard,
suggest_field,
from,
analyzer,
default_operator,
df,
terminate_after,
max_concurrent_shard_requests,
batched_reduce_size,
suggest_text,
pre_filter_shard_size,
ignore_unavailable,
ignore_throttled,
track_scores,
allow_no_indices,
version,
} = params;
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}_plugins/_knn/models/_search", local_var_configuration.base_path);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_str) = pre_filter_shard_size {
local_var_req_builder = local_var_req_builder.query(&[("pre_filter_shard_size", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = timeout {
local_var_req_builder = local_var_req_builder.query(&[("timeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = stats {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("stats".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
_ => local_var_req_builder.query(&[("stats", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
};
}
if let Some(ref local_var_str) = human {
local_var_req_builder = local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = ignore_throttled {
local_var_req_builder = local_var_req_builder.query(&[("ignore_throttled", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = analyzer {
local_var_req_builder = local_var_req_builder.query(&[("analyzer", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = allow_no_indices {
local_var_req_builder = local_var_req_builder.query(&[("allow_no_indices", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = preference {
local_var_req_builder = local_var_req_builder.query(&[("preference", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = seq_no_primary_term {
local_var_req_builder = local_var_req_builder.query(&[("seq_no_primary_term", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder = local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = track_scores {
local_var_req_builder = local_var_req_builder.query(&[("track_scores", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = allow_partial_search_results {
local_var_req_builder = local_var_req_builder.query(&[("allow_partial_search_results", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder = local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = batched_reduce_size {
local_var_req_builder = local_var_req_builder.query(&[("batched_reduce_size", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = ccs_minimize_roundtrips {
local_var_req_builder = local_var_req_builder.query(&[("ccs_minimize_roundtrips", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = routing {
local_var_req_builder = local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = docvalue_fields {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("docvalue_fields".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
_ => local_var_req_builder.query(&[("docvalue_fields", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
};
}
if let Some(ref local_var_str) = suggest_size {
local_var_req_builder = local_var_req_builder.query(&[("suggest_size", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = search_type {
local_var_req_builder = local_var_req_builder.query(&[("search_type", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = suggest_text {
local_var_req_builder = local_var_req_builder.query(&[("suggest_text", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = suggest_field {
local_var_req_builder = local_var_req_builder.query(&[("suggest_field", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source_includes {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("source_includes".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
_ => local_var_req_builder.query(&[("source_includes", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
};
}
if let Some(ref local_var_str) = terminate_after {
local_var_req_builder = local_var_req_builder.query(&[("terminate_after", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = typed_keys {
local_var_req_builder = local_var_req_builder.query(&[("typed_keys", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = max_concurrent_shard_requests {
local_var_req_builder = local_var_req_builder.query(&[("max_concurrent_shard_requests", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = analyze_wildcard {
local_var_req_builder = local_var_req_builder.query(&[("analyze_wildcard", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = stored_fields {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("stored_fields".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
_ => local_var_req_builder.query(&[("stored_fields", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
};
}
if let Some(ref local_var_str) = ignore_unavailable {
local_var_req_builder = local_var_req_builder.query(&[("ignore_unavailable", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder = local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source_excludes {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("source_excludes".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
_ => local_var_req_builder.query(&[("source_excludes", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
};
}
if let Some(ref local_var_str) = request_cache {
local_var_req_builder = local_var_req_builder.query(&[("request_cache", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = scroll {
local_var_req_builder = local_var_req_builder.query(&[("scroll", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = explain {
local_var_req_builder = local_var_req_builder.query(&[("explain", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = default_operator {
local_var_req_builder = local_var_req_builder.query(&[("default_operator", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = sort {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("sort".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
_ => local_var_req_builder.query(&[("sort", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
};
}
if let Some(ref local_var_str) = rest_total_hits_as_int {
local_var_req_builder = local_var_req_builder.query(&[("rest_total_hits_as_int", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = expand_wildcards {
local_var_req_builder = local_var_req_builder.query(&[("expand_wildcards", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = size {
local_var_req_builder = local_var_req_builder.query(&[("size", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = suggest_mode {
local_var_req_builder = local_var_req_builder.query(&[("suggest_mode", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = version {
local_var_req_builder = local_var_req_builder.query(&[("version", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder = local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = q {
local_var_req_builder = local_var_req_builder.query(&[("q", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = from {
local_var_req_builder = local_var_req_builder.query(&[("from", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = track_total_hits {
local_var_req_builder = local_var_req_builder.query(&[("track_total_hits", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = df {
local_var_req_builder = local_var_req_builder.query(&[("df", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = lenient {
local_var_req_builder = local_var_req_builder.query(&[("lenient", &local_var_str.to_string())]);
}
local_var_req_builder = local_var_req_builder.json(&search_models);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
}
}