brokkr-models::models::agent_events Rust
Structs
brokkr-models::models::agent_events::AgentEvent
pub
Derives: Queryable, Selectable, Identifiable, AsChangeset, Debug, Clone, Serialize, Deserialize, Eq, PartialEq, Hash, ToSchema, ``
Represents an agent event in the database.
Fields
| Name | Type | Description |
|---|---|---|
id | Uuid | Unique identifier for the event. |
created_at | DateTime < Utc > | Timestamp when the event was created. |
updated_at | DateTime < Utc > | Timestamp when the event was last updated. |
deleted_at | Option < DateTime < Utc > > | Timestamp for soft deletion, if applicable. |
agent_id | Uuid | ID of the agent associated with this event. |
deployment_object_id | Uuid | ID of the deployment object associated with this event. |
event_type | String | Type of the event. |
status | String | Status of the event (e.g., “SUCCESS”, “FAILURE”, “IN_PROGRESS”, “PENDING”). |
message | Option < String > | Optional message providing additional details about the event. |
brokkr-models::models::agent_events::NewAgentEvent
pub
Derives: Insertable, Debug, Clone, Serialize, Deserialize, ToSchema
Represents a new agent event to be inserted into the database.
Fields
| Name | Type | Description |
|---|---|---|
agent_id | Uuid | ID of the agent associated with this event. |
deployment_object_id | Uuid | ID of the deployment object associated with this event. |
event_type | String | Type of the event. |
status | String | Status of the event (e.g., “SUCCESS”, “FAILURE”). |
message | Option < String > | Optional message providing additional details about the event. |
Methods
new pub
#![allow(unused)]
fn main() {
fn new (agent_id : Uuid , deployment_object_id : Uuid , event_type : String , status : String , message : Option < String > ,) -> Result < Self , String >
}
Creates a new NewAgentEvent instance.
Parameters:
| Name | Type | Description |
|---|---|---|
agent_id | - | UUID of the agent associated with this event. |
deployment_object_id | - | UUID of the deployment object associated with this event. |
event_type | - | Type of the event. Must be a non-empty string. |
status | - | Status of the event. Must be one of: “SUCCESS”, “FAILURE”. |
message | - | Optional message providing additional details about the event. |
Returns:
Returns Ok(NewAgentEvent) if all parameters are valid, otherwise returns an Err with a description of the validation failure.
Source
#![allow(unused)]
fn main() {
pub fn new(
agent_id: Uuid,
deployment_object_id: Uuid,
event_type: String,
status: String,
message: Option<String>,
) -> Result<Self, String> {
// Validate agent_id
if agent_id.is_nil() {
return Err("Invalid agent ID".to_string());
}
// Validate deployment_object_id
if deployment_object_id.is_nil() {
return Err("Invalid deployment object ID".to_string());
}
// Validate event_type
if event_type.trim().is_empty() {
return Err("Event type cannot be empty".to_string());
}
// Validate status
let valid_statuses = ["SUCCESS", "FAILURE"];
if !valid_statuses.contains(&status.as_str()) {
return Err(format!(
"Invalid status. Must be one of: {}",
valid_statuses.join(", ")
));
}
Ok(NewAgentEvent {
agent_id,
deployment_object_id,
event_type,
status,
message,
})
}
}