brokkr-models::models::agents Rust
Structs
brokkr-models::models::agents::Agent
pub
Derives: Queryable, Selectable, Identifiable, AsChangeset, Debug, Clone, Serialize, Deserialize, Eq, PartialEq, Hash, ToSchema, ``
Represents an agent in the database.
Fields
| Name | Type | Description |
|---|---|---|
id | Uuid | Unique identifier for the agent. |
created_at | DateTime < Utc > | Timestamp when the agent was created. |
updated_at | DateTime < Utc > | Timestamp when the agent was last updated. |
deleted_at | Option < DateTime < Utc > > | Timestamp for soft deletion, if applicable. |
name | String | Name of the agent. |
cluster_name | String | Name of the cluster the agent belongs to. |
last_heartbeat | Option < DateTime < Utc > > | Timestamp of the last heartbeat received from the agent. |
status | String | Current status of the agent. |
pak_hash | String | Hash of the agent’s Pre-shared Authentication Key (PAK). |
brokkr-models::models::agents::NewAgent
pub
Derives: Insertable, Debug, Clone, Serialize, Deserialize, ToSchema
Represents a new agent to be inserted into the database.
Fields
| Name | Type | Description |
|---|---|---|
name | String | Name of the agent. |
cluster_name | String | Name of the cluster the agent belongs to. |
Methods
new pub
#![allow(unused)]
fn main() {
fn new (name : String , cluster_name : String) -> Result < Self , String >
}
Creates a new NewAgent instance.
Parameters:
| Name | Type | Description |
|---|---|---|
name | - | Name of the agent. Must be a non-empty string. |
cluster_name | - | Name of the cluster the agent belongs to. Must be a non-empty string. |
Returns:
Returns Ok(NewAgent) if both parameters are valid non-empty strings, otherwise returns an Err with a description of the validation failure.
Source
#![allow(unused)]
fn main() {
pub fn new(name: String, cluster_name: String) -> Result<Self, String> {
// Validate name
if name.trim().is_empty() {
return Err("Agent name cannot be empty".to_string());
}
// Validate cluster_name
if cluster_name.trim().is_empty() {
return Err("Cluster name cannot be empty".to_string());
}
Ok(NewAgent { name, cluster_name })
}
}