brokkr-models::models::diagnostic_requests
Rust
Diagnostic Request model for on-demand diagnostic requests.
Diagnostic requests are created by operators to request detailed diagnostic information from agents about specific deployment objects.
Structs
Section titled “Structs”struct DiagnosticRequest
Section titled “struct DiagnosticRequest”pub
Derives: Debug, Clone, Queryable, Selectable, Identifiable, Serialize, Deserialize, ToSchema
A diagnostic request record from the database.
Fields
Section titled “Fields”| Name | Type | Description |
|---|---|---|
id |
Uuid |
Unique identifier for the diagnostic request. |
agent_id |
Uuid |
The agent that should handle this request. |
deployment_object_id |
Uuid |
The deployment object to gather diagnostics for. |
status |
String |
Status: pending, claimed, completed, failed, expired. |
requested_by |
Option<String> |
Who requested the diagnostics (e.g., operator username). |
created_at |
DateTime<Utc> |
When the request was created. |
claimed_at |
Option<DateTime<Utc>> |
When the agent claimed the request. |
completed_at |
Option<DateTime<Utc>> |
When the request was completed. |
expires_at |
DateTime<Utc> |
When the request expires and should be cleaned up. |
struct NewDiagnosticRequest
Section titled “struct NewDiagnosticRequest”pub
Derives: Debug, Clone, Insertable, Serialize, Deserialize
A new diagnostic request to be inserted.
Fields
Section titled “Fields”| Name | Type | Description |
|---|---|---|
agent_id |
Uuid |
The agent that should handle this request. |
deployment_object_id |
Uuid |
The deployment object to gather diagnostics for. |
status |
String |
Status (defaults to “pending”). |
requested_by |
Option<String> |
Who requested the diagnostics. |
expires_at |
DateTime<Utc> |
When the request expires. |
Methods
Section titled “Methods”pub
fn new( agent_id: Uuid, deployment_object_id: Uuid, requested_by: Option<String>, retention_minutes: Option<i64>,) -> Result<Self, String>Creates a new diagnostic request.
Parameters:
| Name | Type | Description |
|---|---|---|
agent_id |
Uuid |
The agent that should handle this request. |
deployment_object_id |
Uuid |
The deployment object to gather diagnostics for. |
requested_by |
Option<String> |
Optional identifier of who requested the diagnostics. |
retention_minutes |
Option<i64> |
How long the request should be retained (default 60). |
Returns:
A Result containing the new diagnostic request or an error.
Source
pub fn new( agent_id: Uuid, deployment_object_id: Uuid, requested_by: Option<String>, retention_minutes: Option<i64>, ) -> Result<Self, String> { // Validate UUIDs are not nil if agent_id.is_nil() { return Err("Agent ID cannot be nil".to_string()); } if deployment_object_id.is_nil() { return Err("Deployment object ID cannot be nil".to_string()); }
let retention = retention_minutes.unwrap_or(60); if !(1..=1440).contains(&retention) { return Err("Retention must be between 1 and 1440 minutes".to_string()); }
let expires_at = Utc::now() + Duration::minutes(retention);
Ok(Self { agent_id, deployment_object_id, status: "pending".to_string(), requested_by, expires_at, }) }struct UpdateDiagnosticRequest
Section titled “struct UpdateDiagnosticRequest”pub
Derives: Debug, Clone, AsChangeset
Changeset for updating a diagnostic request.
Fields
Section titled “Fields”| Name | Type | Description |
|---|---|---|
status |
Option<String> |
New status. |
claimed_at |
Option<DateTime<Utc>> |
When claimed. |
completed_at |
Option<DateTime<Utc>> |
When completed. |
Constants
Section titled “Constants”| Name | Type | Value | Description |
|---|---|---|---|
VALID_STATUSES |
&[&str] |
&["pending", "claimed", "completed", "failed", "expired"] |
Valid diagnostic request statuses |