#[non_exhaustive]pub struct AgentPolicy {
pub id: String,
pub name: String,
pub namespace: String,
pub revision: u64,
pub description: Option<String>,
pub status: Option<String>,
pub agents: Option<u64>,
pub package_policies: Vec<Value>,
pub extra: Map<String, Value>,
}Expand description
An agent policy returned by Fleet, grouping the integrations assigned to agents.
Use Self::edit to change a retrieved policy while retaining its inactivity
timeout. Debug output counts package policies instead of printing them,
since their variables can hold credentials.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.id: String§name: String§namespace: StringNamespace used for the policy’s data streams, independent of the Kibana space.
revision: u64Configuration delivery revision. Fleet does not use it to reject concurrent edits.
description: Option<String>§status: Option<String>§agents: Option<u64>Present when listed with agent counts.
package_policies: Vec<Value>Populated when listed with full policies.
extra: Map<String, Value>Unmodeled response fields. An edit resubmits only the supported writable fields.
Implementations§
Source§impl AgentPolicy
impl AgentPolicy
Sourcepub fn edit(&self) -> Result<AgentPolicyEdit>
pub fn edit(&self) -> Result<AgentPolicyEdit>
Changes to this policy, bound to its ID. Required name and namespace start from the retrieved values. The inactivity timeout is retained because Kibana resets it to two weeks when it is omitted from an update. Other settings are left unchanged unless their setter is called.
Returns Error::InvalidRequest if extra["inactivity_timeout"] is
missing or is not an unsigned integer. Fetch the policy again rather
than guessing its timeout.
Fleet agent-policy updates do not enforce optimistic concurrency;
revision tracks configuration delivery to agents.
Renaming retains the timeout and leaves other optional settings unset:
use security_client_rs::fleet::AgentPolicy;
use serde_json::{from_value, json, to_value};
let policy: AgentPolicy = from_value(json!({
"id": "policy-a", "name": "Endpoints", "namespace": "default",
"revision": 3, "inactivity_timeout": 3600, "description": "Keep this"
}))?;
let body = to_value(policy.edit()?.name("SOC endpoints"))?;
assert_eq!(body, json!({
"name": "SOC endpoints", "namespace": "default", "inactivity_timeout": 3600
}));To apply an edit:
let fleet = client.fleet();
let policy = fleet.get_agent_policy("policy-id").send().await?.json().await?.item;
let edit = policy.edit()?.name("SOC endpoints").clear_data_output_id();
fleet.edit_agent_policy(&edit).send().await?;