use super::{ContentType, Error, UploadFile, configuration};
use crate::{apis::ResponseContent, models};
use reqwest;
use serde::{Deserialize, Serialize, de::Error as _};
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CountAssistantsAssistantsCountPostError {
Status404(String),
Status422(String),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateAssistantAssistantsPostError {
Status404(String),
Status409(String),
Status422(String),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteAssistantAssistantsAssistantIdDeleteError {
Status404(String),
Status422(String),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetAssistantAssistantsAssistantIdGetError {
Status404(String),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetAssistantGraphAssistantsAssistantIdGraphGetError {
Status404(String),
Status422(String),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetAssistantSchemasAssistantsAssistantIdSchemasGetError {
Status404(String),
Status422(String),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetAssistantSubgraphsAssistantsAssistantIdSubgraphsGetError {
Status404(String),
Status422(String),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetAssistantSubgraphsAssistantsAssistantIdSubgraphsNamespaceGetError {
Status422(String),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetAssistantVersionsAssistantsAssistantIdVersionsGetError {
Status422(String),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatchAssistantAssistantsAssistantIdPatchError {
Status404(String),
Status422(String),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SearchAssistantsAssistantsSearchPostError {
Status404(String),
Status422(String),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SetLatestAssistantVersionAssistantsAssistantIdVersionsPostError {
Status404(String),
Status422(String),
UnknownValue(serde_json::Value),
}
pub fn count_assistants_assistants_count_post_request_builder(
configuration: &configuration::Configuration,
assistant_count_request: models::AssistantCountRequest,
) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
let p_body_assistant_count_request = assistant_count_request;
let uri_str = format!("{}/assistants/count", 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_assistant_count_request);
Ok(req_builder)
}
pub async fn count_assistants_assistants_count_post(
configuration: &configuration::Configuration,
assistant_count_request: models::AssistantCountRequest,
) -> Result<i32, Error<CountAssistantsAssistantsCountPostError>> {
let req_builder = count_assistants_assistants_count_post_request_builder(
configuration,
assistant_count_request,
)
.map_err(super::map_request_builder_error)?;
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 => Err(Error::from(serde_json::Error::custom(
"Received `text/plain` content type response that cannot be converted to `i32`",
))),
ContentType::Unsupported(unknown_type) => {
Err(Error::from(serde_json::Error::custom(format!(
"Received `{unknown_type}` content type response that cannot be converted to `i32`"
))))
}
}
} else {
let content = resp.text().await?;
let entity: Option<CountAssistantsAssistantsCountPostError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub fn create_assistant_assistants_post_request_builder(
configuration: &configuration::Configuration,
assistant_create: models::AssistantCreate,
) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
let p_body_assistant_create = assistant_create;
let uri_str = format!("{}/assistants", 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_assistant_create);
Ok(req_builder)
}
pub async fn create_assistant_assistants_post(
configuration: &configuration::Configuration,
assistant_create: models::AssistantCreate,
) -> Result<models::Assistant, Error<CreateAssistantAssistantsPostError>> {
let req_builder =
create_assistant_assistants_post_request_builder(configuration, assistant_create)
.map_err(super::map_request_builder_error)?;
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 => Err(Error::from(serde_json::Error::custom(
"Received `text/plain` content type response that cannot be converted to `models::Assistant`",
))),
ContentType::Unsupported(unknown_type) => {
Err(Error::from(serde_json::Error::custom(format!(
"Received `{unknown_type}` content type response that cannot be converted to `models::Assistant`"
))))
}
}
} else {
let content = resp.text().await?;
let entity: Option<CreateAssistantAssistantsPostError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub fn delete_assistant_assistants_assistant_id_delete_request_builder(
configuration: &configuration::Configuration,
assistant_id: &str,
) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
let p_path_assistant_id = assistant_id;
let uri_str = format!(
"{}/assistants/{assistant_id}",
configuration.base_path,
assistant_id = crate::apis::urlencode(p_path_assistant_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());
}
Ok(req_builder)
}
pub async fn delete_assistant_assistants_assistant_id_delete(
configuration: &configuration::Configuration,
assistant_id: &str,
) -> Result<serde_json::Value, Error<DeleteAssistantAssistantsAssistantIdDeleteError>> {
let req_builder = delete_assistant_assistants_assistant_id_delete_request_builder(
configuration,
assistant_id,
)
.map_err(super::map_request_builder_error)?;
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 => Err(Error::from(serde_json::Error::custom(
"Received `text/plain` content type response that cannot be converted to `serde_json::Value`",
))),
ContentType::Unsupported(unknown_type) => {
Err(Error::from(serde_json::Error::custom(format!(
"Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`"
))))
}
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteAssistantAssistantsAssistantIdDeleteError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub fn get_assistant_assistants_assistant_id_get_request_builder(
configuration: &configuration::Configuration,
assistant_id: &str,
) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
let p_path_assistant_id = assistant_id;
let uri_str = format!(
"{}/assistants/{assistant_id}",
configuration.base_path,
assistant_id = crate::apis::urlencode(p_path_assistant_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());
}
Ok(req_builder)
}
pub async fn get_assistant_assistants_assistant_id_get(
configuration: &configuration::Configuration,
assistant_id: &str,
) -> Result<models::Assistant, Error<GetAssistantAssistantsAssistantIdGetError>> {
let req_builder =
get_assistant_assistants_assistant_id_get_request_builder(configuration, assistant_id)
.map_err(super::map_request_builder_error)?;
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 => Err(Error::from(serde_json::Error::custom(
"Received `text/plain` content type response that cannot be converted to `models::Assistant`",
))),
ContentType::Unsupported(unknown_type) => {
Err(Error::from(serde_json::Error::custom(format!(
"Received `{unknown_type}` content type response that cannot be converted to `models::Assistant`"
))))
}
}
} else {
let content = resp.text().await?;
let entity: Option<GetAssistantAssistantsAssistantIdGetError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub fn get_assistant_graph_assistants_assistant_id_graph_get_request_builder(
configuration: &configuration::Configuration,
assistant_id: &str,
xray: Option<&str>,
) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
let p_path_assistant_id = assistant_id;
let p_query_xray = xray;
let uri_str = format!(
"{}/assistants/{assistant_id}/graph",
configuration.base_path,
assistant_id = p_path_assistant_id
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_xray {
req_builder = req_builder.query(&[("xray", &serde_json::to_string(param_value)?)]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
Ok(req_builder)
}
pub async fn get_assistant_graph_assistants_assistant_id_graph_get(
configuration: &configuration::Configuration,
assistant_id: &str,
xray: Option<&str>,
) -> Result<
std::collections::HashMap<String, Vec<serde_json::Value>>,
Error<GetAssistantGraphAssistantsAssistantIdGraphGetError>,
> {
let req_builder = get_assistant_graph_assistants_assistant_id_graph_get_request_builder(
configuration,
assistant_id,
xray,
)
.map_err(super::map_request_builder_error)?;
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 => Err(Error::from(serde_json::Error::custom(
"Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, Vec<serde_json::Value>>`",
))),
ContentType::Unsupported(unknown_type) => {
Err(Error::from(serde_json::Error::custom(format!(
"Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, Vec<serde_json::Value>>`"
))))
}
}
} else {
let content = resp.text().await?;
let entity: Option<GetAssistantGraphAssistantsAssistantIdGraphGetError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub fn get_assistant_schemas_assistants_assistant_id_schemas_get_request_builder(
configuration: &configuration::Configuration,
assistant_id: &str,
) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
let p_path_assistant_id = assistant_id;
let uri_str = format!(
"{}/assistants/{assistant_id}/schemas",
configuration.base_path,
assistant_id = crate::apis::urlencode(p_path_assistant_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());
}
Ok(req_builder)
}
pub async fn get_assistant_schemas_assistants_assistant_id_schemas_get(
configuration: &configuration::Configuration,
assistant_id: &str,
) -> Result<models::GraphSchema, Error<GetAssistantSchemasAssistantsAssistantIdSchemasGetError>> {
let req_builder = get_assistant_schemas_assistants_assistant_id_schemas_get_request_builder(
configuration,
assistant_id,
)
.map_err(super::map_request_builder_error)?;
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 => Err(Error::from(serde_json::Error::custom(
"Received `text/plain` content type response that cannot be converted to `models::GraphSchema`",
))),
ContentType::Unsupported(unknown_type) => {
Err(Error::from(serde_json::Error::custom(format!(
"Received `{unknown_type}` content type response that cannot be converted to `models::GraphSchema`"
))))
}
}
} else {
let content = resp.text().await?;
let entity: Option<GetAssistantSchemasAssistantsAssistantIdSchemasGetError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub fn get_assistant_subgraphs_assistants_assistant_id_subgraphs_get_request_builder(
configuration: &configuration::Configuration,
assistant_id: &str,
recurse: Option<bool>,
) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
let p_path_assistant_id = assistant_id;
let p_query_recurse = recurse;
let uri_str = format!(
"{}/assistants/{assistant_id}/subgraphs",
configuration.base_path,
assistant_id = crate::apis::urlencode(p_path_assistant_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_recurse {
req_builder = req_builder.query(&[("recurse", ¶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());
}
Ok(req_builder)
}
pub async fn get_assistant_subgraphs_assistants_assistant_id_subgraphs_get(
configuration: &configuration::Configuration,
assistant_id: &str,
recurse: Option<bool>,
) -> Result<
std::collections::HashMap<String, models::GraphSchemaNoId>,
Error<GetAssistantSubgraphsAssistantsAssistantIdSubgraphsGetError>,
> {
let req_builder =
get_assistant_subgraphs_assistants_assistant_id_subgraphs_get_request_builder(
configuration,
assistant_id,
recurse,
)
.map_err(super::map_request_builder_error)?;
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 => Err(Error::from(serde_json::Error::custom(
"Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, models::GraphSchemaNoId>`",
))),
ContentType::Unsupported(unknown_type) => {
Err(Error::from(serde_json::Error::custom(format!(
"Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, models::GraphSchemaNoId>`"
))))
}
}
} else {
let content = resp.text().await?;
let entity: Option<GetAssistantSubgraphsAssistantsAssistantIdSubgraphsGetError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub fn get_assistant_subgraphs_assistants_assistant_id_subgraphs_namespace_get_request_builder(
configuration: &configuration::Configuration,
assistant_id: &str,
namespace: &str,
recurse: Option<bool>,
) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
let p_path_assistant_id = assistant_id;
let p_path_namespace = namespace;
let p_query_recurse = recurse;
let uri_str = format!(
"{}/assistants/{assistant_id}/subgraphs/{namespace}",
configuration.base_path,
assistant_id = crate::apis::urlencode(p_path_assistant_id),
namespace = crate::apis::urlencode(p_path_namespace)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_recurse {
req_builder = req_builder.query(&[("recurse", ¶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());
}
Ok(req_builder)
}
pub async fn get_assistant_subgraphs_assistants_assistant_id_subgraphs_namespace_get(
configuration: &configuration::Configuration,
assistant_id: &str,
namespace: &str,
recurse: Option<bool>,
) -> Result<
std::collections::HashMap<String, models::GraphSchemaNoId>,
Error<GetAssistantSubgraphsAssistantsAssistantIdSubgraphsNamespaceGetError>,
> {
let req_builder =
get_assistant_subgraphs_assistants_assistant_id_subgraphs_namespace_get_request_builder(
configuration,
assistant_id,
namespace,
recurse,
)
.map_err(super::map_request_builder_error)?;
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 => Err(Error::from(serde_json::Error::custom(
"Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, models::GraphSchemaNoId>`",
))),
ContentType::Unsupported(unknown_type) => {
Err(Error::from(serde_json::Error::custom(format!(
"Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, models::GraphSchemaNoId>`"
))))
}
}
} else {
let content = resp.text().await?;
let entity: Option<GetAssistantSubgraphsAssistantsAssistantIdSubgraphsNamespaceGetError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub fn get_assistant_versions_assistants_assistant_id_versions_get_request_builder(
configuration: &configuration::Configuration,
assistant_id: &str,
) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
let p_path_assistant_id = assistant_id;
let uri_str = format!(
"{}/assistants/{assistant_id}/versions",
configuration.base_path,
assistant_id = crate::apis::urlencode(p_path_assistant_id)
);
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());
}
Ok(req_builder)
}
pub async fn get_assistant_versions_assistants_assistant_id_versions_get(
configuration: &configuration::Configuration,
assistant_id: &str,
) -> Result<Vec<models::Assistant>, Error<GetAssistantVersionsAssistantsAssistantIdVersionsGetError>>
{
let req_builder = get_assistant_versions_assistants_assistant_id_versions_get_request_builder(
configuration,
assistant_id,
)
.map_err(super::map_request_builder_error)?;
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 => Err(Error::from(serde_json::Error::custom(
"Received `text/plain` content type response that cannot be converted to `Vec<models::Assistant>`",
))),
ContentType::Unsupported(unknown_type) => {
Err(Error::from(serde_json::Error::custom(format!(
"Received `{unknown_type}` content type response that cannot be converted to `Vec<models::Assistant>`"
))))
}
}
} else {
let content = resp.text().await?;
let entity: Option<GetAssistantVersionsAssistantsAssistantIdVersionsGetError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub fn patch_assistant_assistants_assistant_id_patch_request_builder(
configuration: &configuration::Configuration,
assistant_id: &str,
assistant_patch: models::AssistantPatch,
) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
let p_path_assistant_id = assistant_id;
let p_body_assistant_patch = assistant_patch;
let uri_str = format!(
"{}/assistants/{assistant_id}",
configuration.base_path,
assistant_id = crate::apis::urlencode(p_path_assistant_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::PATCH, &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_assistant_patch);
Ok(req_builder)
}
pub async fn patch_assistant_assistants_assistant_id_patch(
configuration: &configuration::Configuration,
assistant_id: &str,
assistant_patch: models::AssistantPatch,
) -> Result<models::Assistant, Error<PatchAssistantAssistantsAssistantIdPatchError>> {
let req_builder = patch_assistant_assistants_assistant_id_patch_request_builder(
configuration,
assistant_id,
assistant_patch,
)
.map_err(super::map_request_builder_error)?;
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 => Err(Error::from(serde_json::Error::custom(
"Received `text/plain` content type response that cannot be converted to `models::Assistant`",
))),
ContentType::Unsupported(unknown_type) => {
Err(Error::from(serde_json::Error::custom(format!(
"Received `{unknown_type}` content type response that cannot be converted to `models::Assistant`"
))))
}
}
} else {
let content = resp.text().await?;
let entity: Option<PatchAssistantAssistantsAssistantIdPatchError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub fn search_assistants_assistants_search_post_request_builder(
configuration: &configuration::Configuration,
assistant_search_request: models::AssistantSearchRequest,
) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
let p_body_assistant_search_request = assistant_search_request;
let uri_str = format!("{}/assistants/search", 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_assistant_search_request);
Ok(req_builder)
}
pub async fn search_assistants_assistants_search_post(
configuration: &configuration::Configuration,
assistant_search_request: models::AssistantSearchRequest,
) -> Result<Vec<models::Assistant>, Error<SearchAssistantsAssistantsSearchPostError>> {
let req_builder = search_assistants_assistants_search_post_request_builder(
configuration,
assistant_search_request,
)
.map_err(super::map_request_builder_error)?;
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 => Err(Error::from(serde_json::Error::custom(
"Received `text/plain` content type response that cannot be converted to `Vec<models::Assistant>`",
))),
ContentType::Unsupported(unknown_type) => {
Err(Error::from(serde_json::Error::custom(format!(
"Received `{unknown_type}` content type response that cannot be converted to `Vec<models::Assistant>`"
))))
}
}
} else {
let content = resp.text().await?;
let entity: Option<SearchAssistantsAssistantsSearchPostError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub fn set_latest_assistant_version_assistants_assistant_id_versions_post_request_builder(
configuration: &configuration::Configuration,
assistant_id: &str,
version: i32,
) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
let p_path_assistant_id = assistant_id;
let p_query_version = version;
let uri_str = format!(
"{}/assistants/{assistant_id}/latest",
configuration.base_path,
assistant_id = crate::apis::urlencode(p_path_assistant_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
req_builder = req_builder.query(&[("version", &p_query_version.to_string())]);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
Ok(req_builder)
}
pub async fn set_latest_assistant_version_assistants_assistant_id_versions_post(
configuration: &configuration::Configuration,
assistant_id: &str,
version: i32,
) -> Result<models::Assistant, Error<SetLatestAssistantVersionAssistantsAssistantIdVersionsPostError>>
{
let req_builder =
set_latest_assistant_version_assistants_assistant_id_versions_post_request_builder(
configuration,
assistant_id,
version,
)
.map_err(super::map_request_builder_error)?;
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 => Err(Error::from(serde_json::Error::custom(
"Received `text/plain` content type response that cannot be converted to `models::Assistant`",
))),
ContentType::Unsupported(unknown_type) => {
Err(Error::from(serde_json::Error::custom(format!(
"Received `{unknown_type}` content type response that cannot be converted to `models::Assistant`"
))))
}
}
} else {
let content = resp.text().await?;
let entity: Option<SetLatestAssistantVersionAssistantsAssistantIdVersionsPostError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}