use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct SubagentResource {
#[serde(rename = "id")]
pub id: String,
#[serde(rename = "object")]
pub object: models::SubagentObjectResource,
#[serde(rename = "session_id")]
pub session_id: String,
#[serde(rename = "name", deserialize_with = "Option::deserialize")]
pub name: Option<String>,
#[serde(rename = "instructions", deserialize_with = "Option::deserialize")]
pub instructions: Option<Vec<models::AgentContentResource>>,
#[serde(rename = "parent_agent_id")]
pub parent_agent_id: String,
#[serde(rename = "status")]
pub status: models::SubagentStatusResource,
#[serde(rename = "opened_at")]
pub opened_at: i64,
#[serde(rename = "closed_at", deserialize_with = "Option::deserialize")]
pub closed_at: Option<i64>,
}
impl SubagentResource {
pub fn new(
id: String,
object: models::SubagentObjectResource,
session_id: String,
name: Option<String>,
instructions: Option<Vec<models::AgentContentResource>>,
parent_agent_id: String,
status: models::SubagentStatusResource,
opened_at: i64,
closed_at: Option<i64>,
) -> SubagentResource {
SubagentResource {
id,
object,
session_id,
name,
instructions,
parent_agent_id,
status,
opened_at,
closed_at,
}
}
}
impl std::fmt::Display for SubagentResource {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match serde_json::to_string(self) {
Ok(s) => write!(f, "{}", s),
Err(_) => Err(std::fmt::Error),
}
}
}