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
brokkr-models::models::diagnostic_requests::DiagnosticRequest
pub
Derives: Debug, Clone, Queryable, Selectable, Identifiable, Serialize, Deserialize, ToSchema
A diagnostic request record from the database.
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. |
brokkr-models::models::diagnostic_requests::NewDiagnosticRequest
pub
Derives: Debug, Clone, Insertable, Serialize, Deserialize
A new diagnostic request to be inserted.
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
new pub
#![allow(unused)]
fn main() {
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 | - | The agent that should handle this request. |
deployment_object_id | - | The deployment object to gather diagnostics for. |
requested_by | - | Optional identifier of who requested the diagnostics. |
retention_minutes | - | How long the request should be retained (default 60). |
Returns:
A Result containing the new diagnostic request or an error.
Source
#![allow(unused)]
fn main() {
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,
})
}
}
brokkr-models::models::diagnostic_requests::UpdateDiagnosticRequest
pub
Derives: Debug, Clone, AsChangeset
Changeset for updating a diagnostic request.
Fields
| Name | Type | Description |
|---|---|---|
status | Option < String > | New status. |
claimed_at | Option < DateTime < Utc > > | When claimed. |
completed_at | Option < DateTime < Utc > > | When completed. |