Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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

NameTypeDescription
idUuidUnique identifier for the diagnostic request.
agent_idUuidThe agent that should handle this request.
deployment_object_idUuidThe deployment object to gather diagnostics for.
statusStringStatus: pending, claimed, completed, failed, expired.
requested_byOption < String >Who requested the diagnostics (e.g., operator username).
created_atDateTime < Utc >When the request was created.
claimed_atOption < DateTime < Utc > >When the agent claimed the request.
completed_atOption < DateTime < Utc > >When the request was completed.
expires_atDateTime < 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

NameTypeDescription
agent_idUuidThe agent that should handle this request.
deployment_object_idUuidThe deployment object to gather diagnostics for.
statusStringStatus (defaults to “pending”).
requested_byOption < String >Who requested the diagnostics.
expires_atDateTime < 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:

NameTypeDescription
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

NameTypeDescription
statusOption < String >New status.
claimed_atOption < DateTime < Utc > >When claimed.
completed_atOption < DateTime < Utc > >When completed.