#![allow(clippy::needless_return, clippy::into_iter_on_ref)]
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 CreateAgentError {
Status400(models::ErrorResponse2),
Status401(models::ErrorResponse2),
Status403(models::ErrorResponse2),
Status404(models::ErrorResponse2),
Status409(models::ErrorResponse2),
Status500(models::ErrorResponse2),
Status503(models::ErrorResponse2),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateAgentEnvironmentError {
Status400(models::ErrorResponse2),
Status401(models::ErrorResponse2),
Status403(models::ErrorResponse2),
Status404(models::ErrorResponse2),
Status409(models::ErrorResponse2),
Status429(models::ErrorResponse2),
Status500(models::ErrorResponse2),
Status503(models::ErrorResponse2),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateAgentEnvironmentFileError {
Status400(models::ErrorResponse2),
Status401(models::ErrorResponse2),
Status403(models::ErrorResponse2),
Status404(models::ErrorResponse2),
Status409(models::ErrorResponse2),
Status429(models::ErrorResponse2),
Status500(models::ErrorResponse2),
Status503(models::ErrorResponse2),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateAgentEnvironmentTemplateError {
Status400(models::ErrorResponse2),
Status401(models::ErrorResponse2),
Status403(models::ErrorResponse2),
Status404(models::ErrorResponse2),
Status500(models::ErrorResponse2),
Status503(models::ErrorResponse2),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateAgentSessionError {
Status400(models::ErrorResponse2),
Status401(models::ErrorResponse2),
Status403(models::ErrorResponse2),
Status404(models::ErrorResponse2),
Status409(models::ErrorResponse2),
Status429(models::ErrorResponse2),
Status500(models::ErrorResponse2),
Status503(models::ErrorResponse2),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateAgentSessionEventsError {
Status400(models::ErrorResponse2),
Status401(models::ErrorResponse2),
Status403(models::ErrorResponse2),
Status404(models::ErrorResponse2),
Status409(models::ErrorResponse2),
Status500(models::ErrorResponse2),
Status503(models::ErrorResponse2),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteAgentError {
Status400(models::ErrorResponse2),
Status401(models::ErrorResponse2),
Status403(models::ErrorResponse2),
Status404(models::ErrorResponse2),
Status409(models::ErrorResponse2),
Status500(models::ErrorResponse2),
Status503(models::ErrorResponse2),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteAgentEnvironmentTemplateError {
Status400(models::ErrorResponse2),
Status401(models::ErrorResponse2),
Status403(models::ErrorResponse2),
Status404(models::ErrorResponse2),
Status409(models::ErrorResponse2),
Status500(models::ErrorResponse2),
Status503(models::ErrorResponse2),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteAgentSessionError {
Status400(models::ErrorResponse2),
Status401(models::ErrorResponse2),
Status403(models::ErrorResponse2),
Status404(models::ErrorResponse2),
Status409(models::ErrorResponse2),
Status500(models::ErrorResponse2),
Status503(models::ErrorResponse2),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteAgentSessionArtifactError {
Status400(models::ErrorResponse2),
Status401(models::ErrorResponse2),
Status403(models::ErrorResponse2),
Status404(models::ErrorResponse2),
Status409(models::ErrorResponse2),
Status500(models::ErrorResponse2),
Status503(models::ErrorResponse2),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListAgentEnvironmentFilesError {
Status400(models::ErrorResponse2),
Status401(models::ErrorResponse2),
Status403(models::ErrorResponse2),
Status404(models::ErrorResponse2),
Status409(models::ErrorResponse2),
Status500(models::ErrorResponse2),
Status503(models::ErrorResponse2),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListAgentEnvironmentTemplatesError {
Status400(models::ErrorResponse2),
Status401(models::ErrorResponse2),
Status403(models::ErrorResponse2),
Status404(models::ErrorResponse2),
Status500(models::ErrorResponse2),
Status503(models::ErrorResponse2),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListAgentEnvironmentsError {
Status400(models::ErrorResponse2),
Status401(models::ErrorResponse2),
Status403(models::ErrorResponse2),
Status404(models::ErrorResponse2),
Status409(models::ErrorResponse2),
Status500(models::ErrorResponse2),
Status503(models::ErrorResponse2),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListAgentSessionArtifactsError {
Status400(models::ErrorResponse2),
Status401(models::ErrorResponse2),
Status403(models::ErrorResponse2),
Status404(models::ErrorResponse2),
Status409(models::ErrorResponse2),
Status500(models::ErrorResponse2),
Status503(models::ErrorResponse2),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListAgentSessionEventsError {
Status400(models::ErrorResponse2),
Status401(models::ErrorResponse2),
Status403(models::ErrorResponse2),
Status404(models::ErrorResponse2),
Status409(models::ErrorResponse2),
Status500(models::ErrorResponse2),
Status503(models::ErrorResponse2),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListAgentSessionItemsError {
Status400(models::ErrorResponse2),
Status401(models::ErrorResponse2),
Status403(models::ErrorResponse2),
Status404(models::ErrorResponse2),
Status409(models::ErrorResponse2),
Status500(models::ErrorResponse2),
Status503(models::ErrorResponse2),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListAgentSessionSubagentItemsError {
Status400(models::ErrorResponse2),
Status401(models::ErrorResponse2),
Status403(models::ErrorResponse2),
Status404(models::ErrorResponse2),
Status409(models::ErrorResponse2),
Status500(models::ErrorResponse2),
Status503(models::ErrorResponse2),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListAgentSessionSubagentTurnItemsError {
Status400(models::ErrorResponse2),
Status401(models::ErrorResponse2),
Status403(models::ErrorResponse2),
Status404(models::ErrorResponse2),
Status409(models::ErrorResponse2),
Status500(models::ErrorResponse2),
Status503(models::ErrorResponse2),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListAgentSessionSubagentTurnsError {
Status400(models::ErrorResponse2),
Status401(models::ErrorResponse2),
Status403(models::ErrorResponse2),
Status404(models::ErrorResponse2),
Status409(models::ErrorResponse2),
Status500(models::ErrorResponse2),
Status503(models::ErrorResponse2),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListAgentSessionSubagentsError {
Status400(models::ErrorResponse2),
Status401(models::ErrorResponse2),
Status403(models::ErrorResponse2),
Status404(models::ErrorResponse2),
Status409(models::ErrorResponse2),
Status500(models::ErrorResponse2),
Status503(models::ErrorResponse2),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListAgentSessionTracesError {
Status400(models::ErrorResponse2),
Status401(models::ErrorResponse2),
Status403(models::ErrorResponse2),
Status404(models::ErrorResponse2),
Status409(models::ErrorResponse2),
Status500(models::ErrorResponse2),
Status503(models::ErrorResponse2),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListAgentSessionTurnItemsError {
Status400(models::ErrorResponse2),
Status401(models::ErrorResponse2),
Status403(models::ErrorResponse2),
Status404(models::ErrorResponse2),
Status409(models::ErrorResponse2),
Status500(models::ErrorResponse2),
Status503(models::ErrorResponse2),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListAgentSessionTurnsError {
Status400(models::ErrorResponse2),
Status401(models::ErrorResponse2),
Status403(models::ErrorResponse2),
Status404(models::ErrorResponse2),
Status409(models::ErrorResponse2),
Status500(models::ErrorResponse2),
Status503(models::ErrorResponse2),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListAgentSessionsError {
Status400(models::ErrorResponse2),
Status401(models::ErrorResponse2),
Status403(models::ErrorResponse2),
Status404(models::ErrorResponse2),
Status409(models::ErrorResponse2),
Status500(models::ErrorResponse2),
Status503(models::ErrorResponse2),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListAgentsError {
Status400(models::ErrorResponse2),
Status401(models::ErrorResponse2),
Status403(models::ErrorResponse2),
Status404(models::ErrorResponse2),
Status409(models::ErrorResponse2),
Status500(models::ErrorResponse2),
Status503(models::ErrorResponse2),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RetrieveAgentError {
Status400(models::ErrorResponse2),
Status401(models::ErrorResponse2),
Status403(models::ErrorResponse2),
Status404(models::ErrorResponse2),
Status409(models::ErrorResponse2),
Status500(models::ErrorResponse2),
Status503(models::ErrorResponse2),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RetrieveAgentEnvironmentError {
Status400(models::ErrorResponse2),
Status401(models::ErrorResponse2),
Status403(models::ErrorResponse2),
Status404(models::ErrorResponse2),
Status409(models::ErrorResponse2),
Status500(models::ErrorResponse2),
Status503(models::ErrorResponse2),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RetrieveAgentEnvironmentTemplateError {
Status400(models::ErrorResponse2),
Status401(models::ErrorResponse2),
Status403(models::ErrorResponse2),
Status404(models::ErrorResponse2),
Status500(models::ErrorResponse2),
Status503(models::ErrorResponse2),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RetrieveAgentSessionError {
Status400(models::ErrorResponse2),
Status401(models::ErrorResponse2),
Status403(models::ErrorResponse2),
Status404(models::ErrorResponse2),
Status409(models::ErrorResponse2),
Status500(models::ErrorResponse2),
Status503(models::ErrorResponse2),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RetrieveAgentSessionArtifactError {
Status400(models::ErrorResponse2),
Status401(models::ErrorResponse2),
Status403(models::ErrorResponse2),
Status404(models::ErrorResponse2),
Status409(models::ErrorResponse2),
Status500(models::ErrorResponse2),
Status503(models::ErrorResponse2),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RetrieveAgentSessionArtifactContentError {
Status400(models::ErrorResponse2),
Status401(models::ErrorResponse2),
Status403(models::ErrorResponse2),
Status404(models::ErrorResponse2),
Status409(models::ErrorResponse2),
Status500(models::ErrorResponse2),
Status503(models::ErrorResponse2),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RetrieveAgentSessionSubagentError {
Status400(models::ErrorResponse2),
Status401(models::ErrorResponse2),
Status403(models::ErrorResponse2),
Status404(models::ErrorResponse2),
Status409(models::ErrorResponse2),
Status500(models::ErrorResponse2),
Status503(models::ErrorResponse2),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RetrieveAgentSessionSubagentTurnError {
Status400(models::ErrorResponse2),
Status401(models::ErrorResponse2),
Status403(models::ErrorResponse2),
Status404(models::ErrorResponse2),
Status409(models::ErrorResponse2),
Status500(models::ErrorResponse2),
Status503(models::ErrorResponse2),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RetrieveAgentSessionTurnError {
Status400(models::ErrorResponse2),
Status401(models::ErrorResponse2),
Status403(models::ErrorResponse2),
Status404(models::ErrorResponse2),
Status409(models::ErrorResponse2),
Status500(models::ErrorResponse2),
Status503(models::ErrorResponse2),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateAgentError {
Status400(models::ErrorResponse2),
Status401(models::ErrorResponse2),
Status403(models::ErrorResponse2),
Status404(models::ErrorResponse2),
Status409(models::ErrorResponse2),
Status500(models::ErrorResponse2),
Status503(models::ErrorResponse2),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateAgentEnvironmentTemplateError {
Status400(models::ErrorResponse2),
Status401(models::ErrorResponse2),
Status403(models::ErrorResponse2),
Status404(models::ErrorResponse2),
Status409(models::ErrorResponse2),
Status500(models::ErrorResponse2),
Status503(models::ErrorResponse2),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateAgentSessionError {
Status400(models::ErrorResponse2),
Status401(models::ErrorResponse2),
Status403(models::ErrorResponse2),
Status404(models::ErrorResponse2),
Status409(models::ErrorResponse2),
Status500(models::ErrorResponse2),
Status503(models::ErrorResponse2),
UnknownValue(serde_json::Value),
}
#[bon::builder]
pub async fn create_agent(
configuration: &configuration::Configuration,
create_agent_params: Option<models::CreateAgentParams>,
) -> Result<models::AgentResource, Error<CreateAgentError>> {
let p_body_create_agent_params = create_agent_params;
let uri_str = format!("{}/agents", 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 token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_create_agent_params);
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::AgentResource`"))),
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::AgentResource`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateAgentError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(Box::new(ResponseContent {
status,
content,
entity,
})))
}
}
#[bon::builder]
pub async fn create_agent_environment(
configuration: &configuration::Configuration,
create_agent_environment_params: models::CreateAgentEnvironmentParams,
idempotency_key: Option<&str>,
) -> Result<models::PublicEnvironmentResource, Error<CreateAgentEnvironmentError>> {
let p_body_create_agent_environment_params = create_agent_environment_params;
let p_header_idempotency_key = idempotency_key;
let uri_str = format!("{}/agents/environments", 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(param_value) = p_header_idempotency_key {
req_builder = req_builder.header("Idempotency-Key", param_value.to_string());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_create_agent_environment_params);
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::PublicEnvironmentResource`"))),
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::PublicEnvironmentResource`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateAgentEnvironmentError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(Box::new(ResponseContent {
status,
content,
entity,
})))
}
}
#[bon::builder]
pub async fn create_agent_environment_file(
configuration: &configuration::Configuration,
environment_id: &str,
hosted_environment_file_param: Option<models::HostedEnvironmentFileParam>,
) -> Result<models::EnvironmentFileResource, Error<CreateAgentEnvironmentFileError>> {
let p_path_environment_id = environment_id;
let p_body_hosted_environment_file_param = hosted_environment_file_param;
let uri_str = format!(
"{}/agents/environments/{environment_id}/files",
configuration.base_path,
environment_id = crate::apis::urlencode(p_path_environment_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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_hosted_environment_file_param);
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::EnvironmentFileResource`"))),
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::EnvironmentFileResource`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateAgentEnvironmentFileError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(Box::new(ResponseContent {
status,
content,
entity,
})))
}
}
#[bon::builder]
pub async fn create_agent_environment_template(
configuration: &configuration::Configuration,
create_environment_template_params: Option<models::CreateEnvironmentTemplateParams>,
) -> Result<models::EnvironmentTemplateResource, Error<CreateAgentEnvironmentTemplateError>> {
let p_body_create_environment_template_params = create_environment_template_params;
let uri_str = format!("{}/agents/environments/templates", 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 token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_create_environment_template_params);
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::EnvironmentTemplateResource`"))),
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::EnvironmentTemplateResource`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateAgentEnvironmentTemplateError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(Box::new(ResponseContent {
status,
content,
entity,
})))
}
}
#[bon::builder]
pub async fn create_agent_session(
configuration: &configuration::Configuration,
create_agent_session_params: Option<models::CreateAgentSessionParams>,
) -> Result<models::SessionResource, Error<CreateAgentSessionError>> {
let p_body_create_agent_session_params = create_agent_session_params;
let uri_str = format!("{}/agents/sessions", 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 token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_create_agent_session_params);
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::SessionResource`"))),
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::SessionResource`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateAgentSessionError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(Box::new(ResponseContent {
status,
content,
entity,
})))
}
}
#[bon::builder]
pub async fn create_agent_session_events(
configuration: &configuration::Configuration,
session_id: &str,
idempotency_key: Option<&str>,
create_session_events_params: Option<models::CreateSessionEventsParams>,
) -> Result<(), Error<CreateAgentSessionEventsError>> {
let p_path_session_id = session_id;
let p_header_idempotency_key = idempotency_key;
let p_body_create_session_events_params = create_session_events_params;
let uri_str = format!(
"{}/agents/sessions/{session_id}/events",
configuration.base_path,
session_id = crate::apis::urlencode(p_path_session_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());
}
if let Some(param_value) = p_header_idempotency_key {
req_builder = req_builder.header("Idempotency-Key", param_value.to_string());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_create_session_events_params);
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<CreateAgentSessionEventsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(Box::new(ResponseContent {
status,
content,
entity,
})))
}
}
#[bon::builder]
pub async fn delete_agent(
configuration: &configuration::Configuration,
agent_id: &str,
) -> Result<models::DeletedAgentResource, Error<DeleteAgentError>> {
let p_path_agent_id = agent_id;
let uri_str = format!(
"{}/agents/{agent_id}",
configuration.base_path,
agent_id = crate::apis::urlencode(p_path_agent_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());
}
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 `models::DeletedAgentResource`"))),
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::DeletedAgentResource`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteAgentError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(Box::new(ResponseContent {
status,
content,
entity,
})))
}
}
#[bon::builder]
pub async fn delete_agent_environment_template(
configuration: &configuration::Configuration,
environment_template_id: &str,
) -> Result<models::DeletedEnvironmentTemplateResource, Error<DeleteAgentEnvironmentTemplateError>>
{
let p_path_environment_template_id = environment_template_id;
let uri_str = format!(
"{}/agents/environments/templates/{environment_template_id}",
configuration.base_path,
environment_template_id = crate::apis::urlencode(p_path_environment_template_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());
}
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 `models::DeletedEnvironmentTemplateResource`"))),
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::DeletedEnvironmentTemplateResource`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteAgentEnvironmentTemplateError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(Box::new(ResponseContent {
status,
content,
entity,
})))
}
}
#[bon::builder]
pub async fn delete_agent_session(
configuration: &configuration::Configuration,
session_id: &str,
) -> Result<models::DeletedSessionResource, Error<DeleteAgentSessionError>> {
let p_path_session_id = session_id;
let uri_str = format!(
"{}/agents/sessions/{session_id}",
configuration.base_path,
session_id = crate::apis::urlencode(p_path_session_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());
}
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 `models::DeletedSessionResource`"))),
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::DeletedSessionResource`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteAgentSessionError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(Box::new(ResponseContent {
status,
content,
entity,
})))
}
}
#[bon::builder]
pub async fn delete_agent_session_artifact(
configuration: &configuration::Configuration,
session_id: &str,
artifact_id: &str,
) -> Result<models::DeletedSessionArtifactResource, Error<DeleteAgentSessionArtifactError>> {
let p_path_session_id = session_id;
let p_path_artifact_id = artifact_id;
let uri_str = format!(
"{}/agents/sessions/{session_id}/artifacts/{artifact_id}",
configuration.base_path,
session_id = crate::apis::urlencode(p_path_session_id),
artifact_id = crate::apis::urlencode(p_path_artifact_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());
}
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 `models::DeletedSessionArtifactResource`"))),
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::DeletedSessionArtifactResource`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteAgentSessionArtifactError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(Box::new(ResponseContent {
status,
content,
entity,
})))
}
}
#[bon::builder]
pub async fn list_agent_environment_files(
configuration: &configuration::Configuration,
environment_id: &str,
path: Option<&str>,
limit: Option<i64>,
order: Option<models::ListOrderParam>,
page: Option<&str>,
) -> Result<models::EnvironmentFileListResource, Error<ListAgentEnvironmentFilesError>> {
let p_path_environment_id = environment_id;
let p_query_path = path;
let p_query_limit = limit;
let p_query_order = order;
let p_query_page = page;
let uri_str = format!(
"{}/agents/environments/{environment_id}/files",
configuration.base_path,
environment_id = crate::apis::urlencode(p_path_environment_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_path {
req_builder = req_builder.query(&[("path", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶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_page {
req_builder = req_builder.query(&[("page", ¶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 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 `models::EnvironmentFileListResource`"))),
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::EnvironmentFileListResource`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListAgentEnvironmentFilesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(Box::new(ResponseContent {
status,
content,
entity,
})))
}
}
#[bon::builder]
pub async fn list_agent_environment_templates(
configuration: &configuration::Configuration,
limit: Option<i64>,
order: Option<models::ListOrderParam>,
after: Option<&str>,
) -> Result<models::EnvironmentTemplateListResource, Error<ListAgentEnvironmentTemplatesError>> {
let p_query_limit = limit;
let p_query_order = order;
let p_query_after = after;
let uri_str = format!("{}/agents/environments/templates", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶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_after {
req_builder = req_builder.query(&[("after", ¶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 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 `models::EnvironmentTemplateListResource`"))),
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::EnvironmentTemplateListResource`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListAgentEnvironmentTemplatesError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(Box::new(ResponseContent {
status,
content,
entity,
})))
}
}
#[bon::builder]
pub async fn list_agent_environments(
configuration: &configuration::Configuration,
limit: Option<i64>,
order: Option<models::ListOrderParam>,
after: Option<&str>,
r#type: Option<models::EnvironmentTypeParam>,
) -> Result<models::AgentEnvironmentListResource, Error<ListAgentEnvironmentsError>> {
let p_query_limit = limit;
let p_query_order = order;
let p_query_after = after;
let p_query_type = r#type;
let uri_str = format!("{}/agents/environments", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶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_after {
req_builder = req_builder.query(&[("after", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_type {
req_builder = req_builder.query(&[("type", ¶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 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 `models::AgentEnvironmentListResource`"))),
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::AgentEnvironmentListResource`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListAgentEnvironmentsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(Box::new(ResponseContent {
status,
content,
entity,
})))
}
}
#[bon::builder]
pub async fn list_agent_session_artifacts(
configuration: &configuration::Configuration,
session_id: &str,
limit: Option<i64>,
order: Option<models::ListOrderParam>,
after: Option<&str>,
environment_id: Option<&str>,
) -> Result<models::SessionArtifactListResource, Error<ListAgentSessionArtifactsError>> {
let p_path_session_id = session_id;
let p_query_limit = limit;
let p_query_order = order;
let p_query_after = after;
let p_query_environment_id = environment_id;
let uri_str = format!(
"{}/agents/sessions/{session_id}/artifacts",
configuration.base_path,
session_id = crate::apis::urlencode(p_path_session_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶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_after {
req_builder = req_builder.query(&[("after", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_environment_id {
req_builder = req_builder.query(&[("environment_id", ¶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 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 `models::SessionArtifactListResource`"))),
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::SessionArtifactListResource`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListAgentSessionArtifactsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(Box::new(ResponseContent {
status,
content,
entity,
})))
}
}
#[bon::builder]
pub async fn list_agent_session_events(
configuration: &configuration::Configuration,
session_id: &str,
) -> Result<models::SessionEvent, Error<ListAgentSessionEventsError>> {
let p_path_session_id = session_id;
let uri_str = format!(
"{}/agents/sessions/{session_id}/events",
configuration.base_path,
session_id = crate::apis::urlencode(p_path_session_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());
}
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 `models::SessionEvent`"))),
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::SessionEvent`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListAgentSessionEventsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(Box::new(ResponseContent {
status,
content,
entity,
})))
}
}
#[bon::builder]
pub async fn list_agent_session_items(
configuration: &configuration::Configuration,
session_id: &str,
limit: Option<i64>,
order: Option<models::ListOrderParam>,
after: Option<&str>,
) -> Result<models::SessionItemListResource, Error<ListAgentSessionItemsError>> {
let p_path_session_id = session_id;
let p_query_limit = limit;
let p_query_order = order;
let p_query_after = after;
let uri_str = format!(
"{}/agents/sessions/{session_id}/items",
configuration.base_path,
session_id = crate::apis::urlencode(p_path_session_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶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_after {
req_builder = req_builder.query(&[("after", ¶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 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 `models::SessionItemListResource`"))),
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::SessionItemListResource`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListAgentSessionItemsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(Box::new(ResponseContent {
status,
content,
entity,
})))
}
}
#[bon::builder]
pub async fn list_agent_session_subagent_items(
configuration: &configuration::Configuration,
session_id: &str,
subagent_id: &str,
limit: Option<i64>,
order: Option<models::ListOrderParam>,
after: Option<&str>,
) -> Result<models::SessionItemListResource, Error<ListAgentSessionSubagentItemsError>> {
let p_path_session_id = session_id;
let p_path_subagent_id = subagent_id;
let p_query_limit = limit;
let p_query_order = order;
let p_query_after = after;
let uri_str = format!(
"{}/agents/sessions/{session_id}/subagents/{subagent_id}/items",
configuration.base_path,
session_id = crate::apis::urlencode(p_path_session_id),
subagent_id = crate::apis::urlencode(p_path_subagent_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶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_after {
req_builder = req_builder.query(&[("after", ¶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 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 `models::SessionItemListResource`"))),
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::SessionItemListResource`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListAgentSessionSubagentItemsError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(Box::new(ResponseContent {
status,
content,
entity,
})))
}
}
#[bon::builder]
pub async fn list_agent_session_subagent_turn_items(
configuration: &configuration::Configuration,
session_id: &str,
subagent_id: &str,
turn_id: &str,
limit: Option<i64>,
order: Option<models::ListOrderParam>,
after: Option<&str>,
) -> Result<models::SessionItemListResource, Error<ListAgentSessionSubagentTurnItemsError>> {
let p_path_session_id = session_id;
let p_path_subagent_id = subagent_id;
let p_path_turn_id = turn_id;
let p_query_limit = limit;
let p_query_order = order;
let p_query_after = after;
let uri_str = format!(
"{}/agents/sessions/{session_id}/subagents/{subagent_id}/turns/{turn_id}/items",
configuration.base_path,
session_id = crate::apis::urlencode(p_path_session_id),
subagent_id = crate::apis::urlencode(p_path_subagent_id),
turn_id = crate::apis::urlencode(p_path_turn_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶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_after {
req_builder = req_builder.query(&[("after", ¶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 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 `models::SessionItemListResource`"))),
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::SessionItemListResource`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListAgentSessionSubagentTurnItemsError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(Box::new(ResponseContent {
status,
content,
entity,
})))
}
}
#[bon::builder]
pub async fn list_agent_session_subagent_turns(
configuration: &configuration::Configuration,
session_id: &str,
subagent_id: &str,
limit: Option<i64>,
order: Option<models::ListOrderParam>,
after: Option<&str>,
) -> Result<models::SessionTurnListResource, Error<ListAgentSessionSubagentTurnsError>> {
let p_path_session_id = session_id;
let p_path_subagent_id = subagent_id;
let p_query_limit = limit;
let p_query_order = order;
let p_query_after = after;
let uri_str = format!(
"{}/agents/sessions/{session_id}/subagents/{subagent_id}/turns",
configuration.base_path,
session_id = crate::apis::urlencode(p_path_session_id),
subagent_id = crate::apis::urlencode(p_path_subagent_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶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_after {
req_builder = req_builder.query(&[("after", ¶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 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 `models::SessionTurnListResource`"))),
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::SessionTurnListResource`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListAgentSessionSubagentTurnsError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(Box::new(ResponseContent {
status,
content,
entity,
})))
}
}
#[bon::builder]
pub async fn list_agent_session_subagents(
configuration: &configuration::Configuration,
session_id: &str,
limit: Option<i64>,
order: Option<models::ListOrderParam>,
after: Option<&str>,
) -> Result<models::ListAgentSessionSubagents200Response, Error<ListAgentSessionSubagentsError>> {
let p_path_session_id = session_id;
let p_query_limit = limit;
let p_query_order = order;
let p_query_after = after;
let uri_str = format!(
"{}/agents/sessions/{session_id}/subagents",
configuration.base_path,
session_id = crate::apis::urlencode(p_path_session_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶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_after {
req_builder = req_builder.query(&[("after", ¶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 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 `models::ListAgentSessionSubagents200Response`"))),
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::ListAgentSessionSubagents200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListAgentSessionSubagentsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(Box::new(ResponseContent {
status,
content,
entity,
})))
}
}
#[bon::builder]
pub async fn list_agent_session_traces(
configuration: &configuration::Configuration,
session_id: &str,
limit: Option<i64>,
order: Option<models::ListOrderParam>,
after: Option<&str>,
) -> Result<models::SessionTraceListResource, Error<ListAgentSessionTracesError>> {
let p_path_session_id = session_id;
let p_query_limit = limit;
let p_query_order = order;
let p_query_after = after;
let uri_str = format!(
"{}/agents/sessions/{session_id}/traces",
configuration.base_path,
session_id = crate::apis::urlencode(p_path_session_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶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_after {
req_builder = req_builder.query(&[("after", ¶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 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 `models::SessionTraceListResource`"))),
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::SessionTraceListResource`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListAgentSessionTracesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(Box::new(ResponseContent {
status,
content,
entity,
})))
}
}
#[bon::builder]
pub async fn list_agent_session_turn_items(
configuration: &configuration::Configuration,
session_id: &str,
turn_id: &str,
limit: Option<i64>,
order: Option<models::ListOrderParam>,
after: Option<&str>,
) -> Result<models::SessionItemListResource, Error<ListAgentSessionTurnItemsError>> {
let p_path_session_id = session_id;
let p_path_turn_id = turn_id;
let p_query_limit = limit;
let p_query_order = order;
let p_query_after = after;
let uri_str = format!(
"{}/agents/sessions/{session_id}/turns/{turn_id}/items",
configuration.base_path,
session_id = crate::apis::urlencode(p_path_session_id),
turn_id = crate::apis::urlencode(p_path_turn_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶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_after {
req_builder = req_builder.query(&[("after", ¶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 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 `models::SessionItemListResource`"))),
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::SessionItemListResource`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListAgentSessionTurnItemsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(Box::new(ResponseContent {
status,
content,
entity,
})))
}
}
#[bon::builder]
pub async fn list_agent_session_turns(
configuration: &configuration::Configuration,
session_id: &str,
limit: Option<i64>,
order: Option<models::ListOrderParam>,
after: Option<&str>,
) -> Result<models::SessionTurnListResource, Error<ListAgentSessionTurnsError>> {
let p_path_session_id = session_id;
let p_query_limit = limit;
let p_query_order = order;
let p_query_after = after;
let uri_str = format!(
"{}/agents/sessions/{session_id}/turns",
configuration.base_path,
session_id = crate::apis::urlencode(p_path_session_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶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_after {
req_builder = req_builder.query(&[("after", ¶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 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 `models::SessionTurnListResource`"))),
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::SessionTurnListResource`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListAgentSessionTurnsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(Box::new(ResponseContent {
status,
content,
entity,
})))
}
}
#[bon::builder]
pub async fn list_agent_sessions(
configuration: &configuration::Configuration,
limit: Option<i64>,
order: Option<models::ListOrderParam>,
after: Option<&str>,
agent_id: Option<&str>,
) -> Result<models::SessionListResource, Error<ListAgentSessionsError>> {
let p_query_limit = limit;
let p_query_order = order;
let p_query_after = after;
let p_query_agent_id = agent_id;
let uri_str = format!("{}/agents/sessions", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶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_after {
req_builder = req_builder.query(&[("after", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_agent_id {
req_builder = req_builder.query(&[("agent_id", ¶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 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 `models::SessionListResource`"))),
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::SessionListResource`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListAgentSessionsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(Box::new(ResponseContent {
status,
content,
entity,
})))
}
}
#[bon::builder]
pub async fn list_agents(
configuration: &configuration::Configuration,
limit: Option<i64>,
order: Option<models::ListOrderParam>,
after: Option<&str>,
) -> Result<models::AgentListResource, Error<ListAgentsError>> {
let p_query_limit = limit;
let p_query_order = order;
let p_query_after = after;
let uri_str = format!("{}/agents", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶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_after {
req_builder = req_builder.query(&[("after", ¶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 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 `models::AgentListResource`"))),
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::AgentListResource`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListAgentsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(Box::new(ResponseContent {
status,
content,
entity,
})))
}
}
#[bon::builder]
pub async fn retrieve_agent(
configuration: &configuration::Configuration,
agent_id: &str,
) -> Result<models::AgentResource, Error<RetrieveAgentError>> {
let p_path_agent_id = agent_id;
let uri_str = format!(
"{}/agents/{agent_id}",
configuration.base_path,
agent_id = crate::apis::urlencode(p_path_agent_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());
}
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 `models::AgentResource`"))),
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::AgentResource`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<RetrieveAgentError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(Box::new(ResponseContent {
status,
content,
entity,
})))
}
}
#[bon::builder]
pub async fn retrieve_agent_environment(
configuration: &configuration::Configuration,
environment_id: &str,
) -> Result<models::PublicEnvironmentResource, Error<RetrieveAgentEnvironmentError>> {
let p_path_environment_id = environment_id;
let uri_str = format!(
"{}/agents/environments/{environment_id}",
configuration.base_path,
environment_id = crate::apis::urlencode(p_path_environment_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());
}
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 `models::PublicEnvironmentResource`"))),
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::PublicEnvironmentResource`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<RetrieveAgentEnvironmentError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(Box::new(ResponseContent {
status,
content,
entity,
})))
}
}
#[bon::builder]
pub async fn retrieve_agent_environment_template(
configuration: &configuration::Configuration,
environment_template_id: &str,
) -> Result<models::EnvironmentTemplateResource, Error<RetrieveAgentEnvironmentTemplateError>> {
let p_path_environment_template_id = environment_template_id;
let uri_str = format!(
"{}/agents/environments/templates/{environment_template_id}",
configuration.base_path,
environment_template_id = crate::apis::urlencode(p_path_environment_template_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());
}
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 `models::EnvironmentTemplateResource`"))),
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::EnvironmentTemplateResource`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<RetrieveAgentEnvironmentTemplateError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(Box::new(ResponseContent {
status,
content,
entity,
})))
}
}
#[bon::builder]
pub async fn retrieve_agent_session(
configuration: &configuration::Configuration,
session_id: &str,
) -> Result<models::SessionResource, Error<RetrieveAgentSessionError>> {
let p_path_session_id = session_id;
let uri_str = format!(
"{}/agents/sessions/{session_id}",
configuration.base_path,
session_id = crate::apis::urlencode(p_path_session_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());
}
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 `models::SessionResource`"))),
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::SessionResource`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<RetrieveAgentSessionError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(Box::new(ResponseContent {
status,
content,
entity,
})))
}
}
#[bon::builder]
pub async fn retrieve_agent_session_artifact(
configuration: &configuration::Configuration,
session_id: &str,
artifact_id: &str,
) -> Result<models::SessionArtifactResource, Error<RetrieveAgentSessionArtifactError>> {
let p_path_session_id = session_id;
let p_path_artifact_id = artifact_id;
let uri_str = format!(
"{}/agents/sessions/{session_id}/artifacts/{artifact_id}",
configuration.base_path,
session_id = crate::apis::urlencode(p_path_session_id),
artifact_id = crate::apis::urlencode(p_path_artifact_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());
}
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 `models::SessionArtifactResource`"))),
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::SessionArtifactResource`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<RetrieveAgentSessionArtifactError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(Box::new(ResponseContent {
status,
content,
entity,
})))
}
}
#[bon::builder]
pub async fn retrieve_agent_session_artifact_content(
configuration: &configuration::Configuration,
session_id: &str,
artifact_id: &str,
) -> Result<reqwest::Response, Error<RetrieveAgentSessionArtifactContentError>> {
let p_path_session_id = session_id;
let p_path_artifact_id = artifact_id;
let uri_str = format!(
"{}/agents/sessions/{session_id}/artifacts/{artifact_id}/content",
configuration.base_path,
session_id = crate::apis::urlencode(p_path_session_id),
artifact_id = crate::apis::urlencode(p_path_artifact_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());
}
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();
if !status.is_client_error() && !status.is_server_error() {
Ok(resp)
} else {
let content = resp.text().await?;
let entity: Option<RetrieveAgentSessionArtifactContentError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(Box::new(ResponseContent {
status,
content,
entity,
})))
}
}
#[bon::builder]
pub async fn retrieve_agent_session_subagent(
configuration: &configuration::Configuration,
session_id: &str,
subagent_id: &str,
) -> Result<models::SubagentResource, Error<RetrieveAgentSessionSubagentError>> {
let p_path_session_id = session_id;
let p_path_subagent_id = subagent_id;
let uri_str = format!(
"{}/agents/sessions/{session_id}/subagents/{subagent_id}",
configuration.base_path,
session_id = crate::apis::urlencode(p_path_session_id),
subagent_id = crate::apis::urlencode(p_path_subagent_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());
}
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 `models::SubagentResource`"))),
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::SubagentResource`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<RetrieveAgentSessionSubagentError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(Box::new(ResponseContent {
status,
content,
entity,
})))
}
}
#[bon::builder]
pub async fn retrieve_agent_session_subagent_turn(
configuration: &configuration::Configuration,
session_id: &str,
subagent_id: &str,
turn_id: &str,
) -> Result<models::TurnResource, Error<RetrieveAgentSessionSubagentTurnError>> {
let p_path_session_id = session_id;
let p_path_subagent_id = subagent_id;
let p_path_turn_id = turn_id;
let uri_str = format!(
"{}/agents/sessions/{session_id}/subagents/{subagent_id}/turns/{turn_id}",
configuration.base_path,
session_id = crate::apis::urlencode(p_path_session_id),
subagent_id = crate::apis::urlencode(p_path_subagent_id),
turn_id = crate::apis::urlencode(p_path_turn_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());
}
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 `models::TurnResource`"))),
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::TurnResource`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<RetrieveAgentSessionSubagentTurnError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(Box::new(ResponseContent {
status,
content,
entity,
})))
}
}
#[bon::builder]
pub async fn retrieve_agent_session_turn(
configuration: &configuration::Configuration,
session_id: &str,
turn_id: &str,
) -> Result<models::TurnResource, Error<RetrieveAgentSessionTurnError>> {
let p_path_session_id = session_id;
let p_path_turn_id = turn_id;
let uri_str = format!(
"{}/agents/sessions/{session_id}/turns/{turn_id}",
configuration.base_path,
session_id = crate::apis::urlencode(p_path_session_id),
turn_id = crate::apis::urlencode(p_path_turn_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());
}
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 `models::TurnResource`"))),
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::TurnResource`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<RetrieveAgentSessionTurnError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(Box::new(ResponseContent {
status,
content,
entity,
})))
}
}
#[bon::builder]
pub async fn update_agent(
configuration: &configuration::Configuration,
agent_id: &str,
update_agent_params: Option<models::UpdateAgentParams>,
) -> Result<models::AgentResource, Error<UpdateAgentError>> {
let p_path_agent_id = agent_id;
let p_body_update_agent_params = update_agent_params;
let uri_str = format!(
"{}/agents/{agent_id}",
configuration.base_path,
agent_id = crate::apis::urlencode(p_path_agent_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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_update_agent_params);
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::AgentResource`"))),
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::AgentResource`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateAgentError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(Box::new(ResponseContent {
status,
content,
entity,
})))
}
}
#[bon::builder]
pub async fn update_agent_environment_template(
configuration: &configuration::Configuration,
environment_template_id: &str,
update_environment_template_params: Option<models::UpdateEnvironmentTemplateParams>,
) -> Result<models::EnvironmentTemplateResource, Error<UpdateAgentEnvironmentTemplateError>> {
let p_path_environment_template_id = environment_template_id;
let p_body_update_environment_template_params = update_environment_template_params;
let uri_str = format!(
"{}/agents/environments/templates/{environment_template_id}",
configuration.base_path,
environment_template_id = crate::apis::urlencode(p_path_environment_template_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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_update_environment_template_params);
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::EnvironmentTemplateResource`"))),
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::EnvironmentTemplateResource`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateAgentEnvironmentTemplateError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(Box::new(ResponseContent {
status,
content,
entity,
})))
}
}
#[bon::builder]
pub async fn update_agent_session(
configuration: &configuration::Configuration,
session_id: &str,
update_agent_session_params: Option<models::UpdateAgentSessionParams>,
) -> Result<models::SessionResource, Error<UpdateAgentSessionError>> {
let p_path_session_id = session_id;
let p_body_update_agent_session_params = update_agent_session_params;
let uri_str = format!(
"{}/agents/sessions/{session_id}",
configuration.base_path,
session_id = crate::apis::urlencode(p_path_session_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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_update_agent_session_params);
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::SessionResource`"))),
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::SessionResource`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateAgentSessionError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(Box::new(ResponseContent {
status,
content,
entity,
})))
}
}